MESMA Module¶
-
class
mesma.core.mesma.
MesmaCore
(n_cores: int = 1)[source]¶ Bases:
object
Multiple Endmember Signal Mixture Analysis: calculate SMA for multiple endmember combinations and select the best fit based on the lowest RMSE.
Citations: MESMA: Roberts, D.A., Gardner, M., Church, R., Ustin, S., Scheer, G., Green, R.O., 1998, Mapping Chaparral in the Santa Monica Mountains using Multiple Endmember Spectral Mixture Models, Remote Sensing of Environment, 65, p. 267-279.
Multilevel fusion: Roberts, D.A., Dennison, P.E., Gardner, M., Hetzel, Y., Ustin, S.L., Lee, C., 2003, Evaluation of the Potential of Hyperion for Fire Danger Assessment by Comparison to the Airborne Visible/Infrared Imaging Spectrometer, IEEE Transactions on Geoscience and Remote Sensing, 41, p. 1297-1310.
Spectral band weighing: Somers, B., Delalieux, S, Stuckens, J , Verstraeten, W.W, Coppin, P., 2009, A weighted linear spectral mixture analysis approach to address endmember variability in agricultural production systems, International Journal of Remote Sensing, 30, p. 139-147.
Spectral band selection: Somers, B., Delalieux, S., Verstraeten, W.W., van Aardt, J.A.N., Albrigo, G., Coppin, P., 2010, An automated waveband selection technique for optimized hyperspectral mixture analysis. International Journal of Remote Sensing, 31, p. 5549-5568.
-
execute
(image: numpy.array, library: numpy.array, look_up_table: dict, em_per_class: dict, constraints: list = (-0.05, 1.05, 0.0, 0.8, 0.025, -9999, -9999), fusion_value: float = 0.007, no_data_pixels: tuple = (), shade_spectrum: numpy.array = None, residual_image: bool = False, use_band_weighing: bool = False, use_band_selection: bool = False, bands_selection_values: tuple = (0.99, 0.01), log: callable = <built-in function print>) → tuple[source]¶ Execute MESMA. Process input and output.
In case band weighing or band selection algorithms are used, no residual image or residual constraints can be used.
Returns 3 images [a pixels * b pixels * c bands]:
- the best model [nb of bands = nb of classes] - each band contains the library spectra number per class
- the model’s fractions [nb of bands = nb of classes + 1], including a shade fraction
- the model’s RMSE [nb of bands = 1]
- [optional] a residual image
Value of unmodeled pixels in output:
- models: -1
- fractions: 0
- rmse: 9999
- residual_image: 0
Value of pixels with no data in output:
- models: -2
- fractions: 0
- rmse: 9998
- residual_image: 0
Parameters: - image – image, scaled to reflectance, without bad bands
- library – spectral library with spectra as columns, scaled to reflectance, without bad bands
- look_up_table – all endmember combinations (=models) for MESMA; ordered per complexity level and per class-model; n_models x n_endmembers
- em_per_class – a list of all library indices per endmember class
- constraints – min + max endmember fraction, min + max shade fraction, max rmse, residual reflectance threshold + max number of consecutive bands exceeding threshold. set value to -9999 if not used.
- no_data_pixels – indices of pixels that contain no data (result of np.where)
- shade_spectrum – single spectrum of photometric shade
- fusion_value – only select a model of higher complexity (e.g. 3-EM over 2-EM) of the RMSE is better with at least this value
- residual_image – output the residuals as an image (ignored when using band weighing or -selection)
- use_band_weighing – use the weighted linear spectral mixture analysis (Somers et al, 2009)
- use_band_selection – use the bands selection algorithm (Somers et al, 2010)
- bands_selection_values – correlation threshold and decrease for the band selection algorithm
- log – log function
Returns: images with the best model for each pixel, the model fractions and rmse belonging {+ evt. residuals)
-
-
class
mesma.core.mesma.
MesmaModels
[source]¶ Bases:
object
Create the MESMA look-up-table from a list of classes and user input. No GUI/CLI.
DEFINITIONS:
- endmember: spectrum or signal from a Spectral Library = ‘EM’
- class: logical group of endmembers, e.g. ‘green vegetation’ or ‘soil’
- endmember-model: combination of endmembers used for unmixing
- class-model: endmember-models grouped by class-level, e.g. all ‘green vegetation-soil’ models
- level: class-models grouped by the number of classes (e.g. all 3-EM models)
-
max_digits
() → int[source]¶ Get the maximum number of digits for the GUI, in order to be able to display the number of models.
Returns: The maximum number of digits for the GUI, in order to be able to display the number of models.
-
return_look_up_table
() → dict[source]¶ Get the actual look-up-table as a dictionary with a key-value pair for each level. Each level’s value is another dictionary with a key-value pair for each class-model. Each class-model has a numpy array of all the endmember-combinations for that class-model.
This look-up-table is a required input for MESMA.
Returns: The look-up-table as a dictionary [levels] of dictionaries [class-models] of numpy-arrays [models].
-
save
() → str[source]¶ Get a summary of the selected models, designed specifically for the ‘SAVE’ functionality in the MESMA gui.
Returns: A summary of the selected models, specifically to save in the MESMA settings [multi-line-str].
-
select_class
(state: bool, index: int, level: int)[source]¶ Add/remove a class of a given level. Automatically selects all class-models of all selected classes. For level 3 (= 3-EM models), at least 2 classes must be selected, etc.
Parameters: - state – True = select, False = deselect.
- index – The index of the class, based on the list of unique lowercase classes.
- level – The complexity level in which the user wants to select.
-
select_level
(state: bool, level: int)[source]¶ Add/remove a level from the selection.
- Selecting a level for the first time does not automatically select any classes/class-models in that level.
- Deselecting a level leaves all settings of class/class-model selections intact.
- Selecting a level for the second time (or more) re-instated the previous settings of that level.
Parameters: - state – True = select, False = deselect.
- level – The complexity level the user wants to select.
-
select_model
(state: bool, index: int, level: int)[source]¶ Add/remove an individual class-model.
Parameters: - state – True = select, False = deselect.
- index – The index of the class-model
- level – The complexity level in which the user wants to select.
-
setup
(class_list: numpy.array)[source]¶ Default set up of the model selection: select all 2-EM and 3-EM models.
Parameters: class_list – [array-of-strings] A class for each endmember in the library.
-
summary
() → str[source]¶ Get a summary of the selected models. This is designed specifically to display in the GUI application.
Returns: A summary of the selected models, specifically to display in a GUI application [multi-line-str].
-
total
() → int[source]¶ Get the total number of models in the current selection.
Returns: The total number of models in the current selection.