33from mwr_raw2l1 .errors import CorruptRectype , EmptyLineError
44from mwr_raw2l1 .readers .reader_helpers import get_time , simplify_header
55
6+ from mwr_raw2l1 .log import logger
67
78def 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