Exemplo n.º 1
0
 def calc_age_pdf(self,fehdist='casagrande'):
     """
     NAME:
        calc_age_pdf
     PURPOSE:
        calculate the age PDF for a uniform SFH for a given metallicity 
        distribution
     INPUT:
        fehdist= either:
           1) a single metallicity 
           2) 'casagrande': local metallicity distribution following Casagrande et al. (2011)
           3) a function giving
     OUTPUT:
         a function between 800 Myr and 10 Gyr giving the age distribution
     HISTORY:
        2014-02-27 - Written in this form - Bovy (IAS)
     """
     if isinstance(fehdist,(int,float,numpy.float32,numpy.float64)):
         pz= numpy.zeros(len(self._zs))
         pz[numpy.argmin(numpy.fabs(self._zs-isodist.FEH2Z(fehdist,zsolar=zsolar())))]= 1.
     elif isinstance(fehdist,str) and fehdist.lower() == 'casagrande':
         pz= numpy.array([localfehdist(isodist.Z2FEH(z,zsolar=zsolar()))/z for z in self._zs])
     else:
         pz= numpy.array([fehdist(isodist.Z2FEH(z,zsolar=zsolar()))/z for z in self._zs])
     pz/= numpy.sum(pz)
     agezdist= self._omega/self._coarsemass
     pz= numpy.tile(pz,(len(self._coarselages),1)).T
     postage= numpy.nansum(pz*agezdist,axis=0)/numpy.nansum(pz,axis=0)/10.**self._coarselages
     postage= postage[self._coarselages > numpy.log10(0.8)]
     postage/= numpy.nanmax(postage)
     lages= self._coarselages[self._coarselages > numpy.log10(0.8)]
     postage_spline= interpolate.InterpolatedUnivariateSpline(lages,
                                                              numpy.log(postage),
                                                              k=3)
     return lambda x: dummy_page(x,copy.copy(postage_spline))
Exemplo n.º 2
0
 def calc_age_pdf(self,fehdist='casagrande'):
     """
     NAME:
        calc_age_pdf
     PURPOSE:
        calculate the age PDF for a uniform SFH for a given metallicity 
        distribution
     INPUT:
        fehdist= either:
           1) a single metallicity 
           2) 'casagrande': local metallicity distribution following Casagrande et al. (2011)
           3) a function giving
     OUTPUT:
         a function between 800 Myr and 10 Gyr giving the age distribution
     HISTORY:
        2014-02-27 - Written in this form - Bovy (IAS)
     """
     if isinstance(fehdist,(int,float,numpy.float32,numpy.float64)):
         pz= numpy.zeros(len(self._zs))
         pz[numpy.argmin(numpy.fabs(self._zs-isodist.FEH2Z(fehdist,zsolar=zsolar())))]= 1.
     elif isinstance(fehdist,str) and fehdist.lower() == 'casagrande':
         pz= numpy.array([localfehdist(isodist.Z2FEH(z,zsolar=zsolar()))/z for z in self._zs])
     else:
         pz= numpy.array([fehdist(isodist.Z2FEH(z,zsolar=zsolar()))/z for z in self._zs])
     pz/= numpy.sum(pz)
     agezdist= self._omega/self._coarsemass
     pz= numpy.tile(pz,(len(self._coarselages),1)).T
     postage= numpy.nansum(pz*agezdist,axis=0)/numpy.nansum(pz,axis=0)/10.**self._coarselages
     postage= postage[self._coarselages > numpy.log10(0.8)]
     postage/= numpy.nanmax(postage)
     lages= self._coarselages[self._coarselages > numpy.log10(0.8)]
     postage_spline= interpolate.InterpolatedUnivariateSpline(lages,
                                                              numpy.log(postage),
                                                              k=3)
     return lambda x: dummy_page(x,copy.copy(postage_spline))
Exemplo n.º 3
0
def Gdist(tG, ZG):
    """The distribution of G for the local metallicity distribution
    REWRITE TO TAKE A Z(G) FUNCTION OBTAINED THROUGH INTERPOLATION"""
    try:
        tZ = ZG(tG)
        tjac = numpy.fabs(ZG.derivatives(tG)[0] / tZ / numpy.log(10.))
    except ValueError:
        return 0.
    # Add Jacobian
    return localfehdist(isodist.Z2FEH(tZ, zsolar=0.017)) * tjac
Exemplo n.º 4
0
def Gdist(tG, ZG):
    """The distribution of G for the local metallicity distribution
    REWRITE TO TAKE A Z(G) FUNCTION OBTAINED THROUGH INTERPOLATION"""
    try:
        tZ = ZG(tG)
        tjac = numpy.fabs(ZG.derivatives(tG)[0] / tZ / numpy.log(10.0))
    except ValueError:
        return 0.0
    # Add Jacobian
    return localfehdist(isodist.Z2FEH(tZ, zsolar=0.017)) * tjac