def gitm_alt_slices(zkey,
                    gData,
                    lat_index,
                    lon_index,
                    title=None,
                    figname=None,
                    draw=True,
                    degrees=True,
                    color="k",
                    marker="o",
                    line=":",
                    zmax=None,
                    zmin=None,
                    amax=None,
                    amin=None,
                    xmax=None,
                    xmin=None,
                    zcolor=True,
                    zcenter=False,
                    add_hmf2=False,
                    hcolor="k",
                    hline="--",
                    *args,
                    **kwargs):
    '''
    Creates a contour altitude map with several linear slices as a function of
    altitude for a specified GITM variable.  A list of latitude and longitude
    indexes should be specified.  One list should consist of a single value,
    the other will be the x variable in the contour plot.  The degree flag
    determines whether x will be ploted in radians or degrees.

    Input: zkey      = key for z variable (ie 'e-')
           gData     = gitm bin structure
           lat_index = list of latitude indices
           lon_index = list of longitude indices
           title     = plot title
           figname   = file name to save figure as (default is none)
           draw      = Draw the figure to screen (default=True)
           degrees   = plot x label in radians (False) or degrees (default True)
           color     = line color for linear plots (default black)
           marker    = marker type for linear plots (default circle)
           line      = line type for linear plots (default dotted line)
           zmax      = z key maximum (or None to compute automatically, default)
           zmin      = z key minimum (or None to compute automatically, default)
           amax      = a key maximum (or None to compute automatically, default)
           amin      = a key minimum (or None to compute automatically, default)
           xmax      = x key maximum for countour plots (or None to compute
                       automatically, default)
           xmin      = x key minimum for contour plots (or None to compute
                       automatically, default)
           zcolor    = Color plot or B&W (default is True for color)
           zcenter   = Should the z range be centered about zero (default is
                       False, for uncentered)
           add_hmf2  = Add line showing hmF2? (default=False)
           hcolor    = Line color for hmF2 line (default=black)
           hline     = Line style for hmF2 line (default=dashes)
    '''
    module_name = "gitm_alt_slices"

    # Process the index lists
    lat_len = len(lat_index)
    lon_len = len(lon_index)
    pnum = max([lat_len, lon_len])

    if (pnum < 1):
        print module_name, "ERROR: no altitude slices specified"
        return

    if (lat_len > 1 and lon_len > 1):
        print module_name, "ERROR: one geographic variable must be constant"
        return

    lat_range = False
    lon_range = False
    if lat_len == 1:
        xkey = "Longitude"
        x_indices = lon_index
        lon_index = [0, gData.attrs['nLon']]
        lon_range = True

        if title:
            title = "{:s} at {:5.2f}$^\circ$ N".format(
                title, gData['dLat'][1, ilat_index[0], 1])
        else:
            title = " {:5.2f}$^\circ$ N".format(gData['dLat'][1, lat_index[0],
                                                              1])

        if degrees:
            xkey = "dLon"
        x_data = np.array(gData[xkey][:, lat_index[0], :])
        alt_data = np.array(gData['Altitude'][:, lat_index[0], :] / 1000.0)
        z_data = np.array(gData[zkey][:, lat_index[0], :])
    else:
        xkey = "Latitude"
        x_indices = lat_index
        lat_index = [0, gData.attrs['nLat']]
        lat_range = True

        if title:
            title = "{:s} at {:5.2f}$^\circ$ E".format(
                title, gData['dLon'][lon_index[0], 1, 1])
        else:
            title = "{:5.2f}$^\circ$ E".format(gData['dLon'][lon_index[0], 1,
                                                             1])

        if degrees:
            xkey = "dLat"
        x_data = np.array(gData[xkey][lon_index[0], :, :])
        alt_data = np.array(gData['Altitude'][lon_index[0], :, :] / 1000.0)
        z_data = np.array(gData[zkey][lon_index[0], :, :])

    # Initialize the x,y,z variable limits
    alt_index = [0, gData.attrs['nAlt']]
    alt_range = True

    if amin == None or amax == None:
        tmin, tmax = gpr.find_data_limits_ivalues([gData],
                                                  "Altitude",
                                                  lat_index,
                                                  lon_index,
                                                  alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=False)
        if amin == None:
            amin = math.ceil(tmin / 10000.0) * 10.0
        if amax == None:
            amax = math.floor(tmax / 10000.0) * 10.0

    if zmin == None or zmax == None:
        tmin, tmax = gpr.find_data_limits_ivalues([gData],
                                                  zkey,
                                                  lat_index,
                                                  lon_index,
                                                  alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=True)
        if zmin == None:
            zmin = tmin
        if zmax == None:
            zmax = tmax

    if xmin == None or xmax == None:
        tmin, tmax = gpr.find_data_limits_ivalues([gData],
                                                  xkey,
                                                  lat_index,
                                                  lon_index,
                                                  alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=True)
        if xmin == None:
            xmin = tmin
        if xmax == None:
            xmax = tmax

    # Initialize the new figure
    f, axc, axl = pap.plot_alt_slices(x_data,
                                      alt_data,
                                      z_data,
                                      0,
                                      x_indices,
                                      gData[xkey].attrs['name'],
                                      gData[xkey].attrs['scale'],
                                      gData[xkey].attrs['units'],
                                      "km",
                                      gData[zkey].attrs['name'],
                                      gData[zkey].attrs['scale'],
                                      gData[zkey].attrs['units'],
                                      xmin=xmin,
                                      xmax=xmax,
                                      amin=amin,
                                      amax=amax,
                                      zmin=zmin,
                                      zmax=zmax,
                                      title=title,
                                      draw=False,
                                      color=color,
                                      marker=marker,
                                      line=line,
                                      zcolor=zcolor,
                                      zcenter=zcenter)
    # Add hmF2 lines, if desired
    if add_hmf2:
        # Add hmF2 lines to the linear plots
        ilon = lon_index[0]
        ilat = lat_index[0]
        xlen = len(x_indices) - 1
        for i, iax in enumerate(axl):
            if lon_len > 1:
                ilon = x_indices[xlen - i]
            else:
                ilat = x_indices[xlen - i]
            x = np.array([zmin, zmax])
            y = np.array(
                [gData['hmF2'][ilon, ilat, 0], gData['hmF2'][ilon, ilat, 0]])
            y = y.reshape(2)

            iax.plot(x, y, color=hcolor, linestyle=hline, linewidth=2)

        # Add hmF2 lines to the contour plot
        datadim = list()
        if lat_len == 1:
            lonmin = 0
            lonmax = gData.attrs['nLon']
            latmin = lat_index[0]
            latmax = latmin + 1
            datadim.append(lonmax)
        else:
            lonmin = lon_index[0]
            lonmax = lonmin + 1
            latmin = 0
            latmax = gData.attrs['nLat']
            datadim.append(latmax)

        x = np.array(x_data[:, 0])
        x = x.reshape(datadim)
        y = np.array(gData['hmF2'][lonmin:lonmax, latmin:latmax, 0])
        y = y.reshape(datadim)
        axc.plot(x, y, color=hcolor, linestyle=hline, linewidth=2)

    if draw:
        # Draw to screen.
        if plt.isinteractive():
            plt.draw()  #In interactive mode, you just "draw".
        else:
            # W/o interactive mode, "show" stops the user from typing more
            # at the terminal until plots are drawn.
            plt.show()

    # Save output file
    if figname is not None:
        plt.savefig(figname)

    return f, axc, axl
Example #2
0
def gitm_alt_slices(zkey, gData, lat_index, lon_index, title=None, figname=None,
                    draw=True, degrees=True, color="k", marker="o", line=":",
                    zmax=None, zmin=None, amax=None, amin=None, xmax=None,
                    xmin=None, zcolor=True, zcenter=False, add_hmf2=False,
                    hcolor="k", hline="--", *args, **kwargs):
    '''
    Creates a contour altitude map with several linear slices as a function of
    altitude for a specified GITM variable.  A list of latitude and longitude
    indexes should be specified.  One list should consist of a single value,
    the other will be the x variable in the contour plot.  The degree flag
    determines whether x will be ploted in radians or degrees.

    Input: zkey      = key for z variable (ie 'e-')
           gData     = gitm bin structure
           lat_index = list of latitude indices
           lon_index = list of longitude indices
           title     = plot title
           figname   = file name to save figure as (default is none)
           draw      = Draw the figure to screen (default=True)
           degrees   = plot x label in radians (False) or degrees (default True)
           color     = line color for linear plots (default black)
           marker    = marker type for linear plots (default circle)
           line      = line type for linear plots (default dotted line)
           zmax      = z key maximum (or None to compute automatically, default)
           zmin      = z key minimum (or None to compute automatically, default)
           amax      = a key maximum (or None to compute automatically, default)
           amin      = a key minimum (or None to compute automatically, default)
           xmax      = x key maximum for countour plots (or None to compute
                       automatically, default)
           xmin      = x key minimum for contour plots (or None to compute
                       automatically, default)
           zcolor    = Color plot or B&W (default is True for color)
           zcenter   = Should the z range be centered about zero (default is
                       False, for uncentered)
           add_hmf2  = Add line showing hmF2? (default=False)
           hcolor    = Line color for hmF2 line (default=black)
           hline     = Line style for hmF2 line (default=dashes)
    '''
    module_name = "gitm_alt_slices"

    # Process the index lists
    lat_len = len(lat_index)
    lon_len = len(lon_index)
    pnum = max([lat_len, lon_len])

    if(pnum < 1):
        print module_name, "ERROR: no altitude slices specified"
        return

    if(lat_len > 1 and lon_len > 1):
        print module_name, "ERROR: one geographic variable must be constant"
        return

    lat_range = False
    lon_range = False
    if lat_len == 1:
        xkey = "Longitude"
        x_indices = lon_index
        lon_index = [0, gData.attrs['nLon']]
        lon_range = True

        if title:
            title = "{:s} at {:5.2f}$^\circ$ N".format(title, gData['dLat'][1,ilat_index[0],1])
        else:
            title = " {:5.2f}$^\circ$ N".format(gData['dLat'][1,lat_index[0],1])

        if degrees:
            xkey = "dLon"
        x_data = np.array(gData[xkey][:,lat_index[0],:])
        alt_data = np.array(gData['Altitude'][:,lat_index[0],:] / 1000.0)
        z_data = np.array(gData[zkey][:,lat_index[0],:])
    else:
        xkey = "Latitude"
        x_indices = lat_index
        lat_index = [0, gData.attrs['nLat']]
        lat_range = True

        if title:
            title = "{:s} at {:5.2f}$^\circ$ E".format(title, gData['dLon'][lon_index[0],1,1])
        else:
            title = "{:5.2f}$^\circ$ E".format(gData['dLon'][lon_index[0],1,1])

        if degrees:
            xkey = "dLat"
        x_data = np.array(gData[xkey][lon_index[0],:,:])
        alt_data = np.array(gData['Altitude'][lon_index[0],:,:] / 1000.0)
        z_data = np.array(gData[zkey][lon_index[0],:,:])

    # Initialize the x,y,z variable limits
    alt_index = [0, gData.attrs['nAlt']]
    alt_range = True

    if amin == None or amax == None:
        tmin, tmax = gpr.find_data_limits_ivalues([gData],"Altitude",lat_index,
                                                  lon_index,alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=False)
        if amin == None:
            amin = math.ceil(tmin / 10000.0) * 10.0
        if amax == None:
            amax = math.floor(tmax / 10000.0) * 10.0

    if zmin == None or zmax == None:
        tmin, tmax = gpr.find_data_limits_ivalues([gData], zkey, lat_index,
                                                  lon_index, alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=True)
        if zmin == None:
            zmin = tmin
        if zmax == None:
            zmax = tmax

    if xmin == None or xmax == None:
        tmin, tmax = gpr.find_data_limits_ivalues([gData], xkey, lat_index,
                                                  lon_index, alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=True)
        if xmin == None:
            xmin = tmin
        if xmax == None:
            xmax = tmax

    # Initialize the new figure
    f, axc, axl = pap.plot_alt_slices(x_data, alt_data, z_data, 0, x_indices,
                                      gData[xkey].attrs['name'],
                                      gData[xkey].attrs['scale'],
                                      gData[xkey].attrs['units'], "km",
                                      gData[zkey].attrs['name'],
                                      gData[zkey].attrs['scale'],
                                      gData[zkey].attrs['units'], xmin=xmin,
                                      xmax=xmax, amin=amin, amax=amax,
                                      zmin=zmin, zmax=zmax, title=title,
                                      draw=False, color=color, marker=marker,
                                      line=line, zcolor=zcolor, zcenter=zcenter)
    # Add hmF2 lines, if desired
    if add_hmf2:
        # Add hmF2 lines to the linear plots
        ilon = lon_index[0]
        ilat = lat_index[0]
        xlen = len(x_indices) - 1
        for i,iax in enumerate(axl):
            if lon_len > 1:
                ilon = x_indices[xlen-i] 
            else:
                ilat = x_indices[xlen-i]
            x = np.array([zmin,zmax])
            y = np.array([gData['hmF2'][ilon,ilat,0],
                          gData['hmF2'][ilon,ilat,0]])
            y = y.reshape(2)

            iax.plot(x, y, color=hcolor, linestyle=hline, linewidth=2)

        # Add hmF2 lines to the contour plot
        datadim = list()
        if lat_len == 1:
            lonmin = 0
            lonmax = gData.attrs['nLon']
            latmin = lat_index[0]
            latmax = latmin + 1
            datadim.append(lonmax)
        else:
            lonmin = lon_index[0]
            lonmax = lonmin + 1
            latmin = 0
            latmax = gData.attrs['nLat']
            datadim.append(latmax)

        x = np.array(x_data[:,0])
        x = x.reshape(datadim)
        y = np.array(gData['hmF2'][lonmin:lonmax,latmin:latmax,0])
        y = y.reshape(datadim)
        axc.plot(x, y, color=hcolor, linestyle=hline, linewidth=2)

    if draw:
        # Draw to screen.
        if plt.isinteractive():
            plt.draw() #In interactive mode, you just "draw".
        else:
            # W/o interactive mode, "show" stops the user from typing more 
            # at the terminal until plots are drawn.
            plt.show()

    # Save output file
    if figname is not None:
        plt.savefig(figname)

    return f, axc, axl
def gitm_mult_alt_images(plot_type,
                         zkey,
                         gData,
                         lat_index,
                         lon_index,
                         title=None,
                         figname=None,
                         draw=True,
                         xkey="dLat",
                         color="b",
                         marker="o",
                         line=":",
                         zmax=None,
                         zmin=None,
                         amax=None,
                         amin=None,
                         xmax=None,
                         xmin=None,
                         zcenter=False,
                         add_hmf2=False,
                         hcolor="k",
                         hline="--",
                         *args,
                         **kwargs):
    '''
    Creates a linear or contour altitude map for a specified altitude range.
    A list of latitude and longitude indexes should be specified.  They may
    be of equal length (for paired values), or for a constant value in one
    coordinate, a length of list one can be specified.
    
    Input: plot_type = key to determine plot type (linear, contour)
           zkey      = key for z variable (ie 'Vertical TEC')
           gData     = gitm bin structure
           lat_index = list of latitude indices (empty list for all)
           lon_index = list of longitude indices (empty list for all)
           title     = plot title
           figname   = file name to save figure as (default is none)
           draw      = Draw figure to screen (default is True)
           xkey      = x coordinate for contour plots (default dLat)
           color     = line color for linear plots (default blue)
           marker    = marker type for linear plots (default circle)
           line      = line type for linear plots (default dotted line)
           zmax      = z key maximum (or None to compute automatically, default)
           zmin      = z key minimum (or None to compute automatically, default)
           amax      = a key maximum (or None to compute automatically, default)
           amin      = a key minimum (or None to compute automatically, default)
           xmax      = x key maximum for countour plots (or None to compute
                       automatically, default)
           xmin      = x key minimum for contour plots (or None to compute
                       automatically, default)
           zcenter   = Should the z range be centered about zero (default is
                       False, for uncentered)
           add_hmf2  = Add line showing hmF2? (default=False)
           hcolor    = Line color for hmF2 line (default=black)
           hline     = Line style for hmF2 line (default=dashes)
    '''
    module_name = "gitm_mult_alt_images"

    # Process the index lists
    lat_len = len(lat_index)
    lon_len = len(lon_index)

    if lat_len != lon_len and lat_len > 1 and lon_len > 1:
        print module_name, "ERROR: improperly paired lat/lon indices"
        return

    if lat_len <= 1:
        y_label = [
            "{:.1f}$^\circ$ Lon".format(gData['dLon'][l, 1, 1])
            for l in lon_index
        ]
    elif lon_len <= 1:
        y_label = [
            "{:.1f}$^\circ$ Lat".format(gData['dLat'][1, l, 1])
            for l in lat_index
        ]
    else:
        y_label = [
            "{:.1f}$^\circ$ Lat, {:.1f}$^\circ$ Lon".format(
                gData['dLat'][1, l, 1], gData['dLon'][lon_index[i], 1, 1])
            for i, l in enumerate(lat_index)
        ]

    # Initialize the input data indices
    subindices = [lon_index, lat_index]

    # Initialize the x,y,z variable limits if desired
    alt_index = [0, gData.attrs['nAlt']]
    alt_range = True
    lat_range = False
    lon_range = False
    if lat_len == 0:
        lat_index = [0, gData.attrs['nLat']]
        lat_range = True
    if lon_len == 0:
        lon_index = [0, gData.attrs['nLon']]
        lon_range = True

    if amin == None or amax == None:
        tmin, tmax = gpr.find_data_limits_ivalues([gData],
                                                  "Altitude",
                                                  lat_index,
                                                  lon_index,
                                                  alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=False)
        if amin == None:
            amin = math.ceil(tmin / 10000.0) * 10.0
        if amax == None:
            amax = math.floor(tmax / 10000.0) * 10.0

    if zmin == None or zmax == None:
        if gData[zkey].attrs['scale'].find("exp") >= 0:
            rvals = False
        else:
            rvals = True
        tmin, tmax = gpr.find_data_limits_ivalues([gData],
                                                  zkey,
                                                  lat_index,
                                                  lon_index,
                                                  alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=rvals)
        if zmin == None:
            zmin = tmin
        if zmax == None:
            zmax = tmax

    if (xmin == None or xmax == None) and plot_type.find("linear") < 0:
        tmin, tmax = gpr.find_data_limits_ivalues([gData],
                                                  xkey,
                                                  lat_index,
                                                  lon_index,
                                                  alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=True)
        if xmin == None:
            xmin = tmin
        if xmax == None:
            xmax = tmax

    # Initialize the x and z data
    if plot_type.find("linear") >= 0:
        x_data = np.array(gData[zkey])
        x_name = gData[zkey].attrs['name']
        x_scale = gData[zkey].attrs['scale']
        x_units = gData[zkey].attrs['units']
        xmin = zmin
        xmax = zmax
        z_data = []
        z_name = ""
        z_scale = ""
        z_units = ""
    else:
        x_data = np.array(gData[xkey])
        x_name = gData[xkey].attrs['name']
        x_scale = gData[xkey].attrs['scale']
        x_units = gData[xkey].attrs['units']
        z_data = np.array(gData[zkey])
        z_name = gData[zkey].attrs['name']
        z_scale = gData[zkey].attrs['scale']
        z_units = gData[zkey].attrs['units']

        if color.find('k') == 0:
            color = False
        else:
            color = True

        marker = True
        line = zcenter

    # Initialize the new figure
    alt_data = np.array(gData['Altitude'] / 1000.0)
    f, ax = pap.plot_mult_alt_images(plot_type,
                                     subindices,
                                     x_data,
                                     alt_data,
                                     z_data,
                                     x_name,
                                     x_scale,
                                     x_units,
                                     "km",
                                     y_label=y_label,
                                     z_name=z_name,
                                     z_scale=z_scale,
                                     z_units=z_units,
                                     xmin=xmin,
                                     xmax=xmax,
                                     amin=amin,
                                     amax=amax,
                                     zmin=zmin,
                                     zmax=zmax,
                                     title=title,
                                     figname=None,
                                     draw=False,
                                     color1=color,
                                     color2=marker,
                                     color3=line)

    # Add the hmF2 lines, if desired
    if add_hmf2 and not gData.has_key("hmF2"):
        gData.calc_2dion()
        if not gData.has_key("hmF2"):
            print module_name, "WARNING: hmF2 data is not available"
            add_hmF2 = False

    if add_hmf2:
        # Initialize lat/lon indexes that won't change
        datadim = list()
        if lon_len == 0:
            datadim.append(gData.attrs['nLon'])
            lonmin = 0
            lonmax = gData.attrs['nLon']
        elif lon_len == 1:
            lonmin = lon_index[0]
            lonmax = lonmin + 1

        if lat_len == 0:
            datadim.append(gData.attrs['nLat'])
            latmin = 0
            latmax = gData.attrs['nLat']
        elif lat_len == 1:
            latmin = lat_index[0]
            latmax = latmin + 1

        # Iterate over all subplot axes
        for i, iax in enumerate(ax):
            # Initialize changing lat/lon indexes
            if lon_len > 1:
                lonmin = lon_index[i]
                lonmax = lonmin + 1
            if lat_len > 1:
                latmin = lat_index[i]
                latmax = latmin + 1

            # Initialize the hmF2 data by plot type
            if plot_type.find("linear") >= 0:
                x = np.array([xmin, xmax])
                y = np.array([
                    gData['hmF2'][lonmin:lonmax, latmin:latmax, 0],
                    gData['hmF2'][lonmin:lonmax, latmin:latmax, 0]
                ])
                y = y.reshape(2)
            else:
                x = x_data[lonmin:lonmax, latmin:latmax, 0]
                x = x.reshape(datadim)
                y = np.array(gData['hmF2'][lonmin:lonmax, latmin:latmax, 0])
                y = y.reshape(datadim)

            # Plot the hmF2 line
            iax.plot(x, y, color=hcolor, linestyle=hline, linewidth=2)

    if draw:
        # Draw to screen.
        if plt.isinteractive():
            plt.draw()  #In interactive mode, you just "draw".
        else:
            # W/o interactive mode, "show" stops the user from typing more
            # at the terminal until plots are drawn.
            plt.show()

    # Save output file
    if figname is not None:
        plt.savefig(figname)

    return f
Example #4
0
def gitm_mult_alt_images(plot_type, zkey, gData, lat_index, lon_index,
                         title=None, figname=None, draw=True, xkey="dLat",
                         color="b", marker="o", line=":", zmax=None, zmin=None,
                         amax=None, amin=None, xmax=None, xmin=None,
                         zcenter=False, add_hmf2=False, hcolor="k", hline="--",
                         *args, **kwargs):
    '''
    Creates a linear or contour altitude map for a specified altitude range.
    A list of latitude and longitude indexes should be specified.  They may
    be of equal length (for paired values), or for a constant value in one
    coordinate, a length of list one can be specified.
    
    Input: plot_type = key to determine plot type (linear, contour)
           zkey      = key for z variable (ie 'Vertical TEC')
           gData     = gitm bin structure
           lat_index = list of latitude indices (empty list for all)
           lon_index = list of longitude indices (empty list for all)
           title     = plot title
           figname   = file name to save figure as (default is none)
           draw      = Draw figure to screen (default is True)
           xkey      = x coordinate for contour plots (default dLat)
           color     = line color for linear plots (default blue)
           marker    = marker type for linear plots (default circle)
           line      = line type for linear plots (default dotted line)
           zmax      = z key maximum (or None to compute automatically, default)
           zmin      = z key minimum (or None to compute automatically, default)
           amax      = a key maximum (or None to compute automatically, default)
           amin      = a key minimum (or None to compute automatically, default)
           xmax      = x key maximum for countour plots (or None to compute
                       automatically, default)
           xmin      = x key minimum for contour plots (or None to compute
                       automatically, default)
           zcenter   = Should the z range be centered about zero (default is
                       False, for uncentered)
           add_hmf2  = Add line showing hmF2? (default=False)
           hcolor    = Line color for hmF2 line (default=black)
           hline     = Line style for hmF2 line (default=dashes)
    '''
    module_name = "gitm_mult_alt_images"

    # Process the index lists
    lat_len = len(lat_index)
    lon_len = len(lon_index)

    if lat_len != lon_len and lat_len > 1 and lon_len > 1:
        print module_name, "ERROR: improperly paired lat/lon indices"
        return

    if lat_len <= 1:
        y_label = ["{:.1f}$^\circ$ Lon".format(gData['dLon'][l,1,1])
                   for l in lon_index]
    elif lon_len <= 1:
        y_label = ["{:.1f}$^\circ$ Lat".format(gData['dLat'][1,l,1])
                   for l in lat_index]
    else:
        y_label = ["{:.1f}$^\circ$ Lat, {:.1f}$^\circ$ Lon".format(gData['dLat'][1,l,1], gData['dLon'][lon_index[i],1,1]) for i,l in enumerate(lat_index)]

    # Initialize the input data indices
    subindices = [lon_index, lat_index]

    # Initialize the x,y,z variable limits if desired
    alt_index = [0, gData.attrs['nAlt']]
    alt_range = True
    lat_range = False
    lon_range = False
    if lat_len == 0:
        lat_index = [0, gData.attrs['nLat']]
        lat_range = True
    if lon_len == 0:
        lon_index = [0, gData.attrs['nLon']]
        lon_range = True

    if amin == None or amax == None:
        tmin, tmax = gpr.find_data_limits_ivalues([gData],"Altitude",lat_index,
                                                  lon_index,alt_index,
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=False)
        if amin == None:
            amin = math.ceil(tmin / 10000.0) * 10.0
        if amax == None:
            amax = math.floor(tmax / 10000.0) * 10.0

    if zmin == None or zmax == None:
        if gData[zkey].attrs['scale'].find("exp") >= 0:
            rvals = False
        else:
            rvals = True
        tmin, tmax = gpr.find_data_limits_ivalues([gData], zkey, lat_index,
                                                  lon_index, alt_index, 
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=rvals)
        if zmin == None:
            zmin = tmin
        if zmax == None:
            zmax = tmax

    if (xmin == None or xmax == None) and plot_type.find("linear") < 0:
        tmin, tmax = gpr.find_data_limits_ivalues([gData], xkey, lat_index,
                                                  lon_index, alt_index,  
                                                  lat_range=lat_range,
                                                  lon_range=lon_range,
                                                  alt_range=alt_range,
                                                  rvals=True)
        if xmin == None:
            xmin = tmin
        if xmax == None:
            xmax = tmax

    # Initialize the x and z data
    if plot_type.find("linear") >= 0:
        x_data = np.array(gData[zkey])
        x_name = gData[zkey].attrs['name']
        x_scale = gData[zkey].attrs['scale']
        x_units = gData[zkey].attrs['units']
        xmin = zmin
        xmax = zmax
        z_data = []
        z_name = ""
        z_scale = ""
        z_units = ""
    else:
        x_data = np.array(gData[xkey])
        x_name = gData[xkey].attrs['name']
        x_scale = gData[xkey].attrs['scale']
        x_units = gData[xkey].attrs['units']
        z_data = np.array(gData[zkey])
        z_name = gData[zkey].attrs['name']
        z_scale = gData[zkey].attrs['scale']
        z_units = gData[zkey].attrs['units']

        if color.find('k') == 0:
            color = False
        else:
            color = True

        marker=True
        line=zcenter

    # Initialize the new figure
    alt_data = np.array(gData['Altitude'] / 1000.0)
    f, ax = pap.plot_mult_alt_images(plot_type, subindices, x_data, alt_data,
                                     z_data, x_name, x_scale, x_units, "km",
                                     y_label=y_label, z_name=z_name,
                                     z_scale=z_scale, z_units=z_units,
                                     xmin=xmin, xmax=xmax, amin=amin, amax=amax,
                                     zmin=zmin, zmax=zmax, title=title,
                                     figname=None, draw=False, color1=color,
                                     color2=marker, color3=line)

    # Add the hmF2 lines, if desired
    if add_hmf2 and not gData.has_key("hmF2"):
        gData.calc_2dion()
        if not gData.has_key("hmF2"):
            print module_name, "WARNING: hmF2 data is not available"
            add_hmF2 = False

    if add_hmf2:
        # Initialize lat/lon indexes that won't change
        datadim = list()
        if lon_len == 0:
            datadim.append(gData.attrs['nLon'])
            lonmin = 0
            lonmax = gData.attrs['nLon']
        elif lon_len == 1:
            lonmin = lon_index[0]
            lonmax = lonmin + 1
        
        if lat_len == 0:
            datadim.append(gData.attrs['nLat'])
            latmin = 0
            latmax = gData.attrs['nLat']
        elif lat_len == 1:
            latmin = lat_index[0]
            latmax = latmin + 1

        # Iterate over all subplot axes
        for i,iax in enumerate(ax):
            # Initialize changing lat/lon indexes
            if lon_len > 1:
                lonmin = lon_index[i]
                lonmax = lonmin + 1
            if lat_len > 1:
                latmin = lat_index[i]
                latmax = latmin + 1

            # Initialize the hmF2 data by plot type
            if plot_type.find("linear") >= 0:
                x = np.array([xmin, xmax])
                y = np.array([gData['hmF2'][lonmin:lonmax,latmin:latmax,0],
                              gData['hmF2'][lonmin:lonmax,latmin:latmax,0]])
                y = y.reshape(2)
            else:
                x = x_data[lonmin:lonmax,latmin:latmax,0]
                x = x.reshape(datadim)
                y = np.array(gData['hmF2'][lonmin:lonmax,latmin:latmax,0])
                y = y.reshape(datadim)

            # Plot the hmF2 line
            iax.plot(x, y, color=hcolor, linestyle=hline, linewidth=2)

    if draw:
        # Draw to screen.
        if plt.isinteractive():
            plt.draw() #In interactive mode, you just "draw".
        else:
            # W/o interactive mode, "show" stops the user from typing more 
            # at the terminal until plots are drawn.
            plt.show()

    # Save output file
    if figname is not None:
        plt.savefig(figname)

    return f