15 from dateutil
import parser
16 from datetime
import tzinfo, timedelta, datetime
30 l = glob.glob(fdbdir +
'/*.*.*')
33 filenameSplitted = os.path.split(i)[1].split(
'.')
34 if len(filenameSplitted[2]) < 10:
36 if i.find(
".obt") != -1:
38 file[
"expe"] = filenameSplitted[0]
39 file[
"type"] = filenameSplitted[1]
40 file[
"referenceTime"] = filenameSplitted[2]
41 file[
"refTime"] = parser.parse(filenameSplitted[2])
43 term = self.
getTerm(filenameSplitted[3])
44 file[
"term"] = filenameSplitted[3]
45 file[
"intTerm"] = term
46 file[
"validTime"] = file[
"refTime"] + term
49 file[
"intTerm"] = timedelta(seconds=0)
50 file[
"validTime"] = file[
"refTime"]
52 file[
"filename"] = os.path.split(i)[1]
54 if file[
"term"]
is None:
55 key = file[
"expe"]+
"."+file[
"type"]+
"."+file[
"referenceTime"]
57 key = file[
"expe"]+
"."+file[
"type"]+
"."+file[
"referenceTime"]+
"."+file[
"term"]
65 for file
in self.
map.values():
66 if file[
"validTime"] == date :
74 date = parser.parse(stringdate)
84 infile = open(self.
fdbdir +
"/" + file[
"filename"],
"r") 86 validity_date = infile.readline() 87 d = np.fromfile(file=infile, dtype="float64", \
88 count=int(n), sep=
" ")
98 for f
in self.
map.values():
99 key = f[
"expe"] +
"." + f[
"type"]
105 if f[
"referenceTime"]
in arr:
106 terms = arr[f[
"referenceTime"]]
109 arr[f[
"referenceTime"]] = terms
110 terms[f[
"intTerm"]] = f[
"term"]
111 for expe
in lst.keys():
112 for date
in lst[expe].keys():
119 lst[expe][date] = newT
129 for f
in self.
map.values():
130 key = f[
"expe"] +
"." + f[
"type"]
132 items[f[
'refTime']] = f[
'referenceTime']
144 for f
in self.
map.values():
145 key = f[
"expe"] +
"." + f[
"type"]
146 if expe == key
and refTime == f[
'refTime']
and validTime == f[
'validTime'] :
155 for expe
in lst.keys():
157 for date
in lst[expe].keys():
159 if len(lst[expe][date]) > 1:
160 for ech
in lst[expe][date]:
169 regex = re.compile(
'(?P<sign>-?)P(?:(?P<years>\d+)Y)?(?:(?P<months>\d+)M)?(?:(?P<days>\d+)D)?(?:T(?:(?P<hours>\d+)H)?(?:(?P<minutes>\d+)M)?(?:(?P<seconds>\d+)S)?)?')
170 duration = regex.match(term).groupdict(0)
171 delta = timedelta(days=int(duration[
'days']) + (int(duration[
'months']) * 30) + (int(duration[
'years']) * 365),
172 hours=int(duration[
'hours']),
173 minutes=int(duration[
'minutes']),
174 seconds=int(duration[
'seconds']))
def getTimeList(self, expe)
def getAtValidTime(self, date)
def __init__(self, fdbdir)
def getExpeAt(self, expe, refTime, validTime)
def ggetAtValidTime(self, stringdate)