Skip to content

Commit 773e79d

Browse files
committed
changed default timestamp pattern to new version, add warning for old version
1 parent 49f6356 commit 773e79d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mwr_raw2l1/readers/reader_radiometrics_helpers.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from mwr_raw2l1.errors import CorruptRectype, EmptyLineError
44
from mwr_raw2l1.readers.reader_helpers import get_time, simplify_header
55

6+
from mwr_raw2l1.log import logger
67

78
def get_data(data_raw, header, no_mwr=False, **kwargs):
89
"""extract all known data from data_raw using header
@@ -17,13 +18,16 @@ def get_data(data_raw, header, no_mwr=False, **kwargs):
1718
"""
1819
data = get_simple_vars(data_raw, header)
1920
try:
20-
data['time'] = get_time(data_raw, header, 'date/time', '%m/%d/%y %H:%M:%S')
21-
except ValueError:
2221
# Radiometrics changed its timestamps format with upgrade to VizMetPro.
2322
# The new format is '%Y/%m/%d %H:%M:%S' instead of '%m/%d/%y %H:%M:%S'.
24-
# This is a workaround to support both formats but a better solution would be to
25-
# add this pattern to the config file.
23+
# TODO: This is a workaround to support both formats but a better solution would be to
24+
# add this pattern to the config file (or get rid of older formats but we can not exclude
25+
# that we integrate an old instrument once).
2626
data['time'] = get_time(data_raw, header, 'date/time', '%Y/%m/%d %H:%M:%S')
27+
except ValueError:
28+
logger.warning('Failed to parse time with new timestamp format %Y/%m/%d %H:%M:%S, trying with old version %m/%d/%y %H:%M:%S')
29+
data['time'] = get_time(data_raw, header, 'date/time', '%m/%d/%y %H:%M:%S')
30+
2731
if not no_mwr:
2832
data['Tb'], data['frequency'] = get_mwr(data_raw, header, **kwargs)
2933
return data

0 commit comments

Comments
 (0)