waqasbhatti / astrobase

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

epochs in checkplot_png #38

Closed joshuawallace closed 6 years ago

joshuawallace commented 6 years ago

It seems that the function checkplot_png() calculates only the epoch for the best period and then applies that epoch to the rest of the plotted periods, rather than calculating a separate epoch for each period. This is compared to checkplot_pickle(), which calculates a separate epoch for each period.

It would also be perhaps useful if checkplot_png() and checkplot_pickle() would take a list of epochs, one for each period, in the case that one would want to feed the epochs directly to checkplot.py for all the periods. Or perhaps an 'epoch' keyword could be read from the lsp dict, or something along those lines.

waqasbhatti commented 6 years ago

Yep, I should add this to checkplot_png (sorry; it's been a bit neglected compared to checkplot_pickle).

The suggestion of an additional kwarg to control this behavior is a good one. I'll implement that soon.

waqasbhatti commented 6 years ago

Added this functionality to checkplot_png, twolsp_checkplot_png, and checkplot_pickle in 89aa74260d4e641cc02f071043ddcf0739a0aa4f. Help with testing this would be great!

In general:

    varepoch sets the time of minimum light finding strategy for the checkplot:

                                               the epoch used for all phased
    if varepoch is None                     -> light curve plots will be
                                               min(times)

    if varepoch is a single string == 'min' -> automatic epoch finding for all
                                               periods using light curve fits

    if varepoch is a single float           -> this epoch will be used for all
                                               phased light curve plots

additionally, for checkplot_png:

    if varepoch is a list of floats            each epoch will be applied to
    with length == len(nbestperiods)        -> the phased light curve for each
    from period-finder results                 period specifically

    if you use a list for varepoch, it must be of length len(lspinfo['nbestperiods']) + 2, 
    because we insert half and twice the period into the best periods list to make 
    those phased LC plots.

Similarly, for twolsp_checkplot_png:

    if varepoch is a list of floats            each epoch will be applied to
    with length == 3 (i.e. best 3 for       -> the phased light curve for each
    each of the two period-finder results)     period specifically

Finally, for checkplot_pickle:

    if varepoch is a list of lists             each epoch will be applied for
    each of which has floats with           -> the phased light curve for each
    list length == nperiodstouse               period for each period-finder
    from period-finder results                 method specifically
waqasbhatti commented 6 years ago

This should now work as expected (in git HEAD). To provide custom epochs to checkplot_pickle, use something like (example below for two period-finder methods with 3 best periods each with their own epoch):

    cpf = checkplot.checkplot_pickle(
        [gls, pdm],
        times, mags, errs,
        outfile=outpath,
        objectinfo=lcd['objectinfo'],
        nperiodstouse=3,
        varepoch=[[56000.1,56000.2,56000.3],
                  [56000.4,56000.5,56000.6]]
    )

The varepoch kwarg can probably be generated from whatever is doing the period-finding.

waqasbhatti commented 6 years ago

Added a test for this as well. Appears to work as expected.