Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- from astropy.io import fits
- import numpy as np
- import argparse
- import glob
- import sys
- import os
- def main():
- # parser = argparse.ArgumentParser(description="Creates a sigma image for GALFIT using inverse variance image")
- # parser.add_argument("ImageFile", help="Inverse variance image")
- # args = parser.parse_args()
- # image_file = args.ImageFile
- # if not os.path.exists(image_file):
- # print ('{} image filename does not exist!'.format(image_file))
- # sys.exit()
- convert_to_sigma()
- def convert_to_sigma():
- """
- Convert a inverse variance DESI image
- to sigma image for GALFIT
- """
- files = glob.glob("*wt.fits")
- for file in files:
- hdu = fits.open(file)
- data = hdu[0].data
- data[np.isnan(data)] = 1e7
- data_new = np.sqrt(data)
- hdu_new = fits.PrimaryHDU(data_new, hdu[0].header)
- hdu_new.header["IMTYPE"] = "sigma"
- hdu_new.header["BUNIT"] = "It is doesn't know"
- hdu_new.writeto(file.replace("wt", "sigma"), overwrite=True)
- hdu.close()
- print("Done!")
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement