################################################################################# # This code sorts a group of images based on the CMOS mode. import os import numpy as np from astropy.io import fits from astropy import units as u from astropy import constants as const from astropy.coordinates import SkyCoord from astropy.wcs import WCS from astropy.visualization.wcsaxes import WCSAxes from astropy import constants as const from astropy.modeling import models, fitting from astropy.io import ascii from astropy.nddata import Cutout2D import matplotlib.pyplot as plt import matplotlib as mpl from matplotlib.patches import Ellipse import astroquery import matplotlib.cm as cm import glob # ignore astropy warnings import warnings from astropy.utils.exceptions import AstropyWarning warnings.simplefilter('ignore', category=AstropyWarning) ################################################################################# ################################################################################# # Use glob to create list: image_dir = '/home/cannon/WASP43b-2024-016/' out_dir='/home/cannon/WASP43b-2024-016/' out_dir_high='/home/cannon/WASP43b-2024-016/high/' out_dir_spro='/home/cannon/WASP43b-2024-016/spro/' image_list = sorted(glob.glob(image_dir+'*.fits',recursive=True)) N_images = len(image_list) print('-----------------------------------------------------------') print(' --> '+str(N_images)+' images found in '+image_dir) print('-----------------------------------------------------------') ################################################################################# for i in range(0,len(image_list)): hdu = fits.open(image_list[i])[0] if hdu.header['READOUTM'] == 'High Gain StackPro': outname = str.split(imname,'.')[0]+'_spro.fits' out_filename = out_dir_spro+outname #hdu.writeto(out_filename, overwrite=True) print('Image #'+str(i)+' = '+str(out_filename)+' written to '+str(out_dir_spro+outname)) # else hdu.header['READOUTM'] != 'High Gain StackPro': # outname = str.split(imname,'.')[0]+'_high.fits'# # out_filename = out_dir_high+outname # hdu.writeto(out_filename, overwrite=True)# # print('Image #'+str(i)+' = '+str(out_filename)+' written to '+str(out_dir_high+outname))