Reputation: 147
I have the some files and I want to import them into specific arrays based on a part of their name.
dark_1s-001.fit
dark_1s-002.fit
dark_1s-003.fit
dark_5s-001.fit
dark_5s-002.fit
dark_5s-003.fit
My only real question is how I should change the arguments from glob.glob('*.fit') to discern between the '1s' and '5s' file attribute.
files_1s = glob.glob('*.fit')
files_5s = glob.glob('*.fit')
darks_1s = []
darks_5s = []
for f1, f2 in zip(files_1s, files_5s):
darks_1s.append(fits.getdata(f1))
darks_5s.append(fits.getdata(f1))
darks_1s = np.array(darks_1s)
darks_5s = np.array(darks_5s)
median_dark_1s = np.median(darks_1s, axis=0)
median_dark_5s = np.median(darks_5s, axis=0)
Upvotes: 0
Views: 294
Reputation: 36598
You can sandwich specific pieces of the file names that must exist into the glob string.
Try this:
files_1s = glob.glob('*1s-*.fit')
files_5s = glob.glob('*5s-*.fit')
Upvotes: 1