def build_model(binNum=0,
                fit_metallicity=1,
                fit_redshift=1,
                infile=None,
                add_neb=0,
                **extras):

    from astropy.table import Table
    from prospect.models.priors import LogUniform, TopHat, Normal
    from prospect.models.sedmodel import SedModel
    from prospect.models.templates import TemplateLibrary
    from prospect.sources.constants import cosmo

    table = Table.read(infile)
    zobs = table['z'][binNum]
    max_age = cosmo.age(zobs).value

    model_params = TemplateLibrary['parametric_sfh']  # delay-tau model

    model_params['zred']['init'] = zobs
    model_params['zred']['isfree'] = bool(fit_redshift)
    model_params['zred']['prior'] = TopHat(mini=zobs - 0.01, maxi=zobs + 0.01)

    model_params['mass']['init'] = 1e7
    model_params['mass']['prior'] = LogUniform(mini=1e5, maxi=1e9)

    model_params['logzsol']['init'] = -0.15
    model_params['logzsol']['isfree'] = bool(fit_metallicity)
    model_params['logzsol']['prior'] = Normal(mean=-0.15, sigma=0.22)

    model_params['dust2']['init'] = 0.3
    model_params['dust2']['prior'] = TopHat(mini=0.0, maxi=2.0)

    model_params['tage']['init'] = 6.24
    model_params['tage']['prior'] = TopHat(mini=0.001, maxi=max_age)

    model_params['tau']['init'] = 0.29
    model_params['tau']['prior'] = LogUniform(mini=0.1, maxi=10)

    model_params['imf_type']['init'] = 1  # Chabrier (2003) IMF
    model_params['dust_type']['init'] = 1  # Cardelli+ (1989) MW extinction

    if add_neb:
        model_params.update(TemplateLibrary['nebular'])

    model = SedModel(model_params)

    return model
Beispiel #2
0
def build_model(binNum=0, fit_metallicity=1, fit_redshift=1, infile=None,
                **extras) :
    
    import numpy as np
    from astropy.table import Table
    from prospect.models.priors import StudentT, TopHat
    from prospect.models.sedmodel import SedModel
    from prospect.models.templates import TemplateLibrary
    
    table = Table.read(infile)
    zobs = table['z'][binNum]
    nbins = 10
    
    model_params = TemplateLibrary['continuity_sfh'] # non-parametric SFH
    
    model_params['zred']['init'] = zobs
    model_params['zred']['isfree'] = bool(fit_redshift)
    model_params['zred']['prior'] = TopHat(mini=zobs-0.01, maxi=zobs+0.01)
    
    model_params['logmass']['init'] = 6
    model_params['logmass']['prior'] = TopHat(mini=3, maxi=16)
    model_params['mass']['N'] = nbins
    
    model_params['logzsol']['init'] = -0.5
    model_params['logzsol']['isfree'] = bool(fit_metallicity)
    model_params['logzsol']['prior'] = TopHat(mini=-2, maxi=0.2)
    
    model_params['dust2']['init'] = 0.5
    model_params['dust2']['prior'] = TopHat(mini=0.0, maxi=4.0)
    
    model_params['agebins']['N'] = nbins
    model_params['agebins']['init'] = [[0.0, 7.47712125], [7.47712125, 8.0],
        [8.0, 8.69897], [8.69897, 9.0], [9.0, 9.5261747], [9.5261747, 9.75720267],
        [9.75720267,  9.90720604], [9.90720604, 10.01848862],
        [10.01848862, 10.10699395], [10.10699395, 10.12927034]]
    
    model_params['logsfr_ratios']['N'] = nbins - 1
    model_params['logsfr_ratios']['init'] = np.full(nbins-1, 0.0)
    model_params['logsfr_ratios']['prior'] = StudentT(mean=np.full(nbins-1,0.0),
                                                      scale=np.full(nbins-1,0.3),
                                                      df=np.full(nbins-1, 2))
    
    model_params['imf_type']['init'] = 1 # Chabrier (2003) IMF
    model_params['dust_type']['init'] = 1 # Cardelli+ (1989) MW extinction
    
    model = SedModel(model_params)
    
    return model
Beispiel #3
0
def build_model(binNum=0,
                fit_metallicity=1,
                fit_redshift=1,
                infile=None,
                add_neb=0,
                metalfile=None,
                cluster=None,
                ID=0,
                **extras):

    import numpy as np
    from astropy.table import Table
    from prospect.models.priors import ClippedNormal, StudentT, TopHat
    from prospect.models.sedmodel import SedModel
    from prospect.models.templates import TemplateLibrary
    from prospect.sources.constants import cosmo

    table = Table.read(infile)
    zobs = table['z'][binNum]
    max_age, nbins = cosmo.age(zobs).value, 10

    # sma, smb = table['sma'][binNum], table['smb'][binNum]
    # R_e, width = table['R_e'][binNum], table['width'][binNum]
    # radius = (sma - width)*np.sqrt(smb/sma)/R_e

    metallicities = Table.read(metalfile)
    idx = np.where((metallicities['cluster'] == cluster)
                   & (metallicities['ID'] == ID))[0][0]
    central_metallicity = metallicities['centrallogZ'][idx]
    sigma_metallicity = metallicities['sigma'][idx]
    init_metallicity = central_metallicity  # - 0.1*radius

    model_params = TemplateLibrary['continuity_sfh']  # non-parametric model

    model_params['zred']['init'] = zobs
    model_params['zred']['isfree'] = bool(fit_redshift)
    model_params['zred']['prior'] = TopHat(mini=zobs - 0.01, maxi=zobs + 0.01)

    model_params['logmass']['init'] = 7
    model_params['logmass']['prior'] = TopHat(mini=5, maxi=10)
    model_params['mass']['N'] = nbins

    model_params['logzsol']['init'] = init_metallicity
    model_params['logzsol']['isfree'] = bool(fit_metallicity)
    model_params['logzsol']['prior'] = ClippedNormal(mean=init_metallicity,
                                                     sigma=sigma_metallicity,
                                                     mini=-2,
                                                     maxi=0.2)

    model_params['dust2']['init'] = 0.3
    model_params['dust2']['prior'] = TopHat(mini=0.0, maxi=2.0)

    model_params['agebins']['N'] = nbins
    agelims = np.concatenate([
        np.log10([1e-9, 0.03, 0.1, 0.5]),
        np.linspace(0, np.log10(0.95 * max_age), 6),
        np.log10([max_age])
    ]) + 9
    model_params['agebins']['init'] = np.array([agelims[:-1], agelims[1:]]).T

    model_params['logsfr_ratios']['N'] = nbins - 1
    model_params['logsfr_ratios']['init'] = np.zeros(nbins - 1)
    model_params['logsfr_ratios']['prior'] = StudentT(
        mean=np.zeros(nbins - 1),
        scale=0.3 * np.ones(nbins - 1),
        df=2 * np.ones(nbins - 1))

    model_params['imf_type']['init'] = 1  # Chabrier (2003) IMF
    model_params['dust_type']['init'] = 1  # Cardelli+ (1989) MW extinction

    if add_neb:
        model_params.update(TemplateLibrary['nebular'])

    model = SedModel(model_params)

    return model
Beispiel #4
0
def build_model(binNum=0,
                fit_metallicity=1,
                fit_redshift=1,
                infile=None,
                add_neb=0,
                metalfile=None,
                cluster=None,
                ID=0,
                **extras):

    import numpy as np
    from astropy.table import Table
    from prospect.models.priors import ClippedNormal, LogUniform, TopHat
    from prospect.models.sedmodel import SedModel
    from prospect.models.templates import TemplateLibrary
    from prospect.sources.constants import cosmo

    table = Table.read(infile)
    zobs = table['z'][binNum]
    max_age = cosmo.age(zobs).value

    sma, smb = table['sma'][binNum], table['smb'][binNum]
    R_e, width = table['R_e'][binNum], table['width'][binNum]
    radius = (sma - width) * np.sqrt(smb / sma) / R_e

    metallicities = Table.read(metalfile)
    idx = np.where((metallicities['cluster'] == cluster)
                   & (metallicities['ID'] == ID))[0][0]
    central_metallicity = metallicities['centrallogZ'][idx]
    sigma_metallicity = metallicities['sigma'][idx]
    init_metallicity = central_metallicity - 0.1 * radius

    model_params = TemplateLibrary['parametric_sfh']  # delay-tau model

    model_params['zred']['init'] = zobs
    model_params['zred']['isfree'] = bool(fit_redshift)
    model_params['zred']['prior'] = TopHat(mini=zobs - 0.01, maxi=zobs + 0.01)

    model_params['mass']['init'] = 1e7
    model_params['mass']['prior'] = LogUniform(mini=1e5, maxi=1e10)

    model_params['logzsol']['init'] = init_metallicity
    model_params['logzsol']['isfree'] = bool(fit_metallicity)
    model_params['logzsol']['prior'] = ClippedNormal(mean=init_metallicity,
                                                     sigma=sigma_metallicity,
                                                     mini=-2,
                                                     maxi=0.2)

    model_params['dust2']['init'] = 0.3
    model_params['dust2']['prior'] = TopHat(mini=0.0, maxi=2.0)

    model_params['tage']['init'] = 6.24
    model_params['tage']['prior'] = TopHat(mini=0.001, maxi=max_age)

    model_params['tau']['init'] = 0.29
    model_params['tau']['prior'] = LogUniform(mini=0.1, maxi=10)

    model_params['imf_type']['init'] = 1  # Chabrier (2003) IMF
    model_params['dust_type']['init'] = 1  # Cardelli+ (1989) MW extinction

    if add_neb:
        model_params.update(TemplateLibrary['nebular'])

    model = SedModel(model_params)

    return model