I am using glob.glob make my script only read the data from certain FITS files (astropy.io.fits is brought in as pf and numpy as np). For this x is the value that I change to get these certain files (For reference the 'x = np.arrange(0) and y1 = np.arange(0) simply creates an empty array that I then fill with data later.
def Graph(Pass):
x = np.arange(0)
y1 = np.arange(0)
pathfile = '*_v0' + str(Pass) + '_stis_f25srf2_proj.fits'
for name in glob.glob(pathfile):
imn = 'FilePath' + str(name)
However, I wanted to add another filter to the files that I use. In each FITS file's header there is a quality I will call a. a is a non-integer numerical value that each file has. I only want to read files that have a within a specific range. I then take the data I need from the FITS file and add it to an array (for this is is 'power' p1 being added to y1 and 'time' t being added to x).
imh = pf.getheader(imn)
a = imh['a']
if (192 <= a <= 206) is False:
pass
if (192 <= a <= 206) is True:
im = pf.getdata(imn, origin='lower')
subim1 = im[340:390, 75:120]
p1 = np.mean(subim1)
t = SubfucntionToGetTime
y1 = np.append(y1, p1)
x = np.append(x, t)
However when I run this function it returns with arrays with no values. I believe it is something to do with my code not working properly when it encounters a file without the appropriate a value, but I can't know how to fix this.
For additional reference I have tested this for a smaller subgroup of FITS files that I know have the correct a values and it works fine, that is why I suspect it is experiencing a values that messes-up the code as the first few files don't have the correct a values.