From 2ebe5f322009befd2dae4b92ee96f543984b21d0 Mon Sep 17 00:00:00 2001 From: Florez Ospina Juan Felipe Date: Thu, 11 Jul 2024 13:42:38 +0200 Subject: [PATCH] Made edits to documentation --- src/g5505_file_reader.py | 15 +++++---- src/hdf5_lib.py | 71 ++++++++++++++++++++++++---------------- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/g5505_file_reader.py b/src/g5505_file_reader.py index 67f7253..7e43c27 100644 --- a/src/g5505_file_reader.py +++ b/src/g5505_file_reader.py @@ -20,13 +20,13 @@ def read_xps_ibw_file_as_dict(filename): and formats the data into a dictionary with the structure {datasets: list of datasets}. Each dataset in the list has the following structure: - { - 'name': 'name', - 'data': data_array, - 'data_units': 'units', - 'shape': data_shape, - 'dtype': data_type - } + { + 'name': 'name', + 'data': data_array, + 'data_units': 'units', + 'shape': data_shape, + 'dtype': data_type + } Parameters ---------- @@ -42,6 +42,7 @@ def read_xps_ibw_file_as_dict(filename): ------ ValueError If the input IBW file is not a valid IBW file. + """ diff --git a/src/hdf5_lib.py b/src/hdf5_lib.py index 82e60ed..bb6a700 100644 --- a/src/hdf5_lib.py +++ b/src/hdf5_lib.py @@ -220,27 +220,33 @@ def transfer_file_dict_to_hdf5(h5file, group_name, file_dict): """ Transfers data from a file_dict to an HDF5 file. - Parameters: - h5file (h5py.File): HDF5 file object where the data will be written. - group_name (str): Name of the HDF5 group where data will be stored. - file_dict (dict): Dictionary containing file data to be transferred. - Required structure: + Parameters + ---------- + h5file : h5py.File + HDF5 file object where the data will be written. + group_name : str + Name of the HDF5 group where data will be stored. + file_dict : dict + Dictionary containing file data to be transferred. Required structure: + { + 'name': str, + 'attributes_dict': dict, + 'datasets': [ { 'name': str, - 'attributes_dict': dict, - 'datasets': [ - { - 'name': str, - 'data': array-like, - 'shape': tuple, - 'attributes': dict (optional) - }, - ... - ] - } - - + 'data': array-like, + 'shape': tuple, + 'attributes': dict (optional) + }, + ... + ] + } + + Returns + ------- + None """ + if not file_dict: return @@ -273,7 +279,6 @@ def create_hdf5_file_from_filesystem_path(output_filename : str, root_metadata_dict : dict = {}): """ - Creates an .h5 file with name "output_filename" that preserves the directory tree (or folder structure) of a given filesystem path. @@ -281,20 +286,28 @@ def create_hdf5_file_from_filesystem_path(output_filename : str, admissible file formats. These, however, can be extended. Directories are groups in the resulting HDF5 file. Files are formatted as composite objects consisting of a group, file, and attributes. - Parameters: - output_filename (str): Name of the output HDF5 file. - input_file_system_path (str): Path to root directory, specified with forward slashes, e.g., path/to/root. - select_dir_keywords (list): List of string elements to consider or select only directory paths that contain + Parameters + ---------- + output_filename : str + Name of the output HDF5 file. + input_file_system_path : str + Path to root directory, specified with forward slashes, e.g., path/to/root. + select_dir_keywords : list + List of string elements to consider or select only directory paths that contain a word in 'select_dir_keywords'. When empty, all directory paths are considered to be included in the HDF5 file group hierarchy. - select_file_keywords (list): List of string elements to consider or select only files that contain a word in + select_file_keywords : list + List of string elements to consider or select only files that contain a word in 'select_file_keywords'. When empty, all files are considered to be stored in the HDF5 file. - top_sub_dir_mask (bool): Mask for top-level subdirectories. - root_metadata_dict (dict): Metadata to include at the root level of the HDF5 file. - - Returns: - str: Path to the created HDF5 file. + top_sub_dir_mask : bool + Mask for top-level subdirectories. + root_metadata_dict : dict + Metadata to include at the root level of the HDF5 file. + Returns + ------- + output_filename : str + Path to the created HDF5 file. """ allowed_file_extensions = list(ext_to_reader_dict.keys()) # list(config_file.select_file_readers(group_id).keys())