pyrsig.cmaq package

Submodules

pyrsig.cmaq.pair module

pair_rsigcmaq is designed to pair RSIG data with CMAQ files.

Example

from pair_rsigcmaq import pair_rsigcmaq import pandas a pd

outpath = pair_rsigcmaq(‘CMAQ_ACONC_20160101’, ‘O3’, ‘airnow.ozone’) df = pd.read_csv(outpath) # Print descriptive statistics print(df[[‘ozone’, ‘CMAQ_O3’]].describe().to_csv()) # Print correlation statistics print(df[[‘ozone’, ‘CMAQ_O3’]].corr().to_csv())

More details:

from pair_rsigcmaq import pair_rsigcmaq help(pair_rsigcmaq)

Or use as a script:

python -m pyrsig.cmaq.pair –help

pyrsig.cmaq.pair.pair_rsigcmaq(qds, qkey, datakey, bdate=None, edate=None, bbox=None, prefix='CMAQ_', persist=False, verbose=0)[source]
Parameters:
  • qds (xarray.Dataset or str) – If a str, it must be the path to CMAQ file. If an xarray.Dataset, it must have CMAQ structure and: - crs_proj4 added by pyrsig.open_ioapi - optionally, encoding[‘source’] string describing the file

  • qkey (str) – CMAQ variable key (must be in the CMAQ file)

  • datakey (str) – RSIG variable key

  • bdate (datetime) – Starting date time. If None, infer from file.

  • edate (datetime) – Ending date time. If None, infer from file.

  • bbox (tuple) – ll_lon, ll_lat, ur_lon, ur_lat in decimal degrees East and North If bbox is None, it will be inferred from the file.

  • persist (bool) – If True (default: False), save to disk and return output path

  • verbose (int) – Level of verbosity. Negative omits warning about cached paired files.

Returns:

outpath – path to output

Return type:

str

Module contents

pyrsig.cmaq.open_griddesc(grid, earth_radius=6370000.0, **grid_kw)[source]
Parameters:

grid (str) –

Name of grid in def_grid_kw, or required IOAPI properties of a grid:

GDTYP, NCOLS, NROWS, XORIG, YORIG, XCELL, YCELL, P_ALP, P_BET, P_GAM, XCENT, YCENT, VGTYP, VGTOP, NLAYS

optional: earth_radius, g, R, A, T0, P0, REGRID_AGGREGATE

Returns:

ds – Dataset with properties and meta variables added.

Return type:

xr.Dataset

pyrsig.cmaq.open_ioapi(path, metapath=None, earth_radius=6370000.0, **kwds)[source]

Open an IOAPI file, add coordinate data, and optionally add RSIG metadata.

Parameters:
  • path (str) – Path to IOAPI formatted files.

  • metapath (str) – Path to metadata associated with the RSIG query. The metadata will be added as metadata global property.

  • earth_radius (float) – Assumed radius of the earth. 6370000 is the WRF default.

  • kwds (mappable) – Passed to xr.open_dataset

Returns:

ds – Dataset with IOAPI metadata

Return type:

xarray.Dataset

pyrsig.cmaq.open_mfioapi(paths, metapaths=None, earth_radius=6370000.0, **kwargs)[source]

Minimal version of open_mfdataset that is compatible with open_ioapi. preprocess : keyword defaults to add_ioapi_meta concat_dim : keyword defaults to ‘TSTEP’

Parameters:
  • paths (iterable) – Paths to ioapi files to be opened.

  • metapaths (iterable) – Paths to be added as a string metadata

  • earth_radius (float) – Radius of the earth for projection.

  • kwargs – See xr.open_mfdataset

pyrsig.cmaq.pair_rsigcmaq(qds, qkey, datakey, bdate=None, edate=None, bbox=None, prefix='CMAQ_', persist=False, verbose=0)[source]
Parameters:
  • qds (xarray.Dataset or str) – If a str, it must be the path to CMAQ file. If an xarray.Dataset, it must have CMAQ structure and: - crs_proj4 added by pyrsig.open_ioapi - optionally, encoding[‘source’] string describing the file

  • qkey (str) – CMAQ variable key (must be in the CMAQ file)

  • datakey (str) – RSIG variable key

  • bdate (datetime) – Starting date time. If None, infer from file.

  • edate (datetime) – Ending date time. If None, infer from file.

  • bbox (tuple) – ll_lon, ll_lat, ur_lon, ur_lat in decimal degrees East and North If bbox is None, it will be inferred from the file.

  • persist (bool) – If True (default: False), save to disk and return output path

  • verbose (int) – Level of verbosity. Negative omits warning about cached paired files.

Returns:

outpath – path to output

Return type:

str

pyrsig.cmaq.save_ioapi(ds, path, format='NETCDF3_CLASSIC', **kwds)[source]

Providing a function to clean-up meta-data for IOAPI.

Parameters:
  • ds (xr.Dataset) – Dataset that should be saved as IOAPI. Dimensions and coordinates must support the conversion.

  • path (str) – Path to save ioapi file

  • format (str) – ‘NETCDF3_CLASSIC’ or ‘NETCDF4_CLASSIC’

  • kwds – Passed to xr.Dataset.to_netcdf

Returns:

Saved file

Return type:

ds.to_netcdf