Skip to content

Commit

Permalink
Added an alternative version of the power2 model with a parametrisati…
Browse files Browse the repository at this point in the history
…on introduced by P.F.L. Maxted (2018).
  • Loading branch information
hpparvi committed May 14, 2018
1 parent c733c3c commit 1bb8a82
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
21 changes: 19 additions & 2 deletions ldtk/ldmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"""

import numpy as np
from numpy import asarray, sqrt
from numpy import asarray, sqrt, log2


class LDModel(object):
npar = None
Expand Down Expand Up @@ -127,11 +128,27 @@ def evaluate(cl, mu, pv):
mu = asarray(mu)
return 1. - pv[0]*(1.-(mu**pv[1]))

class Power2MPModel(LDModel):
"""Power-2 limb darkening model with an alternative parametrisation (Maxted, P.F.L., 2018)."""
npar = 2
name = 'power2mp'
abbr = 'p2mp'

@classmethod
def evaluate(cl, mu, pv):
assert len(pv) == cl.npar
mu = asarray(mu)
c = 1 - pv[0] + pv[1]
a = log2(c/pv[1])
return 1. - c*(1.-(mu**a))


models = {'linear': LinearModel,
'quadratic': QuadraticModel,
'triquadratic': TriangularQuadraticModel,
'sqrt': SquareRootModel,
'nonlinear': NonlinearModel,
'general': GeneralModel,
'power2': Power2Model}
'power2': Power2Model,
'power2mp': Power2MPModel}

7 changes: 6 additions & 1 deletion ldtk/ldtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from scipy.optimize import fmin

from .ldmodel import (LinearModel, QuadraticModel, TriangularQuadraticModel, SquareRootModel, NonlinearModel,
GeneralModel, Power2Model, models)
GeneralModel, Power2Model, Power2MPModel, models)
from .client import Client
from .core import *

Expand Down Expand Up @@ -78,6 +78,8 @@ def __init__(self, filters, mu, ldp_samples):
self.lnlike_nl = partial(self._lnlike, ldmodel=NonlinearModel)
self.lnlike_ge = partial(self._lnlike, ldmodel=GeneralModel)
self.lnlike_p2 = partial(self._lnlike, ldmodel=Power2Model)
self.lnlike_p2mp = partial(self._lnlike, ldmodel=Power2MPModel)


self.coeffs_ln = partial(self._coeffs, ldmodel=LinearModel)
self.coeffs_qd = partial(self._coeffs, ldmodel=QuadraticModel)
Expand All @@ -86,6 +88,7 @@ def __init__(self, filters, mu, ldp_samples):
self.coeffs_nl = partial(self._coeffs, ldmodel=NonlinearModel)
self.coeffs_ge = partial(self._coeffs, ldmodel=GeneralModel)
self.coeffs_p2 = partial(self._coeffs, ldmodel=Power2Model)
self.coeffs_p2mp = partial(self._coeffs, ldmodel=Power2MPModel)

self.lnlike_ln.__doc__ = "Linear limb darkening model\n(coeffs, join=True, flt=None)"
self.lnlike_qd.__doc__ = "Quadratic limb darkening model\n(coeffs, join=True, flt=None)"
Expand All @@ -94,6 +97,7 @@ def __init__(self, filters, mu, ldp_samples):
self.lnlike_nl.__doc__ = "Nonlinear limb darkening model\n(coeffs, join=True, flt=None)"
self.lnlike_ge.__doc__ = "General limb darkening model\n(coeffs, join=True, flt=None)"
self.lnlike_p2.__doc__ = "Power-2 limb darkening model\n(coeffs, join=True, flt=None)"
self.lnlike_p2mp.__doc__ = "Power-2 limb darkening model with an alternative parametrisation\n(coeffs, join=True, flt=None)"

self.coeffs_ln.__doc__ = "Estimate the linear limb darkening model coefficients, see LPDSet._coeffs for details."
self.coeffs_qd.__doc__ = "Estimate the quadratic limb darkening model coefficients, see LPDSet._coeffs for details."
Expand All @@ -102,6 +106,7 @@ def __init__(self, filters, mu, ldp_samples):
self.coeffs_nl.__doc__ = "Estimate the nonlinear limb darkening model coefficients, see LPDSet._coeffs for details."
self.coeffs_ge.__doc__ = "Estimate the general limb darkening model coefficients, see LPDSet._coeffs for details."
self.coeffs_p2.__doc__ = "Estimate the power-2 limb darkening model coefficients, see LPDSet._coeffs for details."
self.coeffs_p2mp.__doc__ = "Estimate the power-2 MP limb darkening model coefficients, see LPDSet._coeffs for details."


def save(self, filename):
Expand Down

0 comments on commit 1bb8a82

Please sign in to comment.