Reads a standart MAW file (as only used by me, Mauro A Werder) with
format:
#maw name of dataset # comment line #metadata is an metadata tag:
#metadata.eg = 'asdf' # will create a attribute in metadata.eg with value
'asdf' #metadata.num = '1.234' # # the last comment line has the format
and will be put into # metadata['headers'], metadata['units'] and use as
datatype: # name0 (units) [dtype], name1 (units) [dtype], name2 (units)
[dtype], ... val0, val1, val2 ... . . .
dtypes is one of the following: int, float, str, time_str
Time is represented as an ISO 8601 sting: "yyyy/mm/dd
HH:MM:SS(.FF)" excluding the 'T' without time zone information
(which should be given in the units as eg (UTC-7)).
The idea is to have a easy to parse text represenation of (a subset
of) what can be contained in a netcdf3 file.
- Parameters:
input_file (string) - input file name
- Returns: tuple
- tuple (data, raw_data, metadata)
>>> d,rd,md = read_maw_file('test_files/maw_file_test.maw')
>>> d,rd,md
(array([(733966.3673611111, 0.0, 0.303, 5, 'asdd asdlkj asl'),
(733966.3722222223, 15.0, 0.232, 8866, 'asdd asdlkj asl'),
(733966.3736111111, 25.0, 0.2055, 5, '7'),
(733966.3770833333, 50.0, 0.162, 5, '')],
dtype=[('time', '<f8'), ('var1', '<f8'), ('var2', '<f8'), ('var3', '<i8'), ('var4', '|O8')]), array([('2010-07-13 08:49:00', 0.0, 0.303, 5, 'asdd asdlkj asl'),
('2010-07-13 08:56:00', 15.0, 0.232, 8866, 'asdd asdlkj asl'),
('2010-07-13 08:58:00', 25.0, 0.2055, 5, '7'),
('2010-07-13 09:03:00', 50.0, 0.162, 5, '')],
dtype=[('time', '|O8'), ('var1', '<f8'), ('var2', '<f8'), ('var3', '<i8'), ('var4', '|O8')]), {'calibaration_solution_concentration': 10.0,
'calibaration_solution_concentration_units': 'g/l',
'dtypes': ['time_str', 'float', 'float', 'int', 'str'],
'experimenter': 'MAW + UM',
'headers': ['time', 'var1', 'var2', 'var3', 'var4'],
'raw_headers': ['time', 'var1', 'var2', 'var3', 'var4'],
'title': 'Test file',
'units': ['UTC-7', 'ml', '', 'm^3', '']})
|