Sinusoidal Lightcurve Example

[1]:
# Import the SinusoidalLightCurve class into the current scope
from sorcha_addons.lightcurve.sinusoidal.sinusoidal_lightcurve import SinusoidalLightCurve
from sorcha.lightcurves.lightcurve_registration import update_lc_subclasses, LC_METHODS
/home/docs/checkouts/readthedocs.org/user_builds/sorcha-addons/envs/stable/lib/python3.10/site-packages/rebound/__init__.py:58: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
[2]:
# Update the `LC_METHODS` registration dictionary
update_lc_subclasses()

# Show that SinusoidalLightcurve is now registered and available.
print(LC_METHODS['sinusoidal'])
<class 'sorcha_addons.lightcurve.sinusoidal.sinusoidal_lightcurve.SinusoidalLightCurve'>
[3]:
# make a small pandas dataframe with ~5 rows
import pandas as pd

data_dict = {
    'fieldMJD_TAI': [60277.351867, 60289.319749, 60289.330920, 60292.334497, 60292.346208],
    'LCA': [1, 1, 1, 1, 1],
    'Period': [0.001, 0.001, 0.001, 0.001, 0.001],
    'Time0': [60277.351867, 60277.351867, 60277.351867, 60277.351867, 60277.351867],
    }

df = pd.DataFrame.from_dict(data_dict)
print(df)
   fieldMJD_TAI  LCA  Period         Time0
0  60277.351867    1   0.001  60277.351867
1  60289.319749    1   0.001  60277.351867
2  60289.330920    1   0.001  60277.351867
3  60292.334497    1   0.001  60277.351867
4  60292.346208    1   0.001  60277.351867
[4]:
# instantiate the sinusoidal class
lc_model = LC_METHODS['sinusoidal']()

# compute the change in magnitude using the dataframe created above
output = lc_model.compute(df)

print(output)
0    0.000000
1   -0.675333
2    0.326888
3   -0.728969
4    0.840945
dtype: float64