From 7a8f5dd0c6b246cb825b86fa0c4bc8710697dcba Mon Sep 17 00:00:00 2001 From: asia Date: Wed, 28 May 2025 10:17:51 +0200 Subject: [PATCH] Added function for reading a catalog --- python/catalog/read_catalog.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 python/catalog/read_catalog.py diff --git a/python/catalog/read_catalog.py b/python/catalog/read_catalog.py new file mode 100644 index 0000000..bb31024 --- /dev/null +++ b/python/catalog/read_catalog.py @@ -0,0 +1,22 @@ +# ----------------- +# Copyright © 2025 ACK Cyfronet AGH, Poland. +# ----------------- +from scipy.io import loadmat, whosmat + +def read_catalog(catalog_path): + """ + Reads the provided catalog in EPISODES Platform format (https://docs.cyfronet.pl/display/ISDOC/Catalogs) + + Parameters: + catalog_path: Path to the catalog file to be read. + + Returns: + catalog (np.ndarray): A structured NumPy array representing the catalog. + + Raises: + ValueError: If the specified field name is not found in the catalog. + """ + catalog_contents = loadmat(catalog_path, mat_dtype=True) + catalog_field_name = whosmat(catalog_path)[0][0] # Getting the name of first non-metadata field + catalog = catalog_contents[catalog_field_name][0] + return catalog \ No newline at end of file