Skip to content

Commit

Permalink
Use 'with' suggestion.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Aug 24, 2021
1 parent d21b2cb commit 5e03d26
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions python/lsst/obs/subaru/strayLight/yStrayLight.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,11 @@ class SubaruStrayLightData(StrayLightData):
@classmethod
def readFits(cls, filename, **kwargs):
calib = cls()
hdulist = fits.open(filename)

calib.ampData = []
for extension in (0, 1, 2, 3):
calib.ampData.append(hdulist[extension].data)
with fits.open(filename) as hdulist:
calib.ampData = [hdu.data for hdu in hdulist]
calib.setMetadata(hdulist[0].header)

calib.setMetadata(hdulist[0].header)

hdulist.close()
calib.log.info("Finished reading straylightData.")
return calib

Expand Down

0 comments on commit 5e03d26

Please sign in to comment.