Changeset 3279 for TI02-CSML


Ignore:
Timestamp:
28/01/08 14:30:12 (11 years ago)
Author:
domlowe
Message:

docstrings

Location:
TI02-CSML/trunk/csml/csmllibs
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/csmllibs/csmldataiface.py

    r3277 r3279  
    734734            return subset.copy() 
    735735 
    736  
    737 # Interface for reading data from image files. Requires PIL Image module. 
    738736class ImageFileInterface(RawFileInterface): 
    739737    '''Interface for reading data from image files. Requires PIL Image module.''' 
  • TI02-CSML/trunk/csml/csmllibs/csmldirectory.py

    r2444 r3279  
    1111 
    1212class DirectoryTree(object): 
    13          
     13        ''' Represents a directory''' 
    1414        def __init__(self): 
    1515                self.subdirlist=[] 
     
    3535                 
    3636        def readDirectory(self): 
     37                ''' read directory and add listing of files to subdirlist''' 
    3738                self.subdirlist.append(self.topdir) 
    3839                for item in os.listdir(self.topdir): 
     
    5253 
    5354        def getSubDirectories(self): 
     55                ''' get subdirectories in the file''' 
    5456                sublist = self.subdirlist 
    5557                #note the first (0) entry in the sub directory list is  
     
    5860         
    5961        def getFilesInSubDir(self,sub): 
     62                ''' get files in a sub directory''' 
    6063                filelist=[] 
    6164                for item in os.listdir(sub): 
     
    6568                         
    6669        def getFirstInSubDir(self,sub): 
     70                ''' get first file in a sub directory''' 
    6771                for item in os.listdir(sub): 
    6872                        filename=os.path.join(sub,item) 
     
    7377                                         
    7478        def getCSMLSupportedFilesInSubDir(self,sub): 
     79                ''' get files in sub directory that can be read for CSML content''' 
    7580                filelist=[] 
    7681                for item in os.listdir(sub): 
     
    8287         
    8388        def getAllCSMLFilesExceptFirst(self,sub): 
     89                ''' get all the files that can be read for CSML content except the first one''' 
    8490                filelist=self.getCSMLSupportedFilesInSubDir(sub) 
    8591                filelist=filelist[1:] 
     
    8793         
    8894        def getAllCSMLSupportedFiles(self): 
     95                ''' get all the files that can be read for CSML content''' 
    8996                filelist=[] 
    9097                for subdir in self.subdirlist: 
     
    101108                         
    102109                         
    103 #function to find if file is of a supported CSML type.                    
     110                  
    104111def isCSMLSupported(filename): 
     112        '''function to find if file is of a supported CSML type.''' 
    105113        fileExtension = str(filename)[-3:] 
    106114        supported = False 
  • TI02-CSML/trunk/csml/csmllibs/csmldocument.py

    r1487 r3279  
    55 
    66class CSMLDocument(object): 
     7    ''' Represents a CSML document ''' 
    78    def __init__(self,docID, docMetaDataProperty): 
    89        ''' 
    9         docID = gml:id of Dataset element 
    10         docMetaDataProperty = gml:metaDataProperty of Dataset element  #hmm may need to allow a list here. 
     10        @param docID:  gml:id of Dataset element 
     11        @param docMetaDataProperty:    gml:metaDataProperty of Dataset element  #hmm may need to allow a list here. 
    1112        ''' 
    1213        #initialise a new document 
     
    3435       #separate build classes for each feature type 
    3536    def addPointFeature(self, id, description,domainReference,rangeSet, parameter): 
    36         #TO DO- this needs revising in line with addGridSeriesFeature 
    3737        """ addPointFeature 
    3838        domainReference = Position type 
     
    4040        parameter = Phenomenon type 
    4141        """ 
     42        #TO DO- this needs revising in line with addGridSeriesFeature 
    4243        feat=csml.parser.PointFeature() 
    4344        feat.id=id 
     
    7778 
    7879    def addGridSeriesFeature(self,domain,rangeSet,datasetID=None,featureID=None,description=None): 
     80        ''' add GridSeriesFeature to document ''' 
    7981        fms=[] #empty featureMembers list 
    8082        feat=csml.parser.GridSeriesFeature() 
  • TI02-CSML/trunk/csml/csmllibs/csmlextra.py

    r3242 r3279  
    66 
    77def getRandomID(): 
    8     #returns a random 8 character alphanumeric string that can be used as an internal identifier in a CSML document. 
    9     #the ID only needs to be unique within the document that it occurs, so this is sufficiently random 
    10     #to make a clash extremely unlikely. The string is alphanumeric but always begins with an upper case letter.   
    11     #Note: tested with 50000 ids and all were different 
     8    '''returns a random 8 character alphanumeric string that can be used as an internal identifier in a CSML document. 
     9    the ID only needs to be unique within the document that it occurs, so this is sufficiently random 
     10    to make a clash extremely unlikely. The string is alphanumeric but always begins with an upper case letter.   
     11    Note: tested with 50000 ids and all were different''' 
    1212    randomID=random.choice(string.letters) 
    1313    randomID=string.upper(randomID) 
     
    1717 
    1818def _locateByGmlId(elem, idtofind): 
     19    ''' look for child element with particular id''' 
    1920    it=elem.getiterator() 
    2021    for i in it: 
     
    2526 
    2627def _getEmptyCSMLobj(tag): 
    27     #given an elementtree tag name, such as SpatialOrTemporalPositionList 
    28     #return a parser object such as csml.parser.SpatialOrTemporalPosition() 
     28    '''given an elementtree tag name, such as SpatialOrTemporalPositionList 
     29    return a parser object such as csml.parser.SpatialOrTemporalPosition()''' 
    2930    csmlname=tag.split('}')[1] 
    3031    return csml.parser.__dict__[csmlname]()        
     
    3233 
    3334def getObjbyGMLID(elem,idtofind): 
    34     #Given an element tree object and a gml:id return the fully parsed CSML object 
    35     #that matches the id 
    36     #useful for finding xlink matches 
     35    '''Given an element tree object and a gml:id return the fully parsed CSML object 
     36    that matches the id 
     37    useful for finding xlink matches''' 
    3738    matchingelement= _locateByGmlId(elem, idtofind) 
    3839    csmlobj=_getEmptyCSMLobj(matchingelement.tag) 
     
    9091     
    9192    def getAggregatedEnvelope(self): 
     93        ''' get aggregation of all envelopes in one aggregated envelope''' 
    9294        newenvelope=csml.parser.EnvelopeWithTimePeriod() 
    9395        newenvelope.beginPosition=csml.parser.csString(str(self.t1)) #convert from datetime types 
     
    101103 
    102104def getSeqRule(nDims): 
    103         #returns a sequenceRule  
    104         #*****************very simplified version***************** 
    105         #This really needs more work to see if the +s and -s are correct. and the x/y/z s in right order 
    106         #nDims = spatial dimensions + time dimension 
     105        '''returns a sequenceRule  
     106        *****************very simplified version***************** 
     107        This really needs more work to see if the +s and -s are correct. and the x/y/z s in right order 
     108        nDims = spatial dimensions + time dimension ''' 
    107109         
    108110        #TODO CSML2 - rewrite this 
     
    222224 
    223225def addEnvelope(fc): 
    224     #adds EnvelopeWithTimePeriod to feature collection, based on the spatial extent of the features within.    
    225     aggregator =  None 
     226    '''adds EnvelopeWithTimePeriod to feature collection, based on the spatial extent of the features within.   ''' 
    226227    for feature in fc.featureMembers: 
    227228        env=feature.boundedBy 
  • TI02-CSML/trunk/csml/csmllibs/csmlfeaturefilemap.py

    r1466 r3279  
    33 
    44class FeatureFileMap(object): 
    5         #this class is important to describe the relationship between the file structure and the feature type 'relationships' 
    6         #ie. a gridseriesfeature may span multiple files in a directory 
    7         #or a directory may contain several files each containing separate features. 
     5        '''this class is important to describe the relationship between the file structure and the feature type 'relationships' 
     6        ie. a gridseriesfeature may span multiple files in a directory 
     7        or a directory may contain several files each containing separate features. 
    88         
    99         
    10         #representative files - files that represent themselves as stand alone feature containers or represent a group of identically 
    11         #structured files. eg model data 
    12         #has featureType attribute 
     10        representative files - files that represent themselves as stand alone feature containers or represent a group of identically 
     11        structured files. eg model data 
     12        has featureType attribute 
    1313         
    14         #relatedFiles - files represented by the represented file (files of same structure as represented file -eg model data) 
    15         #also has featureType attribute 
     14        relatedFiles - files represented by the represented file (files of same structure as represented file -eg model data) 
     15        also has featureType attribute''' 
    1616                 
    1717        def __init__(self): 
    18                 #list of representativeFile objects, 
    19                 #each representativeFile object has a list of relatedFiles 
    20                 #each representativeFile has a featureType 
    21                 #each relatedFile has a featureType 
     18                '''list of representativeFile objects, 
     19                each representativeFile object has a list of relatedFiles 
     20                each representativeFile has a featureType 
     21                each relatedFile has a featureType''' 
    2222                self.repFiles=[] 
    2323                 
  • TI02-CSML/trunk/csml/csmllibs/csmlfeaturetypes.py

    r3144 r3279  
    1414 
    1515class featureBuilder(object): 
     16    ''' for building a feature in CSML''' 
    1617    def __init__(self, dataset_element, featureCollection_element, ffmap,fileExtractDictionary, timedim, timestorage,spatialstorage,valuestorage,minaxes): 
    1718        self.ds_element=dataset_element 
  • TI02-CSML/trunk/csml/csmllibs/netCDFWriter.py

    r3096 r3279  
    55 
    66class NCwriter(object): 
    7     #This provides a simplified wrapper to CDMS to write a CF compliant NetCDF 
     7    '''This provides a simplified wrapper to CDMS to write a CF compliant NetCDF''' 
    88    def __init__(self, fileName): 
    99        #initiates a new NetCDF file 
Note: See TracChangeset for help on using the changeset viewer.