possible_classes = []<EOL>if not colorfeatures:<EOL><INDENT>return possible_classes<EOL><DEDENT>if not pmfeatures:<EOL><INDENT>return possible_classes<EOL><DEDENT>if ( ('<STR_LIT>' in colorfeatures) and<EOL>(colorfeatures['<STR_LIT>'] is not None) and<EOL>(np.isfinite(colorfeatures['<STR_LIT>'])) ):<EOL><INDENT>u = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>u = np.nan<EOL><DEDENT>if ( ('<STR_LIT>' in colorfeatures) and<EOL>(colorfeatures['<STR_LIT>'] is not None) and<EOL>(np.isfinite(colorfeatures['<STR_LIT>'])) ):<EOL><INDENT>g = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>g = np.nan<EOL><DEDENT>if ( ('<STR_LIT>' in colorfeatures) and<EOL>(colorfeatures['<STR_LIT>'] is not None) and<EOL>(np.isfinite(colorfeatures['<STR_LIT>'])) ):<EOL><INDENT>r = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>r = np.nan<EOL><DEDENT>if ( ('<STR_LIT>' in colorfeatures) and<EOL>(colorfeatures['<STR_LIT>'] is not None) and<EOL>(np.isfinite(colorfeatures['<STR_LIT>'])) ):<EOL><INDENT>i = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>i = np.nan<EOL><DEDENT>if ( ('<STR_LIT>' in colorfeatures) and<EOL>(colorfeatures['<STR_LIT>'] is not None) and<EOL>(np.isfinite(colorfeatures['<STR_LIT>'])) ):<EOL><INDENT>z = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>z = np.nan<EOL><DEDENT>if ( ('<STR_LIT>' in colorfeatures) and<EOL>(colorfeatures['<STR_LIT>'] is not None) and<EOL>(np.isfinite(colorfeatures['<STR_LIT>'])) ):<EOL><INDENT>j = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>j = np.nan<EOL><DEDENT>if ( ('<STR_LIT>' in colorfeatures) and<EOL>(colorfeatures['<STR_LIT>'] is not None) and<EOL>(np.isfinite(colorfeatures['<STR_LIT>'])) ):<EOL><INDENT>h = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>h = np.nan<EOL><DEDENT>if ( ('<STR_LIT>' in colorfeatures) and<EOL>(colorfeatures['<STR_LIT>'] is not None) and<EOL>(np.isfinite(colorfeatures['<STR_LIT>'])) ):<EOL><INDENT>k = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>k = np.nan<EOL><DEDENT>if '<STR_LIT>' in colorfeatures and colorfeatures['<STR_LIT>'] is not None:<EOL><INDENT>um = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>um = np.nan<EOL><DEDENT>if '<STR_LIT>' in colorfeatures and colorfeatures['<STR_LIT>'] is not None:<EOL><INDENT>gm = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>gm = np.nan<EOL><DEDENT>if '<STR_LIT>' in colorfeatures and colorfeatures['<STR_LIT>'] is not None:<EOL><INDENT>rm = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>rm = np.nan<EOL><DEDENT>if '<STR_LIT>' in colorfeatures and colorfeatures['<STR_LIT>'] is not None:<EOL><INDENT>im = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>im = np.nan<EOL><DEDENT>if '<STR_LIT>' in colorfeatures and colorfeatures['<STR_LIT>'] is not None:<EOL><INDENT>zm = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>zm = np.nan<EOL><DEDENT>if '<STR_LIT>' in colorfeatures and colorfeatures['<STR_LIT>'] is not None:<EOL><INDENT>jm = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>jm = np.nan<EOL><DEDENT>if '<STR_LIT>' in colorfeatures and colorfeatures['<STR_LIT>'] is not None:<EOL><INDENT>hm = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>hm = np.nan<EOL><DEDENT>if '<STR_LIT>' in colorfeatures and colorfeatures['<STR_LIT>'] is not None:<EOL><INDENT>km = colorfeatures['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>km = np.nan<EOL><DEDENT>rpmj = pmfeatures['<STR_LIT>'] if np.isfinite(pmfeatures['<STR_LIT>']) else None<EOL>if (np.isfinite(u) and np.isfinite(g) and<EOL>np.isfinite(r) and np.isfinite(i) and<EOL>np.isfinite(z)):<EOL><INDENT>v_color = <NUM_LIT>*(u-g)-<NUM_LIT>*(g-r)+<NUM_LIT>*(r-i)+<NUM_LIT>*(i-z)<EOL><DEDENT>else:<EOL><INDENT>v_color = np.nan<EOL><DEDENT>if (np.isfinite(u) and np.isfinite(g) and np.isfinite(r)):<EOL><INDENT>p1_color = <NUM_LIT>*(u-g)+<NUM_LIT>*(g-r)-<NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>p1_color = np.nan<EOL><DEDENT>if (np.isfinite(u) and np.isfinite(g) and<EOL>np.isfinite(r) and np.isfinite(i)):<EOL><INDENT>l_color = -<NUM_LIT>*u + <NUM_LIT>*g - <NUM_LIT>*r - <NUM_LIT>*i + <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>l_color = np.nan<EOL><DEDENT>if (np.isfinite(u) and np.isfinite(g) and np.isfinite(r)):<EOL><INDENT>s_color = -<NUM_LIT>*u + <NUM_LIT>*g - <NUM_LIT>*r + <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>s_color = np.nan<EOL><DEDENT>if (np.isfinite(u) and np.isfinite(g) and np.isfinite(r)):<EOL><INDENT>d_ug = (u-g) + <NUM_LIT>*(g-r) - <NUM_LIT><EOL>d_gr = <NUM_LIT>*(u-g) - (g-r) - <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>d_ug, d_gr = np.nan, np.nan<EOL><DEDENT>m_subtype, m_sti, m_sts = mdwarf_subtype_from_sdsscolor(r-i, i-z)<EOL>if m_subtype and rpmj and rpmj > <NUM_LIT:1.0>:<EOL><INDENT>possible_classes.append('<STR_LIT:d>' + m_subtype)<EOL><DEDENT>if ( np.isfinite(u) and np.isfinite(g) and np.isfinite(r) and<EOL>((g-r) < -<NUM_LIT>) and ((g-r) > -<NUM_LIT:1.0>) and<EOL>((u-g) < <NUM_LIT>) and ((u-g) > -<NUM_LIT:1>) and<EOL>((u-g+<NUM_LIT:2>*(g-r)) < -<NUM_LIT:0.1>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( np.isfinite(u) and np.isfinite(g) and np.isfinite(r) and<EOL>((u-g) < <NUM_LIT>) and ((u-g) > <NUM_LIT>) and<EOL>((g-r) < <NUM_LIT>) and ((g-r) > -<NUM_LIT:0.5>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(p1_color) and np.isfinite(p1_color) and<EOL>np.isfinite(u) and np.isfinite(g) and np.isfinite(r) ) and<EOL>(p1_color < -<NUM_LIT>) and (p1_color > -<NUM_LIT>) and<EOL>((u-g) < <NUM_LIT>) and ((u-g) > <NUM_LIT>) and<EOL>((g-r) < <NUM_LIT>) and ((g-r) > <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(u) and np.isfinite(g) and np.isfinite(r) and<EOL>np.isfinite(l_color)) and<EOL>((g-r) < <NUM_LIT>) and ((g-r) > -<NUM_LIT:0.5>) and<EOL>((u-g) < <NUM_LIT>) and ((u-g) > <NUM_LIT>) and<EOL>(l_color > <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(p1_color) and np.isfinite(s_color)) and<EOL>(-<NUM_LIT:0.1> < p1_color < <NUM_LIT>) and (s_color > <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(g) and np.isfinite(g) and np.isfinite(r)) and<EOL>((g-r) < <NUM_LIT>) and ((g-r) > <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(g) and np.isfinite(r)) and<EOL>((g-r) < <NUM_LIT>) and ((g-r) > <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(u) and np.isfinite(g) and<EOL>np.isfinite(r) and np.isfinite(i) and<EOL>np.isfinite(l_color)) and<EOL>((g-r) > <NUM_LIT>) and ((g-r) < <NUM_LIT>) and<EOL>(l_color > <NUM_LIT>) and ((u-g) > <NUM_LIT>) and ((u-g) < <NUM_LIT>) and<EOL>((r-i) > <NUM_LIT>) and ((r-i) < <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(u) and np.isfinite(g) and<EOL>np.isfinite(r) and np.isfinite(s_color)) and<EOL>((u-g) < <NUM_LIT>) and ((u-g) > <NUM_LIT>) and<EOL>((g-r) < <NUM_LIT>) and ((g-r) > <NUM_LIT>) and<EOL>(s_color < -<NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(g) and np.isfinite(r)) and<EOL>((g-r) < <NUM_LIT>) and ((g-r) > <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(g) and np.isfinite(r) and np.isfinite(i)) and<EOL>((g-r) > <NUM_LIT>) and ((r-i) < <NUM_LIT>) and ((r-i) > <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(j) and np.isfinite(h) and np.isfinite(k) and<EOL>np.isfinite(g) and np.isfinite(i)) and<EOL>((j-k) > <NUM_LIT>) and<EOL>((j-h) < (<NUM_LIT>*(j-k) + <NUM_LIT>)) and<EOL>((j-h) > (<NUM_LIT>*(j-k) + <NUM_LIT>)) and<EOL>((g-i) > (<NUM_LIT>*(i-k) - <NUM_LIT>)) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(um) and np.isfinite(gm) and<EOL>np.isfinite(rm) and np.isfinite(im)) and<EOL>((um-gm) < <NUM_LIT>) and ((gm-rm) > -<NUM_LIT>) and<EOL>((gm-rm) < <NUM_LIT>) and ((rm-im) > <NUM_LIT:0.5>) and<EOL>((rm-im) < <NUM_LIT>) and<EOL>((gm-rm) > (-<NUM_LIT>*(rm-im)+<NUM_LIT>)) and<EOL>((gm-rm) < (<NUM_LIT>*(rm-im)+<NUM_LIT:0.5>)) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(um) and np.isfinite(gm) and np.isfinite(rm) and<EOL>np.isfinite(im) and np.isfinite(zm)) and<EOL>(zm < <NUM_LIT>) and (um > <NUM_LIT>) and (gm > <NUM_LIT>) and<EOL>(rm > <NUM_LIT>) and ((im - zm) > <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(u) and np.isfinite(g) and np.isfinite(r) and<EOL>np.isfinite(i) and np.isfinite(z) and np.isfinite(d_ug) and<EOL>np.isfinite(d_gr)) and<EOL>((u-g) > <NUM_LIT>) and ((u-g) < <NUM_LIT>) and<EOL>(d_ug > -<NUM_LIT>) and (d_ug < <NUM_LIT>) and<EOL>(d_gr > <NUM_LIT>) and (d_gr < <NUM_LIT>) and<EOL>((r-i) > -<NUM_LIT>) and ((r-i) < <NUM_LIT>) and<EOL>((i-z) > -<NUM_LIT>) and ((i-z) < <NUM_LIT>) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>if ( (np.isfinite(u) and np.isfinite(g) and np.isfinite(r)) and<EOL>( (((u-g) > -<NUM_LIT:0.1>) and ((u-g) < <NUM_LIT>) and<EOL>((g-r) > -<NUM_LIT>) and ((g-r) < <NUM_LIT:0.5>)) or<EOL>((u-g) > (<NUM_LIT>*(g-r) + <NUM_LIT>)) ) ):<EOL><INDENT>possible_classes.append('<STR_LIT>')<EOL><DEDENT>return {'<STR_LIT>':possible_classes,<EOL>'<STR_LIT>':v_color,<EOL>'<STR_LIT>':p1_color,<EOL>'<STR_LIT>':s_color,<EOL>'<STR_LIT>':l_color,<EOL>'<STR_LIT>':d_ug,<EOL>'<STR_LIT>':d_gr,<EOL>'<STR_LIT>':m_sti,<EOL>'<STR_LIT>':m_sts}<EOL>

This calculates rough star type classifications based on star colors
    in the ugrizJHK bands.

    Uses the output from `color_features` and `coord_features`. By default,
    `color_features` will use dereddened colors, as are expected by most
    relations here.

    Based on the color cuts from:

    - SDSS SEGUE (Yanny+ 2009)
    - SDSS QSO catalog (Schneider+ 2007)
    - SDSS RR Lyrae catalog (Sesar+ 2011)
    - SDSS M-dwarf catalog (West+ 2008)
    - Helmi+ 2003
    - Bochanski+ 2014

    Parameters
    ----------

    colorfeatures : dict
        This is the dict produced by the `color_features` function.

    pmfeatures : dict
        This is the dict produced by the `coord_features` function.

    Returns
    -------

    dict
        A dict containing all of the possible classes this object can belong to
        as a list in the `color_classes` key, and values of the various color
        indices used to arrive to that conclusion as the other keys.


def gilliland_cdpp(times, mags, errs,<EOL>windowlength=<NUM_LIT>,<EOL>polyorder=<NUM_LIT:2>,<EOL>binsize=<NUM_LIT>,  <EOL>sigclip=<NUM_LIT>,<EOL>magsarefluxes=False,<EOL>**kwargs):

<EOL>if errs is None:<EOL><INDENT>errs = <NUM_LIT>*mags<EOL><DEDENT>find = npisfinite(times) & npisfinite(mags) & npisfinite(errs)<EOL>ftimes = times[find]<EOL>fmags = mags[find]<EOL>ferrs = errs[find]<EOL>if ftimes.size < (<NUM_LIT:3>*windowlength):<EOL><INDENT>LOGERROR('<STR_LIT>')<EOL>return npnan<EOL><DEDENT>smoothed = savgol_filter(fmags, windowlength, polyorder, **kwargs)<EOL>subtracted = fmags - smoothed<EOL>stimes, smags, serrs = sigclip_magseries(ftimes, subtracted, ferrs,<EOL>magsarefluxes=magsarefluxes)<EOL>binned = time_bin_magseries_with_errs(stimes, smags, serrs,<EOL>binsize=binsize,<EOL>minbinelems=<NUM_LIT:7>)<EOL>bmags = binned['<STR_LIT>']<EOL>cdpp = npstd(bmags) * <NUM_LIT><EOL>return cdpp<EOL>

This calculates the CDPP of a timeseries using the method in the paper:

    Gilliland, R. L., Chaplin, W. J., Dunham, E. W., et al. 2011, ApJS, 197, 6
    (http://adsabs.harvard.edu/abs/2011ApJS..197....6G)

    The steps are:

    - pass the time-series through a Savitsky-Golay filter.

      - we use `scipy.signal.savgol_filter`, `**kwargs` are passed to this.

      - also see: http://scipy.github.io/old-wiki/pages/Cookbook/SavitzkyGolay.

      - the `windowlength` is the number of LC points to use (Kepler uses 2 days
        = (1440 minutes/day / 30 minutes/LC point) x 2 days = 96 -> 97 LC
        points).

      - the `polyorder` is a quadratic by default.

    - subtract the smoothed time-series from the actual light curve.

    - sigma clip the remaining LC.

    - get the binned mag series by averaging over 6.5 hour bins, only retaining
      bins with at least 7 points.

    - the standard deviation of the binned averages is the CDPP.

    - multiply this by 1.168 to correct for over-subtraction of white-noise.

    Parameters
    ----------

    times,mags,errs : np.array
        The input mag/flux time-series to calculate CDPP for.

    windowlength : int
        The smoothing window size to use.

    polyorder : int
        The polynomial order to use in the Savitsky-Golay smoothing.

    binsize : int
        The bin size to use for binning the light curve.

    sigclip : float or int or sequence of two floats/ints or None
        If a single float or int, a symmetric sigma-clip will be performed using
        the number provided as the sigma-multiplier to cut out from the input
        time-series.

        If a list of two ints/floats is provided, the function will perform an
        'asymmetric' sigma-clip. The first element in this list is the sigma
        value to use for fainter flux/mag values; the second element in this
        list is the sigma value to use for brighter flux/mag values. For
        example, `sigclip=[10., 3.]`, will sigclip out greater than 10-sigma
        dimmings and greater than 3-sigma brightenings. Here the meaning of
        "dimming" and "brightening" is set by *physics* (not the magnitude
        system), which is why the `magsarefluxes` kwarg must be correctly set.

        If `sigclip` is None, no sigma-clipping will be performed, and the
        time-series (with non-finite elems removed) will be passed through to
        the output.

    magsarefluxes : bool
        If True, indicates the input time-series is fluxes and not mags.

    kwargs : additional kwargs
        These are passed directly to `scipy.signal.savgol_filter`.

    Returns
    -------

    float
        The calculated CDPP value.


def lightcurve_ptp_measures(ftimes, fmags, ferrs):

ndet = len(fmags)<EOL>if ndet > <NUM_LIT:9>:<EOL><INDENT>timediffs = npdiff(ftimes)<EOL>nzind = npnonzero(timediffs)<EOL>ftimes, fmags, ferrs = ftimes[nzind], fmags[nzind], ferrs[nzind]<EOL>ndet = ftimes.size<EOL>timediffs = npdiff(ftimes)<EOL>p2p_abs_magdiffs = npabs(npdiff(fmags))<EOL>p2p_squared_magdiffs = npdiff(fmags)*npdiff(fmags)<EOL>robstd = npmedian(npabs(fmags - npmedian(fmags)))*<NUM_LIT><EOL>robvar = robstd*robstd<EOL>eta_robust = npmedian(p2p_abs_magdiffs)/robvar<EOL>eta_robust = eta_robust/(ndet - <NUM_LIT:1.0>)<EOL>eta_normal = npsum(p2p_squared_magdiffs)/npvar(fmags)<EOL>eta_normal = eta_normal/(ndet - <NUM_LIT:1.0>)<EOL>timeweights = <NUM_LIT:1.0>/(timediffs*timediffs)<EOL>eta_uneven_normal = (<EOL>(npsum(timeweights*p2p_squared_magdiffs) /<EOL>(npvar(fmags) * npsum(timeweights)) ) *<EOL>npmean(timeweights) *<EOL>(ftimes.max() - ftimes.min())*(ftimes.max() - ftimes.min())<EOL>)<EOL>eta_uneven_robust = (<EOL>(npsum(timeweights*p2p_abs_magdiffs) /<EOL>(robvar * npsum(timeweights)) ) *<EOL>npmedian(timeweights) *<EOL>(ftimes[-<NUM_LIT:1>] - ftimes[<NUM_LIT:0>])*(ftimes[-<NUM_LIT:1>] - ftimes[<NUM_LIT:0>])<EOL>)<EOL>return {<EOL>'<STR_LIT>':eta_normal,<EOL>'<STR_LIT>':eta_robust,<EOL>'<STR_LIT>':eta_uneven_normal,<EOL>'<STR_LIT>':eta_uneven_robust<EOL>}<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

This calculates various point-to-point measures (`eta` in Kim+ 2014).

    Parameters
    ----------

    ftimes,fmags,ferrs : np.array
        The input mag/flux time-series with all non-finite elements removed.

    Returns
    -------

    dict
        A dict with values of the point-to-point measures, including the `eta`
        variability index (often used as its inverse `inveta` to have the same
        sense as increasing variability index -> more likely a variable star).


def all_nonperiodic_features(times, mags, errs,<EOL>magsarefluxes=False,<EOL>stetson_weightbytimediff=True):

<EOL>finiteind = npisfinite(times) & npisfinite(mags) & npisfinite(errs)<EOL>ftimes, fmags, ferrs = times[finiteind], mags[finiteind], errs[finiteind]<EOL>nzind = npnonzero(ferrs)<EOL>ftimes, fmags, ferrs = ftimes[nzind], fmags[nzind], ferrs[nzind]<EOL>xfeatures = nonperiodic_lightcurve_features(times, mags, errs,<EOL>magsarefluxes=magsarefluxes)<EOL>stetj = stetson_jindex(ftimes, fmags, ferrs,<EOL>weightbytimediff=stetson_weightbytimediff)<EOL>stetk = stetson_kindex(fmags, ferrs)<EOL>xfeatures.update({'<STR_LIT>':stetj,<EOL>'<STR_LIT>':stetk})<EOL>return xfeatures<EOL>

This rolls up the feature functions above and returns a single dict.

    NOTE: this doesn't calculate the CDPP to save time since binning and
    smoothing takes a while for dense light curves.

    Parameters
    ----------

    times,mags,errs : np.array
        The input mag/flux time-series to calculate CDPP for.

    magsarefluxes : bool
        If True, indicates `mags` is actually an array of flux values.

    stetson_weightbytimediff : bool
        If this is True, the Stetson index for any pair of mags will be
        reweighted by the difference in times between them using the scheme in
        Fruth+ 2012 and Zhange+ 2003 (as seen in Sokolovsky+ 2017)::

            w_i = exp(- (t_i+1 - t_i)/ delta_t )

    Returns
    -------

    dict
        Returns a dict with all of the variability features.


def lightcurve_moments(ftimes, fmags, ferrs):

ndet = len(fmags)<EOL>if ndet > <NUM_LIT:9>:<EOL><INDENT>series_median = npmedian(fmags)<EOL>series_wmean = (<EOL>npsum(fmags*(<NUM_LIT:1.0>/(ferrs*ferrs)))/npsum(<NUM_LIT:1.0>/(ferrs*ferrs))<EOL>)<EOL>series_mad = npmedian(npabs(fmags - series_median))<EOL>series_stdev = <NUM_LIT>*series_mad<EOL>series_skew = spskew(fmags)<EOL>series_kurtosis = spkurtosis(fmags)<EOL>series_above1std = len(fmags[fmags > (series_median + series_stdev)])<EOL>series_below1std = len(fmags[fmags < (series_median - series_stdev)])<EOL>series_beyond1std = (series_above1std + series_below1std)/float(ndet)<EOL>series_mag_percentiles = nppercentile(<EOL>fmags,<EOL>[<NUM_LIT>,<NUM_LIT:10>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>]<EOL>)<EOL>return {<EOL>'<STR_LIT>':series_median,<EOL>'<STR_LIT>':series_wmean,<EOL>'<STR_LIT>':series_mad,<EOL>'<STR_LIT>':series_stdev,<EOL>'<STR_LIT>':series_skew,<EOL>'<STR_LIT>':series_kurtosis,<EOL>'<STR_LIT>':series_beyond1std,<EOL>'<STR_LIT>':series_mag_percentiles,<EOL>'<STR_LIT>': series_mag_percentiles[<NUM_LIT:8>] - series_mag_percentiles[<NUM_LIT:3>],<EOL>}<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>return None<EOL><DEDENT>

This calculates the weighted mean, stdev, median, MAD, percentiles, skew,
    kurtosis, fraction of LC beyond 1-stdev, and IQR.

    Parameters
    ----------

    ftimes,fmags,ferrs : np.array
        The input mag/flux time-series with all non-finite elements removed.

    Returns
    -------

    dict
        A dict with all of the light curve moments calculated.


def stetson_jindex(ftimes, fmags, ferrs, weightbytimediff=False):

ndet = len(fmags)<EOL>if ndet > <NUM_LIT:9>:<EOL><INDENT>medmag = npmedian(fmags)<EOL>delta_prefactor = (ndet/(ndet - <NUM_LIT:1>))<EOL>sigma_i = delta_prefactor*(fmags - medmag)/ferrs<EOL>sigma_j = nproll(sigma_i,<NUM_LIT:1>)<EOL>if weightbytimediff:<EOL><INDENT>difft = npdiff(ftimes)<EOL>deltat = npmedian(difft)<EOL>weights_i = npexp(- difft/deltat )<EOL>products = (weights_i*sigma_i[<NUM_LIT:1>:]*sigma_j[<NUM_LIT:1>:])<EOL><DEDENT>else:<EOL><INDENT>products = (sigma_i*sigma_j)[<NUM_LIT:1>:]<EOL><DEDENT>stetsonj = (<EOL>npsum(npsign(products) * npsqrt(npabs(products)))<EOL>) / ndet<EOL>return stetsonj<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>return npnan<EOL><DEDENT>

This calculates the Stetson index for the magseries, based on consecutive
    pairs of observations.

    Based on Nicole Loncke's work for her Planets and Life certificate at
    Princeton in 2014.

    Parameters
    ----------

    ftimes,fmags,ferrs : np.array
        The input mag/flux time-series with all non-finite elements removed.

    weightbytimediff : bool
        If this is True, the Stetson index for any pair of mags will be
        reweighted by the difference in times between them using the scheme in
        Fruth+ 2012 and Zhange+ 2003 (as seen in Sokolovsky+ 2017)::

            w_i = exp(- (t_i+1 - t_i)/ delta_t )

    Returns
    -------

    float
        The calculated Stetson J variability index.


This is used to prevent any further changes to the checkplot.

    TODO: finish this.

    Use this function after all variable classification, period-finding, and
    object xmatches are done. This function will add a 'final' key to the
    checkplot, which will contain:

    - a phased LC plot with the period and epoch set after review using the
      times, mags, errs after any appropriate filtering and sigclip was done in
      the checkplotserver UI

    - The unphased LC using the times, mags, errs after any appropriate
      filtering and sigclip was done in the checkplotserver UI

    - the same plots for any LC collection neighbors

    - the survey cutout for the object if objfits is provided and checks out

    - a redone neighbor search using GAIA and all light curves in the collection
      even if they don't have at least 1000 observations.

    These items will be shown in a special 'Final' tab in the `checkplotserver`
    webapp (this should be run in `readonly` mode as well). The final tab will
    also contain downloadable links for the checkplot pickle in pkl and PNG
    format, as well as the final times, mags, errs as a gzipped CSV with a
    header containing all of this info.

    Parameters
    ----------

    cpx : dict or str
        This is the path to the checkplot dict or pickle file to process.

    outdir : str
        This is the directory to where the final pickle will be written. If this
        is set to the same dir as `cpx` and `cpx` is a pickle, the function will
        return a failure. This is meant to keep the in-process checkplots
        separate from the finalized versions.

    all_lclistpkl : str or dict
        This is the path to the pickle or the dict created by
        :py:func:`astrobase.lcproc.catalogs.make_lclist` with no restrictions on
        the number of observations (so ALL light curves in the collection). This
        is used to make sure all neighbors of this object in the light curve
        collection have had their proximity to this object noted.

    objfits : str or None
        If this is not None, should be a file path to a FITS file containing a
        WCS header and this object from the instrument that was used to observe
        it. This will be used to make a stamp cutout of the object using the
        actual image it was detected on. This will be a useful comparison to the
        usual DSS POSS-RED2 image used by the checkplots.

    Returns
    -------

    str
        The path to the updated checkplot pickle file with a 'final' key added
        to it , as described above.


This is a parallel driver for `finalize_checkplot`, operating on a
    directory of checkplots.

    Parameters
    ----------

    cpdir : str
        This is the path to the directory containing all the checkplot pickles
        to process and run through the finalization process.

    outdir : str
        The directory to where the finalized checkplot pickles will be written.

    objfits : str
        Path to the FITS file containing a WCS header and detections of all
        objects observed by the actual instrument that obtained the light
        curves. This should generally be a high quality 'reference' frame so
        that all of the objects whose checkplots we're finalizing (in `cplist`)
        can be seen on the frame.

    Returns
    -------

    dict
        Dict indicating the success/failure (as True/False) of the checkplot
        finalize operations for each checkplot pickle provided in `cplist`.


def load_xmatch_external_catalogs(xmatchto, xmatchkeys, outfile=None):

outdict = {}<EOL>for xc, xk in zip(xmatchto, xmatchkeys):<EOL><INDENT>parsed_catdef = _parse_xmatch_catalog_header(xc, xk)<EOL>if not parsed_catdef:<EOL><INDENT>continue<EOL><DEDENT>(infd, catdefdict,<EOL>catcolinds, catcoldtypes,<EOL>catcolnames, catcolunits) = parsed_catdef<EOL>catarr = np.genfromtxt(infd,<EOL>usecols=catcolinds,<EOL>names=xk,<EOL>dtype='<STR_LIT:U+002C>'.join(catcoldtypes),<EOL>comments='<STR_LIT:#>',<EOL>delimiter='<STR_LIT:|>',<EOL>autostrip=True)<EOL>infd.close()<EOL>catshortname = os.path.splitext(os.path.basename(xc))[<NUM_LIT:0>]<EOL>catshortname = catshortname.replace('<STR_LIT>','<STR_LIT>')<EOL>objra, objdecl = (catarr[catdefdict['<STR_LIT>']],<EOL>catarr[catdefdict['<STR_LIT>']])<EOL>cosdecl = np.cos(np.radians(objdecl))<EOL>sindecl = np.sin(np.radians(objdecl))<EOL>cosra = np.cos(np.radians(objra))<EOL>sinra = np.sin(np.radians(objra))<EOL>xyz = np.column_stack((cosra*cosdecl,sinra*cosdecl, sindecl))<EOL>kdt = cKDTree(xyz,copy_data=True)<EOL>catoutdict = {'<STR_LIT>':kdt,<EOL>'<STR_LIT:data>':catarr,<EOL>'<STR_LIT>':xk,<EOL>'<STR_LIT>':catcolnames,<EOL>'<STR_LIT>':catcolunits,<EOL>'<STR_LIT:name>':catdefdict['<STR_LIT:name>'],<EOL>'<STR_LIT>':catdefdict['<STR_LIT:description>']}<EOL>outdict[catshortname] = catoutdict<EOL><DEDENT>if outfile is not None:<EOL><INDENT>if sys.platform == '<STR_LIT>':<EOL><INDENT>dumpbytes = pickle.dumps(outdict, protocol=pickle.HIGHEST_PROTOCOL)<EOL>max_bytes = <NUM_LIT:2>**<NUM_LIT> - <NUM_LIT:1><EOL>with open(outfile, '<STR_LIT:wb>') as outfd:<EOL><INDENT>for idx in range(<NUM_LIT:0>, len(dumpbytes), max_bytes):<EOL><INDENT>outfd.write(dumpbytes[idx:idx+max_bytes])<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>with open(outfile, '<STR_LIT:wb>') as outfd:<EOL><INDENT>pickle.dump(outdict, outfd, pickle.HIGHEST_PROTOCOL)<EOL><DEDENT><DEDENT>return outfile<EOL><DEDENT>else:<EOL><INDENT>return outdict<EOL><DEDENT>

This loads the external xmatch catalogs into a dict for use in an xmatch.

    Parameters
    ----------

    xmatchto : list of str
        This is a list of paths to all the catalog text files that will be
        loaded.

        The text files must be 'CSVs' that use the '|' character as the
        separator betwen columns. These files should all begin with a header in
        JSON format on lines starting with the '#' character. this header will
        define the catalog and contains the name of the catalog and the column
        definitions. Column definitions must have the column name and the numpy
        dtype of the columns (in the same format as that expected for the
        numpy.genfromtxt function). Any line that does not begin with '#' is
        assumed to be part of the columns in the catalog. An example is shown
        below::

            # {"name":"NSVS catalog of variable stars",
            #  "columns":[
            #   {"key":"objectid", "dtype":"U20", "name":"Object ID", "unit": null},
            #   {"key":"ra", "dtype":"f8", "name":"RA", "unit":"deg"},
            #   {"key":"decl","dtype":"f8", "name": "Declination", "unit":"deg"},
            #   {"key":"sdssr","dtype":"f8","name":"SDSS r", "unit":"mag"},
            #   {"key":"vartype","dtype":"U20","name":"Variable type", "unit":null}
            #  ],
            #  "colra":"ra",
            #  "coldec":"decl",
            #  "description":"Contains variable stars from the NSVS catalog"}
            objectid1 | 45.0  | -20.0 | 12.0 | detached EB
            objectid2 | 145.0 | 23.0  | 10.0 | RRab
            objectid3 | 12.0  | 11.0  | 14.0 | Cepheid
            .
            .
            .

    xmatchkeys : list of lists
        This is the list of lists of column names (as str) to get out of each
        `xmatchto` catalog. This should be the same length as `xmatchto` and
        each element here will apply to the respective file in `xmatchto`.

    outfile : str or None
        If this is not None, set this to the name of the pickle to write the
        collected xmatch catalogs to. this pickle can then be loaded
        transparently by the :py:func:`astrobase.checkplot.pkl.checkplot_dict`,
        :py:func:`astrobase.checkplot.pkl.checkplot_pickle` functions to provide
        xmatch info to the
        :py:func:`astrobase.checkplot.pkl_xmatch.xmatch_external_catalogs`
        function below.

        If this is None, will return the loaded xmatch catalogs directly. This
        will be a huge dict, so make sure you have enough RAM.

    Returns
    -------

    str or dict
        Based on the `outfile` kwarg, will either return the path to a collected
        xmatch pickle file or the collected xmatch dict.


scaledplottime = stimes - npmin(stimes)<EOL>axes.plot(scaledplottime,<EOL>smags,<EOL>marker='<STR_LIT:o>',<EOL>ms=ms, ls='<STR_LIT:None>',mew=<NUM_LIT:0>,<EOL>color='<STR_LIT>',<EOL>rasterized=True)<EOL>if not magsarefluxes:<EOL><INDENT>plot_ylim = axes.get_ylim()<EOL>axes.set_ylim((plot_ylim[<NUM_LIT:1>], plot_ylim[<NUM_LIT:0>]))<EOL><DEDENT>axes.set_xlim((npmin(scaledplottime)-<NUM_LIT:1.0>,<EOL>npmax(scaledplottime)+<NUM_LIT:1.0>))<EOL>axes.grid(color='<STR_LIT>',<EOL>alpha=<NUM_LIT>,<EOL>zorder=<NUM_LIT:0>,<EOL>linewidth=<NUM_LIT:1.0>,<EOL>linestyle='<STR_LIT::>')<EOL>plot_xlabel = '<STR_LIT>' % npmin(stimes)<EOL>if magsarefluxes:<EOL><INDENT>plot_ylabel = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>plot_ylabel = '<STR_LIT>'<EOL><DEDENT>axes.set_xlabel(plot_xlabel)<EOL>axes.set_ylabel(plot_ylabel)<EOL>axes.get_yaxis().get_major_formatter().set_useOffset(False)<EOL>axes.get_xaxis().get_major_formatter().set_useOffset(False)<EOL>

Makes the mag-series plot tile for `checkplot_png` and
    `twolsp_checkplot_png`.

    axes : matplotlib.axes.Axes object
        The Axes object where the generated plot will go.

    stimes,smags,serrs : np.array
        The mag/flux time-series arrays along with associated errors. These
        should all have been run through nan-stripping and sigma-clipping
        beforehand.

    magsarefluxes : bool
        If True, indicates the input time-series is fluxes and not mags so the
        plot y-axis direction and range can be set appropriately.

    ms : float
        The `markersize` kwarg to use when making the mag-series plot.

    Returns
    -------

    Does not return anything, works on the input Axes object directly.


plotvarepoch = None<EOL>if varepoch is None:<EOL><INDENT>plotvarepoch = npmin(stimes)<EOL><DEDENT>elif isinstance(varepoch, str) and varepoch == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>spfit = spline_fit_magseries(stimes,<EOL>smags,<EOL>serrs,<EOL>varperiod,<EOL>magsarefluxes=magsarefluxes,<EOL>sigclip=None,<EOL>verbose=verbose)<EOL>plotvarepoch = spfit['<STR_LIT>']['<STR_LIT>']<EOL>if len(plotvarepoch) != <NUM_LIT:1>:<EOL><INDENT>plotvarepoch = varepoch[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGERROR('<STR_LIT>')<EOL>sgfit = savgol_fit_magseries(stimes,<EOL>smags,<EOL>serrs,<EOL>varperiod,<EOL>sigclip=None,<EOL>magsarefluxes=magsarefluxes,<EOL>verbose=verbose)<EOL>plotvarepoch = sgfit['<STR_LIT>']['<STR_LIT>']<EOL>if len(plotvarepoch) != <NUM_LIT:1>:<EOL><INDENT>plotvarepoch = plotvarepoch[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if plotvarepoch is None:<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>plotvarepoch = npmin(stimes)<EOL><DEDENT><DEDENT><DEDENT>elif isinstance(varepoch, list):<EOL><INDENT>try:<EOL><INDENT>if twolspmode:<EOL><INDENT>thisvarepochlist = varepoch[lspmethodind]<EOL>plotvarepoch = thisvarepochlist[periodind]<EOL><DEDENT>else:<EOL><INDENT>plotvarepoch = varepoch[periodind]<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL>plotvarepoch = npmin(stimes)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>plotvarepoch = varepoch<EOL><DEDENT>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' %<EOL>(varperiod, plotvarepoch))<EOL><DEDENT>phasedlc = phase_magseries(stimes,<EOL>smags,<EOL>varperiod,<EOL>plotvarepoch,<EOL>wrap=phasewrap,<EOL>sort=phasesort)<EOL>plotphase = phasedlc['<STR_LIT>']<EOL>plotmags = phasedlc['<STR_LIT>']<EOL>if phasebin:<EOL><INDENT>binphasedlc = phase_bin_magseries(plotphase,<EOL>plotmags,<EOL>binsize=phasebin,<EOL>minbinelems=minbinelems)<EOL>binplotphase = binphasedlc['<STR_LIT>']<EOL>binplotmags = binphasedlc['<STR_LIT>']<EOL><DEDENT>axes.plot(plotphase,<EOL>plotmags,<EOL>marker='<STR_LIT:o>',<EOL>ms=phasems, ls='<STR_LIT:None>',mew=<NUM_LIT:0>,<EOL>color='<STR_LIT>',<EOL>rasterized=True)<EOL>if phasebin:<EOL><INDENT>axes.plot(binplotphase,<EOL>binplotmags,<EOL>marker='<STR_LIT:o>',<EOL>ms=phasebinms, ls='<STR_LIT:None>',mew=<NUM_LIT:0>,<EOL>color='<STR_LIT>',<EOL>rasterized=True)<EOL><DEDENT>if not magsarefluxes:<EOL><INDENT>plot_ylim = axes.get_ylim()<EOL>axes.set_ylim((plot_ylim[<NUM_LIT:1>], plot_ylim[<NUM_LIT:0>]))<EOL><DEDENT>if not plotxlim:<EOL><INDENT>axes.set_xlim((npmin(plotphase)-<NUM_LIT:0.1>,<EOL>npmax(plotphase)+<NUM_LIT:0.1>))<EOL><DEDENT>else:<EOL><INDENT>axes.set_xlim((plotxlim[<NUM_LIT:0>],plotxlim[<NUM_LIT:1>]))<EOL><DEDENT>axes.grid(color='<STR_LIT>',<EOL>alpha=<NUM_LIT>,<EOL>zorder=<NUM_LIT:0>,<EOL>linewidth=<NUM_LIT:1.0>,<EOL>linestyle='<STR_LIT::>')<EOL>plot_xlabel = '<STR_LIT>'<EOL>if magsarefluxes:<EOL><INDENT>plot_ylabel = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>plot_ylabel = '<STR_LIT>'<EOL><DEDENT>axes.set_xlabel(plot_xlabel)<EOL>axes.set_ylabel(plot_ylabel)<EOL>axes.get_yaxis().get_major_formatter().set_useOffset(False)<EOL>axes.get_xaxis().get_major_formatter().set_useOffset(False)<EOL>if periodind == <NUM_LIT:0>:<EOL><INDENT>plottitle = '<STR_LIT>' % (<EOL>METHODSHORTLABELS[lspmethod],<EOL>varperiod,<EOL>plotvarepoch<EOL>)<EOL><DEDENT>elif periodind == <NUM_LIT:1> and not twolspmode:<EOL><INDENT>plottitle = '<STR_LIT>' % (<EOL>METHODSHORTLABELS[lspmethod],<EOL>varperiod,<EOL>plotvarepoch<EOL>)<EOL><DEDENT>elif periodind == <NUM_LIT:2> and not twolspmode:<EOL><INDENT>plottitle = '<STR_LIT>' % (<EOL>METHODSHORTLABELS[lspmethod],<EOL>varperiod,<EOL>plotvarepoch<EOL>)<EOL><DEDENT>elif periodind > <NUM_LIT:2> and not twolspmode:<EOL><INDENT>plottitle = '<STR_LIT>' % (<EOL>METHODSHORTLABELS[lspmethod],<EOL>periodind-<NUM_LIT:1>,<EOL>varperiod,<EOL>plotvarepoch<EOL>)<EOL><DEDENT>elif periodind > <NUM_LIT:0>:<EOL><INDENT>plottitle = '<STR_LIT>' % (<EOL>METHODSHORTLABELS[lspmethod],<EOL>periodind+<NUM_LIT:1>,<EOL>varperiod,<EOL>plotvarepoch<EOL>)<EOL><DEDENT>axes.set_title(plottitle)<EOL>if (plotxlim and isinstance(plotxlim, (list,tuple)) and<EOL>len(plotxlim) == <NUM_LIT:2> and xliminsetmode is True):<EOL><INDENT>axesylim = axes.get_ylim()<EOL>if magsarefluxes:<EOL><INDENT>axes.set_ylim(axesylim[<NUM_LIT:0>],<EOL>axesylim[<NUM_LIT:1>] + <NUM_LIT:0.5>*npabs(axesylim[<NUM_LIT:1>]-axesylim[<NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>axes.set_ylim(axesylim[<NUM_LIT:0>],<EOL>axesylim[<NUM_LIT:1>] - <NUM_LIT:0.5>*npabs(axesylim[<NUM_LIT:1>]-axesylim[<NUM_LIT:0>]))<EOL><DEDENT>inset = inset_axes(axes, width="<STR_LIT>", height="<STR_LIT>", loc=<NUM_LIT:1>)<EOL>inset.plot(plotphase,<EOL>plotmags,<EOL>marker='<STR_LIT:o>',<EOL>ms=<NUM_LIT>, ls='<STR_LIT:None>',mew=<NUM_LIT:0>,<EOL>color='<STR_LIT>',<EOL>rasterized=True)<EOL>if phasebin:<EOL><INDENT>inset.plot(binplotphase,<EOL>binplotmags,<EOL>marker='<STR_LIT:o>',<EOL>ms=<NUM_LIT>, ls='<STR_LIT:None>',mew=<NUM_LIT:0>,<EOL>color='<STR_LIT>',<EOL>rasterized=True)<EOL><DEDENT>if phasewrap:<EOL><INDENT>inset.set_xlim(-<NUM_LIT>,<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>inset.set_xlim(-<NUM_LIT:0.1>,<NUM_LIT>)<EOL><DEDENT>if not magsarefluxes:<EOL><INDENT>inset_ylim = inset.get_ylim()<EOL>inset.set_ylim((inset_ylim[<NUM_LIT:1>], inset_ylim[<NUM_LIT:0>]))<EOL><DEDENT>inset.text(<NUM_LIT:0.5>,<NUM_LIT:0.1>,'<STR_LIT>',<EOL>ha='<STR_LIT>',va='<STR_LIT>',transform=inset.transAxes)<EOL>inset.set_xticks([])<EOL>inset.set_yticks([])<EOL><DEDENT>

Makes the phased magseries plot tile for the `checkplot_png` and
    `twolsp_checkplot_png` functions.

    Parameters
    ----------

    axes : matplotlib.axes.Axes object
        The Axes object where the generated plot will be written.

    periodind : int
        The index of the current best period being processed in the lspinfo
        dict.

    stimes,smags,serrs : np.array
        The mag/flux time-series arrays along with associated errors. These
        should all have been run through nan-stripping and sigma-clipping
        beforehand.

    varperiod : float or None
        The period to use for this phased light curve plot tile.

    varepoch : 'min' or float or list of lists or None
        The epoch to use for this phased light curve plot tile. If this is a
        float, will use the provided value directly. If this is 'min', will
        automatically figure out the time-of-minimum of the phased light
        curve. If this is None, will use the mimimum value of `stimes` as the
        epoch of the phased light curve plot. If this is a list of lists, will
        use the provided value of `lspmethodind` to look up the current
        period-finder method and the provided value of `periodind` to look up
        the epoch associated with that method and the current period. This is
        mostly only useful when `twolspmode` is True.

    phasewrap : bool
        If this is True, the phased time-series will be wrapped around
        phase 0.0.

    phasesort : bool
        If True, will sort the phased light curve in order of increasing phase.

    phasebin: float
        The bin size to use to group together measurements closer than this
        amount in phase. This is in units of phase. If this is a float, a
        phase-binned version of the phased light curve will be overplotted on
        top of the regular phased light curve.

    minbinelems : int
        The minimum number of elements required per phase bin to include it in
        the phased LC plot.

    plotxlim : sequence of two floats or None
        The x-range (min, max) of the phased light curve plot. If None, will be
        determined automatically.

    lspmethod : str
        One of the three-letter keys corresponding to period-finder method names
        in the `astrobase.plotbase.METHODSHORTLABELS` dict. Used to set the plot
        title correctly.

    lspmethodind : int
        If `twolspmode` is set, this will be used to look up the correct epoch
        associated with the current period-finder method and period.

    xliminsetmode : bool
        If this is True, the generated phased light curve plot will use the
        values of `plotxlim` as the main plot x-axis limits (i.e. zoomed-in if
        `plotxlim` is a range smaller than the full phase range), and will show
        the full phased light curve plot as an smaller inset. Useful for
        planetary transit light curves.

    twolspmode : bool
        If this is True, will use the `lspmethodind` and `periodind` to look up
        the correct values of epoch, etc. in the provided `varepoch` list of
        lists for plotting purposes.

    magsarefluxes : bool
        If True, indicates the input time-series is fluxes and not mags so the
        plot y-axis direction and range can be set appropriately.

    verbose : bool
        If True, indicates progress.

    phasems : float
        The marker size to use for the main phased light curve plot symbols.

    phasebinms : float
        The marker size to use for the binned phased light curve plot symbols.

    Returns
    -------

    Does not return anything, works on the input Axes object directly.


if not outfile and isinstance(lspinfo,str):<EOL><INDENT>plotfpath = os.path.join(<EOL>os.path.dirname(lspinfo),<EOL>'<STR_LIT>' % (<EOL>os.path.basename(lspinfo),<EOL>)<EOL>)<EOL><DEDENT>elif outfile:<EOL><INDENT>plotfpath = outfile<EOL><DEDENT>else:<EOL><INDENT>plotfpath = '<STR_LIT>'<EOL><DEDENT>if isinstance(lspinfo,str) and os.path.exists(lspinfo):<EOL><INDENT>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' % lspinfo)<EOL><DEDENT>if '<STR_LIT>' in lspinfo:<EOL><INDENT>with gzip.open(lspinfo,'<STR_LIT:rb>') as infd:<EOL><INDENT>lspinfo = pickle.load(infd)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with open(lspinfo,'<STR_LIT:rb>') as infd:<EOL><INDENT>lspinfo = pickle.load(infd)<EOL><DEDENT><DEDENT><DEDENT>if ('<STR_LIT>' in lspinfo and<EOL>'<STR_LIT>' in lspinfo and<EOL>'<STR_LIT>' in lspinfo):<EOL><INDENT>bestperiod = lspinfo['<STR_LIT>']<EOL>nbestperiods = lspinfo['<STR_LIT>']<EOL>lspmethod = lspinfo['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>')<EOL>return None<EOL><DEDENT>if not npisfinite(bestperiod):<EOL><INDENT>LOGWARNING('<STR_LIT>')<EOL>return None<EOL><DEDENT>fig, axes = plt.subplots(<NUM_LIT:3>,<NUM_LIT:3>)<EOL>axes = npravel(axes)<EOL>fig.set_size_inches(<NUM_LIT:30>,<NUM_LIT>)<EOL>_make_periodogram(axes[<NUM_LIT:0>],lspinfo,objectinfo,<EOL>findercmap, finderconvolve,<EOL>verbose=verbose,<EOL>findercachedir=findercachedir)<EOL>stimes, smags, serrs = sigclip_magseries(times,<EOL>mags,<EOL>errs,<EOL>magsarefluxes=magsarefluxes,<EOL>sigclip=sigclip)<EOL>if normto is not False:<EOL><INDENT>stimes, smags = normalize_magseries(stimes, smags,<EOL>normto=normto,<EOL>magsarefluxes=magsarefluxes,<EOL>mingap=normmingap)<EOL><DEDENT>if len(stimes) >= <NUM_LIT:50>:<EOL><INDENT>_make_magseries_plot(axes[<NUM_LIT:1>], stimes, smags, serrs,<EOL>magsarefluxes=magsarefluxes)<EOL>lspbestperiods = nbestperiods[::]<EOL>lspperiodone = lspbestperiods[<NUM_LIT:0>]<EOL>lspbestperiods.insert(<NUM_LIT:1>,lspperiodone*<NUM_LIT>)<EOL>lspbestperiods.insert(<NUM_LIT:1>,lspperiodone*<NUM_LIT:0.5>)<EOL>for periodind, varperiod in enumerate(lspbestperiods):<EOL><INDENT>if periodind == <NUM_LIT:0> and bestperiodhighlight:<EOL><INDENT>if MPLVERSION >= (<NUM_LIT:2>,<NUM_LIT:0>,<NUM_LIT:0>):<EOL><INDENT>axes[periodind+<NUM_LIT:2>].set_facecolor(bestperiodhighlight)<EOL><DEDENT>else:<EOL><INDENT>axes[periodind+<NUM_LIT:2>].set_axis_bgcolor(bestperiodhighlight)<EOL><DEDENT><DEDENT>_make_phased_magseries_plot(axes[periodind+<NUM_LIT:2>],<EOL>periodind,<EOL>stimes, smags, serrs,<EOL>varperiod, varepoch,<EOL>phasewrap, phasesort,<EOL>phasebin, minbinelems,<EOL>plotxlim, lspmethod,<EOL>xliminsetmode=xliminsetmode,<EOL>magsarefluxes=magsarefluxes,<EOL>verbose=verbose)<EOL><DEDENT>fig.set_tight_layout(True)<EOL>if plotfpath.endswith('<STR_LIT>'):<EOL><INDENT>fig.savefig(plotfpath,dpi=plotdpi)<EOL><DEDENT>else:<EOL><INDENT>fig.savefig(plotfpath)<EOL><DEDENT>plt.close('<STR_LIT:all>')<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' % plotfpath)<EOL><DEDENT>return plotfpath<EOL><DEDENT>else:<EOL><INDENT>LOGWARNING('<STR_LIT>')<EOL>for periodind in range(<NUM_LIT:5>):<EOL><INDENT>axes[periodind+<NUM_LIT:2>].text(<EOL><NUM_LIT:0.5>,<NUM_LIT:0.5>,<EOL>('<STR_LIT>'),<EOL>horizontalalignment='<STR_LIT>',<EOL>verticalalignment='<STR_LIT>',<EOL>transform=axes[periodind+<NUM_LIT:2>].transAxes<EOL>)<EOL><DEDENT>fig.set_tight_layout(True)<EOL>if plotfpath.endswith('<STR_LIT>'):<EOL><INDENT>fig.savefig(plotfpath, dpi=plotdpi)<EOL><DEDENT>else:<EOL><INDENT>fig.savefig(plotfpath)<EOL><DEDENT>plt.close('<STR_LIT:all>')<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' % plotfpath)<EOL><DEDENT>return plotfpath<EOL><DEDENT>

This makes a checkplot PNG using the output from a period-finder routine.

    A checkplot is a 3 x 3 grid of plots like so::

        [periodogram + objectinfo] [     unphased LC     ] [period 1 phased LC]
        [  period 1 phased LC /2 ] [period 1 phased LC x2] [period 2 phased LC]
        [   period 3 phased LC   ] [period 4 phased LC   ] [period 5 phased LC]

    This is used to sanity check the five best periods obtained from a
    period-finder function in `astrobase.periodbase` or from your own
    period-finder routines if their results can be turned into a dict with the
    format shown below.

    Parameters
    ----------

    lspinfo : dict or str
        If this is a dict, it must be a dict produced by an
        `astrobase.periodbase` period-finder function or a dict from your own
        period-finder function or routine that is of the form below with at
        least these keys::

            {'periods': np.array of all periods searched by the period-finder,
             'lspvals': np.array of periodogram power value for each period,
             'bestperiod': a float value that is the period with the highest
                           peak in the periodogram, i.e. the most-likely actual
                           period,
             'method': a three-letter code naming the period-finder used; must
                       be one of the keys in the
                       `astrobase.periodbase.METHODLABELS` dict,
             'nbestperiods': a list of the periods corresponding to periodogram
                             peaks (`nbestlspvals` below) to annotate on the
                             periodogram plot so they can be called out
                             visually,
             'nbestlspvals': a list of the power values associated with
                             periodogram peaks to annotate on the periodogram
                             plot so they can be called out visually; should be
                             the same length as `nbestperiods` above}

        `nbestperiods` and `nbestlspvals` must have at least 5 elements each,
        e.g. describing the five 'best' (highest power) peaks in the
        periodogram.

        If lspinfo is a str, then it must be a path to a pickle file (ending
        with the extension '.pkl' or '.pkl.gz') that contains a dict of the form
        described above.

    times,mags,errs : np.array
        The mag/flux time-series arrays to process along with associated errors.

    varepoch : 'min' or float or None or list of lists
        This 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='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

            If varepoch is a list of floats        each epoch will be applied to
            with length = `len(nbestperiods)+2` -> 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.

    magsarefluxes : bool
        If True, indicates the input time-series is fluxes and not mags so the
        plot y-axis direction and range can be set appropriately.

    objectinfo : dict or None
        If provided, this is a dict containing information on the object whose
        light curve is being processed. This function will then be able to look
        up and download a finder chart for this object and write that to the
        output checkplot PNG image.The `objectinfo` dict must be of the form and
        contain at least the keys described below::

            {'objectid': the name of the object,
             'ra': the right ascension of the object in decimal degrees,
             'decl': the declination of the object in decimal degrees,
             'ndet': the number of observations of this object}

        You can also provide magnitudes and proper motions of the object using
        the following keys and the appropriate values in the `objectinfo`
        dict. These will be used to calculate colors, total and reduced proper
        motion, etc. and display these in the output checkplot PNG.

        - SDSS mag keys: 'sdssu', 'sdssg', 'sdssr', 'sdssi', 'sdssz'
        - 2MASS mag keys: 'jmag', 'hmag', 'kmag'
        - Cousins mag keys: 'bmag', 'vmag'
        - GAIA specific keys: 'gmag', 'teff'
        - proper motion keys: 'pmra', 'pmdecl'

    findercmap : str or matplotlib.cm.ColorMap object
        The Colormap object to use for the finder chart image.

    finderconvolve : astropy.convolution.Kernel object or None
        If not None, the Kernel object to use for convolving the finder image.

    findercachedir : str
        The directory where the FITS finder images are downloaded and cached.

    normto : {'globalmedian', 'zero'} or a float
        This sets the normalization target::

            'globalmedian' -> norms each mag to global median of the LC column
            'zero'         -> norms each mag to zero
            a float        -> norms each mag to this specified float value.

    normmingap : float
        This defines how much the difference between consecutive measurements is
        allowed to be to consider them as parts of different timegroups. By
        default it is set to 4.0 days.

    sigclip : float or int or sequence of two floats/ints or None
        If a single float or int, a symmetric sigma-clip will be performed using
        the number provided as the sigma-multiplier to cut out from the input
        time-series.

        If a list of two ints/floats is provided, the function will perform an
        'asymmetric' sigma-clip. The first element in this list is the sigma
        value to use for fainter flux/mag values; the second element in this
        list is the sigma value to use for brighter flux/mag values. For
        example, `sigclip=[10., 3.]`, will sigclip out greater than 10-sigma
        dimmings and greater than 3-sigma brightenings. Here the meaning of
        "dimming" and "brightening" is set by *physics* (not the magnitude
        system), which is why the `magsarefluxes` kwarg must be correctly set.

        If `sigclip` is None, no sigma-clipping will be performed, and the
        time-series (with non-finite elems removed) will be passed through to
        the output.

    phasewrap : bool
        If this is True, the phased time-series will be wrapped around phase
        0.0.

    phasesort : bool
        If this is True, the phased time-series will be sorted in phase.

    phasebin : float or None
        If this is provided, indicates the bin size to use to group together
        measurements closer than this amount in phase. This is in units of
        phase. The binned phased light curve will be overplotted on top of the
        phased light curve. Useful for when one has many measurement points and
        needs to pick out a small trend in an otherwise noisy phased light
        curve.

    minbinelems : int
        The minimum number of elements in each phase bin.

    plotxlim : sequence of two floats or None
        The x-axis limits to use when making the phased light curve plot. By
        default, this is (-0.8, 0.8), which places phase 0.0 at the center of
        the plot and covers approximately two cycles in phase to make any trends
        clear.

    xliminsetmode : bool
        If this is True, the generated phased light curve plot will use the
        values of `plotxlim` as the main plot x-axis limits (i.e. zoomed-in if
        `plotxlim` is a range smaller than the full phase range), and will show
        the full phased light curve plot as an smaller inset. Useful for
        planetary transit light curves.

    bestperiodhighlight : str or None
        If not None, this is a str with a matplotlib color specification to use
        as the background color to highlight the phased light curve plot of the
        'best' period and epoch combination. If None, no highlight will be
        applied.

    outfile : str or None
        The file name of the file to save the checkplot to. If this is None,
        will write to a file called 'checkplot.png' in the current working
        directory.

    plotdpi : int
        Sets the resolution in DPI for PNG plots (default = 100).

    verbose : bool
        If False, turns off many of the informational messages. Useful for
        when an external function is driving lots of `checkplot_png` calls.

    Returns
    -------

    str
        The file path to the generated checkplot PNG file.


<EOL>if not outfile and isinstance(lspinfo1,str):<EOL><INDENT>plotfpath = os.path.join(<EOL>os.path.dirname(lspinfo1),<EOL>'<STR_LIT>' % (<EOL>os.path.basename(lspinfo1),<EOL>)<EOL>)<EOL><DEDENT>elif outfile:<EOL><INDENT>plotfpath = outfile<EOL><DEDENT>else:<EOL><INDENT>plotfpath = '<STR_LIT>'<EOL><DEDENT>if isinstance(lspinfo1,str) and os.path.exists(lspinfo1):<EOL><INDENT>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' % lspinfo1)<EOL><DEDENT>if '<STR_LIT>' in lspinfo1:<EOL><INDENT>with gzip.open(lspinfo1,'<STR_LIT:rb>') as infd:<EOL><INDENT>lspinfo1 = pickle.load(infd)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with open(lspinfo1,'<STR_LIT:rb>') as infd:<EOL><INDENT>lspinfo1 = pickle.load(infd)<EOL><DEDENT><DEDENT><DEDENT>if isinstance(lspinfo2,str) and os.path.exists(lspinfo2):<EOL><INDENT>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' % lspinfo2)<EOL><DEDENT>if '<STR_LIT>' in lspinfo2:<EOL><INDENT>with gzip.open(lspinfo2,'<STR_LIT:rb>') as infd:<EOL><INDENT>lspinfo2 = pickle.load(infd)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with open(lspinfo2,'<STR_LIT:rb>') as infd:<EOL><INDENT>lspinfo2 = pickle.load(infd)<EOL><DEDENT><DEDENT><DEDENT>if ('<STR_LIT>' in lspinfo1 and '<STR_LIT>' in lspinfo2 and<EOL>'<STR_LIT>' in lspinfo1 and '<STR_LIT>' in lspinfo2 and<EOL>'<STR_LIT>' in lspinfo1 and '<STR_LIT>' in lspinfo2):<EOL><INDENT>bestperiod1 = lspinfo1['<STR_LIT>']<EOL>nbestperiods1 = lspinfo1['<STR_LIT>']<EOL>lspmethod1 = lspinfo1['<STR_LIT>']<EOL>bestperiod2 = lspinfo2['<STR_LIT>']<EOL>nbestperiods2 = lspinfo2['<STR_LIT>']<EOL>lspmethod2 = lspinfo2['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>return None<EOL><DEDENT>if (not npisfinite(bestperiod1)) or (not npisfinite(bestperiod2)):<EOL><INDENT>LOGWARNING('<STR_LIT>')<EOL>return None<EOL><DEDENT>fig, axes = plt.subplots(<NUM_LIT:3>,<NUM_LIT:3>)<EOL>axes = npravel(axes)<EOL>fig.set_size_inches(<NUM_LIT:30>,<NUM_LIT>)<EOL>_make_periodogram(axes[<NUM_LIT:0>], lspinfo1, objectinfo,<EOL>findercmap, finderconvolve,<EOL>verbose=verbose,<EOL>findercachedir=findercachedir)<EOL>_make_periodogram(axes[<NUM_LIT:1>], lspinfo2, None,<EOL>findercmap, finderconvolve)<EOL>stimes, smags, serrs = sigclip_magseries(times,<EOL>mags,<EOL>errs,<EOL>magsarefluxes=magsarefluxes,<EOL>sigclip=sigclip)<EOL>if normto is not False:<EOL><INDENT>stimes, smags = normalize_magseries(stimes, smags,<EOL>normto=normto,<EOL>magsarefluxes=magsarefluxes,<EOL>mingap=normmingap)<EOL><DEDENT>if len(stimes) >= <NUM_LIT:50>:<EOL><INDENT>_make_magseries_plot(axes[<NUM_LIT:2>], stimes, smags, serrs,<EOL>magsarefluxes=magsarefluxes,<EOL>ms=unphasedms)<EOL>lspbestperiods1 = nbestperiods1[::]<EOL>lspbestperiods2 = nbestperiods2[::]<EOL>for periodind, varperiod, plotaxes in zip([<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:2>],<EOL>lspbestperiods1[:<NUM_LIT:3>],<EOL>[axes[<NUM_LIT:3>], axes[<NUM_LIT:4>], axes[<NUM_LIT:5>]]):<EOL><INDENT>if periodind == <NUM_LIT:0> and bestperiodhighlight:<EOL><INDENT>if MPLVERSION >= (<NUM_LIT:2>,<NUM_LIT:0>,<NUM_LIT:0>):<EOL><INDENT>plotaxes.set_facecolor(bestperiodhighlight)<EOL><DEDENT>else:<EOL><INDENT>plotaxes.set_axis_bgcolor(bestperiodhighlight)<EOL><DEDENT><DEDENT>_make_phased_magseries_plot(plotaxes,<EOL>periodind,<EOL>stimes, smags, serrs,<EOL>varperiod, varepoch,<EOL>phasewrap, phasesort,<EOL>phasebin, minbinelems,<EOL>plotxlim, lspmethod1,<EOL>lspmethodind=<NUM_LIT:0>,<EOL>twolspmode=True,<EOL>magsarefluxes=magsarefluxes,<EOL>xliminsetmode=xliminsetmode,<EOL>verbose=verbose,<EOL>phasems=phasems,<EOL>phasebinms=phasebinms)<EOL><DEDENT>for periodind, varperiod, plotaxes in zip([<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:2>],<EOL>lspbestperiods2[:<NUM_LIT:3>],<EOL>[axes[<NUM_LIT:6>], axes[<NUM_LIT:7>], axes[<NUM_LIT:8>]]):<EOL><INDENT>if periodind == <NUM_LIT:0> and bestperiodhighlight:<EOL><INDENT>if MPLVERSION >= (<NUM_LIT:2>,<NUM_LIT:0>,<NUM_LIT:0>):<EOL><INDENT>plotaxes.set_facecolor(bestperiodhighlight)<EOL><DEDENT>else:<EOL><INDENT>plotaxes.set_axis_bgcolor(bestperiodhighlight)<EOL><DEDENT><DEDENT>_make_phased_magseries_plot(plotaxes,<EOL>periodind,<EOL>stimes, smags, serrs,<EOL>varperiod, varepoch,<EOL>phasewrap, phasesort,<EOL>phasebin, minbinelems,<EOL>plotxlim, lspmethod2,<EOL>lspmethodind=<NUM_LIT:1>,<EOL>twolspmode=True,<EOL>magsarefluxes=magsarefluxes,<EOL>xliminsetmode=xliminsetmode,<EOL>verbose=verbose,<EOL>phasems=phasems,<EOL>phasebinms=phasebinms)<EOL><DEDENT>fig.set_tight_layout(True)<EOL>if plotfpath.endswith('<STR_LIT>'):<EOL><INDENT>fig.savefig(plotfpath,dpi=plotdpi)<EOL><DEDENT>else:<EOL><INDENT>fig.savefig(plotfpath)<EOL><DEDENT>plt.close()<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' % plotfpath)<EOL><DEDENT>return plotfpath<EOL><DEDENT>else:<EOL><INDENT>LOGWARNING('<STR_LIT>')<EOL>for periodind in range(<NUM_LIT:5>):<EOL><INDENT>axes[periodind+<NUM_LIT:2>].text(<EOL><NUM_LIT:0.5>,<NUM_LIT:0.5>,<EOL>('<STR_LIT>'),<EOL>horizontalalignment='<STR_LIT>',<EOL>verticalalignment='<STR_LIT>',<EOL>transform=axes[periodind+<NUM_LIT:2>].transAxes<EOL>)<EOL><DEDENT>fig.set_tight_layout(True)<EOL>if plotfpath.endswith('<STR_LIT>'):<EOL><INDENT>fig.savefig(plotfpath, dpi=plotdpi)<EOL><DEDENT>else:<EOL><INDENT>fig.savefig(plotfpath)<EOL><DEDENT>plt.close()<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' % plotfpath)<EOL><DEDENT>return plotfpath<EOL><DEDENT>

This makes a checkplot using results from two independent period-finders.

    Adapted from Luke Bouma's implementation of a similar function in his
    work. This makes a special checkplot that uses two lspinfo dictionaries,
    from two independent period-finding methods. For EBs, it's probably best to
    use Stellingwerf PDM or Schwarzenberg-Czerny AoV as one of these, and the
    Box Least-squared Search method as the other one.

    The checkplot layout in this case is::

        [ pgram1 + objectinfo ] [        pgram2       ] [     unphased LC     ]
        [ pgram1 P1 phased LC ] [ pgram1 P2 phased LC ] [ pgram1 P3 phased LC ]
        [ pgram2 P1 phased LC ] [ pgram2 P2 phased LC ] [ pgram2 P3 phased LC ]

    where:

    - pgram1 is the plot for the periodogram in the lspinfo1 dict
    - pgram1 P1, P2, and P3 are the best three periods from lspinfo1
    - pgram2 is the plot for the periodogram in the lspinfo2 dict
    - pgram2 P1, P2, and P3 are the best three periods from lspinfo2

    Note that we take the output file name from lspinfo1 if lspinfo1 is a string
    filename pointing to a (gzipped) pickle containing the results dict from a
    period-finding routine similar to those in periodbase.

    Parameters
    ----------

    lspinfo1,lspinfo2 : dict or str
        If this is a dict, it must be a dict produced by an
        `astrobase.periodbase` period-finder function or a dict from your own
        period-finder function or routine that is of the form below with at
        least these keys::

            {'periods': np.array of all periods searched by the period-finder,
             'lspvals': np.array of periodogram power value for each period,
             'bestperiod': a float value that is the period with the highest
                           peak in the periodogram, i.e. the most-likely actual
                           period,
             'method': a three-letter code naming the period-finder used; must
                       be one of the keys in the
                       `astrobase.periodbase.METHODLABELS` dict,
             'nbestperiods': a list of the periods corresponding to periodogram
                             peaks (`nbestlspvals` below) to annotate on the
                             periodogram plot so they can be called out
                             visually,
             'nbestlspvals': a list of the power values associated with
                             periodogram peaks to annotate on the periodogram
                             plot so they can be called out visually; should be
                             the same length as `nbestperiods` above}

        `nbestperiods` and `nbestlspvals` must have at least 3 elements each,
        e.g. describing the three 'best' (highest power) peaks in the
        periodogram.

        If lspinfo is a str, then it must be a path to a pickle file (ending
        with the extension '.pkl' or '.pkl.gz') that contains a dict of the form
        described above.

    times,mags,errs : np.array
        The mag/flux time-series arrays to process along with associated errors.

    varepoch : 'min' or float or None or list of lists
        This 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='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

            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'])`.

    magsarefluxes : bool
        If True, indicates the input time-series is fluxes and not mags so the
        plot y-axis direction and range can be set appropriately/

    objectinfo : dict or None
        If provided, this is a dict containing information on the object whose
        light curve is being processed. This function will then be able to look
        up and download a finder chart for this object and write that to the
        output checkplot PNG image.The `objectinfo` dict must be of the form and
        contain at least the keys described below::

            {'objectid': the name of the object,
             'ra': the right ascension of the object in decimal degrees,
             'decl': the declination of the object in decimal degrees,
             'ndet': the number of observations of this object}

        You can also provide magnitudes and proper motions of the object using
        the following keys and the appropriate values in the `objectinfo`
        dict. These will be used to calculate colors, total and reduced proper
        motion, etc. and display these in the output checkplot PNG.

        - SDSS mag keys: 'sdssu', 'sdssg', 'sdssr', 'sdssi', 'sdssz'
        - 2MASS mag keys: 'jmag', 'hmag', 'kmag'
        - Cousins mag keys: 'bmag', 'vmag'
        - GAIA specific keys: 'gmag', 'teff'
        - proper motion keys: 'pmra', 'pmdecl'

    findercmap : str or matplotlib.cm.ColorMap object
        The Colormap object to use for the finder chart image.

    finderconvolve : astropy.convolution.Kernel object or None
        If not None, the Kernel object to use for convolving the finder image.

    findercachedir : str
        The directory where the FITS finder images are downloaded and cached.

    normto : {'globalmedian', 'zero'} or a float
        This sets the LC normalization target::

            'globalmedian' -> norms each mag to global median of the LC column
            'zero'         -> norms each mag to zero
            a float        -> norms each mag to this specified float value.

    normmingap : float
        This defines how much the difference between consecutive measurements is
        allowed to be to consider them as parts of different timegroups. By
        default it is set to 4.0 days.

    sigclip : float or int or sequence of two floats/ints or None
        If a single float or int, a symmetric sigma-clip will be performed using
        the number provided as the sigma-multiplier to cut out from the input
        time-series.

        If a list of two ints/floats is provided, the function will perform an
        'asymmetric' sigma-clip. The first element in this list is the sigma
        value to use for fainter flux/mag values; the second element in this
        list is the sigma value to use for brighter flux/mag values. For
        example, `sigclip=[10., 3.]`, will sigclip out greater than 10-sigma
        dimmings and greater than 3-sigma brightenings. Here the meaning of
        "dimming" and "brightening" is set by *physics* (not the magnitude
        system), which is why the `magsarefluxes` kwarg must be correctly set.

        If `sigclip` is None, no sigma-clipping will be performed, and the
        time-series (with non-finite elems removed) will be passed through to
        the output.

    phasewrap : bool
        If this is True, the phased time-series will be wrapped around phase
        0.0.

    phasesort : bool
        If this is True, the phased time-series will be sorted in phase.

    phasebin : float or None
        If this is provided, indicates the bin size to use to group together
        measurements closer than this amount in phase. This is in units of
        phase. The binned phased light curve will be overplotted on top of the
        phased light curve. Useful for when one has many measurement points and
        needs to pick out a small trend in an otherwise noisy phased light
        curve.

    minbinelems : int
        The minimum number of elements in each phase bin.

    plotxlim : sequence of two floats or None
        The x-axis limits to use when making the phased light curve plot. By
        default, this is (-0.8, 0.8), which places phase 0.0 at the center of
        the plot and covers approximately two cycles in phase to make any trends
        clear.

    unphasedms : float
        The marker size to use for the main unphased light curve plot symbols.

    phasems : float
        The marker size to use for the main phased light curve plot symbols.

    phasebinms : float
        The marker size to use for the binned phased light curve plot symbols.

    xliminsetmode : bool
        If this is True, the generated phased light curve plot will use the
        values of `plotxlim` as the main plot x-axis limits (i.e. zoomed-in if
        `plotxlim` is a range smaller than the full phase range), and will show
        the full phased light curve plot as an smaller inset. Useful for
        planetary transit light curves.

    bestperiodhighlight : str or None
        If not None, this is a str with a matplotlib color specification to use
        as the background color to highlight the phased light curve plot of the
        'best' period and epoch combination. If None, no highlight will be
        applied.

    outfile : str or None
        The file name of the file to save the checkplot to. If this is None,
        will write to a file called 'checkplot.png' in the current working
        directory.

    plotdpi : int
        Sets the resolution in DPI for PNG plots (default = 100).

    verbose : bool
        If False, turns off many of the informational messages. Useful for
        when an external function is driving lots of `checkplot_png` calls.

    Returns
    -------

    str
        The file path to the generated checkplot PNG file.


<EOL>try:<EOL><INDENT>objuuid = hashlib.sha512(times[<NUM_LIT:5>:<NUM_LIT:10>].tostring() +<EOL>mags[<NUM_LIT:5>:<NUM_LIT:10>].tostring()).hexdigest()[:<NUM_LIT:5>]<EOL><DEDENT>except Exception as e:<EOL><INDENT>if verbose:<EOL><INDENT>LOGWARNING('<STR_LIT>')<EOL>objuuid = hashlib.sha512(times.tostring() +<EOL>mags.tostring()).hexdigest()[:<NUM_LIT:5>]<EOL><DEDENT><DEDENT>if (objectinfo is None):<EOL><INDENT>if verbose:<EOL><INDENT>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>objectinfo = {'<STR_LIT>':objuuid}<EOL><DEDENT>elif (isinstance(objectinfo, dict) and '<STR_LIT>' in objectinfo):<EOL><INDENT>objectinfo['<STR_LIT>'] = objectinfo['<STR_LIT>']<EOL><DEDENT>elif ((isinstance(objectinfo, dict) and '<STR_LIT>' not in objectinfo) or<EOL>(isinstance(objectinfo, dict) and '<STR_LIT>' in objectinfo and<EOL>(objectinfo['<STR_LIT>'] is None or objectinfo['<STR_LIT>'] == '<STR_LIT>'))):<EOL><INDENT>if verbose:<EOL><INDENT>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>objectinfo['<STR_LIT>'] = objuuid<EOL><DEDENT>checkplotdict = _pkl_finder_objectinfo(<EOL>objectinfo,<EOL>varinfo,<EOL>findercmap,<EOL>finderconvolve,<EOL>sigclip,<EOL>normto,<EOL>normmingap,<EOL>deredden_object=deredden_object,<EOL>custom_bandpasses=custom_bandpasses,<EOL>lclistpkl=lclistpkl,<EOL>nbrradiusarcsec=nbrradiusarcsec,<EOL>maxnumneighbors=maxnumneighbors,<EOL>plotdpi=plotdpi,<EOL>verbose=verbose,<EOL>findercachedir=findercachedir,<EOL>gaia_submit_timeout=gaia_submit_timeout,<EOL>gaia_submit_tries=gaia_submit_tries,<EOL>gaia_max_timeout=gaia_max_timeout,<EOL>gaia_mirror=gaia_mirror,<EOL>complete_query_later=complete_query_later,<EOL>fast_mode=fast_mode<EOL>)<EOL>if (objectinfo and isinstance(objectinfo, dict) and<EOL>'<STR_LIT>' in objectinfo and objectinfo['<STR_LIT>']):<EOL><INDENT>checkplotdict['<STR_LIT>'] = objectinfo['<STR_LIT>']<EOL><DEDENT>stimes, smags, serrs = sigclip_magseries(times,<EOL>mags,<EOL>errs,<EOL>magsarefluxes=magsarefluxes,<EOL>sigclip=sigclip)<EOL>if ((stimes is None) or (smags is None) or (serrs is None) or<EOL>(stimes.size < <NUM_LIT>) or (smags.size < <NUM_LIT>) or (serrs.size < <NUM_LIT>)):<EOL><INDENT>LOGERROR("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" %<EOL>checkplotdict['<STR_LIT>'])<EOL>checkplotdict['<STR_LIT>'] = None<EOL>checkplotdict['<STR_LIT:status>'] = '<STR_LIT>'<EOL>return checkplotdict<EOL><DEDENT>if isinstance(stimes, AstColumn):<EOL><INDENT>stimes = stimes.data<EOL>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if isinstance(smags, AstColumn):<EOL><INDENT>smags = smags.data<EOL>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if isinstance(serrs, AstColumn):<EOL><INDENT>serrs = serrs.data<EOL>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(sigclip, len(times), len(stimes)))<EOL><DEDENT>if normto is not False:<EOL><INDENT>stimes, smags = normalize_magseries(stimes, smags,<EOL>normto=normto,<EOL>magsarefluxes=magsarefluxes,<EOL>mingap=normmingap)<EOL><DEDENT>if len(stimes) > mindet:<EOL><INDENT>magseriesdict = _pkl_magseries_plot(stimes, smags, serrs,<EOL>plotdpi=plotdpi,<EOL>magsarefluxes=magsarefluxes)<EOL>checkplotdict.update(magseriesdict)<EOL>checkplot_pfmethods = []<EOL>for lspind, lspinfo in enumerate(lspinfolist):<EOL><INDENT>if isinstance(lspinfo,str) and os.path.exists(lspinfo):<EOL><INDENT>LOGINFO('<STR_LIT>' % lspinfo)<EOL>if '<STR_LIT>' in lspinfo:<EOL><INDENT>with gzip.open(lspinfo,'<STR_LIT:rb>') as infd:<EOL><INDENT>lspinfo = pickle.load(infd)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with open(lspinfo,'<STR_LIT:rb>') as infd:<EOL><INDENT>lspinfo = pickle.load(infd)<EOL><DEDENT><DEDENT><DEDENT>override_pfmethod = '<STR_LIT>' % (lspind, lspinfo['<STR_LIT>'])<EOL>periodogramdict = _pkl_periodogram(<EOL>lspinfo,<EOL>plotdpi=plotdpi,<EOL>override_pfmethod=override_pfmethod<EOL>)<EOL>checkplotdict.update(periodogramdict)<EOL>for nbpind, nbperiod in enumerate(<EOL>lspinfo['<STR_LIT>'][:nperiodstouse]<EOL>):<EOL><INDENT>if lcfitfunc:<EOL><INDENT>try:<EOL><INDENT>if lcfitparams is None:<EOL><INDENT>lcfitparams = {}<EOL><DEDENT>overplotfit = lcfitfunc(stimes,<EOL>smags,<EOL>serrs,<EOL>nbperiod,<EOL>**lcfitparams)<EOL><DEDENT>except Exception as e:<EOL><INDENT>LOGEXCEPTION('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>overplotfit = None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>overplotfit = None<EOL><DEDENT>if (lspinfo is not None and<EOL>'<STR_LIT>' in lspinfo['<STR_LIT>'] and<EOL>'<STR_LIT>' in lspinfo):<EOL><INDENT>thisvarepoch = lspinfo['<STR_LIT>'][nbpind]<EOL>if verbose:<EOL><INDENT>LOGINFO(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (thisvarepoch, nbperiod)<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>thisvarepoch = varepoch<EOL><DEDENT>checkplotdict = _pkl_phased_magseries_plot(<EOL>checkplotdict,<EOL>lspinfo['<STR_LIT>'],<EOL>nbpind,<EOL>stimes, smags, serrs,<EOL>nbperiod, thisvarepoch,<EOL>lspmethodind=lspind,<EOL>phasewrap=phasewrap,<EOL>phasesort=phasesort,<EOL>phasebin=phasebin,<EOL>minbinelems=minbinelems,<EOL>plotxlim=plotxlim,<EOL>overplotfit=overplotfit,<EOL>plotdpi=plotdpi,<EOL>bestperiodhighlight=bestperiodhighlight,<EOL>magsarefluxes=magsarefluxes,<EOL>xliminsetmode=xliminsetmode,<EOL>xgridlines=xgridlines,<EOL>verbose=verbose,<EOL>override_pfmethod=override_pfmethod,<EOL>)<EOL><DEDENT>if '<STR_LIT>' in lspinfo:<EOL><INDENT>if override_pfmethod in checkplotdict:<EOL><INDENT>checkplotdict[override_pfmethod]['<STR_LIT>'] = (<EOL>lspinfo['<STR_LIT>']<EOL>)<EOL><DEDENT><DEDENT>if '<STR_LIT>' in lspinfo:<EOL><INDENT>if override_pfmethod in checkplotdict:<EOL><INDENT>checkplotdict[override_pfmethod]['<STR_LIT>'] = (<EOL>lspinfo['<STR_LIT>']<EOL>)<EOL><DEDENT><DEDENT>if '<STR_LIT>' in lspinfo:<EOL><INDENT>if override_pfmethod in checkplotdict:<EOL><INDENT>checkplotdict[override_pfmethod]['<STR_LIT>'] = (<EOL>lspinfo['<STR_LIT>']<EOL>)<EOL><DEDENT><DEDENT>checkplot_pfmethods.append(override_pfmethod)<EOL><DEDENT>checkplotdict['<STR_LIT>'] = None<EOL>if getvarfeatures is True:<EOL><INDENT>checkplotdict['<STR_LIT>']['<STR_LIT>'] = all_nonperiodic_features(<EOL>stimes,<EOL>smags,<EOL>serrs,<EOL>magsarefluxes=magsarefluxes,<EOL>)<EOL><DEDENT>checkplotdict['<STR_LIT>'] = {}<EOL>checkplotdict['<STR_LIT>'] = []<EOL>if (externalplots and<EOL>isinstance(externalplots, list) and<EOL>len(externalplots) > <NUM_LIT:0>):<EOL><INDENT>for externalrow in externalplots:<EOL><INDENT>if all(os.path.exists(erowfile) for erowfile in externalrow):<EOL><INDENT>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' %<EOL>repr(externalrow))<EOL><DEDENT>checkplotdict['<STR_LIT>'].append(externalrow)<EOL><DEDENT>else:<EOL><INDENT>LOGWARNING('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% repr(externalrow))<EOL><DEDENT><DEDENT><DEDENT>if xmatchinfo is not None:<EOL><INDENT>checkplotdict = xmatch_external_catalogs(<EOL>checkplotdict,<EOL>xmatchinfo,<EOL>xmatchradiusarcsec=xmatchradiusarcsec<EOL>)<EOL><DEDENT>contents = sorted(list(checkplotdict.keys()))<EOL>checkplotdict['<STR_LIT:status>'] = '<STR_LIT>' % contents<EOL>if verbose:<EOL><INDENT>LOGINFO('<STR_LIT>' %<EOL>checkplotdict['<STR_LIT>'])<EOL>LOGINFO('<STR_LIT>' % contents)<EOL><DEDENT>checkplotdict['<STR_LIT>'] = checkplot_pfmethods<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>' %<EOL>(checkplotdict['<STR_LIT>'],len(stimes),mindet))<EOL>checkplotdict['<STR_LIT>'] = None<EOL>checkplotdict['<STR_LIT:status>'] = '<STR_LIT>'<EOL><DEDENT>return checkplotdict<EOL>

This writes a multiple lspinfo checkplot to a dict.

    This function can take input from multiple lspinfo dicts (e.g. a list of
    output dicts or gzipped pickles of dicts from independent runs of BLS, PDM,
    AoV, or GLS period-finders in periodbase).

    NOTE: if `lspinfolist` contains more than one lspinfo object with the same
    lspmethod ('pdm','gls','sls','aov','bls'), the latest one in the list will
    overwrite the earlier ones.

    The output dict contains all the plots (magseries and phased magseries),
    periodograms, object information, variability information, light curves, and
    phased light curves. This can be written to:

    - a pickle with `checkplot_pickle` below
    - a PNG with `checkplot.pkl_png.checkplot_pickle_to_png`

    Parameters
    ----------

    lspinfolist : list of dicts
        This is a list of dicts containing period-finder results ('lspinfo'
        dicts). These can be from any of the period-finder methods in
        astrobase.periodbase. To incorporate external period-finder results into
        checkplots, these dicts must be of the form below, including at least
        the keys indicated here::

            {'periods': np.array of all periods searched by the period-finder,
             'lspvals': np.array of periodogram power value for each period,
             'bestperiod': a float value that is the period with the highest
                           peak in the periodogram, i.e. the most-likely actual
                           period,
             'method': a three-letter code naming the period-finder used; must
                       be one of the keys in the
                       `astrobase.periodbase.METHODLABELS` dict,
             'nbestperiods': a list of the periods corresponding to periodogram
                             peaks (`nbestlspvals` below) to annotate on the
                             periodogram plot so they can be called out
                             visually,
             'nbestlspvals': a list of the power values associated with
                             periodogram peaks to annotate on the periodogram
                             plot so they can be called out visually; should be
                             the same length as `nbestperiods` above}

        `nbestperiods` and `nbestlspvals` in each lspinfo dict must have at
        least as many elements as the `nperiodstouse` kwarg to this function.

    times,mags,errs : np.arrays
        The magnitude/flux time-series to process for this checkplot along with
        their associated measurement errors.

    fast_mode : bool or float
        This runs the external catalog operations in a "fast" mode, with short
        timeouts and not trying to hit external catalogs that take a long time
        to respond.

        If this is set to True, the default settings for the external requests
        will then become::

                skyview_lookup = False
                skyview_timeout = 10.0
                skyview_retry_failed = False
                dust_timeout = 10.0
                gaia_submit_timeout = 7.0
                gaia_max_timeout = 10.0
                gaia_submit_tries = 2
                complete_query_later = False
                search_simbad = False

        If this is a float, will run in "fast" mode with the provided timeout
        value in seconds and the following settings::

                skyview_lookup = True
                skyview_timeout = fast_mode
                skyview_retry_failed = False
                dust_timeout = fast_mode
                gaia_submit_timeout = 0.66*fast_mode
                gaia_max_timeout = fast_mode
                gaia_submit_tries = 2
                complete_query_later = False
                search_simbad = False

    magsarefluxes : bool
        If True, indicates the input time-series is fluxes and not mags so the
        plot y-axis direction and range can be set appropriately.

    nperiodstouse : int
        This controls how many 'best' periods to make phased LC plots for. By
        default, this is the 3 best. If this is set to None, all 'best' periods
        present in each lspinfo dict's 'nbestperiods' key will be processed for
        this checkplot.

    objectinfo : dict or None
        This is a dict containing information on the object whose light
        curve is being processed. This function will then be able to
        look up and download a finder chart for this object and write
        that to the output checkplotdict. External services such as
        GAIA, SIMBAD, TIC, etc. will also be used to look up this object
        by its coordinates, and will add in information available from
        those services.

        This dict must be of the form and contain at least the keys described
        below::

            {'objectid': the name of the object,
             'ra': the right ascension of the object in decimal degrees,
             'decl': the declination of the object in decimal degrees,
             'ndet': the number of observations of this object}

        You can also provide magnitudes and proper motions of the object using
        the following keys and the appropriate values in the `objectinfo`
        dict. These will be used to calculate colors, total and reduced proper
        motion, etc. and display these in the output checkplot PNG::

            'pmra'   -> the proper motion in mas/yr in right ascension,
            'pmdecl' -> the proper motion in mas/yr in declination,
            'umag'  -> U mag		 -> colors: U-B, U-V, U-g
            'bmag'  -> B mag		 -> colors: U-B, B-V
            'vmag'  -> V mag		 -> colors: U-V, B-V, V-R, V-I, V-K
            'rmag'  -> R mag		 -> colors: V-R, R-I
            'imag'  -> I mag		 -> colors: g-I, V-I, R-I, B-I
            'jmag'  -> 2MASS J mag	 -> colors: J-H, J-K, g-J, i-J
            'hmag'  -> 2MASS H mag	 -> colors: J-H, H-K
            'kmag'  -> 2MASS Ks mag	 -> colors: g-Ks, H-Ks, J-Ks, V-Ks
            'sdssu' -> SDSS u mag	 -> colors: u-g, u-V
            'sdssg' -> SDSS g mag	 -> colors: g-r, g-i, g-K, u-g, U-g, g-J
            'sdssr' -> SDSS r mag	 -> colors: r-i, g-r
            'sdssi' -> SDSS i mag	 -> colors: r-i, i-z, g-i, i-J, i-W1
            'sdssz' -> SDSS z mag	 -> colors: i-z, z-W2, g-z
            'ujmag' -> UKIRT J mag	 -> colors: J-H, H-K, J-K, g-J, i-J
            'uhmag' -> UKIRT H mag	 -> colors: J-H, H-K
            'ukmag' -> UKIRT K mag	 -> colors: g-K, H-K, J-K, V-K
            'irac1' -> Spitzer IRAC1 mag -> colors: i-I1, I1-I2
            'irac2' -> Spitzer IRAC2 mag -> colors: I1-I2, I2-I3
            'irac3' -> Spitzer IRAC3 mag -> colors: I2-I3
            'irac4' -> Spitzer IRAC4 mag -> colors: I3-I4
            'wise1' -> WISE W1 mag	 -> colors: i-W1, W1-W2
            'wise2' -> WISE W2 mag	 -> colors: W1-W2, W2-W3
            'wise3' -> WISE W3 mag	 -> colors: W2-W3
            'wise4' -> WISE W4 mag	 -> colors: W3-W4

        If you have magnitude measurements in other bands, use the
        `custom_bandpasses` kwarg to pass these in.

        If this is None, no object information will be incorporated into the
        checkplot (kind of making it effectively useless for anything other than
        glancing at the phased light curves at various 'best' periods from the
        period-finder results).

    deredden_object : bool
        If this is True, will use the 2MASS DUST service to get extinction
        coefficients in various bands, and then try to deredden the magnitudes
        and colors of the object already present in the checkplot's objectinfo
        dict.

    custom_bandpasses : dict
        This is a dict used to provide custom bandpass definitions for any
        magnitude measurements in the objectinfo dict that are not automatically
        recognized by :py:func:`astrobase.varclass.starfeatures.color_features`.

    gaia_submit_timeout : float
        Sets the timeout in seconds to use when submitting a request to look up
        the object's information to the GAIA service. Note that if `fast_mode`
        is set, this is ignored.

    gaia_submit_tries : int
        Sets the maximum number of times the GAIA services will be contacted to
        obtain this object's information. If `fast_mode` is set, this is
        ignored, and the services will be contacted only once (meaning that a
        failure to respond will be silently ignored and no GAIA data will be
        added to the checkplot's objectinfo dict).

    gaia_max_timeout : float
        Sets the timeout in seconds to use when waiting for the GAIA service to
        respond to our request for the object's information. Note that if
        `fast_mode` is set, this is ignored.

    gaia_mirror : str or None
        This sets the GAIA mirror to use. This is a key in the
        `services.gaia.GAIA_URLS` dict which defines the URLs to hit for each
        mirror.

    complete_query_later : bool
        If this is True, saves the state of GAIA queries that are not yet
        complete when `gaia_max_timeout` is reached while waiting for the GAIA
        service to respond to our request. A later call for GAIA info on the
        same object will attempt to pick up the results from the existing query
        if it's completed. If `fast_mode` is True, this is ignored.

    varinfo : dict
        If this is None, a blank dict of the form below will be added to the
        checkplotdict::

            {'objectisvar': None -> variability flag (None indicates unset),
             'vartags': CSV str containing variability type tags from review,
             'varisperiodic': None -> periodic variability flag (None -> unset),
             'varperiod': the period associated with the periodic variability,
             'varepoch': the epoch associated with the periodic variability}

        If you provide a dict matching this format in this kwarg, this will be
        passed unchanged to the output checkplotdict produced.

    getvarfeatures : bool
        If this is True, several light curve variability features for this
        object will be calculated and added to the output checkpotdict as
        checkplotdict['varinfo']['features']. This uses the function
        `varclass.varfeatures.all_nonperiodic_features` so see its docstring for
        the measures that are calculated (e.g. Stetson J indices, dispersion
        measures, etc.)

    lclistpkl : dict or str
        If this is provided, must be a dict resulting from reading a catalog
        produced by the `lcproc.catalogs.make_lclist` function or a str path
        pointing to the pickle file produced by that function. This catalog is
        used to find neighbors of the current object in the current light curve
        collection. Looking at neighbors of the object within the radius
        specified by `nbrradiusarcsec` is useful for light curves produced by
        instruments that have a large pixel scale, so are susceptible to
        blending of variability and potential confusion of neighbor variability
        with that of the actual object being looked at. If this is None, no
        neighbor lookups will be performed.

    nbrradiusarcsec : flaot
        The radius in arcseconds to use for a search conducted around the
        coordinates of this object to look for any potential confusion and
        blending of variability amplitude caused by their proximity.

    maxnumneighbors : int
        The maximum number of neighbors that will have their light curves and
        magnitudes noted in this checkplot as potential blends with the target
        object.

    xmatchinfo : str or dict
        This is either the xmatch dict produced by the function
        `load_xmatch_external_catalogs` above, or the path to the xmatch info
        pickle file produced by that function.

    xmatchradiusarcsec : float
        This is the cross-matching radius to use in arcseconds.

    lcfitfunc : Python function or None
        If provided, this should be a Python function that is used to fit a
        model to the light curve. This fit is then overplotted for each phased
        light curve in the checkplot. This function should have the following
        signature:

        `def lcfitfunc(times, mags, errs, period, **lcfitparams)`

        where `lcfitparams` encapsulates all external parameters (i.e. number of
        knots for a spline function, the degree of a Legendre polynomial fit,
        etc., planet transit parameters) This function should return a Python
        dict with the following structure (similar to the functions in
        `astrobase.lcfit`) and at least the keys below::

            {'fittype':<str: name of fit method>,
             'fitchisq':<float: the chi-squared value of the fit>,
             'fitredchisq':<float: the reduced chi-squared value of the fit>,
             'fitinfo':{'fitmags':<ndarray: model mags/fluxes from fit func>},
             'magseries':{'times':<ndarray: times where fitmags are evaluated>}}

        Additional keys in the dict returned from this function can include
        `fitdict['fitinfo']['finalparams']` for the final model fit parameters
        (this will be used by the checkplotserver if present),
        `fitdict['fitinfo']['fitepoch']` for the minimum light epoch returned by
        the model fit, among others.

        In any case, the output dict of `lcfitfunc` will be copied to the output
        checkplotdict as::

            checkplotdict[lspmethod][periodind]['lcfit'][<fittype>]

        for each phased light curve.

    lcfitparams : dict
        A dict containing the LC fit parameters to use when calling the function
        provided in `lcfitfunc`. This contains key-val pairs corresponding to
        parameter names and their respective initial values to be used by the
        fit function.

    externalplots : list of tuples of str
        If provided, this is a list of 4-element tuples containing:

        1. path to PNG of periodogram from an external period-finding method
        2. path to PNG of best period phased LC from the external period-finder
        3. path to PNG of 2nd-best phased LC from the external period-finder
        4. path to PNG of 3rd-best phased LC from the external period-finder

        This can be used to incorporate external period-finding method results
        into the output checkplot pickle or exported PNG to allow for comparison
        with astrobase results.

        Example of externalplots::

                [('/path/to/external/bls-periodogram.png',
                 '/path/to/external/bls-phasedlc-plot-bestpeak.png',
                 '/path/to/external/bls-phasedlc-plot-peak2.png',
                 '/path/to/external/bls-phasedlc-plot-peak3.png'),
                 ('/path/to/external/pdm-periodogram.png',
                 '/path/to/external/pdm-phasedlc-plot-bestpeak.png',
                 '/path/to/external/pdm-phasedlc-plot-peak2.png',
                 '/path/to/external/pdm-phasedlc-plot-peak3.png'),
                 ...]

        If `externalplots` is provided here, these paths will be stored in the
        output checkplotdict. The `checkplot.pkl_png.checkplot_pickle_to_png`
        function can then automatically retrieve these plot PNGs and put
        them into the exported checkplot PNG.

    findercmap : str or matplotlib.cm.ColorMap object
        The Colormap object to use for the finder chart image.

    finderconvolve : astropy.convolution.Kernel object or None
        If not None, the Kernel object to use for convolving the finder image.

    findercachedir : str
        The path to the astrobase cache directory for finder chart downloads
        from the NASA SkyView service.

    normto : {'globalmedian', 'zero'} or a float
        These are specified as below:
        - 'globalmedian' -> norms each mag to the global median of the LC column
        - 'zero'         -> norms each mag to zero
        - a float        -> norms each mag to this specified float value.

    normmingap : float
        This defines how much the difference between consecutive measurements is
        allowed to be to consider them as parts of different timegroups. By
        default it is set to 4.0 days.

    sigclip : float or int or sequence of two floats/ints or None
        If a single float or int, a symmetric sigma-clip will be performed using
        the number provided as the sigma-multiplier to cut out from the input
        time-series.

        If a list of two ints/floats is provided, the function will perform an
        'asymmetric' sigma-clip. The first element in this list is the sigma
        value to use for fainter flux/mag values; the second element in this
        list is the sigma value to use for brighter flux/mag values. For
        example, `sigclip=[10., 3.]`, will sigclip out greater than 10-sigma
        dimmings and greater than 3-sigma brightenings. Here the meaning of
        "dimming" and "brightening" is set by *physics* (not the magnitude
        system), which is why the `magsarefluxes` kwarg must be correctly set.

        If `sigclip` is None, no sigma-clipping will be performed, and the
        time-series (with non-finite elems removed) will be passed through to
        the output.

    varepoch : 'min' or float or list of lists or None
        The epoch to use for this phased light curve plot tile. If this is a
        float, will use the provided value directly. If this is 'min', will
        automatically figure out the time-of-minimum of the phased light
        curve. If this is None, will use the mimimum value of `stimes` as the
        epoch of the phased light curve plot. If this is a list of lists, will
        use the provided value of `lspmethodind` to look up the current
        period-finder method and the provided value of `periodind` to look up
        the epoch associated with that method and the current period. This is
        mostly only useful when `twolspmode` is True.

    phasewrap : bool
        If this is True, the phased time-series will be wrapped around
        phase 0.0.

    phasesort : bool
        If True, will sort the phased light curve in order of increasing phase.

    phasebin: float
        The bin size to use to group together measurements closer than this
        amount in phase. This is in units of phase. If this is a float, a
        phase-binned version of the phased light curve will be overplotted on
        top of the regular phased light curve.

    minbinelems : int
        The minimum number of elements required per phase bin to include it in
        the phased LC plot.

    plotxlim : sequence of two floats or None
        The x-range (min, max) of the phased light curve plot. If None, will be
        determined automatically.

    xliminsetmode : bool
        If this is True, the generated phased light curve plot will use the
        values of `plotxlim` as the main plot x-axis limits (i.e. zoomed-in if
        `plotxlim` is a range smaller than the full phase range), and will show
        the full phased light curve plot as an smaller inset. Useful for
        planetary transit light curves.

    plotdpi : int
        The resolution of the output plot PNGs in dots per inch.

    bestperiodhighlight : str or None
        If not None, this is a str with a matplotlib color specification to use
        as the background color to highlight the phased light curve plot of the
        'best' period and epoch combination. If None, no highlight will be
        applied.

    xgridlines : list of floats or None
        If this is provided, must be a list of floats corresponding to the phase
        values where to draw vertical dashed lines as a means of highlighting
        these.

    mindet : int
        The minimum of observations the input object's mag/flux time-series must
        have for this function to plot its light curve and phased light
        curve. If the object has less than this number, no light curves will be
        plotted, but the checkplotdict will still contain all of the other
        information.

    verbose : bool
        If True, will indicate progress and warn about problems.

    Returns
    -------

    dict
        Returns a checkplotdict.