Commit 5b396c4276fff40698484deb88d35416321fd48a
1 parent
9ecc3961
Exists in
master
and in
9 other branches
time.mktime : LOCAL TIME => replace by calendar.timegm : UTC
Showing
1 changed file
with
5 additions
and
8 deletions
Show diff stats
src/DDSERVICES/HAPI/reader.py
... | ... | @@ -16,6 +16,7 @@ import shutil |
16 | 16 | import gzip |
17 | 17 | import tempfile |
18 | 18 | import time |
19 | +import calendar | |
19 | 20 | import datetime |
20 | 21 | import dateutil.parser |
21 | 22 | import xml.etree.ElementTree as ET |
... | ... | @@ -255,9 +256,8 @@ def get_start_stop_from_times_nc_file(metadata, localpath, tmin, tmax): |
255 | 256 | localpath = metadata['LOCATION'] |
256 | 257 | |
257 | 258 | times_nc_file = "{}{}".format(localpath, metadata['TIMES']) |
258 | - | |
259 | - start = time.mktime(tmin.timetuple()) | |
260 | - stop = time.mktime(tmax.timetuple()) | |
259 | + start = calendar.timegm(tmin.timetuple()) | |
260 | + stop = calendar.timegm(tmax.timetuple()) | |
261 | 261 | |
262 | 262 | command = _GETFILENAMES+' '+str(times_nc_file)+' '+str(start)+' '+str(stop) |
263 | 263 | result = subprocess.check_output(command, shell=True) |
... | ... | @@ -339,9 +339,8 @@ def main(argv): |
339 | 339 | para_index = None |
340 | 340 | para_name = par |
341 | 341 | var_index[para_name].append(para_index) |
342 | - | |
342 | + | |
343 | 343 | #variables = OrderedDict([(key, variables[key]) for key in para]) |
344 | - | |
345 | 344 | if tmin <= cur_end_time and tmax >= cur_start_time: # checking if file contains data within interval |
346 | 345 | # time = [amda_to_datetime(cur_time) for cur_time in nc.variables['Time']] |
347 | 346 | time = map(amda_to_datetime, nc.variables['Time']) |
... | ... | @@ -351,9 +350,7 @@ def main(argv): |
351 | 350 | break |
352 | 351 | |
353 | 352 | if cur_dt >= tmin and cur_dt <= tmax: |
354 | - | |
355 | - stream = '{}'.format(cur_dt.isoformat()) | |
356 | - | |
353 | + stream = '{}'.format(cur_dt.isoformat()) | |
357 | 354 | for var in variables: |
358 | 355 | if not 'Time' in var: |
359 | 356 | cur_data = nc.variables[var][cur_index] |
... | ... |