Skip to content

Commit

Permalink
Merge pull request #218 from kglidic/NIRCam_tutorial_updates
Browse files Browse the repository at this point in the history
Fix to read in files faster
  • Loading branch information
AarynnCarter authored Oct 4, 2024
2 parents 86461a9 + 37751e6 commit bac0445
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions spaceKLIP/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,13 @@ def read_jwst_s012_data(self,
else:
allpaths = np.array(datapaths)
Nallpaths = len(allpaths)

for i in range(Nallpaths):
hdul = pyfits.open(allpaths[i])
head = hdul[0].header
data = hdul['SCI'].data
# Only read in the data if needed.
data = hdul['SCI'].data if not head.get('NINTS') else None

if 'uncal' in allpaths[i]:
DATAMODL += ['STAGE0']
elif 'rate' in allpaths[i] or 'rateints' in allpaths[i]:
Expand Down Expand Up @@ -248,7 +251,7 @@ def read_jwst_s012_data(self,
raise UserWarning('Data originates from unknown telescope')
EXP_TYPE += [head.get('EXP_TYPE', 'UNKNOWN')]
EXPSTART += [head.get('EXPSTART', np.nan)]
NINTS += [head.get('NINTS', data.shape[0] if data.ndim == 3 else 1)]
NINTS += [head.get('NINTS', data.shape[0] if data is not None and data.ndim == 3 else 1)]
EFFINTTM += [head.get('EFFINTTM', np.nan)]
IS_PSF += [head.get('IS_PSF', 'NONE')]
SELFREF += [head.get('SELFREF', 'NONE')]
Expand Down

0 comments on commit bac0445

Please sign in to comment.