Changeset 2061 for TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py
- Timestamp:
- 26/01/07 15:01:10 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py
r2000 r2061 22 22 for gridOrd in self.value.gridSeriesDomain.coordTransformTable.gridOrdinates: 23 23 name=gridOrd.coordAxisLabel.CONTENT 24 if isinstance(gridOrd.coordAxisValues, csml.parser.FileExtract): 25 #not tested with file extracts yet: (01/01/07) 26 self.domain[name]=gridOrd.coordAxisValues.getData() 24 if hasattr(gridOrd.coordAxisValues, '__insertedExtract'): 25 self.domain[name]=gridOrd.coordAxisValues.__insertedExtract.getData() 27 26 else: 28 27 vals=gridOrd.coordAxisValues.coordinateList.CONTENT 29 28 valList=[] 30 for val in vals.split(','): #remove commas 29 print 'splitting' 30 for val in vals.split(): 31 31 valList.append(val) 32 print val 32 33 self.domain[name]=valList 33 34 return self.domain … … 41 42 42 43 self.getDomain() 44 45 #TODO - incoporate the crsCatalogue. into this 43 46 #deal with longitude requests 44 47 #if the request is in -ve,+ve eg (-30,30) but the data is in (0,360) need to handle this by changing the args. 45 48 kwargs=csmlutils.fixLongitude(self.domain,kwargs) 46 #deal with times 47 timeAxis=self._identifyTimeAxis(self.domain.keys()) 48 self.times=kwargs[timeAxis] 49 50 #deal with times 51 #need to find the time axis: 52 cat=csml.csmllibs.csmlcrs.CRSCatalogue() 53 crs=cat.getCRS(self.value.gridSeriesDomain.srsName) 54 #get the position of the time axis in crs/ axis labels 55 timeAxisPos=crs.timeAxis 56 #get the name of the time axis in the crs 57 timeName=crs.axes[timeAxisPos] 58 #get the ordinate with that name and find the original time name for the file. 59 for gridOrd in self.value.gridSeriesDomain.coordTransformTable.gridOrdinates: 60 if gridOrd.coordAxisLabel.CONTENT==timeName: 61 timeAxis = gridOrd.gridAxesSpanned.CONTENT #only works for regular grids atm 62 else: 63 print 'crs not supported' 64 65 66 #here, timeName is the name given to the time axis by the CRS, 67 #and timeAxis is the name given to the time axis in the file. 68 #currently supporting domain subsetting only by CRS name 69 #(but should be easy to extend later) 70 self.times=kwargs[timeName] 49 71 self.files=[] 50 72 strTimes='' … … 52 74 53 75 #set the reference system for the time axis 54 76 calset=False 55 77 for gridOrd in self.value.gridSeriesDomain.coordTransformTable.gridOrdinates: 56 if gridOrd.coordAxisLabel.CONTENT==time Axis:78 if gridOrd.coordAxisLabel.CONTENT==timeName: 57 79 try: 58 80 caltype=gridOrd.coordAxisValues.frame.split(':',1)[0] … … 69 91 except: 70 92 csml.csmllibs.csmltime.setcdtimeCalendar(csml.csmllibs.csmltime.cdtime.DefaultCalendar) 71 72 93 94 73 95 if len(self.times) == 2: 74 96 #then this is a range of times (t1, tn) 75 97 try: 76 tone= ops_AbstractFeature.__getCDtime(self.times[0])98 tone=csml.API.ops_AbstractFeature.__getCDtime(self.times[0]) 77 99 except: 78 100 tone=self.times[0] 79 101 try: 80 ttwo= ops_AbstractFeature.__getCDtime(self.times[1])102 ttwo=csml.API.ops_AbstractFeature.__getCDtime(self.times[1]) 81 103 except: 82 104 ttwo=self.times[1] … … 86 108 else: 87 109 self.getDomain() 88 for time in self.domain[timeAxis][0].split(): 110 111 for time in self.domain[timeName]: 89 112 timeok=csml.API.ops_AbstractFeature.__compareTimes(tone,time,ttwo) 90 113 if timeok ==1: 91 114 self.times.append(time) 115 #okay up to here! 116 92 117 if hasattr(self.value.rangeSet, 'aggregatedArray'): 93 118 #handle aggregatedArray … … 159 184 straxisValues='' 160 185 #now deal with each argument: 161 162 print "KWARGS" 163 print kwargs 164 print "DOM" 165 print self.domain 186 166 187 if key in kwargs: 167 if kwargs[key][0] < kwargs[key][1]: 188 if key ==timeName: 189 continue #dealt with time earlier 190 elif kwargs[key][0] < kwargs[key][1]: 168 191 for val in self.domain[key]: 169 print self.domain[key]170 192 if val is not '': 171 193 if float(val) >= kwargs[key][0]: … … 173 195 arraySize=arraySize+1 174 196 straxisValues=straxisValues+ str(val) + ', ' 175 176 197 else:#this if deals with selections such as longitude (330,30) where the lower limit is 'greater' than the upper limit in a mathematical sense. 177 198 for val in self.domain[key]: … … 210 231 floatTimes.append(time.value) 211 232 nc.addAxis('t',floatTimes,isTime=1,units=calunits,calendar=caltype) 233 #USE CRS! 212 234 for ordinate in ordinates: 213 235 lon,lat=None,None … … 223 245 if len(ordinates)==3: 224 246 axes=['t',axisorder[1],axisorder[2],axisorder[3]] 225 elif len( grid.ordinates)==2:247 elif len(ordinates)==2: 226 248 axes=['t',axisorder[1],axisorder[2]] 227 249 nc.addVariable(fulldata,self.id, axes,units='') #to do, units attribute for CF compliance
Note: See TracChangeset
for help on using the changeset viewer.