Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add dBZ as a unit in the registry #3343

Merged
merged 6 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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