Skip to content

Commit

Permalink
preserve event_id == number_of_events (deeplycloudy#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
wx4stg committed Jul 1, 2024
1 parent fe657e4 commit 043acd8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyxlma/lmalib/io/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ def reorder_stations(dataset, index_mapping):
# merge all the data from this file with the previously-known data
combined_event_data = xr.merge([lma_station_data, lma_event_data])
all_data = combined_event_data
# Sort the data by file_start_time
all_data = all_data.sortby('file_start_time')
# Update the global attributes
all_data.attrs.update(final_attrs)
# To reduce complexity and resource usage, if the 'number_of_files' dimension is the same for all variables, then the dimension is unnecessary
Expand Down Expand Up @@ -236,6 +234,10 @@ def dataset(filenames, sort_time=True):
except:
raise
ds = combine_datasets(lma_data)
if sort_time:
ds = ds.sortby('event_time')
if 'file_start_time' in ds.dims:
ds = ds.sortby('file_start_time')
ds = ds.reset_index(('number_of_events', 'number_of_stations'))
if 'number_of_events_' in ds.coords:
# Older xarray versions appended a trailing underscore. reset_coords then dropped
Expand All @@ -252,8 +254,6 @@ def dataset(filenames, sort_time=True):
resetted = ('number_of_events', 'number_of_stations')
ds = ds.reset_coords(resetted)
ds = ds.rename_vars({resetted[0]:'event_id'})
if sort_time:
ds = ds.sortby('event_time')
return ds, starttime

def to_dataset(lma_file, event_id_start=0):
Expand Down

0 comments on commit 043acd8

Please sign in to comment.