Advertisement
canorve

Panstarrs var to sigma image

Jun 6th, 2024 (edited)
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | Source Code | 0 0
  1. #! /usr/bin/env python3
  2.  
  3. from astropy.io import fits
  4. import numpy as np
  5. import argparse
  6. import glob
  7. import sys
  8. import os
  9.  
  10. def main():
  11.     # parser = argparse.ArgumentParser(description="Creates a sigma image for GALFIT using inverse variance image")
  12.     # parser.add_argument("ImageFile", help="Inverse variance image")
  13.  
  14.     # args = parser.parse_args()
  15.     # image_file = args.ImageFile
  16.  
  17.     # if not os.path.exists(image_file):
  18.     #     print ('{} image filename does not exist!'.format(image_file))
  19.     #     sys.exit()
  20.  
  21.     convert_to_sigma()
  22.  
  23. def convert_to_sigma():
  24.     """
  25.    Convert a inverse variance DESI image
  26.    to sigma image for GALFIT
  27.    """
  28.     files = glob.glob("*wt.fits")
  29.    
  30.     for file in files:
  31.    
  32.             hdu = fits.open(file)
  33.             data = hdu[0].data
  34.             data[np.isnan(data)] = 1e7
  35.             data_new = np.sqrt(data)
  36.            
  37.             hdu_new = fits.PrimaryHDU(data_new, hdu[0].header)
  38.             hdu_new.header["IMTYPE"] = "sigma"
  39.             hdu_new.header["BUNIT"] = "It is doesn't know"
  40.             hdu_new.writeto(file.replace("wt", "sigma"), overwrite=True)
  41.            
  42.             hdu.close()
  43.      
  44.     print("Done!")
  45.      
  46. if __name__ == '__main__':
  47.     main()
Tags: panstarrs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement