CatalogHeaderCreator is a class that automates the creation of catalog and header records
This class creates and adds catalog and header records that meet the Cedar standards. It does this
by examining the input Cedar file for all summary information possible. The user needs only
add text that describes their experiment. A Cedar file must already be written to disk before
this class is created.
Methods
|
|
__init__
_createCedarLines
_createMaxMinSummaryLines
_padStr
createCatalog
createHeader
write
|
|
__init__
|
__init__ ( self, madFilename )
__init__ reads in all summary information about madFilename using madrigal.data
|
|
_createCedarLines
|
_createCedarLines (
self,
prefix,
text,
)
_createCedarLines is a private method that returns a string which is a multiple of
80 characters (no line feeds) where each 80 character block starts with prefix,then a space,
and then the next part of text that fits on line, padded with spaces
Exceptions
|
|
IOError, 'Can not fit the word <%s> in a Cedar text record' %( word )
IOError, 'Too long prefix %s' %(str( prefix ) )
|
|
|
_createMaxMinSummaryLines
|
_createMaxMinSummaryLines ( self )
_createMaxMinSummaryLines is a private method that creates the max and min summary
lines (e.g., alt, gdlat, etc)
|
|
_padStr
|
_padStr (
self,
thisStr,
lineLen,
)
_padStr is a private method that pads a string with spaces so its length is module lineLen
|
|
createCatalog
|
createCatalog (
self,
principleInvestigator=None,
expPurpose=None,
expMode=None,
cycleTime=None,
correlativeExp=None,
sciRemarks=None,
instRemarks=None,
)
createCatalog will create a catalog record appropriate for this file. The additional
information fields are all optional, and are all simple text strings (except for
cycleTime, which is in minutes). If the text contains line feeds, those will be used
as line breaks in the catalog record.
The descriptions of these fields all come from Barbara Emery's documentation
cedarFormat.pdf
Inputs:
principleInvestigator - Names of responsible Principal Investigator(s) or others knowledgeable
about the experiment.
expPurpose - Brief description of the experiment purpose
expMode - Further elaboration of meaning of MODEXP; e.g. antenna patterns and
pulse sequences.
cycleTime - Minutes for one full measurement cycle
correlativeExp - Correlative experiments (experiments with related data)
sciRemarks - scientific remarks
instRemarks - instrument remarks
Returns: None
Affects: sets self._catalog
|
|
createHeader
|
createHeader (
self,
kindatDesc=None,
analyst=None,
comments=None,
history=None,
)
createHeader will create a header record appropriate for this file. The additional
information fields are all optional, and are all simple text strings. If the text contains l
ine feeds, those will be used as line breaks in the header record.
Inputs:
kindatDesc - description of how this data was analyzed (the kind of data)
analyst - name of person who analyzed this data
comments - additional comments about data (describe any instrument-specific parameters)
history - a description of the history of the processing of this file
Returns: None
Affects: sets self._header
|
|
write
|
write (
self,
newFilename=None,
format=None,
)
write will output the new file with prepended catalog and header records
Raises an IOError if no new catalog or header records to prepend
Inputs:
newFilename - if None, overwrite original file
format - Cedar format to use. If None, use same format as original file.
Exceptions
|
|
IOError, 'Does not make sense to save a new file if no catalog or header has been added'
|
|
|