From 344a620a6195ecf779c92f7b7007d7be59319f16 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Fri, 4 Oct 2024 16:13:14 +0200 Subject: [PATCH 1/8] Removing CampbellBozorgnia classes by updating the CoeffsTable instead --- .../gsim/bozorgnia_campbell_2016_vh.py | 12 +- .../hazardlib/gsim/campbell_bozorgnia_2014.py | 132 +++++++----------- .../gsim/campbell_bozorgnia_2014_test.py | 14 +- 3 files changed, 62 insertions(+), 96 deletions(-) diff --git a/openquake/hazardlib/gsim/bozorgnia_campbell_2016_vh.py b/openquake/hazardlib/gsim/bozorgnia_campbell_2016_vh.py index 33bb1575934a..a9be4ceb11d9 100644 --- a/openquake/hazardlib/gsim/bozorgnia_campbell_2016_vh.py +++ b/openquake/hazardlib/gsim/bozorgnia_campbell_2016_vh.py @@ -173,7 +173,8 @@ class BozorgniaCampbell2016HighQVH(BozorgniaCampbell2016VH): low attenuation (high quality factor, Q) (e.g. eastern China) """ VGMPE = bozorgnia_campbell_2016.BozorgniaCampbell2016(sgn=+1) - HGMPE = campbell_bozorgnia_2014.CampbellBozorgnia2014HighQ() + HGMPE = campbell_bozorgnia_2014.CampbellBozorgnia2014( + coeffs=campbell_bozorgnia_2014.coeffs_high) class BozorgniaCampbell2016LowQVH(BozorgniaCampbell2016VH): @@ -185,7 +186,8 @@ class BozorgniaCampbell2016LowQVH(BozorgniaCampbell2016VH): high attenuation (low quality factor, Q) (e.g. Japan and Italy) """ VGMPE = bozorgnia_campbell_2016.BozorgniaCampbell2016(sgn=-1) - HGMPE = campbell_bozorgnia_2014.CampbellBozorgnia2014LowQ() + HGMPE = campbell_bozorgnia_2014.CampbellBozorgnia2014( + coeffs=campbell_bozorgnia_2014.coeffs_low) class BozorgniaCampbell2016AveQJapanSiteVH(BozorgniaCampbell2016VH): @@ -215,7 +217,8 @@ class BozorgniaCampbell2016HighQJapanSiteVH( low attenuation (high quality factor, Q) """ VGMPE = bozorgnia_campbell_2016.BozorgniaCampbell2016(SJ=1, sgn=+1) - HGMPE = campbell_bozorgnia_2014.CampbellBozorgnia2014HighQ(SJ=1) + HGMPE = campbell_bozorgnia_2014.CampbellBozorgnia2014( + coeffs=campbell_bozorgnia_2014.coeffs_high, SJ=1) class BozorgniaCampbell2016LowQJapanSiteVH( @@ -231,4 +234,5 @@ class BozorgniaCampbell2016LowQJapanSiteVH( high attenuation (low quality factor, Q) """ VGMPE = bozorgnia_campbell_2016.BozorgniaCampbell2016(SJ=1, sgn=-1) - HGMPE = campbell_bozorgnia_2014.CampbellBozorgnia2014LowQ(SJ=1) + HGMPE = campbell_bozorgnia_2014.CampbellBozorgnia2014( + coeffs=campbell_bozorgnia_2014.coeffs_low, SJ=1) diff --git a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py index eb8bc66e0086..ae8c73125595 100644 --- a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py +++ b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py @@ -409,9 +409,11 @@ class CampbellBozorgnia2014(GMPE): #: Required distance measures are Rrup, Rjb and Rx REQUIRES_DISTANCES = {'rrup', 'rjb', 'rx'} - def __init__(self, SJ=False, sigma_mu_epsilon=0.0, estimate_ztor=False, + def __init__(self, coeffs=None, SJ=False, sigma_mu_epsilon=0.0, estimate_ztor=False, estimate_width=False, estimate_hypo_depth=False): # tested in logictree/case_71 + if coeffs: # extra coefficients by IMT + self.COEFFS |= coeffs self.SJ = SJ # flag for Japan self.sigma_mu_epsilon = sigma_mu_epsilon self.estimate_ztor = estimate_ztor @@ -516,93 +518,55 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): ia -10.272 2.318 0.88 -2.672 -0.837 -4.441 0.416 4.869 0.187 -0.196 1.165 1.596 2.829 2.76 0.108 -0.315 1.612 0.1311 0.0453 0.01242 -0.0103 0 0.167 0.241 1.474 -0.715 -0.337 -0.27 400 -1.982 1 1.174 0.809 0.614 0.435 0.948 0.911 0.615989848 0 0 """) - -class CampbellBozorgnia2014HighQ(CampbellBozorgnia2014): - """ - Implements the Campbell & Bozorgnia (2014) NGA-West2 GMPE for regions with - low attenuation (high quality factor, Q) (i.e. China, Turkey) - """ - COEFFS = CoeffsTable(sa_damping=5, table="""\ - IMT c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 Dc20 a2 h1 h2 h3 h5 h6 k1 k2 k3 phi1 phi2 tau1 tau2 rho1pga rho2pga philnAF phiC rholny - 0.01 -4.365 0.977 0.533 -1.485 -0.499 -2.773 0.248 6.753 0 -0.214 0.72 1.094 2.191 1.416 -0.007 -0.207 0.39 0.0981 0.0334 0.00755 -0.0055 0.0036 0.168 0.242 1.471 -0.714 -0.336 -0.27 865 -1.186 1.839 0.734 0.492 0.404 0.325 1 1 0.3 0.19 1 - 0.02 -4.348 0.976 0.549 -1.488 -0.501 -2.772 0.247 6.502 0 -0.208 0.73 1.149 2.189 1.453 -0.0167 -0.199 0.387 0.1009 0.0327 0.00759 -0.0055 0.0036 0.166 0.244 1.467 -0.711 -0.339 -0.263 865 -1.219 1.84 0.738 0.496 0.417 0.326 0.999 0.998 0.3 0.166 0.998 - 0.03 -4.024 0.931 0.628 -1.494 -0.517 -2.782 0.246 6.291 0 -0.213 0.759 1.29 2.164 1.476 -0.0422 -0.202 0.378 0.1095 0.0331 0.0079 -0.0057 0.0037 0.167 0.246 1.467 -0.713 -0.338 -0.259 908 -1.273 1.841 0.747 0.503 0.446 0.344 0.987 0.987 0.3 0.166 0.986 - 0.05 -3.479 0.887 0.674 -1.388 -0.615 -2.791 0.24 6.317 0 -0.244 0.826 1.449 2.138 1.549 -0.0663 -0.339 0.295 0.1226 0.027 0.00803 -0.0063 0.004 0.173 0.251 1.449 -0.701 -0.338 -0.263 1054 -1.346 1.843 0.777 0.52 0.508 0.377 0.955 0.946 0.3 0.166 0.938 - 0.075 -3.293 0.902 0.726 -1.469 -0.596 -2.745 0.227 6.861 0 -0.266 0.815 1.535 2.446 1.772 -0.0794 -0.404 0.322 0.1165 0.0288 0.00811 -0.007 0.0039 0.198 0.26 1.435 -0.695 -0.347 -0.219 1086 -1.471 1.845 0.782 0.535 0.504 0.418 0.943 0.897 0.3 0.165 0.887 - 0.1 -3.666 0.993 0.698 -1.572 -0.536 -2.633 0.21 7.294 0 -0.229 0.831 1.615 2.969 1.916 -0.0294 -0.416 0.384 0.0998 0.0325 0.00744 -0.0073 0.0042 0.174 0.259 1.449 -0.708 -0.391 -0.201 1032 -1.624 1.847 0.769 0.543 0.445 0.426 0.942 0.883 0.3 0.162 0.87 - 0.15 -4.866 1.267 0.51 -1.669 -0.49 -2.458 0.183 8.031 0 -0.211 0.749 1.877 3.544 2.161 0.0642 -0.407 0.417 0.076 0.0388 0.00716 -0.0069 0.0042 0.198 0.254 1.461 -0.715 -0.449 -0.099 878 -1.931 1.852 0.769 0.543 0.382 0.387 0.921 0.891 0.3 0.158 0.876 - 0.2 -5.411 1.366 0.447 -1.75 -0.451 -2.421 0.182 8.385 0 -0.163 0.764 2.069 3.707 2.465 0.0968 -0.311 0.404 0.0571 0.0437 0.00688 -0.006 0.0041 0.204 0.237 1.484 -0.721 -0.393 -0.198 748 -2.188 1.856 0.761 0.552 0.339 0.338 0.874 0.881 0.3 0.17 0.87 - 0.25 -5.962 1.458 0.274 -1.711 -0.404 -2.392 0.189 7.534 0 -0.15 0.716 2.205 3.343 2.766 0.1441 -0.172 0.466 0.0437 0.0463 0.00556 -0.0055 0.0036 0.185 0.206 1.581 -0.787 -0.339 -0.21 654 -2.381 1.861 0.744 0.545 0.34 0.316 0.809 0.861 0.3 0.18 0.85 - 0.3 -6.403 1.528 0.193 -1.77 -0.321 -2.376 0.195 6.99 0 -0.131 0.737 2.306 3.334 3.011 0.1597 -0.084 0.528 0.0323 0.0508 0.00458 -0.0049 0.0031 0.164 0.21 1.586 -0.795 -0.447 -0.121 587 -2.518 1.865 0.727 0.568 0.34 0.3 0.741 0.824 0.3 0.186 0.819 - 0.4 -7.566 1.739 -0.02 -1.594 -0.426 -2.303 0.185 7.012 0 -0.159 0.738 2.398 3.544 3.203 0.141 0.085 0.54 0.0209 0.0432 0.00401 -0.0037 0.0028 0.16 0.226 1.544 -0.77 -0.525 -0.086 503 -2.657 1.874 0.69 0.593 0.356 0.264 0.635 0.738 0.3 0.191 0.743 - 0.5 -8.379 1.872 -0.121 -1.577 -0.44 -2.296 0.186 6.902 0 -0.153 0.718 2.355 3.016 3.333 0.1474 0.233 0.638 0.0092 0.0405 0.00388 -0.0027 0.0025 0.184 0.217 1.554 -0.77 -0.407 -0.281 457 -2.669 1.883 0.663 0.611 0.379 0.263 0.553 0.661 0.3 0.198 0.684 - 0.75 -9.841 2.021 -0.042 -1.757 -0.443 -2.232 0.186 5.522 0 -0.09 0.795 1.995 2.616 3.054 0.1764 0.411 0.776 -0.0082 0.042 0.0042 -0.0016 0.0016 0.216 0.154 1.626 -0.78 -0.371 -0.285 410 -2.401 1.906 0.606 0.633 0.43 0.326 0.393 0.526 0.3 0.206 0.562 - 1 -11.011 2.18 -0.069 -1.707 -0.527 -2.158 0.169 5.65 0 -0.105 0.556 1.447 2.47 2.562 0.2593 0.479 0.771 -0.0131 0.0426 0.00409 -0.0006 0.0006 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 -1.955 1.929 0.579 0.628 0.47 0.353 0.313 0.438 0.3 0.208 0.467 - 1.5 -12.469 2.27 0.047 -1.621 -0.63 -2.063 0.158 5.795 0 -0.058 0.48 0.33 2.108 1.453 0.2881 0.566 0.748 -0.0187 0.038 0.00424 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 -1.025 1.974 0.541 0.603 0.497 0.399 0.242 0.36 0.3 0.221 0.364 - 2 -12.969 2.271 0.149 -1.512 -0.768 -2.104 0.158 6.632 0 -0.028 0.401 -0.514 1.327 0.657 0.3112 0.562 0.763 -0.0258 0.0252 0.00448 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 -0.299 2.019 0.529 0.588 0.499 0.4 0.234 0.318 0.3 0.225 0.298 - 3 -13.306 2.15 0.368 -1.315 -0.89 -2.051 0.148 6.759 0 0 0.206 -0.848 0.601 0.367 0.3478 0.534 0.686 -0.0311 0.0236 0.00345 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.11 0.527 0.578 0.5 0.417 0.236 0.295 0.3 0.222 0.234 - 4 -14.02 2.132 0.726 -1.506 -0.885 -1.986 0.135 7.978 0 0 0.105 -0.793 0.568 0.306 0.3747 0.522 0.691 -0.0413 0.0102 0.00603 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.2 0.521 0.559 0.543 0.393 0.232 0.274 0.3 0.226 0.202 - 5 -14.558 2.116 1.027 -1.721 -0.878 -2.021 0.135 8.538 0 0 0 -0.748 0.356 0.268 0.3382 0.477 0.67 -0.0281 0.0034 0.00805 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.291 0.502 0.551 0.534 0.421 0.182 0.247 0.3 0.229 0.184 - 7.5 -15.509 2.223 0.169 -0.756 -1.077 -2.179 0.165 8.468 0 0 0 -0.664 0.075 0.374 0.3754 0.321 0.757 -0.0205 0.005 0.0028 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.517 0.457 0.546 0.523 0.438 0.142 0.203 0.3 0.237 0.176 - 10 -15.975 2.132 0.367 -0.8 -1.282 -2.244 0.18 6.564 0 0 0 -0.576 -0.027 0.297 0.3506 0.174 0.621 0.0009 0.0099 0.00458 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.744 0.441 0.543 0.466 0.438 0.111 0.103 0.3 0.237 0.154 - pga -4.416 0.984 0.537 -1.499 -0.496 -2.773 0.248 6.768 0 -0.212 0.72 1.09 2.186 1.42 -0.0064 -0.202 0.393 0.0977 0.0333 0.00757 -0.0055 0.0036 0.167 0.241 1.474 -0.715 -0.337 -0.27 865 -1.186 1.839 0.734 0.492 0.409 0.322 1 1 0.3 0.271 1 - pgv -2.895 1.51 0.27 -1.299 -0.453 -2.466 0.204 5.837 0 -0.168 0.305 1.713 2.602 2.457 0.106 0.332 0.585 0.0517 0.0327 0.00613 -0.0017 0.0017 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 -1.955 1.929 0.655 0.494 0.317 0.297 0.877 0.654 0.3 0.29 0.684 - cav -4.75 1.397 0.282 -1.062 -0.17 -1.624 0.134 6.325 0.054 -0.1 0.469 1.015 1.208 1.777 0.1248 -0.191 1.087 0.0432 0.0127 0.00429 -0.0043 0.0027 0.167 0.241 1.474 -0.715 -0.337 -0.27 400 -1.311 1 0.514 0.394 0.276 0.257 0.842 0.78 0.3 0 0 - ia -10.272 2.318 0.88 -2.672 -0.837 -4.441 0.416 4.869 0.187 -0.196 1.165 1.596 2.829 2.76 0.108 -0.315 1.612 0.1311 0.0453 0.01242 -0.0103 0.0064 0.167 0.241 1.474 -0.715 -0.337 -0.27 400 -1.982 1 1.174 0.809 0.614 0.435 0.948 0.911 0.615989848 0 0 - """) - - -class CampbellBozorgnia2014LowQ(CampbellBozorgnia2014): - """ - Implements the Campbell & Bozorgnia (2014) NGA-West2 GMPE for regions with - high attenuation (low quality factor, Q) (i.e. Japan, Italy) - """ - COEFFS = CoeffsTable(sa_damping=5, table="""\ - IMT c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 Dc20 a2 h1 h2 h3 h5 h6 k1 k2 k3 phi1 phi2 tau1 tau2 rho1pga rho2pga philnAF phiC rholny - 0.01 -4.365 0.977 0.533 -1.485 -0.499 -2.773 0.248 6.753 0 -0.214 0.72 1.094 2.191 1.416 -0.007 -0.207 0.39 0.0981 0.0334 0.00755 -0.0055 -0.0035 0.168 0.242 1.471 -0.714 -0.336 -0.27 865 -1.186 1.839 0.734 0.492 0.404 0.325 1 1 0.3 0.19 1 - 0.02 -4.348 0.976 0.549 -1.488 -0.501 -2.772 0.247 6.502 0 -0.208 0.73 1.149 2.189 1.453 -0.0167 -0.199 0.387 0.1009 0.0327 0.00759 -0.0055 -0.0035 0.166 0.244 1.467 -0.711 -0.339 -0.263 865 -1.219 1.84 0.738 0.496 0.417 0.326 0.999 0.998 0.3 0.166 0.998 - 0.03 -4.024 0.931 0.628 -1.494 -0.517 -2.782 0.246 6.291 0 -0.213 0.759 1.29 2.164 1.476 -0.0422 -0.202 0.378 0.1095 0.0331 0.0079 -0.0057 -0.0034 0.167 0.246 1.467 -0.713 -0.338 -0.259 908 -1.273 1.841 0.747 0.503 0.446 0.344 0.987 0.987 0.3 0.166 0.986 - 0.05 -3.479 0.887 0.674 -1.388 -0.615 -2.791 0.24 6.317 0 -0.244 0.826 1.449 2.138 1.549 -0.0663 -0.339 0.295 0.1226 0.027 0.00803 -0.0063 -0.0037 0.173 0.251 1.449 -0.701 -0.338 -0.263 1054 -1.346 1.843 0.777 0.52 0.508 0.377 0.955 0.946 0.3 0.166 0.938 - 0.075 -3.293 0.902 0.726 -1.469 -0.596 -2.745 0.227 6.861 0 -0.266 0.815 1.535 2.446 1.772 -0.0794 -0.404 0.322 0.1165 0.0288 0.00811 -0.007 -0.0037 0.198 0.26 1.435 -0.695 -0.347 -0.219 1086 -1.471 1.845 0.782 0.535 0.504 0.418 0.943 0.897 0.3 0.165 0.887 - 0.1 -3.666 0.993 0.698 -1.572 -0.536 -2.633 0.21 7.294 0 -0.229 0.831 1.615 2.969 1.916 -0.0294 -0.416 0.384 0.0998 0.0325 0.00744 -0.0073 -0.0034 0.174 0.259 1.449 -0.708 -0.391 -0.201 1032 -1.624 1.847 0.769 0.543 0.445 0.426 0.942 0.883 0.3 0.162 0.87 - 0.15 -4.866 1.267 0.51 -1.669 -0.49 -2.458 0.183 8.031 0 -0.211 0.749 1.877 3.544 2.161 0.0642 -0.407 0.417 0.076 0.0388 0.00716 -0.0069 -0.003 0.198 0.254 1.461 -0.715 -0.449 -0.099 878 -1.931 1.852 0.769 0.543 0.382 0.387 0.921 0.891 0.3 0.158 0.876 - 0.2 -5.411 1.366 0.447 -1.75 -0.451 -2.421 0.182 8.385 0 -0.163 0.764 2.069 3.707 2.465 0.0968 -0.311 0.404 0.0571 0.0437 0.00688 -0.006 -0.0031 0.204 0.237 1.484 -0.721 -0.393 -0.198 748 -2.188 1.856 0.761 0.552 0.339 0.338 0.874 0.881 0.3 0.17 0.87 - 0.25 -5.962 1.458 0.274 -1.711 -0.404 -2.392 0.189 7.534 0 -0.15 0.716 2.205 3.343 2.766 0.1441 -0.172 0.466 0.0437 0.0463 0.00556 -0.0055 -0.0033 0.185 0.206 1.581 -0.787 -0.339 -0.21 654 -2.381 1.861 0.744 0.545 0.34 0.316 0.809 0.861 0.3 0.18 0.85 - 0.3 -6.403 1.528 0.193 -1.77 -0.321 -2.376 0.195 6.99 0 -0.131 0.737 2.306 3.334 3.011 0.1597 -0.084 0.528 0.0323 0.0508 0.00458 -0.0049 -0.0035 0.164 0.21 1.586 -0.795 -0.447 -0.121 587 -2.518 1.865 0.727 0.568 0.34 0.3 0.741 0.824 0.3 0.186 0.819 - 0.4 -7.566 1.739 -0.02 -1.594 -0.426 -2.303 0.185 7.012 0 -0.159 0.738 2.398 3.544 3.203 0.141 0.085 0.54 0.0209 0.0432 0.00401 -0.0037 -0.0034 0.16 0.226 1.544 -0.77 -0.525 -0.086 503 -2.657 1.874 0.69 0.593 0.356 0.264 0.635 0.738 0.3 0.191 0.743 - 0.5 -8.379 1.872 -0.121 -1.577 -0.44 -2.296 0.186 6.902 0 -0.153 0.718 2.355 3.016 3.333 0.1474 0.233 0.638 0.0092 0.0405 0.00388 -0.0027 -0.0034 0.184 0.217 1.554 -0.77 -0.407 -0.281 457 -2.669 1.883 0.663 0.611 0.379 0.263 0.553 0.661 0.3 0.198 0.684 - 0.75 -9.841 2.021 -0.042 -1.757 -0.443 -2.232 0.186 5.522 0 -0.09 0.795 1.995 2.616 3.054 0.1764 0.411 0.776 -0.0082 0.042 0.0042 -0.0016 -0.0032 0.216 0.154 1.626 -0.78 -0.371 -0.285 410 -2.401 1.906 0.606 0.633 0.43 0.326 0.393 0.526 0.3 0.206 0.562 - 1 -11.011 2.18 -0.069 -1.707 -0.527 -2.158 0.169 5.65 0 -0.105 0.556 1.447 2.47 2.562 0.2593 0.479 0.771 -0.0131 0.0426 0.00409 -0.0006 -0.003 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 -1.955 1.929 0.579 0.628 0.47 0.353 0.313 0.438 0.3 0.208 0.467 - 1.5 -12.469 2.27 0.047 -1.621 -0.63 -2.063 0.158 5.795 0 -0.058 0.48 0.33 2.108 1.453 0.2881 0.566 0.748 -0.0187 0.038 0.00424 0 -0.0019 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 -1.025 1.974 0.541 0.603 0.497 0.399 0.242 0.36 0.3 0.221 0.364 - 2 -12.969 2.271 0.149 -1.512 -0.768 -2.104 0.158 6.632 0 -0.028 0.401 -0.514 1.327 0.657 0.3112 0.562 0.763 -0.0258 0.0252 0.00448 0 -0.0005 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 -0.299 2.019 0.529 0.588 0.499 0.4 0.234 0.318 0.3 0.225 0.298 - 3 -13.306 2.15 0.368 -1.315 -0.89 -2.051 0.148 6.759 0 0 0.206 -0.848 0.601 0.367 0.3478 0.534 0.686 -0.0311 0.0236 0.00345 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.11 0.527 0.578 0.5 0.417 0.236 0.295 0.3 0.222 0.234 - 4 -14.02 2.132 0.726 -1.506 -0.885 -1.986 0.135 7.978 0 0 0.105 -0.793 0.568 0.306 0.3747 0.522 0.691 -0.0413 0.0102 0.00603 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.2 0.521 0.559 0.543 0.393 0.232 0.274 0.3 0.226 0.202 - 5 -14.558 2.116 1.027 -1.721 -0.878 -2.021 0.135 8.538 0 0 0 -0.748 0.356 0.268 0.3382 0.477 0.67 -0.0281 0.0034 0.00805 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.291 0.502 0.551 0.534 0.421 0.182 0.247 0.3 0.229 0.184 - 7.5 -15.509 2.223 0.169 -0.756 -1.077 -2.179 0.165 8.468 0 0 0 -0.664 0.075 0.374 0.3754 0.321 0.757 -0.0205 0.005 0.0028 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.517 0.457 0.546 0.523 0.438 0.142 0.203 0.3 0.237 0.176 - 10 -15.975 2.132 0.367 -0.8 -1.282 -2.244 0.18 6.564 0 0 0 -0.576 -0.027 0.297 0.3506 0.174 0.621 0.0009 0.0099 0.00458 0 0 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 0 2.744 0.441 0.543 0.466 0.438 0.111 0.103 0.3 0.237 0.154 - pga -4.416 0.984 0.537 -1.499 -0.496 -2.773 0.248 6.768 0 -0.212 0.72 1.09 2.186 1.42 -0.0064 -0.202 0.393 0.0977 0.0333 0.00757 -0.0055 -0.0035 0.167 0.241 1.474 -0.715 -0.337 -0.27 865 -1.186 1.839 0.734 0.492 0.409 0.322 1 1 0.3 0.271 1 - pgv -2.895 1.51 0.27 -1.299 -0.453 -2.466 0.204 5.837 0 -0.168 0.305 1.713 2.602 2.457 0.106 0.332 0.585 0.0517 0.0327 0.00613 -0.0017 -0.0006 0.596 0.117 1.616 -0.733 -0.128 -0.756 400 -1.955 1.929 0.655 0.494 0.317 0.297 0.877 0.654 0.3 0.29 0.684 - cav -4.75 1.397 0.282 -1.062 -0.17 -1.624 0.134 6.325 0.054 -0.1 0.469 1.015 1.208 1.777 0.1248 -0.191 1.087 0.0432 0.0127 0.00429 -0.0043 -0.0024 0.167 0.241 1.474 -0.715 -0.337 -0.27 400 -1.311 1 0.514 0.394 0.276 0.257 0.842 0.78 0.3 0 0 - ia -10.272 2.318 0.88 -2.672 -0.837 -4.441 0.416 4.869 0.187 -0.196 1.165 1.596 2.829 2.76 0.108 -0.315 1.612 0.1311 0.0453 0.01242 -0.0103 -0.0051 0.167 0.241 1.474 -0.715 -0.337 -0.27 400 -1.982 1 1.174 0.809 0.614 0.435 0.948 0.911 0.615989848 0 0 - """) +coeffs_high = CoeffsTable.fromtoml(''' +["SA(0.01)"]\nDc20 = 0.0036 +["SA(0.02)"]\nDc20 = 0.0036 +["SA(0.03)"]\nDc20 = 0.0037 +["SA(0.05)"]\nDc20 = 0.0040 +["SA(0.075)"]\nDc20 = 0.0039 +["SA(0.1)"]\nDc20 = 0.0042 +["SA(0.15)"]\nDc20 = 0.0042 +["SA(0.2)"]\nDc20 = 0.0041 +["SA(0.25)"]\nDc20 = 0.0036 +["SA(0.3)"]\nDc20 = 0.0031 +["SA(0.4)"]\nDc20 = 0.0028 +["SA(0.5)"]\nDc20 = 0.0025 +["SA(0.75)"]\nDc20 = 0.0016 +["SA(1.0)"]\nDc20 = 0.0006 +''') + +coeffs_low = CoeffsTable.fromtoml(''' +["SA(0.01)"]\nDc20 = 0.0035 +["SA(0.02)"]\nDc20 = 0.0034 +["SA(0.03)"]\nDc20 = 0.0037 +["SA(0.05)"]\nDc20 = 0.0037 +["SA(0.075)"]\nDc20 = 0.0034 +["SA(0.1)"]\nDc20 = 0.0030 +["SA(0.15)"]\nDc20 = 0.0031 +["SA(0.2)"]\nDc20 = 0.0033 +["SA(0.25)"]\nDc20 = 0.0035 +["SA(0.3)"]\nDc20 = 0.0034 +["SA(0.4)"]\nDc20 = 0.0032 +["SA(0.5)"]\nDc20 = 0.0030 +["SA(0.75)"]\nDc20 = 0.0019 +["SA(1.0)"]\nDc20 = 0.0005 +''') class CampbellBozorgnia2019(CampbellBozorgnia2014): DEFINED_FOR_INTENSITY_MEASURE_COMPONENT = const.IMC.GEOMETRIC_MEAN -class CampbellBozorgnia2019HighQ(CampbellBozorgnia2014HighQ): - DEFINED_FOR_INTENSITY_MEASURE_COMPONENT = const.IMC.GEOMETRIC_MEAN - - -class CampbellBozorgnia2019LowQ(CampbellBozorgnia2014LowQ): - DEFINED_FOR_INTENSITY_MEASURE_COMPONENT = const.IMC.GEOMETRIC_MEAN - - -add_alias('CampbellBozorgnia2014JapanSite', CampbellBozorgnia2014, SJ=True) -add_alias('CampbellBozorgnia2014HighQJapanSite', CampbellBozorgnia2014HighQ, SJ=True) -add_alias('CampbellBozorgnia2014LowQJapanSite', CampbellBozorgnia2014LowQ, SJ=True) +add_alias('CampbellBozorgnia2014JapanSite', CampbellBozorgnia2014, + SJ=True) +add_alias('CampbellBozorgnia2014HighQJapanSite', CampbellBozorgnia2014, + coeffs=coeffs_high, SJ=True) +add_alias('CampbellBozorgnia2014LowQJapanSite', CampbellBozorgnia2014, + coeffs=coeffs_low, SJ=True) -add_alias('CampbellBozorgnia2019JapanSite', CampbellBozorgnia2019, SJ=True) -add_alias('CampbellBozorgnia2019HighQJapanSite', CampbellBozorgnia2019HighQ, SJ=True) -add_alias('CampbellBozorgnia2019LowQJapanSite', CampbellBozorgnia2019LowQ, SJ=True) +add_alias('CampbellBozorgnia2019JapanSite', CampbellBozorgnia2019, + SJ=True) +add_alias('CampbellBozorgnia2019HighQJapanSite', CampbellBozorgnia2019, + coeffs=coeffs_high, SJ=True) +add_alias('CampbellBozorgnia2019LowQJapanSite', CampbellBozorgnia2019, + coeffs=coeffs_low, SJ=True) diff --git a/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py b/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py index e22f17808c17..0f724baf6303 100644 --- a/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py +++ b/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py @@ -29,21 +29,19 @@ # * A1100 should refer to Z2.5 (VS30=1100) in Cell B48, not constant in A48. """ from openquake.hazardlib.gsim.campbell_bozorgnia_2014 import ( - CampbellBozorgnia2014, CampbellBozorgnia2014HighQ, CampbellBozorgnia2014LowQ, - CampbellBozorgnia2019, CampbellBozorgnia2019HighQ, CampbellBozorgnia2019LowQ) + CampbellBozorgnia2014, CampbellBozorgnia2019, coeffs_high, coeffs_low) from openquake.hazardlib.tests.gsim.utils import BaseGSIMTestCase class CampbellBozorgnia2014TestCase(BaseGSIMTestCase): - classes = [CampbellBozorgnia2014, CampbellBozorgnia2014HighQ, CampbellBozorgnia2014LowQ] + GSIM_CLASS = CampbellBozorgnia2014 MEAN_FILE = 'CB14/CB2014%s_MEAN.csv' STD_INTRA_FILE = 'CB14/CB2014%s_STD_INTRA.csv' STD_INTER_FILE = 'CB14/CB2014%s_STD_INTER.csv' STD_TOTAL_FILE = 'CB14/CB2014%s_STD_TOTAL.csv' def test_all(self): - for name, cls in zip(['', '_HIGHQ', '_LOWQ'], self.classes): - self.GSIM_CLASS = cls + for name, c in zip(['', '_HIGHQ', '_LOWQ'], [None, coeffs_high, coeffs_low]): for SJ in [0, 1]: tag = name + ('_JAPAN' if SJ else '') self.check(self.MEAN_FILE % tag, @@ -51,11 +49,11 @@ def test_all(self): self.STD_INTER_FILE % tag, self.STD_TOTAL_FILE % tag, max_discrep_percentage=0.1, - SJ=SJ) + coeffs=c, SJ=SJ) -class CampbellBozorgnia2019_IA_CAV_TestCase(CampbellBozorgnia2014TestCase): - classes = [CampbellBozorgnia2019, CampbellBozorgnia2019HighQ, CampbellBozorgnia2019LowQ] +class CampbellBozorgnia2019TestCase(CampbellBozorgnia2014TestCase): + GSIM_CLASS = CampbellBozorgnia2019 MEAN_FILE = 'CB19/CB2019%s_MEAN.csv' STD_INTRA_FILE = 'CB19/CB2019%s_STD_INTRA.csv' STD_INTER_FILE = 'CB19/CB2019%s_STD_INTER.csv' From f7ddf7e395f1d02e935a2931cccc72c0ba740472 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Fri, 4 Oct 2024 16:30:39 +0200 Subject: [PATCH 2/8] Added 4 aliases --- .../hazardlib/gsim/campbell_bozorgnia_2014.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py index ae8c73125595..c76398edc504 100644 --- a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py +++ b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py @@ -451,7 +451,7 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): pga = get_mean_values(self.SJ, C_PGA, ctx, pga1100) idx = mean[m] <= pga mean[m, idx] = pga[idx] - mean[m] += (self.sigma_mu_epsilon*get_epistemic_sigma(ctx)) + mean[m] += self.sigma_mu_epsilon * get_epistemic_sigma(ctx) # Get stddevs for PGA on basement rock tau_lnpga_b = _get_taulny(C_PGA, ctx.mag) @@ -473,9 +473,8 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): p = np.sqrt( phi_lnyb**2 + C["philnAF"]**2 + alpha**2 * phi_lnpga_b**2 - + 2.0 * alpha * _get_rholnpga(C, ctx.mag) * phi_lnyb * phi_lnpga_b - ) - + + 2.0 * alpha * _get_rholnpga(C, ctx.mag) * phi_lnyb * phi_lnpga_b) + else: # Use formula in CB14 supplementary spreadsheet t = np.sqrt(tau_lnyb**2 + alpha**2 * tau_lnpga_b**2 + @@ -557,6 +556,10 @@ class CampbellBozorgnia2019(CampbellBozorgnia2014): DEFINED_FOR_INTENSITY_MEASURE_COMPONENT = const.IMC.GEOMETRIC_MEAN +add_alias('CampbellBozorgnia2014HighQ', CampbellBozorgnia2014, + coeffs=coeffs_high) +add_alias('CampbellBozorgnia2014LowQ', CampbellBozorgnia2014, + coeffs=coeffs_low) add_alias('CampbellBozorgnia2014JapanSite', CampbellBozorgnia2014, SJ=True) add_alias('CampbellBozorgnia2014HighQJapanSite', CampbellBozorgnia2014, @@ -564,6 +567,10 @@ class CampbellBozorgnia2019(CampbellBozorgnia2014): add_alias('CampbellBozorgnia2014LowQJapanSite', CampbellBozorgnia2014, coeffs=coeffs_low, SJ=True) +add_alias('CampbellBozorgnia2019HighQ', CampbellBozorgnia2019, + coeffs=coeffs_high) +add_alias('CampbellBozorgnia2019LowQ', CampbellBozorgnia2019, + coeffs=coeffs_low) add_alias('CampbellBozorgnia2019JapanSite', CampbellBozorgnia2019, SJ=True) add_alias('CampbellBozorgnia2019HighQJapanSite', CampbellBozorgnia2019, From 11258f8c2ccdf34e1e1660412b88d37c0f712695 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Fri, 4 Oct 2024 16:50:51 +0200 Subject: [PATCH 3/8] Cleanup --- .../gsim/campbell_bozorgnia_2014_test.py | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py b/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py index 0f724baf6303..3fab06ad7ccd 100644 --- a/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py +++ b/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py @@ -28,6 +28,7 @@ # (Basin Response Term) should refer to the Sj flag instead of the Sji flag # * A1100 should refer to Z2.5 (VS30=1100) in Cell B48, not constant in A48. """ +import pytest from openquake.hazardlib.gsim.campbell_bozorgnia_2014 import ( CampbellBozorgnia2014, CampbellBozorgnia2019, coeffs_high, coeffs_low) from openquake.hazardlib.tests.gsim.utils import BaseGSIMTestCase @@ -40,22 +41,27 @@ class CampbellBozorgnia2014TestCase(BaseGSIMTestCase): STD_INTER_FILE = 'CB14/CB2014%s_STD_INTER.csv' STD_TOTAL_FILE = 'CB14/CB2014%s_STD_TOTAL.csv' - def test_all(self): - for name, c in zip(['', '_HIGHQ', '_LOWQ'], [None, coeffs_high, coeffs_low]): - for SJ in [0, 1]: - tag = name + ('_JAPAN' if SJ else '') - self.check(self.MEAN_FILE % tag, - self.STD_INTRA_FILE % tag, - self.STD_INTER_FILE % tag, - self.STD_TOTAL_FILE % tag, - max_discrep_percentage=0.1, - coeffs=c, SJ=SJ) - -class CampbellBozorgnia2019TestCase(CampbellBozorgnia2014TestCase): +class CampbellBozorgnia2019TestCase(BaseGSIMTestCase): GSIM_CLASS = CampbellBozorgnia2019 MEAN_FILE = 'CB19/CB2019%s_MEAN.csv' STD_INTRA_FILE = 'CB19/CB2019%s_STD_INTRA.csv' STD_INTER_FILE = 'CB19/CB2019%s_STD_INTER.csv' STD_TOTAL_FILE = 'CB19/CB2019%s_STD_TOTAL.csv' + +coeffs = {'': None, '_HIGHQ': coeffs_high, '_LOWQ': coeffs_low} +params = [(cls, name, SJ) + for name in ['', '_HIGHQ', '_LOWQ'] for SJ in [0, 1] + for cls in [CampbellBozorgnia2014TestCase, CampbellBozorgnia2019TestCase]] +@pytest.mark.parametrize('cls, name, SJ', params) +def test_all(cls, name, SJ): + self = cls() + tag = name + ('_JAPAN' if SJ else '') + self.check(self.MEAN_FILE % tag, + self.STD_INTRA_FILE % tag, + self.STD_INTER_FILE % tag, + self.STD_TOTAL_FILE % tag, + max_discrep_percentage=0.1, + coeffs=coeffs[name], SJ=SJ) + From 6c1aa4be62c269ecf6ede3d9357d615e6ceb1c72 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Sat, 5 Oct 2024 04:55:05 +0200 Subject: [PATCH 4/8] Fixed some tests --- openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | 8 ++++---- openquake/hazardlib/gsim/coeffs_table.py | 2 +- openquake/hazardlib/tests/gsim/coeffs_table_test.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py index c76398edc504..21cd8aa87005 100644 --- a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py +++ b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py @@ -409,11 +409,11 @@ class CampbellBozorgnia2014(GMPE): #: Required distance measures are Rrup, Rjb and Rx REQUIRES_DISTANCES = {'rrup', 'rjb', 'rx'} - def __init__(self, coeffs=None, SJ=False, sigma_mu_epsilon=0.0, estimate_ztor=False, + def __init__(self, coeffs={}, SJ=False, sigma_mu_epsilon=0.0, estimate_ztor=False, estimate_width=False, estimate_hypo_depth=False): # tested in logictree/case_71 if coeffs: # extra coefficients by IMT - self.COEFFS |= coeffs + self.COEFFS |= CoeffsTable.fromdict(coeffs) self.SJ = SJ # flag for Japan self.sigma_mu_epsilon = sigma_mu_epsilon self.estimate_ztor = estimate_ztor @@ -532,7 +532,7 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): ["SA(0.5)"]\nDc20 = 0.0025 ["SA(0.75)"]\nDc20 = 0.0016 ["SA(1.0)"]\nDc20 = 0.0006 -''') +''').to_dict() coeffs_low = CoeffsTable.fromtoml(''' ["SA(0.01)"]\nDc20 = 0.0035 @@ -549,7 +549,7 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): ["SA(0.5)"]\nDc20 = 0.0030 ["SA(0.75)"]\nDc20 = 0.0019 ["SA(1.0)"]\nDc20 = 0.0005 -''') +''').to_dict() class CampbellBozorgnia2019(CampbellBozorgnia2014): diff --git a/openquake/hazardlib/gsim/coeffs_table.py b/openquake/hazardlib/gsim/coeffs_table.py index 16d018dced2b..36333d8db926 100644 --- a/openquake/hazardlib/gsim/coeffs_table.py +++ b/openquake/hazardlib/gsim/coeffs_table.py @@ -324,7 +324,7 @@ def to_array(self): """ return np.array([self[imt] for imt in self._coeffs]) - def to_ddic(self): + def to_dict(self): """ :returns: a double dictionary imt -> coeff -> value """ diff --git a/openquake/hazardlib/tests/gsim/coeffs_table_test.py b/openquake/hazardlib/tests/gsim/coeffs_table_test.py index b8b6a430991f..96a98a896655 100644 --- a/openquake/hazardlib/tests/gsim/coeffs_table_test.py +++ b/openquake/hazardlib/tests/gsim/coeffs_table_test.py @@ -47,8 +47,8 @@ def setUp(self): """) self.ctab_eas = ctab - def test_ddic(self): - ddic = self.ctab.to_ddic() + def test_to_dict(self): + ddic = self.ctab.to_dict() self.assertEqual(toml.dumps(ddic), '''\ [PGA] a1 = 0.1 From 170b4269aa75de8972a0af94a1fb4625a5bf2c1d Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Sat, 5 Oct 2024 05:14:04 +0200 Subject: [PATCH 5/8] Added method CoeffsTable.assert_equal --- openquake/hazardlib/gsim/coeffs_table.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/openquake/hazardlib/gsim/coeffs_table.py b/openquake/hazardlib/gsim/coeffs_table.py index 36333d8db926..1a2114afbbaf 100644 --- a/openquake/hazardlib/gsim/coeffs_table.py +++ b/openquake/hazardlib/gsim/coeffs_table.py @@ -231,6 +231,9 @@ def get_coeffs(self, coeff_list): coeffs = coeffs[idx, :] return pof, coeffs + def __iter__(self): + return iter(self._coeffs) + def __getitem__(self, imt): """ Return a dictionary of coefficients corresponding to ``imt`` @@ -318,6 +321,19 @@ def __ior__(self, other): """ return self | other + def assert_equal(self, other): + """ + Compare two tables of coefficients + """ + assert sorted(self) == sorted(other), (sorted(self), sorted(other)) + for imt in self: + rec0 = self[imt] + rec1 = other[imt] + names = rec0.dtype.names + assert rec1.dtype.names == names, (rec1.dtype.names, names) + for name in names: + assert rec0[name] == rec1[name], (name, rec0[name], rec1[name]) + def to_array(self): """ :returns: a composite array with the coefficient names as columns From a3992ae33d4ae701d90b726f9f5fe70bc53383fb Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Sat, 5 Oct 2024 05:27:36 +0200 Subject: [PATCH 6/8] Fixed coeffs_low --- .../hazardlib/gsim/campbell_bozorgnia_2014.py | 28 +++++++++---------- openquake/hazardlib/gsim/coeffs_table.py | 16 +++++++++++ .../gsim/campbell_bozorgnia_2014_test.py | 1 - 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py index 21cd8aa87005..5f29abe5092e 100644 --- a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py +++ b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py @@ -535,20 +535,20 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): ''').to_dict() coeffs_low = CoeffsTable.fromtoml(''' -["SA(0.01)"]\nDc20 = 0.0035 -["SA(0.02)"]\nDc20 = 0.0034 -["SA(0.03)"]\nDc20 = 0.0037 -["SA(0.05)"]\nDc20 = 0.0037 -["SA(0.075)"]\nDc20 = 0.0034 -["SA(0.1)"]\nDc20 = 0.0030 -["SA(0.15)"]\nDc20 = 0.0031 -["SA(0.2)"]\nDc20 = 0.0033 -["SA(0.25)"]\nDc20 = 0.0035 -["SA(0.3)"]\nDc20 = 0.0034 -["SA(0.4)"]\nDc20 = 0.0032 -["SA(0.5)"]\nDc20 = 0.0030 -["SA(0.75)"]\nDc20 = 0.0019 -["SA(1.0)"]\nDc20 = 0.0005 +["SA(0.01)"]\nDc20 = -0.0035 +["SA(0.02)"]\nDc20 = -0.0034 +["SA(0.03)"]\nDc20 = -0.0037 +["SA(0.05)"]\nDc20 = -0.0037 +["SA(0.075)"]\nDc20 = -0.0034 +["SA(0.1)"]\nDc20 = -0.0030 +["SA(0.15)"]\nDc20 = -0.0031 +["SA(0.2)"]\nDc20 = -0.0033 +["SA(0.25)"]\nDc20 = -0.0035 +["SA(0.3)"]\nDc20 = -0.0034 +["SA(0.4)"]\nDc20 = -0.0032 +["SA(0.5)"]\nDc20 = -0.0030 +["SA(0.75)"]\nDc20 = -0.0019 +["SA(1.0)"]\nDc20 = -0.0005 ''').to_dict() diff --git a/openquake/hazardlib/gsim/coeffs_table.py b/openquake/hazardlib/gsim/coeffs_table.py index 1a2114afbbaf..59717c37c8b0 100644 --- a/openquake/hazardlib/gsim/coeffs_table.py +++ b/openquake/hazardlib/gsim/coeffs_table.py @@ -334,6 +334,22 @@ def assert_equal(self, other): for name in names: assert rec0[name] == rec1[name], (name, rec0[name], rec1[name]) + def get_diffs(self, other): + """ + :returns: a list of tuples [(imt, field, value_self, value_other), ...] + """ + assert sorted(self) == sorted(other), (sorted(self), sorted(other)) + diffs = [] + for imt in self: + rec0 = self[imt] + rec1 = other[imt] + names = rec0.dtype.names + assert rec1.dtype.names == names, (rec1.dtype.names, names) + for name in names: + if rec0[name] != rec1[name]: + diffs.append((imt.string, name, rec0[name], rec1[name])) + return diffs + def to_array(self): """ :returns: a composite array with the coefficient names as columns diff --git a/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py b/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py index 3fab06ad7ccd..6a9d3906571e 100644 --- a/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py +++ b/openquake/hazardlib/tests/gsim/campbell_bozorgnia_2014_test.py @@ -64,4 +64,3 @@ def test_all(cls, name, SJ): self.STD_TOTAL_FILE % tag, max_discrep_percentage=0.1, coeffs=coeffs[name], SJ=SJ) - From 9154d7c5e9e105efd8cd5dbd168d71ef61c08c82 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Sat, 5 Oct 2024 05:44:47 +0200 Subject: [PATCH 7/8] Fixed the coefficients --- .../hazardlib/gsim/campbell_bozorgnia_2014.py | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py index 5f29abe5092e..a3be6e68ae64 100644 --- a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py +++ b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py @@ -532,23 +532,33 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): ["SA(0.5)"]\nDc20 = 0.0025 ["SA(0.75)"]\nDc20 = 0.0016 ["SA(1.0)"]\nDc20 = 0.0006 +[PGA]\nDc20 = 0.0036 +[PGV]\nDc20 = 0.0017 +[CAV]\nDc20 = 0.0027 +[IA]\nDc20 = 0.0064 ''').to_dict() coeffs_low = CoeffsTable.fromtoml(''' ["SA(0.01)"]\nDc20 = -0.0035 -["SA(0.02)"]\nDc20 = -0.0034 -["SA(0.03)"]\nDc20 = -0.0037 +["SA(0.02)"]\nDc20 = -0.0035 +["SA(0.03)"]\nDc20 = -0.0034 ["SA(0.05)"]\nDc20 = -0.0037 -["SA(0.075)"]\nDc20 = -0.0034 -["SA(0.1)"]\nDc20 = -0.0030 -["SA(0.15)"]\nDc20 = -0.0031 -["SA(0.2)"]\nDc20 = -0.0033 -["SA(0.25)"]\nDc20 = -0.0035 -["SA(0.3)"]\nDc20 = -0.0034 -["SA(0.4)"]\nDc20 = -0.0032 -["SA(0.5)"]\nDc20 = -0.0030 -["SA(0.75)"]\nDc20 = -0.0019 -["SA(1.0)"]\nDc20 = -0.0005 +["SA(0.075)"]\nDc20 = -0.0037 +["SA(0.1)"]\nDc20 = -0.0034 +["SA(0.15)"]\nDc20 = -0.0030 +["SA(0.2)"]\nDc20 = -0.0031 +["SA(0.25)"]\nDc20 = -0.0033 +["SA(0.3)"]\nDc20 = -0.0035 +["SA(0.4)"]\nDc20 = -0.0034 +["SA(0.5)"]\nDc20 = -0.0034 +["SA(0.75)"]\nDc20 = -0.0032 +["SA(1.0)"]\nDc20 = -0.0030 +["SA(1.5)"]\nDc20 = -0.0019 +["SA(2.0)"]\nDc20 = -0.0005 +[PGA]\nDc20 = -0.0035 +[PGV]\nDc20 = -0.0006 +[CAV]\nDc20 = -0.0024 +[IA]\nDc20 = -0.0051 ''').to_dict() From 87ba00262adcd2fd1f52f4c8f2005a8ae72d86e8 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Sat, 5 Oct 2024 05:55:08 +0200 Subject: [PATCH 8/8] Better TOML syntax [ci skip] --- .../hazardlib/gsim/campbell_bozorgnia_2014.py | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py index a3be6e68ae64..f5ad0293436a 100644 --- a/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py +++ b/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py @@ -518,47 +518,47 @@ def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi): """) coeffs_high = CoeffsTable.fromtoml(''' -["SA(0.01)"]\nDc20 = 0.0036 -["SA(0.02)"]\nDc20 = 0.0036 -["SA(0.03)"]\nDc20 = 0.0037 -["SA(0.05)"]\nDc20 = 0.0040 -["SA(0.075)"]\nDc20 = 0.0039 -["SA(0.1)"]\nDc20 = 0.0042 -["SA(0.15)"]\nDc20 = 0.0042 -["SA(0.2)"]\nDc20 = 0.0041 -["SA(0.25)"]\nDc20 = 0.0036 -["SA(0.3)"]\nDc20 = 0.0031 -["SA(0.4)"]\nDc20 = 0.0028 -["SA(0.5)"]\nDc20 = 0.0025 -["SA(0.75)"]\nDc20 = 0.0016 -["SA(1.0)"]\nDc20 = 0.0006 -[PGA]\nDc20 = 0.0036 -[PGV]\nDc20 = 0.0017 -[CAV]\nDc20 = 0.0027 -[IA]\nDc20 = 0.0064 +"SA(0.01)".Dc20 = 0.0036 +"SA(0.02)".Dc20 = 0.0036 +"SA(0.03)".Dc20 = 0.0037 +"SA(0.05)".Dc20 = 0.0040 +"SA(0.075)".Dc20 = 0.0039 +"SA(0.1)".Dc20 = 0.0042 +"SA(0.15)".Dc20 = 0.0042 +"SA(0.2)".Dc20 = 0.0041 +"SA(0.25)".Dc20 = 0.0036 +"SA(0.3)".Dc20 = 0.0031 +"SA(0.4)".Dc20 = 0.0028 +"SA(0.5)".Dc20 = 0.0025 +"SA(0.75)".Dc20 = 0.0016 +"SA(1.0)".Dc20 = 0.0006 +PGA.Dc20 = 0.0036 +PGV.Dc20 = 0.0017 +CAV.Dc20 = 0.0027 +IA.Dc20 = 0.0064 ''').to_dict() coeffs_low = CoeffsTable.fromtoml(''' -["SA(0.01)"]\nDc20 = -0.0035 -["SA(0.02)"]\nDc20 = -0.0035 -["SA(0.03)"]\nDc20 = -0.0034 -["SA(0.05)"]\nDc20 = -0.0037 -["SA(0.075)"]\nDc20 = -0.0037 -["SA(0.1)"]\nDc20 = -0.0034 -["SA(0.15)"]\nDc20 = -0.0030 -["SA(0.2)"]\nDc20 = -0.0031 -["SA(0.25)"]\nDc20 = -0.0033 -["SA(0.3)"]\nDc20 = -0.0035 -["SA(0.4)"]\nDc20 = -0.0034 -["SA(0.5)"]\nDc20 = -0.0034 -["SA(0.75)"]\nDc20 = -0.0032 -["SA(1.0)"]\nDc20 = -0.0030 -["SA(1.5)"]\nDc20 = -0.0019 -["SA(2.0)"]\nDc20 = -0.0005 -[PGA]\nDc20 = -0.0035 -[PGV]\nDc20 = -0.0006 -[CAV]\nDc20 = -0.0024 -[IA]\nDc20 = -0.0051 +"SA(0.01)".Dc20 = -0.0035 +"SA(0.02)".Dc20 = -0.0035 +"SA(0.03)".Dc20 = -0.0034 +"SA(0.05)".Dc20 = -0.0037 +"SA(0.075)".Dc20 = -0.0037 +"SA(0.1)".Dc20 = -0.0034 +"SA(0.15)".Dc20 = -0.0030 +"SA(0.2)".Dc20 = -0.0031 +"SA(0.25)".Dc20 = -0.0033 +"SA(0.3)".Dc20 = -0.0035 +"SA(0.4)".Dc20 = -0.0034 +"SA(0.5)".Dc20 = -0.0034 +"SA(0.75)".Dc20 = -0.0032 +"SA(1.0)".Dc20 = -0.0030 +"SA(1.5)".Dc20 = -0.0019 +"SA(2.0)".Dc20 = -0.0005 +PGA.Dc20 = -0.0035 +PGV.Dc20 = -0.0006 +CAV.Dc20 = -0.0024 +IA.Dc20 = -0.0051 ''').to_dict()