-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes numpydoc for util #969
Changes from 3 commits
11f1202
6449325
a795e11
f1bcd59
6bd10d5
d4f3a6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -72,6 +72,19 @@ def __str__(self): | |||||
)) | ||||||
|
||||||
def int_to_roman(i): | ||||||
""" | ||||||
Convert an integer into its roman numeral representation. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
i: int | ||||||
Integer to be converted into roman numerals | ||||||
|
||||||
Returns | ||||||
------- | ||||||
: str | ||||||
Returns roman numeral representation of i in str format. | ||||||
""" | ||||||
result = [] | ||||||
for integer, numeral in NUMERAL_MAP: | ||||||
count = i // integer | ||||||
|
@@ -81,15 +94,16 @@ def int_to_roman(i): | |||||
|
||||||
def roman_to_int(roman_string): | ||||||
""" | ||||||
|
||||||
Convert a roman numeral into its corresponding integer. | ||||||
Parameters | ||||||
---------- | ||||||
roman_string: str | ||||||
Roman numeral to be converted into an integer | ||||||
|
||||||
Returns | ||||||
------- | ||||||
: int | ||||||
|
||||||
Returns integer representation of roman_string | ||||||
""" | ||||||
|
||||||
NUMERALS_SET = set(list(zip(*NUMERAL_MAP))[1]) | ||||||
|
@@ -108,7 +122,23 @@ def roman_to_int(roman_string): | |||||
|
||||||
def calculate_luminosity(spec_fname, distance, wavelength_column=0, wavelength_unit=u.angstrom, flux_column=1, | ||||||
flux_unit=u.Unit('erg / (Angstrom cm2 s)')): | ||||||
""" | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
spec_fname | ||||||
distance | ||||||
wavelength_column: int, optional | ||||||
wavelength_unit: float | ||||||
flux_column | ||||||
flux_unit | ||||||
|
||||||
Returns | ||||||
------- | ||||||
luminosity.value | ||||||
wavelength.min() | ||||||
wavelength.max() | ||||||
""" | ||||||
#BAD STYLE change to parse quantity | ||||||
distance = u.Unit(distance) | ||||||
|
||||||
|
@@ -121,6 +151,22 @@ def calculate_luminosity(spec_fname, distance, wavelength_column=0, wavelength_u | |||||
|
||||||
|
||||||
def create_synpp_yaml(radial1d_mdl, fname, shell_no=0, lines_db=None): | ||||||
|
||||||
""" | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
radial1d_mdl | ||||||
fname | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file name for the synpp yaml |
||||||
shell | ||||||
lines_db | ||||||
|
||||||
Returns | ||||||
------- | ||||||
|
||||||
|
||||||
""" | ||||||
|
||||||
logger.warning('Currently only works with Si and a special setup') | ||||||
if radial1d_mdl.atom_data.synpp_refs is not None: | ||||||
raise ValueError( | ||||||
|
@@ -184,6 +230,17 @@ def intensity_black_body(nu, T): | |||||
.. math:: | ||||||
I(\\nu, T) = \\frac{2h\\nu^3}{c^2}\frac{1}{e^{h\\nu \\beta_\\textrm{rad}} - 1} | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
nu: int | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that is a float |
||||||
Frequency of a wave of light | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
T: int | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. float |
||||||
Temperature in kelvin | ||||||
|
||||||
Returns | ||||||
------- | ||||||
Intensity: float | ||||||
Approximates the intensity of electromagnetic radiation for the black body | ||||||
""" | ||||||
beta_rad = 1 / (k_B_cgs * T) | ||||||
coefficient = 2 * h_cgs / c_cgs ** 2 | ||||||
|
@@ -193,6 +250,23 @@ def intensity_black_body(nu, T): | |||||
|
||||||
|
||||||
def species_tuple_to_string(species_tuple, roman_numerals=True): | ||||||
""" | ||||||
Parameters | ||||||
---------- | ||||||
species_tuple: tuple | ||||||
Tuple of 2 values indicated atomic number and number of electrons(?) | ||||||
|
||||||
roman_numerals: bool, optional | ||||||
Indicates whether the returned ion number is in roman numerals | ||||||
|
||||||
Returns | ||||||
------- | ||||||
roman_ion_number: str | ||||||
Returns element symbol and | ||||||
ion_number: int | ||||||
Returns element symbol and | ||||||
|
||||||
""" | ||||||
atomic_number, ion_number = species_tuple | ||||||
element_symbol = ATOMIC_NUMBER2SYMBOL[atomic_number] | ||||||
if roman_numerals: | ||||||
|
@@ -203,6 +277,23 @@ def species_tuple_to_string(species_tuple, roman_numerals=True): | |||||
|
||||||
|
||||||
def species_string_to_tuple(species_string): | ||||||
""" | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
species_string | ||||||
|
||||||
Returns | ||||||
---------- | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make the minuses just as long as the Returns or Raises |
||||||
atomic_number | ||||||
ion number | ||||||
|
||||||
Raises | ||||||
---------- | ||||||
AttributeError: | ||||||
ValueError: | ||||||
|
||||||
""" | ||||||
|
||||||
try: | ||||||
element_symbol, ion_number_string = re.match('^(\w+)\s*(\d+)', species_string).groups() | ||||||
|
@@ -230,6 +321,16 @@ def species_string_to_tuple(species_string): | |||||
|
||||||
|
||||||
def parse_quantity(quantity_string): | ||||||
""" | ||||||
Parameters | ||||||
---------- | ||||||
quantity_string | ||||||
|
||||||
Returns | ||||||
------- | ||||||
q | ||||||
|
||||||
""" | ||||||
|
||||||
if not isinstance(quantity_string, str): | ||||||
raise MalformedQuantityError(quantity_string) | ||||||
|
@@ -253,6 +354,20 @@ def parse_quantity(quantity_string): | |||||
|
||||||
|
||||||
def element_symbol2atomic_number(element_string): | ||||||
""" | ||||||
Takes an element symbol and returns its corresponding atomic number | ||||||
Parameters | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newline missing |
||||||
---------- | ||||||
element_string: str | ||||||
Inputted element symbol | ||||||
|
||||||
Returns | ||||||
------- | ||||||
SYMBOL2ATOMIC_NUMBER[reformatted_element_string]: int | ||||||
Returned atomic number | ||||||
|
||||||
|
||||||
""" | ||||||
reformatted_element_string = reformat_element_symbol(element_string) | ||||||
if reformatted_element_string not in SYMBOL2ATOMIC_NUMBER: | ||||||
raise MalformedElementSymbolError(element_string) | ||||||
|
@@ -262,6 +377,19 @@ def element_symbol2atomic_number(element_string): | |||||
def atomic_number2element_symbol(atomic_number): | ||||||
""" | ||||||
Convert atomic number to string symbol | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
atomic_number: int | ||||||
Inputted atomic number | ||||||
|
||||||
|
||||||
Returns | ||||||
------- | ||||||
ATOMIC_NUMBER2SYMBOL[atomic_number]: str | ||||||
Returned corresponding element symbol | ||||||
|
||||||
|
||||||
""" | ||||||
return ATOMIC_NUMBER2SYMBOL[atomic_number] | ||||||
|
||||||
|
@@ -272,11 +400,15 @@ def reformat_element_symbol(element_string): | |||||
|
||||||
Parameters | ||||||
---------- | ||||||
element_symbol: str | ||||||
element_string: str | ||||||
Inputted element symbol | ||||||
|
||||||
|
||||||
Returns | ||||||
------- | ||||||
reformated element symbol | ||||||
reformatted element symbol: str | ||||||
Returned reformatted element symbol | ||||||
|
||||||
""" | ||||||
|
||||||
return element_string[0].upper() + element_string[1:].lower() | ||||||
|
@@ -307,6 +439,17 @@ def quantity_linspace(start, stop, num, **kwargs): | |||||
|
||||||
|
||||||
def convert_abundances_format(fname, delimiter='\s+'): | ||||||
""" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lookup docstring indentation |
||||||
Parameters | ||||||
---------- | ||||||
fname: str | ||||||
delimiter: str, optional | ||||||
|
||||||
Returns | ||||||
------- | ||||||
df: | ||||||
|
||||||
""" | ||||||
df = pd.read_csv(fname, delimiter=delimiter, comment='#', header=None) | ||||||
#Drop shell index column | ||||||
df.drop(df.columns[0], axis=1, inplace=True) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a yaml file that is readable from syn++