API Reference

class PyThat.MeasurementTree(path, override=False, index=True)

Return a list of random ingredients as strings.

Parameters:
  • path – Path to .h5 measurement file. Can be relative or absolute path.

  • override – This will force PyThat to reconstruct the measurement tree again, even if there is already a netcdf file (.nc) from a previous run. Setting this to True is the only way to ensure that most attributes are available during a run.

  • index (bool, tuple (i, j) or None) –

    Default True: All of the measurement data being loaded into a xarray Dataset.

    Tuple: DataArray of that particular group.

    None: User input after the measurement tree has been printed.

    False: Exit after measurement tree has been printed.

dataset
Type:

xarray.Dataset

If index is True, all available data will be included here.

array
Type:

xarray.DataArray

If index is None or Tuple, the data from the selected row will be included here.

path
Type:

pathlib.Path

Absolute path to h5 file

filepath
Type:

str

String representation of the filepath as entered by user.

index
Type:

Bool, tuple or None

Index of data which will be read during construct_tree. Will iterate through all relevant rows if True.

f
Type:

h5py.File

File handler of the .h5 file.

save_path
Type:

None or pathlib.Path

Path to the generated netcdf (.nc) file.

definition
Type:

dict

Scan definition/measurement tree of the measurement as saved by THATec without any processing.

tree_string
Type:

str

String representation of the scan definition/measurement tree.

labbook
Type:

dict

Contains labbook entries as specified in Thatec interface.

devices
Type:

dict

Contains devices configuration at beginning of measurement.

logs
Type:

dict

Contains log entries which occured during the measurement.

metadata
Type:

dict

Contains measurement metadata such as date and operator as specified in Thatec interface.

construct_tree()

Goes through scan definition and reconstructs data in .h5 file. Is automatically called on creation of object.

open_netcdf()

Open netcdf file from savepath.

save_netcdf()

Save array to netcdf file at savepath.

save_netcdf_dset()

Save dataset to netcdf file at savepath.

print_metadata(metadata)

Comfort function to print metadata in yaml formatting.

Parameters:

metadata – Can be Can be {‘devices’, ‘labbook’, ‘logs’, ‘scan_definition’}

class PyThat.Group(m_tree: PyThat.MeasurementTree)

Helper class for organizing measurement tree.

Helper Functions

PyThat.consolidate_dims(array, name_includes, compare_to: str or None = None, new_dim: str = None)

This function helps finding unnecessary duplicates of dimensions.

Parameters:
  • array – The xarry object which is to be changed.

  • name_includes – String which must be included in the dimension name or list of dimension names which should be merged.

  • compare_to – String or None: The equality of this coordinate axis with all other axis is a condition for merging. If this entry is not provided, it loops through all entries which match name_includes, until a duplicate is found.

  • new_dim – Name which will be given to the merged dimension. Defaults to compare_to

Returns:

xarray object where dimension and coordinate duplicates have been dropped.