4 Commits

2 changed files with 7 additions and 13 deletions

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

View File

@@ -16,14 +16,15 @@
# This work was partially funded by DT-GEO Project. # This work was partially funded by DT-GEO Project.
# ----------------- # -----------------
import numpy as np import numpy as np
from find_catalog_column import find_catalog_column
def sort_by_time(catalog): 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: Parameters:
catalog (np.ndarray): A structured NumPy array representing the catalog, where each row catalog (np.ndarray): A structured NumPy array representing a seismic catalog in EPISODES Platform format:
contains fields like 'Time', 'ID', and others. https://docs.cyfronet.pl/display/ISDOC/Seismic+catalog
Returns: Returns:
np.ndarray: The sorted catalog, where rows in 'val' fields are ordered by ascending 'Time' values. 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: Raises:
ValueError: If the 'Time' column is not found in the catalog. ValueError: If the 'Time' column is not found in the catalog.
""" """
time_col_index = find_catalog_column(catalog, 'Time')
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_values = catalog[time_col_index]['val'].flatten() time_values = catalog[time_col_index]['val'].flatten()
sorted_indexes = np.argsort(time_values) sorted_indexes = np.argsort(time_values)