8 Commits

5 changed files with 55 additions and 33 deletions

View File

@@ -10,6 +10,9 @@
% It follows the Singleton pattern to ensure that only one instance of the logger
% exists throughout the application.
%
% The log file is specified by the environment variable 'APP_LOG_FILE'. If
% the variable is not set, a default file 'base-logger-log.log' is used.
%
% Properties:
% fid - (private) The file identifier for the log file. This is used to write logs.
%
@@ -17,20 +20,20 @@
%
% getInstance() - Retrieves the singleton instance of the logger.
%
% trace(message) - Logs a message with TRACE level.
% @param message The message to log.
% trace(varargin) - Logs one or more messages with TRACE level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% debug(message) - Logs a message with DEBUG level.
% @param message The message to log.
% debug(varargin) - Logs one or more messages with DEBUG level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% info(message) - Logs a message with INFO level.
% @param message The message to log.
% info(varargin) - Logs one or more messages with INFO level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% warning(message) - Logs a message with WARNING level.
% @param message The message to log.
% warning(varargin) - Logs one or more messages with WARNING level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% error(message) - Logs a message with ERROR level.
% @param message The message to log.
% error(varargin) - Logs one or more messages with ERROR level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% delete() - Destructor method that closes the file identifier when the logger is deleted.
%

View File

@@ -10,6 +10,9 @@
% It follows the Singleton pattern to ensure that only one instance of the logger
% exists throughout the application.
%
% The log file is specified by the environment variable 'APP_LOG_FILE'. If
% the variable is not set, a default file 'base-logger-log.log' is used.
%
% Properties:
% fid - (private) The file identifier for the log file. This is used to write logs.
%
@@ -17,20 +20,20 @@
%
% getInstance() - Retrieves the singleton instance of the logger.
%
% trace(message) - Logs a message with TRACE level.
% @param message The message to log.
% trace(varargin) - Logs one or more messages with TRACE level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% debug(message) - Logs a message with DEBUG level.
% @param message The message to log.
% debug(varargin) - Logs one or more messages with DEBUG level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% info(message) - Logs a message with INFO level.
% @param message The message to log.
% info(varargin) - Logs one or more messages with INFO level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% warning(message) - Logs a message with WARNING level.
% @param message The message to log.
% warning(varargin) - Logs one or more messages with WARNING level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% error(message) - Logs a message with ERROR level.
% @param message The message to log.
% error(varargin) - Logs one or more messages with ERROR level.
% @param varargin The messages to log. Can be strings, numbers, or MException objects.
%
% delete() - Destructor method that closes the file identifier when the logger is deleted.
%

View File

@@ -20,8 +20,8 @@ def find_catalog_column(catalog, field_name):
Finds the index of a column in the catalog based on its field name.
Parameters:
catalog (np.ndarray): A structured NumPy array representing the catalog, where each row
corresponds to a field with attributes like 'field', 'val', etc.
catalog (np.ndarray): A structured NumPy array representing a catalog in EPISODES Platform format:
https://docs.cyfronet.pl/display/ISDOC/Catalogs
field_name (str): The field name of the entry to search for.
Returns:

View File

@@ -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

View File

@@ -16,14 +16,15 @@
# This work was partially funded by DT-GEO Project.
# -----------------
import numpy as np
from find_catalog_column import find_catalog_column
def sort_by_time(catalog):
"""
Sorts the given catalog based on the 'Time' column.
Sorts the given catalog based on the 'Time' column. Requires find_catalog_column script to work.
Parameters:
catalog (np.ndarray): A structured NumPy array representing the catalog, where each row
contains fields like 'Time', 'ID', and others.
catalog (np.ndarray): A structured NumPy array representing a seismic catalog in EPISODES Platform format:
https://docs.cyfronet.pl/display/ISDOC/Seismic+catalog
Returns:
np.ndarray: The sorted catalog, where rows in 'val' fields are ordered by ascending 'Time' values.
@@ -31,14 +32,7 @@ def sort_by_time(catalog):
Raises:
ValueError: If the 'Time' column is not found in the catalog.
"""
time_col_index = None
for idx, col in enumerate(catalog):
if col['field'] == "Time":
time_col_index = idx
if time_col_index is None:
raise ValueError("No 'Time' field found in the catalog.")
time_col_index = find_catalog_column(catalog, 'Time')
time_values = catalog[time_col_index]['val'].flatten()
sorted_indexes = np.argsort(time_values)