Skip to content

Commit

Permalink
Merge pull request #53 from gbrammer/hdf5-cgm-bug
Browse files Browse the repository at this point in the history
Fix hdf5 bug with new cgm options
  • Loading branch information
gbrammer authored Dec 13, 2024
2 parents 078bada + f22d4cc commit 828db5a
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 131 deletions.
335 changes: 212 additions & 123 deletions docs/examples/HDFN-demo.ipynb

Large diffs are not rendered by default.

37 changes: 29 additions & 8 deletions eazy/hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
pass

from . import photoz
from . import param
from . import utils
from . import templates as templates_code

Expand Down Expand Up @@ -339,16 +340,36 @@ def __init__(self, h5file, verbose=True):
Om0=self.param['OMEGA_M'],
Ode0=self.param['OMEGA_L'],
Tcmb0=2.725, Ob0=0.048)

self.set_tempfilt()

if self.param['ADD_CGM'] in utils.TRUE_VALUES:
self.add_cgm = True

if 'ADD_CGM' in self.param:
if self.param['ADD_CGM'] in utils.TRUE_VALUES:
self.add_cgm = True
self.max_fuv_wav = 2000.
else:
self.add_cgm = False
self.max_fuv_wav = 1300

self.sigmoid_params = (
self.param['SIGMOID_PARAM1'],
self.param['SIGMOID_PARAM2'],
self.param['SIGMOID_PARAM3']
)

else:
self.add_cgm = False
self.param['ADD_CGM'] = False

sigmoid_params = (self.param['SIGMOID_PARAM1'], self.param['SIGMOID_PARAM2'], self.param['SIGMOID_PARAM3'])
self.sigmoid_params = sigmoid_params
defaults = param.EazyParam(verbose=False)

self.sigmoid_params = (
defaults['SIGMOID_PARAM1'],
defaults['SIGMOID_PARAM2'],
defaults['SIGMOID_PARAM3']
)

self.add_cgm = False
self.max_fuv_wav = 1300

self.set_tempfilt()


def info(self):
Expand Down
19 changes: 19 additions & 0 deletions eazy/tests/test_photoz.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ def test_hdf5():
"""
Test HDF5 save / recover state
"""
import matplotlib.pyplot as plt
plt.ioff()

global ez

from .. import hdf5
Expand All @@ -456,6 +459,22 @@ def test_hdf5():
assert(np.allclose(ez.zbest, new_ez.zbest))
assert(np.allclose(ez.lnp, new_ez.lnp, rtol=1.e-4))

_ = new_ez.show_fit(10)
plt.close('all')

# Compact viewer
h5 = hdf5.Viewer('test.hdf5')

assert(h5.NOBJ == new_ez.NOBJ)
assert(h5.NTEMP == new_ez.NTEMP)
assert(h5.NFILT == new_ez.NFILT)
assert(h5.NZ == new_ez.NZ)
assert(np.allclose(h5.zp, new_ez.zp))

_cat = h5.get_catalog()
_ = h5.show_fit(10)
plt.close('all')


def test_cleanup():

Expand Down

0 comments on commit 828db5a

Please sign in to comment.