analysisbase provides general purpose analysis functions and classes used by several nmrglue.analysis modules
This modules is imported as nmrglue.analysisbase and can be called as such.
These functions are typically not used directly by users. They are called by high level functions.
Determind the names of a records array provided lineshape classes,
Parameters:
Returns list of records array names (strings).
Find the limits which outline the provided list of points
Parameters:
Returns (min,max):
Create a set of slice objects given list of min,max limits
Parameters:
Returns: list of slices which will return points between limits.
Create a tuple of min,max limits from a set of slices
Parameters:
Returns: Tuple of minimum and maximum indices
Convert peakpick.pick output to linesh.fit_NDregion input
Parameters:
Return: guesses,amp_guesses
N-length lists of tuples where each each tuple is the optimiztion starting parameters for a given peak and dimension lineshape.
amp_guesses P-length list of amplitudes.
Convert linesh.fit_NDregion input/output to peakpick.pick output
Parameters:
N-length lists of tuples where each each tuple is the optimiztion starting parameters for a given peak and dimension lineshape.
amp_guesses P-length list of amplitudes.
Return: (centers,linewidths,amplitudes)
Gaussian (normal) lineshape class
Parameters (mu,sigma):
Peak lineshape class
This is really a gaussian lineshape which takes a center,fwhm as parameters
Lorentzian lineshape class
Parameters (x0,g):
One dimensional scale class
Simulates a lineshape with functional form:
1.0,a0,a1,a2,....
Where a0, a1, ... are the parameters provided.
An N-dimentional iterator to slice arrays into windows.
Given the shape of an array and a window size, an ‘ndwindow’ instance iterators over tuples of slices which slice an the array into wsize sub-arrays. At each iteration, the index of the center of the sub-array is incremented by one along the last dimension. Array border are ignored so the resulting sub-array can be smaller than wsize. If wsize contains even values the window is off center containing an additional point with lower index.
Parameters
Example:
>>> a = np.arange(12).reshape(3,4)
>>> for s in ndwindow(a.shape,(3,3))
... print a[s]
[[0 1]
[4 5]]
[[0 1 2]
[4 5 6]]
[[1 2 3]
[5 6 7]]
[[2 3]
[6 7]]
[[0 1]
[4 5]
[8 9]]
[[ 0 1 2]
[ 4 5 6]
[ 8 9 10]]
...
An N-dimensional interator object which returns the index of the window center and a ndwindow slice array.
Equivalent to:
An N-dimentional iterator to slice arrays into uniform size windows.
Given the shape of an array and a window size, an ‘ndwindow_inside’ instance iterators over tuples of slices which slice an the array into uniform size wsize sub-arrays. At each iteration, the index of the top left of the sub-array is incremented by one along the last dimension utill the windows would extend past the array border. All sub-arrays are equal sized (wsize).
Parameters:
Example:
>>> a = np.arange(9).reshape(3,3)
>>> for s in ndwindow_inside(a.shape,(2,2):
... print a[s]
[[0 1]
[4 5]]
[[1 2]
[5 6]]
[[2 3]
[6 7]]
[[4 5]
[8 9]]
[[ 5 6]
[ 9 10]]
[[ 6 7]
[10 11]]
An N-dimensional interator object which returns the index of the window top-left and a ndwindow_inside slice array.
Similar to ndwindow_index but reports top left index of window.