Skip to content

Create propagation_p368.py - #69

Open
fgiovanard wants to merge 3 commits into
bwinkel:masterfrom
fgiovanard:p368
Open

Create propagation_p368.py#69
fgiovanard wants to merge 3 commits into
bwinkel:masterfrom
fgiovanard:p368

Conversation

@fgiovanard

Copy link
Copy Markdown
Collaborator

No description provided.

@bwinkel

bwinkel commented Jan 21, 2025

Copy link
Copy Markdown
Owner

Dear @fgiovanard,

thanks a lot for your first Pull Request! There a a few minor things, which we'll need to fix before merging; see comments.

A general remark, please make a few changes to the formatting. I like to stick to pep8 as much as possible. If you want a quick fix, simply use black to reformat it automatically. I think, you could also simply use this online tool for reformatting.

Let me know if you need help.

@bwinkel

bwinkel commented Jan 21, 2025

Copy link
Copy Markdown
Owner

I forgot to say, please also add a test into the tests subdirectory. (There are plenty of examples about how it's done.)

Comment thread pycraf/pathprof/propagation_p368.py Outdated
Comment thread pycraf/pathprof/propagation_p368.py Outdated

# Data Lookup Function
def findE40(freq, key_ground_term):
"""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstrings require a slightly different format (numpy style). See other functions in pycraf as a reference.

Comment thread pycraf/pathprof/propagation_p368.py Outdated
from astropy import units as u
import scipy.constants
from pycraf import protection

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order for the functions in this module to appear in pycraf, it is required to put them into the so-called slots (__all__ = ['findE40', ...] list at the top of the file. See other pycraf modules. Furthermore, in the __init__.py file in the pathprof directory, you need to add from .propagation_p368 import *.

Comment thread pycraf/pathprof/propagation_p368.py Outdated
}

# Ground types with their respective conductivity and permittivity values
Ground_Types = {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be cleaner to just have the values for sigma and epsilon (stored as integers) instead of the strings? Could add a comment, what they are.

Comment thread pycraf/pathprof/propagation_p368.py Outdated
MIN_VAL, MAX_VAL = 10 * u.kHz, 30 * u.MHz

# Check if the frequency is within the allowed range
if not (MIN_VAL <= freq <= MAX_VAL):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to make sure that input parameters have a certain value range, you should instead use the @utils.ranged_quantity_input decorator. It also checks the units and applies automatic conversion, if required. It also means that you can work without units in the function core, which may be a bit faster. See other modules, how it's done.

Comment thread pycraf/pathprof/propagation_p368.py Outdated
# Compute the ground-wave propagation distance
distance_gw = (1000 * np.power(10, (Eint.value - E_limit.to_value(cnv.dB_uV_m)) / 40) * u.m).to(u.km)

return m_type, d_transition, distance_gw

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably put the following at the end of the file:

if __name__ == '__main__':
    print('This not a standalone python program! Use as module.')

Integrate ITU-R SM.2028-0 / P.368 low-frequency propagation module into pycraf's pathprof package

Refactor findE40, low_prop, and protection_distance functions for computing protection distance between inductive systems and radio services below 30 MHz
Vectorize field/distance maths using ranged_quantity_input to handle arrays in a single call
Fix N×N broadcasting bug in regime selection using np.choose, restoring correct (N,) output shape
Correct Table 2 permittivity for average-salinity seawater (70 → 80) per ITU Handbook on Ground Wave Propagation (2014)
Add test suite with 10 cases, including vectorized-shape regression guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants