Table of Contents

Class: MadrigalDataRecord cedar.py

MadrigalDataRecord holds all the information in a Cedar data record.

Methods   
__get2DIncrValueList__
__get2DMainValueList__
__get2DValueList__
__init__
__str__
add1D
add2D
delete1D
delete2DParm
delete2DRows
get1D
get1DParms
get2D
get2DParms
getEndTimeList
getHeaderKodLines
getKindat
getKinst
getNrow
getStartTimeList
getType
set1D
set2D
setEndTimeList
setKindat
setKinst
setStartTimeList
writeRecord
  __get2DIncrValueList__ 
__get2DIncrValueList__ (
        self,
        code,
        scaleFactor,
        )

__get2DIncrValueList__ returns a list containing all the additional increment 2D values of a given main parameter.

Inputs:

parm - parameter code (integer). Must be a parameter with an additional increment parameter.

Outputs: a list containing all the additional increment 2D values of a given main parameter. Special values will be given the values missing, assumed, or knownbad

  __get2DMainValueList__ 
__get2DMainValueList__ (
        self,
        code,
        scaleFactor,
        )

__get2DMainValueList__ returns a list containing all the 2D values of a given main parameter.

Inputs:

code - parameter code (integer). Must be a parameter with an additional increment parameter.

Outputs: a list containing all the 2D values of a given main parameter that has an additional increment parameter. Special values will be given the values missing, assumed, or knownbad

  __get2DValueList__ 
__get2DValueList__ ( self,  parm )

__get2DValueList__ returns a list containing all the 2D values of a given parameter.

Inputs:

parm - can be defined as code (integer) or case-insensitive mnemonic string (eg, "Gdalt")

Outputs: a list containing all the 2D values of a given parameter. Special values will be given the values missing, assumed, or knownbad

  __init__ 
__init__ (
        self,
        kinst,
        kindat,
        sYear,
        sMonth,
        sDay,
        sHour,
        sMin,
        sSec,
        sCentisec,
        eYear,
        eMonth,
        eDay,
        eHour,
        eMin,
        eSec,
        eCentisec,
        oneDList,
        twoDList,
        nrow,
        madInstObj=None,
        madParmObj=None,
        )

__init__ creates a MadrigalDataRecord with all missing data.

Inputs:

kinst - the kind of instrument code. A warning will be raised if not in instTab.txt.

kindat - kind of data code. Must be a non-negative integer.

sYear,sMonth,sDay,sHour,sMin,sSec,sCentisec - record start time. sCentisec must be 0-99

eYear,eMonth,eDay,eHour,eMin,eSec,eCentisec - record end time. eCentisec must be 0-99

oneDList - list of one-dimensional parameters in record. Parameters can be defined as codes (integers) or case-insensitive mnemonic strings (eg, "Gdalt")

twoDList - list of two-dimensional parameters in record. Parameters can be defined as codes (integers) or case-insensitive mnemonic strings (eg, "Gdalt")

nrow - number of rows of 2D data to create. Until set, all values default to missing.

madInstObj - a madrigal.metadata.MadrigalInstrument object. If None, one will be created. Used to verify kinst.

madParmObj - a madrigal.data.MadrigalParameter object. If None, one will be created. Used to verify convert parameters to codes.

Outputs: None

Returns: None

Exceptions   
'kindat cannot be negative: %i' %( kindat )
ValueError, 'nrow must not be less that zero: = %i' %( nrow )
  __str__ 
__str__ ( self )

returns a string representation of a MadrigalDataRecord

  add1D 
add1D ( self,  oneDParm )

add1D adds a new one-dim parameter to a MadrigalDataRecord

Input: oneDParm - Parameter can be defined as codes (integer) or case-insensitive mnemonic string (eg, "Gdalt")

Affects: adds tuple to self.__oneDList, where tuple has five elements: (code, lower-case mnemonic, parameter description, scaleFactor, hasAddIncrement)

Also adds one item to self.__oneDData, with value = missing. Creates self.__oneDData if does not exist.

Exceptions   
ValueError, 'Illegal use of an "additional increment" Cedar parameter %s, since this module sets values via doubles, not ints' %( mnem )
  add2D 
add2D ( self,  twoDParm )

add2D adds a new two-dim parameter to a MadrigalDataRecord

Input: twoDParm - Parameter can be defined as codes (integer) or case-insensitive mnemonic string (eg, "Gdalt")

Affects: adds tuple to self.__twoDList, where tuple has five elements: (code, lower-case mnemonic, parameter description, scaleFactor, hasAddIncrement)

Also adds one column with self.__nrow rows to self.__twoDData, with value = missing. Creates self.__twoDData if does not exist.

Exceptions   
ValueError, 'Illegal use of an "additional increment" Cedar parameter %s, since this module sets values via doubles, not ints' %( mnem )
  delete1D 
delete1D ( self,  parm )

delete1D removes the given 1D parameter from the record

Inputs:

parm - can be defined as code (integer) or case-insensitive mnemonic string (eg, "Gdalt")

Outputs: None

Raise exception if 1D parm does not exist

Exceptions   
ValueError, 'Parameter %s not found as 1D parameter in this data record' %(str( parm ) )
  delete2DParm 
delete2DParm ( self,  parm )

delete2DParm removes the given 2D parameter from every row in the record

Inputs:

parm - can be defined as code (integer) or case-insensitive mnemonic string (eg, "Gdalt")

Outputs: None

Raise exception if 2D parm does not exist

Exceptions   
ValueError, '2D Parameter %s not found in this data record' %(str( parm ) )
  delete2DRows 
delete2DRows ( self,  rows )

delete2DRows removes the given 2D row or rows in the record (first is row 0)

Inputs:

row number (integer) or list of row numbers to delete (first is row 0)

Outputs: None

Raise exception if row does not exist

Exceptions   
ValueError, 'Illegal value of row %i with nrow = %i' %( thisRow, self.__nrow )
  get1D 
get1D ( self,  parm )

get1D returns the 1D value for a given 1D parameter

Inputs:

parm - can be defined as code (integer) or case-insensitive mnemonic string (eg, "Gdalt")

Outputs: double value, or the strings "missing", "assumed", or "knownbad"

Exceptions   
ValueError, '1D Parameter %s not found in this data record' %(str( parm ) )
  get1DParms 
get1DParms ( self )

get1DParms returns a list of 1D parameters in the MadrigalDataRecord.

Inputs: None

Outputs: a list of 1D CedarParameter objects in the MadrigalDataRecord.

  get2D 
get2D (
        self,
        parm,
        row,
        )

get2D returns the 2D value for a given 2D parameter

Inputs:

parm - can be defined as code (integer) or case-insensitive mnemonic string (eg, "Gdalt")

row - row number to get data. Starts at 0.

Outputs: double value, or the strings "missing", "assumed", or "knownbad"

Exceptions   
ValueError, '2D Parameter %s not found in this data record' %(str( parm ) )
ValueError, 'Illegal value of row %i with nrow = %i' %( row, self.__nrow )
  get2DParms 
get2DParms ( self )

get2DParms returns a list of 2D parameters in the MadrigalDataRecord.

Inputs: None

Outputs: a list of 2D CedarParameter objects in the MadrigalDataRecord.

  getEndTimeList 
getEndTimeList ( self )

getEndTimeList returns a tuple containing eYear, eMonth, eDay, eHour, eMin, eSec, and eCentisec

Inputs: None

Outputs: a tuple containing eYear, eMonth, eDay, eHour, eMin, eSec, and eCentisec.

  getHeaderKodLines 
getHeaderKodLines ( self )

getHeaderKodLines creates the lines in the Madrigal header record that start KOD and describe parms

Inputs: None

Returns: a string of length 80*num 1D parms. Each 80 characters contains a description of a single parm accodring to the Cedar Standard

  getKindat 
getKindat ( self )

getKindat returns the kind of data code (int) for a given data record.

Inputs: None

Outputs: the kind of data code (int) for a given data record.

  getKinst 
getKinst ( self )

getKinst returns the kind of instrument code (int) for a given data record.

Inputs: None

Outputs: the kind of instrument code (int) for a given data record.

  getNrow 
getNrow ( self )

getNrow returns the number of 2D data rows (int) for a given data record.

Inputs: None

Outputs: the number of 2D data rows.

  getStartTimeList 
getStartTimeList ( self )

getStartTimeList returns a tuple containing sYear, sMonth, sDay, sHour, sMin, sSec, and sCentisec

Inputs: None

Outputs: a tuple containing sYear, sMonth, sDay, sHour, sMin, sSec, and sCentisec.

  getType 
getType ( self )

returns the type data

  set1D 
set1D (
        self,
        parm,
        value,
        )

set1D sets a 1D value for a given 1D parameter

Inputs:

parm - can be defined as code (integer) or case-insensitive mnemonic string (eg, "Gdalt")

value - double (or string convertable to double) value to set 1D parameter to. To set special Cedar values, the global values missing, assumed, or knownbad may be used, or the strings "missing", "assumed", or "knownbad"

Outputs: None

Note: if value exceeds the dynamic range of given parameter (ie, if value < -32766*scaleFactor or value > 32767*scaleFactor, then WARNING printed to stderr and value set to missing

Exceptions   
ValueError, 'Cannot set a Madrigal parameter to %s' %(str( value ) )
ValueError, 'Parameter %s not found as 1D parameter in this data record' %(str( parm ) )
  set2D 
set2D (
        self,
        parm,
        row,
        value,
        )

set2D sets a 2D value for a given 2D parameter and row

Inputs:

parm - can be defined as code (integer) or case-insensitive mnemonic string (eg, "Gdalt")

row - row number to set data. Starts at 0.

value - double (or string convertable to double) value to set 2D parameter to. To set special Cedar values, the global values missing, assumed, or knownbad may be used, or the strings "missing", "assumed", or "knownbad"

Outputs: None

Note: if value exceeds the dynamic range of given parameter (ie, if value < -32766*scaleFactor or value > 32767*scaleFactor, then WARNING printed to stderr and value set to missing

Exceptions   
ValueError, 'Cannot set a Madrigal parameter to %s' %(str( value ) )
ValueError, 'Illegal value of row %i with nrow = %i' %( row, self.__nrow )
ValueError, 'Parameter %s not found as 2D parameter in this data record' %(str( parm ) )
  setEndTimeList 
setEndTimeList (
        self,
        eYear,
        eMonth,
        eDay,
        eHour,
        eMin,
        eSec,
        eCentisec=0,
        )

setEndTimeList changes the data record end time

Inputs: integers eYear, eMonth, eDay, eHour, eMin, eSec. eCentisec defaults to 0

Outputs: None

Affects: changes self.__eYear, self.__eMonth, self.__eDay, self.__eHour, self.__eMin, self.__eSec, and self.__eCentisec. Also self.__eTime

Prints warning if new start time after present end time

Exceptions   
ValueError, 'Illegal datetime %s' %(str(( eYear, eMonth, eDay, eHour, eMin, eSec ) ) )
ValueError, 'Illegal eCentisec %i' %( eCentisec )
  setKindat 
setKindat ( self,  newKindat )

setKindat sets the kind of data code (int) for a given data record.

Inputs: newKindat (integer)

Outputs: None

Affects: sets self.__kindat

Exceptions   
'kindat cannot be negative: %i' %( kindat )
  setKinst 
setKinst ( self,  newKinst )

setKinst sets the kind of instrument code (int) for a given data record.

Inputs: newKinst - new instrument code (integer)

Outputs: None

Affects: sets self.__kinst

Exceptions   
ValueError, 'Kinst must not be less than 0, not %i' %( newKinst )
  setStartTimeList 
setStartTimeList (
        self,
        sYear,
        sMonth,
        sDay,
        sHour,
        sMin,
        sSec,
        sCentisec=0,
        )

setStartTimeList changes the data record start time

Inputs: integers sYear, sMonth, sDay, sHour, sMin, sSec. sCentisec defaults to 0

Outputs: None

Affects: changes self.__sYear, self.__sMonth, self.__sDay, self.__sHour, self.__sMin, self.__sSec, and self.__sCentisec. Also self.__sTime

Prints warning if new start time after present end time

Exceptions   
ValueError, 'Illegal datetime %s' %(str(( sYear, sMonth, sDay, sHour, sMin, sSec ) ) )
ValueError, 'Illegal sCentisec %i' %( sCentisec )
  writeRecord 
writeRecord (
        self,
        cedarFile,
        format,
        )

writeRecord writes a MadrigalDataRecord to an open cedarFile.

Users should not call this method directly. Use MadrigalCedarFile.write to persist data.

Inputs:

cedarFile - pointer to madrec as returned by madrigal._Madrec.madrecOpen

format - a format to save the file in. For now, the allowed values are Madrigal, BlockedBinary, UnblockedBinary, Cbf, and Ascii.

Outputs: None

Affects: writes MadrigalDataRecord to cedar file

Exceptions   
IOError, 'Tried to set 1D error parm %s to zero' %(thisParm [ 1 ] )
IOError, 'Tried to set 2D error parm %s to zero' %(thisParm [ 0 ] )
IOError, 'error in cedarSet1dParm'

Table of Contents

This document was automatically generated on Thu Oct 20 16:51:50 2011 by HappyDoc version r1_5