skultrafast.twoD_dataset ======================== .. py:module:: skultrafast.twoD_dataset Attributes ---------- .. autoapisummary:: skultrafast.twoD_dataset.num_integration skultrafast.twoD_dataset.PathLike Classes ------- .. autoapisummary:: skultrafast.twoD_dataset.SingleCLSResult skultrafast.twoD_dataset.FFCFResult skultrafast.twoD_dataset.CLSResult skultrafast.twoD_dataset.DiagResult skultrafast.twoD_dataset.ExpFit2DResult skultrafast.twoD_dataset.GaussResult skultrafast.twoD_dataset.TwoDim Module Contents --------------- .. py:data:: num_integration .. py:data:: PathLike .. py:class:: SingleCLSResult Result of a single CLS fit. .. py:attribute:: pump_wn :type: numpy.ndarray Pump wavenumbers. .. py:attribute:: max_pos :type: numpy.ndarray Maximum positions for each pump-slice. .. py:attribute:: max_pos_err :type: numpy.ndarray Standard error of the maximum positions. Nan if not available .. py:attribute:: slope :type: float Slope of the linear fit. .. py:attribute:: reg_result :type: Any Result of the linear regression using statsmodels. .. py:attribute:: recentered_pump_wn :type: numpy.ndarray Recentered pump wavenumbers by mean subtraction. Used in the linear regression. .. py:attribute:: linear_fit :type: numpy.ndarray Linear fit of the CLS data. .. py:class:: FFCFResult Baseclass for FFCF determination methods. For backwards compatibility, the values are always called slopes .. py:attribute:: wt :type: numpy.ndarray Wait times. .. py:attribute:: slopes :type: numpy.ndarray Values .. py:attribute:: slope_errors :type: Optional[numpy.ndarray] :value: None .. py:attribute:: exp_fit_result_ :type: Optional[lmfit.model.ModelResult] :value: None .. py:method:: exp_fit(start_taus: List[float], use_const=True, use_weights=True) .. py:method:: plot_cls(ax=None, model_style: Dict = {}, symlog=False, **kwargs) .. py:class:: CLSResult Bases: :py:obj:`FFCFResult` Class holding the data of CLS-analysis. Has methods to analyze and plot them. .. py:attribute:: intercepts :type: numpy.ndarray Contains the intercepts, useful for plotting mostly .. py:attribute:: intercept_errors :type: Optional[numpy.ndarray] Errors of the intercepts .. py:attribute:: lines :type: List[numpy.ndarray] Contains the pump_wn, probe_wn, probe_wn-erroprs used for the linear fit, as well as the linear fit itself. .. py:class:: DiagResult .. py:attribute:: diag :type: numpy.ndarray Contains the diagonal signals of the 2d-spectra .. py:attribute:: antidiag :type: numpy.ndarray Contains the antidiagonal signals of the 2d-spectra .. py:attribute:: diag_coords :type: numpy.ndarray Contains the coordinates of the diagonal signals .. py:attribute:: antidiag_coords :type: numpy.ndarray Contains the coordinates of the antidiagonal signals .. py:attribute:: offset :type: float The offset of the diagonal signals .. py:attribute:: p :type: float The position crossing the diagonals .. py:class:: ExpFit2DResult .. py:attribute:: minimizer :type: lmfit.minimizer.MinimizerResult Lmfit minimizer result .. py:attribute:: model :type: TwoDim The fit data .. py:attribute:: residuals :type: numpy.ndarray The residuals of the fit .. py:attribute:: das :type: numpy.ndarray The decay amplitudes aka the DAS of the 2D-spectra .. py:attribute:: basis :type: numpy.ndarray The basis functions used for the fit .. py:attribute:: taus :type: numpy.ndarray The decay times of the fit .. py:class:: GaussResult Bases: :py:obj:`FFCFResult` A dataclass to hold the results of the Gaussian fit. .. py:attribute:: results :type: List[lmfit.model.ModelResult] List of lmfit results from the gaussian fits .. py:attribute:: fit_out :type: TwoDim TwoDim object with the fit data, useful for plotting .. py:class:: TwoDim Dataset for an two dimensional dataset. Requires the t- (waiting times),the probe- and pump-axes in addition to the three dimensional spec2d data. .. py:attribute:: t :type: numpy.ndarray Array of the waiting times .. py:attribute:: pump_wn :type: numpy.ndarray Array with the pump-wavenumbers .. py:attribute:: probe_wn :type: numpy.ndarray Array with the probe-wavenumbers .. py:attribute:: spec2d :type: numpy.ndarray Array with the data, shape must be (t.size, wn_probe.size, wn_pump.size) .. py:attribute:: info :type: Dict Meta Info .. py:attribute:: single_cls_result_ :type: Optional[SingleCLSResult] :value: None Contains the data from a Single CLS analysis .. py:attribute:: cls_result_ :type: Optional[CLSResult] :value: None Contains the data from a CLS analysis .. py:attribute:: plot :type: skultrafast.twoD_plotter.TwoDimPlotter Plot object offering plotting methods .. py:attribute:: interpolator_ :type: Optional[scipy.interpolate.RegularGridInterpolator] :value: None Contains the interpolator for the 2d-spectra .. py:attribute:: fit_exp_result_ :type: Optional[ExpFit2DResult] :value: None Contains the result of the exponential fit .. py:attribute:: unit_scaling :type: float :value: 1.0 Scaling factor for the units of the dataset .. py:method:: _make_int() .. py:method:: __attrs_post_init__() .. py:method:: copy() -> TwoDim Makes a copy of the dataset. .. py:method:: save_numpy(fname: PathLike) Saves the dataset as a numpy file. :param fname: The file name. :type fname: PathLike .. py:method:: load_numpy(fname: PathLike) -> TwoDim :classmethod: Loads a dataset from a numpy file. :param fname: The file name. :type fname: PathLike :returns: The dataset. :rtype: TwoDim .. py:method:: t_idx(t: float) -> int t_idx(t: Iterable[float]) -> List[int] Return nearest idx to nearest time value .. py:method:: t_d(t) -> numpy.ndarray Return the dataset nearest to the given time t .. py:method:: data_at(t: Optional[float] = None, probe_wn: Optional[float] = None, pump_wn: Optional[float] = None) -> numpy.ndarray Extracts the data at given coordinates. .. py:method:: probe_idx(wn: float) -> int Return nearest idx to nearest probe_wn value .. py:method:: pump_idx(wn: Union[float, Iterable[float]]) -> Union[int, List[int]] Return nearest idx to nearest pump_wn value .. py:method:: select_range(pump_range: Tuple[float, float], probe_range: Tuple[float, float], invert: bool = False) -> TwoDim Return a dataset containing only the selected region. .. py:method:: select_t_range(t_min: float = -np.inf, t_max: float = np.inf) -> TwoDim " Returns a dataset only containing the data within given time limits. .. py:method:: integrate_pump(lower: float = -np.inf, upper: float = np.inf) -> skultrafast.dataset.TimeResSpec Calculate and return 1D Time-resolved spectra for given range. Uses Simpson’s Rule for integration. :param lower: Lower pump wl :type lower: float :param upper: upper pump wl :type upper: float :returns: The corresponding 1D Dataset :rtype: TimeResSpec .. py:method:: single_cls(t: float, pr_range: Union[float, Tuple[float, float]] = 9.0, pu_range: Union[float, Tuple[float, float]] = 7.0, mode: Literal['neg', 'pos'] = 'neg', method: Literal['com', 'quad', 'fit', 'log_quad', 'skew_fit'] = 'com') -> SingleCLSResult Calculate the CLS for single 2D spectrum. :param t: Delay time of the spectrum to analyse :type t: float :param pr_range: How many wavenumbers away from the maximum to use for determining the exact position, by default 9, resulting a total range of 18 wavenumbers. Also accepts a tuple, which is interpreted as (lower, upper) range. :type pr_range: float or float, optional :param pu_range: The range around the pump-maxima used for calculating the CLS. If given a float, the range is calculated as (max - pu_range, max + pu_range). If given a tuple, it is interpreted as (lower, upper) range. :type pu_range: float, optional :param mode: negative or positive maximum, by default 'neg'. Ignored when method is 'nodal'. :type mode: ('neg', 'pos'), optional :param method: Selects the method used for determination of the maximum signal. `com` uses the center-of-mass, `quad` uses a quadratic fit and `fit` uses a gaussian fit. 'log_quad' uses a quadratic fit on the logarithm of the signal. 'skew_fit' uses a gaussian fit with a linear background. 'nodal' finds the zero-crossing of the signal. :type method: ('com', 'quad', 'fit', 'log_quad', 'skew_fit', 'nodal'), optional :returns: pump_wn max_pos max_pos_err slope reg_result recentered_pump_wn linear_fit :rtype: Returns SingleCLSResult object with attributes .. py:method:: cls(joblib_kws=None, **cls_args) -> CLSResult Calculates the CLS for all 2d-spectra. The arguments are given to the single cls function, except joblib_kw, which is forwarded to joblib.Parallel. Returns as `CLSResult`. .. py:method:: diag_and_antidiag(t: float, offset: Optional[float] = None, p: Optional[float] = None) -> DiagResult Extracts the diagonal and anti-diagonal. :param t: Waiting time of the 2d-spectra from which the data is extracted. :type t: float :param offset: Offset of the diagonal, if none, it will we determined by the going through the signal minimum. :type offset: float :param p: The point where the anti-diagonal crosses the diagonal. If none, it also goes through the signal minimum. :type p: float :returns: Contains the diagonals, coordinates and points. :rtype: CLSResult .. py:method:: pump_slice_amp(t: float, bg_correct: bool = True) -> numpy.ndarray " Calculates the pump-slice-amplitude for a given delay t. .. py:method:: apply_filter(kind: Literal['uniform', 'gaussian'], size, *args) -> TwoDim " Returns filtered dataset. :param kind: Which filter to use. Supported are uniform and gaussian. :type kind: str :param size: Kernel of the filter :type size: tuple[float, float, float] :returns: Filtered dataset. :rtype: TwoDim .. py:method:: save_txt(pname: PathLike, **kwargs) Saves 2d-spectra as a text files a directory. :param pname: Path to the file. :type pname: PathLike :param kwargs: Additional arguments for the np.savetxt function. .. py:method:: save_single_txt(fname: PathLike, i: int, **kwargs) Save a single 2D spectra as a text file :param fname: The file name. :type fname: str :param i: The index of the 2D spectra. :type i: int :param kwargs: Additional arguments for the `np.savetxt` function. .. py:method:: background_correction(excluded_range: tuple[float, float], deg: int = 3, exclude_diag: None | float = None) -> None Fits and subtracts a background for each pump-frequency. Done for each waiting time. Does the subtraction inplace, e.g. modifies the dataset. :param excluded_range: The range of the pump axis which is excluded from the fit, e.g. contains the signal. :type excluded_range: Tuple[float, float] :param deg: Degree of the polynomial fit. :type deg: int :param exclude_diag: If not None, the diagonal is excluded from the fit. This is useful where the is a lot of scattering at the diagonal. The value specifies the width of the diagonal to be excluded. If None, the diagonal is not excluded. :type exclude_diag: None|float :rtype: None .. py:method:: get_minmax(t: float, com: int = 3) -> Dict[str, float] Returns the position of the minimum and maximum of the dataset at time t. If com > 0, it return the center of mass around the minimum and maximum. The com argument gives the number of points to be used for the center of mass. :param t: The waiting time. :type t: float :param com: Number of points for the center of mass. :type com: int :returns: Dictionary with the positions of the minimum and maximum. Has the keys 'ProbeMin', 'ProbeMax', 'PSAMax', 'PumpMin', 'PumpMax', 'Anh'. :rtype: Dict[str, float] .. py:method:: integrate_reg(pump_range: Tuple[float, float], probe_range: Tuple[float, float] = None) -> numpy.ndarray Integrates the 2D spectra over a given range, using Simpson's rule. :param pump_range: The range of the pump axis to be integrated over. :type pump_range: tuple[float, float] :param probe_range: The range of the probe axis to be integrated over. If None, the probe range is used. :type probe_range: tuple[float, float] :returns: The integrated spectral signal for all waiting times. :rtype: np.ndarray .. py:method:: fit_taus(taus: numpy.ndarray) Given a set of decay times, fit the data to a sum of the exponentials. Used by the `fit_taus` method. .. py:method:: fit_das(taus, fix_last_decay=False) -> ExpFit2DResult Fit the data to a sum of exponentials (DAS), starting from the given decay constants. The results are stored in the `fit_exp_result` attribute. .. py:method:: fit_gauss(mode='both') -> GaussResult Fits the 2D spectra using two gaussians peaks.