Skip to content

Commit 3393656

Browse files
committed
Allow the loaded NetCDF file to be subsetted by the provided st
1 parent 30fb8f1 commit 3393656

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

rtm/travel_time.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ def infresnel_travel_time(grid, st, celerity=343, stored_result=None, dem_file=N
365365
diff_path_lens_loaded = xr.open_dataarray(result_filepath) # Load the stored result
366366
diff_path_lens_loaded = diff_path_lens_loaded.assign_attrs(UTM=grid.UTM) # Add back in (can't be stored)
367367
diff_path_lens_loaded.attrs['grid_center'] = tuple(diff_path_lens_loaded.grid_center)
368+
# Subset the loaded result to match the input `st` — this is necessary if
369+
# the NetCDF file was created using a full network but RTM is being run on a
370+
# subset of that network (e.g., if there's a station outage; see
371+
# https://github.com/uafgeotools/rtm/pull/85#issuecomment-2352055340)
372+
diff_path_lens_loaded = diff_path_lens_loaded.sel(station=[tr.id for tr in st])
368373
# Various checks to ensure that what we're loading in makes sense
369374
assert diff_path_lens.shape == diff_path_lens_loaded.shape, 'Shapes differ!'
370375
for coord_da, coord_loaded_da in zip(

0 commit comments

Comments
 (0)