Skip to content

Commit

Permalink
add Gaia bandpasses and cleanup MANIFEST + loading from file
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarayan committed Oct 6, 2018
1 parent 46a1063 commit e79a403
Show file tree
Hide file tree
Showing 7 changed files with 6,931 additions and 14 deletions.
21 changes: 12 additions & 9 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
include WDmodel/TlustyGrids.hdf5
include WDmodel/WDmodel_param_defaults.json
include WDmodel/WDmodel_pb_obsmode_map.txt
include WDmodel/reddening_custom.txt
graft WDmodel/tests/
graft WDmodel/passbands/
include tesh.sh
include test_WDmodel.py
include LICENSE
exclude docs/_build
exclude docs/api
exclude build/
exclude cache/
exclude products/
exclude dist/
exclude src/
graft docs/
global-include *.txt
global-include *.rst
global-include *.md
Expand All @@ -20,8 +18,13 @@ global-exclude *.prof
global-exclude *.swp
global-exclude *.png
global-exclude out*/*
graft docs/
graft WDmodel/tests/
exclude docs/_build
exclude docs/api
exclude build/
exclude cache/
exclude products/
exclude dist/
exclude src/
prune scripts/
prune data/
prune WDdata/
3 changes: 3 additions & 0 deletions WDmodel/WDmodel_pb_obsmode_map.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ sdssg passbands/SDSS/sdss_g.dat abmag 0.
sdssr passbands/SDSS/sdss_r.dat abmag 0.
sdssi passbands/SDSS/sdss_i.dat abmag 0.
sdssz passbands/SDSS/sdss_z.dat abmag 0.
gaia_g passbands/Gaia/gaia_g.dat vegamag 0.
gaia_bp passbands/Gaia/gaia_bp.dat vegamag 0.
gaia_rp passbands/Gaia/gaia_rp.dat vegamag 0.
6 changes: 5 additions & 1 deletion WDmodel/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,11 @@ def get_pkgfile(infile):
model grid file.
"""

pkgfile = pkg_resources.resource_filename('WDmodel',infile)
try:
pkgfile = pkg_resources.resource_filename('WDmodel',infile)
except KeyError as e:
message = 'Could not find package file {}'.format(infile)
raise IOError(message)

if not os.path.exists(pkgfile):
message = 'Could not find package file {}'.format(pkgfile)
Expand Down
19 changes: 15 additions & 4 deletions WDmodel/passband.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,19 +357,30 @@ def get_pbmodel(pbnames, model, pbfile=None, mag_type=None, mag_zero=0.):
message = 'Unknown standard system {} for passband {}'.format(magsys, pb)
raise RuntimeError(message)

loadedpb = False
# treat the passband as a obsmode string
try:
bp = S.ObsBandpass(obsmode)
loadedpb = True
except ValueError:
# if that fails, try to load the passband interpreting obsmode as a file
message = 'Could not load pb {} as an obsmode string {}'.format(pb, obsmode)
warnings.warn(message, RuntimeWarning)
bandpassfile = io.get_filepath(obsmode)
loadedpb = False

# if that fails, try to load the passband interpreting obsmode as a file
if not loadedpb:
try:
bandpassfile = io.get_filepath(obsmode)
bp = S.FileBandpass(bandpassfile)
except ValueError:
loadedpb = True
except Exception as e:
message = 'Could not load passband {} from obsmode or file {}'.format(pb, obsmode)
raise RuntimeError(message)
warnings.warn(message, RuntimeWarning)
loadedpb = False

if not loadedpb:
message = 'Could not load passband {}. Giving up.'.format(pb)
raise RuntimeError(message)

avgwave = bp.avgwave()
if standard.wave.min() > model._wave.min():
Expand Down

0 comments on commit e79a403

Please sign in to comment.