PseudoNetCDF.camxfiles package
Subpackages
- PseudoNetCDF.camxfiles.cloud_rain package
- PseudoNetCDF.camxfiles.finst package
- PseudoNetCDF.camxfiles.height_pressure package
- PseudoNetCDF.camxfiles.humidity package
- PseudoNetCDF.camxfiles.ipr package
- PseudoNetCDF.camxfiles.irr package
- PseudoNetCDF.camxfiles.landuse package
- PseudoNetCDF.camxfiles.lateral_boundary package
- PseudoNetCDF.camxfiles.one3d package
- PseudoNetCDF.camxfiles.point_source package
- PseudoNetCDF.camxfiles.temperature package
- PseudoNetCDF.camxfiles.uamiv package
- PseudoNetCDF.camxfiles.vertical_diffusivity package
- PseudoNetCDF.camxfiles.wind package
Submodules
PseudoNetCDF.camxfiles.ArrayTransforms module
utils
– Array Transforms
- PseudoNetCDF.camxfiles.ArrayTransforms.BoundToDiff(a, dim=-1)[source]
Calculate the first order difference between neighbors along dimension
- PseudoNetCDF.camxfiles.ArrayTransforms.CAMxHeightToDepth(a)[source]
Use full height array to calculate the depth of each model layer
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterCAMxU(a)[source]
Interpolate staggered U component of CAMx wind to cell center
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterCAMxV(a)[source]
Interpolate staggered V component of CAMx wind to cell center
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterCAMxWind(a)[source]
This function needs to be reviewed
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterCMAQWind(a)[source]
CMAQ wind components are located on the corners of a cell. This function centers those values and returns the time averaged and cell centered value.
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterCol(a)[source]
Center a variable across dimension 3. By IOAPI convention, dimension 3 is col.
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterLay(a)[source]
Center a variable across dimension 1. By IOAPI convention, dimension 1 is LAY.
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterRow(a)[source]
Center a variable across dimension 2. By IOAPI convention, dimension 2 is row.
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterRowCol(a)[source]
Center a variable across dimension 2 and 3. By IOAPI convention, dimension 2 is row and 3 is col.
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterTime(a)[source]
Center a variable across dimension 0. By IOAPI and general NetCDF convention, dimension 0 is time.
- PseudoNetCDF.camxfiles.ArrayTransforms.CenterTimeRowCol(a)[source]
Center a variable across dimension 0,2,3. By IOAPI convention, dimension 0 is time, 2 is row, and 3 si col.
- PseudoNetCDF.camxfiles.ArrayTransforms.ConvertCAMxTime(date, time, nvars=1)[source]
Use camx date and time arrays to produce an IOAPI standard TFLAG variable
- PseudoNetCDF.camxfiles.ArrayTransforms.interior_vertex_func(a, dims=(-1, -2), func=<function sum>)[source]
Reduces the array dimensions by 1, by applying func to neighboring values.
- ex:
>>> x = array([[1,2,3], [4,5,6], [7,8,9]]) >>> y = interior_vertex_func(x) >>> y array([[12, 16], [24, 28]])
Note: low index neighbor is the first argument to func
PseudoNetCDF.camxfiles.FortranFileUtil module
FortranFileUtil
– Fortran File interaction functions
- PseudoNetCDF.camxfiles.FortranFileUtil.Asc2Int(spcname)[source]
Some CAMx output files need the text stored as integers. This function helps to do that
- PseudoNetCDF.camxfiles.FortranFileUtil.Int2Asc(mspec)[source]
Some CAMx input files have text stored as integers. This function helps to undo that
- PseudoNetCDF.camxfiles.FortranFileUtil.OpenRecordFile(rf)[source]
All CAMx files use FortranFileUtil.RecordFiles as inputs. This function decides if the input was of the right type. If not, it tries to make a RecordFile from the input.
rf - str, unicode, file, RecordFile
- class PseudoNetCDF.camxfiles.FortranFileUtil.RecordFile(infile, bigendian=True)[source]
Bases:
object
This class provides an easy interface to treat unformated Fortran files like like record files.
TODO: count=-1 does not work in aread, off by one element?!? TODO: error checking in aread, prevent reading past end of record
Arguments: infile – an open file-like object. Must be random access. Must
be a real file if the RecordFile.aread method is going to be used.
bigendian – boolean, True if file is bigendian
***Assumes single 4 byte integer pad on either end
- aread(type, count)[source]
Read a Numeric array
Arguments: type – a type code, one of those used by the struct or Numeric modules count – number of elements to read. If not specified,
defaults to all remaining bytes in current record
- next()[source]
Move to the next record. Returns True if sucessful, False if no more records available.
- PseudoNetCDF.camxfiles.FortranFileUtil.check_read(requested, result)[source]
Checks that the result of a read from a file was of the expected size Raises EOFError if nothing was read, or IOError if the read was incomplete
- PseudoNetCDF.camxfiles.FortranFileUtil.fread(ifile, count, read_type, return_type=None, byteswap=False)
- PseudoNetCDF.camxfiles.FortranFileUtil.freadnumpy(ifile, count, read_type, return_type=None, byteswap=False)[source]
- PseudoNetCDF.camxfiles.FortranFileUtil.freadstruct(ifile, count, read_type, return_type=None, byteswap=False)[source]
- PseudoNetCDF.camxfiles.FortranFileUtil.needs_byteswap(bigendian)[source]
Determines if byteswapping is necessary for the given endianness For example, if we are reading bigendian data, call
need_byteswap(True)
to see if that data needs to be swapped on the current platform
- PseudoNetCDF.camxfiles.FortranFileUtil.read_into(rf, dest, id_fmt, data_fmt='f')[source]
Read an array from a RecordFile into a Numeric array. I don’t know how this will work if dest is anything but 2D.
Arguments: rf – a RecordFile instance dest – a Numeric array, possibly a slice.
There must be at least product(shape(dest)) elements left in the current record
- PseudoNetCDF.camxfiles.FortranFileUtil.seek_to_record(rf, rid, fmt)[source]
Searches for a record beginning with rid by unpacking the first struct.calcsize(fmt) bytes and comparing the results
PseudoNetCDF.camxfiles.Memmaps module
Memmaps
– CAMx Memmap Interfaces
- class PseudoNetCDF.camxfiles.Memmaps.cloud_rain(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
cloud_rain provides a PseudoNetCDF interface for CAMx cloud_rain files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> cloud_rain_path = 'cloud_rain.bin' >>> rows, cols = 65, 83 >>> cloud_rainfile = cloud_rain(cloud_rain_path, rows, cols) >>> cloud_rainfile.variables.keys() ['CLOUD', 'RAIN', 'SNOW', 'GRAUPEL', 'COD', 'TFLAG'] >>> v = cloud_rainfile.variables['CLOUD'] >>> tflag = cloud_rainfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0, 0, :] array([2005185, 0]) >>> tflag[-1, 0, :] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> cloud_rainfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
- class PseudoNetCDF.camxfiles.Memmaps.finst(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
finst provides a PseudoNetCDF interface for CAMx finst files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> finst_path = 'camx_finst.bin' >>> finstfile = finst(finst_path) >>> finstfile.variables.keys() ['TFLAG', 'O3', 'NO', 'NO2', ...] >>> v = finstfile.variables['V'] >>> tflag = finstfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> finstfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- class PseudoNetCDF.camxfiles.Memmaps.height_pressure(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
height_pressure provides a PseudoNetCDF interface for CAMx height_pressure files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> height_pressure_path = 'camx_height_pressure.bin' >>> rows,cols = 65,83 >>> hpf = height_pressure(height_pressure_path,rows,cols) >>> hpf.variables.keys() ['TFLAG', 'HGHT', 'PRES'] >>> v = hpf.variables['V'] >>> tflag = hpf.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> hpf.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
- data_fmt = 'f'
- id_fmt = 'fi'
- class PseudoNetCDF.camxfiles.Memmaps.humidity(*args, **kwds)[source]
Bases:
one3d
humidity provides a PseudoNetCDF interface for CAMx humidity files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> humidity_path = 'camx_humidity.bin' >>> rows,cols = 65,83 >>> humidityfile = humidity(humidity_path,rows,cols) >>> humidityfile.variables.keys() ['TFLAG', 'HUM'] >>> v = humidityfile.variables['HUM'] >>> tflag = humidityfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> humidityfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
rows - number of rows in domain (defaults: 1) cols - number of columns in domain (defaults: size)
- units = 'ppm'
- var_name = 'HUM'
- class PseudoNetCDF.camxfiles.Memmaps.ipr(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
ipr provides a PseudoNetCDF interface for CAMx ipr files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> ipr_path = 'camx_ipr.bin' >>> iprfile = ipr(ipr_path) >>> iprfile.variables.keys() ['TFLAG', 'SPAD_O3', 'DATE_O3', 'TIME_O3', 'SPC_O3', 'PAGRID_O3', 'NEST_O3', 'I_O3', 'J_O3', 'K_O3', 'INIT_O3', 'CHEM_O3', 'EMIS_O3', 'PTEMIS_O3', 'PIG_O3', 'WADV_O3', 'EADV_O3', 'SADV_O3', 'NADV_O3', 'BADV_O3', 'TADV_O3', 'DIL_O3', 'WDIF_O3', 'EDIF_O3', 'SDIF_O3', 'NDIF_O3', 'BDIF_O3', 'TDIF_O3', 'DDEP_O3', 'WDEP_O3', 'INORGACHEM_O3', 'ORGACHEM_O3', 'AQACHEM_O3', 'FCONC_O3', 'UCNV_O3', 'AVOL_O3', 'EPAD_O3'] >>> v = iprfile.variables['CHEM_O3'] >>> tflag = iprfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> iprfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- Keywords (i.e., props) for projection: P_ALP, P_BET, P_GAM, XCENT,
YCENT, XORIG, YORIG, XCELL, YCELL
- data_fmt = 'f'
- dt_fmt = 'if'
- id_fmt = 'if10s5i'
- class PseudoNetCDF.camxfiles.Memmaps.irr(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
irr provides a PseudoNetCDF interface for CAMx irr files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> irr_path = 'camx_irr.bin' >>> rows,cols = 65,83 >>> irrfile = irr(irr_path,rows,cols) >>> irrfile.variables.keys() ['TFLAG', 'RXN_01', 'RXN_02', 'RXN_03', ...] >>> v = irrfile.variables['RXN_01'] >>> tflag = irrfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> irrfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- data_fmt = 'f'
- id_fmt = 'if5i'
- class PseudoNetCDF.camxfiles.Memmaps.landuse(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
landuse provides a PseudoNetCDF interface for CAMx landuse files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> landuse_path = 'camx_landuse.bin' >>> rows, cols = 65, 83 >>> landusefile = landuse(landuse_path, rows, cols) >>> landusefile.variables.keys() ['TFLAG', 'FLAND', 'TOPO'] >>> tflag = landusefile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0, 0, :] array([2005185, 0]) >>> tflag[-1, 0, :] array([2005185, 240000]) >>> v = landusefile.variables['FLAND'] >>> v.dimensions ('LANDUSE', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> landusefile.dimensions {'LANDUSE': 11, 'ROW': 65, 'COL': 83, 'VAR': 2}
- class PseudoNetCDF.camxfiles.Memmaps.lateral_boundary(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
lateral_boundary provides a PseudoNetCDF interface for CAMx lateral_boundary files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> lateral_boundary_path = 'camx_lateral_boundary.bin' >>> rows,cols = 65,83 >>> lbf = lateral_boundary(lateral_boundary_path,rows,cols) >>> lbf.variables.keys() ['TFLAG', 'O3', 'NO', 'NO2', ...] >>> tflag = lbf.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = lbf.variables['O3'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> lbf.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- class PseudoNetCDF.camxfiles.Memmaps.one3d(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
one3d provides a PseudoNetCDF interface for CAMx one3d files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> one3d_path = 'camx_one3d.bin' >>> rows,cols = 65,83 >>> one3dfile = one3d(one3d_path,rows,cols) >>> one3dfile.variables.keys() ['TFLAG', 'UNKNOWN'] >>> tflag = one3dfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = one3dfile.variables['UNKNOWN'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> one3dfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
rows - number of rows in domain (defaults: 1) cols - number of columns in domain (defaults: size)
- data_fmt = 'f'
- id_fmt = 'fi'
- classmethod isMine(path)[source]
True if this file or object can be identified for use by this class. Useful to override for classes that can be initialized from disk.
- units = 'UNKNOWN'
- var_name = 'UNKNOWN'
- class PseudoNetCDF.camxfiles.Memmaps.point_source(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
point_source provides a PseudoNetCDF interface for CAMx point_source files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> point_source_path = 'camx_point_source.bin' >>> rows,cols = 65,83 >>> point_sourcefile = point_source(point_source_path,rows,cols) >>> point_sourcefile.variables.keys() ['TFLAG', 'ETFLAG', 'TFLAG', 'XSTK', 'YSTK', 'HSTK', 'DSTK', 'TSTK', 'VSTK', 'KCELL', 'FLOW', 'PLMHT', 'NSTKS', 'NO', 'NO2', ...] >>> tflag = point_sourcefile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = point_sourcefile.variables['XSTK'] >>> v.dimensions ('NSTK',) >>> v.shape (38452,) >>> v = point_sourcefile.variables['NO2'] >>> v.dimensions ('TSTEP', 'NSTK') >>> v.shape (25, 38452) >>> point_sourcefile.dimensions {'TSTEP': 25, 'NSTK': 38452}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- class PseudoNetCDF.camxfiles.Memmaps.temperature(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
temperature provides a PseudoNetCDF interface for CAMx temperature files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> temperature_path = 'camx_temperature.bin' >>> rows,cols = 65,83 >>> temperaturefile = temperature(temperature_path,rows,cols) >>> temperaturefile.variables.keys() ['TFLAG', 'AIRTEMP', 'SURFTEMP'] >>> tflag = temperaturefile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = temperaturefile.variables['SURFTEMP'] >>> v.dimensions ('TSTEP', 'ROW', 'COL') >>> v.shape (25, 65, 83) >>> v = temperaturefile.variables['AIRTEMP'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> temperaturefile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
- data_fmt = 'f'
- id_fmt = 'fi'
- class PseudoNetCDF.camxfiles.Memmaps.uamiv(*args, **kwds)[source]
Bases:
ioapi_base
uamiv provides a PseudoNetCDF interface for CAMx uamiv files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> uamiv_path = 'camx_uamiv.bin' >>> uamivfile = uamiv(uamiv_path) >>> uamivfile.variables.keys() ['TFLAG', 'O3', 'NO', 'NO2', ...] >>> tflag = uamivfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = uamivfile.variables['O3'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> uamivfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
- Parameters:
rf (string or RecordFile) – usually a path to a CAMx formatted file, can be a FortranFileUtil RecordFile object.
mode (string) – file open mode read (‘r’), write (‘w’), append (‘a’, ‘r+’)
P_ALP (float) – see IOAPI GRIDDESC documentation
P_BET (float) – see IOAPI GRIDDESC documentation
P_GAM (float) – see IOAPI GRIDDESC documentation
XCENT (float) – see IOAPI GRIDDESC documentation
YCENT (float) – see IOAPI GRIDDESC documentation
GDTYP (float) – see IOAPI GRIDDESC documentation
endian (string) – ‘big’ or ‘little’ usually only if mistaken compile
chemparam (None or string) – used to identify gases and aerosols
- Returns:
outf – PseudoNetCDFFile populated from file
- Return type:
- class PseudoNetCDF.camxfiles.Memmaps.vertical_diffusivity(*args, **kwds)[source]
Bases:
one3d
vertical_diffusivity provides a PseudoNetCDF interface for CAMx vertical_diffusivity files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> vd_path = 'camx_vd.bin' >>> rows,cols = 65,83 >>> vdfile = vertical_diffusivity(vd_path,rows,cols) >>> vdfile.variables.keys() ['TFLAG', 'KV'] >>> tflag = vdfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = vdfile.variables['KV'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> vdfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
rows - number of rows in domain (defaults: 1) cols - number of columns in domain (defaults: size)
- units = 'm**2/s'
- var_name = 'KV'
- class PseudoNetCDF.camxfiles.Memmaps.wind(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
wind provides a PseudoNetCDF interface for CAMx wind files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> wind_path = 'camx_wind.bin' >>> rows,cols = 65,83 >>> windfile = wind(wind_path,rows,cols) >>> windfile.variables.keys() ['TFLAG', 'U', 'V'] >>> v = windfile.variables['V'] >>> tflag = windfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> windfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
PseudoNetCDF.camxfiles.Readers module
Readers
– CAMx Reader Interfaces
- class PseudoNetCDF.camxfiles.Readers.height_pressure(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
height_pressure provides a PseudoNetCDF interface for CAMx height_pressure files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> height_pressure_path = 'camx_height_pressure.bin' >>> rows,cols = 65,83 >>> hpf = height_pressure(height_pressure_path,rows,cols) >>> hpf.variables.keys() ['TFLAG', 'HGHT', 'PRES'] >>> v = hpf.variables['V'] >>> tflag = hpf.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> hpf.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- data_fmt = 'f'
- id_fmt = 'fi'
- class PseudoNetCDF.camxfiles.Readers.humidity(*args, **kwds)[source]
Bases:
one3d
humidity provides a PseudoNetCDF interface for CAMx humidity files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> humidity_path = 'camx_humidity.bin' >>> rows,cols = 65,83 >>> humidityfile = humidity(humidity_path,rows,cols) >>> humidityfile.variables.keys() ['TFLAG', 'HUM'] >>> v = humidityfile.variables['HUM'] >>> tflag = humidityfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> humidityfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- units = 'ppm'
- var_name = 'HUM'
- class PseudoNetCDF.camxfiles.Readers.ipr(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
ipr provides a PseudoNetCDF interface for CAMx ipr files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> ipr_path = 'camx_ipr.bin' >>> rows,cols = 65,83 >>> iprfile = ipr(ipr_path,rows,cols) >>> iprfile.variables.keys() ['TFLAG', 'SPAD_O3', 'DATE_O3', 'TIME_O3', 'SPC_O3', 'PAGRID_O3', 'NEST_O3', 'I_O3', 'J_O3', 'K_O3', 'INIT_O3', 'CHEM_O3', 'EMIS_O3', 'PTEMIS_O3', 'PIG_O3', 'WADV_O3', 'EADV_O3', 'SADV_O3', 'NADV_O3', 'BADV_O3', 'TADV_O3', 'DIL_O3', 'WDIF_O3', 'EDIF_O3', 'SDIF_O3', 'NDIF_O3', 'BDIF_O3', 'TDIF_O3', 'DDEP_O3', 'WDEP_O3', 'INORGACHEM_O3', 'ORGACHEM_O3', 'AQACHEM_O3', 'FCONC_O3', 'UCNV_O3', 'AVOL_O3', 'EPAD_O3'] >>> v = iprfile.variables['CHEM_O3'] >>> tflag = iprfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> iprfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- Keywords (i.e., props) for projection: P_ALP, P_BET, P_GAM, XCENT,
YCENT, XORIG, YORIG, XCELL, YCELL
- class PseudoNetCDF.camxfiles.Readers.irr(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
irr provides a PseudoNetCDF interface for CAMx irr files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> irr_path = 'camx_irr.bin' >>> irrfile = irr(irr_path) >>> irrfile.variables.keys() ['TFLAG', 'RXN_01', 'RXN_02', 'RXN_03', ...] >>> v = irrfile.variables['RXN_01'] >>> tflag = irrfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> irrfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- data_fmt = 'f'
- id_fmt = 'ifiiiii'
- class PseudoNetCDF.camxfiles.Readers.one3d(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
one3d provides a PseudoNetCDF interface for CAMx one3d files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> one3d_path = 'camx_one3d.bin' >>> rows,cols = 65,83 >>> one3dfile = one3d(one3d_path,rows,cols) >>> one3dfile.variables.keys() ['TFLAG', 'UNKNOWN'] >>> tflag = one3dfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = one3dfile.variables['UNKNOWN'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> one3dfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- data_fmt = 'f'
- id_fmt = 'fi'
- seek(date=None, time=None, k=1, chkvar=True)[source]
Move file cursor to beginning of specified record see __recordposition for a definition of variables
- units = 'UNKNOWN'
- var_name = 'UNKNOWN'
- class PseudoNetCDF.camxfiles.Readers.point_source(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
point_source provides a PseudoNetCDF interface for CAMx point_source files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> point_source_path = 'camx_point_source.bin' >>> rows,cols = 65,83 >>> point_sourcefile = point_source(point_source_path,rows,cols) >>> point_sourcefile.variables.keys() ['TFLAG', 'ETFLAG', 'TFLAG', 'XSTK', 'YSTK', 'HSTK', 'DSTK', 'TSTK', 'VSTK', 'KCELL', 'FLOW', 'PLMHT', 'NSTKS', 'NO', 'NO2', ...] >>> tflag = point_sourcefile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = point_sourcefile.variables['XSTK'] >>> v.dimensions ('NSTK',) >>> v.shape (38452,) >>> v = point_sourcefile.variables['NO2'] >>> v.dimensions ('TSTEP', 'NSTK') >>> v.shape (25, 38452) >>> point_sourcefile.dimensions {'TSTEP': 25, 'NSTK': 38452}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- cell_hdr_fmt = 'iiii'
- data_fmt = 'f'
- emiss_hdr_fmt = '10i60i3ifif'
- grid_hdr_fmt = 'ffiffffiiiiifff'
- id_fmt = 'i10i'
- id_size = 44
- nstk_hdr_fmt = 'ii'
- padded_nstk_hdr_size = 16
- padded_time_hdr_size = 24
- seek(date=None, time=None, spc=-1, offset=False)[source]
Move file cursor to the beginning of the specified record see __recordposition for parameter definitions
- spc_fmt = '10i'
- stk_hdr_fmt = 'ffffff'
- stkprops = ['XSTK', 'YSTK', 'HSTK', 'DSTK', 'TSTK', 'VSTK']
- stktimeprops = ['KCELL', 'FLOW', 'PLMHT']
- time_hdr_fmt = 'ifif'
- class PseudoNetCDF.camxfiles.Readers.temperature(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
temperature provides a PseudoNetCDF interface for CAMx temperature files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> temperature_path = 'camx_temperature.bin' >>> rows,cols = 65,83 >>> temperaturefile = temperature(temperature_path,rows,cols) >>> temperaturefile.variables.keys() ['TFLAG', 'AIRTEMP', 'SURFTEMP'] >>> tflag = temperaturefile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = temperaturefile.variables['SURFTEMP'] >>> v.dimensions ('TSTEP', 'ROW', 'COL') >>> v.shape (25, 65, 83) >>> v = temperaturefile.variables['AIRTEMP'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> temperaturefile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
- data_fmt = 'f'
- id_fmt = 'fi'
- class PseudoNetCDF.camxfiles.Readers.uamiv(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
uamiv provides a PseudoNetCDF interface for CAMx uamiv files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> uamiv_path = 'camx_uamiv.bin' >>> rows,cols = 65,83 >>> uamivfile = uamiv(uamiv_path,rows,cols) >>> uamivfile.variables.keys() ['TFLAG', 'O3', 'NO', 'NO2', ...] >>> tflag = uamivfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = uamivfile.variables['O3'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> uamivfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- cell_hdr_fmt = 'iiii'
- data_fmt = 'f'
- emiss_hdr_fmt = '10i60i3ifif'
- getArray(krange=slice(1, None, None), nspec=slice(None, None, None), nx=slice(None, None, None), ny=slice(None, None, None))[source]
Method takes slice arguments. Alternatively, takes a hashable object with 2 values (e.g., the list: [0,3]). Arguments: krange vertical slice (1 indexed) nspec species slice (0 indexed) nx column slice (0 indexed) ny row slice (0 indexed)
- grid_hdr_fmt = 'ffiffffiiiiifff'
- id_fmt = 'i10i'
- id_size = 44
- idum = 0
- ione = 1
- rdum = 0.0
- seek(date=None, time=None, spc=-1, k=0, chkvar=True)[source]
Move file cursor to the beginning of the specified record see __recordposition for parameter definitions
- spc_fmt = '10i'
- time_hdr_fmt = 'ifif'
- class PseudoNetCDF.camxfiles.Readers.vertical_diffusivity(*args, **kwds)[source]
Bases:
one3d
vertical_diffusivity provides a PseudoNetCDF interface for CAMx vertical_diffusivity files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> vd_path = 'camx_vd.bin' >>> rows,cols = 65,83 >>> vdfile = vertical_diffusivity(vd_path,rows,cols) >>> vdfile.variables.keys() ['TFLAG', 'KV'] >>> tflag = vdfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v = vdfile.variables['KV'] >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> vdfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- units = 'm**2/s'
- var_name = 'KV'
- class PseudoNetCDF.camxfiles.Readers.wind(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
wind provides a PseudoNetCDF interface for CAMx wind files. Where possible, the inteface follows IOAPI conventions (see www.baronams.com).
- ex:
>>> wind_path = 'camx_wind.bin' >>> rows,cols = 65,83 >>> windfile = wind(wind_path,rows,cols) >>> windfile.variables.keys() ['TFLAG', 'U', 'V'] >>> v = windfile.variables['V'] >>> tflag = windfile.variables['TFLAG'] >>> tflag.dimensions ('TSTEP', 'VAR', 'DATE-TIME') >>> tflag[0,0,:] array([2005185, 0]) >>> tflag[-1,0,:] array([2005185, 240000]) >>> v.dimensions ('TSTEP', 'LAY', 'ROW', 'COL') >>> v.shape (25, 28, 65, 83) >>> windfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83}
Initialization included reading the header and learning about the format.
see __readheader and __gettimestep() for more info
- data_fmt = 'f'
- seek(date=None, time=None, k=1, uv=1)[source]
Move file cursor to beginning of specified record see __recordposition for a definition of variables
- time_hdr_fmts = {8: 'fi', 12: 'fii'}
PseudoNetCDF.camxfiles.Writers module
Writers
– CAMx Write Interfaces
- PseudoNetCDF.camxfiles.Writers.ncf2height_pressure(ncffile, outpath, hght='HGHT', pres='PRES', tflag='TFLAG')[source]
- PseudoNetCDF.camxfiles.Writers.ncf2humidity(ncffile, outpath, key=None, tflag='TFLAG')
- PseudoNetCDF.camxfiles.Writers.ncf2uamiv(ncffile, outpath)[source]
ncf2uamiv converts a ncffile to a uamiv file
- Parameters:
ncffile (PseudoNetCDF-like object) –
Must be open and have all properties of a uamiv file as produced by PseudoNetCDF.camxfiles 1) IOAPI conventions 2) UAMIV specific properties: PLON PLAT IUTM CPROJ
TLAT1 TLAT2 ISTAG
outpath (string) – path to create a uamiv file output
- Returns:
outfile – File object is in write binary mode and has the uamiv file as its contents
- Return type:
file object
Examples
$ # test.uamiv must be a file in uamiv format $ pncgen -f uamiv test.uamiv test.uamiv.nc $ python -c ” ncpath = ‘test.uamiv.nc’ uamivpath = ‘test.uamiv.nc.uamiv’ from netCDF4 import Dataset from PseudoNetCDF.camxfiles.uamiv.Write import ncf2uamiv inncf = Dataset(ncpath) ncf2uamiv(inncf, uamivpath) ” # If uamivpath does not include EOD, the diff will be perfect diff test.uamiv test.uamiv.nc.uamiv
# If uamivpath includes EOD, the diff may yield difference. # The ONLY difference will be time flags for the end of a day. # Most time software agrees – there is no such thing as 2002154T24:00. # Some CAMx files, however, have a 2400 time. # PseudoNetCDF interprets this equivalently as 2002155T00:00 $ python -c “from PseudoNetCDF.camxfiles.Memmaps import uamiv import numpy as np old = uamiv(‘test.uamiv’) new = uamiv(‘test.uamiv.nc.uamiv’) for k in old.variables.keys():
check = (old.variables[k][…] == new.variables[k][…]) if not check.all():
print(k) if k == ‘ETFLAG’:
diffidx = np.where(~check)[:2]
- else:
diffidx = np.where(~check)
print(old.variables[k][diffidx]) print(new.variables[k][diffidx])
- PseudoNetCDF.camxfiles.Writers.ncf2vertical_diffusivity(ncffile, outpath, key=None, tflag='TFLAG')
PseudoNetCDF.camxfiles.aerosol_names module
- mech_aerosol_options keys:
camx6_3_chemparam_2_cf camx6_3_chemparam_6_cmu camx6_3_chemparam_2_cf_vbs camx6_3_chemparam_6_none camx6_3_chemparam_2_none camx6_3_chemparam_4_none camx6_3_chemparam_6_cf_hg camx6_3_chemparam_3_none camx6_3_chemparam_6_cf camx6_3_chemparam_6_cf_vbs camx6_3_chemparam_4_cf camx6_3_chemparam_4_none_srfmod camx6_3_chemparam_5_cf camx6_3_chemparam_5_none camx6_3_chemparam_3_cf camx6_3_chemparam_6_inert
PseudoNetCDF.camxfiles.timetuple module
timetuple
– CAMx simple time functions
- PseudoNetCDF.camxfiles.timetuple.cmp_time(lhs, rhs)[source]
Compare two time tuples. Each arg is a 2-tuple, the first element being the hour of the day * 100, the second being the date
- PseudoNetCDF.camxfiles.timetuple.timeadd(datetime1, datetime2, eod=2400.0)[source]
Adds time tuple 1 to time tuple 2. Time values greater than eod (dflt 2400) are converted to days
Big question is hr 24 day 1