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

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

lots of changes to do with subsetting

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    timeok=0
21    try:
22        year=int(timecheck.split('-')[0])
23        month=int(timecheck.split('-')[1])
24        day=int(timecheck.split('-')[2].split('T')[0])
25        tcheck=cdtime.comptime(year,month,day)
26        timeok=0
27        if tcheck.cmp(timemin) >= 0:
28            if tcheck.cmp(timemax) < 1:
29                timeok = 1
30        print 'TMIN time  %s'%timemin
31        print 'CHECK time  %s'%tcheck
32        print 'TMAX time  %s'%timemax
33    except:
34        #if it's not a proper internet time e.g. time = '6' then just compare numerically
35        timeok=0
36        if timecheck >=timemin:
37            if timecheck <=timemax:
38                timeok = 1
39    return timeok
40
41def __getCDtime(time): 
42    year=int(time.split('-')[0])
43    month=int(time.split('-')[1])
44    day=int(time.split('-')[2].split('T')[0])
45    hour=int(time.split('-')[2].split('T')[1].split(':')[0])
46    minute=int(time.split('-')[2].split('T')[1].split(':')[1])
47    second=float(time.split('-')[2].split('T')[1].split(':')[2])
48    cdTimeVal=cdtime.comptime(year,month,day,hour,minute,second)
49    return cdTimeVal
Note: See TracBrowser for help on using the repository browser.