ffta.load package¶
Module contents¶
ffta.load.get_utils module¶
Created on Fri Aug 24 13:40:54 2018
@author: Raj
- ffta.load.get_utils.change_params(h5_path, new_vals={}, verbose=False)¶
Changes a parameter to a new value
This is equivalent to h5_main.parent.attrs[key] = new_value
- Parameters
h5_path (str or h5py) – Can pass either an h5_path to a file or a file already in use
new_vals –
verbose (bool, optional) – Prints all parameters to console
- Returns
- Return type
- ffta.load.get_utils.get_line(h5_path, line_num, params={}, array_form=False, avg=False, transpose=False)¶
Gets a line of data.
If h5_path is a dataset it processes based on user-defined pnts_avg If h5_path is a group/file/string_path then it can be a Line class or array
- Parameters
h5_path (str or h5py or Dataset) – Can pass either an h5_path to a file or a file already in use or a specific Dataset
line_num (int) – Returns specific line in the dataset
params (dict) – If explicitly changing parameters (to test a feature), you can pass any subset and this will overwrite it e.g. parameters = {‘drive_freq’: 10} will extract the Line, then change Line.drive_freq = 10
array_form (bool, optional) – Returns the raw array contents rather than Line class
avg (bool, optional) – Averages the pixels of the entire line This will force output to be an array
transpose (bool, optional) – For legacy FFtrEFM code, pixel is required in (n_points, n_signals) format
- ffta.load.get_utils.get_params(h5_path, key='', verbose=False, del_indices=True)¶
Gets dict of parameters from the FF-file Returns a specific key-value if requested
- Parameters
h5_path (str or h5py) – Can pass either an h5_path to a file or a file already in use
key (str, optional) – Returns specific key in the parameters dictionary
verbose (bool, optional) – prints all parameters to console
del_indices (bool, optional) – Deletes relative links within the H5Py and any quantity/units
- Returns
- Return type
- ffta.load.get_utils.get_pixel(h5_path, rc, params={}, pixel_params={}, array_form=False, avg=False, transpose=False)¶
Gets a pixel of data, returns all the averages within that pixel Returns a specific key if requested Supplying a direct link to a Dataset is MUCH faster than just the file Note that you should supply the deflection data, not instantaneous_frequency
- Parameters
h5_path (str or h5py or Dataset) – Can pass either an h5_path to a file or a file already in use or specific Dataset Again, should pass the deflection data (Rebuilt_Data, or FF_Avg)
rc (list [r, c]) – Pixel location in terms of ROW, COLUMN
params (dict) – If explicitly changing parameters (to test a feature), you can pass any subset and this will overwrite it e.g. parameters = {‘drive_freq’: 10} will extract the Pixel, then change Pixel.drive_freq = 10
pixel_params (dict, optional) – Parameters ‘fit’, ‘pycroscopy’, ‘method’, ‘fit_form’ See ffta.pixel for details. ‘pycroscopy’ is set to True in this function
array_form (bool, optional) – Returns the raw array contents rather than Pixel class
avg (bool, optional) – Averages the pixels of n_pnts_per_pixel and then creates Pixel of that
transpose (bool, optional) – For legacy FFtrEFM code, pixel is required in (n_points, n_signals) format
- Returns
2D numpy array signal_line iff array_form == True, contains hte line OR Line line_inst iff array_form == False, contains signal_array object and parameters
ffta.load.gl_ibw module¶
Created on Wed Feb 21 10:06:12 2018
@author: Raj Giridharagopal
- class ffta.load.gl_ibw.GLIBWTranslator(*args, **kwargs)¶
Bases:
TranslatorTranslates Ginger Lab Igor Binary Wave (.ibw) files containing images or force curves to .h5
- translate(file_path, verbose=False, parm_encoding='utf-8', ftype='FF', subfolder='Measurement_000', h5_path='', channel_label_name=True)¶
Translates the provided file to .h5 Adapted heavily from pycroscopy IBW file, modified to work with Ginger format
- Parameters
file_path (String / unicode) – Absolute path of the .ibw file
verbose (boolean, optional) – Whether or not to show print statements for debugging
parm_encoding (str, optional) – Codec to be used to decode the bytestrings into Python strings if needed. Default ‘utf-8’
ftype (str, optional) – Delineates Ginger Lab imaging file type to be imported (not case-sensitive) ‘FF’ : FF-trEFM ‘SKPM’ : FM-SKPM ‘ringdown’ : Ringdown ‘trEFM’ : normal trEFM
subfolder (str, optional) – Specifies folder under root (/) to save data in. Default is standard pycroscopy format
h5_path (str, optional) – Existing H5 file to append to
channel_label_name (bool, optional) – If True, uses the Channel as the subfolder name (e.g. Height, Phase, Amplitude, Charging)
- Returns
Absolute path of the .h5 file
- Return type
String / unicode
ffta.load.load_commands module¶
Created on Thu Jan 30 15:53:47 2020
@author: Raj
- ffta.load.load_commands.hdf_commands(h5_path, ds='FF_Raw')¶
Creates a bunch of typical workspace HDF5 variables for scripting use
- param h5_path
String path to H5PY file
ffta.load.load_hdf module¶
loadHDF5.py: Includes routines for loading into HDF5 files.
- ffta.load.load_hdf.load_FF(data_files, parm_dict, h5_path, verbose=False, loadverbose=True, average=True, mirror=True)¶
Generates the HDF5 file given path to data_files and parameters dictionary
Creates a Datagroup FFtrEFM_Group with a single dataset in chunks
- Parameters
data_files (list) – List of the *.ibw files to be invidually scanned. This is generated by load_folder above
parm_dict (dict) – Scan parameters to be saved as attributes. This is generated by load_folder above, or you can pass this explicitly.
h5_path –
:type h5_path : string
- Parameters
verbose (bool, optional) – Display outputs of each function or not
loadverbose (bool, optional) – Whether to print any simple “loading Line X” statements for feedback
average (bool, optional) – Whether to average each pixel before saving to H5. This saves both time and space
mirror (bool, optional) – Mirrors the data when saving. This parameter is to match the FFtrEFM data with the associate topography as FFtrEFM is acquired during a retrace while topo is saved during a forward trace
- Returns
The filename path to the H5 file created
- Return type
str
- ffta.load.load_hdf.load_folder(folder_path='', xy_scansize=[0, 0], file_name='FF_H5', textload=False, verbose=False)¶
Sets up loading the HDF5 files. Parses the data file list and creates the .H5 file path
- Parameters
folder_path (string) – Path to folder you want to process
xy_scansize (2-float array) – Width by Height in meters (e.g. [8e-6, 4e-6]), if not in parameters file
file_name (str) – Desired file name, otherwise is auto-generated
textload (bool, optional) – If you have a folder of .txt instead of .ibw (older files, some synthetic data)
verbose (bool, optional) – Whether to output the datasets being processed
- Returns
tuple (h5_path, data_files, parm_dict) WHERE str h5_path is the filename path to the H5 file created List data_files is the list of *.ibw files in the folder to be processed dict parm_dict is the dictionary of relevant scan parameters
- ffta.load.load_hdf.load_pixel_averaged_from_raw(h5_file, verbose=True, loadverbose=True)¶
Creates a new group FF_Avg where the FF_raw file is averaged together.
This is more useful as pixel-wise averages are more relevant in FF-processing
This Dataset is (n_pixels*n_rows, n_pnts_per_avg)
- Parameters
h5_file (h5py File) – H5 File to be examined. File typically set as h5_file = hdf.file hdf = px.ioHDF5(h5_path), h5_path = path to disk
verbose (bool, optional) – Display outputs of each function or not
loadverbose (bool, optional) – Whether to print any simple “loading Line X” statements for feedback
- Returns
The new averaged Dataset
- Return type
Dataset
- ffta.load.load_hdf.load_wrapper(ibw_file_path='', ff_file_path='', ftype='FF', verbose=False, subfolder='/', loadverbose=True, average=True, mirror=True)¶
Wrapper function for processing a .ibw file and associated FF data
Average just uses the pixel-wise averaged data Raw_Avg processes the raw deflection data, then averages those together
Loads .ibw single file an HDF5 format. Then appends the FF data to that HDF5
- Parameters
ibw_file_path (string, optional) – Path to signal file IBW with images to add.
ff_file_path (string, optional) – Path to folder containing the FF-trEFM files and config file. If empty prompts dialogue
ftype (str, optional) – Delineates Ginger Lab imaging file type to be imported (not case-sensitive) ‘FF’ : FF-trEFM ‘SKPM’ : FM-SKPM ‘ringdown’ : Ringdown ‘trEFM’ : normal trEFM
verbose (bool, optional Whether or not to show print statements for debugging. Passed to Pycroscopy functions) –
subfolder (string) – Specifies folder under root (/) to save data in. Default is standard pycroscopy format
loadverbose (bool, optional) – Whether to print any simple “loading Line X” statements for feedback
average (bool, optional) – Whether to automatically call the load_pixel_averaged_FF function to average data at each pixel
mirror (bool, optional) – Whether to reverse the data on each line read (since data are usually saved during a RETRACE scan)
- Returns
tuple (h5_path, parm_dict, h5_ff) WHERE string h5_path is the filename path to the H5 file created dict parm_dict Dictionary of relevant scan parameters [type] h5_ff is…
ffta.load.load_ringdown module¶
Created on Tue Mar 31 11:16:36 2020
@author: Raj
- ffta.load.load_ringdown.exp(t, A1, y0, tau)¶
Uses a single exponential for the case of no drive
- Parameters
t –
A1 –
y0 –
tau –
- Returns
- Return type
- ffta.load.load_ringdown.fit_exp(t, cut)¶
- Parameters
t –
cut –
- Returns
- Return type
- ffta.load.load_ringdown.load_ringdown(data_files, parm_dict, h5_path, verbose=False, loadverbose=True, average=True, mirror=False)¶
Generates the HDF5 file given path to files_list and parameters dictionary
Creates a Datagroup FFtrEFM_Group with a single dataset in chunks
- Parameters
data_files (list) – List of the *.ibw files to be invidually scanned
parm_dict (dict) – Scan parameters to be saved as attributes
h5_path (string) – Path to H5 file on disk
verbose (bool, optional) – Display outputs of each function or not
loadverbose (bool, optional) – Whether to print any simple “loading Line X” statements for feedback
average (bool, optional) – Whether to reverse the data on each line read (since data are usually saved during a RETRACE scan)
mirror (bool, optional) – Flips the ibw signal if acquired during a retrace, so data match the topography pixel-to-pixel
- Returns
The filename path to the H5 file created
- Return type
str
- ffta.load.load_ringdown.plot_ringdown(h5_file, h5_path='/', append='', savefig=True, stdevs=2)¶
Plots the relevant tfp, inst_freq, and shift values as separate image files
- Parameters
h5_file (h5Py File) –
h5_path (str, optional) – Location of the relevant datasets to be saved/plotted. e.g. h5_rb.name
append (str, optional) – A string to include in the saved figure filename
savefig (bool, optional) – Whether or not to save the image
stdevs (int, optional) – Number of standard deviations to display
- Returns
tuple (fig, a) WHERE fig is figure object a is axes object
- ffta.load.load_ringdown.reprocess_ringdown(h5_rd, fit_time=[1, 5])¶
Reprocess ringdown data using an exponential fit around the timescales indicated.
- Parameters
h5_rd – Ringdown dataset
:type h5_rd : USIDataset
- Parameters
fit_time (list) – The times (in milliseconds) to fit between. This function uses a single exponential fit
- ffta.load.load_ringdown.save_CSV_from_file(h5_file, h5_path='/', append='', mirror=False)¶
Saves the Q, Amp, as CSV files
- Parameters
h5_file (H5Py file) – Reminder you can always type: h5_svd.file or h5_avg.file for this
h5_path (str, optional) – specific folder path to search for the tfp data. Usually not needed.
append (str, optional) – text to append to file name (e.g. RD01 or something related to the file)
mirror (bool, optional) – Flips the ibw signal if acquired during a retrace, so data match the topography pixel-to-pixel
- ffta.load.load_ringdown.test_fitting(h5_rd, pixel=0, fit_time=[1, 5], plot=True)¶
Tests curve fitting on a particular pixel, then plots the result
- Parameters
h5_rd (USIDataset) – Ringdown dataset
pixel (int) – Which pixel to fit to.
fit_time (list) – The times (in milliseconds) to fit between. This function uses a single exponential fit
plot (bool, optional) –
- Returns
- Return type
- ffta.load.load_ringdown.wrapper(ibw_file_path='', rd_folder='', verbose=False, subfolder='/', loadverbose=True, mirror=True, average=True, AMPINVOLS=1e-07)¶
Wrapper function for processing a .ibw file and associated ringdown data
Average just uses the pixel-wise averaged data Raw_Avg processes the raw deflection data, then averages those together
Loads .ibw single file an HDF5 format. Then appends the FF data to that HDF5
- Parameters
ibw_file_path (string, optional) – Path to signal file IBW with images to add.
rd_folder (string, optional) – Path to folder containing the Ringdown files and config file. If empty prompts dialogue
verbose (bool, optional) – Whether or not to show print statements for debugging. Passed to Pycroscopy functions
subfolder (str, optional) – Specifies folder under root (/) to save data in. Default is standard pycroscopy format
loadverbose (bool, optional) – Whether to print any simple “loading Line X” statements for feedback
mirror (bool, optional) –
average (bool, optional) – Whether to automatically call the load_pixel_averaged_FF function to average data at each pixel
AMPINVOLS (float) – inverted optical level sensitivity (scaling factor for amplitude). if not provided, it will search for one in the attributes of h5_rd or use default
- Returns
- Return type
USIDataset of ringdown