ctrappy.file

Code for opening and saving files.

Generates a link to download the given object_to_download for streamlit.

object_to_download (str, pd.DataFrame, dict): The object to be downloaded. download_filename (str): filename and extension of file. e.g. mydata.csv, some_txt_output.txt, output.yaml download_link_text (str): Text to display for download link.

Examples: download_link(YOUR_DF, ‘YOUR_DF.csv’, ‘Click here to download data!’) download_link(YOUR_STRING, ‘YOUR_STRING.txt’, ‘Click here to download your text!’) download_link(YOUR_DICT, ‘YOUR_STRING.yaml’, ‘Click here to download your dict!’)

ctrappy.file.get_avg_quantity_from_h5file(quantity, start, stop)

Read a quantity from an h5 file between timestamps start/stop; take the mean.

ctrappy.file.get_full_quantity_from_h5file(quantity, start, stop)

Read a quantity from an h5 file between timestamps start/stop.

ctrappy.file.get_scan_force_distance_data(h5file, scan, raise_errors=True)

Get the force and distance data from an h5 file during a scan; output as DataFrame.

ctrappy.file.get_scan_metadata(h5file, scan, raise_errors=True)

Get scan metadata from an h5file; output as dictionary.

ctrappy.file.read_biotiff(path)

Read scan from tiff file.

Parameters:

path (str) – Path to file.

Returns:

output – Scan object.

Return type:

scan

ctrappy.file.read_config(path, schema='ctrappy_configuration')

Read config yaml file from path.

ctrappy.file.read_h5file(path)

Read scan images from h5 file.

Parameters:

path (str) – Path to file.

Returns:

  • h5file (pylake.File) – Pylake file object.

  • output (dict) – Dict with scan names (keys) and Scan objects (values).

ctrappy.file.read_yaml(path, schema=None)

Read yaml file from path. Allowed schemas are ‘gui_defaults’, ‘ctrappy_configuration’, ‘tiff_metadata’, ‘tracking_params’.