Changeset 3271


Ignore:
Timestamp:
25/01/08 15:13:21 (12 years ago)
Author:
domlowe
Message:

More docstrings

Location:
TI02-CSML/trunk/csml/API
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/API/ops_AbstractFeature.py

    r3267 r3271  
    11''' ops_AbstractFeature  contains operations for AbstractFeatures 
    22These methods are attached to AbstractFeature instances at runtime. 
    3 Therefore they are inherited by all feature instances (unless they are overwritten''' 
     3Therefore they are inherited by all feature instances (unless they are overwritten)''' 
    44import string 
    55import cdtime 
  • TI02-CSML/trunk/csml/API/ops_ArrayGenerator.py

    r1483 r3271  
    1 ''' ops_ArrayGenerator ''' 
     1''' ops_ArrayGenerator, These methods are attached to ArrayGenerator instances at runtime. ''' 
    22import sys 
    33import cdtime 
    44     
    55def getGeneratedValues(self,frame, summary=None): 
    6     #For times, given a CF 'frame' generate a list of times. 
    7     #frame of the form "calendar:units since date time") 
    8     #supported calendars on NDG wiki 
    9     #eg getGeneratedValues("360_day:days since 2001-12-18 00:00:00") 
     6    ''' 
     7    For times, given a CF 'frame' generate a list of times. 
     8    frame of the form "calendar:units since date time") 
     9    supported calendars on NDG wiki 
     10    eg getGeneratedValues("360_day:days since 2001-12-18 00:00:00") 
     11     
     12    Not widely used or  tested yet 
     13     
     14    ''' 
    1015    cal=frame.split(':',1)[0] 
    1116    basedate=frame.split(':',1)[1] 
     
    1419    interval=int(self.expression.split(':')[1]) 
    1520    end=int(self.expression.split(':')[2]) 
    16     print cdtime.DefaultCalendar 
    17     print start 
    18     print end 
    19     print interval 
    2021    if summary is not None: 
    2122        #return a summary of times (min, interval, max)  using cdtime 
  • TI02-CSML/trunk/csml/API/ops_Dataset.py

    r3003 r3271  
    1 ''' ops_Dataset  contains operations for root Dataset class''' 
     1''' ops_Dataset  contains operations for root Dataset class. These methods are attached to Dataset instances at runtime.''' 
    22import codecs 
    33import csml.csmllibs.xmlEncoding 
     
    1717 
    1818def testmethod(self): 
     19    ''' test method ''' 
    1920    print 'testmethod for dataset' 
    2021    return 'testmethod dataset' 
    2122 
    2223def parse(self, csmlfile, xmldb=None, collection='/db/ndg_A_metadata', id_field = 'id', nslong='http://ndg.nerc.ac.uk/csml', nsshort='csml', passwords=None): 
    23     """must be provided with csmlfile   parses the csmlfile into self """ 
     24    '''This Dataset.parse() method is the way to parse a CSML document. must be provided with csmlfile   parses the csmlfile into self. Alternatively can access an Exist database, but this is not widely tested. 
     25    Dataset then becomes complete hierarchy of CSML parser objects corresponding to the document that has beeen parser ''' 
    2426    if xmldb is not None:       
    2527        #use xml db (exist) 
     
    99101 
    100102def getFeatureList(self): 
    101     #returns a list of feature ids for the dataset 
     103    ''' returns a list of feature ids for the dataset''' 
    102104    self.featureList = [] 
    103105    for member in csml.csmllibs.csmlextra.listify(self.featureCollection.featureMembers): 
     
    112114 
    113115def getFileExtract(self,extractID): 
    114         for extract in csml.csmllibs.csmlextra.listify(self.dataset.arrayDescriptors): 
    115             if  extract.id==extractID: 
    116                 return extract  
     116    ''' returns a single file extract by id''' 
     117    for extract in csml.csmllibs.csmlextra.listify(self.dataset.arrayDescriptors): 
     118        if  extract.id==extractID: 
     119            return extract  
    117120 
    118121def getCSMLBoundingBox(self): 
    119     #returns a complete boundingBox object including temporal domain and crs 
     122    ''' returns a complete boundingBox object including temporal domain and crs''' 
    120123    if hasattr(self.featureCollection, 'boundedBy'): 
    121124        return csml.API.csmlbbox.CSMLBoundingBox(self.featureCollection.boundedBy) 
  • TI02-CSML/trunk/csml/API/ops_Phenomenon.py

    r3055 r3271  
    22    ''' returns a CF standard name or None from within the phenomoneon object''' 
    33    #<parameter xlink:href="http://badc.rl.ac.uk/localparams#solar_1"></parameter> 
    4 # 
    54    if self.href[:40]=='http://cfconventions.org/standard_names/': 
    65        stdname=self.href[40:] 
  • TI02-CSML/trunk/csml/API/ops_PointSeriesFeature.py

    r3022 r3271  
    1 ''' ops_PointSeriesFeature  contains operations for PointSeriesFeatures''' 
     1''' ops_PointSeriesFeature  contains operations for PointSeriesFeatures. These methods are attached to PointSeriesFeature instances at runtime.''' 
    22import csml,sys 
    33import cdms, MV, MA 
    44 
    55def testmethod(self): 
     6    ''' testmethod for gridseries feature''' 
    67    print 'testmethod for pointSeries feature' 
    78    return 'testmethod pointSeries' 
    89 
    910def getAllowedSubsettings(self): 
     11    '''get the allowed operations 
     12    @return:    list of operations''' 
    1013    return ['subsetToPointSeries'] 
    1114     
    1215def getDomain(self): 
    13     #returns domain as a dictionary of ordinates {name: [values], ...} 
     16    ''' returns domain as a dictionary of ordinates {name: [values], ...} ''' 
    1417    self.domain={} 
    1518    valList=[] 
     
    2427    
    2528def getLongitudeAxis(self): 
     29    ''' get the index of the longitude axis''' 
    2630    return 'longitude' #dummy value not used, subsetting is by time only 
    2731 
    2832def getLatitudeAxis(self): 
     33    ''' get the index of the latitude axis''' 
    2934    return 'latitude' #dummy value not used,  subsetting is by time only 
    3035 
    3136def getTimeAxis(self): 
     37    ''' get the index of the time axis''' 
    3238    return 'times' 
    3339     
    3440def subsetToPointSeries(self, outputdir=None, ncname='pointseries.nc' ,times=None): 
     41    '''Subset a PointSeriesFeature to a PointSeriesFeature. Performs the subset (note this includes nearest neighbour searching, so may return a different set of kwargs. 
     42     
     43    @param outputdir:    name of directory to write data files to 
     44    @param ncname:     name of netcdf file to write out 
     45    @param times:       selection by times 
     46    @return:     subsettedFeature (PointSeriesFeature instance)  pathToSubsetNetCDF (filepath), descriptor (array descriptor instance)''' 
    3547    if outputdir is not None: 
    3648        self.outputdir=outputdir 
     
    167179     
    168180def subsetToPoint(self, outputdir=None, ncname='point.nc',time=None): 
     181    '''Subset a PointSeriesFeature to a PointFeature. Performs the subset (note this includes nearest neighbour searching, so may return a different set of kwargs. 
     182         
     183    @param outputdir:    name of directory to write data files to 
     184    @param ncname:     name of netcdf file to write out 
     185    @param time:       selection by single time 
     186    @return:     subsettedFeature (PointFeature instance)  pathToSubsetNetCDF (filepath), descriptor (array descriptor instance)''' 
    169187    if outputdir is not None: 
    170188        self.outputdir=outputdir 
  • TI02-CSML/trunk/csml/API/ops_ProfileSeriesFeature.py

    r3096 r3271  
    1 ''' ops_ProfileSeriesFeature  contains operations for ProfileSeriesFeatures''' 
     1''' ops_ProfileSeriesFeature  contains operations for ProfileSeriesFeatures. These methods are attached to ProfileSeriesFeature instances at runtime.''' 
    22import csml 
    33 
    44def testmethod(self): 
     5    ''' testmethod for gridseries feature''' 
    56    print 'testmethod for profileSeries feature' 
    67    return 'testmethod profileseries' 
     
    89 
    910def getDomain(self): 
    10     #returns domain as a dictionary of ordinates {name: [values], ...} 
    11     #For ProfileSeries this is a combination of the location attribute and the time ordinate. 
     11    '''returns domain as a dictionary of ordinates {name: [values], ...} 
     12    For ProfileSeries this is a combination of the location attribute and the time ordinate.''' 
    1213    self.domain={} 
    1314    self.gridnames={} 
     
    4142 
    4243def _subsetProfileSeries(self, **kwargs): 
    43     '''this takes a temporal selection from a ProfileSeries object  - i.e. returns one or more 'profiles', can be used to make another ProfileSeriesFeature or a Profile feature in the case of a single selection''' 
     44    '''this takes a temporal selection from a ProfileSeries object  - i.e. returns one or more 'profiles', can be used to make another ProfileSeriesFeature or a Profile feature in the case of a single selection - called by subsetToProfile and subsetToPointSeries''' 
    4445            
    4546    #set self.domain: 
     
    6869             
    6970def subsetToProfile(self, outputdir=None,ncname ='profile.nc',**kwargs): 
    70     #perform the subset  
     71    '''Subset a ProfileSeriesFeature to a ProfileFeature. Performs the subset (note this includes nearest neighbour searching, so may return a different set of kwargs. 
     72         
     73    @param outputdir:    name of directory to write data files to 
     74    @param ncname:     name of netcdf file to write out 
     75    @param kwargs:      subset selection by axis name. 
     76    @return:     subsettedFeature (ProfileFeature instance)  pathToSubsetNetCDF (filepath), descriptor (array descriptor instance)''' 
    7177    if outputdir is not None: 
    7278        self.outputdir=outputdir 
     
    173179 
    174180def subsetToPointSeries(self, outputdir=None,  ncname='pointseries.nc',**kwargs): 
    175     #this operation needs more testing. 
    176     #perform the subset  
     181    '''Subset a ProfileSeriesFeature to a PointSeriesFeature. Performs the subset (note this includes nearest neighbour searching, so may return a different set of kwargs. 
     182         
     183    @param outputdir:    name of directory to write data files to 
     184    @param ncname:     name of netcdf file to write out 
     185    @param kwargs:      subset selection by axis name. 
     186    @return:     subsettedFeature (PointSeriesFeature instance)  pathToSubsetNetCDF (filepath), descriptor (array descriptor instance) 
     187     
     188    note:     this operation needs more testing. 
     189    ''' 
    177190    if outputdir is not None: 
    178191        self.outputdir=outputdir 
  • TI02-CSML/trunk/csml/API/ops_RaggedSectionFeature.py

    r3096 r3271  
    1 ''' ops_RaggedSectionFeature  contains operations for RaggedSectionFeatures''' 
     1''' ops_RaggedSectionFeature  contains operations for RaggedSectionFeatures. These methods are attached to GridFeature instances at runtime.''' 
    22import csml 
    33import MA,MV,Numeric 
     
    66 
    77def testmethod(self): 
     8    ''' test method''' 
    89    print 'testmethod for ragged section feature' 
    910    return 'testmethod 2' 
    1011 
    1112def getDomain(self): 
    12     #returns domain as a dictionary of ordinates {name: [values], ...} 
     13    '''returns domain as a dictionary of ordinates {name: [values], ...}''' 
    1314    self.domain={} 
    1415     
     
    4849 
    4950def subsetByTime(self, outputdir=None, ncname='pointseries.nc' ,time=None): 
     51    ''' subset a ragged section by time 
     52    @param outputdir:    name of directory to write data files to 
     53    @param ncname:     name of netcdf file to write out 
     54    @param time:      subset selection by time. 
     55    @return:     subsettedFeature (RaggedSectionFeature)  pathToSubsetNetCDF (filepath), descriptor (array descriptor instance) 
     56    ''' 
     57     
    5058    descriptors=[] 
    5159    if outputdir is not None: 
  • TI02-CSML/trunk/csml/API/ops_RawFileExtract.py

    r3117 r3271  
    11''' ops_RawFileExtract  contains operations for RawFileExtracts which are assigned to class at runtime''' 
    2 # raw and image extracts need access to metadata defined in the CSML to 
    3 # correctly read the file. This method overrides the FileExtract getData() 
    4 # method making use of the readFile() DI method to pass this metadata to 
    5 # the data interface. 
    6 # TODO: This should probably be moved outside parser.py, possibly into 
    7 # API/ops_FileExtract 
     2 
    83def getData(self,  fileposition=None,**kwargs): 
    9     #file position defines the position of the filename if a list of filenames exists 
    10     #**kwargs can hold subsetting request. 
     4    '''raw and image extracts need access to metadata defined in the CSML to  
     5    correctly read the file. This method overrides the FileExtract getData() 
     6    method making use of the readFile() DI method to pass this metadata to 
     7    the data interface. 
    118     
     9    @param fileposition:   defines the position of the filename if a list of filenames exists 
     10    @param **kwargs:     can hold subsetting request. 
     11    @return:       data, fillValue, axisnames, units 
     12    ''' 
    1213 
    1314    if fileposition is not None: 
  • TI02-CSML/trunk/csml/API/ops_TrajectoryFeature.py

    r3068 r3271  
    1 ''' ops_TrajectoryFeature  contains operations for TrajectoryFeature''' 
     1''' ops_TrajectoryFeature  contains operations for TrajectoryFeature.These methods are attached to TrajectoryFeature instances at runtime.''' 
    22 
    33import csml, cdms, MV, MA 
     
    66 
    77def testmethod(self): 
     8    '''testmethod''' 
    89    print 'testmethod for TrajectoryFeature' 
    910    return 'testmethod - TrajectoryFeature' 
     11 
    1012def getAllowedSubsettings(self): 
     13    '''get the allowed operations 
     14    @return:    list of operations''' 
    1115    return ['subsetToTrajectory']  
    1216 
     
    2933     
    3034def getLongitudeAxis(self): 
     35    ''' get the index of the longitude axis, if one exists''' 
    3136    return self.__getAxis('lon') 
    3237 
    3338def getLatitudeAxis(self): 
     39    ''' get the index of the latitude axis, if one exists''' 
    3440    return self.__getAxis('lat') 
    3541 
    3642def getTimeAxis(self): 
     43    ''' get the index of the time axis, if one exists''' 
    3744    return self.__getAxis('time') 
    3845 
    3946def getNativeCRS(self): 
    40     #returns the crs of the feature 
     47    ''' returns the crs of the feature''' 
    4148    return self.value.trajectoryDomain.srsName 
    4249                     
    4350def getDomain(self): 
    44     #returns domain as a dictionary of ordinates {name: [values], ...} 
     51    ''' returns domain as a dictionary of ordinates {name: [values], ...}''' 
    4552    self.domain={} 
    4653    self.gridnames={} 
     
    6572 
    6673def _writeNetCDF(self): 
    67     #Now open a new NetCDF File:    
     74    ''' Writes a trajectory feature to netcdf:   ''' 
    6875    nc=cdms.open(self.pathToSubsetNetCDF,'w') 
    6976     
     
    110117    
    111118def subsetToTrajectory(self, outputdir=None, ncname='trajectory.nc' ,time=None, **kwargs): 
    112     ''' subsetting a trajectory feature by time '''         
     119    ''' subsetting a trajectory feature by time  
     120    @param outputdir:  name of directory to write data files to 
     121    @param ncname: name of netcdf file to write out 
     122    @param time: requested time point 
     123    @param kwargs: subset selection by axis name. 
     124    @return:     subsettedFeature (TrajectoryFeature instance)  pathToSubsetNetCDF (filepath), descriptor (array descriptor instance) 
     125     
     126    '''         
    113127    dataToRemove=[] # list to hold index values of data that falls outside the bounding box, 
    114128    #work out where to store the resulting files: 
Note: See TracChangeset for help on using the changeset viewer.