SWDatabase
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
Classes | Functions
common.module_toolbox_num Namespace Reference

Classes

class  ToolboxNumError
 

Functions

def row_beg2end
 
def col_beg2end
 
def vec_beg2end
 
def is_sortable
 
def nearest
 
def encadre
 
def interpolation1D
 Interpolate at a given x0 a 1d curve given by its x,y. More...
 
def interpolate
 
def gridpos
 
def polint
 
def cell2grid
 
def grid2cell
 
def gaussian
 Gaussian function. More...
 
def fit_gaussian
 Fit data with a gaussian. More...
 
def fit_gaussian_latitude
 Fit latitudes with a gaussian. More...
 
def fit_gaussian_longitude
 Fit longitudes with a gaussian. More...
 
def relative_error
 Get the relative error between two np.array. More...
 
def almost_equal
 Check if two objects are equals up to the tolint-th decimal. More...
 
def almost_equal_float
 Check if 2 floats are equals up to the tolint-th decimal. More...
 
def almost_equal_tuple
 Check if 2 tuples of floats are equals up to the tolint-th decimal. More...
 
def get_yyyy_mm
 Between 2 dates, return the list of different YYYY/MM there is. More...
 
def draw_normal_plane
 Return the unit normal vector from a given vector. More...
 
def get_angle
 From a $\vec{V} = (V_x,V_y)$ vector, retrieve the oriented angle $(\vec{e_x},\vec{V})$ in degree. More...
 
def normalise_angle_mpi_pi
 Put a degree angle in [-180,180]. More...
 
def mean_longitude
 Compute the mean of 2 longitudes. More...
 
def print_array2D
 Print a 2D array. More...
 
def print_array1D
 Print a 1D array. More...
 
def mean_datetime
 Compute mean datetime of a list of datetimes. More...
 
def compare_dict
 Compare 2 dictionaries. More...
 

Function Documentation

def common.module_toolbox_num.almost_equal (   x,
  y,
  tolint 
)

Check if two objects are equals up to the tolint-th decimal.

Parameters
[in]x,yobjects to be compared. Can be Float, Tuple of floats.
[in]tolintinteger. The number of decimal taken into account.
Returns
boolean

Here is the call graph for this function:

def common.module_toolbox_num.almost_equal_float (   x,
  y,
  tolint 
)

Check if 2 floats are equals up to the tolint-th decimal.

Parameters
[in]x,yfloats to be compared.
[in]tolintinteger. The number of decimal taken into account.
Returns
boolean

Here is the caller graph for this function:

def common.module_toolbox_num.almost_equal_tuple (   x,
  y,
  tolint 
)

Check if 2 tuples of floats are equals up to the tolint-th decimal.

Parameters
[in]x,ytuples to be compared.
[in]tolintinteger. The number of decimal taken into account.
Returns
boolean

Here is the call graph for this function:

Here is the caller graph for this function:

def common.module_toolbox_num.cell2grid (   cells)
From a cell centered coordinate axis (c_i)_{i in [0,N-1]},
compute the grid points coordinates (g_i)_{i in [0,N]}:
g_{i+1} = \frac{c_{i} + c_{i+1}}{2} for all i in [0,N-2]
g_{0} = 2*c_{0}   - g_{1}
g_{N} = 2*c_{N-1} - g_{N-1}
def common.module_toolbox_num.col_beg2end (   j0,
  input_mat 
)
For a matrix, put the columns from 0 to j0-1 (include) at the end
and translate every other columns.
def common.module_toolbox_num.compare_dict (   d1,
  d2 
)

Compare 2 dictionaries.

def common.module_toolbox_num.draw_normal_plane (   dx,
  dy 
)

Return the unit normal vector from a given vector.

Returns
(norm_x,norm_y) normal unit vector
def common.module_toolbox_num.encadre (   items,
  pivot 
)
In a list of object with order relation, find nearest items from pivot.
For a given list (a_i)_{i=1..N} and a given pivot x, return:
[a_{i0}, a{j0}] such that 
a_{i0} is the nearest item from x
a{j0} the element just after x if a_{i0} < x or just before x if a_{i0} > x

Here is the call graph for this function:

def common.module_toolbox_num.fit_gaussian (   xbins,
  ydata 
)

Fit data with a gaussian.

Does not fit the data directly, but the number of point present in some given bins.

Parameters
[in]xbins,:bins of x axis. Lenght M
[in]ydata,:data. Length N (at least 100)
[out]a,:amplitude of the fitted distribution
[out]mean,:mean of the fitted distribution
[out]sigma,:standard deviation of the fitted distribution
[out]perr,:np.array(3). Sqrt(variance) for each parameter

Here is the call graph for this function:

Here is the caller graph for this function:

def common.module_toolbox_num.fit_gaussian_latitude (   latitudes,
  bin_width = 1. 
)

Fit latitudes with a gaussian.

Parameters
[in]latitudes,:np.array
[out]a,mean,sigma,perr

Here is the call graph for this function:

def common.module_toolbox_num.fit_gaussian_longitude (   longitudes,
  bin_width = 1. 
)

Fit longitudes with a gaussian.

Parameters
[in]longitudes,:np.array
[out]a,mean,sigma,perr

Here is the call graph for this function:

def common.module_toolbox_num.gaussian (   x,
  a,
  mean,
  sigma 
)

Gaussian function.

Parameters
[in]x,:np.array for x values
[in]a,:amplitude
[in]mean,:mean
[in]sigma,:standard deviation
[out]gaussianas np.array
def common.module_toolbox_num.get_angle (   vx,
  vy 
)

From a $\vec{V} = (V_x,V_y)$ vector, retrieve the oriented angle $(\vec{e_x},\vec{V})$ in degree.

Returns
oriented angle $(\vec{e_x},\vec{V})$ in degree in [0,360]
def common.module_toolbox_num.get_yyyy_mm (   date1,
  date2 
)

Between 2 dates, return the list of different YYYY/MM there is.

Returns
List of tuple (year,month) in increasing order
def common.module_toolbox_num.grid2cell (   grids)
From a grid centered coordinate axis (g_i)_{i in [0,N]},
compute the cell points coordinates (c_i)_{i in [0,N-1]}:
c_{i} = \frac{g_{i} + g_{i+1}}{2} for all i in [0,N-1]

Here is the caller graph for this function:

def common.module_toolbox_num.gridpos (   x,
  x0 
)
 

Here is the caller graph for this function:

def common.module_toolbox_num.interpolate (   x,
  y,
  f,
  nptx,
  npty,
  x0,
  y0 
)
 

Here is the call graph for this function:

def common.module_toolbox_num.interpolation1D (   x,
  y,
  x0,
  kind = 'linear' 
)

Interpolate at a given x0 a 1d curve given by its x,y.

Parameters
[in]x,yList of x and y values of the curve.
[in]x0Float or List of float where the interpolation is done.
[out]f(x0)Float or List of float of interpolated y.

Here is the call graph for this function:

def common.module_toolbox_num.is_sortable (   obj)
Check if an object has an order relation in Python 2.X or 3.X

Here is the caller graph for this function:

def common.module_toolbox_num.mean_datetime (   dates)

Compute mean datetime of a list of datetimes.

The input list can contains some None value.

def common.module_toolbox_num.mean_longitude (   x,
  y 
)

Compute the mean of 2 longitudes.

If longitide 1 is near from 0 and longitude 2 is near from 360, (x+y)/2 is not correct.

def common.module_toolbox_num.nearest (   items,
  pivot 
)
In a list of object with order relation, find the nearest item from pivot.

Here is the caller graph for this function:

def common.module_toolbox_num.normalise_angle_mpi_pi (   angle)

Put a degree angle in [-180,180].

def common.module_toolbox_num.polint (   xa,
  ya,
  x 
)
 

Here is the caller graph for this function:

def common.module_toolbox_num.print_array1D (   array1D)

Print a 1D array.

def common.module_toolbox_num.print_array2D (   array2D)

Print a 2D array.

def common.module_toolbox_num.relative_error (   x1,
  x2 
)

Get the relative error between two np.array.

def common.module_toolbox_num.row_beg2end (   i0,
  input_mat 
)
For a matrix, put the row from 0 to i0-1 (include) at the end
and translate every other rows.
def common.module_toolbox_num.vec_beg2end (   i0,
  input_vec 
)
For a vector, put the first i0 at the end
and translate every other.