Table of Contents

Class: madPcolorPlot madrigalWebPlot/madrigalPlot.py

madPcolorPlot is the class that produces pcolor plots of x versus y with z intensity.

Assumes the x axis is time.

Usage example:

        obj = madPcolorPlot(isprintText,
                        'Nel (log(m^-3)) - Millstone Hill - Oct. 30, 2003 - Alt code',
                        'Hours since midnight UT Oct. 30, 2003',
                        'Altitude (km)',
                        './isprint.png',
                        minColormap = 9,
                        maxColormap = 12,
                        smoothAltitude = False)    

Non-standard Python modules used: matplotlib

Change history:

Written by Bill Rideout Mar. 31, 2005

Methods   
__filter_missing
__getYIndex
__init__
__truncateIsprint
_removeMissing
decimateTimes
displayToScreen
getAverage
getFigureHandle
sortArrayInTime
  __filter_missing 
__filter_missing ( self,  x )

  __getYIndex 
__getYIndex ( self,  yvalue )

__getYIndex returns the correct index into the y dimension for a given y value.

Input: yvalue - value of y parameter

Returns: the correct index into the y dimension

Algorithm: if self.truncateAlt == False, simple use the dictionary self.yListDict. Else loop through self.yListRanges and return the first greater than the requested value

  __init__ 
__init__ (
        self,
        isprintText,
        titleStr,
        xLabelStr,
        yLabelStr,
        fullFilename,
        minColormap=None,
        maxColormap=None,
        smoothAltitude=True,
        insertDataGap=5,
        useAbsoluteTime=False,
        startTime=None,
        endTime=None,
        sortTimeFlag=False,
        maxNumTimes=None,
        maxNumAlt=None,
        truncateIsprint=False,
        colorMap=matplotlib.cm.jet,
        yMinimum=None,
        yMaximum=None,
        altYTitle=None,
        altYLabels=None,
        )

__init__ writes a madPColorPlot to a file.

Inputs:

isprintText - a string giving isprint output without headers. First parameter must be UTH or UT1, depending on whether time scale should be relative to the experiment beginning (UTH) or absolute (UT1). The second must be gdalt, and third parameter to be plotted.

titleStr - plot title (string) - should describe parameter being plotted

xLabelStr - x label string

yLabelStr - ylabel string

fullFilename - full path of file containing pcolor plot to be saved. Extension must be jpeg or png, or exception thrown.

minColormap - minimum parameter value (defaults to lowest parameter value)

maxColormap - maximum parameter value (defaults to highest parameter value). However, if both minColormap and maxColormap == None, autoscaling applied.

smoothAltitude - if True, extrapolate between existing data between altitudes to fill in missing data; if False, leave missing

insertDataGap - this parameter sets the threshold for inserting a data gap. The time intervals being plotted are ordered, and the time gap larger than 90% of the rest is determined. Any time interval more than insertDataGap times bigger is then considered missing data. Defaults to five. If None, no gaps are ever inserted. For data with close to uniform time intervals, no gaps will be inserted.

useAbsoluteTime - if true, print time as YYYY-MM-DD HH:MM:SS. If false (default), print time as hour since beginning of experiment (UTH). If useAbsoluteTime is true, first parameter in isprintText must be UT1, if false, it must be UTH.

startTime - start plot at given time. If useAbsoluteTime == True, then startTime must be in units of seconds since 1/1/1950. If useAbsoluteTime == False, then startTime must be in units of UTH (hours since midnight UT of first day of experiment). Default is None, which means start at lowest time found.

endTime - end plot at given time. If useAbsoluteTime == True, then endTime must be in units of seconds since 1/1/1950. If useAbsoluteTime == False, then endTime must be in units of UTH (hours since midnight UT of first day of experiment). Default is None, which means end at largest time found.

sortTimeFlag - if true, check that time is correctly sorted. If false (the default), assume time already sorted

maxNumTimes - if not None, decimate the number of times in the isprint string to maxNumTimes. If None (the default), plot all times.

maxNumAlt - if not None, reduce the number of altitudes to maxNumAlt. If None (the default), plot all altitudes.

truncateIsprint - if True, and both maxNumTimes and maxNumAlt not = None, then truncate the number of isprint lines to be maxNumTimes * maxNumAlt

colorMap - sets colormap. It not given, defaults to matplotlib.cm.jet

yMinimum - minumum y value. If None (default), set by data y minimum.

yMaximum - maximum y value. If None (default), set by data y maximum.

altYTitle - title of right (second) y axis. If None (the default), no Y axis on the right side.

altYLabels - a list of Y labels (strings) for the right axis. If None (the default), no Y labels on the right axis.

Returns: void

Affects: None

Exceptions   
ValueError, 'No valid z data found'
ValueError, 'input text is not parseable'
  __truncateIsprint 
__truncateIsprint (
        self,
        isprintText,
        maxLines,
        )

__truncateIsprint truncates isprintText to have maxLines at most.

  _removeMissing 
_removeMissing ( self,  isprintText )

returns modified isprintText with all missing data removed

  decimateTimes 
decimateTimes (
        self,
        array_data,
        maxNumTimes,
        insertDataGap,
        )

decimateTimes decimates array_data to have at most maxNumTimes times.

Input: array_data - two-dimensional array to be decimated by deleting times and missing data.

maxNumTimes: int representing the maximum number of times to keep in array_data

insertDataGap - this parameter sets the threshold for inserting a data gap. The time intervals being plotted are ordered, and the time gap larger than 90% of the rest is determined. Note that this parameter is used here to stop the truncation of isprint lines that will eventually be considered edge lines.

Returns: new array built from decimated array_data

  displayToScreen 
displayToScreen ( self )

to implement this takes a reworking away from pylab to use the underlying matplotlib code

  getAverage 
getAverage ( self,  X )

returns the average of items in a float array. Does not including missing data. If all data missing, returns self.__missing

  getFigureHandle 
getFigureHandle ( self )

  sortArrayInTime 
sortArrayInTime ( self,  array_data )

sortArrayInTime sorts a two-dimensional array so that the first element in each row (time) is in ascending order.

Input: array_data - two-dimensional array to be sorted by rearranging rows so that the first element in each row (time) is in ascending order

Returns: new_array


Table of Contents

This document was automatically generated on Thu Aug 25 15:33:04 2011 by HappyDoc version r1_5