Skip to content
Open
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
781957f
Pkg by pkg
christinaholtNOAA Aug 22, 2025
cc75b2c
Adding cfgrib entries to default_specs.yml
christinaholtNOAA Oct 15, 2025
6626b01
A few more cfgrib entries.
christinaholtNOAA Oct 15, 2025
b954aa0
Best effort with RRFS pressure level file.
christinaholtNOAA Oct 15, 2025
cea64b5
Can plot t2m field.
christinaholtNOAA Oct 15, 2025
9698269
Tested all graphics that show up on web for RRFS.
christinaholtNOAA Oct 17, 2025
51e962f
All complete. Working through diffs in graphics.
christinaholtNOAA Oct 20, 2025
24069a6
Matching all RRFS/HRRR graphics.
christinaholtNOAA Oct 21, 2025
413b5b1
Adding some tooling for testing.
christinaholtNOAA Oct 21, 2025
30b6cb4
Formatting existing code.
christinaholtNOAA Oct 21, 2025
fdc0624
Executable.
christinaholtNOAA Oct 21, 2025
f87eb13
Partially done formatting and linting.
christinaholtNOAA Oct 21, 2025
df1da6d
Fully linted.
christinaholtNOAA Oct 22, 2025
48617df
WIP with mypy.
christinaholtNOAA Oct 22, 2025
ffc321a
WIP with mypy
christinaholtNOAA Oct 23, 2025
717686a
mypy done!
christinaholtNOAA Oct 23, 2025
85fe1f9
Passing all tests that still exist.
christinaholtNOAA Oct 24, 2025
fbc8ba1
Conversions fully tested.
christinaholtNOAA Oct 24, 2025
ef756c1
specs.py tested.
christinaholtNOAA Oct 24, 2025
5b52c34
Simplified and unittested gribfile.py
christinaholtNOAA Oct 24, 2025
c5b4b30
WIP testing gribdata
christinaholtNOAA Oct 24, 2025
da861e4
WIP testing gribdata
christinaholtNOAA Oct 25, 2025
145ba3e
WIP finished uppdata class.
christinaholtNOAA Oct 26, 2025
3daa75f
WIP testings gribdata
christinaholtNOAA Oct 27, 2025
6f75a5c
gribdata tested!
christinaholtNOAA Oct 28, 2025
d364554
Figure_builders tested.
christinaholtNOAA Oct 30, 2025
9d5647d
Probably should add the tests.
christinaholtNOAA Oct 30, 2025
c691a64
WIP for utils tests.
christinaholtNOAA Oct 31, 2025
f5b9676
utils tested.
christinaholtNOAA Nov 4, 2025
dc58711
Runs graphics the same again.
christinaholtNOAA Nov 5, 2025
2dbc2a5
Cleanup data and add environment management.
christinaholtNOAA Nov 5, 2025
0fc45a8
Passing all tests.
christinaholtNOAA Nov 5, 2025
87608c9
Configure Git LFS for tracking data files.
christinaholtNOAA Nov 5, 2025
4471c0c
Updates needed for portability.
christinaholtNOAA Nov 6, 2025
e26fe2b
All HRRR AK images completed.
christinaholtNOAA Nov 6, 2025
cfcb4ec
Generalize forecast lead times in default specs.
christinaholtNOAA Nov 6, 2025
33d21e1
Fix wind barbs.
christinaholtNOAA Nov 6, 2025
0152ca9
WIP RAP.
christinaholtNOAA Nov 7, 2025
487cad3
Works for SkewTs.
christinaholtNOAA Nov 17, 2025
eecbeab
Passing tests.
christinaholtNOAA Nov 17, 2025
d9eca5b
All current tests passing.
christinaholtNOAA Nov 18, 2025
f945a6b
Speedup unittests to ~1 min.
christinaholtNOAA Nov 19, 2025
6a89ede
Tests and maps pass. SkewTs need some speed work.
christinaholtNOAA Nov 19, 2025
e8523a1
Okay, NOW the tests pass.
christinaholtNOAA Nov 19, 2025
6a2dbcb
30s skewts.
christinaholtNOAA Nov 20, 2025
22c301e
Remove errant pylint directives.
christinaholtNOAA Nov 20, 2025
af7c49e
Open file into single datastructure.
christinaholtNOAA Nov 21, 2025
f1b4204
Open the file only once for most cases.
christinaholtNOAA Nov 25, 2025
78a0ca7
Merge branch 'cfgrib' of https://github.com/NOAA-GSL/pygraf into cfgrib
christinaholtNOAA Dec 1, 2025
4a3d789
small fixes
christinaholtNOAA Dec 1, 2025
ca93e25
Merge remote-tracking branch 'origin/main' into cfgrib
christinaholtNOAA Dec 1, 2025
deac2bc
Changes needed from self review.
christinaholtNOAA Dec 2, 2025
fdef24d
Need to install the dev packages.
christinaholtNOAA Dec 2, 2025
1c9b054
Activate mamba?
christinaholtNOAA Dec 2, 2025
0eda1c8
Try again.
christinaholtNOAA Dec 2, 2025
cf13c58
Try again
christinaholtNOAA Dec 2, 2025
c6243c5
Try again
christinaholtNOAA Dec 2, 2025
3be841f
Let's try miniforge
christinaholtNOAA Dec 2, 2025
590fc82
Miniforge worked! Activate env and use for hrrr tests
christinaholtNOAA Dec 2, 2025
2825512
Refine test filtering.
christinaholtNOAA Dec 2, 2025
e457778
Run this test with more procs and fewer lead times.
christinaholtNOAA Dec 2, 2025
b95a7b7
Verbose
christinaholtNOAA Dec 3, 2025
b6e6bb7
MORE verbose
christinaholtNOAA Dec 3, 2025
7689e6e
Try again.
christinaholtNOAA Dec 3, 2025
f12506a
Only one map.
christinaholtNOAA Dec 3, 2025
e97c5a3
Changes discussed in person at review.
christinaholtNOAA Dec 3, 2025
dc75054
Updating to newest python solvable.
christinaholtNOAA Dec 4, 2025
c5eb8c3
Pin miniforge version.
christinaholtNOAA Dec 4, 2025
6dc0421
Ignore future warnings from cfgrib.
christinaholtNOAA Dec 4, 2025
1f5a94b
Update the pattern for str | None = "default".
christinaholtNOAA Dec 4, 2025
8352b46
_kwargs instead of noqa.
christinaholtNOAA Dec 4, 2025
81d809d
Suggested changes from pr.
christinaholtNOAA Dec 4, 2025
5baea8b
One more parent.
christinaholtNOAA Dec 4, 2025
bf0a2a5
Apply suggestions from code review
christinaholtNOAA Dec 4, 2025
bb9dc75
Apply suggested reduction of suppressors.
christinaholtNOAA Dec 4, 2025
e36d4f0
Merge branch 'cfgrib' of https://github.com/NOAA-GSL/pygraf into cfgrib
christinaholtNOAA Dec 4, 2025
233f946
Updating numeric_level to use regex.
christinaholtNOAA Dec 5, 2025
776ba87
Use native zipfile instead of subprocess.
christinaholtNOAA Dec 8, 2025
85fc4a3
More suggested changes.
christinaholtNOAA Dec 8, 2025
7466dfd
Apply suggestions from code review
christinaholtNOAA Dec 8, 2025
1f30829
pragma: no cover with 100% coverage requirement.
christinaholtNOAA Dec 8, 2025
6400807
Merge branch 'cfgrib' of https://github.com/NOAA-GSL/pygraf into cfgrib
christinaholtNOAA Dec 8, 2025
f6dd1f5
A few changes I missed on GH.
christinaholtNOAA Dec 8, 2025
2946044
Renaming.
christinaholtNOAA Dec 8, 2025
0e9cf27
A few more coverage statements.
christinaholtNOAA Dec 9, 2025
593ab17
Missed one more block.
christinaholtNOAA Dec 9, 2025
2083ce8
Add backend args for open_datasets.
christinaholtNOAA Jan 7, 2026
5f8c287
WIP Debugging CAR and HI runs.
christinaholtNOAA Jan 14, 2026
6335b16
Testing with all.
christinaholtNOAA Jan 15, 2026
ccdd977
Lint and test.
christinaholtNOAA Jan 15, 2026
fed4606
Adding support for regional mpas.
christinaholtNOAA Jan 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tests/data/wrfnat_hrconus_16.grib2 filter=lfs diff=lfs merge=lfs -text
tests/data/wrfprs_hrconus_16.grib2 filter=lfs diff=lfs merge=lfs -text
tests/data/wrf* filter=lfs diff=lfs merge=lfs -text
21 changes: 10 additions & 11 deletions .github/workflows/graphics_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
shell: bash -el {0}
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v6
with:
lfs: true
- name: Install Micromamba with pygraf environment
uses: mamba-org/setup-micromamba@v1
- name: Install Miniforge with pygraf environment
uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment.yml
cache-downloads: true
cache-environment: true
- name: Lint code
run: find . -type f -name "*.py" | xargs pylint
shell: bash -el {0}
miniforge-version: 25.11.0-0
- name: Install dev pkgs
run: make devenv
- name: Test code
run: python -m pytest --nat-file tests/data/wrfnat_hrconus_07.grib2 --prs-file tests/data/wrfprs_hrconus_07.grib2 --ignore=tests/test_hrrr_maps.py
shell: bash -el {0}
run: |
conda activate pygraf
make test
54 changes: 0 additions & 54 deletions .github/workflows/hrrr_maps_tests.yml

This file was deleted.

30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
TARGETS = devenv env format lint test typecheck unittest
DEVPKGS = $(shell cat devpkgs)
ENVNAME = pygraf

.PHONY: $(TARGETS)


devenv: env
mamba install -y -n $(ENVNAME) $(DEVPKGS)

env:
mamba env create -y -f environment.yml

format:
@./format

lint:
ruff check .

test: lint typecheck unittest

typecheck:
mypy --install-types --non-interactive .

unittest:
pytest --cov -k "not hrrr_maps" -n 4 .

memtest:
pytest --memray -k "not hrrr" .

76 changes: 68 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# ADB Graphics Creation for UPP Model Output

> Note: This repository is under heavy development. Use at your own risk!

This repository houses a Python-based implementation of the graphics package
that is responsible for generating maps for the RAP/HRRR/FV3/RRFS data. It has
replaced NCL as the real-time graphics creation package at NOAA GSL for maps and
Expand Down Expand Up @@ -40,10 +38,30 @@ activate this environment, do the following:

```
module use -a /contrib/miniconda3/modulefiles
module load miniconda3
module load miniconda3/25.11.0
conda activate pygraf
```

This environment contains the necessary develepment packages.

## Installing with conda

Pygraf comes with an environment.yml file for use with any conda installation. Ensure the conda base
environment is activated, and run the following command to create a `pygraf` envirionment suitable
for creating graphics:

```
cd pygraf
make env
```

For developers who want to run the test suite before contributing new changes to the repository,
additional development packages are required. To install those, run:

```
cd pygraf
make devenv
```

## Stage data

Expand Down Expand Up @@ -143,7 +161,7 @@ python create_graphics.py \
--tiles full,ATL,CA-NV,CentralCA

```
NOTE: The graphics already run as a workflow step in the RRFS Retros! They may be
> NOTE: The graphics already run as a workflow step in the RRFS Retros! They may be
zipped by default, so you can unzip those files to see your images on disk.

### Creating Skew-T Diagrams
Expand Down Expand Up @@ -274,16 +292,58 @@ guidelines:
- All code must pass tests, and tests must be updated to accommodate new code.
- Style beyond linting:
- Alphabetize lists (anywhere another order is not more obvious to everyone)
- A single white space line before and after comments.
- A single white space after each method/function. Two after classes.
- Lists are maintained with each item on a single line followed by a comma,
even the last item.

This repository is using a minor variation on GitLab flow, requiring new work be
contributed via Pull Request from a branch with reviewers (required). Releases
will be handled with tags (as opposed to branches, in the original GitLab flow),
and will be marked as versions with v[major].[minor].[update].


# Running Tests

GitHub Actions is configured to run several code quality checks, including linting, formatting, and
sorting with `ruff`, type checking with `mypy`, and unit tests with `pytest`. To perform the same
checks locally, developers can run:

```
(pygraf) $ make format && make test
```

# Working with ecCodes for grib2

Two command line utilities are available in the conda environment that will help navigate the
ecCodes interpretation of a grib2 file. `grib_ls` gives a single-line record listing of the entire file by
default, while `grib_dump` provides all the metadata for each record.

Documentation is available from ECMWF:
* https://confluence.ecmwf.int/display/ECC/grib_ls
* https://confluence.ecmwf.int/display/ECC/grib_dump


There are many examples in the documentation, but here are a couple that could help with pygraf
specifically.

Show the common `pygraf` parameters for the 6th record:
```
$ grib_ls -p shortName,parameterNumber,typeOfLevel,stepType,level -w count=6 hrrr.t05z.wrfnatf08.grib2
hrrr.t05z.wrfnatf08.grib2
shortName parameterNumber typeOfLevel stepType level
grle 32 hybrid instant 1
```

The `count` parameter is nice to use in conjunction with `wgrib2` output where that tool may show
the information needed to identify a variable where the `shortName` from ecCodes may be "unknown".

To see all available information from that record:

```
grib_dump -w count=6 hrrr.t05z.wrfnatf08.grib2
```

> NOTE: When using the `-w` flag with items other than `count`, multiple records may be included in
the output.


# Contact

| Name | Email |
Expand Down
100 changes: 50 additions & 50 deletions adb_graphics/conversions.py
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
# pylint: disable=unused-argument,invalid-name
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no significant changes here, only those related to typing, formatting, and linting.

'''
"""
This module contains functions for converting the units of a field. The
interface requires a single atmospheric field in a Numpy array, and returns the
converted values as output.
'''
"""

import numpy as np
from numpy import ndarray
from xarray import DataArray
from xarray.ufuncs import sqrt, square

def k_to_c(field, **kwargs):

''' Conversion from Kelvin to Celsius '''
def k_to_c(field: ndarray, **_kwargs):
"""Conversion from Kelvin to Celsius."""

return field - 273.15

def k_to_f(field, **kwargs):

''' Conversion from Kelvin to Farenheit '''
def k_to_f(field: ndarray, **_kwargs):
"""Conversion from Kelvin to Farenheit."""
return (field - 273.15) * 9 / 5 + 32

return (field - 273.15) * 9/5 + 32

def kgm2_to_in(field, **kwargs):

''' Conversion from kg per m^2 to inches '''
def kgm2_to_in(field: ndarray, **_kwargs):
"""Conversion from kg per m^2 to inches."""

return field * 0.03937

def magnitude(a, b, **kwargs):

''' Return the magnitude of vector components '''
def magnitude(a: DataArray, b: DataArray, **_kwargs) -> DataArray:
"""Return the magnitude of vector components."""

return np.sqrt(np.square(a) + np.square(b))
return DataArray(sqrt(square(a) + square(b)))

def m_to_dm(field, **kwargs):

''' Conversion from meters to decameters '''
def m_to_dm(field: ndarray, **_kwargs):
"""Conversion from meters to decameters."""

return field / 10.
return field / 10.0

def m_to_in(field, **kwargs):

''' Conversion from meters to inches '''
def m_to_in(field: ndarray, **_kwargs):
"""Conversion from meters to inches."""

return field * 39.3701

def m_to_kft(field, **kwargs):

''' Conversion from meters to kilofeet '''
def m_to_kft(field: ndarray, **_kwargs):
"""Conversion from meters to kilofeet."""

return field / 304.8

def m_to_mi(field, **kwargs):

''' Conversion from meters to miles '''
def m_to_mi(field: ndarray, **_kwargs):
"""Conversion from meters to miles."""
return field / 1609.344

def ms_to_kt(field, **kwargs):

''' Conversion from m s-1 to knots '''
def ms_to_kt(field: ndarray, **_kwargs):
"""Conversion from m s-1 to knots."""

return field * 1.9438

def pa_to_hpa(field, **kwargs):

''' Conversion from Pascals to hectopascals '''
def pa_to_hpa(field: ndarray, **_kwargs):
"""Conversion from Pascals to hectopascals."""

return field / 100.
return field / 100.0

def percent(field, **kwargs):

''' Conversion from values between 0 - 1 to percent '''
def percent(field: ndarray, **_kwargs):
"""Conversion from values between 0 - 1 to percent."""

return field * 100.
return field * 100.0

def to_micro(field, **kwargs):

''' Convert field to micro '''
def sden_to_slr(field: ndarray, **_kwargs):
"""Convert snow density (kg m-3) to snow-liquid ratio."""

return field * 1E6
return 1000.0 / field

def to_micrograms_per_m3(field, **kwargs):

''' Convert field to micrograms per cubic meter '''
def to_micro(field: ndarray, **_kwargs):
"""Convert field to micro."""

return field * 1E9
return field * 1e6

def vvel_scale(field, **kwargs):

''' Scale vertical velocity for plotting '''
def to_micrograms_per_m3(field: ndarray, **_kwargs):
"""Convert field to micrograms per cubic meter."""

return field * -10
return field * 1e9

def vort_scale(field, **kwargs):

''' Scale vorticity for plotting '''
def vvel_scale(field: ndarray, **_kwargs):
"""Scale vertical velocity for plotting."""

return field / 1E-05
return field * -10

def weasd_to_1hsnw(field, **kwargs):

''' Conversion from snow wter equiv to snow (10:1 ratio) '''
def vort_scale(field: ndarray, **_kwargs):
"""Scale vorticity for plotting."""

return field * 10.
return field / 1e-05

def sden_to_slr(field, **kwargs):

''' Convert snow density (kg m-3) to snow-liquid ratio '''
def weasd_to_1hsnw(field: ndarray, **_kwargs):
"""Conversion from snow water equiv to snow (10:1 ratio)."""

return 1000. / field
return field * 10.0
Loading
Loading