Skip to content

Commit

Permalink
Merge PR #271 (Allow comparisons of ref & dev w/ different units)
Browse files Browse the repository at this point in the history
This merge brings PR #271 (Fix bug preventing comparison plots of
ref and dev with different units, by @lizziel) into the GCPy 1.4.0
development stream.

This OR removes raising an error if the units do not match.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Oct 26, 2023
2 parents 620d449 + f7ae983 commit 2caafb9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Updated `seaborn` plot style names to conform to the latest matplotlib
- Set `lev:positive` and/or `ilev:positive` properly in `regrid_restart_file.py` and `file_regrid.py`
- Prevent overwriting of `lev` coord in `file_regrid.py` at netCDF write time
- Fixed bug in option to allow different units when making comparison plots

### Removed
- Removed `gchp_is_pre_13_1` arguments & code from benchmarking routines
Expand Down
8 changes: 3 additions & 5 deletions gcpy/plot/compare_single_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,9 @@ def compare_single_level(
if ds_devs[i].units.strip() == "UNITLESS":
ds_devs[i].attrs["units"] = "1"

# Check that units are the same in ref and dev. Will exit with
# an error if do not match and enforce_units is true (default).
if not check_units(ds_refs[i], ds_devs[i]) and enforce_units:
raise ValueError(
'Units in ref and dev must match when enforce_units is True')
# Compare units of ref and dev. The check_units function will throw an
# error if units do not match and enforce_units is True.
check_units(ds_refs[i], ds_devs[i], enforce_units)

# Convert from ppb to ug/m3 if convert_to_ugm3 is passed as true
if convert_to_ugm3:
Expand Down
8 changes: 3 additions & 5 deletions gcpy/plot/compare_zonal_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,9 @@ def compare_zonal_mean(
if ds_devs[i].units.strip() == "UNITLESS":
ds_devs[i].attrs["units"] = "1"

# Check that units are the same in ref and dev. Will exit with
# an error if do not match and enforce_units is true (default).
if not check_units(ds_refs[i], ds_devs[i]) and enforce_units:
raise ValueError(
'Units in ref and dev must match when enforce_units is True')
# Compare units of ref and dev. The check_units function will throw an error
# if the units do not match and enforce_units is True.
check_units(ds_refs[i], ds_devs[i], enforce_units)

# Convert from ppb to ug/m3 if convert_to_ugm3 is passed as true
if convert_to_ugm3:
Expand Down

0 comments on commit 2caafb9

Please sign in to comment.