EMToolKit.algorithms package
EMToolKit.algorithms.multi_inst_dem_wrapper module
EMToolKit.algorithms.simple_reg_dem module
EMToolKit.algorithms.simple_reg_dem_parallel module
- EMToolKit.algorithms.simple_reg_dem_parallel.precompute_matrices(data, errors, exptimes, logt, tresps, drv_con)[source]
Precomputes matrices and vectors required for regularized differential emission measure.
Parameters: - data: The observed data array. - errors: The uncertainties associated with the data. - exptimes: Exposure times for each observation. - logt: Logarithm of temperature bins. - tresps: Temperature response functions. - drv_con: Drive constant for regularization.
Returns: - nt_ones: Array of ones of size nt. - nx, ny: Dimensions of the data array. - Bij: Matrix used in regularization. - Rij: Matrix mapping coefficients to data. - Dij: Matrix used in regularization. - regmat: Regularization matrix. - rvec: Sum of Rij across axis=1.
- EMToolKit.algorithms.simple_reg_dem_parallel.process_pixel(i, j, data, errors, Rij, regmat, rvec, nt_ones, kmax, kcon, steps, drv_con, chi2_th, tol)[source]
Processes a single pixel (i, j) in a dataset to compute its differential emission measure (DEM) and chi-squared value.
Parameters: - i, j: Indices of the pixel in the data array. - data: The observed data array. - errors: The uncertainties associated with the data. - Rij: Matrix mapping coefficients to data. - regmat: Regularization matrix. - rvec: Sum of Rij across axis=1. - nt_ones: Array of ones of size nt. - kmax: Maximum number of iterations. - kcon: Convergence criterion based on the number of iterations. - steps: Step sizes for the iterative method. - drv_con: Drive constant for regularization. - chi2_th: Chi-squared threshold for stopping criterion. - tol: Tolerance for convergence criterion.
Returns: - i, j: Indices of the processed pixel. - dem_pixel: Computed DEM value for the pixel. - chi2_pixel: Computed chi-squared value for the pixel.
Notes: - The function skips pixels with NaN values in data or errors. - If the Cholesky factorization fails, the iteration breaks early. - The function employs an iterative method to adjust the DEM based on the observed data, errors, and a regularization term.
- EMToolKit.algorithms.simple_reg_dem_parallel.simple_reg_dem(*args, doParallel=True, **kwargs)[source]
Wrapper function to call the serial or parallel version of the simple regularized DEM computation.
Accepts the same parameters as simple_reg_dem_serial and simple_reg_dem_parallel.
Returns: - dems: Computed DEM values, a 3D array (nx, ny, nt). - chi2: Computed chi-squared values for each pixel, a 2D array (nx, ny).
- EMToolKit.algorithms.simple_reg_dem_parallel.simple_reg_dem_parallel(data, errors, exptimes, logt, tresps, kmax=100, kcon=5, steps=[0.1, 0.5], drv_con=8.0, chi2_th=1.0, tol=0.1)[source]
Perform a parallel computation of differential emission measure (DEM) and chi-squared values for observational data against a set of response functions using multiple processes.
Parameters are the same as in simple_reg_dem_serial.
Returns: - dems: Computed DEM values, a 3D array (nx, ny, nt). - chi2: Computed chi-squared values for each pixel, a 2D array (nx, ny).
- EMToolKit.algorithms.simple_reg_dem_parallel.simple_reg_dem_serial(data, errors, exptimes, logt, tresps, kmax=100, kcon=5, steps=[0.1, 0.5], drv_con=8.0, chi2_th=1.0, tol=0.1)[source]
Perform a serial computation of differential emission measure (DEM) and chi-squared values for observational data against a set of response functions.
Parameters: - data: Observed data, a 3D array (nx, ny, nd). - errors: Uncertainties in the observed data, same shape as data. - exptimes: Exposure times for each observation, 1D array of length nd. - logt: Logarithm of temperature bins, 1D array. - tresps: Temperature response functions, 2D array (nt, nd). - kmax: Maximum number of iterations for the fitting process. - kcon: Minimum number of iterations before convergence can be considered. - steps: Step sizes to use in the fitting iterations, list of two floats. - drv_con: Drive constant for the regularization term. - chi2_th: Threshold chi-squared value for stopping the iterations. - tol: Tolerance for convergence.
Returns: - dems: Computed DEM values, a 3D array (nx, ny, nt). - chi2: Computed chi-squared values for each pixel, a 2D array (nx, ny).
EMToolKit.algorithms.simple_reg_dem_wrapper module
EMToolKit.algorithms.simple_reg_dem_wrapper_parallel module
EMToolKit.algorithms.sparse_em module
EMToolKit.algorithms.sparse_em_wrapper module
- EMToolKit.algorithms.sparse_em_wrapper.autoloading_sparse_em_wrapper(datasequence, data_dir='.data/default', *, wrapargs={}, recalc=False)[source]
Wrapper function that calculates or loads a precomputed sparse regularized DEM.
This function first checks if a precomputed DEM exists in the specified directory. If not, it calculates the DEM using sparse_em_wrapper, saves the result, and returns it.
- Parameters:
datasequence (NDCubeSequence) – A sequence of data cubes containing the observations. Each cube should contain 2D spatial data with associated uncertainties and metadata.
data_dir (str, optional) – The directory where the DEM result will be saved or loaded from. Default is “../.data/default”.
recalc (bool, optional) – If True, the DEM will be recalculated even if a precomputed result exists. Default is False.
wrapargs (A dictionary)
- Returns:
emtk.dem_model – The DEM model generated from the input data.
tuple – The output from the sparse_em_wrapper function.
- EMToolKit.algorithms.sparse_em_wrapper.sparse_em_wrapper(datasequence, wrapargs={})[source]
Wrapper function for the sparse regularized Differential Emission Measure (DEM) calculation.
This function prepares input data and passes it to the sparse_em_init and sparse_em_solve algorithms. It processes the input data to ensure that all input maps have consistent dimensions, extracts the necessary metadata, and then calls the DEM calculation.
- Parameters:
datasequence (NDCubeSequence) – A sequence of data cubes containing the observations. Each cube should contain 2D spatial data with associated uncertainties and metadata.
wrapargs (dict, optional) – Additional arguments to pass to the initialization routines of the sparse_em functions.
- Returns:
list of numpy.ndarray – The calculated DEM coefficients for each temperature bin.
list of numpy.ndarray – The temperature bins used in the calculation.
list of numpy.ndarray – The basis functions for the temperature bins.
WCS – World Coordinate System (WCS) information from the input data.
str – A string identifier for the DEM method used.
EMToolKit.algorithms.sparse_nlmap_dem_wrapper module
- EMToolKit.algorithms.sparse_nlmap_dem_wrapper.autoloading_sparse_nlmap_dem_wrapper(datasequence, data_dir='.data/default/', recalc=False, wrapargs={})[source]
Wrapper function that calculates or loads a precomputed sparse non-linear map-based DEM.
This function first checks if a precomputed DEM exists in the specified directory. If not, it calculates the DEM using sparse_nlmap_dem_wrapper, saves the result, and returns it.
- Parameters:
datasequence (NDCubeSequence) – A sequence of data cubes containing the observations. Each cube should contain 2D spatial data with associated uncertainties and metadata.
data_dir (str, optional) – The directory where the DEM result will be saved or loaded from. Default is “.data/default/”.
recalc (bool, optional) – If True, the DEM will be recalculated even if a precomputed result exists. Default is False.
wrapargs (dict, optional) – Additional arguments to pass to the initialization routines of the sparse_nlmap_dem_wrapper function.
- Returns:
emtk.dem_model – The DEM model generated from the input data.
tuple – The output from the sparse_nlmap_dem_wrapper function.
- class EMToolKit.algorithms.sparse_nlmap_dem_wrapper.sparse_nlmap_dem_wrap_object(wrapargs, source=None)[source]
Bases:
object
- EMToolKit.algorithms.sparse_nlmap_dem_wrapper.sparse_nlmap_dem_wrapper(datasequence, wrapargs={})[source]
Wrapper function for the sparse non-linear map-based Differential Emission Measure (DEM) calculation.
This function prepares input data and passes it to the sparse_nlmap_dem_wrapper algorithm. It processes the input data to ensure that all input maps have consistent dimensions, extracts the necessary metadata, and then calls the DEM calculation.
- Parameters:
datasequence (NDCubeSequence) – A sequence of data cubes containing the observations. Each cube should contain 2D spatial data with associated uncertainties and metadata.
wrapargs (dict, optional) – Additional arguments to pass to the initialization routines of the sparse_nlmap_dem_wrapper function.
- Returns:
list of numpy.ndarray – The calculated DEM coefficients for each temperature bin.
list of numpy.ndarray – The temperature bins used in the calculation.
list of numpy.ndarray – The basis functions for the temperature bins.
WCS – World Coordinate System (WCS) information from the input data.
str – A string identifier for the DEM method used.
EMToolKit.algorithms.sparse_nlmap_solver module
- class EMToolKit.algorithms.sparse_nlmap_solver.nlmap_operator(*args, **kwargs)[source]
Bases:
LinearOperator
- EMToolKit.algorithms.sparse_nlmap_solver.solve(data0, errors0, amat0, guess=None, reg_fac=1, func=None, dfunc=None, ifunc=None, regmat=None, silent=False, solver=None, sqrmap=False, regfunc=None, dregfunc=None, iregfunc=None, map_reg=False, adapt_lam=True, solver_tol=0.001, niter=40, dtype='float32', steps=None, precompute_ata=False, flatguess=True, chi2_th=1.0, store_outer_Av=False, conv_chi2=1e-15)[source]