def checkplot_png(lspinfo,<EOL>times,<EOL>mags,<EOL>errs,<EOL>varepoch='<STR_LIT>',<EOL>magsarefluxes=False,<EOL>objectinfo=None,<EOL>findercmap='<STR_LIT>',<EOL>finderconvolve=None,<EOL>findercachedir='<STR_LIT>',<EOL>normto='<STR_LIT>',<EOL>normmingap=<NUM_LIT>,<EOL>sigclip=<NUM_LIT>,<EOL>phasewrap=True,<EOL>phasesort=True,<EOL>phasebin=<NUM_LIT>,<EOL>minbinelems=<NUM_LIT:7>,<EOL>plotxlim=(-<NUM_LIT>,<NUM_LIT>),<EOL>xliminsetmode=False,<EOL>bestperiodhighlight=None,<EOL>plotdpi=<NUM_LIT:100>,<EOL>outfile=None,<EOL>verbose=True):
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.