Ignore:
Timestamp:
04/02/08 12:19:28 (12 years ago)
Author:
domlowe
Message:

fixing example parser and point series subsetting of inline content

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/Examples/Parsing/apicalls.py

    r2049 r3296  
    33import csml 
    44 
    5 f='Examples/parsing/test.xml' 
     5f='example.xml' 
     6outputdir = 'out' 
    67 
    78#Initialise the CSML container 
    8 csmlContainer=csml.API.csmlContainer.Container(csmlpath='myfile.xml',docID="mycsmldoc_1", metadata="mymetadatastring") 
     9csmlContainer=csml.API.csmlContainer.Container(outputdir,csmlname='myfile.xml',docID="mycsmldoc_1", metadata="mymetadatastring") 
    910 
    1011#Initialise and parse the dataset 
    11 csmldoc = csml.parser.Dataset() 
    12 csmldoc.parse(f) 
     12csmldoc = csml.parser.Dataset(file=f) 
    1313 
    1414 
     
    1919 
    2020#select a feature by name (gml:id) 
    21 print '\n Selecting feature with gml:id = %s' %flist[4] 
    22 feature=csmldoc.getFeature(flist[4]) 
     21print '\n Selecting feature with gml:id = %s' %flist[0] 
     22feature=csmldoc.getFeature(flist[0]) 
    2323 
    2424f#eature 'bestname' 
     
    2727 
    2828#get the domain of the feature 
    29 print '\n The feature has domain reference:'  
    30 print feature.getDomainReference() 
    31  
    32 #get the domain complement of the feature 
    33 print '\n The feature has domain complement :'  
    34 print feature.getDomainComplement() 
    35  
    36 #get combined domain 
    37 print '\n The feature has domain:'  
    38 #print feature.getDomain() 
     29print '\n The feature has domain: ' 
     30print feature.getDomain() 
    3931 
    4032#get list of allowed subsettings 
     
    4335 
    4436 
    45 #define a selection (based on the domain ref/complement) 
    46 #timeSelection=['2881-3-16T0:0:0.0', '2881-4-16T0:0:0.0', '2881-5-16T0:0:0.0', '2881-6-16T0:0:0.0', '2881-7-16T0:0:0.0', '2881-8-16T0:0:0.0', '2881-9-16T0:0:0.0'] 
    47 timeSelection=['2794-12-1T0:0:0.0', '2844-12-1T0:0:0.0'] 
    48  
    49 spatialSubsetDictionary= {} 
    50 spatialSubsetDictionary['latitude']=(-90,90) 
    51 #spatialSubsetDictionary['longitude']=(330,359) 
    52 spatialSubsetDictionary['longitude']=(-31.265,30.258) 
     37#define a selection (based on the domain) 
     38timeSelection=['2007-08-12T10:45:00', '2007-08-12T11:45:00'] 
    5339 
    5440#request subsetted data from features (can set paths here) and add to container 
    5541#subset a feature 
    56 csmlContainer.add(feature.subsetToGridSeries(timeSelection,  ncpath='myfile.nc',**spatialSubsetDictionary)) 
    57 #subset another feature (in fact it's the same feature again, but it proves the concept) 
    58 csmlContainer.add(feature.subsetToGridSeries(timeSelection,  ncpath='myfile2.nc',**spatialSubsetDictionary)) 
     42csmlContainer.add(feature.subsetToPointSeries(times=timeSelection,  ncname='myfile.nc')) 
    5943 
    6044#when you have finished, get the contents of the container 
Note: See TracChangeset for help on using the changeset viewer.