|
PyNeb
1.1.2
PyNeb Reference Manua
|
Functions | |
| def | bs (x) |
| def | execution_path (filename) |
| def | int_to_roman (input_) |
| def | roman_to_int (input_) |
| def | parseAtom (atom) |
| def | parseAtom2 (atom) |
| def | strExtract |
| def | formatExceptionInfo |
| def | multi_split (s, seps) |
| def | cleanPypicFiles |
| def | getPypicFiles |
| def | revert_seterr (oldsettings) |
| def | quiet_divide (a, b) |
| def | quiet_log10 (a) |
| def | get_reduced |
| def | get_reduced_dic |
| def | addRand |
| def | solve_cvxopt (a, b) |
| def | solve (a, b) |
Variables | |
| cvxopt_ok = True | |
| def pyneb.utils.misc.addRand | ( | N, | |
| list_, | |||
list_errors = None, |
|||
lowlim = None |
|||
| ) |
This function adds MonteCarlo random-gauss values to a list.
Parameters:
N: number of MonteCarlo values to be added
list_: list of input values
list_errors: list of errors associated to the values in list_. The errors are absolutes, the
result will be a gaussian distribution of sigma=list_errors.
If None, the functions adds N time the same values to the list
lowlim: if not None (default), any random-gauss number lower then the lowlim value is set to lowlim.
Usage:
print addRand(3, [1,2,3]) # no errors: no random values, only replicates the values
[1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3]
print addRand(3, [1,20,300], [1, 1, 0.1])
[1, 20, 300,
1.550094377016822, 1.868307356917796, 1.0242090163674675,
19.782857703031276, 19.049474190752157, 21.58680361755194,
299.99810384362934, 300.00753905080154, 299.94052054137694]
| def bs | ( | x | ) |
| def pyneb.utils.misc.cleanPypicFiles | ( | files = None, |
|
all_ = False, |
|||
dir_ = None |
|||
| ) |
Method to clean the directory containing the pypics files.
Parameters:
- files list of files to be removed
- all_ Boolean, is set to True, all the files are deleted from the directory
- dir_ directory from where the files are removed.
If None (default), pn.config.pypic_path is used.
| def pyneb.utils.misc.execution_path | ( | filename | ) |
| def pyneb.utils.misc.formatExceptionInfo | ( | maxTBlevel = 5 | ) |
| def pyneb.utils.misc.get_reduced | ( | N_rand, | |
| a, | |||
value_method = 'original', |
|||
error_method = 'std' |
|||
| ) |
This function returns a tuple of value and error corresponding to an array of values
obtained from a MonteCarlo computation
It takes as argument an array that contains the original value,
followed by N_rand MonteCarlo values.
The relevant value is computed by returning the original value (default), the mean or the median,
depending on "value_method"
The errors are computed by 68% quantiles or standart deviation (Default),
depending on "error_method"
| def pyneb.utils.misc.get_reduced_dic | ( | N_rand, | |
| n_obs_ori, | |||
| dic, | |||
value_method = 'original', |
|||
error_method = 'std', |
|||
abund12 = False |
|||
| ) |
This function returns a dictionary of values (ionic or atomic abundances, temp...) and errors.
It takes as argument a dictionary that is supposed to contains n_obs_ori values from
the original observations, followed (optionaly) by N_rand*n_obs_ori MonteCarlo values.
The new values are computed by returning the original value (default), the mean or the median,
depending on "value_method"
The errors are computed by 68% quantiles or standart deviation (Default), depending on on "error_method"
It also transforms the abundances by number into 12+log10(abundances by number)
| def pyneb.utils.misc.getPypicFiles | ( | dir_ = None | ) |
Return the list of files in the directory.
Parameters:
- dir_ directory from where the files are removed.
If None (default), pn.pypic_path is used.
| def pyneb.utils.misc.int_to_roman | ( | input_ | ) |
Convert an integer to Roman numerals. Examples: >>> int_to_roman(0) Traceback (most recent call last): ValueError: Argument must be between 1 and 3999 >>> int_to_roman(-1) Traceback (most recent call last): ValueError: Argument must be between 1 and 3999 >>> int_to_roman(1.5) Traceback (most recent call last): TypeError: expected integer, got <type 'float'> >>> print int_to_roman(2000) MM >>> print int_to_roman(1999) MCMXCIX
| def pyneb.utils.misc.multi_split | ( | s, | |
| seps | |||
| ) |
| def pyneb.utils.misc.parseAtom | ( | atom | ) |
Parses an atom label into the element and spectrum parts
| def pyneb.utils.misc.parseAtom2 | ( | atom | ) |
Parses an atom label into the element and spectrum parts
| def pyneb.utils.misc.quiet_divide | ( | a, | |
| b | |||
| ) |
This function returns the division of a by b, without any waring in case of b beeing 0.
| def pyneb.utils.misc.quiet_log10 | ( | a | ) |
This function returns the log10 of a, without any waring in case of b beeing 0.
| def pyneb.utils.misc.revert_seterr | ( | oldsettings | ) |
This function revert the options of seterr to a value saved in oldsettings.
Usage:
oldsettings = np.seterr(all='ignore')
to_return = (result - int_ratio) / int_ratio # this will not issue Warning messages
revert_seterr(oldsettings)
Parameters:
oldsettings result of np.seterr(all='ignore')
| def pyneb.utils.misc.roman_to_int | ( | input_ | ) |
Convert a roman numeral to an integer.
>>> r = range(1, 4000)
>>> nums = [int_to_roman(i) for i in r]
>>> ints = [roman_to_int(n) for n in nums]
>>> print r == ints
1
>>> roman_to_int('VVVIV')
Traceback (most recent call last):
...
ValueError: input is not a valid roman numeral: VVVIV
>>> roman_to_int(1)
Traceback (most recent call last):
...
TypeError: expected string, got <type 'int'>
>>> roman_to_int('a')
Traceback (most recent call last):
...
ValueError: input is not a valid roman numeral: A
>>> roman_to_int('IL')
Traceback (most recent call last):
...
ValueError: input is not a valid roman numeral: IL
| def pyneb.utils.misc.solve | ( | a, | |
| b | |||
| ) |
| def pyneb.utils.misc.solve_cvxopt | ( | a, | |
| b | |||
| ) |
| def pyneb.utils.misc.strExtract | ( | text, | |
par1 = None, |
|||
par2 = None |
|||
| ) |
Extract a substring from text (first parameter)
If par1 is a string, the extraction starts after par1,
else if it is an integer, it starts at position par1.
If par 2 is a string, extraction stops at par2,
else if par2 is an integer, extraction stops after par2 characters.
Examples:
strExtract('test123','e','1')
strExtract('test123','st',4)
| cvxopt_ok = True |