pysecs.SECS.fit#
- SECS.fit(obs_loc: ndarray, obs_B: ndarray, obs_std: ndarray | None = None, epsilon: float = 0.05, mode: str = 'relative', robust: str | None = None, robust_maxiter: int = 20, robust_tol: float = 1e-06) SECS#
Fits the SECS to the given observations.
Given a number of observation locations and measurements, this function fits the SEC system to them. It uses singular value decomposition (SVD) to fit the SEC amplitudes with the epsilon parameter used to regularize the solution.
- Parameters:
obs_locs (ndarray (nobs, 3 [lat, lon, r])) – Contains latitude, longitude, and radius of the observation locations (place where the measurements are made)
obs_B (ndarray (ntimes, nobs, 3 [Bx, By, Bz])) – An array containing the measured/observed B-fields.
obs_std (ndarray (ntimes, nobs, 3 [stdX, stdY, stdZ]), optional) – Standard error (1-sigma) of vector components at each observation location. This can be used to weight different observations more/less heavily. An infinite value eliminates the observation from the fit. Default: ones(nobs, 3) equal weights
epsilon (float) – Value used to regularize/smooth the SECS amplitudes. Epsilon has different meanings depending on the mode used, described in that parameter section. Must be between 0 and 1. A higher number produces a more regularized (smoother) solution. Default: 0.05
mode (str) –
The mode used to filter the singular values. Options are:
’relative’: filter singular values that are less than epsilon times the largest singular value, keep [S >= epsilon * S.max()].
’variance’: filter singular values that contribute to 1-epsilon of the total energy of the system (% total variance as a ratio).
Default: ‘relative’
robust (str, optional) –
Robust reweighting of the observations. A localized disturbance at a single station (spikes, baseline jumps, instrument noise) is inconsistent with any smooth current system this basis can produce, so it shows up as a large standardized residual and is automatically downweighted by iteratively reweighted least squares (IRLS). Weights are applied per vector component and per time step. Options are:
None: ordinary weighted least squares (default).
’huber’: Huber weights, downweights outliers gradually.
’bisquare’: Tukey biweight, fully rejects gross outliers.
robust_maxiter (int) – Maximum number of IRLS iterations. Each iteration refits every time step with its own weights, so robust fits of long time series cost roughly
robust_maxitertimes the ordinary fit. Default: 20robust_tol (float) – Relative amplitude change used to declare IRLS convergence. Default: 1e-6