pyUSID.io.hdf_utils.model.reshape_to_n_dims

pyUSID.io.hdf_utils.model.reshape_to_n_dims(h5_main, h5_pos=None, h5_spec=None, get_labels=False, verbose=False, sort_dims=False, lazy=False)[source]

Reshape the input 2D matrix to be N-dimensions based on the position and spectroscopic datasets.

Parameters:
  • h5_main (HDF5 Dataset) – 2D data to be reshaped

  • h5_pos (HDF5 Dataset, optional) – Position indices corresponding to rows in h5_main

  • h5_spec (HDF5 Dataset, optional) – Spectroscopic indices corresponding to columns in h5_main

  • get_labels (bool, optional) – Whether or not to return the dimension labels. Default False

  • verbose (bool, optional) – Whether or not to print debugging statements

  • sort_dims (bool) – If True, the data is sorted so that the dimensions are in order from slowest to fastest If False, the data is kept in the original order If get_labels is also True, the labels are sorted as well.

  • lazy (bool, optional. Default = False) – If False, ds_Nd will be a numpy.ndarray object - this is suitable if the HDF5 dataset fits into memory If True, ds_Nd will be a dask.array object - This is suitable if the HDF5 dataset is too large to fit into memory. Note that this will bea lazy computation meaning that the returned object just contains the instructions . In order to get the actual value or content in numpy arrays, call ds_Nd.compute()

Returns:

  • ds_Nd (N-D numpy array or dask.array object) – N dimensional array arranged as [positions slowest to fastest, spectroscopic slowest to fastest]

  • success (boolean or string) – True if full reshape was successful

    ”Positions” if it was only possible to reshape by the position dimensions

    False if no reshape was possible

  • ds_labels (list of str) – List of the labels of each dimension of ds_Nd

Notes

If either h5_pos or h5_spec are not provided, the function will first attempt to find them as attributes of h5_main. If that fails, it will generate dummy values for them.