MadrigalReport is the class that produces reports on Madrigal data.
Non-standard Python modules used:
None
Change history:
Written by Bill Rideout May. 23, 2002
Modified by Bill Rideout Feb. 6, 2003
to use the C Maddata module
Modified by Bill Rideout Apr. 9, 2003
to add looker reports
Methods
|
|
__addPid
__dropLock
__getLock
__getNumQueriesRunning
__init__
genBackgroundReport
looker
looker2
|
|
__addPid
|
__addPid ( self, pid )
__addPid is a private helper function that adds a new pid to queryPid.txt.
Inputs: the pid to add.
Returns: None
Affects: Locks the global file metadata/userdata/queryPid.txt while being used; adds new pid to that file.
Exceptions: None
|
|
__dropLock
|
__dropLock ( self, filename )
__dropLock is a private helper function that drops exclusive access to filename via a locking file.
Inputs: filename = the file that exclusive access is required to.
Returns: None
Affects: Removes file filename + .LCK as a lock mechanism
Exceptions: None.
|
|
__getLock
|
__getLock ( self, filename )
__getLock is a private helper function that provides exclusive access to filename via a locking file.
Inputs: filename = the file that exclusive access is required to.
Returns: None
Affects: Writes file filename + .LCK as a lock mechanism
Exceptions: MadrigalError thrown if unable to write lock file
Notes: Will sleep for 1 second at a time, for a maximum of _MaxSleep seconds (presently 10)
if the file is not modified. After each second, it will check for the lock file to be removed
or modified. If it was modified, it resets the count to 0 sec and starts counting again. After
_MaxSleep counts it then assumes lock file is orphaned and returns. Orphaned file will be
removed when dropLock is called.
Exceptions
|
|
madrigal.admin.MadrigalError( "Unable to open " + filename + ".LCK as locking file ", None )
|
|
|
__getNumQueriesRunning
|
__getNumQueriesRunning ( self )
__getNumQueriesRunning is a private helper function that returns the number of global queries running.
Inputs: None.
Returns: the number of global queries running
Affects: Locks the global file metadata/userdata/queryPid.txt while being used; removes any dead process
ids from that file.
Exceptions: None
Exceptions
|
|
madrigal.admin.MadrigalError( 'Unable to read from file ' + str( queryFileName ), None )
madrigal.admin.MadrigalError( 'Unable to write to file ' + str( queryFileName ), None )
|
|
|
__init__
|
__init__ ( self, madDB=None )
__init__ initializes MadrigalWeb by reading from MadridalDB..
Inputs: Existing MadrigalDB object, by default = None.
Returns: void
Affects: Initializes self.__metaDir.
Exceptions: None.
|
|
genBackgroundReport
|
genBackgroundReport (
self,
email,
filenameList,
parmList,
filterList,
headerStr='',
summaryLevelIndicator=0,
)
genBackgroundReport starts a separate process that emails a report.
Inputs:
email - the email address to send the complete report to
filenameList - a list of full file paths to collect data from. (May be generated
by MadrigalDB.getFileList). The order of the filenames will be the order they
are listed in the report.
parmList - list of Mnemonics (may be in the form of integer strings) to be displayed.
filterList - list of filters to select data. Each filter is a string of the form
"mnem1 [,[+, -, /, *],mnem2],[lower limit 1],[upper limit 1][other limits]
Examples:
"gdalt,-,sdwht,0,10000"
"azm,170,180,-180,-170"
headerStr - a String to insert at the beginning of the report. (For example,
can include iformation on the parameters used to select the data.) Defaults to ''
summaryLevelIndicator:
0 - data level (the default), include data, and file info.
1 - same as 0 (data level), but with no file names and parameter labels between data.
2 - record level, include only record headers and file info.
3 - cycle level (not yet implemented, for now acts just like experiment level)
4 - experiment level, include only file info.
Returns: Process id (integer) of background process created. If too many processes are already
running, returns -1 and does not generate a report.
Affects: Generates a separate process to email a report.
|
|
looker
|
looker (
self,
parmList,
start_lat,
stop_lat,
step_lat,
start_lon,
stop_lon,
step_lon,
start_alt,
stop_alt,
step_alt,
year,
month,
day,
hour,
min,
sec,
printHeaderFlag=1,
oneDParmList=[],
oneDParmValues=[],
)
looker prints a Madrecord for a range of lat, lon, and alt.
Inputs:
parmList - a list of requested parameter mnemonics.
Do not include gdlat, glon, or gdalt - included by default
start_lat - start latitude in degrees
stop_lat - end latitude in degrees
step_lat - number of degrees in lat to step
start_lon - start longitude in degrees
stop_lon - end longitude in degrees
step_lon - number of longitude in lat to step
start_alt - start altitude in km
stop_alt - stop altitude in km
step_alt - number of km in alt to step
year
month
day
hour
min
sec
printHeaderFlag - if 0, don't print header. Default will print header.
oneDParmList - a python list of one-D parameters as mnemonics. Defaults to [].
oneDParmValues - a python list of doubles representing values of the one-D
parameters set in oneDParmList. Length must = len(oneDParmList).
Defaults to [].
Returns: None.
Affects: Prints a single Madrecord with lat, lon and alt as 2D parameters, along with all
requested parameters. If stop_lon < start_lon, goes through 0 long.
Exceptions: If problems with arguments
Exceptions
|
|
ValueError, 'Illegal float %s in oneDParmValues' %(str(oneDParmValues [ i ] ) )
ValueError, 'Illegal parm %s in oneDParmList' %(str(oneDParmList [ i ] ) )
ValueError, 'Len of oneDParmList=%i, must equal len of oneDParmValues=%i' %(len( oneDParmList ), ( oneDParmValues ) )
|
|
|
looker2
|
looker2 (
self,
parmList,
lats,
longs,
alts,
year,
month,
day,
hour,
min,
sec,
printHeaderFlag=1,
oneDParmList=[],
oneDParmValues=[],
twoDParmList=[],
twoDParmValues=[],
)
looker2 prints a Madrecord for a collection of lat, lon, and alt values.
It is similar to looker, but it does not use a grid of lat, lon, and alts. Instead, each input
point is independent. Also, it allows users to set both 1D and 2D parameters.
Inputs:
parmList - a list of requested parameter mnemonics.
Do not include gdlat, glon, or gdalt - included by default
lats - a list of latitudes to use
longs - a list of longitudes to use
alts - a list of altitudes (km) to use
year
month
day
hour
min
sec
printHeaderFlag - if 0, don't print header. Default will print header.
oneDParmList - a python list of one-D parameters as mnemonics. Defaults to [].
oneDParmValues - a python list of doubles representing values of the one-D
parameters set in oneDParmList. Length must = len(oneDParmList).
Defaults to [].
twoDParmList - a python list of two-D parameters as mnemonics. Defaults to [].
twoDParmValues - a python list of lists of len = len(twoDParmList). Each individual
list is a list of doubles representing values of the two-D
parameter set in twoDParmList, with a length = number
of points (or equal to len(lats)).
Defaults to [].
Returns: None.
Affects: Prints a single Madrecord with lat, lon and alt as 2D parameters, along with all
requested parameters.
Exceptions: If problems with arguments
Exceptions
|
|
ValueError, 'Illegal float %s in oneDParmValues' %(str(oneDParmValues [ i ] ) )
ValueError, 'Illegal parm %s in oneDParmList' %(str(oneDParmList [ i ] ) )
ValueError, 'Len of oneDParmList=%i, must equal len of oneDParmValues=%i' %(len( oneDParmList ), ( oneDParmValues ) )
|
|
|