Commit e9311903 authored by Jeff Piollé's avatar Jeff Piollé

added AVISO specificities in NCFile mapper, removed unnecessary mapper

parent 89908115
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
cerbere.mapper.cryosat2ncfile
=============================
Mapper for CryoSat-2 Altimeter files from NOAA RADS 4.0
:copyright: Copyright 2013 Ifremer / Cersat.
:license: Released under GPL v3 license, see :ref:`license`.
.. sectionauthor:: Jeff Piolle <jfpiolle@ifremer.fr>
.. codeauthor:: Jeff Piolle <jfpiolle@ifremer.fr>
"""
from datetime import datetime
from .ncfile import NCFile
class Cryosat2NCFile(NCFile):
"""
Mapper for CryoSat-2 Altimeter files from NOAA RADS 4.0.
Overrides the NCFile mapper to take into account some specific
attributes naming
"""
def get_start_time(self):
"""Returns the minimum date of the file temporal coverage"""
handler = self.get_handler()
attrdate = handler.getncattr('first_meas_time')
return datetime.strptime(attrdate, "%Y-%m-%d %H:%M:%S.%f")
def get_end_time(self):
"""Returns the maximum date of the file temporal coverage"""
handler = self.get_handler()
attrdate = handler.getncattr('last_meas_time')
return datetime.strptime(attrdate, "%Y-%m-%d %H:%M:%S.%f")
......@@ -1439,6 +1439,17 @@ class NCFile(AbstractMapper):
logging.error('Unexpected metadata time format.')
# Unexpected metadata time format.
return None
elif 'first_meas_time' in attrs:
# found in AVISO L2 products
try:
handler = self.get_handler()
attrdate = handler.getncattr('first_meas_time')
return datetime.datetime.strptime(attrdate,
"%Y-%m-%d %H:%M:%S.%f")
except ValueError:
logging.error('Unexpected metadata time format.')
# Unexpected metadata time format.
return None
else:
return None
......@@ -1482,6 +1493,17 @@ class NCFile(AbstractMapper):
# Unexpected metadata time format.
logging.error('Unexpected metadata time format.')
return None
elif 'last_meas_time' in attrs:
# found in AVISO L2 products
try:
handler = self.get_handler()
attrdate = handler.getncattr('last_meas_time')
return datetime.datetime.strptime(attrdate,
"%Y-%m-%d %H:%M:%S.%f")
except ValueError:
logging.error('Unexpected metadata time format.')
# Unexpected metadata time format.
return None
else:
return None
......
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