polyml.py 文件源码

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

项目:PyCS 作者: COSMOGRAIL 项目源码 文件源码
def factory(seasons, nparams, mltype="poly"):
    """
    A factory function to create a microlensings object filled by seasonfct objects.
    seasons is a list of season objects
    nparams is an array or list of ints. "default" = one constant per season.
    All parameters will be set to 0.0, and free to be optimized.

    mltype = "poly" : simple polynomial microlensing, very stupid but fast, ok for degree <= 3
    default type.

    mltype = "leg" : legendre polynomials, very clever but slow :-) These are fine for degree <= 25
    Above deg 25, some numerical errors set in. Could perhaps be rewritten to make this faster.
    Or implement in C !!!!

    """
    #if nparams == "default":
    #   nparams = ones(len(seasons), dtype="int")

    if len(nparams) != len(seasons):
        raise RuntimeError, "Give as many nparams as they are seasons !"

    mllist = []
    for (season, n) in zip(seasons, nparams):
        if n != 0:
            p = np.zeros(n, dtype="float")
            mask = p > -1.0
            sfct = seasonfct(season, mltype, p, mask)
            mllist.append(sfct)

    return microlensing(mllist)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号