geoprior.models.subsidence.payloads#
Physics diagnostics payloads.
This module centralizes data collection from a trained model for physics sanity plots (e.g., Fig.4) and provides robust persistence to disk with simple provenance metadata.
Functions
|
Compute identifiability diagnostics for Supp. |
|
Build lightweight, JSON-serializable provenance from a model. |
|
Collect a flat physics payload from a batched dataset for diagnostics. |
Compute synthetic identifiability diagnostics from a physics payload. |
|
|
Load a previously saved physics payload and its metadata. |
|
Save payload + sidecar metadata to disk. |
|
Collapse 1D arrays to scalar effective parameters. |
- geoprior.models.subsidence.payloads.default_meta_from_model(model)[source]#
Build lightweight, JSON-serializable provenance from a model.
Notes
time_unitsdescribes the time coordinate units in the dataset (for example,"year"), meaning whattrepresents before conversion.Physics diagnostics such as
tau,tau_prior,K, andcons_res_valsare exported in SI time units after the model’s internal conversions. In practice,Kis in m/s,tauis in s, andcons_res_valsis in m/s.
- Return type:
- geoprior.models.subsidence.payloads.identifiability_diagnostics_from_payload(payload, tau_true, K_true, Ss_true, Hd_true, K_prior, Ss_prior, Hd_prior, quantiles=(0.5, 0.75, 0.9, 0.95), eps=1e-12)[source]#
Compute synthetic identifiability diagnostics from a physics payload.
This implements the three diagnostics described in Supplementary Methods 3:
Relative error in the effective relaxation time tau.
Discrepancy between the composite timescale closure H_d^2 S_s / (kappa K) (stored as tau_prior) and the true effective timescale tau_eff,true, via a log-timescale residual.
Marginal log-offsets of K, S_s and H_d relative to their true effective values and lithology-based priors.
- Parameters:
- payload
dict Physics payload returned by
gather_physics_payload()orGeoPriorSubsNet.export_physics_payload(). Must contain 1D arrays with keys: “tau”, “tau_prior”, “K”, “Ss”, “Hd”.- tau_true
float True effective relaxation time :math:` au_{mathrm{eff,true}}` from the 1D consolidation column.
- K_true, Ss_true, Hd_true
float True effective closures \(K_{\mathrm{eff}}\), \(S_{s,\mathrm{eff}}\), and \(H_{d,\mathrm{eff}}\) at the column scale.
- K_prior, Ss_prior, Hd_prior
float Lithology-based priors used to construct the GeoPrior head for this synthetic column.
- quantiles
tupleoffloat,default(0.5, 0.75, 0.9, 0.95) Quantile levels used for summary statistics of the distributions.
- eps
float,default1e-12 Lower bound used to clip strictly positive quantities before taking logarithms.
- payload
- Returns:
dictA dictionary with three blocks:
"tau_rel_error": statistics of the relative error :math:`
- rac{| au - au_{true}|}{ au_{true}}`.
"closure_log_resid": statistics of the log-timescale residuallog(tau_prior) - log(tau_true)."offsets": nested dict with"vs_true"and"vs_prior", each containing summary stats for the log-offsetsdelta_K,delta_Ss, anddelta_Hd.
- Parameters:
- Return type:
- geoprior.models.subsidence.payloads.summarise_effective_params(payload)[source]#
Collapse 1D arrays to scalar effective parameters.
Intended for 1D synthetic-column experiments where model outputs are spatially constant and we only need a single representative value per run.
- geoprior.models.subsidence.payloads.compute_identifiability_summary(eff_params, true_params, prior_params, kappa_b=1.0, eps=1e-12)[source]#
Compute identifiability diagnostics for Supp. Methods 3.
See Supplementary Methods 3 for definitions of the quantities returned.
- geoprior.models.subsidence.payloads.gather_physics_payload(model, dataset, max_batches=None, float_dtype=<class 'numpy.float32'>, log_fn=None, eps=1e-12, **tqdm_kws)[source]#
Collect a flat physics payload from a batched dataset for diagnostics.
This function iterates over a tf.data.Dataset (or any iterable) and calls model.evaluate_physics(inputs, return_maps=True) on each batch. The returned per-batch tensors are flattened and concatenated into 1D arrays suitable for scatter plots, histograms, and summary stats.
Important
No unit conversion is performed here. The payload is exported in whatever units evaluate_physics(…) returns. Unit consistency is therefore a responsibility of the model’s physics implementation (and its scaling_kwargs), not this I/O layer.
- geoprior.models.subsidence.payloads.save_physics_payload(payload, meta, path=None, format='npz', overwrite=False, log_fn=None)[source]#
Save payload + sidecar metadata to disk.
- Parameters:
payload (
dict) – Output of gather_physics_payload.meta (
dict) – Provenance dictionary. Will be JSON-serialized.path (
strorNonr) – File path. If extension missing, inferred from format. If not provided, then get the current directory instead.format (
{"npz","csv","parquet"}) – Storage format. “npz” is compact and dependency-free.overwrite (
bool) – If False, raise if the file already exists.
- Returns:
The resolved data file path that was written.
- Return type:
- geoprior.models.subsidence.payloads.load_physics_payload(path)[source]#
Load a previously saved physics payload and its metadata.
- Parameters:
path (
str) – Data file path. Supports .npz, .csv, .parquet.- Returns:
(payload, meta) – Payload dict with arrays and metadata dict (if found).
- Return type:
(dict,dict)