Skip to content
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 CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Pint Changelog
0.24 (unreleased)
-----------------

- Added dBW, decibel Watts, which is used in RF high power applications
- NumPy 2.0 support
(PR #1985, #1971)
- Implement numpy roll (Related to issue #981)
Expand Down
1 change: 1 addition & 0 deletions pint/default_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ refractive_index_unit = [] = RIU

# Logaritmic Units of dimensionless quantity: [ https://en.wikipedia.org/wiki/Level_(logarithmic_quantity) ]

decibelwatt = watt; logbase: 10; logfactor: 10 = dBW
decibelmilliwatt = 1e-3 watt; logbase: 10; logfactor: 10 = dBm
decibelmicrowatt = 1e-6 watt; logbase: 10; logfactor: 10 = dBu

Expand Down
8 changes: 8 additions & 0 deletions pint/testsuite/test_log_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def test_log_convert(self):
helpers.assert_quantity_almost_equal(
self.Q_(0.0, "dBm"), self.Q_(29.999999999999996, "dBu"), atol=1e-7
)
# ## Test dB to dB units dBm - dBW
# 0 dBW = 1W = 1e3 mW = 30 dBm
helpers.assert_quantity_almost_equal(
self.Q_(0.0, "dBW"), self.Q_(29.999999999999996, "dBm"), atol=1e-7
)

def test_mix_regular_log_units(self):
# Test regular-logarithmic mixed definition, such as dB/km or dB/cm
Expand All @@ -84,6 +89,8 @@ def test_mix_regular_log_units(self):


log_unit_names = [
"decibelwatt",
"dBW",
"decibelmilliwatt",
"dBm",
"decibelmicrowatt",
Expand Down Expand Up @@ -135,6 +142,7 @@ def test_quantity_by_multiplication(module_registry_auto_offset, unit_name, mag)
@pytest.mark.parametrize(
"unit1,unit2",
[
("decibelwatt", "dBW"),
("decibelmilliwatt", "dBm"),
("decibelmicrowatt", "dBu"),
("decibel", "dB"),
Expand Down