SimPEG.utils.unpack_widths#
- SimPEG.utils.unpack_widths(value)[source]#
- Unpack a condensed representation of cell widths or time steps. - For a list of numbers, if the same value is repeat or expanded by a constant factor, it may be represented in a condensed form using list of floats and/or tuples. unpack_widths takes a list of floats and/or tuples in condensed form, e.g.: - [ float, (cellSize, numCell), (cellSize, numCell, factor) ] - and expands the representation to a list containing all widths in order. That is: - [ w1, w2, w3, …, wn ] - Parameters
- Returns
- numpy.ndarray
- The unpacked list with all widths in order 
 
 - Examples - Time stepping for time-domain codes can be represented in condensed form, e.g.: - >>> from discretize.utils import unpack_widths >>> dt = [ (1e-5, 10), (1e-4, 4), 1e-3 ] - The above means to take 10 steps at a step width of 1e-5 s and then 4 more at 1e-4 s, and then one step of 1e-3 s. When unpacked, the output is of length 15 and is given by: - >>> unpack_widths(dt) array([1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-05, 1.e-04, 1.e-04, 1.e-04, 1.e-04, 1.e-03]) - Each axis of a tensor mesh can also be defined as a condensed list of floats and/or tuples. When a third number is defined in any tuple, the width value is successively expanded by that factor, e.g.: - >>> dt = [ 6., 8., (10.0, 3), (8.0, 4, 2.) ] >>> unpack_widths(dt) array([ 6., 8., 10., 10., 10., 16., 32., 64., 128.]) 
 
 
