sandy.shared module
Collection of utilities, functions and classes that are requetsed in all code components.
- sandy.shared.pad_from_beginning(vals, maxlen=None, value=0.0, axis=0)
 Convert list of arrays into matrix by backward padding. .. note:: this function can be used to put cross sections into one matrix
by adding zeros before the first value of threshold reactions.
- Parameters:
 - valsiterable of arrays/lists
 values of the matrix
- maxlenint, optional, default is None
 length to fill with padding. If not given, use the maximum length of the arrays in vals .. important:: if given, maxlen should be
maxlen <= max([len(v) for v in vals])
- valuefloat, optional, default is 0.
 value used for padding
- axisint, optional, either 0 or 1, default is 0
 axis along whihc the arrays should be positioned. 0 means rows, 1 means columns
- Returns:
 - numpy.array
 2D numpy.array with shape (len(vals), maxlen) if axis=0 and (maxlen, len(vals)) if axis=1
- Raises:
 - ValueError
 if axis is neither 0 nor 1
- ValueError
 if maxlen <= max([len(v) for v in vals])
- sandy.shared.pad_from_beginning_fast(vals, maxlen)
 Like aleph.utils.pad_from_beginning but faster. Keyword arguments axis and values take the default options. .. note:: this function can be used to put cross sections into one matrix
by adding zeros before the first value of threshold reactions.
- Parameters:
 - valsiterable of arrays/lists
 values of the matrix
- maxlenint
 length to fill with padding.
- Returns:
 - numpy.array
 2D numpy.array with shape (len(vals), maxlen)
- sandy.shared.uniform_loggrid(xmin, xmax, npoints=100)
 Given lower and upper limits, produce a grid with a number of points npoints that define equivalent intervals in log scale.
- Parameters:
 - xminfloat
 lower bound of the grid structure
- xmaxfloat
 upper bound of the grid structure
- npointsint, optional, default 100
 
- Returns:
 - numpy array
 grid equally spaced in logarithmic scale
Examples
>>> uniform_loggrid(1e-5, 1e7, 25) array([1.00000000e-05, 3.16227766e-05, 1.00000000e-04, 3.16227766e-04, 1.00000000e-03, 3.16227766e-03, 1.00000000e-02, 3.16227766e-02, 1.00000000e-01, 3.16227766e-01, 1.00000000e+00, 3.16227766e+00, 1.00000000e+01, 3.16227766e+01, 1.00000000e+02, 3.16227766e+02, 1.00000000e+03, 3.16227766e+03, 1.00000000e+04, 3.16227766e+04, 1.00000000e+05, 3.16227766e+05, 1.00000000e+06, 3.16227766e+06, 1.00000000e+07])