def fits_finder_chart(<EOL>fitsfile,<EOL>outfile,<EOL>fitsext=<NUM_LIT:0>,<EOL>wcsfrom=None,<EOL>scale=ZScaleInterval(),<EOL>stretch=LinearStretch(),<EOL>colormap=plt.cm.gray_r,<EOL>findersize=None,<EOL>finder_coordlimits=None,<EOL>overlay_ra=None,<EOL>overlay_decl=None,<EOL>overlay_pltopts={'<STR_LIT>':'<STR_LIT:o>',<EOL>'<STR_LIT>':<NUM_LIT>,<EOL>'<STR_LIT>':'<STR_LIT:none>',<EOL>'<STR_LIT>':<NUM_LIT>,<EOL>'<STR_LIT>':'<STR_LIT>'},<EOL>overlay_zoomcontain=False,<EOL>grid=False,<EOL>gridcolor='<STR_LIT:k>'<EOL>):
<EOL>if wcsfrom is None:<EOL><INDENT>hdulist = pyfits.open(fitsfile)<EOL>img, hdr = hdulist[fitsext].data, hdulist[fitsext].header<EOL>hdulist.close()<EOL>frameshape = (hdr['<STR_LIT>'], hdr['<STR_LIT>'])<EOL>w = WCS(hdr)<EOL><DEDENT>elif os.path.exists(wcsfrom):<EOL><INDENT>hdulist = pyfits.open(fitsfile)<EOL>img, hdr = hdulist[fitsext].data, hdulist[fitsext].header<EOL>hdulist.close()<EOL>frameshape = (hdr['<STR_LIT>'], hdr['<STR_LIT>'])<EOL>w = WCS(wcsfrom)<EOL><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>' %<EOL>fitsfile)<EOL>return None<EOL><DEDENT>if findersize is None:<EOL><INDENT>fig = plt.figure(figsize=(frameshape[<NUM_LIT:0>]/<NUM_LIT>,<EOL>frameshape[<NUM_LIT:1>]/<NUM_LIT>))<EOL><DEDENT>else:<EOL><INDENT>fig = plt.figure(figsize=findersize)<EOL><DEDENT>if (overlay_zoomcontain and<EOL>overlay_ra is not None and<EOL>overlay_decl is not None):<EOL><INDENT>finder_coordlimits = [overlay_ra.min()-<NUM_LIT>/<NUM_LIT>,<EOL>overlay_ra.max()+<NUM_LIT>/<NUM_LIT>,<EOL>overlay_decl.min()-<NUM_LIT>/<NUM_LIT>,<EOL>overlay_decl.max()+<NUM_LIT>/<NUM_LIT>]<EOL><DEDENT>if finder_coordlimits and isinstance(finder_coordlimits, (list,tuple)):<EOL><INDENT>minra, maxra, mindecl, maxdecl = finder_coordlimits<EOL>cntra, cntdecl = (minra + maxra)/<NUM_LIT>, (mindecl + maxdecl)/<NUM_LIT><EOL>pixelcoords = w.all_world2pix([[minra, mindecl],<EOL>[maxra, maxdecl],<EOL>[cntra, cntdecl]],<NUM_LIT:1>)<EOL>x1, y1, x2, y2 = (int(pixelcoords[<NUM_LIT:0>,<NUM_LIT:0>]),<EOL>int(pixelcoords[<NUM_LIT:0>,<NUM_LIT:1>]),<EOL>int(pixelcoords[<NUM_LIT:1>,<NUM_LIT:0>]),<EOL>int(pixelcoords[<NUM_LIT:1>,<NUM_LIT:1>]))<EOL>xmin = x1 if x1 < x2 else x2<EOL>xmax = x2 if x2 > x1 else x1<EOL>ymin = y1 if y1 < y2 else y2<EOL>ymax = y2 if y2 > y1 else y1<EOL>whdr = w.to_header()<EOL>whdr['<STR_LIT>'] = (xmax - xmin)/<NUM_LIT:2><EOL>whdr['<STR_LIT>'] = (ymax - ymin)/<NUM_LIT:2><EOL>whdr['<STR_LIT>'] = cntra<EOL>whdr['<STR_LIT>'] = cntdecl<EOL>whdr['<STR_LIT>'] = xmax - xmin<EOL>whdr['<STR_LIT>'] = ymax - ymin<EOL>w = WCS(whdr)<EOL><DEDENT>else:<EOL><INDENT>xmin, xmax, ymin, ymax = <NUM_LIT:0>, hdr['<STR_LIT>'], <NUM_LIT:0>, hdr['<STR_LIT>']<EOL><DEDENT>fig.add_subplot(<NUM_LIT>,projection=w)<EOL>if scale is not None and stretch is not None:<EOL><INDENT>norm = ImageNormalize(img,<EOL>interval=scale,<EOL>stretch=stretch)<EOL>plt.imshow(img[ymin:ymax,xmin:xmax],<EOL>origin='<STR_LIT>',<EOL>cmap=colormap,<EOL>norm=norm)<EOL><DEDENT>else:<EOL><INDENT>plt.imshow(img[ymin:ymax,xmin:xmax],<EOL>origin='<STR_LIT>',<EOL>cmap=colormap)<EOL><DEDENT>if grid:<EOL><INDENT>plt.grid(color=gridcolor,ls='<STR_LIT>',lw=<NUM_LIT:1.0>)<EOL><DEDENT>if overlay_ra is not None and overlay_decl is not None:<EOL><INDENT>our_pltopts = dict(<EOL>transform=plt.gca().get_transform('<STR_LIT>'),<EOL>marker='<STR_LIT:o>',<EOL>markersize=<NUM_LIT>,<EOL>markerfacecolor='<STR_LIT:none>',<EOL>markeredgewidth=<NUM_LIT>,<EOL>markeredgecolor='<STR_LIT>',<EOL>rasterized=True,<EOL>linestyle='<STR_LIT:none>'<EOL>)<EOL>if overlay_pltopts is not None and isinstance(overlay_pltopts,<EOL>dict):<EOL><INDENT>our_pltopts.update(overlay_pltopts)<EOL><DEDENT>plt.gca().set_autoscale_on(False)<EOL>plt.gca().plot(overlay_ra, overlay_decl,<EOL>**our_pltopts)<EOL><DEDENT>plt.xlabel('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>xax = plt.gca().coords[<NUM_LIT:0>]<EOL>yax = plt.gca().coords[<NUM_LIT:1>]<EOL>yax.set_major_formatter('<STR_LIT>')<EOL>xax.set_major_formatter('<STR_LIT>')<EOL>plt.savefig(outfile, dpi=<NUM_LIT>)<EOL>plt.close('<STR_LIT:all>')<EOL>return outfile<EOL>
This makes a finder chart for a given FITS with an optional object
    position overlay.

    Parameters
    ----------

    fitsfile : str
        `fitsfile` is the FITS file to use to make the finder chart.

    outfile : str
        `outfile` is the name of the output file. This can be a png or pdf or
        whatever else matplotlib can write given a filename and extension.

    fitsext : int
        Sets the FITS extension in `fitsfile` to use to extract the image array
        from.

    wcsfrom : str or None
        If `wcsfrom` is None, the WCS to transform the RA/Dec to pixel x/y will
        be taken from the FITS header of `fitsfile`. If this is not None, it
        must be a FITS or similar file that contains a WCS header in its first
        extension.

    scale : astropy.visualization.Interval object
        `scale` sets the normalization for the FITS pixel values. This is an
        astropy.visualization Interval object.
        See http://docs.astropy.org/en/stable/visualization/normalization.html
        for details on `scale` and `stretch` objects.

    stretch : astropy.visualization.Stretch object
        `stretch` sets the stretch function for mapping FITS pixel values to
        output pixel values. This is an astropy.visualization Stretch object.
        See http://docs.astropy.org/en/stable/visualization/normalization.html
        for details on `scale` and `stretch` objects.

    colormap : matplotlib Colormap object
        `colormap` is a matplotlib color map object to use for the output image.

    findersize : None or tuple of two ints
        If `findersize` is None, the output image size will be set by the NAXIS1
        and NAXIS2 keywords in the input `fitsfile` FITS header. Otherwise,
        `findersize` must be a tuple with the intended x and y size of the image
        in inches (all output images will use a DPI = 100).

    finder_coordlimits : list of four floats or None
        If not None, `finder_coordlimits` sets x and y limits for the plot,
        effectively zooming it in if these are smaller than the dimensions of
        the FITS image. This should be a list of the form: [minra, maxra,
        mindecl, maxdecl] all in decimal degrees.

    overlay_ra, overlay_decl : np.array or None
        `overlay_ra` and `overlay_decl` are ndarrays containing the RA and Dec
        values to overplot on the image as an overlay. If these are both None,
        then no overlay will be plotted.

    overlay_pltopts : dict
        `overlay_pltopts` controls how the overlay points will be plotted. This
        a dict with standard matplotlib marker, etc. kwargs as key-val pairs,
        e.g. 'markersize', 'markerfacecolor', etc. The default options make red
        outline circles at the location of each object in the overlay.

    overlay_zoomcontain : bool
        `overlay_zoomcontain` controls if the finder chart will be zoomed to
        just contain the overlayed points. Everything outside the footprint of
        these points will be discarded.

    grid : bool
        `grid` sets if a grid will be made on the output image.

    gridcolor : str
        `gridcolor` sets the color of the grid lines. This is a usual matplotib
        color spec string.

    Returns
    -------

    str or None
        The filename of the generated output image if successful. None
        otherwise.