Commit 95ca6cf4 authored by Jeff Piolle's avatar Jeff Piolle
Browse files

added zulu time management in time attributes

parent 23acc2aa
......@@ -96,7 +96,7 @@ class NCFile(AbstractMapper):
def get_geolocation_field(self, fieldname):
"""
return the equivalent field name in the file format for a standard
geolocation field (lat, lon, time).
geolocation field (lat, lon, time, z).
Used for internal purpose and should not be called directly.
......@@ -399,9 +399,9 @@ class NCFile(AbstractMapper):
if dim_translation:
# renaming of default dimensions
dims = list(comp.dimensions)
for i, dim in enumerate(dims):
for idim, dim in enumerate(dims):
if dim in dim_translation:
dims[i] = dim_translation[dim]
dims[idim] = dim_translation[dim]
logging.debug(
"CREATE : %s %s %s %s",
varnames[i], vardatatypes[i], dims, fillvalue
......@@ -721,9 +721,16 @@ class NCFile(AbstractMapper):
attrs = handler.ncattrs()
if 'start_date' in attrs:
attrdate = handler.getncattr('start_date').replace(' UTC', '')
# remove Zulu time indication
attrdate = attrdate.strip('Z')
if 'start_time' in attrs:
attrtime = handler.getncattr('start_time')
attrdate = attrdate + 'T' + attrtime.replace(' UTC', '')
# remove Zulu time indication
attrtime = attrtime.strip('Z')
# remove UTC time indication
attrtime = attrtime.replace(' UTC', '')
# combine time and date
attrdate = attrdate + 'T' + attrtime
if '.' in attrdate:
return datetime.datetime.strptime(
attrdate, "%Y-%m-%dT%H:%M:%S.%f"
......@@ -741,9 +748,16 @@ class NCFile(AbstractMapper):
attrs = self.get_handler().ncattrs()
if 'stop_date' in attrs:
attrdate = handler.getncattr('stop_date').replace(' UTC', '')
# remove Zulu time indication
attrdate = attrdate.strip('Z')
if 'stop_time' in attrs:
attrtime = handler.getncattr('stop_time')
attrdate = attrdate + 'T' + attrtime.replace(' UTC', '')
# remove Zulu time indication
attrtime = attrtime.strip('Z')
# remove UTC time indication
attrtime = attrtime.replace(' UTC', '')
# combine time and date
attrdate = attrdate + 'T' + attrtime
if '.' in attrdate:
return datetime.datetime.strptime(
attrdate, "%Y-%m-%dT%H:%M:%S.%f"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment