source: TI02-CSML/trunk/csml/API/ops_AbstractFeature.py @ 1932

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/API/ops_AbstractFeature.py@1937
Revision 1932, 1.5 KB checked in by domlowe, 13 years ago (diff)

changes to !subsetGridSeries

Line 
1''' ops_AbstractFeature  contains operations for AbstractFeatures'''
2import string
3import cdtime
4
5def testmethod(self):
6    print 'testmethod for abstract feature'
7    return 'testmethod abstract feature'
8
9def getAllowedSubsettings(self):
10    return ['none']
11
12def _identifyTimeAxis(self,listToCheck):
13    #given a list of possible axes, find the one which is most probably the time axis.
14    for name in listToCheck:
15        if string.upper(name) in ['T', 'TIME']:
16            tname =name
17    return tname
18
19def __compareTimes(timemin, timecheck, timemax):
20    try:
21        year=int(timecheck.split('-')[0])
22        month=int(timecheck.split('-')[1])
23        day=int(timecheck.split('-')[2].split('T')[0])
24        tcheck=cdtime.comptime(year,month,day)
25        timeok=0
26        if tcheck.cmp(timemin) >= 0:
27            if tcheck.cmp(timemax) < 1:
28                timeok = 1
29    except:
30        #if it's not a proper internet time e.g. time = '6' then just compare numerically
31        timeok=0
32        if timecheck >=timemin:
33            if timecheck <=timemax:
34                timeok = 1
35    return timeok
36
37def __getCDtime(time): 
38    year=int(time.split('-')[0])
39    month=int(time.split('-')[1])
40    day=int(time.split('-')[2].split('T')[0])
41    hour=int(time.split('-')[2].split('T')[1].split(':')[0])
42    minute=int(time.split('-')[2].split('T')[1].split(':')[1])
43    second=float(time.split('-')[2].split('T')[1].split(':')[2])
44    cdTimeVal=cdtime.comptime(year,month,day,hour,minute,second)
45    return cdTimeVal
Note: See TracBrowser for help on using the repository browser.