def test_make_kurucz_tlusty_spectral_grid(): # download the needed files kurucz_fname = download_rename("kurucz2004.grid.fits") tlusty_fname = download_rename("tlusty.lowres.grid.fits") filter_fname = download_rename("filters.hd5") iso_fname = download_rename("beast_example_phat_iso.csv") # download cached version of spectral grid spec_fname_cache = download_rename("beast_example_phat_spec_grid.hd5") ################ # generate the same spectral grid from the code # read in the cached isochrones oiso = ezIsoch(iso_fname) # define the distance distances = [24.47] distance_unit = units.mag velocity = -300 * units.km / units.s redshift = (velocity / const.c).decompose().value # define the spectral libraries to use osl = stellib.Tlusty(filename=tlusty_fname) + stellib.Kurucz( filename=kurucz_fname) # define the extinction curve to use extLaw = extinction.Gordon16_RvFALaw() filters = [ "HST_WFC3_F275W", "HST_WFC3_F336W", "HST_ACS_WFC_F475W", "HST_ACS_WFC_F814W", "HST_WFC3_F110W", "HST_WFC3_F160W", ] add_spectral_properties_kwargs = dict(filternames=filters) spec_fname = "/tmp/beast_example_phat_spec_grid.hd5" spec_fname, g = make_spectral_grid( "test", oiso, osl=osl, redshift=redshift, distance=distances, distance_unit=distance_unit, spec_fname=spec_fname, filterLib=filter_fname, extLaw=extLaw, add_spectral_properties_kwargs=add_spectral_properties_kwargs, ) # compare the new to the cached version compare_hdf5(spec_fname_cache, spec_fname)
def test_extinction_generalRvFA_initialize(): tlaw = extinction.Generalized_RvFALaw() if not isinstance(tlaw, extinction.Generalized_RvFALaw): raise AssertionError("Should use Generalized_RvFALaw extinction") lam = np.linspace(2.0e3, 1.0e4, 10) tlaw_vals = tlaw(lam, Av=1.0, Rv=4.0, f_A=0.8) orig = extinction.Gordon16_RvFALaw() orig_vals = orig(lam, Av=1.0, Rv=4.0, f_A=0.8) np.testing.assert_allclose(tlaw_vals, orig_vals)
def test_make_extinguished_sed_grid(): # download the needed files priors_fname = download_rename("beast_example_phat_spec_w_priors.grid.hd5") filter_fname = download_rename("filters.hd5") # download cached version of sed grid seds_fname_cache = download_rename("beast_example_phat_seds.grid.hd5") ################ # generate the same extinguished SED grid from the code # Add in the filters filters = [ "HST_WFC3_F275W", "HST_WFC3_F336W", "HST_ACS_WFC_F475W", "HST_ACS_WFC_F814W", "HST_WFC3_F110W", "HST_WFC3_F160W", ] add_spectral_properties_kwargs = dict(filternames=filters) g_pspec = SpectralGrid(priors_fname, backend="memory") # generate the SED grid by integrating the filter response functions # effect of dust extinction applied before filter integration # also computes the dust priors as weights seds_fname = "/tmp/beast_example_phat_sed.grid.hd5" seds_fname, g_seds = make_extinguished_sed_grid( "test", g_pspec, filters, seds_fname=seds_fname, filterLib=filter_fname, extLaw=extinction.Gordon16_RvFALaw(), av=[0.0, 10.055, 1.0], rv=[2.0, 6.0, 1.0], fA=[0.0, 1.0, 0.25], av_prior_model={"name": "flat"}, rv_prior_model={"name": "flat"}, fA_prior_model={"name": "flat"}, add_spectral_properties_kwargs=add_spectral_properties_kwargs, ) # compare the new to the cached version compare_hdf5(seds_fname_cache, seds_fname)
# MISTWeb() -- `rotation` param (choices: vvcrit0.0=default, vvcrit0.4) # # Default: PARSEC+COLIBRI oiso = isochrone.PadovaWeb() # Alternative: PARSEC1.2S -- old grid parameters #oiso = isochrone.PadovaWeb(modeltype='parsec12s', filterPMS=True) # Alternative: MIST -- v1, no rotation #oiso = isochrone.MISTWeb() # Stellar Atmospheres library definition osl = stellib.Tlusty() + stellib.Kurucz() ################ ### Dust extinction grid definition extLaw = extinction.Gordon16_RvFALaw() # A(V): dust column in magnitudes # acceptable avs > 0.0 # example [min, max, step] = [0.0, 10.055, 1.0] avs = [0.0, 10.055, 1.0] av_prior_model = {'name': 'flat'} #av_prior_model = {'name': 'lognormal', # 'max_pos': 2.0, # 'sigma': 1.0, # 'N': 10.} # R(V): dust average grain size # example [min, max, step] = [2.0,6.0,1.0] rvs = [2.0, 6.0, 1.0] rv_prior_model = {'name': 'flat'}