pmaxted / pycheops

Python module for the analysis of light curves from the ESA Cheops mission
http://cheops.unibe.ch/
GNU General Public License v3.0
21 stars 15 forks source link

Dataset detrended flux error #320

Open suman-phy opened 2 months ago

suman-phy commented 2 months ago

Hi, I'm facing an issue when plotting the detrended flux from lmfit (plot_lmfit, with detrend=True), where it gives an incorrect plot. However, with detrend=False, the plot doesn't have any issues. I found the same error when I used 'cds_data_export' to export the data and plot myself. I've attached the figures without (1st) and with detrending.

Figure_1 Figure_2

I didn't have this issue when I used the same function a few months back. Not sure sure if updating the package or dependencies has affected something here. I'll really appreciate if you can help me with this.

Thank you.

pmaxted commented 2 months ago

The plotting function appears to be working correctly but you have a very low point in your data that is messing up the plot. Run clip_outliers on your data to remove the outliers before doing your fit.

suman-phy commented 2 months ago

Outliers are not causing it and clip_outliers has already been used here. Below, I've added a zoomed out upper panel of the plot. It seems to be not subtracting the glint function while detrending, as you can also see the Y-axis shows Flux/Trend, instead of (Flux-Glint)/Trend. However, I'm not sure why is it behaving this way.

Figure_3

suman-phy commented 2 months ago

Also, I've already tested on other datasets and faced the same issue.

suman-phy commented 2 months ago

After some testing, I was able to figure out part of it. For some reason, 'glint=False' at the output of line 3072. The same is the case with 'cds_data_export'. Making 'glint=True' there manually solves the issue. However, you might want to look into more details to correct the issue.

suman-phy commented 2 months ago

In particular,

model.right.name == 'Model(_glint_func, f_theta='<scipy.interpolate._interpolate.interp1d object at 0x169cafde0>', f_glint='<scipy.interpolate._fitpack2.LSQUnivariateSpline object at 0x13eb14490>')'

instead of,

model.right.name == 'Model(_glint_func)'

pmaxted commented 2 months ago

Thanks for the hint Suman.

It looks like lmfit have changed the output of __repr__ for models.

Please try installing version 1.1.13 from github and let me know if this fixes the problem.

pip install git+https://github.com/pmaxted/pycheops.git