JuliaPhysics / JuliaPhysics/Unitful.jl

multiple issues with ratios of logarithmic units

Open
#587 3 comments 0 reactions 0 assignees View on GitHub
logarithmic
Dominant language
Julia
Stars
675
Forks
124
Avg merge
3h 38m
Merged PRs (30d)
1

Description

logarithmic units in the following don't simplify properly, and sometimes dividing a by b works, but it's inverse does not.

See example using power flux densities:

max_PFD = (-100)u"dBm/m^2/MHz"

tx_power = @dB 10W/mW
r = 1000u"km"
tx_gain = 30u"dB"
bandwidth = 10u"MHz"

pfd_on_ground = tx_power * tx_gain / (4π * r^2) / bandwidth

# Units in this first ratio don't simplify properly to dimensionless or plain dB, but the calculation is correct
ratio = max_PFD/pfd_on_ground

# This second ratio is the inverse of the first and should also be dimensionless:
inv_ratio = pfd_on_ground/max_PFD

But it throws a dimension error instead:
julia> inv_ratio = pfd_on_ground/max_PFD
ERROR: DimensionError: m² mW km⁻² and 7.957747154594767e8 mW⁻¹ are not dimensionally compatible.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.