samconnolly / DELightcurveSimulation

Emmanoulopoulos style lightcurve simulation
33 stars 19 forks source link

TK LC simulation parameters not read from the input LC #3

Open bersavosh opened 6 years ago

bersavosh commented 6 years ago

Hi Sam,

I've noticed a tiny issue with the Simulate_TK_Lightcurve command: It seems this function does not automatically read light curve parameters (sampling rate, length, mean and standard deviation) from an input light curve and just assumes default values, eventhough the function docstring indicates so. This specifically seems to be a recent issue I think as my older simulations (from 2 years ago) did not have this problem, while same simulations have this problem with the newer version of the package.

cheers, Arash

import numpy as np
from DELCgen import *
import matplotlib.pylab as plt

x = np.linspace(1,100,100)
y = np.random.normal(5,1,size=100)
dy = (np.random.rand(100)+0.5)*0.5

lc = Lightcurve(x,y,1.0,dy)
A,v_bend,a_low,a_high,c = 1e-6, 1.0/14000.0, 0.0, 1.0, 0 
tklc_implicit = Simulate_TK_Lightcurve(BendingPL,(A,v_bend,a_low,a_high,c),lightcurve=lc)
tklc_explicit = Simulate_TK_Lightcurve(BendingPL,(A,v_bend,a_low,a_high,c),lightcurve=lc,mean=lc.mean, tbin=lc.tbin,length=lc.length,std=lc.std)

plt.errorbar(lc.time,lc.flux,lc.errors,fmt='.k',alpha=0.2,label='data')
plt.errorbar(tklc_implicit.time,tklc_implicit.flux,tklc_implicit.errors,fmt='.r',label='sim. w/ implicit params')
plt.errorbar(tklc_explicit.time,tklc_explicit.flux,tklc_explicit.errors,fmt='.b',label='sim. w/ explicit params')
plt.legend()

tk_sim