joshjchayes / TransitFit

Transit light curve fitting using nested sampling
GNU General Public License v3.0
4 stars 1 forks source link

Consistent window for plots #9

Closed sourestdeeds closed 1 year ago

sourestdeeds commented 3 years ago

I've been considering a consistent way to plot the final transits, and I think I've found a robust way to do it. The best procedure I think would be:

Currently the code I have implemented reads in the fitted_lc's and performs this via:

    # First take the fitted flux and figure out where the dip in the lc is and return a bool mask
    transit_mask = np.ma.masked_values(fity, 1.).mask
    # Next find the indices where this happens
    transit_loc = np.where(transit_mask==False)
    # Create a fixed window either side which is 50% of the t14
    window = int(len(transit_loc[0]) * 0.5)
    start, stop = transit_loc[0][0] - window, transit_loc[0][-1] + window
    # Apply the extended window
    transit_mask[start:stop] = False

    # Apply the masks
    time = time[~transit_mask]
    flux = flux[~transit_mask]
    flux_err = flux_err[~transit_mask]
    fitx = fitx[~transit_mask]
    fity = fity[~transit_mask]

With this method we could effectively make the window wide enough to capture all planet transits to fit them, and then trim off the extra data before plotting. Instead of a window based on distance from t0, this is a window based upon the fitted transit duration and would guarantee every plot has the same ratio of transit to baseline.

I also guess this could be a way of estimating tdv from each fitted lc?

sourestdeeds commented 3 years ago

Below show the difference between a window of 8, and with a window of 8 followed by using the mask before plotting. TOI-157 b density noresid TOI-157 b density noresid