MadrigalInstrument is an object that provides access to Madrigal instrument info from the metadata.
This object provides access to all Madrigal instrument information in the metadata files instTab.txt
and instType.Tab.
Usage example:
import madrigal.metadata
import madrigal.admin
try:
test = madrigal.metadata.MadrigalInstrument()
print test.getInstrumentName(30)
except madrigal.admin.MadrigalError, e:
print e.getExceptionStr()
Non-standard Python modules used:
None
MadrigalError exception thrown if:
MadrigalMetadata fails to open or parse metadata file
Columns expected to be ints or floats cannot be converted
Change history:
Written by Bill Rideout Nov. 9, 2001
Methods
|
|
|
|
__init__
|
__init__ (
self,
madDB=None,
initFile=None,
init2File=None,
)
__init__ initializes MadrigalInstrument by reading from instTab.txt (or initFile)
and instType.txt file (or init2File).
Inputs:
madDB - Existing MadrigalDB object, by default = None.
initFile - String representing the full path to the metadata file. Default is None, in
which case file read is MadrigalDB.getMetadataDir()/instTab.txt.
init2File - String representing the full path to the metadata file instType.txt. Default is
None, in which case file read is MadrigalDB.getMetadataDir()/instType.txt.
Returns: void
Affects: Initializes all the class member variables.
Exceptions: MadrigalError thrown by MadrigalMetadata if file not opened or parsed successfully.
Note that the instTab.txt file was updated with the release of the madrigal python api, and this
function will throw an error if used with the old file.
|
|
__instrumentSort
|
__instrumentSort (
self,
thisInst,
otherInst,
)
instrumentSort is a private method used to sort tuples of instrument data
|
|
getAltitude
|
getAltitude ( self, kinst )
getAltitude returns the altitude as a float that matches kinst argument, or None if not found or blank.
Inputs: kinst integer to get altitude.
Returns: the altitude in km above sea level as a float that matches kinst argument, or None if not found or blank.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getCategory
|
getCategory ( self, kinst )
getCategory returns the instrument category that matches kinst argument as a string, or
None if kinst not found.
Inputs: kinst integer to get altitude.
Returns: the instrument category that matches kinst argument as a string, or
None if kinst not found.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
madrigal.admin.MadrigalError('Error in instTtpe.txt parsing metadata row: ' + str( inst2 ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getCategoryId
|
getCategoryId ( self, kinst )
getCategory returns the instrument category that matches kinst argument as a string, or
None if kinst not found.
Inputs: kinst integer to get altitude.
Returns: the instrument category that matches kinst argument as a string, or
None if kinst not found.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getContactEmail
|
getContactEmail ( self, kinst )
getContactEmail returns the contact email as a string that matches kinst argument, or None if not found or blank.
Inputs: kinst integer to get contact email.
Returns: the contact email as a string that matches kinst argument, or None if not found or blank.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
This method added in Madrigal 2.6
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getContactName
|
getContactName ( self, kinst )
getContactName returns the contact name as a string that matches kinst argument, or None if not found or blank.
Inputs: kinst integer to get contact name.
Returns: the contact name as a string that matches kinst argument, or None if not found or blank.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
This method added in Madrigal 2.6
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getInstrumentList
|
getInstrumentList ( self )
getInstrumentList returns a list of all instrument names, mnemonics, and their kinst values.
Inputs: None.
Returns: a list of all instrument names, mnemonics, and their kinst values. Each item in the list
is a tuple of the form (Instrument Name (string), mnemonic (string), kinst (integer)). Example item:
(Millstone Hill UHF Steerable Antenna , mlh , 31)
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getInstrumentMnemonic
|
getInstrumentMnemonic ( self, kinst )
getInstrumentMnemonic returns the 3 char instrument mnemonic that matches kinst argument, or None if not found.
Inputs: kinst integer to get instrument mnemonic.
Returns: the instrument mnemonic that matches kinst argument, or None if not found.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getInstrumentName
|
getInstrumentName ( self, kinst )
getInstrumentName returns the instrument name that matches kinst argument, or None if not found.
Inputs: kinst integer to get instrument name.
Returns: the instrument name that matches kinst argument, or None if not found.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getLatitude
|
getLatitude ( self, kinst )
getLatitude returns the latitude as a float that matches kinst argument, or None if not found or blank.
Inputs: kinst integer to get latitude.
Returns: the latitude as a float that matches kinst argument, or None if not found or blank.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getLongitude
|
getLongitude ( self, kinst )
getLongitude returns the longitude as a float that matches kinst argument, or None if not found or blank.
Inputs: kinst integer to get longitude.
Returns: the longitude as a float that matches kinst argument, or None if not found or blank.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getOrderedInstrumentList
|
getOrderedInstrumentList ( self )
getOrderedInstrumentList returns a list of all (instrument names, mnemonics, kinst, categories, categoryId),
ordered by categoryId and then kinst.
Inputs: None.
Returns: a list of tuples of (instrument name, mnemonic, kinst, category, categoryId) ordered by categoryId and
then kinst. Example item:
(Millstone Hill UHF Steerable Antenna , mlh , 31, Incoherent Scatter Radars , 1)
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in instTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getOrderedInstrumentListWithData
|
getOrderedInstrumentListWithData (
self,
isTrusted,
localOnly=False,
localExpObj=None,
globalExpObj=None,
allowArchive=False,
requireFiles=False,
)
getInstrumentList returns information about which instruments have local and global data.
Inputs:
isTrusted - True if client is trusted, False otherwise
localOnly - if False (the default), will return information about both local and global data.
If True, then global data ignored.
localExpObj - an MadrigalExperiment object for the local data. If None (the default),
will be created.
globalExpObj - an MadrigalExperiment object for the global data. If None (the default),
will be created if not localOnly.
allowArchive - if True, allow experiments marked as security==2(public arcive), and if
isTrusted, allow security==3(private archive)
requireFiles - if True, only include experiments with Madrigal data files. If False
(default), not not require that.
Returns: an ordered tuple of two items:
1. a list of tuples of (instName, localStartYear, localEndYear, globalStartYear,
globalEndYear, kinst, categoryId), ordered by by categoryId, then kinst. If
localOnly, globalStartYear and globalEndYear = 0. If not local only, localStartYear
and localEndYear will be zero if no local data for that instrument.
2. categoryDict - key = categoryId, value = category Description
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
|
|