resistics.regression.remote module¶
-
class
resistics.regression.remote.
RemoteRegressor
(winSelector, outpath: str)[source]¶ Bases:
resistics.regression.local.LocalRegressor
Perform remote reference processing of magnetotelluric data
Remote reference processing uses a different equation for spectral power than the single site processor. The equation that the processor uses is:
- Attributes
- winSelectorWindowSelector
A window selector object which defines which windows to use in the linear model
- decParamsDecimationParameters
DecimationParameters object with information about the decimation scheme
- winParamsWindowParameters
WindowParameters object with information about the windowing
- outpathstr
Location to put the calculated transfer functions (Edi files)
- inSitestr
The site to use for the input channels
- inChannels: List[str] ([“Hx”, “Hy”])
List of hannels to use as input channels for the linear system
- inSizeint
Number of input channels
- outSitestr
The site to use for the output channels
- outChannelsList[str] ([“Ex”, “Ey”])
List of channels to use as output channels for the linear system
- outSizeint
Number of output channels
- remoteSitestr
The site to use as a remote reference
- remoteChannelsList[str]
The channels to use as remote reference channels
- remoteSizeint
Number of remote reference channels
- interceptbool (default False)
Flag for including an intercept (static) term in the linear system
- methodstr (options, “ols”, “cm”)
String for describing what solution method to use
- winstr (default hanning)
Window function to use in robust solution
- winSmoothint (default -1)
The size of the window smoother. If -1, this will be autocalculated based on data size
- postpendstr (default “”)
String to postpend to the output filename to help file management
- evalFreqList[float] or np.ndarray
The evaluation frequencies
- impedancesList
- variancesList
Methods
__init__(winSelector, outpath)
Initialise the remote reference processor
setRemote(remoteSite, remoteChannels)
Set the remote site and channels
process()
Perform the remote reference processing
checkRemote()
Ensure remote reference site and channels are properly defined
prepareLinearEqn(data)
Prepare regressors and observations for regression from cross-power data
robustProcess(numWindows, obs, reg)
Robust regression processing
olsProcess(numWindows, obs, reg)
Ordinary least squares processing
stackedProcess(data)
Stacked processing
printList()
Class status returned as list of strings
-
checkRemote
(self)[source]¶ Check that the remote channels are the same as the input channels
- Returns
- bool
Check outcome
-
olsProcess
(self, numWindows: int, obs: numpy.ndarray, reg: numpy.ndarray) → numpy.ndarray[source]¶ Ordinary least squares regression processing
Perform ordinary least regression processing using observations and regressors for a single evaluation frequency.
- Parameters
- numWindowsint
The number of windows
- obsnp.ndarray
The observations
- regnp.ndarray
The regressors
- Returns
- outputnp.ndarray
The solution to the regression problem
- varOutputnp.ndarray
The variance
-
prepareLinearEqn
(self, data)[source]¶ Prepare data as a linear equation for the robust regression
This prepares the data for the following type of solution,
\[y = Ax,\]where \(y\) is the observations, \(A\) is the regressors and \(x\) is the unknown.
The number of observations is number of windows * number of cross-power channels The shapes of the arrays are as follows:
y is (number of output channels, number of observations)
A is (number of output channels, number of observations, number of input channels)
x is (number of output channels, number of input channels)
Consider the impedance tensor,
\begin{eqnarray} E_x & = & Z_{xx} H_x + Z_{xy} H_y \\ E_y & = & Z_{yx} H_x + Z_{yy} H_y \end{eqnarray}Here, there are two input channels, \(H_x\), \(H_y\) and two output channels \(E_x\) and \(E_y\). In total, there are four components of the unknown impedance tensor, \(Z_{xx}\), \(Z_{xy}\), \(Z_{yx}\), \(Z_{yy}\) (number of input channels * number of output channels). The number of observations is the number of windows multiplied by the number of channels used for cross-power spectra.
- Parameters
- datanp.ndarray
Cross-power spectral data at evaluation frequencies
- Returns
- numWindowsint
The number of windows included in the regression (after bad value removal)
- obsnp.ndarray
Observations array
- regnp.ndarray
Regressors array
-
printList
(self) → List[str][source]¶ Class information as a list of strings
- Returns
- outlist
List of strings with information
-
process
(self, ncores: int = 0) → None[source]¶ Process spectra data
The processing sequence for each decimation level is as below:
Get shared (unmasked) windows for all relevant sites (inSite and outSite)
For shared unmasked windows
Calculate out the cross-power spectra.
Interpolate calculated cross-power data to the evaluation frequencies for the decimation level.
For each evaluation frequency
Do the robust processing to calculate the transfer function at that evaluation frequency.
The spectral power data is smoothed as this tends to improve results. The smoothing can be changed by setting the smoothing parameters. This method is still subject to change in the future as it is an area of active work
-
robustProcess
(self, numWindows: int, obs: numpy.ndarray, reg: numpy.ndarray) → Tuple[numpy.ndarray][source]¶ Robust regression processing
Perform robust regression processing using observations and regressors for a single evaluation frequency.
- Parameters
- numWindowsint
The number of windows
- obsnp.ndarray
The observations
- regnp.ndarray
The regressors
- Returns
- outputnp.ndarray
The solution to the regression problem
- varOutputnp.ndarray
The variance