polyml.py 文件源码

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

项目:PyCS 作者: COSMOGRAIL 项目源码 文件源码
def smooth(self, lightcurve):
        """
        Only for plotting purposes : returns jds, mlmagshifts, and refmags with a tight and regular sampling,
        over the range given by the season.
        Note that this time we are interested in the acutal shifted jds, so that it looks right when plotted !
        We return arrays that can directly be plotted to illustrate the microlensing.

        TODO : return refmag, not refmags !
        """

        jds = lightcurve.getjds()[self.season.indices]

        # Old method :
        if self.mltype == "poly":

            refjd = np.mean(jds)
            jds -= refjd

            refmag = np.median(lightcurve.getmags())    # So the reference magnitude is evaluated from the entire lightcurve.
                            # Independent on seasons.

            smoothtime = np.linspace(jds[0], jds[-1], 50)
            smoothml =  np.polyval(self.params, smoothtime)
            smoothtime += refjd # important, to get the time back at the right place.
            refmags = np.zeros(50) + refmag
            return {"jds":smoothtime, "ml":smoothml, "refmags":refmags}


        # Legendre polynomials :

        if self.mltype == "leg":

            rjd = (np.max(jds) - np.min(jds))/2.0
            cjd = (np.max(jds) + np.min(jds))/2.0
            jds = (jds - cjd)/rjd

            refmag = np.median(lightcurve.getmags())    # So the reference magnitude is evaluated from the entire lightcurve.
                            # Independent on seasons.

            smoothtime = np.linspace(-1, 1, 300)
            smoothml = np.zeros(len(smoothtime))
            for (n, p) in enumerate(self.params):
                smoothml += p * ss.legendre(n)(smoothtime)

            smoothtime = smoothtime * rjd + cjd # important, to get the time back at the right place.
            refmags = np.zeros(300) + refmag
            return {"jds":smoothtime, "ml":smoothml, "refmags":refmags}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号