Skip to content
Open
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
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"python.testing.pytestArgs": [
"pycraf"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python-envs.defaultEnvManager": "ms-python.python:conda",
"python-envs.defaultPackageManager": "ms-python.python:conda"
}
25 changes: 0 additions & 25 deletions licenses/LICENSE_ASTROPY_PACKAGE_TEMPLATE.rst

This file was deleted.

23 changes: 23 additions & 0 deletions pycraf/conversions/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'dB_mW_MHz', 'dBm_MHz', # this is often used in engineering (dBm/MHz)
'dB_1_m',
'dB_uV_m',
'dB_uA_m',
]

__all__ = [
Expand Down Expand Up @@ -57,6 +58,7 @@
dBm = dB_mW = apu.dB(apu.mW)
dBm_MHz = dB_mW_MHz = apu.dB(apu.mW / apu.MHz)
dB_uV_m = apu.dB(apu.uV ** 2 / apu.m ** 2)
dB_uA_m = apu.dB(apu.uA ** 2 / apu.m ** 2)
dB_1_m = apu.dB(1. / apu.m) # for antenna factor

# Astropy.unit equivalency between linear and logscale field strength
Expand Down Expand Up @@ -94,8 +96,29 @@ def efield_equivalency():
)]


def magfield_equivalency():
'''
`~astropy.units` equivalency to handle log-scale magnetic field units.

For magnetic fields, the Decibel scale is define via the amplitude
of the field squared, :math:`{\\vert\\vec B\\vert}^2` which is
proportional to the power.

Returns
-------
equivalency : list
The returned list contains one tuple with the equivalency.
'''
return [(
apu.uA / apu.m,
(apu.uA / apu.m) ** 2,
lambda x: x ** 2,
lambda x: x ** 0.5
)]

# apu.add_enabled_equivalencies(apu.logarithmic())
apu.add_enabled_equivalencies(efield_equivalency())
apu.add_enabled_equivalencies(magfield_equivalency())

# define some useful constants
MU0_VALUE = 1.2566370614359173e-06
Expand Down
5 changes: 5 additions & 0 deletions pycraf/conversions/tests/test_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def test_db_scales(self):
_val
)

assert_quantity_allclose(
(_db * cnv.dB_uA_m).to((apu.uA / apu.m) ** 2).value,
_val
)

def test_constants(self):

assert_quantity_allclose(
Expand Down
1 change: 1 addition & 0 deletions pycraf/pathprof/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .bel import *
from .imt import *
from .srtm import *
from .low_freq_propagation import *

_clutter_table = '''
+-------+-------------------+------+------+
Expand Down
Loading