ultrapyfit.graphics package
Submodules
ultrapyfit.graphics.ExploreData module
Created on Thu Nov 12 21:18:25 2020 @author: lucas
- class ultrapyfit.graphics.ExploreData.ExploreData(x, data, wavelength, selected_traces=None, selected_wavelength=None, cmap='viridis', **kwargs)
Bases:
PlotSVD
Class to explore a time resolved data set and easily create figures already formatted. The class inherits PlotSVD therefore all methods for plotting and exploring the SVD space are available. .. attribute:: x
x-vector, normally time vector
- type
1darray
- data
array containing the data, the number of rows should be equal to the len(x)
- Type
2darray
- wavelength
wavelength vector
- Type
1darray
- selected_traces
sub dataset of data
- Type
2darray
- selected_wavelength
sub dataset of wavelength
- Type
1darray
- time_unit
Contains the strings of the time units to format axis labels and legends automatically: time_unit str of the unit. >>> e.g.: ‘ps’ for picosecond Can be passes as kwargs when instantiating the object
- Type
str (default ps)
- wavelength_unit
Contains the strings of the wavelength units to format axis labels and legends automatically: wavelength_unit str of the unit: >>> e.g.: ‘nm’ for nanometers Can be passes as kwargs when instantiating the object
- Type
str (default nm)
- cmap
Contains the name of a matplotlib color map
- Type
str
- get_color_map()
- plot_3D(cmap=None, figsize=(12, 8))
Plot the data in 3D
- Parameters
cmap (str or None) –
- name of matplotlib color map if None the attribute color_map will
be use
figsize (tuple) – Size of the figure similar to matplotlib figsize
- Return type
Figure and axes matplotlib objects
- plot_spectra(times='all', rango=None, average=0, cover_range=None, from_max_to_min=True, legend=True, legend_decimal=2, ncol=1, cmap=None, style='lmu_spec', include_rango_max=True)
Function to plot spectra
- Parameters
times (list or “all” or “auto” (default “all”)) –
- “all”: all spectra will be plotted if they are less than 250
spectra (if there are more than 250 the output is the same as “auto”)
- “auto”: 8 spectra equally spaced at the wavelength where the data
has maximum amplitude will be displayed
- list: (option 1)
list containing a number of time points, then the closest points in x vector to those in the list will be plotted
- list: (Option 2) –> modifies auto plotting
a list of either length 2 or 3 elements where the structure should follow this sequence: mode = “auto” number_of_spectra = (optional; int) wavelength_to_select_spectra = (optional; int) times=[“auto”, number_of_spectra, wavelength_to_select_spectra] with three possible options: 1 –>if only [“auto”] 8 spectra will be plotted equally spaced
at the maximum for all wavelengths same as “auto” as string
- 2 –>if [“auto”, n_number_spec] n_number spectra will be plotted
equally spaced at the maximum for all wavelengths
- 3 –>if [“auto”, n_number_spec, wavelength] n_number spectra
will be plotted equally spaced at the selected wavelength
- e.g.1: [“auto”, 10, 350] >>> 10 spectra equally spaced at
wavelength 350
- e.g.2: [“auto”, 10] >>> 10 spectra equally spaced at data
wavelength were signal is maximum amplitude (absolute value)
- e.g.3: [“auto”, 6, 480] >>> 6 spectra equally spaced at w
avelength 480
rango (List of length 2 or None (default None)) – Defines a time range where to auto select spectra
average (int (default 0)) – Number of points to average the spectra. Is recommended to be zero except for special cases
cover_range (List of length 2 or None (default None)) – Defines a range in wavelength that will be cover in white. This can be use to cut the excitation wavelength range
from_max_to_min (bool (default True)) – In case the rango is None. Generally the data sets have a time point where the transient signal is maximum. If from_max_to_min is True the range will be given from the time point where the data amplitude is maximum to the end. If False from the initial time to the maximum in amplitude of the data.
legend (True, False or bar) – If True a legend will be display. If False no legend will be display. If bar a color-bar with the times is add to the side.
legend_decimal (int (default 2)) – Only applicable if legend=True number of decimal values in the legend names
ncol (int (default 1)) – Number of legend columns
cmap (str or None (default None)) – Name of matplotlib color map if None the attribute color_map will be use
style (style valid name (default ‘lmu_res’)) – defines the style to format the output figure, it can be any defined matplotlib style, any ultrapyfit style (utf) or any user defined style that follows matplotlib or utf styles and is saved in the correct folder. Check styles for more information.
include_rango_max (bool (default True)) – If True, spectra are auto-plotted in a given range the last spectrum plotted will be the closest to the range limit
- Return type
Figure and axes matplotlib objects
- plot_traces(traces='select', style='lmu_trac', legend='auto')
Plots either the selected traces or 9-10 trace equally space in the wavelength range. If less than 10 (included) traces are plotted a legend will be display.
- Parameters
traces (auto, select or a list (default select)) –
- 1–> If auto between 9 and 10 traces equally spaced in the
wavelength range will be plotted.
2–> If select the selected traces will be plotted 3–> If a list containing the traces wave values
style (style valid name (default ‘lmu_res’)) – defines the style to format the output figure, it can be any defined matplotlib style, any ultrapyfit style (utf) or any user defined style that follows matplotlib or utf styles and is saved in the correct folder. Check styles for more information.
legend (“auto”, True or False, (default “auto”)) – If auto, a legend is display if there are less than 10 traces in the Figure plotted. If True or False, a legend will be displayed or not independently of the number of traces in the Figure.
- Return type
Figure and axes matplotlib objects
- select_traces(points=10, average=1, avoid_regions=None)
Method to select traces from the data attribute and defines a subset of traces in the selected_traces attribute.
- Parameters
points (int or list or “auto” (default 10)) – If type(space) =int: a series of traces separated by the value indicated will be selected. If type(space) = list: the traces in the list will be selected. If space = auto, the number of returned traces is 10 and equally spaced along the wavelength vector and points is set to 0
average (int (default 1)) – Binning points surrounding the selected wavelengths. e. g.: if point is 1 trace = mean(index-1, index, index+1)
avoid_regions (list of list (default None)) – Defines wavelength regions that are avoided in the selection when space is an integer. The sub_list should have two elements defining the region to avoid in wavelength values i. e.: [[380,450],[520,530] traces with wavelength values
between 380-450 and 520-530 will not be selected
- Return type
Modifies the attributes selected_traces and selected_wavelength.
- select_traces_graph(points=- 1, average=0)
Function to select traces graphically
- Parameters
points (int (default -1)) – Defines the number of traces that can be selected. If -1 an infinitive number of traces can be selected
- set_color_map(val: str)
- property time_unit
- property wavelength_unit
ultrapyfit.graphics.ExploreResults module
Created on Sun Nov 15 18:35:41 2020
@author: lucas
- class ultrapyfit.graphics.ExploreResults.ExploreResults(fits, **kwargs)
Bases:
object
- das_to_eas(das, params, wavelength, n_exp, tau_inf, deconv)
Recalculates DAS spectra into EAS, treating y_inf as final product. Replaces DAS with EAS, so one should treat this data as EAS after calling this method. It works with matrices and should be correct for any number of exp’s.
- get_DAS(number='all', fit_number=None, convert_to_EAS=False)
returns an array of the Decay associated spectra. The number of rows is the number of species and the number of columns correspond to the wavelength vector.
- Parameters
number (list of inst or ‘all’) – Defines the DAS spectra wanted, if there is tau_inf include -1 in the list: e.g.: for a fit with three exponential, if the last two are wanted;
number = [1, 2]
e.g.2: the last two exponential plus tau_inf; number = [1, 2, -1]
fit_number (int or None (default None)) – defines the fit number of the results all_fit dictionary. If None the last fit in will be considered
convert_to_EAS – return the especies associted spectra, obtained as a linear combination of the DAS and considering a sequential model.
- Return type
numpy 2d array
- get_gloabl_fit_curve_results(fit_number=None, verify_svd_fit=False)
Returns a data set created from the best parameters values.
- Parameters
fit_number (int or None (default None)) – defines the fit number of the results all_fit dictionary. If None the last fit in will be considered
verify_svd_fit (bool (default False)) – If True it will return the single fit perform to every trace of the spectra after an svd fit. If false and the fit is an SVD, the values return are the fit to the svd left vectors. If is not an SVD fit this parameter is not applicable
- plot_DAS(fit_number=None, number='all', plot_offset=True, precision=2, style='lmu_spec', cover_range=None, plot_integrated_DAS=False, convert_to_EAS=False)
- Function that generates a figure with the decay associated spectra (DAS)
of the fit stored in the all_fit attributes
- Parameters
fit_number (int or None (default None)) – defines the fit number of the results all_fit dictionary. If None the last fit in will be considered.
number (list of inst or ‘all’ (default ‘all’)) – Defines the DAS spectra wanted, if there is tau_inf include -1 in the list (Note we start counting by ‘0’, thus for tau1 ‘0’ should be pass): e.g.: for a fit with three exponential, if the last two are wanted;
number = [1, 2]
e.g.2: the last two exponential plus tau_inf; number = [1, 2, -1]
plot_offset (bool (default True)) – If True the offset of a global fit without deconvolution will be plot. (Only applicable for exponential or target fit without deconvolution)
precision (int (default 2)) – Defines the number of decimal places of the legend legend
style (style valid name (default ‘lmu_spec’)) – defines the style to format the output figure, it can be any defined matplotlib style, any ultrapyfit style (utf) or any user defined style that follows matplotlib or utf styles and is saved in the correct folder. Check styles for more information.
cover_range (List of length 2 or None (default None)) – Defines a range in wavelength that will be cover in white. This can be use to cut the excitation wavelength range
plot_integrated_DAS (bool (default False)) – Defines in case if data has been derivative, to directly integrate the DAS.
convert_to_EAS – return the especies associted spectra, obtained as a linear combination of the DAS and considering a sequential model.
- Return type
Figure and axes matplotlib objects
- plot_concentrations(fit_number=None, names=None, plot_total_c=True, legend=True, style='lmu_res')
Function that generates a figure with the concentration evolution of a Target fit
- Parameters
fit_number (int or None (default None)) – defines the fit number of the results all_fit dictionary. If None the last fit in will be considered.
names (list (default None)) – List that allows to redefine the names of the components. Is none the default names “specie” is use. The names are display in the legend if legend is True
plot_total_c (bool (default True)) – Defines if the Total concentration is
legend (bool (default True)) – Defines if the legend is display
style (style valid name (default ‘lmu_res’)) – defines the style to format the output figure, it can be any defined matplotlib style, any ultrapyfit style (utf) or any user defined style that follows matplotlib or utf styles and is saved in the correct folder. Check styles for more information.
- Return type
Figure and axes matplotlib objects
- plot_global_fit(fit_number=None, selection=None, plot_residues=True, style='lmu_res')
Function that generates a figure with the results of the fit stored in the all_fit attributes. If less than 10 traces are fitted or selected a legend will be displayed
- Parameters
fit_number (int or None (default None)) – defines the fit number of the results all_fit dictionary. If None the last fit in will be considered
selection (list or None (default None)) – If None all the traces fitted will be plotted, if a list only those selected in the list
plot_residues (Bool (default True)) – If True the Figure returned will contain two axes a top one with the residues, and the bottom one with the fit and data
style (style valid name (default ‘lmu_res’)) – defines the style to format the output figure, it can be any defined matplotlib style, any ultrapyfit style (utf) or any user defined style that follows matplotlib or utf styles and is saved in the correct folder. Check styles for more information.
- Return type
Figure and axes matplotlib objects
- plot_verify_fit(fit_number=None)
Function that generates a figure with a slider to evaluate every single trace fitted independently.
- Parameters
fit_number (int or None (default None)) – defines the fit number of the results all_fit dictionary. If None the last fit in will be considered.
- Return type
Figure and axes matplotlib objects
- print_fit_results(fit_number=None)
Print out a summarize result of the fit.
- Parameters
fit_number (int or None (default None)) – defines the fit number of the results all_fit dictionary. If None the last fit in will be considered.
- property time_unit
- property wavelength_unit
ultrapyfit.graphics.MaptplotLibCursor module
Created on Fri Nov 13 17:59:23 2020
@author: 79344
ultrapyfit.graphics.PlotSVD module
Created on Sun Nov 15 11:29:27 2020
@author: lucas
- class ultrapyfit.graphics.PlotSVD.PlotSVD(x, data, wavelength, selected_traces=None, selected_wavelength=None)
Bases:
object
Class to do a singular value decomposition (SVD) of the data and explore the results.
- x
x-vector, normally time vector
- Type
1darray
- data
array containing the data, the number of rows should be equal to the len(x)
- Type
2darray
- wavelength
wavelength vector
- Type
1darray
- selected_traces
sub dataset of data
- Type
2darray
- selected_wavelength
sub dataset of wavelength
- Type
1darray
- _S
Number of singular values calculated.
- _U
Number of left singular vectors calculated .
- _V
Number of right singular vectors calculated.
- get_svd_decomposition()
Return the left singular vectors(U) the eingen values(S) and right singular vectors(V).
- plot_full_SVD(vectors=1, select=False, calculate=15)
- plot_singular_values(data='all', size=14, log_scale=True)
Plot the singular values of either the whole data set or the selected data set.
- Parameters
data (str “all” or “select”) – If “all” the singular values plotted correspond to the whole data set if “select” correspond to the singular values of the selected traces.
size (int (default 14)) –
- size of the figure text labels including tick labels axis labels and
legend.
log_scale (bool (default True)) – defines the scale of the y axis, if true a logarithmic scale will be set.
- select_SVD_vectors(val)
function to select the left singular vectors as selected traces. This allows to perform a fit to the singular vector which is much faster
than a global fit, since the number of singular vector is lower.
- Parameters
val (int) – indicate the number of singular vectors to select
- select_traces(points=10, average=1, avoid_regions=None)
Method to select traces from the data attribute ande defines a subset of traces in the selected_traces attribute
- Parameters
points (int or list or “auto” (default 10)) – If type(space) =int: a series of traces separated by the value indicated will be selected. If type(space) = list: the traces in the list will be selected. If space = auto, the number of returned traces is 10 and equally spaced along the wavelength vector and points is set to 0
average (int (default 1)) – Binning points surrounding the selected wavelengths. e. g.: if point is 1 trace = mean(index-1, index, index+1)
avoid_regions (list of list (default None)) – Defines wavelength regions that are avoided in the selection when space is an integer. The sub_list should have two elements defining the region to avoid in wavelength values i. e.: [[380,450],[520,530] traces with wavelength values between
380-450 and 520-530 will not be selected