pycamx
Credits
Environcorp: http://www.camx.com
FortranFile.py: Neil Martinsen-Burrell
Description
Basically I can load camx avrg file into python's numpy array. I also intend to support met files.
reads:
avrg file
zp file
temp file
writes:
avrg file
creates:
avrg file
Here is an example.
Example
reads
>>> import camx
>>> avfil = camx.camx('avrg.dat')
>>> avfil.header
{'nx': 89, 'name': 'AVERAGE ', 'bdatetime': camx_datetime(2006, 6, 1, 0, 0),
'note': 'camx5201pr_cb05, 20060601, dfw8h2.bc06_06jun.reg2.2006ep0ext',
'ny': 89, 'nz': 28, 'iutm': 0, 'xorg': -12000.0, 'delx': 12000.0, 'dely': 12000.0,
'yorg': -1488000.0, 'nspec': 3, 'spec': ['NO', 'NO2', 'O3'],
'edatetime': camx_datetime(2006, 6, 2, 0, 0)}
>>> avfil.value.dtype, avfil.value.shape
(dtype('float32'), (89, 89, 28, 3, 24))
>>> avfil.value[5,5,0,2,:]
array([ 0.01212548, 0.01062091, 0.00699076, 0.00291533, 0.0016371 ,
0.00283867, 0.00527306, 0.00860224, 0.01262952, 0.02665699,
0.03111625, 0.03403297, 0.03732257, 0.04100296, 0.04435699,
0.04419025, 0.04000658, 0.03637949, 0.02711839, 0.02053112,
0.02039303, 0.02175843, 0.02041762, 0.01836622], dtype=float32)
>>>
>>>
writes
>>> avfil.write('out.dat')
>>> import filecmp
>>> filecmp.cmp('avrg.dat', 'out.dat')
True
>>>
>>>
met files
>>> zpfil = camx.zp('zp.dat', (89,89,28), (-12,-1488,12,0), (6152,0,6152,24))
>>> zpfil.header
{'nx': 89, 'name': 'AVERAGE ', 'bdatetime': camx_datetime(2006, 6, 1, 0, 0),
'note': 'pyCamx ',
'ny': 89, 'nz': 28, 'iutm': 0, 'xorg': -12000.0, 'delx': 12000.0, 'dely': 12000.0,
'yorg': -1488000.0, 'nspec': 2, 'spec': ['HEIGHT', 'PRESS'],
'edatetime': camx_datetime(2006, 6, 2, 0, 0)}
>>>
>>> tempfil = camx.temp('temp.dat', (89,89,28), (-12,-1488,12,0), (6152,0,6152,24))
>>> tempfil.header
{'nx': 89, 'name': 'AVERAGE ', 'bdatetime': camx_datetime(2006, 6, 1, 0, 0),
'note': 'pyCamx ',
'ny': 89, 'nz': 28, 'iutm': 0, 'xorg': -12000.0, 'delx': 12000.0, 'dely': 12000.0,
'yorg': -1488000.0, 'nspec': 1, 'spec': ['TEMP'],
'edatetime': camx_datetime(2006, 6, 2, 0, 0)}
>>>
>>>
from scratch
>>> newfil = camx.camx({'nx':89, 'ny':89, 'nz':1, 'spec': ['O3'],
... 'xorg':-12000,'yorg':-1488000,'delx':12000,'dely':12000,
... 'bdatetime': datetime.datetime(2006,6,1), 'edatetime':datetime.datetime(2006,6,2)})
>>> newfil.header
{'nx': 89, 'name': 'AVERAGE ', 'bdatetime': camx_datetime(2006, 6, 1, 0, 0),
'note': 'pyCamx ',
'ny': 89, 'nz': 1, 'iutm': 0, 'xorg': -12000, 'delx': 12000, 'dely': 12000,
'yorg': -1488000, 'nspec': 1, 'spec': ['O3'],
'edatetime': camx_datetime(2006, 6, 2, 0, 0)}
>>> newfil.value.dtype, newfil.value.shape
(dtype('float32'), (89, 89, 1, 1, 24))
>>> newfil.value[5,5,0,0,:]
array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32)
>>>
>>>