Example usage
This document shows a couple of quick examples of how to analyze output from the U-net model. For more detailed information, see the guides on Installation, Data, Running the model, and Analysis.
To use unox in a project:
import unox
print(unox.__version__)
0.1.1
Exploring datasets
This section shows examples of plotting functions which can be used to explore a dataset.
from unox.plotting import plot_var_maps
var_plots = plot_var_maps(
'../datafiles/sample_data/2019u10.nc',
vars = 'u10',
datetime='2019-01-01',
)
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/proplot/__init__.py:6: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources as pkg
/home/mschee/unox/src/unox/HPC/data0/dataset.py:474: UserWarning: (is_ensemble) `dataset` must be a prediction set to check for ensemble members.
warnings.warn(f"(is_ensemble) `dataset` must be a prediction set to check for ensemble members.")
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
from unox.plotting import plot_var_maps
var_plots = plot_var_maps(
'../inputfiles/no2_2019_JFM/no2_2019_JFM.nc',
vars = ['no2', 'no2_tm1', 'no2_s2', 'no2_s2_tm1'],
datetime='2019-01-01',
interval='3M',
)
/home/mschee/unox/src/unox/HPC/data0/dataset.py:474: UserWarning: (is_ensemble) `dataset` must be a prediction set to check for ensemble members.
warnings.warn(f"(is_ensemble) `dataset` must be a prediction set to check for ensemble members.")
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
from unox.plotting import plot_var_maps
var_plots = plot_var_maps(
'no2_example_run',
is_predict=True,
vars = ['nox_pred', 'nox_pred_s2'],
datetime='2019-06-01',
interval='364D',
restrict_lat_lon_to='../datafiles/sample_data/nox_2019_t106_US.nc',
)
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
from unox.plotting import plot_run_analysis
this_plt = plot_run_analysis(
'no2_example_run',
year = 2019,
datetime='2019-03-01',
interval='4M',
restrict_lat_lon_to='../datafiles/sample_data/nox_2019_t106_US.nc',
)
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
Plotting CO
The code not only functions with NOₓ, but also with CO, however only for stage 1 predictions. Here’s an example:
from unox import plotting as uplt
ex_HPC_run = 'co_example_run'
ex_input_set = 'co_sample_input'
restrict_to_this = '../datafiles/sample_data/nox_2019_t106_US.nc'
comp_maps = uplt.plot_stage_comp_maps(
truth_params={'stage':1, 'x_or_y':'y', 'year':ex_year, 'input_set':ex_input_set},
pred_params={'HPC_run':ex_HPC_run, 'year':ex_year},
this_date=ex_date,
var='EmisCO_Total',
avg_over='364D',
restrict_lat_lon_to=restrict_to_this,
clr_bar_scale=0.1,
stage1_only=True,
)
comp_plot = uplt.plot_true_pred_comp(
truth_data={'stage':1, 'x_or_y':'y', 'year':ex_year, 'input_set':ex_input_set},
pred_data={'HPC_run':ex_HPC_run, 'year':ex_year},
hist_params={'bins':100, 'vmax':1000, 'vmin':10},
var='EmisCO_Total',
restrict_lat_lon_to=restrict_to_this,
)
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
/home/mschee/miniconda3/envs/uplt/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:403: UserWarning: The `map_projection` keyword argument is deprecated, use `projection` to instantiate a GeoAxes instead.
warnings.warn("The `map_projection` keyword argument is "
start DOY: 1 end DOY: 364