Skip to content

Conversation

@fgiovanard
Copy link
Collaborator

No description provided.

@bwinkel
Copy link
Owner

bwinkel commented Jan 21, 2025

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
Copy link
Owner

bwinkel commented Jan 21, 2025

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


# Data Lookup Function
def findE40(freq, key_ground_term):
"""
Copy link
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.

from astropy import units as u
import scipy.constants
from pycraf import protection

Copy link
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 *.

}

# Ground types with their respective conductivity and permittivity values
Ground_Types = {
Copy link
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.

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
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.

# 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
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.')

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