rsqsim_api.tsunami.gf_netcdf
Utilities for reading and computing Green’s-function sea-surface displacement (SSD) from netCDF files.
Provides LookupPatch for indexing individual patch Green’s
functions within multi-file netCDF datasets, and functions for
computing and saving per-event SSD grids using superposition of patch
responses.
Classes
Index entry mapping a fault patch to its location within a netCDF Green's-function dataset. |
Functions
|
Build a patch-lookup dictionary from a set of netCDF Green's-function files. |
|
Compute the sea-surface displacement grid for a single event. |
|
Compute and save sea-surface displacements for multiple events to a netCDF file. |
Module Contents
- class rsqsim_api.tsunami.gf_netcdf.LookupPatch(patch_index, dset, dset_index)[source]
Index entry mapping a fault patch to its location within a netCDF Green’s-function dataset.
- Parameters:
patch_index (int)
dset (netCDF4.Dataset)
dset_index (int)
- rsqsim_api.tsunami.gf_netcdf.create_lookup_dict(search_string)[source]
Build a patch-lookup dictionary from a set of netCDF Green’s-function files.
Opens all files matching
search_stringand constructs a mapping from global patch index toLookupPatchobjects.- Parameters:
search_string (str) – Glob pattern for the netCDF files, e.g.
"/path/to/gf_files/*.nc".- Returns:
Mapping of patch index (int) to
LookupPatch.- Return type:
dict
- rsqsim_api.tsunami.gf_netcdf.sea_surface_displacements(input_tuple)[source]
Compute the sea-surface displacement grid for a single event.
Superposes the per-patch Green’s functions scaled by the event’s patch slip values. Returns NaN-filled arrays for events whose patches are not all present in the lookup dictionary.
- Parameters:
input_tuple (tuple) –
(event, lookup)whereeventis anRsqSimEventandlookupis a dict mapping patch index toLookupPatch.- Returns:
event_id (int) – The event identifier.
disp (numpy.ndarray) – Sea-surface displacement grid (shape matches the Green’s function grid). Filled with
NaNif any patch is missing from the lookup.
- rsqsim_api.tsunami.gf_netcdf.sea_surface_displacements_multi(event_ls, lookup, out_netcdf, num_processes=None)[source]
Compute and save sea-surface displacements for multiple events to a netCDF file.
Uses a
ThreadPoolExecutorto compute displacements in parallel, then writes the results to a new netCDF file with dimensions(event_id, y, x).- Parameters:
event_ls (list) – List of
RsqSimEventobjects.lookup (dict) – Patch-lookup dictionary from
create_lookup_dict().out_netcdf (str) – Output netCDF file path.
num_processes (int or None, optional) – Maximum number of worker threads. Defaults to
None(determined byThreadPoolExecutordefault).