Esempio n. 1
0
def hden_ascii(fileout, **kwargs):
    # change these parameters to modify the ionizing source grid
    # default mode is to produce an ascii grid in age and Z,
    # though different variables and more dimensions are possible.
    sp_dict = dict(zcontinuous=1, imf_type=2, sfh=0, const=0.0, sf_start=0.0)
    sp = fsps.StellarPopulation(**sp_dict)
    # all ages and Zs
    ages = 10.**sp.log_age
    logZs = np.log10(old_div(sp.zlegend, zsun))
    print(ages, logZs)
    modpars = [(age, logZ) for age in ages for logZ in logZs]
    lam = sp.wavelengths
    all_fluxs = []
    for logZ in logZs:
        sp.params['logzsol'] = logZ
        all_fluxs.append(sp.get_spectrum()[1])  #lsun per hz
    nmod = len(modpars)
    # flatten flux for writing
    flat_flux = np.array(
        [all_fluxs[j][i] for i in range(len(ages)) for j in range(len(logZs))])
    # this function is flexible, ndim can be 3/4/n.
    # in this example, however, ndim is 2 (age, logz).
    writeASCII(fileout,
               lam,
               flat_flux,
               modpars,
               nx=len(lam),
               ndim=2,
               npar=2,
               nmod=nmod)
    return
Esempio n. 2
0
def fbhb_ascii(fileout, **kwargs):
    # change these parameters to modify the ionizing source grid
    # default mode is to produce an ascii grid in age and Z,
    # though different variables and more dimensions are possible.
    fbhb_fracs = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
    sp_dict = dict(zcontinuous=1,
                   imf_type=2,
                   sfh=0)
    sp = fsps.StellarPopulation(**sp_dict)
    # all ages, default solar metallicity
    ages = 10.**sp.log_age
    modpars = [(age, fb) for age in ages for fb in fbhb_fracs]
    lam = sp.wavelengths
    all_fluxs = []
    for fb in fbhb_fracs:
        sp.params["fbhb"] = fb
        all_fluxs.append(sp.get_spectrum()[1]) #lsun per hz
    nmod = len(modpars)
    # flatten flux for writing
    flat_flux = np.array([all_fluxs[j][i]
                          for i in range(len(ages))
                          for j in range(len(fbhb_fracs))])
    # this function is flexible, ndim can be 3/4/n.
    writeASCII(fileout, lam, flat_flux, modpars,
               nmod=nmod, ndim=2, npar=2,
               par1='age', par2='fbhb')
    return
Esempio n. 3
0
def fbhb_ascii(fileout, **kwargs):
    # change these parameters to modify the ionizing source grid
    # default mode is to produce an ascii grid in age and Z,
    # though different variables and more dimensions are possible.
    fbhb_fracs = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
    sp_dict = dict(zcontinuous=1,
                   imf_type=2,
                   sfh=0)
    sp = fsps.StellarPopulation(**sp_dict)
    # all ages, default solar metallicity
    ages = 10.**sp.log_age
    modpars = [(age, fb) for age in ages for fb in fbhb_fracs]
    lam = sp.wavelengths
    all_fluxs = []
    for fb in fbhb_fracs:
        sp.params["fbhb"] = fb
        all_fluxs.append(sp.get_spectrum()[1]) #lsun per hz
    nmod = len(modpars)
    # flatten flux for writing
    flat_flux = np.array([all_fluxs[j][i]
                          for i in range(len(ages))
                          for j in range(len(fbhb_fracs))])
    # this function is flexible, ndim can be 3/4/n.
    writeASCII(fileout, lam, flat_flux, modpars,
               nmod=nmod, ndim=2, npar=2,
               par1='age', par2='fbhb')
    return
Esempio n. 4
0
def mist_ascii(fileout, **kwargs):
    # change these parameters to modify the ionizing source grid
    # default mode is to produce an ascii grid in age and Z,
    # though different variables and more dimensions are possible.
    sp_dict = dict(zcontinuous=1,
                   imf_type=2,
                   sfh=0,
                   const=0.0,
                   sf_start=0.0)
    sp = fsps.StellarPopulation(**sp_dict)
    # all ages and Zs
    ages = 10.**sp.log_age
    logZs = np.log10(sp.zlegend/zsun)
    modpars = [(age, logZ) for age in ages for logZ in logZs]
    lam = sp.wavelengths
    all_fluxs = []
    for logZ in logZs:
        sp.params['logzsol'] = logZ
        all_fluxs.append(sp.get_spectrum()[1]) #lsun per hz
    nmod = len(modpars)
    # flatten flux for writing
    flat_flux = np.array([all_fluxs[j][i]
                          for i in range(len(ages))
                          for j in range(len(logZs))])
    # this function is flexible, ndim can be 3/4/n.
    writeASCII(fileout, lam, flat_flux, modpars,
               nx=len(lam), ndim=2, npar=2, nmod=nmod)
    return