pygmi.rsense.transforms#
Transforms such as PCA and MNF.
Classes#
Functions#
|
Calculate noise dataset from original data. |
|
MNF Calculation. |
|
PCA Calculation. |
|
PCA Calculation with using list of files in common fit. |
Blockwise covariance. |
|
|
Compute the dot product of two matrices in a block-wise fashion. |
Module Contents#
- class pygmi.rsense.transforms.MNF(parent=None)#
Bases:
pygmi.misc.BasicModule
GUI to perform MNF transform.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- setupui()#
Set up UI.
- Return type:
None.
- settings(nodialog=False)#
Entry point into item.
- Parameters:
nodialog (bool, optional) – Run settings without a dialog. The default is False.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- changeoutput()#
Change the interface to reflect whether full calculation is needed.
- Return type:
None.
- saveproj()#
Save project data from class.
- Return type:
None.
- acceptall()#
Accept option.
Updates self.outdata, which is used as input to other modules.
- Return type:
None.
- class pygmi.rsense.transforms.PCA(parent=None)#
Bases:
pygmi.misc.BasicModule
GUI to perform PCA transform.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- setupui()#
Set up UI.
- Return type:
None.
- settings(nodialog=False)#
Entry point into item.
- Parameters:
nodialog (bool, optional) – Run settings without a dialog. The default is False.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- changeoutput()#
Change the interface to reflect whether full calculation is needed.
- Return type:
None.
- saveproj()#
Save project data from class.
- Return type:
None.
- acceptall()#
Accept option.
Updates self.outdata, which is used as input to other modules.
- Return type:
None.
- pygmi.rsense.transforms.get_noise(x2d, mask, noisetype='', piter=iter)#
Calculate noise dataset from original data.
- Parameters:
x2d (numpy array) – Input array, of dimension (MxNxChannels).
mask (numpy array) – mask of dimension (MxN).
noisetype (str, optional) – Noise type to calculate. Can be ‘diagonal’, ‘hv average’ or ‘’. The default is ‘’.
- Returns:
nevals (numpy array) – Noise eigenvalues.
nevecs (numpy array) – Noise eigenvectors.
- pygmi.rsense.transforms.mnf_calc(dat, *, ncmps=None, noisetxt='hv average', showlog=print, piter=iter, fwdonly=True)#
MNF Calculation.
- Parameters:
dat (list of pygmi.raster.datatypes.Data.) – List of PyGMI Data.
ncmps (int or None, optional) – Number of components to use for filtering. The default is None (meaning all).
noisetxt (txt, optional) – Noise type. Can be ‘diagonal’, ‘hv average’ or ‘quad’. The default is ‘hv average’.
showlog (function, optional) – Function for printing text. The default is print.
piter (function, optional) – Iteration function, used for progress bars. The default is iter.
fwdonly (bool, optional) – Option to perform forward calculation only. The default is True.
- Returns:
odata (list of pygmi.raster.datatypes.Data.) – Output list of PyGMI Data. Can be forward or inverse transformed data.
ev (numpy array) – Explained variance, from PCA.
- pygmi.rsense.transforms.pca_calc(dat, ncmps=None, showlog=print, piter=iter, fwdonly=True)#
PCA Calculation.
- Parameters:
dat (list of pygmi.raster.datatypes.Data.) – List of PyGMI Data.
ncmps (int or None, optional) – Number of components to use for filtering. The default is None (meaning all).
showlog (function, optional) – Function for printing text. The default is print.
piter (function, optional) – Iteration function, used for progress bars. The default is iter.
fwdonly (bool, optional) – Option to perform forward calculation only. The default is True.
- Returns:
odata (list of pygmi.raster.datatypes.Data.) – Output list of PyGMI Data. Can be forward or inverse transformed data.
ev (numpy array) – Explained variance, from PCA.
- pygmi.rsense.transforms.pca_calc_fitlist(flist, ncmps=None, showlog=print, piter=iter, fwdonly=True)#
PCA Calculation with using list of files in common fit.
- Parameters:
dat (list of pygmi.raster.datatypes.Data.) – List of PyGMI Data.
ncmps (int or None, optional) – Number of components to use for filtering. The default is None (meaning all).
showlog (function, optional) – Function for printing text. The default is print.
piter (function, optional) – Iteration function, used for progress bars. The default is iter.
fwdonly (bool, optional) – Option to perform forward calculation only. The default is True.
- Returns:
odata (list of pygmi.raster.datatypes.Data.) – Output list of PyGMI Data.Can be forward or inverse transformed data.
ev (numpy array) – Explained variance, from PCA.
- pygmi.rsense.transforms.blockwise_cov(A)#
Blockwise covariance.
- Parameters:
A (numpy array) – Matrix.
- Returns:
ncov – Covariance matrix.
- Return type:
numpy array
- pygmi.rsense.transforms.blockwise_dot(A, B, max_elements=int(2**27))#
Compute the dot product of two matrices in a block-wise fashion.
Only blocks of A with a maximum size of max_elements will be processed simultaneously.
from : https://stackoverflow.com/questions/20983882/efficient-dot-products-of-large-memory-mapped-arrays
- Parameters:
A (numpy array) – MxN matrix.
B (Numpy array) – NxO matrix.
max_elements (int, optional) – Maximum number of elements in a block. The default is int(2**27).
- Returns:
out – Output dot product.
- Return type:
numpy array