pyCloudy  0.8.33
manage Cloudy photoionization code
pyCloudy::utils::misc Namespace Reference

Classes

class  ImportFromFile

Functions

def execution_path
def sextract
def half_gaussian
def gaussian
def gauss_kern
def blur_image
def Hb_prof
def convol
def save
def restore
def convert_label
def dist_point_line
def points_right_of_line
def points_left_of_line
def points_inside_triangle
def int_to_roman
def roman_to_int
def get_elem_ion
def pyneb2cloudy
def cloudy2pyneb
def convert2RGB
def make_mask
def revert_seterr
def fill_from_file
def write_cols
def read_atm_ascii

Function Documentation

def pyCloudy::utils::misc::blur_image (   im,
  n,
  ny = None 
)
blurs the image by convolving with a gaussian kernel of typical
    size n. The optional keyword argument ny allows for a different
    size in the y direction.
def pyCloudy::utils::misc::cloudy2pyneb (   file_ = 'pyneb2cloudy.txt')
define a dictionary to translate cloudy labels into pyneb atom.lines
def pyCloudy::utils::misc::convert2RGB (   im_R,
  im_G,
  im_B 
)
def pyCloudy::utils::misc::convert_label (   str_)
converts a line in format Cloudy to a line in format pyCloudy
ex: 
convert_label('C  2  1335') is C__2__1335A
convert_label('Ne 3 15.55m') is NE_3_1555M
def pyCloudy::utils::misc::convol (   y,
  kernel 
)
def pyCloudy::utils::misc::dist_point_line (   P,
  P0,
  P1 
)
computing the distance between point x,y and line (x0,y0)->(x1,y1)
def pyCloudy::utils::misc::execution_path (   filename)
def pyCloudy::utils::misc::fill_from_file (   N,
  open_file,
  dtype = np.float64 
)
Read N elements from an already open file and put them to a numpy array.
The elements don't need to be in rectangular form, e.g. the following 10 elements can be read:
1 2 3 4
2 3 4 5
2 4
def pyCloudy::utils::misc::gauss_kern (   size,
  sizey = None 
)
Returns a normalized 2D gauss kernel array for convolutions 
def pyCloudy::utils::misc::gaussian (   x,
  zeta_0 = None,
  sigma = None,
  FWHM = None 
)
Return the value of a gaussian function.
param:
    x
    One of the following parameter must be given:
    zeta_0, sigma or FWHM
def pyCloudy::utils::misc::get_elem_ion (   label)
Split a Cloudy label into elem and ion
def pyCloudy::utils::misc::half_gaussian (   N = 100,
  sigma = 1. 
)
def pyCloudy::utils::misc::Hb_prof (   x,
  zeta_0 
)
The Hbeta profile is sum of 2 blocks of lines (actually 3 + 4 lines)
def pyCloudy::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 pyCloudy::utils::misc::make_mask (   X,
  Y,
  ap_center,
  ap_size,
  seeing = None 
)
def pyCloudy::utils::misc::points_inside_triangle (   x,
  y,
  P0,
  P1,
  P2 
)
Determine if a point is in a triangle
Adapted from http://paulbourke.net/geometry/insidepoly/
param:
    x, y [float] coordinates of the test point
    P1, P2, P3 [list or tupple or array of 3 elements] coordinates of the triangle corners.
return:
    [boolean] True if points (x,y) is/are inside a triangle P0-P1-P2.
def pyCloudy::utils::misc::points_left_of_line (   x,
  y,
  P0,
  P1 
)
Return True if the point (x,y) is left to the line P0-P1
def pyCloudy::utils::misc::points_right_of_line (   x,
  y,
  P0,
  P1 
)
Return True if the point (x,y) is right to the line P0-P1
def pyCloudy::utils::misc::pyneb2cloudy (   file_ = 'pyneb2cloudy.txt',
  with_ = False 
)
define a dictionary to translate pyneb labels, as used in observation files, into Cloudy label
ex: 'N2_6583A': 'N  2  6584A'
the with_ option transform the output into pyCloudy label:
ex: 'Ne3_3869A': 'NE_3__3869A'
def pyCloudy::utils::misc::read_atm_ascii (   ascii_file)
   20060612
   1
   1
   Teff
   1
   110396
   lambda
   1.00000000e+00
F_lambda
2.37160000e+20
   1.070E+05
  43.2662      43.3385      43.4109      43.4834      43.5561      43.6288      43.7017      43.7747      43.8479      43.9211
def pyCloudy::utils::misc::restore (   file_)
Read data saved with save function.
Usage: datos = restore('misdatos.pypic')
def pyCloudy::utils::misc::revert_seterr (   oldsettings)
def pyCloudy::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 pyCloudy::utils::misc::save (   file_,
  args,
  kwargs 
)
Save the value of some data in a file.
Usage: save('misdatos.pypic','a',b=b)
def pyCloudy::utils::misc::sextract (   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 stop at par2, 
else if par2 is an integer, extraction stop after par2 characters.
ex: sextract('test123','e','1')
sextract('test123','st',4)
def pyCloudy::utils::misc::write_cols (   tab,
  N,
  open_file 
)
Write an array into an already open file, using N columns