Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ description = "Simple tools for astronomical spectral energy distributions, part
authors = [{ name = "Benjamin Johnson", email = "benjamin.johnson@cfa.harvard.edu" }]
readme = "README.rst"
license = { text = "MIT License" }
requires-python = ">=3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dynamic = ["version"]
dependencies = ["numpy", "astropy"]
dependencies = [
"numpy",
"astropy"
]

[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm"]
Expand Down
19 changes: 9 additions & 10 deletions sedpy/observate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
from numpy import trapz as trapezoid

import os
try:
from pkg_resources import resource_filename, resource_listdir
except(ImportError):
pass
from importlib.resources import files
from .reference_spectra import vega, solar, sedpydir


Expand Down Expand Up @@ -90,8 +87,9 @@ def __init__(self, kname='sdss_r0', nick=None,
if directory is None:
loc = os.path.join('data', 'filters', kname + '.par')
try:
self.filename = resource_filename("sedpy", loc)
except:
data_files = files('sedpy') / 'data' / 'filters'
self.filename = str(data_files / (kname + '.par'))
except Exception:
self.filename = os.path.join(sedpydir, loc)
else:
self.filename = os.path.join(directory, kname+'.par')
Expand Down Expand Up @@ -815,11 +813,12 @@ def list_available_filters():
have been installed in the sedpy/data/filters/ directory.
"""
try:
names = resource_listdir('sedpy', '/data/filters/')
except:
names = os.listdir(os.path.join(sedpydir, '/data/filters/'))
data_files = files('sedpy') / 'data' / 'filters'
names = [f.name for f in data_files.iterdir() if f.is_file()]
except Exception:
names = os.listdir(os.path.join(sedpydir, 'data', 'filters'))

parfiles = [n.replace('.par', '') for n in names if n[-4:] == '.par']
parfiles = [n.replace('.par', '') for n in names if n.endswith('.par')]
parfiles.sort()
return parfiles

Expand Down
15 changes: 7 additions & 8 deletions sedpy/reference_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

import numpy as np
import os
try:
from pkg_resources import resource_filename
except ImportError:
pass
from importlib.resources import files
try:
import astropy.io.fits as pyfits
except ImportError:
Expand All @@ -28,8 +25,9 @@
# This is from stsci calspec database ("calspec_ascii_review")
# C.f. https://ui.adsabs.harvard.edu/abs/2007ASPC..364..315B/abstract
# C.f. https://ui.adsabs.harvard.edu/abs/2014AJ....147..127B/abstract
vega_file = resource_filename('sedpy', 'data/alpha_lyr_stis_005.fits')
except:
data_files = files('sedpy') / 'data'
vega_file = str(data_files / 'alpha_lyr_stis_005.fits')
except Exception:
vega_file = os.path.join(sedpydir, 'data', 'alpha_lyr_stis_005.fits')

# This file should be in AA and erg/s/cm^2/AA
Expand All @@ -43,8 +41,9 @@
'spectrum at {0}'.format(vega_file))

try:
solar_file = resource_filename('sedpy', 'data/sun_kurucz93.fits')
except:
data_files = files('sedpy') / 'data'
solar_file = str(data_files / 'sun_kurucz93.fits')
except Exception:
solar_file = os.path.join(sedpydir, 'data', 'sun_kurucz93.fits')

# conversion to d=10 pc from 1 AU
Expand Down
Loading