Skip to content

Commit

Permalink
ENH: Add dBZ as a unit in the registry (#3343)
Browse files Browse the repository at this point in the history
* ENH: Add dBZ as a unit in the registry
  • Loading branch information
mgrover1 committed Jan 11, 2024
1 parent fcd883d commit 45730bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/metpy/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def setup_registry(reg):
'= degreeN')
reg.define('degrees_east = degree = degrees_E = degreesE = degree_east = degree_E '
'= degreeE')
reg.define('dBz = 1e-18 m^3; logbase: 10; logfactor: 10 = dBZ')

# Alias geopotential meters (gpm) to just meters
reg.define('@alias meter = gpm')
Expand Down
4 changes: 3 additions & 1 deletion tests/units/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import pandas as pd
import pytest

from metpy.testing import assert_array_almost_equal, assert_array_equal, assert_nan
from metpy.testing import (assert_almost_equal, assert_array_almost_equal, assert_array_equal,
assert_nan)
from metpy.units import (check_units, concatenate, is_quantity,
pandas_dataframe_to_unit_arrays, units)

Expand Down Expand Up @@ -176,6 +177,7 @@ def test_added_degrees_units():
assert units('degrees_north').to_base_units().units == units.radian
assert units('degrees_east') == units('degrees')
assert units('degrees_east').to_base_units().units == units.radian
assert_almost_equal(0 * units.dBz, 1 * units('mm^6/m^3'))


def test_is_quantity():
Expand Down

0 comments on commit 45730bb

Please sign in to comment.