isochrones/starmodel_old.py
def lnlike(self, p):
        """Log-likelihood of model at given parameters

        
        :param p: 
            mass_A, mass_B, log10(age), feh, [distance, A_V (extinction)].
            Final two should only be provided if ``self.fit_for_distance``
            is ``True``; that is, apparent magnitudes are provided.
            
        :return:
           log-likelihood.  Will be -np.inf if values out of range.
        
        """
        if not self._props_cleaned:
            self._clean_props()

        if not self.use_emcee:
            fit_for_distance = True
            mass_A, mass_B, age, feh, dist, AV = (p[0], p[1], p[2],
                                                  p[3], p[4], p[5])
        else:
            if len(p)==6:
                fit_for_distance = True
                mass_A, mass_B, age, feh, dist, AV = p
            elif len(p)==4:
                fit_for_distance = False
                mass_A, mass_B, age, feh = p
                        
        #keep values in range; enforce mass_A > mass_B
        if mass_A < self.ic.minmass or mass_A > self.ic.maxmass \
           or mass_B < self.ic.minmass or mass_B > self.ic.maxmass \
           or mass_B > mass_A \
           or age < self.ic.minage or age > self.ic.maxage \
           or feh < self.ic.minfeh or feh > self.ic.maxfeh:
            return -np.inf
        if fit_for_distance:
            if dist < 0 or AV < 0 or dist > self.max_distance:
                return -np.inf
            if AV > self.maxAV:
                return -np.inf

        if self.min_logg is not None:
            logg = self.ic.logg(mass_A,age,feh)
            if logg < self.min_logg:
                return -np.inf        

        logl = 0
        for prop in self.properties.keys():
            try:
                val,err = self.properties[prop]
            except TypeError:
                #property not appropriate for fitting (e.g. no error provided)
                continue
            m = re.search('delta_(\w+)',prop)
            if prop in self.ic.bands:
                if not fit_for_distance:
                    raise ValueError('must fit for mass, age, feh, dist, A_V '+
                                     'if apparent magnitudes provided.')
                mod_A = self.ic.mag[prop](mass_A,age,feh) + 5*np.log10(dist) - 5
                mod_B = self.ic.mag[prop](mass_B,age,feh) + 5*np.log10(dist) - 5
                A = AV*EXTINCTION[prop]
                mod_A += A
                mod_B += A
                mod = addmags(mod_A, mod_B)
            elif m:
                band = m.group(1)
                mod_A = self.ic.mag[band](mass_A,age,feh) + 5*np.log10(dist) - 5
                mod_B = self.ic.mag[band](mass_B,age,feh) + 5*np.log10(dist) - 5
                A = AV*EXTINCTION[band]
                mod_A += A
                mod_B += A
                mod = mod_B - mod_A
            elif prop=='feh':
                mod = feh
            elif prop=='mass_B':
                mod = mass_B
            elif prop=='parallax':
                mod = 1./dist * 1000
            else:
                mod = getattr(self.ic,prop)(mass_A,age,feh)

            logl += -(val-mod)**2/(2*err**2) + np.log(1/(err*np.sqrt(2*np.pi)))


        if np.isnan(logl):
            logl = -np.inf


        return logl
Log-likelihood of model at given parameters

        
        :param p: 
            mass_A, mass_B, log10(age), feh, [distance, A_V (extinction)].
            Final two should only be provided if ``self.fit_for_distance``
            is ``True``; that is, apparent magnitudes are provided.
            
        :return:
           log-likelihood.  Will be -np.inf if values out of range.
        
        
Log-likelihood of model at given parameters
Log - likelihood of model at given parameters
def lnlike(self, p):
        if not self._props_cleaned:
            self._clean_props()
        if not self.use_emcee:
            fit_for_distance = True
            mass_A, mass_B, age, feh, dist, AV = (p[0], p[1], p[2],
                                                  p[3], p[4], p[5])
        else:
            if len(p)==6:
                fit_for_distance = True
                mass_A, mass_B, age, feh, dist, AV = p
            elif len(p)==4:
                fit_for_distance = False
                mass_A, mass_B, age, feh = p
        if mass_A < self.ic.minmass or mass_A > self.ic.maxmass \
           or mass_B < self.ic.minmass or mass_B > self.ic.maxmass \
           or mass_B > mass_A \
           or age < self.ic.minage or age > self.ic.maxage \
           or feh < self.ic.minfeh or feh > self.ic.maxfeh:
            return -np.inf
        if fit_for_distance:
            if dist < 0 or AV < 0 or dist > self.max_distance:
                return -np.inf
            if AV > self.maxAV:
                return -np.inf
        if self.min_logg is not None:
            logg = self.ic.logg(mass_A,age,feh)
            if logg < self.min_logg:
                return -np.inf        
        logl = 0
        for prop in self.properties.keys():
            try:
                val,err = self.properties[prop]
            except TypeError:
                continue
            m = re.search('delta_(\w+)',prop)
            if prop in self.ic.bands:
                if not fit_for_distance:
                    raise ValueError('must fit for mass, age, feh, dist, A_V '+
                                     'if apparent magnitudes provided.')
                mod_A = self.ic.mag[prop](mass_A,age,feh) + 5*np.log10(dist) - 5
                mod_B = self.ic.mag[prop](mass_B,age,feh) + 5*np.log10(dist) - 5
                A = AV*EXTINCTION[prop]
                mod_A += A
                mod_B += A
                mod = addmags(mod_A, mod_B)
            elif m:
                band = m.group(1)
                mod_A = self.ic.mag[band](mass_A,age,feh) + 5*np.log10(dist) - 5
                mod_B = self.ic.mag[band](mass_B,age,feh) + 5*np.log10(dist) - 5
                A = AV*EXTINCTION[band]
                mod_A += A
                mod_B += A
                mod = mod_B - mod_A
            elif prop=='feh':
                mod = feh
            elif prop=='mass_B':
                mod = mass_B
            elif prop=='parallax':
                mod = 1./dist * 1000
            else:
                mod = getattr(self.ic,prop)(mass_A,age,feh)
            logl += -(val-mod)**2/(2*err**2) + np.log(1/(err*np.sqrt(2*np.pi)))
        if np.isnan(logl):
            logl = -np.inf
        return logl
def lnlike ( self , p ) : if not self . _props_cleaned : self . _clean_props ( ) if not self . use_emcee : fit_for_distance = True mass_A , mass_B , age , feh , dist , AV = ( p [ 0 ] , p [ 1 ] , p [ 2 ] , p [ 3 ] , p [ 4 ] , p [ 5 ] ) else : if len ( p ) == 6 : fit_for_distance = True mass_A , mass_B , age , feh , dist , AV = p elif len ( p ) == 4 : fit_for_distance = False mass_A , mass_B , age , feh = p if mass_A < self . ic . minmass or mass_A > self . ic . maxmass or mass_B < self . ic . minmass or mass_B > self . ic . maxmass or mass_B > mass_A or age < self . ic . minage or age > self . ic . maxage or feh < self . ic . minfeh or feh > self . ic . maxfeh : return - np . inf if fit_for_distance : if dist < 0 or AV < 0 or dist > self . max_distance : return - np . inf if AV > self . maxAV : return - np . inf if self . min_logg is not None : logg = self . ic . logg ( mass_A , age , feh ) if logg < self . min_logg : return - np . inf logl = 0 for prop in self . properties . keys ( ) : try : val , err = self . properties [ prop ] except TypeError : continue m = re . search ( 'delta_(\w+)' , prop ) if prop in self . ic . bands : if not fit_for_distance : raise ValueError ( 'must fit for mass, age, feh, dist, A_V ' + 'if apparent magnitudes provided.' ) mod_A = self . ic . mag [ prop ] ( mass_A , age , feh ) + 5 * np . log10 ( dist ) - 5 mod_B = self . ic . mag [ prop ] ( mass_B , age , feh ) + 5 * np . log10 ( dist ) - 5 A = AV * EXTINCTION [ prop ] mod_A += A mod_B += A mod = addmags ( mod_A , mod_B ) elif m : band = m . group ( 1 ) mod_A = self . ic . mag [ band ] ( mass_A , age , feh ) + 5 * np . log10 ( dist ) - 5 mod_B = self . ic . mag [ band ] ( mass_B , age , feh ) + 5 * np . log10 ( dist ) - 5 A = AV * EXTINCTION [ band ] mod_A += A mod_B += A mod = mod_B - mod_A elif prop == 'feh' : mod = feh elif prop == 'mass_B' : mod = mass_B elif prop == 'parallax' : mod = 1. / dist * 1000 else : mod = getattr ( self . ic , prop ) ( mass_A , age , feh ) logl += - ( val - mod ) ** 2 / ( 2 * err ** 2 ) + np . log ( 1 / ( err * np . sqrt ( 2 * np . pi ) ) ) if np . isnan ( logl ) : logl = - np . inf return logl
Log-likelihood of model at given parameters
Log - likelihood of model at given parameters
"""Log-likelihood of model at given parameters

        
        :param p: 
            mass_A, mass_B, log10(age), feh, [distance, A_V (extinction)].
            Final two should only be provided if ``self.fit_for_distance``
            is ``True``; that is, apparent magnitudes are provided.
            
        :return:
           log-likelihood.  Will be -np.inf if values out of range.
        
        """ #keep values in range; enforce mass_A > mass_B #property not appropriate for fitting (e.g. no error provided)
log-likelihood.  Will be -np.inf if values out of range.
log - likelihood . Will be - np . inf if values out of range .
self
p
mass_A, mass_B, log10(age), feh, [distance, A_V (extinction)].
Final two should only be provided if ``self.fit_for_distance``
is ``True``; that is, apparent magnitudes are provided.
mass_A mass_B log10 ( age ) feh [ distance A_V ( extinction ) ] . Final two should only be provided if ` ` self . fit_for_distance ` ` is ` ` True ` ` ; that is apparent magnitudes are provided .