grapa.datatypes.curveTRPL.CurveTRPL

class grapa.datatypes.curveTRPL.CurveTRPL(data, attributes, silent=False)

Bases: Curve

CurveTRPL offers support to process and fit time-resolved photoluminence (TRPL) data.

__init__(data, attributes, silent=False)

Methods

CurveTRPL_fitExp([nbExp, ROI, fixed, ...])

Fts the data as a constant plus a sum of exponentials.

CurveTRPL_sequence_fitexp([nb_exp, roi, ...])

Fits the data with a sum of exponentials, in a piece-wise manner.

CurveTRPL_smoothBin([window_len, window, ...])

Returns a copy of the Curve after smoothening and data binning.

CurveTRPL_spline([roi, transform, numknots, ...])

Fits the data with a spline and returns a CurveTRPL object.

Curve_differential_lifetime()

Returns a CurveTRPL object with differential (instantaneous) lifetime.

Curve_differential_lifetime_vs_signal()

Returns differential lifetime versus signal (log(signal) proportional to QFLS) Differential lifetime: see Curve_differential_lifetime Make sure to remove background before calculating differential lifetime.

__init__(data, attributes[, silent])

addOffset(value)

to adjust the background level.

addXOffset(value)

Adds a temporal offset, to place the peak onset at t=0.

alterListGUI()

Determines the possible curve visualisations.

findOnset()

fit_resampleX(spacing)

This method modifies self.

fitparams_to_clipboard()

fitparams_weightedaverage([silent])

Weighted averages of decays: returns tau_effective with tau_i weighted by A_i, and by A_i * tau_i (i.e. integral of exponential).

funcListGUI(**kwargs)

Fills in the Curve actions specific to the Curve type. Retuns a list, which elements are instances of FuncGUI, or (old style): ::.

func_fitExp(t, bg, a1, tau1, *args)

computes the sum of a cst plus an arbitrary number of exponentials To keep within class, will be called as getattr(CurveTRPL, functionname)()

getFactor()

getOffset()

getXOffset()

integrate([ROI, alter])

Returns the integral of the curve, within ROI.

normalize(repetfreq_Hz, duration_s, binwidth_ps)

Normalizes intensity of TRPL to account for repetition rate, acquisition duration and binwidth.

normalizerevert(*_args)

setIntensity([offsetnew, factornew])

Data stored as (raw + offset) * factor

Attributes

AXISLABELS_X

AXISLABELS_Y

AXISLABEL_DIFFLIFETIME

CURVE

CurveTRPL_fitExp(nbExp=2, ROI=None, fixed=None, showResiduals=False, showfitonroi=False, silent=False)

Fts the data as a constant plus a sum of exponentials. Returns a Curve as the best fit to the TRPL decay. Formula: y(t) = BG + A1 exp(-t/tau1) + A2 exp(-t/tau2) + … thus y(0) = BG + A1 + A2 + …

Parameters:
  • nbExp – The number of exponentials in the fit

  • ROI – minimum and maximum on horizontal axis, e.g. [min, max]

  • fixed – an array of values. When a number is set, the corresponding fit parameter is fixed. The order of fit parametersis as follows: BG, A1, tau1, A2, tau2, …. e.g. [0,’’,’’]

  • showResiduals – when 1, also returns a Curve as the fit residuals.

  • showfitonroi – restrict the xrange of the fitted curve to the ROI

  • silent – if False, prints additional information

Returns:

a CurveTRPL instance

CurveTRPL_sequence_fitexp(nb_exp=3, roi=None, roi0=None, multiplier=5, maxpoints=None)

Fits the data with a sum of exponentials, in a piece-wise manner.

Parameters:
  • nb_exp – (int, optional) Number of exponentials to fit. Defaults to 3.

  • roi – (list, optional) Overall data range of interest, specified as [xmin, xmax]. Defaults to None.

  • roi0 – (list, optional) Initial data range of interest for the first fit, specified as [xmin, xmax]. Defaults to None.

  • multiplier – (int, optional) Factor to multiply the initial roi0 to get the next one. Defaults to 5.

  • maxpoints – (int, optional) Maximum number of points in the fit, to limit data size. Defaults to None.

Returns:

(list) A list of CurveTRPL objects, each representing a piece-wise fit.

CurveTRPL_smoothBin(window_len=9, window='hanning', binning=4)

Returns a copy of the Curve after smoothening and data binning.

Parameters:
  • window_len – (width) number of points in the smooth window

  • window – (convolution widow) the type of window. Possible values: ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’, or ‘flat’ (moving average).

  • binning – how many points are merged.

CurveTRPL_spline(roi=None, transform='semilogx', numknots=30, minspacingnpts=4, maxspacingrange=0.1)

Fits the data with a spline and returns a CurveTRPL object.

Parameters:
  • roi – (list, optional): Region of interest for the fit, specified as [xmin, xmax]. Defaults to None.

  • transform – (str, optional): Transformation to apply to the data. Options: “semilogx”, “semilogy”, “loglog”, “linlin”, or “”. Defaults “semilogx”.

  • numknots – (int, optional): Target number of knots for spline interpolation. Defaults to 30.

  • minspacingnpts – (int, optional): Minimum spacing between knots, in number of data points. Defaults to 4.

  • maxspacingrange – (float, optional): Maximum spacing between knots, as a fraction of the x range. Defaults to 0.1.

Returns:

A CurveTRPL object with the fitted spline data.

Curve_differential_lifetime()

Returns a CurveTRPL object with differential (instantaneous) lifetime. Assuming y = A exp(- t / tau), formula is: tau(t) = - dt / d(ln(y)) Make sure to remove background before calculating differential lifetime.

Curve_differential_lifetime_vs_signal()

Returns differential lifetime versus signal (log(signal) proportional to QFLS) Differential lifetime: see Curve_differential_lifetime Make sure to remove background before calculating differential lifetime.

addOffset(value)

to adjust the background level. Data are modified. The previous adjustment is shown. The original data can be re-computed by setting the offset back to 0

addXOffset(value: float)

Adds a temporal offset, to place the peak onset at t=0. The curve data are modified. Adding a time offset is relevant as interpretation of fit intensity A values assumes the decay starts at t=0.

Parameters:

value – (float). If value is not a number, the software tries to autodetect the leading edge, as the last point below a threshold defined as the average of the 25% and 95% percentiles.

alterListGUI()

Determines the possible curve visualisations. One element has the form: AlterListItem(‘Label GUI’, [‘alter_x’, ‘alter_y’], ‘semilogx’, “print help doc”) By default only neutral (i.e. raw data) is provided

fit_resampleX(spacing)

This method modifies self. :param spacing: e.g. 3, or [xmin, xmax, xstep]

fitparams_weightedaverage(silent=False)

Weighted averages of decays: returns tau_effective with tau_i weighted by A_i, and by A_i * tau_i (i.e. integral of exponential). Formulas: (sum A_i * tau_i) / (sum A_i), and (sum A_i * tau_i^2) / (sum A_i * tau_i) Do not use if any tau values > time range of interest. The fit is weakly constrained, and the resulting average values may be artifact. Warning is raised if any tau value is larger than the time span.

Parameters:

silent – prints suff if False

Returns:

Sum (A tau) / Sum (A), Sum (A tau**2) / Sum (A tau)

funcListGUI(**kwargs)

Fills in the Curve actions specific to the Curve type. Retuns a list, which elements are instances of FuncGUI, or (old style):

[func,
 'Button text',
 ['label 1', 'label 2', ...],
 ['value 1', 'value 2', ...],
 {'hiddenvar1': 'value1', ...}, (optional)
 [dictFieldAttributes, {}, ...]] (optional)

By default, returns quick modifs for offset and muloffset (if already set), and a help for some plot types (errorbar, scatter).

Parameters:

kwargs – this function should be called specifying kwargs[‘graph’] the graph self is embedded in, and kwargs[‘graph_i’] as position of self in graph.

static func_fitExp(t, bg, a1, tau1, *args)

computes the sum of a cst plus an arbitrary number of exponentials To keep within class, will be called as getattr(CurveTRPL, functionname)()

integrate(ROI=None, alter=None)

Returns the integral of the curve, within ROI.

Parameters:
  • ROI – example [xmin, xmax]

  • alter – ‘raw’, or any Graph ‘alter’ value including (mul-)offsets.

normalize(repetfreq_Hz, duration_s, binwidth_ps)

Normalizes intensity of TRPL to account for repetition rate, acquisition duration and binwidth. Assumes data is in unit ‘counts’. Data: (raw+offset) * (1 / (syncfreq * (measstop-meastime) * binwidth))

setIntensity(offsetnew=None, factornew=None)

Data stored as (raw + offset) * factor