Skip to content

Commit

Permalink
MAINT: Don't use importlib.resources.files as a context manager (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrjbca authored Dec 10, 2024
1 parent 5e53f77 commit 560d950
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions skypy/galaxies/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ class KCorrectTemplates(SpectrumTemplates):
'''

def __init__(self, hdu=1):
with resources.files('skypy') / 'data/kcorrect/k_nmf_derived.default.fits' as filename:
with fits.open(filename) as hdul:
self.templates = hdul[hdu].data * units.Unit('erg s-1 cm-2 angstrom-1')
self.wavelength = hdul[11].data * units.Unit('angstrom')
self.mass = hdul[16].data
self.mremain = hdul[17].data
self.mets = hdul[18].data
self.mass300 = hdul[19].data
self.mass1000 = hdul[20].data
filename = resources.files('skypy') / 'data/kcorrect/k_nmf_derived.default.fits'
with fits.open(filename) as hdul:
self.templates = hdul[hdu].data * units.Unit('erg s-1 cm-2 angstrom-1')
self.wavelength = hdul[11].data * units.Unit('angstrom')
self.mass = hdul[16].data
self.mremain = hdul[17].data
self.mets = hdul[18].data
self.mass300 = hdul[19].data
self.mass1000 = hdul[20].data

def stellar_mass(self, coefficients, magnitudes, filter):
r'''Compute stellar mass from absolute magnitudes in a reference filter.
Expand Down

0 comments on commit 560d950

Please sign in to comment.