PseudoNetCDF package
Subpackages
- PseudoNetCDF.aermodfiles package
- PseudoNetCDF.camxfiles package
- PseudoNetCDF.ceilometerfiles package
- PseudoNetCDF.cmaqfiles package
- PseudoNetCDF.conventions package
- PseudoNetCDF.core package
- PseudoNetCDF.derived package
- PseudoNetCDF.epafiles package
- PseudoNetCDF.geoschemfiles package
- PseudoNetCDF.icarttfiles package
- PseudoNetCDF.noaafiles package
- PseudoNetCDF.plotutil package
- PseudoNetCDF.racmfiles package
- PseudoNetCDF.raob package
- PseudoNetCDF.test package
- PseudoNetCDF.testcase package
- PseudoNetCDF.textfiles package
- PseudoNetCDF.toms package
- PseudoNetCDF.woudcfiles package
- PseudoNetCDF.wrffiles package
Submodules
PseudoNetCDF.ArrayTransforms module
utils
– Array Transforms
- PseudoNetCDF.ArrayTransforms.CenterCMAQWind(a)
PseudoNetCDF.MetaNetCDF module
MetaNetCDF
– PseudoNetCDF manipulation utilities
- class PseudoNetCDF.MetaNetCDF.MetaNetCDF(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
MetaNetCDF provides a basic interface for combining files and adding derived variables.
- ex:
>>> kvfile = kv(kv_path, 65, 83) >>> zpfile = height_pressure(zp_path, 65, 83) >>> windfile = wind(wind_path, 65, 83) >>> metfile = MetaNetCDF([kvfile, zpfile, windfile]) >>> wind_speed_calc = lambda self: (self.variables['U'][:]**2 + self.variables['V'][:]**2)**.5 >>> metfile.addMetaVariable('WS', wind_speed_calc) >>> metfile.variables['WS'].shape (25, 28, 65, 83)
- PseudoNetCDF.MetaNetCDF.WindowFromFile(WindowThis, WindowFrom)[source]
WindowFromFile creates a bounding box to window one file from the meta data of another file.
- ex:
>>> wind12k = wind(wind12k_path, 89, 89) >>> wind04k = wind(wind04k_path, 65, 83) >>> window4k_from_wind12k = WindowFromFile(wind12k, wind04k) >>> V12k = wind12k.variables['V'] >>> V04k = wind04k.variables['V'] >>> V04k_12k = window4k_from_wind12k.variables['V'] >>> V04k_12k.shape (25, 28, 89, 89) >>> V04k_12k.shape (25, 28, 65, 83) >>> V04k_12k.shape # Note the trimmed buffer cells (25, 28, 21, 27)
- class PseudoNetCDF.MetaNetCDF.add_derived(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
add_derived provides a simple interface to add derived variables to a PseudoNetCDFFile interface
create a new class with the following modifications: overwrite __childclass__ with the base class overwrite __addvars__ with a list of keys for variable names you
intend to derive
for each key name, create a key interface funciton (e.g. key = DEPTH, interface = __DEPTH__)
- PseudoNetCDF.MetaNetCDF.file_master
alias of
MetaNetCDF
- class PseudoNetCDF.MetaNetCDF.newresolution(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
newresolution converts a netcdf or PseudoNetCDF file to a new resolution based on user input. This class updates dimensions and variables, but metadata is unaffected.
- ex:
>>> kvfile = kv(kv_path, 65, 83) >>> newresfile = newresolution(kvfile, (2, 3), 4000, 1000) >>> kvfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83} >>> kvfile.variables['KV'].shape (25, 28, 65, 83) >>> newresfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 18, 'COL': 18} >>> newresfile.variables['KV'].shape (25, 28, 260, 332)
- class PseudoNetCDF.MetaNetCDF.time_avg_new_unit(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
This base class provides an interface for converting instantaneous data to time averaged. It also provides an optional unit conversion.
- ex:
>>> windfile = wind(wind_path, 65, 83) >>> windfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83} >>> windfile.variables['U'].units 'm/s' >>> windfile.variables['V'].units 'm/s' >>> class windavgnewunit(time_avg_new_unit): ... __reader__ = wind >>> windavgfile = windavgnewunit(wind_path, rows, cols, {'U': 'km/h', 'V': 'mph'}) >>> windavgfile.dimensions {'TSTEP': 24, 'LAY': 28, 'ROW': 65, 'COL': 83} >>> windfile.variables['U'].units 'km/h' >>> windfile.variables['V'].units 'mph'
- class PseudoNetCDF.MetaNetCDF.window(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
Window takes a netcdf or PseudoNetCDF file and creates a windowed version.
- ex:
>>> windfile = wind(wind_path, 65, 83) >>> subsetfile = window(windfile, tslice = slice(8, 18), kslice = slice(0, 1), jslice = slice(19, 37), islice = slice(19, 37)) >>> windfile.dimensions {'TSTEP': 25, 'LAY': 28, 'ROW': 65, 'COL': 83} >>> windfile.variables['U'].shape (25, 28, 65, 83) >>> subsetfile.dimensions {'TSTEP': 10, 'LAY': 1, 'ROW': 18, 'COL': 18} >>> windfile.variables['U'].shape (10, 1, 18, 18)
PseudoNetCDF.coordutil module
- PseudoNetCDF.coordutil.basemap_from_file(ifile, withgrid=False, **kwds)[source]
Typically, the user will need to provide some options
- PseudoNetCDF.coordutil.basemap_options_from_proj4(proj4, **kwds)[source]
proj4 - string with projection optoins according to the proj4 system kwds - add keywords to control basemap specific options
resolution = ‘i’ or ‘c’ or ‘h’ controls dpi of boundaries llcrnrlon=None, llcrnrlat=None, urcrnrlon=None, urcrnrlat=None, llcrnrx=None, llcrnry=None, urcrnrx=None, urcrnry=None, width=None, height=None,
- PseudoNetCDF.coordutil.getcdo(ifile)[source]
- ifile - file containing latitude, longitude and optionally latitude_bounds
and longitude_bounds
- PseudoNetCDF.coordutil.getinterpweights(xs, nxs, kind='linear', fill_value='extrapolate', extrapolate=False)[source]
Get weights for interpolation by matrix multiplication
- Parameters:
xs (old input coordinates)
nxs (new output coordinates)
extrapolate (allow extrapolation beyond bounds, default False)
fill_value (set fill value (e.g, nan) to prevent extrapolation or edge) – continuation
- Returns:
weights
- Return type:
numpy array shape = (old, new)
Notes
When extrapolate is false, the edge values are used for points beyond the inputs. Particularly useful when interpolating many values
Example
xs = np.arange(10, 100, 10) ys = xs nxs = np.arange(0, 100, 5) weights = getinterpweights(a, b) nys = (weights * xs[:, None]).sum(0)
- PseudoNetCDF.coordutil.getlonlatcoordstr(ifile, makemesh=None)[source]
ifile - file with latitude and longitude variables makemesh - use numpy.meshgrid to construct gridded values (default None)
- None - check if longitude and latitude are coordinate variables
or have different dimensions if so set to True
True - use meshgrid False - assume latitude and longitude are on same g
- PseudoNetCDF.coordutil.getproj4(ifile, withgrid=False)[source]
- Parameters:
file (ifile - PseudoNetCDF)
parameters (withgrid - True to include gridding)
- Returns:
proj4str - string with proj4 parameters
PseudoNetCDF.net_balance module
- class PseudoNetCDF.net_balance.TestReaders(methodName='runTest')[source]
Bases:
TestCase
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- class PseudoNetCDF.net_balance.ctb_reader(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
- class PseudoNetCDF.net_balance.mrgaloft(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
- ipr_re = re.compile('"\\w+\\s*"\\s*(-?\\d+.\\d+[E,e][+,-]\\d+\\s+)+', re.IGNORECASE)
- irr_re = re.compile('\\{\\s*(\\d+)\\}\\s+(-?\\d+.\\d+[E,e][+,-]\\d+)', re.IGNORECASE)
- classmethod isMine(*args, **kwds)[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.
- re = <module 're' from '/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/re/__init__.py'>
- sci_not = '-?\\d+.\\d+[E,e][+,-]\\d+'
- split_on_blanks_re = re.compile('[ ]+')
- time_re = re.compile('Time =([0-9][0-9]0000)', re.IGNORECASE)
- class PseudoNetCDF.net_balance.net_reader(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
PseudoNetCDF.netcdf module
netcdf
– netcdf import point
- PseudoNetCDF.netcdf.NetCDFFile
alias of
Dataset
- PseudoNetCDF.netcdf.NetCDFVariable
alias of
Variable
PseudoNetCDF.pncdump module
dumper
– PseudoNetCDF dump module
- PseudoNetCDF.pncdump.pncdump(f, name='unknown', header=False, variables=[], line_length=80, full_indices=None, float_precision=8, double_precision=16, isgroup=False, timestring=False, outfile=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]
pncdump is designed to implement basic functionality of the NetCDF ncdump binary.
f - a PseudoNetCDFFile object name - string name for the file
(equivalent to ncdump -n name)
- header - boolean value for display of header only
(equivalent to ncdump -h)
- variables - iterable of variable names for subsetting
data display (equivalent to ncddump -v var[,…]
- pncdump(
- vertical_diffusivity(
‘camx_kv.20000825.hgbpa_04km.TCEQuh1_eta.v43.tke’,rows=65,cols=83))
PseudoNetCDF.pnceval module
- PseudoNetCDF.pnceval.PSUTMNPB(obs, mod, axis=None)[source]
Paired Space/Unpaired Time Mean Normalized Peak Bias (%)
- PseudoNetCDF.pnceval.PSUTMNPE(obs, mod, axis=None)[source]
Paired Space/Unpaired Time Mean Normalized Peak Error (%)
- PseudoNetCDF.pnceval.PSUTMdnNPB(obs, mod, axis=None)[source]
Paired Space/Unpaired Time Median Normalized Peak Bias (%)
- PseudoNetCDF.pnceval.PSUTMdnNPE(obs, mod, axis=None)[source]
Paired Space/Unpaired Time Median Normalized Peak Error (%)
- PseudoNetCDF.pnceval.PSUTNMPB(obs, mod, axis=None)[source]
Paired Space/Unpaired Time Normalized Mean Peak Bias (%)
- PseudoNetCDF.pnceval.PSUTNMPE(obs, mod, axis=None)[source]
Paired Space/Unpaired Time Normalized Mean Peak Error (%)
- PseudoNetCDF.pnceval.PSUTNMdnPB(obs, mod, axis=None)[source]
Paired Space/Unpaired Time Normalized Median Peak Bias (%)
- PseudoNetCDF.pnceval.PSUTNMdnPE(obs, mod, axis=None)[source]
Paired Space/Unpaired Time Normalized Median Peak Error (%)
- PseudoNetCDF.pnceval.RMSEs(obs, mod, axis=None)[source]
Root Mean Squared Error systematic (obs, mod_hat)
- PseudoNetCDF.pnceval.RMSEu(obs, mod, axis=None)[source]
Root Mean Squared Error unsystematic (mod_hat, mod)
- PseudoNetCDF.pnceval.RMdn(obs, mod, axis=None)[source]
Median Ratio Observations/Predictions (none)
- PseudoNetCDF.pnceval.USUTPB(obs, mod, axis=None)[source]
Unpaired Space/Unpaired Time Peak Bias (%)
- PseudoNetCDF.pnceval.USUTPE(obs, mod, axis=None)[source]
Unpaired Space/Unpaired Time Peak Error (%)
- PseudoNetCDF.pnceval.WDME(obs, mod, axis=None)[source]
Wind Direction Mean Gross Error (model and obs unit)
- PseudoNetCDF.pnceval.WDMdnE(obs, mod, axis=None)[source]
Wind Direction Median Gross Error (model and obs unit)
PseudoNetCDF.pncgen module
- class PseudoNetCDF.pncgen.Pseudo2NetCDF(datafirst=False, verbose=1)[source]
Bases:
object
Pseudo2NetCDF is a base class for conversion. Properties and methods can be overwritten to facilitate conversion of special PseudoNetCDFFiles.
Specifically: ignore_global_properties and ignore_variable_properties lists can be overwritten so that class properties and methods are not written to a netCDF file
- create_variable_kwds = {}
- ignore_global_properties = ['variables', 'dimensions']
- ignore_global_re = re.compile('^_\\w*(__\\w*)?')
- ignore_variable_properties = ['typecode', 'dimensions']
- ignore_variable_re = re.compile('^_\\w*(__\\w*)?')
- re = <module 're' from '/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/re/__init__.py'>
- special_properties = ['_fillvalue', '_FillValue']
- unlimited_dimensions = []
- PseudoNetCDF.pncgen.pncgen(ifile, outpath, inmode='r', outmode='w', format='NETCDF4_CLASSIC', verbose=1, complevel=0, writer_kw=None)[source]
ifile - input file to write out outpath - path to outputfile inmode - how is file read (if ifile is a path) outmode - w, w+s format - any PseudoNetCDF or Dataset option
PseudoNetCDF.pncload module
dumper
– PseudoNetCDF dump module
- class PseudoNetCDF.pncload.PNCConsole(locals=None, filename='<console>', histfile=None)[source]
Bases:
InteractiveConsole
The PNCConsole is designed to create a fast Integrated Development Environment for scientific analysis.
locals - dictionary of local variables filename - filename for error printouts histfile - path for history
PseudoNetCDF.pncparse module
- PseudoNetCDF.pncparse.PNC(*args, **kwds)[source]
- Parameters:
PseudoNetCDF (args - Command Line arguments/options for) – for full list of potential args PNC(’–help’)
- (ifiles)
(default (actions -) –
False) False: only open files do not make outputs True: enable dump,gen,map,etc output actions
for action options see subparsers help e.g., PNC(‘dump’, ‘–help’, actions = True)
- Returns:
- out - Namespace object with parsed arguments
including a list of processed files (out.ifiles)
Example
# Single File out = PNC(’–format=netcdf’, inpath) infile = out.ifiles[0] O3 = infile.variables[‘O3’]
# Multiple Files out = PNC(’–format=netcdf’, inpath1, inpath2) infile1, infile2 = out.ifiles O3_1 = infile1.variables[‘O3’] O3_2 = infile2.variables[‘O3’]
# With Actions out = PNC(‘dump’, ‘–variables=O3’, ‘–format=netcdf’, inpath)
netcdf icartt/dc3-mrg60-dc8_merge_20120518_R7_thru20120622.nc { dimensions:
POINTS = 6817 ;
- variables:
- double O3(TSTEP, LAY, ROW, COL);
O3_ESRL:units = “ppbV” ; O3_ESRL:standard_name = “Ozone” ; O3_ESRL:missing_value = -999999 ;
…
- PseudoNetCDF.pncparse.getparser(has_ofile, plot_options=False, map_options=False, interactive=False, actions=False)[source]
getparser produces a parser for PseudoNetCDF
- Parameters:
has_ofile (boolean) – Requires the outpath option and processes existence check
plot_options (boolean, optional) – Adds options for plotting including matplotlibrc, spatial overlays, and normalization options, default is False
interactive (boolean, optional) – Adds for interactive option, default is False
- Returns:
parser
- Return type:
ArgumentParser with options that are processable with pncparse
- PseudoNetCDF.pncparse.pnc(*args, **kwds)[source]
Arguments - see PNC :returns: file(s) - single file or, if more than 1 file is returned a list of files
- PseudoNetCDF.pncparse.pncparse(has_ofile=False, plot_options=False, map_options=False, interactive=False, args=None, parser=None, ifiles=[])[source]
- Parameters:
has_ofile (boolean, optional) – Requires the outpath option and processes existence check default is False
plot_options (boolean, optional) – Processes matplotlib options before loading matplotlib (preprocessing important for backend), default is False.
interactive (boolean, optional) – Only relevant if parser is not provided (see getparser), default is False.
args (list or string, optional) – args are usually taken from the command-line, but can be provided in a function call, default is None.
parser (AgumentParser object, optional) –
- pncparser parser, default getparser(has_ofile,
plot_options = plot_options, interactive = interactive)
- Returns:
(ifiles, args)
ifiles (list of PseudoNetCDFFiles)
args (args as parsed)
PseudoNetCDF.pncview module
PseudoNetCDF.pncwarn module
PseudoNetCDF.register module
PseudoNetCDF.sci_var module
Scientific data has dimensions that have physical meaning and values only have meaning in the context of their units. This module implements numpy arrays that are aware of their dimensions trying to vaguely adhere to the Common Data Model from Unitdata at UCAR.
Each variable has as a property its dimensions names (dimensions). Further, each dimension name exists as a property and contains a one dimensional array of values associated with that dimension.
For the purposes of ease of use, the standard properties of netCDF files are attached and the arrays implement the Scientific.IO.NetCDF.NetCDFVariable interfaces.
- class PseudoNetCDF.sci_var.Pseudo2NetCDF(datafirst=False, verbose=1)[source]
Bases:
object
Pseudo2NetCDF is a base class for conversion. Properties and methods can be overwritten to facilitate conversion of special PseudoNetCDFFiles.
Specifically: ignore_global_properties and ignore_variable_properties lists can be overwritten so that class properties and methods are not written to a netCDF file
- create_variable_kwds = {}
- ignore_global_properties = ['variables', 'dimensions']
- ignore_global_re = re.compile('^_\\w*(__\\w*)?')
- ignore_variable_properties = ['typecode', 'dimensions']
- ignore_variable_re = re.compile('^_\\w*(__\\w*)?')
- re = <module 're' from '/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/re/__init__.py'>
- special_properties = ['_fillvalue', '_FillValue']
- unlimited_dimensions = []
- PseudoNetCDF.sci_var.PseudoIOAPIVariable(parent, name, typecode, dimensions, **kwds)[source]
Creates a variable using the dimensions as defined in the parent object
- Parameters:
parent (PseudoNetCDFFile) – an object with a dimensions variable
name (string) – name for variable
typecode (string or numpy.dtype) – numpy style typecode
dimensions (tuple of strings) – dimension names to be used from parent
**kwds (dictionary) – units: default = none long_name: default = name var_desc: default = name
- class PseudoNetCDF.sci_var.PseudoNetCDFDimension(group, name, size)[source]
Bases:
object
Dimension object responds like that of netcdf4-python
- class PseudoNetCDF.sci_var.PseudoNetCDFFile(*args, **kwds)[source]
Bases:
pnc
,object
PseudoNetCDFFile provides an interface and standard set of methods that a file should present to act like a netCDF file using the Scientific.IO.NetCDF.NetCDFFile interface.
- apply(verbose=0, **dimfuncs)
Similar to numpy.apply_along_axis, but for damed dimensions and processes dimensions as well as variables
- Parameters:
dimfuncs (dictionary) – key value pairs where the key is a dimensions and the value is a 1D function (func1d) or a dictionary. If the value is a dictionary it must include func1d as a function and any keyword arguments as additional options
verbose (integer) – 0 silent, 1 show variable, 2 show dimensions and variables
- Returns:
outf – instance with variables and dimensions after processing
- Return type:
- applyAlongDimensions(verbose=0, **dimfuncs)[source]
Similar to numpy.apply_along_axis, but for damed dimensions and processes dimensions as well as variables
- Parameters:
dimfuncs (dictionary) – key value pairs where the key is a dimensions and the value is a 1D function (func1d) or a dictionary. If the value is a dictionary it must include func1d as a function and any keyword arguments as additional options
verbose (integer) – 0 silent, 1 show variable, 2 show dimensions and variables
- Returns:
outf – instance with variables and dimensions after processing
- Return type:
- copy(props=True, dimensions=True, variables=True, data=True)[source]
Function for making copies of the same type
- Parameters:
props (boolean) – include properties (default: True)
dimensions (boolean) – include dimensions (default: True)
variables (boolean) – include variable structures (default: True)
data (boolean) – include variable data (default: True)
- Returns:
outf
- Return type:
PseudoNetCDFFile instance
- copyVariable(var, key=None, dtype=None, dimensions=None, fill_value=None, withdata=True)[source]
Copy var into self as vark
- Parameters:
var (PseudoNetCDFVariable) – netCDF4.Variable-like object (must have ncattrs and setncatts)
key (string) – key for variable in self (can be omitted if var has name, standard_name, or long_name)
dtype (string or numpy.dtype) – change the data type to dtype
dimensions (iterable of strings) – change the dimensions to dimensions
fill_value (integer or flaot) – change the fill_value to this values
withdata (boolean) – default True, copies data
- Returns:
myvar – copy of var in this file
- Return type:
PseuodNetCDFVairable
- createDimension(name, length)[source]
Create a dimension
- Parameters:
name (string) – name for dimension
length (integer) – maximum length of dimension
- Returns:
dim – new dimension
- Return type:
PseudoNetCDFDimensions
- createVariable(name, type, dimensions, fill_value=None, **properties)[source]
Create a variable
- Parameters:
name (string) – name for new variable
type (string or numpy dtype) – code (e.g., ‘f’, ‘i’, ‘d’)
dimensions (tuple of strigns) – dimension keys that can be found in objects’ dimensions dictionary
- Returns:
var
- Return type:
new variable
- date2num(time, timekey='time')[source]
- Parameters:
time (array-like) – array of datetime.datetime objects
timekey (str) – time variable key which requires units and should have calendar. If calendar is missing, standard is the default. default ‘time’
- Returns:
num – time in relative time as defined by units of time variable (i.e., timekey) which defaults to ‘time’
- Return type:
array-like
- eval(expr, inplace=False, copyall=False)[source]
Evaluate expr and return a PseudoNetCDFFile object with resutl
- Parameters:
expr (string) – expression to evaluate
inplace (boolean) – create the new variable in this netcdf file (default False)
copyall (boolean) – if not inplace, should all variables be copied to new file
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- flush()
Does nothing. Implemented for continuity with Scientific.IO.NetCDF
- classmethod from_arrays(dims=None, attrs=None, nameattr='standard_name', fileattrs=None, **inarrkw)[source]
Create a new ioapi file from arrays.
- Parameters:
dims (iterable) – Explicit dimensions. If not provided, they will be created as phony_dim_{i} where i for i in range(ndim). For example, an array of shape (2, 3) would have dimensions (phony_dim_0, phony_dim_1)
attrs (mappable) – Attributes for all variables (e.g., units). long_name and var_desc will be set based on key if not provided.
nameattr (str) – Key for name as an attribute
fileattrs (mappable) – Attributes for the file to be created.
inarrkw (mappable) – Keys are the names of variables to be created and the value should be an array of values.
- Returns:
outf
- Return type:
PseudoNetcdf-like file
- classmethod from_ncf(infile)[source]
- Parameters:
infile (PseudoNetCDF-like file)
- Returns:
outf
- Return type:
PseudoNetcdf-like file
- classmethod from_ncvs(*invars, **invarkw)[source]
- Parameters:
invars (list) – NetCDF-like variable must have standard_name, long_name or name
invarkw (kwds) – NetCDF-like variables
- Returns:
outf
- Return type:
PseudoNetcdf-like file
- getMap(maptype='basemap_auto', **kwds)[source]
Description
- Parameters:
maptype (string) –
choices ‘basemap’, ‘basemap_auto’, ‘cartopy’ (not yet) basemap : attempts to open a basemap with only supplied kwds basemap_auto : automatically adds llcrnrlon,llcrnrlat,u
rcrnrlon,urcrnrlat based on longitude_bounds
**kwds (keywords) – for basemap or cartopy
- Returns:
map
- Return type:
basemap or cartopy axis
- getTimes(datetype='datetime', bounds=False)[source]
Get an array of datetime objects
- Parameters:
datetype (string or numpy.dtype) – ‘datetime’ or datetime64 dtype
bounds (boolean) – get time boundaries
- Returns:
out – datetime objects or array of numpy’s datetype type
- Return type:
array
Notes
self must have a time or TFLAG variable
- get_dest()[source]
- Returns:
path – path where a new file is created on some action
- Return type:
str
Notes
If None, a file is created in memory. Else, a netcdf file is created on disk.
- get_varopt()[source]
Get options
- Parameters:
None
- Returns:
options
- Return type:
dictionary of options
- getncatts()[source]
Return all ncattrs keys and values as a dictionary
- Returns:
attdict – key/value pairs of properties
- Return type:
dictionary
- getproj(withgrid=False, projformat='pyproj')[source]
Description
- Parameters:
withgrid (boolean) – use grid units instead of meters
projformat (string) – ‘pyproj’ (default), ‘proj4’ or ‘wkt’ allows function to return a pyproj projection object or a string in the format of proj4 or WKT
- Returns:
proj – (wkt, proj4) or pyprojProj (pyproj)
- Return type:
string pyproj.Proj
- ij2ll(i, j)[source]
Converts i, j to lon, lat (no false easting/northing) using cell centers assuming 0-based i/j
- Parameters:
i (scalar/iterable) – indicies (0-based) for the west-east dimension
j (scalar/iterable) – indicies (0-based) for the south-north dimension
- Returns:
lon, lat – longitudes and latitudes in decimal degrees
- Return type:
scalars or iterables
- insertDimension(newonly=True, multionly=False, before=None, after=None, inplace=False, **newdims)[source]
Insert dimensions with keys and lengths from newdims
- Parameters:
**newdims (dictionary) – where key is the new dimension and value is the length
newonly (boolean) – Only add dimension to variables that do not already have it, default True
multionly (boolean) – Only add dimension if there are already more than one (good for ignoring coordinate dimensions)
before (string) – if variable has this dimension, insert the new dimension before it. Otherwise, add to the beginning. (before takes precedence)
after (string) – if variable has this dimension, insert the new dimension after it. Otherwise, add to the beginning.
inplace (boolean) – create the new variable in this netcdf file (default False)
- Returns:
outf – instance will new dimension in dimensions and variables
- Return type:
Notes
Adding a non unity dimension will cause the data to be repeated along the new axis.
If order of addition matters, use multiple calls. newdimsuse will be a non-ordered dictionary
- interpDimension(dimkey, newdimvals, coordkey=None, **interpkwds)[source]
- Parameters:
dimkey (string) – the new dimension for interpolation
newdimvals (iterable) – the new values to interpolate to
coordkey (string) – the variable to use as the old coordinate values
interptype (string) –
- ‘linear’ or ‘conserve’. linear uses a linear interpolation
conserve uses a mass conserving interpolation
extrapolate (boolean) – allow extrapolation beyond bounds with linear, default False
fill_value (numeric value) – set fill value (e.g, nan) to prevent extrapolation or edge continuation
- Returns:
outf – instance with all variables interpolated
- Return type:
Notes
When extrapolate is false, the edge values are used for points beyond the inputs.
- classmethod isMine(*args, **kwds)[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.
- ll2ij(lon, lat, bounds='ignore', clean='none')[source]
Converts lon/lat to 0-based indicies (0,M), (0,N)
- Parameters:
lon (scalar or iterable) – longitudes in decimal degrees
lat (scalar or iterable) – latitudes in decimal degrees
bounds (string) – ignore, error, warn if i,j are out of domain
clean (string) – none - return values regardless of bounds; mask - mask values out of bounds; clip - return min(max(0, v), nx - 1)
- Returns:
i, j
- Return type:
indices (0-based) for variables
- ll2xy(lon, lat)[source]
Converts lon/lat to x distances (no false easting/northing)
- Parameters:
lon (scalar or iterable) – longitudes in decimal degrees
lat (scalar or iterable) – latitudes in decimal degrees
- Returns:
x, y – coordinates in map projection (meters or radians)
- Return type:
tuple of arrays
- mask(where=None, less=None, less_equal=None, greater=None, greater_equal=None, values=None, equal=None, invalid=False, mask=None, dims=None, fill_value=-999, coords=False, verbose=0)[source]
Apply mask to all variables of same shape or just where dimensions match.
- Parameters:
where (array-like) – boolean array to use as a mask see numpy.ma.masked_where
greater (scalar) – mask when values are greater than this value see numpy.ma.masked_greater
less (scalar) – mask when values are less than this value see numpy.ma.masked_less
greater_equal (scalar) – mask when values are greater than or equal to this value see numpy.ma.masked_greater
less_equal (scalar) – mask when values are less than or equal to this value see numpy.ma.masked_less
values (scalar) – mask when values are equal to this value within standard floating point see numpy.ma.masked_values
equal (scalar) – mask when values are exactly this value (i.e., integers) see numpy.ma.masked_equal
invalid (boolean) – mask when values are invalid, see numpy.ma.masked_invalid
mask (array-like) – alias for where
dims (iterable of strings) – only apply “mask” or “where” to variables with these dimensions no effet on other masks
fill_value (scalar) – value to use as the fill_value for new arrays
coords (boolean) – if True, apply masks to coordinate variables. Default, False
verbose (int) – level of verbosity for function, mostly for debugging
- Returns:
outf – instance with masked variables
- Return type:
See also
numpy.ma
all masks are passing throught to numpy.ma.masked_…
Notes
mask options are not mutually exclusive. the order is where, greater, greater_equal, less, less_equal, values, equal, invalid
- plot(varkey, plottype=None, ax_kw=None, plot_kw=None, cbar_kw=None, map_kw=None, dimreduction='mean')[source]
- Parameters:
varkey (string) – the variable to plot
plottype (string) – any dimension name pair delimited by a hyphen (e.g., longitude-latitude, latitude-pressure, longitude-pressure, vertical-profile, time-longitude, time-latitude, time-pressure) defaults to the last two dimensions.
ax_kw (dictionary) – keywords for the axes to be created
plot_kw (dictionary) – keywords for the plot (plot, scatter, or pcolormesh) to be created
cbar_kw (dictionary or bool or None) – keywords for the colorbar; if True or None, use defaults. If False, do not create a colorbar
map_kw (dictionary or bool or None) – keywords for the getMap routine, which is only used with map capable dimensions (ie, plottype=’longitude-latitude’) If True or None, use default configuration dict(countries=True, coastlines=True, states=False, counties=False). If False, do not draw a map.
dimreduction (string or function) – dimensions not being used in the plot are removed using applyAlongDimensions(dimkey=dimreduction) where each dimenions
- Returns:
ax – Axes that was drawn on
- Return type:
matplotlib.axes.Axes
- removeSingleton(dimkey=None)[source]
Return a netcdflike object with dimensions sliced
- Parameters:
dimkey (string) – key of dimension to be evaluated for removal; if None, evaluate all. only singleton dimensions will be removed.
- Returns:
outf – instance with dimensions removed
- Return type:
- renameDimension(oldkey, newkey, inplace=False)[source]
Rename dimension (oldkey) in dimensions and in all variables
- Parameters:
oldkey (string) – dimension to be renamed
newkey (string) – new dame for dimension
inplace (boolean) – create the new variable in this netcdf file (default False)
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- renameDimensions(inplace=False, **newkeys)[source]
Rename dimension (oldkey) in dimensions and in all variables
- Parameters:
**newkeys (dictionary) – where key is the oldkey and value is the newkey
inplace (boolean) – create the new variable in this netcdf file (default False)
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- renameVariable(oldkey, newkey, inplace=False, copyall=True)[source]
Rename variable (oldkey)
- Parameters:
oldkey (string) – variable to be renamed
newkey (string) – new dame for variable
inplace (boolean) – create the new variable in this netcdf file (default False)
copyall (boolean) – if not inplace, should all variables be copied to new file
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- renameVariables(inplace=False, copyall=True, **newkeys)[source]
Rename variables for each oldkey: newkey dictionary item
- Parameters:
**newkeys (dictionary) – where key is the oldkey and value is the newkey
inplace (boolean) – create the new variable in this netcdf file (default False)
copyall (boolean) – if not inplace, should all variables be copied to new file
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- reorderDimensions(oldorder, neworder, inplace=False)[source]
Evaluate expr and return a PseudoNetCDFFile object with resutl
- Parameters:
oldorder (iterable of strings) – dimension names in existing order
neworder (iterable of strings) – dimension names in new order
- Returns:
outf – instance with dimensions reordered in variables
- Return type:
- save(*args, **kwds)[source]
Provides access to pncwrite for self
- Parameters:
pncwrite (see Help)
- Return type:
see Help pncwrite
- setCoords(keys, missing='ignore')[source]
Set a variable as a coordinate variable
- Parameters:
keys (iterable of strings) – keys for coord variables
missing (string) – action if missing ‘ignore’, ‘skip’ or ‘error’ ignore - add in case used later skip - do not add error - raise an error
- Return type:
None
Notes
Coordinate variables are excluded from math
- set_dest(path, **options)[source]
Sets the path where a new file is created on some action
- Parameters:
path (str) – path for new file
**options (keywords for constructor) – options for new file creation
- Return type:
None
- set_varopt(**options)[source]
Set options to be used when creating any Variable
- Parameters:
**options (options for createVariable) – optional keywords to be supplied when creating new variables in destination file
- Return type:
None
- setncatts(attdict)[source]
Set ncattrs from attdict keys and values
- Parameters:
attdict (dictionary) – key/value pairs of properties
- Return type:
None
- slice(newdims=('POINTS',), verbose=0, **dimslices)
Return a netcdflike object with dimensions sliced
- Parameters:
newdims (iterable of strings) – names for new dimensions. When more than one iterable applies to a variable slice, fancy indexing removes both dimensions and creates a new one of the iterable lengths
**dimslices (dictionary) – key value pairs where the key is a dimension and the value is a valid slice object (slices, ints or iterables) if iterables are provided, all iterables must be the same size and shape. If the arrays are not 1D, newdims must have ndim names
- Returns:
outf – instance with variables and dimensions sliced
- Return type:
- sliceDimensions(newdims=('POINTS',), verbose=0, **dimslices)[source]
Return a netcdflike object with dimensions sliced
- Parameters:
newdims (iterable of strings) – names for new dimensions. When more than one iterable applies to a variable slice, fancy indexing removes both dimensions and creates a new one of the iterable lengths
**dimslices (dictionary) – key value pairs where the key is a dimension and the value is a valid slice object (slices, ints or iterables) if iterables are provided, all iterables must be the same size and shape. If the arrays are not 1D, newdims must have ndim names
- Returns:
outf – instance with variables and dimensions sliced
- Return type:
- stack(other, stackdim)[source]
Concatenates all variables on stackdim
- Parameters:
other (instance or list of PseudoNetCDFFiles) – files to add to this file along stackdim
stackdim (str) – dimension name
- Returns:
outf – instance with stacked variables and dimension equal to new length
- Return type:
- subset(varkeys, inplace=False, exclude=False, keepcoords=True)
Return a PseudoNetCDFFile with only varkeys
- Parameters:
varkeys (iterable of strings) – keys to keep
inplace (boolean) – if true (default false), then remove other variable from this file
exclude (boolean) – if True (default False), then remove just these variables
keepcoords (boolean) – if True (default True), keep coordinate variables
- Returns:
outf – instance with variables
- Return type:
- subsetVariables(varkeys, inplace=False, exclude=False, keepcoords=True)[source]
Return a PseudoNetCDFFile with only varkeys
- Parameters:
varkeys (iterable of strings) – keys to keep
inplace (boolean) – if true (default false), then remove other variable from this file
exclude (boolean) – if True (default False), then remove just these variables
keepcoords (boolean) – if True (default True), keep coordinate variables
- Returns:
outf – instance with variables
- Return type:
- sync()
Does nothing. Implemented for continuity with Scientific.IO.NetCDF
- time2idx(time, dim='time', timekey=None, **kwds)[source]
Convert datetime objects to dimension indices
- Parameters:
time (array-like) – array of datetime.datetime objects
dim (str) – dimension name for val2idx
timekey (str) – time variable key. None defaults to dim
kwds (mappable) – see val2idx
- Returns:
idx – time index (0-based)
- Return type:
array-like
- time2t(time, ttype='nearest', index=True)[source]
- Parameters:
time (array of datetime.datetime objects)
interp ('nearest', 'bounds', 'bounds_close')
index (return index)
- Returns:
t
- Return type:
fractional time or if index, integers for indexing
- val2idx(dim, val, method='nearest', bounds='warn', left=None, right=None, clean='mask')[source]
Convert coordinate values to indices
- Parameters:
dim (str) – name of dimensions, which must have a coordinate variable
val (array-like) – value in coordinate space
method (str) –
- nearest, bounds, exact - each calculates the index differently
nearest : uses interp with coord values and rounds
bounds : uses interp between bounding values and truncates
- exactreturns indices for exact coord values with other
indices masked (clean keyword has no effect)
bounds (str) – ignore, error, warn if i,j are out of domain
left (scalar) – see np.interp
right (scalar) – see np.interp
clean ({'none', 'mask'}) –
none - return values regardless of bounds; mask - mask invalid values (use with left/right=np.nan);
has no affect with method exact
- Returns:
i – indices (0-based) for variables
- Return type:
array-like
- xy2ll(x, y)[source]
Converts x, y to lon, lat (no false easting/northing)
- Parameters:
x (scalar or iterable) – projected west-east coordinates
y (scalar or iterable) – projected south-north coordinates
- Returns:
lon, lat – longitudes and latitudes in decimal degrees
- Return type:
scalars or iterables
- class PseudoNetCDF.sci_var.PseudoNetCDFMaskedVariable(parent, name, typecode='f', dimensions=(), **kwds)[source]
Bases:
PseudoNetCDFVariable
,MaskedArray
Creates a variable using the dimensions as defined in the parent object
- parent: PseudoNetCDFFile
an object with a dimensions variable
- name: string
name for variable
- typecode: string or numpy.dtype
numpy style typecode
- dimensions: tuple of strings
dimension names to be used from parent
- **kwds: dictionary
keywords to be added as properties to the variable. The keyword ‘values’ is a special case that will be used as the starting values of the array
- class PseudoNetCDF.sci_var.PseudoNetCDFVariable(parent, name, typecode, dimensions, **kwds)[source]
Bases:
ndarray
PseudoNetCDFVariable presents the Scientific.IO.NetCDF.NetCDFVariable interface, but unlike that type, provides a contructor for variables that could be used without adding it to the parent file
Creates a variable using the dimensions as defined in the parent object
- Parameters:
parent (PseudoNetCDFFile) – an object with a dimensions variable
name (string) – name for variable
typecode (string or numpy.dtype) – numpy style typecode
dimensions (tuple of strings) – dimension names to be used from parent
**kwds (keywords) – Dictionary of keywords to be added as properties to the variable. The keyword ‘values’ is a special case that will be used as the starting values of the array
- ncattrs()[source]
- Returns:
ncattrs – attributes that have been user defined
- Return type:
tuple of strings
- PseudoNetCDF.sci_var.PseudoNetCDFVariableConvertUnit(var, outunit)[source]
Convert the unit of var and update the associated IOAPI metadata
- class PseudoNetCDF.sci_var.PseudoNetCDFVariables(func, keys)[source]
Bases:
OrderedDefaultDict
PseudoNetCDFVariables provides a special implementation of the default dictionary that provides efficient access to variables of a PseudoNetCDFFile. PseudoNetCDFFiles may have large variables that should only be loaded if accessed. PseudoNetCDFVariables allows a user to specify a function that can create variables on demand.
- func: function
must take a key and provides a PseudoNetCDFVariable
- keys: iterable of strings
keys that the dictionary should act as if it has
- class PseudoNetCDF.sci_var.WrapPNC(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
- PseudoNetCDF.sci_var.extract(f, lonlat, unique=False, gridded=None, method='nn', passthrough=True)
- PseudoNetCDF.sci_var.extract_from_file(f, lonlatfs, unique=False, gridded=None, method='nn', passthrough=True)[source]
- PseudoNetCDF.sci_var.get_dimension_length(pfile, key)[source]
Return the length of a dimension (key) from pfile
- PseudoNetCDF.sci_var.get_ncf_object(path_or_object, mode, format='NETCDF4_CLASSIC')[source]
Return an open NetCDF or PseudoNetCDF from an object or path
- PseudoNetCDF.sci_var.interpvars(f, weights, dimension, loginterp=[])[source]
f - PseudoNetCDFFile weights - weights for new dimensions from old dimension dim(new, old) dimension - which dimensions will be reduced loginterp - iterable of keys to interp on log scale
- PseudoNetCDF.sci_var.manglenames(f, translator={' ': '_', '$': 'S', '(': '', ')': '', '+': '_add_', '-': '_'})[source]
- PseudoNetCDF.sci_var.mask_vals(f, maskdef, metakeys=['time', 'layer', 'level', 'latitude', 'longitude', 'time_bounds', 'latitude_bounds', 'longitude_bounds', 'ROW', 'COL', 'LAY', 'TFLAG', 'ETFLAG'])[source]
- PseudoNetCDF.sci_var.pncbo(op, ifile1, ifile2, coordkeys=None, verbose=0)[source]
Perform binary operation (op) on all variables in ifile1 and ifile2. The returned file (rfile) contains the result
rfile = ifile1 <op> ifile2
op can be any valid operator (e.g., +, -, /, , *, &, ||)
- PseudoNetCDF.sci_var.pncexpr(expr, ifile, verbose=0)[source]
Evaluate an arbitrary expression in the context of ifile.variables and add the result to the file with appropriate units.
- PseudoNetCDF.sci_var.reduce_dim(f, reducedef, fuzzydim=True, metakeys=['time', 'layer', 'level', 'latitude', 'longitude', 'time_bounds', 'latitude_bounds', 'longitude_bounds', 'ROW', 'COL', 'LAY', 'TFLAG', 'ETFLAG'])[source]
variable dimensions can be reduced using
reduce_dim(file ‘dim,function,weight’)
e.g., reduce_dim(layer,mean,weight).
Weighting is not fully functional.
PseudoNetCDF.units module
units
– Functions for converting units
PseudoNetCDF.userfuncs module
- PseudoNetCDF.userfuncs.daymax(arr, axis=None, keepdims=True)[source]
see _dayfunc with np.maximum as func
- PseudoNetCDF.userfuncs.daymean(arr, axis=None, keepdims=True)[source]
see _dayfunc with np.mean as func
- PseudoNetCDF.userfuncs.daymin(arr, axis=None, keepdims=True)[source]
see _dayfunc with np.minimum as func
- PseudoNetCDF.userfuncs.daystd(arr, axis=None, keepdims=True)[source]
see _dayfunc with np.std as func
- PseudoNetCDF.userfuncs.dayvar(arr, axis=None, keepdims=True)[source]
see _dayfunc with np.var as func
- PseudoNetCDF.userfuncs.mda8(arr, axis=None, keepdims=True)[source]
- Daily-Maximum 8-hour average concentration
can be applied to any dimensions, but make sense with time
returns the day max of the a8
- Parameters:
like (arr - array)
mda8 (axis - axis over which to apply)
true (keepdims - should be)
- Returns:
- out - maximum of 8 element running average. For masked inptus, only
values with 6 or more valid entries are returned
PseudoNetCDF.version module
PseudoNetCDF.xarray_plugin module
- class PseudoNetCDF.xarray_plugin.PncArrayWrapper(variable_name, datastore)[source]
Bases:
BackendArray
- class PseudoNetCDF.xarray_plugin.PseudoNetCDFBackend[source]
Bases:
BackendEntrypoint
Backend for netCDF-like data formats in the air quality field based on the PseudoNetCDF package. It can open: - CAMx - RACM2 box-model outputs - Kinetic Pre-Processor outputs - ICARTT Data files (ffi1001) - CMAQ Files - GEOS-Chem Binary Punch/NetCDF files - and many more This backend is not selected by default for any files, so make sure to specify
engine="pseudonetcdf"
inopen_dataset
. For more information about the underlying library, visit: https://pseudonetcdf.readthedocs.io .. seealso::backends.PseudoNetCDFDataStore
- description: ClassVar[str] = 'Open many atmospheric science data formats using PseudoNetCDF in Xarray'
- open_dataset(filename_or_obj: str | os.PathLike[Any] | BufferedIOBase | AbstractDataStore, mask_and_scale=False, decode_times=True, concat_characters=True, decode_coords=True, drop_variables: str | Iterable[str] | None = None, use_cftime=None, decode_timedelta=None, mode=None, lock=None, **format_kwargs) Dataset [source]
Backend open_dataset method used by Xarray in
open_dataset()
.
- open_dataset_parameters: ClassVar[tuple | None] = ('filename_or_obj', 'mask_and_scale', 'decode_times', 'concat_characters', 'decode_coords', 'drop_variables', 'use_cftime', 'decode_timedelta', 'mode', 'lock')
Module contents
PseudoNetCDF provides basic interfaces for emulating NetCDF and manipulating or extending existing NetCDF like files
- PseudoNetCDF.PNC(*args, **kwds)[source]
- Parameters:
PseudoNetCDF (args - Command Line arguments/options for) – for full list of potential args PNC(’–help’)
- (ifiles)
(default (actions -) –
False) False: only open files do not make outputs True: enable dump,gen,map,etc output actions
for action options see subparsers help e.g., PNC(‘dump’, ‘–help’, actions = True)
- Returns:
- out - Namespace object with parsed arguments
including a list of processed files (out.ifiles)
Example
# Single File out = PNC(’–format=netcdf’, inpath) infile = out.ifiles[0] O3 = infile.variables[‘O3’]
# Multiple Files out = PNC(’–format=netcdf’, inpath1, inpath2) infile1, infile2 = out.ifiles O3_1 = infile1.variables[‘O3’] O3_2 = infile2.variables[‘O3’]
# With Actions out = PNC(‘dump’, ‘–variables=O3’, ‘–format=netcdf’, inpath)
netcdf icartt/dc3-mrg60-dc8_merge_20120518_R7_thru20120622.nc { dimensions:
POINTS = 6817 ;
- variables:
- double O3(TSTEP, LAY, ROW, COL);
O3_ESRL:units = “ppbV” ; O3_ESRL:standard_name = “Ozone” ; O3_ESRL:missing_value = -999999 ;
…
- class PseudoNetCDF.Pseudo2NetCDF(datafirst=False, verbose=1)[source]
Bases:
object
Pseudo2NetCDF is a base class for conversion. Properties and methods can be overwritten to facilitate conversion of special PseudoNetCDFFiles.
Specifically: ignore_global_properties and ignore_variable_properties lists can be overwritten so that class properties and methods are not written to a netCDF file
- create_variable_kwds = {}
- ignore_global_properties = ['variables', 'dimensions']
- ignore_global_re = re.compile('^_\\w*(__\\w*)?')
- ignore_variable_properties = ['typecode', 'dimensions']
- ignore_variable_re = re.compile('^_\\w*(__\\w*)?')
- re = <module 're' from '/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/re/__init__.py'>
- special_properties = ['_fillvalue', '_FillValue']
- unlimited_dimensions = []
- PseudoNetCDF.PseudoIOAPIVariable(parent, name, typecode, dimensions, **kwds)[source]
Creates a variable using the dimensions as defined in the parent object
- Parameters:
parent (PseudoNetCDFFile) – an object with a dimensions variable
name (string) – name for variable
typecode (string or numpy.dtype) – numpy style typecode
dimensions (tuple of strings) – dimension names to be used from parent
**kwds (dictionary) – units: default = none long_name: default = name var_desc: default = name
- class PseudoNetCDF.PseudoNetCDFDimension(group, name, size)[source]
Bases:
object
Dimension object responds like that of netcdf4-python
- class PseudoNetCDF.PseudoNetCDFFile(*args, **kwds)[source]
Bases:
pnc
,object
PseudoNetCDFFile provides an interface and standard set of methods that a file should present to act like a netCDF file using the Scientific.IO.NetCDF.NetCDFFile interface.
- apply(verbose=0, **dimfuncs)
Similar to numpy.apply_along_axis, but for damed dimensions and processes dimensions as well as variables
- Parameters:
dimfuncs (dictionary) – key value pairs where the key is a dimensions and the value is a 1D function (func1d) or a dictionary. If the value is a dictionary it must include func1d as a function and any keyword arguments as additional options
verbose (integer) – 0 silent, 1 show variable, 2 show dimensions and variables
- Returns:
outf – instance with variables and dimensions after processing
- Return type:
- applyAlongDimensions(verbose=0, **dimfuncs)[source]
Similar to numpy.apply_along_axis, but for damed dimensions and processes dimensions as well as variables
- Parameters:
dimfuncs (dictionary) – key value pairs where the key is a dimensions and the value is a 1D function (func1d) or a dictionary. If the value is a dictionary it must include func1d as a function and any keyword arguments as additional options
verbose (integer) – 0 silent, 1 show variable, 2 show dimensions and variables
- Returns:
outf – instance with variables and dimensions after processing
- Return type:
- copy(props=True, dimensions=True, variables=True, data=True)[source]
Function for making copies of the same type
- Parameters:
props (boolean) – include properties (default: True)
dimensions (boolean) – include dimensions (default: True)
variables (boolean) – include variable structures (default: True)
data (boolean) – include variable data (default: True)
- Returns:
outf
- Return type:
PseudoNetCDFFile instance
- copyVariable(var, key=None, dtype=None, dimensions=None, fill_value=None, withdata=True)[source]
Copy var into self as vark
- Parameters:
var (PseudoNetCDFVariable) – netCDF4.Variable-like object (must have ncattrs and setncatts)
key (string) – key for variable in self (can be omitted if var has name, standard_name, or long_name)
dtype (string or numpy.dtype) – change the data type to dtype
dimensions (iterable of strings) – change the dimensions to dimensions
fill_value (integer or flaot) – change the fill_value to this values
withdata (boolean) – default True, copies data
- Returns:
myvar – copy of var in this file
- Return type:
PseuodNetCDFVairable
- createDimension(name, length)[source]
Create a dimension
- Parameters:
name (string) – name for dimension
length (integer) – maximum length of dimension
- Returns:
dim – new dimension
- Return type:
PseudoNetCDFDimensions
- createVariable(name, type, dimensions, fill_value=None, **properties)[source]
Create a variable
- Parameters:
name (string) – name for new variable
type (string or numpy dtype) – code (e.g., ‘f’, ‘i’, ‘d’)
dimensions (tuple of strigns) – dimension keys that can be found in objects’ dimensions dictionary
- Returns:
var
- Return type:
new variable
- date2num(time, timekey='time')[source]
- Parameters:
time (array-like) – array of datetime.datetime objects
timekey (str) – time variable key which requires units and should have calendar. If calendar is missing, standard is the default. default ‘time’
- Returns:
num – time in relative time as defined by units of time variable (i.e., timekey) which defaults to ‘time’
- Return type:
array-like
- eval(expr, inplace=False, copyall=False)[source]
Evaluate expr and return a PseudoNetCDFFile object with resutl
- Parameters:
expr (string) – expression to evaluate
inplace (boolean) – create the new variable in this netcdf file (default False)
copyall (boolean) – if not inplace, should all variables be copied to new file
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- flush()
Does nothing. Implemented for continuity with Scientific.IO.NetCDF
- classmethod from_arrays(dims=None, attrs=None, nameattr='standard_name', fileattrs=None, **inarrkw)[source]
Create a new ioapi file from arrays.
- Parameters:
dims (iterable) – Explicit dimensions. If not provided, they will be created as phony_dim_{i} where i for i in range(ndim). For example, an array of shape (2, 3) would have dimensions (phony_dim_0, phony_dim_1)
attrs (mappable) – Attributes for all variables (e.g., units). long_name and var_desc will be set based on key if not provided.
nameattr (str) – Key for name as an attribute
fileattrs (mappable) – Attributes for the file to be created.
inarrkw (mappable) – Keys are the names of variables to be created and the value should be an array of values.
- Returns:
outf
- Return type:
PseudoNetcdf-like file
- classmethod from_ncf(infile)[source]
- Parameters:
infile (PseudoNetCDF-like file)
- Returns:
outf
- Return type:
PseudoNetcdf-like file
- classmethod from_ncvs(*invars, **invarkw)[source]
- Parameters:
invars (list) – NetCDF-like variable must have standard_name, long_name or name
invarkw (kwds) – NetCDF-like variables
- Returns:
outf
- Return type:
PseudoNetcdf-like file
- getMap(maptype='basemap_auto', **kwds)[source]
Description
- Parameters:
maptype (string) –
choices ‘basemap’, ‘basemap_auto’, ‘cartopy’ (not yet) basemap : attempts to open a basemap with only supplied kwds basemap_auto : automatically adds llcrnrlon,llcrnrlat,u
rcrnrlon,urcrnrlat based on longitude_bounds
**kwds (keywords) – for basemap or cartopy
- Returns:
map
- Return type:
basemap or cartopy axis
- getTimes(datetype='datetime', bounds=False)[source]
Get an array of datetime objects
- Parameters:
datetype (string or numpy.dtype) – ‘datetime’ or datetime64 dtype
bounds (boolean) – get time boundaries
- Returns:
out – datetime objects or array of numpy’s datetype type
- Return type:
array
Notes
self must have a time or TFLAG variable
- get_dest()[source]
- Returns:
path – path where a new file is created on some action
- Return type:
str
Notes
If None, a file is created in memory. Else, a netcdf file is created on disk.
- get_varopt()[source]
Get options
- Parameters:
None
- Returns:
options
- Return type:
dictionary of options
- getncatts()[source]
Return all ncattrs keys and values as a dictionary
- Returns:
attdict – key/value pairs of properties
- Return type:
dictionary
- getproj(withgrid=False, projformat='pyproj')[source]
Description
- Parameters:
withgrid (boolean) – use grid units instead of meters
projformat (string) – ‘pyproj’ (default), ‘proj4’ or ‘wkt’ allows function to return a pyproj projection object or a string in the format of proj4 or WKT
- Returns:
proj – (wkt, proj4) or pyprojProj (pyproj)
- Return type:
string pyproj.Proj
- ij2ll(i, j)[source]
Converts i, j to lon, lat (no false easting/northing) using cell centers assuming 0-based i/j
- Parameters:
i (scalar/iterable) – indicies (0-based) for the west-east dimension
j (scalar/iterable) – indicies (0-based) for the south-north dimension
- Returns:
lon, lat – longitudes and latitudes in decimal degrees
- Return type:
scalars or iterables
- insertDimension(newonly=True, multionly=False, before=None, after=None, inplace=False, **newdims)[source]
Insert dimensions with keys and lengths from newdims
- Parameters:
**newdims (dictionary) – where key is the new dimension and value is the length
newonly (boolean) – Only add dimension to variables that do not already have it, default True
multionly (boolean) – Only add dimension if there are already more than one (good for ignoring coordinate dimensions)
before (string) – if variable has this dimension, insert the new dimension before it. Otherwise, add to the beginning. (before takes precedence)
after (string) – if variable has this dimension, insert the new dimension after it. Otherwise, add to the beginning.
inplace (boolean) – create the new variable in this netcdf file (default False)
- Returns:
outf – instance will new dimension in dimensions and variables
- Return type:
Notes
Adding a non unity dimension will cause the data to be repeated along the new axis.
If order of addition matters, use multiple calls. newdimsuse will be a non-ordered dictionary
- interpDimension(dimkey, newdimvals, coordkey=None, **interpkwds)[source]
- Parameters:
dimkey (string) – the new dimension for interpolation
newdimvals (iterable) – the new values to interpolate to
coordkey (string) – the variable to use as the old coordinate values
interptype (string) –
- ‘linear’ or ‘conserve’. linear uses a linear interpolation
conserve uses a mass conserving interpolation
extrapolate (boolean) – allow extrapolation beyond bounds with linear, default False
fill_value (numeric value) – set fill value (e.g, nan) to prevent extrapolation or edge continuation
- Returns:
outf – instance with all variables interpolated
- Return type:
Notes
When extrapolate is false, the edge values are used for points beyond the inputs.
- classmethod isMine(*args, **kwds)[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.
- ll2ij(lon, lat, bounds='ignore', clean='none')[source]
Converts lon/lat to 0-based indicies (0,M), (0,N)
- Parameters:
lon (scalar or iterable) – longitudes in decimal degrees
lat (scalar or iterable) – latitudes in decimal degrees
bounds (string) – ignore, error, warn if i,j are out of domain
clean (string) – none - return values regardless of bounds; mask - mask values out of bounds; clip - return min(max(0, v), nx - 1)
- Returns:
i, j
- Return type:
indices (0-based) for variables
- ll2xy(lon, lat)[source]
Converts lon/lat to x distances (no false easting/northing)
- Parameters:
lon (scalar or iterable) – longitudes in decimal degrees
lat (scalar or iterable) – latitudes in decimal degrees
- Returns:
x, y – coordinates in map projection (meters or radians)
- Return type:
tuple of arrays
- mask(where=None, less=None, less_equal=None, greater=None, greater_equal=None, values=None, equal=None, invalid=False, mask=None, dims=None, fill_value=-999, coords=False, verbose=0)[source]
Apply mask to all variables of same shape or just where dimensions match.
- Parameters:
where (array-like) – boolean array to use as a mask see numpy.ma.masked_where
greater (scalar) – mask when values are greater than this value see numpy.ma.masked_greater
less (scalar) – mask when values are less than this value see numpy.ma.masked_less
greater_equal (scalar) – mask when values are greater than or equal to this value see numpy.ma.masked_greater
less_equal (scalar) – mask when values are less than or equal to this value see numpy.ma.masked_less
values (scalar) – mask when values are equal to this value within standard floating point see numpy.ma.masked_values
equal (scalar) – mask when values are exactly this value (i.e., integers) see numpy.ma.masked_equal
invalid (boolean) – mask when values are invalid, see numpy.ma.masked_invalid
mask (array-like) – alias for where
dims (iterable of strings) – only apply “mask” or “where” to variables with these dimensions no effet on other masks
fill_value (scalar) – value to use as the fill_value for new arrays
coords (boolean) – if True, apply masks to coordinate variables. Default, False
verbose (int) – level of verbosity for function, mostly for debugging
- Returns:
outf – instance with masked variables
- Return type:
See also
numpy.ma
all masks are passing throught to numpy.ma.masked_…
Notes
mask options are not mutually exclusive. the order is where, greater, greater_equal, less, less_equal, values, equal, invalid
- plot(varkey, plottype=None, ax_kw=None, plot_kw=None, cbar_kw=None, map_kw=None, dimreduction='mean')[source]
- Parameters:
varkey (string) – the variable to plot
plottype (string) – any dimension name pair delimited by a hyphen (e.g., longitude-latitude, latitude-pressure, longitude-pressure, vertical-profile, time-longitude, time-latitude, time-pressure) defaults to the last two dimensions.
ax_kw (dictionary) – keywords for the axes to be created
plot_kw (dictionary) – keywords for the plot (plot, scatter, or pcolormesh) to be created
cbar_kw (dictionary or bool or None) – keywords for the colorbar; if True or None, use defaults. If False, do not create a colorbar
map_kw (dictionary or bool or None) – keywords for the getMap routine, which is only used with map capable dimensions (ie, plottype=’longitude-latitude’) If True or None, use default configuration dict(countries=True, coastlines=True, states=False, counties=False). If False, do not draw a map.
dimreduction (string or function) – dimensions not being used in the plot are removed using applyAlongDimensions(dimkey=dimreduction) where each dimenions
- Returns:
ax – Axes that was drawn on
- Return type:
matplotlib.axes.Axes
- removeSingleton(dimkey=None)[source]
Return a netcdflike object with dimensions sliced
- Parameters:
dimkey (string) – key of dimension to be evaluated for removal; if None, evaluate all. only singleton dimensions will be removed.
- Returns:
outf – instance with dimensions removed
- Return type:
- renameDimension(oldkey, newkey, inplace=False)[source]
Rename dimension (oldkey) in dimensions and in all variables
- Parameters:
oldkey (string) – dimension to be renamed
newkey (string) – new dame for dimension
inplace (boolean) – create the new variable in this netcdf file (default False)
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- renameDimensions(inplace=False, **newkeys)[source]
Rename dimension (oldkey) in dimensions and in all variables
- Parameters:
**newkeys (dictionary) – where key is the oldkey and value is the newkey
inplace (boolean) – create the new variable in this netcdf file (default False)
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- renameVariable(oldkey, newkey, inplace=False, copyall=True)[source]
Rename variable (oldkey)
- Parameters:
oldkey (string) – variable to be renamed
newkey (string) – new dame for variable
inplace (boolean) – create the new variable in this netcdf file (default False)
copyall (boolean) – if not inplace, should all variables be copied to new file
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- renameVariables(inplace=False, copyall=True, **newkeys)[source]
Rename variables for each oldkey: newkey dictionary item
- Parameters:
**newkeys (dictionary) – where key is the oldkey and value is the newkey
inplace (boolean) – create the new variable in this netcdf file (default False)
copyall (boolean) – if not inplace, should all variables be copied to new file
- Returns:
outf – instance with renamed variable (this file if inplace = True)
- Return type:
- reorderDimensions(oldorder, neworder, inplace=False)[source]
Evaluate expr and return a PseudoNetCDFFile object with resutl
- Parameters:
oldorder (iterable of strings) – dimension names in existing order
neworder (iterable of strings) – dimension names in new order
- Returns:
outf – instance with dimensions reordered in variables
- Return type:
- save(*args, **kwds)[source]
Provides access to pncwrite for self
- Parameters:
pncwrite (see Help)
- Return type:
see Help pncwrite
- setCoords(keys, missing='ignore')[source]
Set a variable as a coordinate variable
- Parameters:
keys (iterable of strings) – keys for coord variables
missing (string) – action if missing ‘ignore’, ‘skip’ or ‘error’ ignore - add in case used later skip - do not add error - raise an error
- Return type:
None
Notes
Coordinate variables are excluded from math
- set_dest(path, **options)[source]
Sets the path where a new file is created on some action
- Parameters:
path (str) – path for new file
**options (keywords for constructor) – options for new file creation
- Return type:
None
- set_varopt(**options)[source]
Set options to be used when creating any Variable
- Parameters:
**options (options for createVariable) – optional keywords to be supplied when creating new variables in destination file
- Return type:
None
- setncatts(attdict)[source]
Set ncattrs from attdict keys and values
- Parameters:
attdict (dictionary) – key/value pairs of properties
- Return type:
None
- slice(newdims=('POINTS',), verbose=0, **dimslices)
Return a netcdflike object with dimensions sliced
- Parameters:
newdims (iterable of strings) – names for new dimensions. When more than one iterable applies to a variable slice, fancy indexing removes both dimensions and creates a new one of the iterable lengths
**dimslices (dictionary) – key value pairs where the key is a dimension and the value is a valid slice object (slices, ints or iterables) if iterables are provided, all iterables must be the same size and shape. If the arrays are not 1D, newdims must have ndim names
- Returns:
outf – instance with variables and dimensions sliced
- Return type:
- sliceDimensions(newdims=('POINTS',), verbose=0, **dimslices)[source]
Return a netcdflike object with dimensions sliced
- Parameters:
newdims (iterable of strings) – names for new dimensions. When more than one iterable applies to a variable slice, fancy indexing removes both dimensions and creates a new one of the iterable lengths
**dimslices (dictionary) – key value pairs where the key is a dimension and the value is a valid slice object (slices, ints or iterables) if iterables are provided, all iterables must be the same size and shape. If the arrays are not 1D, newdims must have ndim names
- Returns:
outf – instance with variables and dimensions sliced
- Return type:
- stack(other, stackdim)[source]
Concatenates all variables on stackdim
- Parameters:
other (instance or list of PseudoNetCDFFiles) – files to add to this file along stackdim
stackdim (str) – dimension name
- Returns:
outf – instance with stacked variables and dimension equal to new length
- Return type:
- subset(varkeys, inplace=False, exclude=False, keepcoords=True)
Return a PseudoNetCDFFile with only varkeys
- Parameters:
varkeys (iterable of strings) – keys to keep
inplace (boolean) – if true (default false), then remove other variable from this file
exclude (boolean) – if True (default False), then remove just these variables
keepcoords (boolean) – if True (default True), keep coordinate variables
- Returns:
outf – instance with variables
- Return type:
- subsetVariables(varkeys, inplace=False, exclude=False, keepcoords=True)[source]
Return a PseudoNetCDFFile with only varkeys
- Parameters:
varkeys (iterable of strings) – keys to keep
inplace (boolean) – if true (default false), then remove other variable from this file
exclude (boolean) – if True (default False), then remove just these variables
keepcoords (boolean) – if True (default True), keep coordinate variables
- Returns:
outf – instance with variables
- Return type:
- sync()
Does nothing. Implemented for continuity with Scientific.IO.NetCDF
- time2idx(time, dim='time', timekey=None, **kwds)[source]
Convert datetime objects to dimension indices
- Parameters:
time (array-like) – array of datetime.datetime objects
dim (str) – dimension name for val2idx
timekey (str) – time variable key. None defaults to dim
kwds (mappable) – see val2idx
- Returns:
idx – time index (0-based)
- Return type:
array-like
- time2t(time, ttype='nearest', index=True)[source]
- Parameters:
time (array of datetime.datetime objects)
interp ('nearest', 'bounds', 'bounds_close')
index (return index)
- Returns:
t
- Return type:
fractional time or if index, integers for indexing
- val2idx(dim, val, method='nearest', bounds='warn', left=None, right=None, clean='mask')[source]
Convert coordinate values to indices
- Parameters:
dim (str) – name of dimensions, which must have a coordinate variable
val (array-like) – value in coordinate space
method (str) –
- nearest, bounds, exact - each calculates the index differently
nearest : uses interp with coord values and rounds
bounds : uses interp between bounding values and truncates
- exactreturns indices for exact coord values with other
indices masked (clean keyword has no effect)
bounds (str) – ignore, error, warn if i,j are out of domain
left (scalar) – see np.interp
right (scalar) – see np.interp
clean ({'none', 'mask'}) –
none - return values regardless of bounds; mask - mask invalid values (use with left/right=np.nan);
has no affect with method exact
- Returns:
i – indices (0-based) for variables
- Return type:
array-like
- xy2ll(x, y)[source]
Converts x, y to lon, lat (no false easting/northing)
- Parameters:
x (scalar or iterable) – projected west-east coordinates
y (scalar or iterable) – projected south-north coordinates
- Returns:
lon, lat – longitudes and latitudes in decimal degrees
- Return type:
scalars or iterables
- class PseudoNetCDF.PseudoNetCDFMaskedVariable(parent, name, typecode='f', dimensions=(), **kwds)[source]
Bases:
PseudoNetCDFVariable
,MaskedArray
Creates a variable using the dimensions as defined in the parent object
- parent: PseudoNetCDFFile
an object with a dimensions variable
- name: string
name for variable
- typecode: string or numpy.dtype
numpy style typecode
- dimensions: tuple of strings
dimension names to be used from parent
- **kwds: dictionary
keywords to be added as properties to the variable. The keyword ‘values’ is a special case that will be used as the starting values of the array
- class PseudoNetCDF.PseudoNetCDFVariable(parent, name, typecode, dimensions, **kwds)[source]
Bases:
ndarray
PseudoNetCDFVariable presents the Scientific.IO.NetCDF.NetCDFVariable interface, but unlike that type, provides a contructor for variables that could be used without adding it to the parent file
Creates a variable using the dimensions as defined in the parent object
- Parameters:
parent (PseudoNetCDFFile) – an object with a dimensions variable
name (string) – name for variable
typecode (string or numpy.dtype) – numpy style typecode
dimensions (tuple of strings) – dimension names to be used from parent
**kwds (keywords) – Dictionary of keywords to be added as properties to the variable. The keyword ‘values’ is a special case that will be used as the starting values of the array
- ncattrs()[source]
- Returns:
ncattrs – attributes that have been user defined
- Return type:
tuple of strings
- PseudoNetCDF.PseudoNetCDFVariableConvertUnit(var, outunit)[source]
Convert the unit of var and update the associated IOAPI metadata
- class PseudoNetCDF.PseudoNetCDFVariables(func, keys)[source]
Bases:
OrderedDefaultDict
PseudoNetCDFVariables provides a special implementation of the default dictionary that provides efficient access to variables of a PseudoNetCDFFile. PseudoNetCDFFiles may have large variables that should only be loaded if accessed. PseudoNetCDFVariables allows a user to specify a function that can create variables on demand.
- func: function
must take a key and provides a PseudoNetCDFVariable
- keys: iterable of strings
keys that the dictionary should act as if it has
- class PseudoNetCDF.WrapPNC(*args, **kwds)[source]
Bases:
PseudoNetCDFFile
- PseudoNetCDF.anyfile(*args, **kwds)
Open any PNC supported format using args and kwds, which are format specific. format is not passed to the reader
- Parameters:
*args – arguments for opening file
**kwds – keywords for reader (see format)
format (string) – name of reader (not passed to reader), default auto-detect see Format Options for formats
addcf (boolean) – to add CF conventions (not passed to reader; default: False)
diskless (boolean) – If addcf (default: False), the file must either be wrapped or loaded into memory (diskless) to add attributes.
help (boolean) – without format, returns help of pncopen and with format keyword, returns help of that class. See the __init__ interface for help with keywords that are not in the class __doc__.
- Returns:
pfile
- Return type:
PseudoNetCDF
Notes
- Format Options:
add your own by subclassing PseudoNetCDFFile
for a full list, use pncopen(help=True)
netcdf
nc
ncf
WrapPNC
cloud_rain
camxfiles.cloud_rain.Memmap.cloud_rain
add_derived
MetaNetCDF.add_derived
time_avg_new_unit
MetaNetCDF.time_avg_new_unit
window
MetaNetCDF.window
newresolution
MetaNetCDF.newresolution
MetaNetCDF
MetaNetCDF.MetaNetCDF
cloud_rain_center_time
camxfiles.cloud_rain.Transforms.cloud_rain_center_time
cloud_rain_plus
camxfiles.cloud_rain.Transforms.cloud_rain_plus
cloud_rain_center_time_plus
camxfiles.cloud_rain.Transforms.cloud_rain_center_time_plus
height_pressure
camxfiles.height_pressure.Memmap.height_pressure
camxfiles.height_pressure.Read.height_pressure
height_pressure_plus
camxfiles.height_pressure.Transforms.height_pressure_plus
height_pressure_center_time_plus
camxfiles.height_pressure.Transforms.height_pressure_center_time_plus
height_pressure_center_time
camxfiles.height_pressure.Transforms.height_pressure_center_time
one3d
camxfiles.one3d.Memmap.one3d
camxfiles.one3d.Read.one3d
humidity
camxfiles.humidity.Memmap.humidity
camxfiles.humidity.Read.humidity
humidity_center_time
camxfiles.humidity.Transforms.humidity_center_time
ipr
camxfiles.ipr.Memmap.ipr
camxfiles.ipr.Read.ipr
irr
camxfiles.irr.Memmap.irr
camxfiles.irr.Read.irr
landuse
camxfiles.landuse.Memmap.landuse
point_source
camxfiles.point_source.Memmap.point_source
camxfiles.point_source.Read.point_source
temperature
camxfiles.temperature.Memmap.temperature
camxfiles.temperature.Read.temperature
temperature_center_time
camxfiles.temperature.Transforms.temperature_center_time
jtable
cmaqfiles.jtable
ioapi_base
cmaqfiles.ioapi_base
ioapi
cmaqfiles.ioapi
icon_profile
cmaqfiles.profile.icon_profile
bcon_profile
cmaqfiles.profile.bcon_profile
griddesc
cmaqfiles.griddesc
cmaqomidat
cmaqfiles.cmaqomidat
uamiv
camxfiles.uamiv.Memmap.uamiv
camxfiles.uamiv.Read.uamiv
osat
camxfiles.uamiv.Transforms.osat
vertical_diffusivity
camxfiles.vertical_diffusivity.Memmap.vertical_diffusivity
camxfiles.vertical_diffusivity.Read.vertical_diffusivity
vertical_diffusivity_center_time
camxfiles.vertical_diffusivity.Transforms.vertical_diffusivity_center_time
wind
camxfiles.wind.Memmap.wind
camxfiles.wind.Read.wind
wind_center_time_cell
camxfiles.wind.Transforms.wind_center_time_cell
lateral_boundary
camxfiles.lateral_boundary.Memmap.lateral_boundary
finst
camxfiles.finst.Memmap.finst
_diag_group
geoschemfiles._diag_group
bpch_base
geoschemfiles.bpch_base
bpch1
geoschemfiles.bpch1
gcnc_base
geoschemfiles.gcnc_base
gcnc
geoschemfiles.gcnc
bpch2
geoschemfiles.bpch2
bpch
geoschemfiles.bpch
geos
geoschemfiles.geos
flightlogs
geoschemfiles.flightlogs
ffi1001
icarttfiles.ffi1001.ffi1001
reader
aermodfiles.reader
ceilometerl2
ceilometerfiles.ceilometerl2
aqsraw
epafiles.aqsraw
arlpackedbit
noaafiles.arlpackedbit
l100
noaafiles.l100
arlpardump
noaafiles.arlpardump
arlconcdump
noaafiles.arlconcdump
arltrajdump
noaafiles.arltrajdump
csv
textfiles.csv
tomsl3
toms.level3.tomsl3
woudcsonde
woudcfiles.woudcsonde
wrf_base
wrffiles.wrf_base
wrf
wrffiles.wrf
sum_reader
net_balance.sum_reader
ctb_reader
net_balance.ctb_reader
net_reader
net_balance.net_reader
mrgaloft
net_balance.mrgaloft
- PseudoNetCDF.extract(f, lonlat, unique=False, gridded=None, method='nn', passthrough=True)
- PseudoNetCDF.extract_from_file(f, lonlatfs, unique=False, gridded=None, method='nn', passthrough=True)[source]
- PseudoNetCDF.get_dimension_length(pfile, key)[source]
Return the length of a dimension (key) from pfile
- PseudoNetCDF.get_ncf_object(path_or_object, mode, format='NETCDF4_CLASSIC')[source]
Return an open NetCDF or PseudoNetCDF from an object or path
- PseudoNetCDF.getreader(*args, **kwds)[source]
- Parameters:
*args – arguments for opening file
**kwds – keywords for file opener and optional format
format (string) – name of reader (optional)
- Returns:
reader
- Return type:
class
- PseudoNetCDF.interpvars(f, weights, dimension, loginterp=[])[source]
f - PseudoNetCDFFile weights - weights for new dimensions from old dimension dim(new, old) dimension - which dimensions will be reduced loginterp - iterable of keys to interp on log scale
- PseudoNetCDF.manglenames(f, translator={' ': '_', '$': 'S', '(': '', ')': '', '+': '_add_', '-': '_'})[source]
- PseudoNetCDF.mask_vals(f, maskdef, metakeys=['time', 'layer', 'level', 'latitude', 'longitude', 'time_bounds', 'latitude_bounds', 'longitude_bounds', 'ROW', 'COL', 'LAY', 'TFLAG', 'ETFLAG'])[source]
- PseudoNetCDF.pnc(*args, **kwds)[source]
Arguments - see PNC :returns: file(s) - single file or, if more than 1 file is returned a list of files
- PseudoNetCDF.pncbo(op, ifile1, ifile2, coordkeys=None, verbose=0)[source]
Perform binary operation (op) on all variables in ifile1 and ifile2. The returned file (rfile) contains the result
rfile = ifile1 <op> ifile2
op can be any valid operator (e.g., +, -, /, , *, &, ||)
- PseudoNetCDF.pncexpr(expr, ifile, verbose=0)[source]
Evaluate an arbitrary expression in the context of ifile.variables and add the result to the file with appropriate units.
- PseudoNetCDF.pncfile
alias of
PseudoNetCDFFile
- PseudoNetCDF.pncmfopen(paths, *args, stackdim=None, **kwds)[source]
Open any PNC supported format using pncopen on all files passed as teh first argument of pncmfopen. See pncopen
- Parameters:
paths (list) – List of paths to open
args (arguments) – pncopen arguments (see pncopen)
stackdim (str) – dimension upon which to stack files
kwds (dict) – pncopen and format-specific keywords (see pncopen for more details)
- Returns:
pfile
- Return type:
PseudoNetCDF
- PseudoNetCDF.pncopen(*args, **kwds)[source]
Open any PNC supported format using args and kwds, which are format specific. format is not passed to the reader
- Parameters:
*args – arguments for opening file
**kwds – keywords for reader (see format)
format (string) – name of reader (not passed to reader), default auto-detect see Format Options for formats
addcf (boolean) – to add CF conventions (not passed to reader; default: False)
diskless (boolean) – If addcf (default: False), the file must either be wrapped or loaded into memory (diskless) to add attributes.
help (boolean) – without format, returns help of pncopen and with format keyword, returns help of that class. See the __init__ interface for help with keywords that are not in the class __doc__.
- Returns:
pfile
- Return type:
PseudoNetCDF
Notes
- Format Options:
add your own by subclassing PseudoNetCDFFile
for a full list, use pncopen(help=True)
netcdf
nc
ncf
WrapPNC
cloud_rain
camxfiles.cloud_rain.Memmap.cloud_rain
add_derived
MetaNetCDF.add_derived
time_avg_new_unit
MetaNetCDF.time_avg_new_unit
window
MetaNetCDF.window
newresolution
MetaNetCDF.newresolution
MetaNetCDF
MetaNetCDF.MetaNetCDF
cloud_rain_center_time
camxfiles.cloud_rain.Transforms.cloud_rain_center_time
cloud_rain_plus
camxfiles.cloud_rain.Transforms.cloud_rain_plus
cloud_rain_center_time_plus
camxfiles.cloud_rain.Transforms.cloud_rain_center_time_plus
height_pressure
camxfiles.height_pressure.Memmap.height_pressure
camxfiles.height_pressure.Read.height_pressure
height_pressure_plus
camxfiles.height_pressure.Transforms.height_pressure_plus
height_pressure_center_time_plus
camxfiles.height_pressure.Transforms.height_pressure_center_time_plus
height_pressure_center_time
camxfiles.height_pressure.Transforms.height_pressure_center_time
one3d
camxfiles.one3d.Memmap.one3d
camxfiles.one3d.Read.one3d
humidity
camxfiles.humidity.Memmap.humidity
camxfiles.humidity.Read.humidity
humidity_center_time
camxfiles.humidity.Transforms.humidity_center_time
ipr
camxfiles.ipr.Memmap.ipr
camxfiles.ipr.Read.ipr
irr
camxfiles.irr.Memmap.irr
camxfiles.irr.Read.irr
landuse
camxfiles.landuse.Memmap.landuse
point_source
camxfiles.point_source.Memmap.point_source
camxfiles.point_source.Read.point_source
temperature
camxfiles.temperature.Memmap.temperature
camxfiles.temperature.Read.temperature
temperature_center_time
camxfiles.temperature.Transforms.temperature_center_time
jtable
cmaqfiles.jtable
ioapi_base
cmaqfiles.ioapi_base
ioapi
cmaqfiles.ioapi
icon_profile
cmaqfiles.profile.icon_profile
bcon_profile
cmaqfiles.profile.bcon_profile
griddesc
cmaqfiles.griddesc
cmaqomidat
cmaqfiles.cmaqomidat
uamiv
camxfiles.uamiv.Memmap.uamiv
camxfiles.uamiv.Read.uamiv
osat
camxfiles.uamiv.Transforms.osat
vertical_diffusivity
camxfiles.vertical_diffusivity.Memmap.vertical_diffusivity
camxfiles.vertical_diffusivity.Read.vertical_diffusivity
vertical_diffusivity_center_time
camxfiles.vertical_diffusivity.Transforms.vertical_diffusivity_center_time
wind
camxfiles.wind.Memmap.wind
camxfiles.wind.Read.wind
wind_center_time_cell
camxfiles.wind.Transforms.wind_center_time_cell
lateral_boundary
camxfiles.lateral_boundary.Memmap.lateral_boundary
finst
camxfiles.finst.Memmap.finst
_diag_group
geoschemfiles._diag_group
bpch_base
geoschemfiles.bpch_base
bpch1
geoschemfiles.bpch1
gcnc_base
geoschemfiles.gcnc_base
gcnc
geoschemfiles.gcnc
bpch2
geoschemfiles.bpch2
bpch
geoschemfiles.bpch
geos
geoschemfiles.geos
flightlogs
geoschemfiles.flightlogs
ffi1001
icarttfiles.ffi1001.ffi1001
reader
aermodfiles.reader
ceilometerl2
ceilometerfiles.ceilometerl2
aqsraw
epafiles.aqsraw
arlpackedbit
noaafiles.arlpackedbit
l100
noaafiles.l100
arlpardump
noaafiles.arlpardump
arlconcdump
noaafiles.arlconcdump
arltrajdump
noaafiles.arltrajdump
csv
textfiles.csv
tomsl3
toms.level3.tomsl3
woudcsonde
woudcfiles.woudcsonde
wrf_base
wrffiles.wrf_base
wrf
wrffiles.wrf
sum_reader
net_balance.sum_reader
ctb_reader
net_balance.ctb_reader
net_reader
net_balance.net_reader
mrgaloft
net_balance.mrgaloft
- PseudoNetCDF.pncvar
alias of
PseudoNetCDFVariable
- PseudoNetCDF.pncwrite(*args, **kwds)[source]
See PseudoNetCDF.pncgen.pncgen
*args : iterable **kwds : keywords
keywords for pncgen
- helpboolean
without format, returns help of pncopen and with format keyword, returns help of the function that writes that format.
- PseudoNetCDF.reduce_dim(f, reducedef, fuzzydim=True, metakeys=['time', 'layer', 'level', 'latitude', 'longitude', 'time_bounds', 'latitude_bounds', 'longitude_bounds', 'ROW', 'COL', 'LAY', 'TFLAG', 'ETFLAG'])[source]
variable dimensions can be reduced using
reduce_dim(file ‘dim,function,weight’)
e.g., reduce_dim(layer,mean,weight).
Weighting is not fully functional.
- PseudoNetCDF.slice_dim(f, slicedef, fuzzydim=True)[source]
variables have dimensions (e.g., time, layer, lat, lon), which can be subset using:
slice_dim(f, ‘dim,start,stop,stride’)
e.g., slice_dim(f, ‘layer,0,47,5’) would sample every fifth layer starting at 0