BGlib.be.analysis.be_loop_fitter.BELoopFitter

class BGlib.be.analysis.be_loop_fitter.BELoopFitter(h5_main, be_data_type, vs_mode, vs_cycle_frac, **kwargs)[source]

Bases: Fitter

A class that fits Simple Harmonic Oscillator model data to a 9-parameter model to describe hysteretic switching in ferroelectric materials

Notes

Quantitative mapping of switching behavior in piezoresponse force microscopy, Stephen Jesse, Ho Nyung Lee, and Sergei V. Kalinin, Review of Scientific Instruments 77, 073702 (2006); doi: http://dx.doi.org/10.1063/1.2214699

Parameters:
  • h5_main (h5py.Dataset) – The dataset over which the analysis will be performed. This dataset should be linked to the spectroscopic indices and values, and position indices and values datasets.

  • data_type (str) – Type of data. This is an attribute written to the HDF5 file at the root level by either the translator or the acquisition software. Accepted values are: ‘BEPSData’ and ‘cKPFMData’ Default - this function will attempt to extract this metadata from the HDF5 file

  • vs_mode (str) –

    Type of measurement. Accepted values are:

    ’AC modulation mode with time reversal’ or ‘DC modulation mode’ This is an attribute embedded under the “Measurement” group with the following key: ‘VS_mode’. Default - this function will attempt to extract this metadata from the HDF5 file

  • vs_cycle_frac (str) – Fraction of the bi-polar triangle waveform for voltage spectroscopy used in this experiment

  • h5_target_group (h5py.Group, optional. Default = None) – Location where to look for existing results and to place newly computed results. Use this kwarg if the results need to be written to a different HDF5 file. By default, this value is set to the parent group containing h5_main

  • kwargs (passed onto pyUSID.Process) –

Methods

compute

Creates placeholders for the results, applies the _unit_computation() to chunks of the dataset

do_fit

Computes the Fit

do_guess

Computes the Guess

extract_loop_parameters

Method to extract a set of physical loop parameters from a dataset of fit parameters :param h5_loop_fit: Dataset of loop fit parameters :type h5_loop_fit: h5py.Dataset :param nuc_threshold: Nucleation threshold to use in calculation physical parameters :type nuc_threshold: float

set_up_fit

Performs necessary book-keeping before do_fit can be called.

set_up_guess

Performs necessary book-keeping before do_guess can be called.

test

Tests the process on a subset (for example a pixel) of the whole data.

use_partial_computation

Extracts the necessary parameters from the provided h5 group to resume computation

Attributes

parms_dict

The name of the HDF5 dataset that should be present to signify which positions have already been computed This is NOT a fully private variable so that multiple processes can be run within a single group - Eg Fitter In the case of Fitter - this name can be changed from 'completed_guesses' to 'completed_fits' check_for_duplicates will be called by the Child class where they have the opportunity to change this variable before checking for duplicates

compute(override=False, *args, **kwargs)

Creates placeholders for the results, applies the _unit_computation() to chunks of the dataset

Parameters:
  • override (bool, optional. default = False) – By default, compute will simply return duplicate results to avoid recomputing or resume computation on a group with partial results. Set to True to force fresh computation.

  • args (list) – arguments to the mapped function in the correct order

  • kwargs (dict) – keyword arguments to the mapped function

Returns:

h5_results_grp – Group containing all the results

Return type:

h5py.Group

do_fit(override=False)[source]

Computes the Fit

Parameters:

override (bool, optional) – If True, computes a fresh guess even if existing Fit was found Else, returns existing Fit dataset. Default = False

Returns:

HDF5 dataset with the Fit computed

Return type:

USIDataset

do_guess(*args, override=False, **kwargs)

Computes the Guess

Parameters:
  • args (list, optional) – List of arguments

  • override (bool, optional) – If True, computes a fresh guess even if existing Guess was found Else, returns existing Guess dataset. Default = False

  • kwargs (dict, optional) – Keyword arguments

Returns:

HDF5 dataset with the Guesses computed

Return type:

USIDataset

static extract_loop_parameters(h5_loop_fit, nuc_threshold=0.03)[source]

Method to extract a set of physical loop parameters from a dataset of fit parameters :param h5_loop_fit: Dataset of loop fit parameters :type h5_loop_fit: h5py.Dataset :param nuc_threshold: Nucleation threshold to use in calculation physical parameters :type nuc_threshold: float

Returns:

h5_loop_parm – Dataset of physical parameters

Return type:

h5py.Dataset

parms_dict

The name of the HDF5 dataset that should be present to signify which positions have already been computed This is NOT a fully private variable so that multiple processes can be run within a single group - Eg Fitter In the case of Fitter - this name can be changed from ‘completed_guesses’ to ‘completed_fits’ check_for_duplicates will be called by the Child class where they have the opportunity to change this variable before checking for duplicates

set_up_fit(h5_partial_fit=None, h5_guess=None)[source]

Performs necessary book-keeping before do_fit can be called. Also remaps data reading, computation, writing functions to those specific to Fit

Parameters:
  • h5_partial_fit (h5py.Dataset or pyUSID.io.USIDataset, optional) – HDF5 dataset containing partial Fit. Not implemented

  • h5_guess (h5py.Dataset or pyUSID.io.USIDataset, optional) – HDF5 dataset containing completed Guess. Not implemented

set_up_guess(h5_partial_guess=None)[source]

Performs necessary book-keeping before do_guess can be called. Also remaps data reading, computation, writing functions to those specific to Guess

Parameters:

h5_partial_guess (h5py.Dataset or pyUSID.io.USIDataset, optional) – HDF5 dataset containing partial Guess. Not implemented

test(**kwargs)

Tests the process on a subset (for example a pixel) of the whole data. The class can be re-instantiated with improved parameters and tested repeatedly until the user is content, at which point the user can call compute() on the whole dataset.

Notes

This is not a function that is expected to be called in MPI

Parameters:
  • dict (kwargs -) – keyword arguments to test the process

  • optional – keyword arguments to test the process

use_partial_computation(h5_partial_group=None)

Extracts the necessary parameters from the provided h5 group to resume computation

Parameters:

h5_partial_group (h5py.Group) – Group containing partially computed results