def test_lerp_threading(self): for nthr in range(16): f = Gimenez(npol=500, nthr=nthr, lerp=True)(self.z, self.k, self.u[0]) npt.assert_array_almost_equal(f, self.f_ref[:,0], decimal=4) for i in range(2,4): f = Gimenez(npol=500, nthr=nthr, lerp=True)(self.z, self.k, self.u[0:i]) npt.assert_array_almost_equal(f, self.f_ref[:,0:i], decimal=4)
def __init__(self, lcdata, tmodel=None, **kwargs): self.tmodel = tmodel or Gimenez() self.lcdata = lcdata self.group = None self.pid_ar = None self.pid_ld = None self.pid_private = None ## Precalculate the likelihood constants ## ===================================== self.lln = -0.5 * self.lcdata.npt * m.log(2 * m.pi) ## Define priors ## ============= pr = kwargs.get('priors', {}) self.priors = [] self.priors.extend([ UP(0.2, 5.0, 'e', 'Error multiplier') for i in range(self.lcdata.npb) ]) self.priors.extend([ UP(0.0, 0.01, 'c', 'Contamination') for i in range(self.lcdata.npb) ]) self.ps = PriorSet(self.priors) self.np = len(self.priors) self.pv_start_idx = None
import numpy as np import matplotlib.pyplot as pl from pytransit.gimenez import Gimenez k, t0, p, a, i, e, w = 0.1, 1., 4., 8., 0.5*np.pi, 0.01, 0.5*np.pi t = np.linspace(0.9,1.1,500) u = np.array([[0.04*iu, 0.025*iu, 0.01*iu] for iu in range(10)]) c = np.linspace(0,0.9,10) m = Gimenez(lerp=False, npol=100, nldc=3) f = m.evaluate(t, k, u, t0, p, a, i, e, w, c=c) fig,ax = pl.subplots(1,1,figsize=(7,7)) ax.plot(t,f + np.arange(u.shape[0])*0.00, 'k'); pl.setp(ax, ylim=(0.9875,1.011), yticks=[], xlabel='Time [d]', ylabel='Normalised flux', title='Light curve for a set of multiple limb darkening coefficients'); fig.tight_layout() pl.show()
def test_lerp_npol(self): f = Gimenez(npol=100, nthr=1, lerp=True)(self.z, self.k, self.u[0]) npt.assert_array_almost_equal(f,self.f_ref[:,0], decimal=4) for i in range(2,4): f = Gimenez(npol=100, nthr=1, lerp=True)(self.z, self.k, self.u[0:i]) npt.assert_array_almost_equal(f,self.f_ref[:,0:i], decimal=4)
def test_nolerp_basic(self): f = Gimenez(npol=500, nthr=1, lerp=False)(self.z, self.k, self.u[0]) npt.assert_array_almost_equal(f, self.f_ref[:,0]) for i in range(2,4): f = Gimenez(npol=500, nthr=1, lerp=False)(self.z, self.k, self.u[0:i]) npt.assert_array_almost_equal(f, self.f_ref[:,0:i])
import numpy as np import matplotlib.pyplot as pl from pytransit.gimenez import Gimenez z = np.linspace(1e-7, 1.5, 1000) u = np.array([0.3, 0.1]) k = 0.10 npols = [800, 500, 200, 100, 50, 20, 10, 5] I = [Gimenez(npol, 2)(z, k, u) for npol in npols] fig, ax = pl.subplots(1, 1) la = 1 - np.linspace(0, 0.75, len(npols)) ax.plot(I[0], c='0.0') for i in range(1, len(npols)): print '\tN {:3d} -- Max deviation {:6.4f} ppm'.format( npols[i], 1e3 * np.abs(I[0] - I[i]).max()) ax.plot(I[i], c='0', alpha=la[i]) ax.set_ylim(0.988, 1.001) pl.show()
import numpy as np import matplotlib.pyplot as pl from pytransit.gimenez import Gimenez k, t0, p, a, i, e, w = 0.1, 1., 4., 8., 0.5 * np.pi, 0.01, 0.5 * np.pi t = np.linspace(0.9, 1.1, 500) u = np.array([[0.04 * iu, 0.025 * iu, 0.01 * iu] for iu in range(10)]) c = np.linspace(0, 0.9, 10) m = Gimenez(lerp=False, npol=100, nldc=3) f = m.evaluate(t, k, u, t0, p, a, i, e, w, c=c) fig, ax = pl.subplots(1, 1, figsize=(7, 7)) ax.plot(t, f + np.arange(u.shape[0]) * 0.00, 'k') pl.setp(ax, ylim=(0.9875, 1.011), yticks=[], xlabel='Time [d]', ylabel='Normalised flux', title='Light curve for a set of multiple limb darkening coefficients') fig.tight_layout() pl.show()