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.2

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 "
_images/01631b89e7ce6f1ec97cbbc0a5136546e194f6cdb67d38c0c3df22b7f424d77b.png
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 "
_images/63c786d208722df6ec2fb5d1be470de1f06be4da6d851555065279f93b44ab19.png
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 "
_images/d06f7939f4002a2c25150c881d34b15d9b85bb389dd9887dfe998a81302b3fa2.png
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 "
_images/aad8bed8e158268951c3785fd159b59171c9edfacd2a7b5f38f9488a082eeced.png

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
_images/3f5fe200ef6e9c3a3c4a5baeb57646db4034d0783ecf2e855d64735b9f5400f4.png _images/e9c64fc4f81704fefa011531b16b13f383eb9563e4a034612e8e5365e9581d55.png