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

LookupPatch

Index entry mapping a fault patch to its location within a netCDF Green's-function dataset.

Functions

create_lookup_dict(search_string)

Build a patch-lookup dictionary from a set of netCDF Green's-function files.

sea_surface_displacements(input_tuple)

Compute the sea-surface displacement grid for a single event.

sea_surface_displacements_multi(event_ls, lookup, ...)

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)

patch_index[source]

Global patch identifier.

Type:

int

dset[source]

Open netCDF4 dataset containing the Green’s-function data for this patch.

Type:

netCDF4.Dataset

dset_index[source]

Local index of this patch within dset.

Type:

int

patch_index[source]
dset[source]
dset_index[source]
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_string and constructs a mapping from global patch index to LookupPatch objects.

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) where event is an RsqSimEvent and lookup is a dict mapping patch index to LookupPatch.

Returns:

  • event_id (int) – The event identifier.

  • disp (numpy.ndarray) – Sea-surface displacement grid (shape matches the Green’s function grid). Filled with NaN if 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 ThreadPoolExecutor to 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 RsqSimEvent objects.

  • 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 by ThreadPoolExecutor default).