Changeset 2767 for TI02-CSML


Ignore:
Timestamp:
06/08/07 15:43:15 (12 years ago)
Author:
domlowe
Message:

subset trajectory by times working, added some standard names support

Location:
TI02-CSML/trunk/csml
Files:
4 edited

Legend:

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

    r2761 r2767  
    1010    '''CSMLContainer object is used to hold features before generating a CSML document. This is useful because it allows you to subset several features sequentially then build a single CSML document containing all the subsetted features ''' 
    1111     
    12     def __init__(self,outputdir, csmlname='myfile.xml',docID='none',metadata='unspecified'): 
     12    def __init__(self,outputdir, csmlname='myfile.xml',docID='none',metadata='unspecified', datasetName='unspecified'): 
    1313        self.outputdir =outputdir 
    1414        globalContainer.OUTPUTDIR=outputdir 
    1515        self.csmlname=csmlname 
     16        self.datasetName=datasetName 
    1617        ''' Initialise CSML Dataset and FeatureCollection and populate with basic Metadata''' 
    1718        ''' 
    1819        docID = gml:id of Dataset element 
    19         docMetaDataProperty = gml:metaDataProperty of Dataset element  #hmm may need to allow a list here. 
     20        metadata = gml:metaDataProperty of Dataset element  #hmm may need to allow a list here. 
     21        csmlname = name of resulting csml file 
     22        datasetName = name used in <name> element of csml doc. 
    2023        ''' 
    2124        #initialise a new document 
     
    7477        self.ds.featureCollection.metaDataProperty=self.mdp 
    7578        self.ds.featureCollection.id=csml.csmllibs.csmlextra.getRandomID() 
     79        self.ds.name=csml.parser.csString(self.datasetName) 
    7680        csmlout=self.ds.toXML() 
    7781        #parse and pretty print the result to file 
  • TI02-CSML/trunk/csml/API/ops_TrajectoryFeature.py

    r2764 r2767  
    198198    var.name=self.name.CONTENT 
    199199    var.units=units[0] # hopefully there is just one unit in this list.. 
    200     setattr(var, 'missing_value' ,fillvalue) 
    201      
     200 
     201    
    202202    #create the time axis 
    203203    floatTimes=[] 
     
    210210    timeAx.designateTime() 
    211211    timeAx.id='time' 
     212    timeAx.standard_name='time' 
    212213    timeAx.units=tbase   
    213214    var.setAxis(0,timeAx)       
    214215    nc.write(var) 
    215216     
     217     
     218    #get standard_name table 
     219    sntable=csml.csmllibs.standardnames.__path__[0]+'/cf-standard-name-table.xml' 
     220    snt=csml.csmllibs.standardnames.snames.StandardNameTable(tablelocation=sntable) 
    216221     
    217222    #add auxiliary coordinate variables to hold the locations 
     
    219224        var=MV.array(spatialAxes[ax]) 
    220225        var.id=ax 
     226        #if id is standard_name, use it as a standard_name         
     227        if snt.lookup(ax) is 1: 
     228            var.standard_name=ax 
    221229        var.setAxis(0,timeAx) 
    222230        nc.write(var)     
  • TI02-CSML/trunk/csml/csmllibs/__init__.py

    r2029 r2767  
    1313import csmlcrs 
    1414import csmlxlink 
     15import standardnames 
    1516 
  • TI02-CSML/trunk/csml/csmllibs/standardnames/snames.py

    r2766 r2767  
    4242        description=None 
    4343         
    44         #parse the file and build the entries: 
     44        #parse the file and build the entries:        
     45         
    4546        try: 
    4647            tree=ET.parse(tablelocation)         
    47             self.tree=tree 
    4848        except IOError: 
    49             print 'Could not find standard name table' 
     49            print 'Warning: Could not find local copy of standard name table' 
     50            return None 
    5051        allEntries=tree.findall('entry') 
    5152        #add the entries to the dictionary 
Note: See TracChangeset for help on using the changeset viewer.