Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verification test suite for the conditioned GMF calculator #8542

Merged
merged 30 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
99aadf5
Move the ConditionedGmfComputer from the shakemap module to calc
raoanirudh Mar 15, 2023
9dd33b9
Relax hardcoding of spatial correlation model for cond gmf
raoanirudh Mar 16, 2023
6073753
Add input data for the conditioned gmfs verification tests
raoanirudh Mar 16, 2023
6e0b745
Setup the conditioned gmf verification test structure
raoanirudh Mar 16, 2023
4c35b65
Merge branch 'master' into cgmf-test
raoanirudh Mar 16, 2023
e9864be
Add conditioned gmfs verification test case 01
raoanirudh Mar 16, 2023
4fffcd9
Avoid small negative values in conditioned covariance matrices
raoanirudh Mar 16, 2023
59195a0
Add a fuunction to plot cond gmf test case results
raoanirudh Mar 16, 2023
3d46dc5
Add conditioned gmfs verification test case 02
raoanirudh Mar 16, 2023
492675a
Round target site coordinates to five significant digits
raoanirudh Mar 17, 2023
8d8c68b
Add conditioned gmfs verification test case 03
raoanirudh Mar 17, 2023
86bbc23
Merge branch 'master' into cgmf-test
raoanirudh Mar 17, 2023
17add41
Add conditioned gmfs verification test case 04
raoanirudh Mar 17, 2023
f382775
Add station locations for case 04b
raoanirudh Mar 17, 2023
e8f902a
Add conditioned gmfs verification test case 05
raoanirudh Mar 17, 2023
a41d8b3
Add conditioned gmfs verification test cases 04b, 06, 07
raoanirudh Mar 17, 2023
cc3b103
Add calculated results for case 08
raoanirudh Mar 17, 2023
532b25f
Add conditioned gmfs verification test case 08
raoanirudh Mar 17, 2023
1392dd3
Add conditioned gmfs verification test cases 09 and 10
raoanirudh Mar 17, 2023
c8d9569
Merge branch 'master' into cgmf-test
raoanirudh Mar 17, 2023
b712955
Do not plot test results in production mode
raoanirudh Mar 17, 2023
d6bbf5e
Correct the formula used for the nominal_bias_stddev
raoanirudh Mar 18, 2023
70dad1b
Add expected results for case 04b
raoanirudh Mar 18, 2023
24f629a
Skip matplotlib import if not needed
raoanirudh Mar 21, 2023
1a043e7
Merge branch 'master' into cgmf-test
raoanirudh Mar 21, 2023
e3840f1
Add a trivial cross-correlation model for between-event residuals for…
raoanirudh Mar 22, 2023
029dde4
Switch to the trivial cross-correlation model for between-event resid…
raoanirudh Mar 22, 2023
62cfade
Do not plot test results in production mode
raoanirudh Mar 22, 2023
1fb532e
Merge branch 'master' into cgmf-test
raoanirudh Mar 22, 2023
3d72563
Merge branch 'master' into cgmf-test
raoanirudh Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openquake/calculators/event_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from openquake.hazardlib.gsim.base import ContextMaker, FarAwayRupture
from openquake.hazardlib.calc.filters import nofilter, getdefault, SourceFilter
from openquake.hazardlib.calc.gmf import GmfComputer
from openquake.hazardlib.shakemap.conditioned_gmfs import ConditionedGmfComputer
from openquake.hazardlib.calc.conditioned_gmfs import ConditionedGmfComputer
from openquake.hazardlib import InvalidFile
from openquake.hazardlib.calc.stochastic import get_rup_array, rupture_dt
from openquake.hazardlib.site import SiteCollection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,12 @@ def get_conditioned_mean_and_covariance(
# Compute the distribution of the conditional between-event
# residual B|Y2=y2
mu_BD_yD = T_D @ mu_HD_yD
cov_BD_BD_yD = numpy.sqrt(
numpy.diag(numpy.linalg.multi_dot([T_D, cov_HD_HD_yD, T_D.T])))
cov_BD_BD_yD = numpy.linalg.multi_dot([T_D, cov_HD_HD_yD, T_D.T])

# Get the nominal bias and its variance as the means of the
# conditional between-event residual mean and covariance
# Get the nominal bias and its standard deviation as the means of the
# conditional between-event residual mean and standard deviation
nominal_bias_mean = numpy.mean(mu_BD_yD)
nominal_bias_stddev = numpy.sqrt(numpy.mean(cov_BD_BD_yD))
nominal_bias_stddev = numpy.sqrt(numpy.mean(numpy.diag(cov_BD_BD_yD)))
logging.info(
"GMM: %s, IMT: %s, Nominal bias mean: %.3f, Nominal bias stddev: %.3f",
gmm_name, target_imt.string, nominal_bias_mean, nominal_bias_stddev)
Expand Down Expand Up @@ -584,6 +583,12 @@ def get_conditioned_mean_and_covariance(
# for the target sites
cov_BY_BY_yD = numpy.linalg.multi_dot([C, cov_HD_HD_yD, C.T])

# Both conditioned covariance matrices can contain extremely
# small negative values due to limitations of floating point
# operations (~ -10^-17 to -10^-15), these are clipped to zero
cov_WY_WY_wD = cov_WY_WY_wD.clip(min=0)
cov_BY_BY_yD = cov_BY_BY_yD.clip(min=0)

# Finally, compute the conditioned mean
# of the ground motion at the target sites
mu_Y_yD = mu_Y + mu_BY_yD + RC @ (zeta_D - mu_BD_yD)
Expand Down Expand Up @@ -633,16 +638,16 @@ def _compute_spatial_cross_correlation_matrix(
spatial_correl, cross_correl_within):
if imt_1 == imt_2:
# Since we have a single IMT, no cross-correlation terms to be computed
spatial_correlation_matrix = correlation.jbcorrelation(
distance_matrix, imt_1, spatial_correl.vs30_clustering
spatial_correlation_matrix = spatial_correl._get_correlation_matrix(
distance_matrix, imt_1
)
spatial_cross_correlation_matrix = spatial_correlation_matrix
else:
spatial_correlation_matrix_1 = correlation.jbcorrelation(
distance_matrix, imt_1, spatial_correl.vs30_clustering
spatial_correlation_matrix_1 = spatial_correl._get_correlation_matrix(
distance_matrix, imt_1
)
spatial_correlation_matrix_2 = correlation.jbcorrelation(
distance_matrix, imt_2, spatial_correl.vs30_clustering
spatial_correlation_matrix_2 = spatial_correl._get_correlation_matrix(
distance_matrix, imt_2
)
spatial_correlation_matrix = numpy.maximum(
spatial_correlation_matrix_1, spatial_correlation_matrix_2
Expand Down
Loading