waqasbhatti / astrobase

Python modules for light curve work and variable star astronomy
MIT License
55 stars 12 forks source link

Discrepancy in epoch between `fourier_fit_magseries` and `fourier_sinusoidal_func` #70

Closed joshuawallace closed 5 years ago

joshuawallace commented 5 years ago

fourier_fit_magseries() returns an epoch that corresponds to the minimum brightness in the light curve (here). 'fourier_sinusoidal_func()' makes no such assumption for the epoch (here, and line 60 where phase gets used). In my application of the code, where I'm fitting a Fourier series to an RR Lyrae signal and then inserting an attenuated version of that signal into some other light curves, this leads to the inserted signal not having the same epoch as the original signal. What should I do to fix this?

waqasbhatti commented 5 years ago

Sorry for the delay, was away for a couple of days.

I think the easiest way to do this would be to pass in the epoch you get from the fourier_fit_magseries function to the fourier_sinusoidal_func function as part of the input fourierparams. That should make it use the same epoch as the one you got out of the fit. If you want to use another epoch (e.g. that of the object whose LC you're inserting the signal into), I think passing that in as part of the fourierparams will do the right thing.

joshuawallace commented 5 years ago

That's what I'm doing currently and having a problem with. I'm using the ['fitinfo']['fitepoch'] from fourier_fit_magseries's returndict as the epoch for fourier_sinusoidal_func and it leads to the creation of a signal that does not line up with the signal in the light curve being fit by 'fourier_fit_magseries'.

waqasbhatti commented 5 years ago

Ah, I see what you mean now. A random RRab from HATSouth:

magseries-phased-plot

The model fit:

magseries-phased-plot

Let me think about this for a bit. I thought I had this working earlier...

joshuawallace commented 5 years ago

I think I figured it out. The _get_phased_quantities function in fourier_fit_magseries uses the minimum time as the epoch for phase folding. This value does not get returned out of fourier_fit_magseries, and the value that does get returned (time of minimum in light curve) does not correspond to the actual epoch for the phase-folding and fitting, and neither does t=0, which I tried.

I will change the code so that the returned ['fitinfo']['fitepoch'] value is the same as used by _get_phased_quantities and if it works out, I'll create a pull request.

waqasbhatti commented 5 years ago

This was fixed by @joshuawallace in 25fc9ae4106a4a304d204f86bb979057459d8d6f.