Interpolates global chemistry fields for use with WRF-CHEM
Project description
Interpolator for WRF-CHEM
Interpolator for WRF-CHEM is a preprocessing application for using global chemistry model fields with WRF-CHEM. It interpolates the global chemistry model fields to the WRF-CHEM grid and vertical levels. Think of it like WPS but for chemistry fields.
Some features:
- Interpolates 3D fields
- Can do species/size bin mapping through linear combinations of source fields
- Potentially support many global models (currently supports CAMS EAC4)
The application is written in Python and is meant to be used a command-line tool. Some potential limitations:
- The application currently assumes that fields are mixing ratios.
- The global model fields should be on a regular lat-lon grid.
Installation
The application is available on PyPI and can be installed using pip:
pip install interpolator-for-wrfchem
Usage
The workflow for using the interpolator is as follows:
- Use WPS and
real.exeas usual to generate thewrfinputandwrfbdyfiles. - Download global chemistry model fields (e.g. CAMS EAC4 or global forecasts) for the same time period as the WRF simulation.
- Run the interpolator to interpolate the global chemistry model fields to the WRF-CHEM grid and vertical levels.
- Run WRF-CHEM.
The interpolator will update wrfinput and wrfbdy files to include the chemistry information.
The interpolator is a command-line tool and can be run as follows:
interpolator-for-wrfchem <global model name> <global model data path> <species map path> <wrfinput path>
The wrfinput and wrfbdy files WILL BE MODIFIED! The global model name can be one of the following:
cams_eac4: CAMS EAC4 data (w/ 60 vertical levels)cams_global_forecasts: CAMS global forecasts (w/ 137 vertical levels)wrfout: Use a WRF forecast as the source model. The domain of the forecasts should cover the entirety of the domain ofwrfinput.
You can add support for other global models by implementing a subclass of GlobalModel, check the global_models/prototype.py file for details.
There are some optional flags:
--wrfbdy=: Path to thewrfbdy_d01file, if not provided, the boundary is not updated.--copy-icbc: Make a backup of thewrfinputandwrfbdyfiles before updating them.--no-ic: Do not update thewrfinput. You must nonetheless provide the path to thewrfinputfile as it is required to read some information.--diagnostics: Store some diagnostic information in thediag_cams_interp.ncfile.
When you use nested domains, you can run the application multiple times, each time pointing to a different wrfinput file. You can omit the wrfbdy file when running the application for the nested domains' wrfinput files.
If you need to update wrfbdy files for the future without touching wrfinput (e.g. for a cycling run), point to a correct wrfinput file (correct means it's the same model grid and configuration) and use the --no-ic flag.
Species mapping
In many cases, the available fields of the global model do not directly correspond to the ones used by the chemistry/dust scheme you want to use in WRF-CHEM. For example, you might have dust concentrations available in different size bins. The application supports "species mapping", through which the WRF-CHEM fields are created through a linear combination of global model fields, after interpolation.
Detailed description of the species file format is available in species_maps.md.
Use in other projects
To automate use of the interpolator by using it as a library in your project, it is recommended to use the do_initial_conditions() and do_boundary_conditions() functions from the interpolator_for_wrfchem module. Provided with the correct arguments, these functions will mirror the command-line behavior of the interpolator. Exact details of how to set up all the magic objects required by these functions are available inside the main CLI entrypoint (file interpolator_for_wrfchem/__init__.py, main() function).
An example usage would be:
# Contains information on how to map from global model species to WRF-CHEM species
mapping = SpeciesMap(mapping_path)
# Represents a wrfinput file. The original netCDF file can be accessed as a
# `netcdf4.Dataset` in the `WRFInput.nc_file` attribute.
wrf = WRFInput(wrfinput_path)
# You can get the main coordinates in dataset form by calling wrf.get_dataset()
wrf_ds = wrf.get_dataset()
# Represents a set of global model files. Available choices in `global_models/__init__.py`.
global_model = CAMS_ADSBeta_Base(input_files, mapping.required_source_species)
global_model_ds = global_model.get_dataset(wrf.time)
# Do initial condition interpolation and MODIFY wrfinput_d01
do_initial_conditions(wrf, wrf_ds, global_model_ds, mapping, diagnostics)
wrf.close()
# Do boundary condition interpolation and MODIFY wrfbdy_d01
do_boundary_conditions(wrfbdy, wrf_ds, global_model_ds, mapping)
The interpolation routines are available inside the interpolation.py file and are applied to xarray Datasets, so they might be useful in other projects as well.
License
The interpolator is licensed under the MIT License. See LICENSE for more information. Please cite the project if you use it for your research!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interpolator_for_wrfchem-1.7.0.tar.gz.
File metadata
- Download URL: interpolator_for_wrfchem-1.7.0.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0def6b992e243e5d58a9720eb07c264f927f7f04f08c01b06fc15fd44950a1de
|
|
| MD5 |
84823823d234e6d72b8876fa2aaeaf05
|
|
| BLAKE2b-256 |
418043e72b9e77a1008fc126397be40c3c6d98fc42ec0c0924a3711d4f7e0fd6
|
Provenance
The following attestation bundles were made for interpolator_for_wrfchem-1.7.0.tar.gz:
Publisher:
publish.yml on NOA-ReACT/interpolator_for_wrfchem
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
interpolator_for_wrfchem-1.7.0.tar.gz -
Subject digest:
0def6b992e243e5d58a9720eb07c264f927f7f04f08c01b06fc15fd44950a1de - Sigstore transparency entry: 1172222519
- Sigstore integration time:
-
Permalink:
NOA-ReACT/interpolator_for_wrfchem@891c14a6fb5448c1b9b5d552950da380e8a9126d -
Branch / Tag:
refs/tags/v1.7.0 - Owner: https://github.com/NOA-ReACT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@891c14a6fb5448c1b9b5d552950da380e8a9126d -
Trigger Event:
release
-
Statement type:
File details
Details for the file interpolator_for_wrfchem-1.7.0-py3-none-any.whl.
File metadata
- Download URL: interpolator_for_wrfchem-1.7.0-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97194faec3bc2663244f7dfeb33af5cd82888c69dec949b54bd2abd45f241643
|
|
| MD5 |
2a7a546f3249d62381af233b3e8d4085
|
|
| BLAKE2b-256 |
c44296d06c7523e6ad9eaf974505d10527e3559cb7af5d393a305fbfb9f02729
|
Provenance
The following attestation bundles were made for interpolator_for_wrfchem-1.7.0-py3-none-any.whl:
Publisher:
publish.yml on NOA-ReACT/interpolator_for_wrfchem
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
interpolator_for_wrfchem-1.7.0-py3-none-any.whl -
Subject digest:
97194faec3bc2663244f7dfeb33af5cd82888c69dec949b54bd2abd45f241643 - Sigstore transparency entry: 1172222524
- Sigstore integration time:
-
Permalink:
NOA-ReACT/interpolator_for_wrfchem@891c14a6fb5448c1b9b5d552950da380e8a9126d -
Branch / Tag:
refs/tags/v1.7.0 - Owner: https://github.com/NOA-ReACT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@891c14a6fb5448c1b9b5d552950da380e8a9126d -
Trigger Event:
release
-
Statement type: