Trying to fit a sine function to phased light curve

前端 未结 2 522
孤城傲影
孤城傲影 2020-12-20 02:32
import numpy as np
import matplotlib.pyplot as plt
from lmfit import Model,Parameters


f2= \"KELT_N16_lc_006261_V01_west_tfa.dat\"    
t2=\"TIMES\"   # file name

N         


        
2条回答
  •  执念已碎
    2020-12-20 02:53

    A couple of comments/suggestions:

    First, it is almost certainly better to replace

    p = Parameters()
    p.add_many(('new_flux',13.42, True, None, None, None) )
    p.add_many(('new_phase',0,True, None, None, None) )
    

    with

    p = Parameters()
    p.add('new_flux', value=13.42, vary=True)
    p.add('new_phase', value=0, vary=True)
    

    Second, your model does not include a DC offset, but your data clearly has one. The offset is approximately 13.4 and the amplitude of the sine wave is approximately 0.05. While you're at it, you probably want to include a scale the phase as a well as an offset, so that the model is

    offset + amplitude * sin(scale*x + phase_shift)
    

    You don't necessarily have to vary all of those, but making your model more general will allow to see how the phase shift and scale are correlated -- given the noise level in your data, that might be important.

    With the more general model, you can try a few sets of parameter values, using model.eval() to evaluate a model with a set of Parameters. Once you have a better model and reasonable starting points, you should get a reasonable fit.

提交回复
热议问题