Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- import numpy as np
- import argparse
- import os
- from astropy.io import fits
- # Load your FITS file
- #hdul = fits.open('A407-pan-g-cut.fits')
- parser = argparse.ArgumentParser(description="removes nan pixels")
- parser.add_argument("ImageFile", help="Fits image file")
- 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()
- hdul = fits.open(image_file)
- # Access the CompImageHDU (assuming it's the first extension)
- # Extract the data
- data = hdul[0].data
- masknan = np.isnan(data)
- data[masknan] = 30000
- hdul[0].data= data
- hdul.writeto(image_file.replace("fits", "new.fits"), overwrite=True)
- hdul.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement