model.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:ugali 作者: DarkEnergySurvey 项目源码 文件源码
def histogram2d(self,distance_modulus=None,delta_mag=0.03,steps=10000):
        """
        Return a 2D histogram the isochrone in mag-mag space.

        Parameters:
        -----------
        distance_modulus : distance modulus to calculate histogram at
        delta_mag : magnitude bin size
        mass_steps : number of steps to sample isochrone at

        Returns:
        --------
        bins_mag_1 : bin edges for first magnitude
        bins_mag_2 : bin edges for second magnitude
        isochrone_pdf : weighted pdf of isochrone in each bin
        """
        if distance_modulus is not None:
            self.distance_modulus = distance_modulus

        # Isochrone will be binned, so might as well sample lots of points
        mass_init,mass_pdf,mass_act,mag_1,mag_2 = self.sample(mass_steps=steps)

        #logger.warning("Fudging intrinisic dispersion in isochrone.")
        #mag_1 += np.random.normal(scale=0.02,size=len(mag_1))
        #mag_2 += np.random.normal(scale=0.02,size=len(mag_2))

        # We cast to np.float32 to save memory
        bins_mag_1 = np.arange(self.mod+mag_1.min() - (0.5*delta_mag),
                               self.mod+mag_1.max() + (0.5*delta_mag),
                               delta_mag).astype(np.float32)
        bins_mag_2 = np.arange(self.mod+mag_2.min() - (0.5*delta_mag),
                               self.mod+mag_2.max() + (0.5*delta_mag),
                               delta_mag).astype(np.float32)

        # ADW: Completeness needs to go in mass_pdf here...
        isochrone_pdf = np.histogram2d(self.mod + mag_1,
                                       self.mod + mag_2,
                                       bins=[bins_mag_1, bins_mag_2],
                                       weights=mass_pdf)[0].astype(np.float32)

        return isochrone_pdf, bins_mag_1, bins_mag_2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号