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

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