-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathoqvalidation.py
More file actions
2383 lines (2106 loc) · 87.7 KB
/
Copy pathoqvalidation.py
File metadata and controls
2383 lines (2106 loc) · 87.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (C) 2014-2025 GEM Foundation
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>.
import os
import re
import ast
import sys
import json
import inspect
import logging
import pathlib
import functools
import collections
import numpy
import pandas
import itertools
from openquake.baselib import __version__, hdf5, python3compat, config
from openquake.baselib.parallel import Starmap
from openquake.baselib.general import DictArray, AccumDict, cached_property
from openquake.hazardlib.imt import from_string, sort_by_imt, sec_imts
from openquake.hazardlib import shakemap
from openquake.hazardlib import correlation, cross_correlation, stats, calc
from openquake.hazardlib import valid, InvalidFile, site
from openquake.sep.classes import SecondaryPeril
from openquake.hazardlib.gsim_lt import GsimLogicTree
from openquake.risklib import asset, scientific
from openquake.risklib.riskmodels import get_risk_files
__doc__ = """\
Full list of configuration parameters
=====================================
Engine Version: %s
Some parameters have a default that it is used when the parameter is
not specified in the job.ini file. Some other parameters have no default,
which means that not specifying them will raise an error when running
a calculation for which they are required.
override_vs30:
Optional Vs30 parameter to override the site model Vs30
Example: *override_vs30 = 800*
Default: None
aggregate_by:
Used to compute aggregate losses and aggregate loss curves in risk
calculations. Takes in input one or more exposure tags.
Example: *aggregate_by = region, taxonomy*.
Default: empty list
aggregate_loss_curves_types:
Used for event-based risk and damage calculations, to estimate the aggregated
loss Exceedance Probability (EP) only or to also calculate (if possible) the
Occurrence Exceedance Probability (OEP) and/or the Aggregate Exceedance
Probability (AEP).
Example: *aggregate_loss_curves_types = aep, oep*.
Default: ep
reaggregate_by:
Used to perform additional aggregations in risk calculations. Takes in
input a proper subset of the tags in the aggregate_by option.
Example: *reaggregate_by = region*.
Default: empty list
amplification_method:
Used in classical PSHA calculations to amplify the hazard curves with
the convolution or kernel method.
Example: *amplification_method = kernel*.
Default: "convolution"
asce_version:
ASCE version used in AELO mode.
Example: *asce_version = asce7-22*.
Default: "asce7-16"
area_source_discretization:
Discretization parameters (in km) for area sources.
Example: *area_source_discretization = 10*.
Default: 10
ash_wet_amplification_factor:
Used in volcanic risk calculations.
Example: *ash_wet_amplification_factor=1.0*.
Default: 1.0
asset_correlation:
Used in risk calculations to take into account asset correlation. Accepts
only the values 1 (full correlation) and 0 (no correlation).
Example: *asset_correlation=1*.
Default: 0
asset_hazard_distance:
In km, used in risk calculations to print a warning when there are assets
too distant from the hazard sites. In multi_risk calculations can be a
dictionary: asset_hazard_distance = {'ASH': 50, 'LAVA': 10, ...}
Example: *asset_hazard_distance = 5*.
Default: 15
asset_life_expectancy:
Used in the classical_bcr calculator.
Example: *asset_life_expectancy = 50*.
Default: no default
assets_per_site_limit:
INTERNAL
gmf_max_gb:
If the size (in GB) of the GMFs is below this value, then compute avg_gmf
Example: *gmf_max_gb = 1.*
Default: 0.1
avg_losses:
Used in risk calculations to compute average losses.
Example: *avg_losses=false*.
Default: True
base_path:
INTERNAL
cachedir:
INTERNAL
cache_distances:
Useful in UCERF calculations.
Example: *cache_distances = true*.
Default: False
calculation_mode:
One of classical, disaggregation, event_based, scenario, scenario_risk,
scenario_damage, event_based_risk, classical_risk, classical_bcr.
Example: *calculation_mode=classical*
Default: no default
collapse_gsim_logic_tree:
INTERNAL
collapse_level:
INTERNAL
collect_rlzs:
Collect all realizations into a single effective realization. If not given
it is true for sampling and false for full enumeration.
Example: *collect_rlzs=true*.
Default: None
correlation_cutoff:
Used in conditioned GMF calculation to avoid small negative eigenvalues
wreaking havoc with the numerics
Example: *correlation_cutoff = 1E-11*
Default: 1E-12
compare_with_classical:
Used in event based calculation to perform also a classical calculation,
so that the hazard curves can be compared.
Example: *compare_with_classical = true*.
Default: False
complex_fault_mesh_spacing:
In km, used to discretize complex faults.
Example: *complex_fault_mesh_spacing = 15*.
Default: 5
concurrent_tasks:
A hint to the engine for the number of tasks to generate. Do not set
it unless you know what you are doing.
Example: *concurrent_tasks = 100*.
Default: twice the number of cores
conditional_loss_poes:
Used in classical_risk calculations to compute loss curves.
Example: *conditional_loss_poes = 0.01 0.02*.
Default: empty list
cholesky_limit:
When generating the GMFs from a ShakeMap the engine needs to perform a
Cholesky decomposition of a matrix of size (M x N)^2, being M the number
of intensity measure types and N the number of sites. The decomposition
can become ultra-slow, run out of memory, or produce bogus negative
eigenvalues, therefore there is a limit on the maximum size of M x N.
Example: *cholesky_limit = 1000*.
Default: 10,000
continuous_fragility_discretization:
Used when discretizing continuuos fragility functions.
Example: *continuous_fragility_discretization = 10*.
Default: 20
coordinate_bin_width:
Used in disaggregation calculations.
Example: *coordinate_bin_width = 1.0*.
Default: 100 degrees, meaning don't disaggregate by lon, lat
countries:
Used to restrict the exposure to a single country in Aristotle mode.
Example: *countries = ITA*.
Default: ()
cross_correlation:
When used in Conditional Spectrum calculation is the name of a cross
correlation class (i.e. "BakerJayaram2008").
When used in ShakeMap calculations the valid choices are "yes", "no" "full",
same as for *spatial_correlation*.
Example: *cross_correlation = no*.
Default: "yes"
description:
A string describing the calculation.
Example: *description = Test calculation*.
Default: "no description"
disagg_bin_edges:
A dictionary where the keys can be: mag, dist, lon, lat, eps and the
values are lists of floats indicating the edges of the bins used to
perform the disaggregation.
Example: *disagg_bin_edges = {'mag': [5.0, 5.5, 6.0, 6.5]}*.
Default: empty dictionary
disagg_by_src:
Flag used to enable disaggregation by source when possible.
Example: *disagg_by_src = true*.
Default: False
disagg_outputs:
Used in disaggregation calculations to restrict the number of exported
outputs.
Example: *disagg_outputs = Mag_Dist*
Default: list of all possible outputs
discard_assets:
Flag used in risk calculations to discard assets from the exposure.
Example: *discard_assets = true*.
Default: False
discard_trts:
Used to discard tectonic region types that do not contribute to the hazard.
Example: *discard_trts = Volcanic*.
Default: empty list
discrete_damage_distribution:
Make sure the damage distribution contain only integers (require the "number"
field in the exposure to be integer).
Example: *discrete_damage_distribution = true*
Default: False
distance_bin_width:
In km, used in disaggregation calculations to specify the distance bins.
Example: *distance_bin_width = 20*.
Default: no default
epsilon_star:
A boolean controlling the typology of disaggregation output to be provided.
When True disaggregation is perfomed in terms of epsilon* rather then
epsilon (see Bazzurro and Cornell, 1999)
Example: *epsilon_star = true*
Default: False
extreme_gmv:
A scalar on an IMT-keyed dictionary specifying when a ground motion value is
extreme and the engine has to treat is specially.
Example: *extreme_gmv = 5.0*
Default: {'default': numpy.inf} i.e. no values are extreme
floating_x_step:
Float, used in rupture generation for kite faults. indicates the fraction
of fault length used to float ruptures along strike by the given float
(i.e. "0.5" floats the ruptures at half the rupture length). Uniform
distribution of the ruptures is maintained, such that if the mesh spacing
and rupture dimensions prohibit the defined overlap fraction, the fraction
is increased until uniform distribution is achieved. The minimum possible
value depends on the rupture dimensions and the mesh spacing.
If 0, standard rupture floating is used along-strike (i.e. no mesh nodes
are skipped).
Example: *floating_x_step = 0.5*
Default: 0
floating_y_step:
Float, used in rupture generation for kite faults. indicates the fraction
of fault width used to float ruptures down dip. (i.e. "0.5" floats that
half the rupture length). Uniform distribution of the ruptures
is maintained, such that if the mesh spacing and rupture dimensions
prohibit the defined overlap fraction, the fraction is increased until
uniform distribution is achieved. The minimum possible value depends on
the rupture dimensions and the mesh spacing.
If 0, standard rupture floating is used along-strike (i.e. no mesh nodes
on the rupture dimensions and the mesh spacing.
Example: *floating_y_step = 0.5*
Default: 0
ignore_encoding_errors:
If set, skip characters with non-UTF8 encoding
Example: *ignore_encoding_errors = true*.
Default: False
ignore_master_seed:
If set, estimate analytically the uncertainty on the losses due to the
uncertainty on the vulnerability functions.
Example: *ignore_master_seed = vulnerability*.
Default: None
export_dir:
Set the export directory.
Example: *export_dir = /tmp*.
Default: the current directory, "."
exports:
Specify what kind of outputs to export by default.
Example: *exports = csv, rst*.
Default: empty list
ground_motion_correlation_model:
Enable ground motion correlation.
Example: *ground_motion_correlation_model = JB2009*.
Default: None
ground_motion_correlation_params:
To be used together with ground_motion_correlation_model.
Example: *ground_motion_correlation_params = {"vs30_clustering": False}*.
Default: empty dictionary
ground_motion_fields:
Flag to turn on/off the calculation of ground motion fields.
Example: *ground_motion_fields = false*.
Default: True
gsim:
Used to specify a GSIM in scenario or event based calculations.
Example: *gsim = BooreAtkinson2008*.
Default: "[FromFile]"
hazard_calculation_id:
Used to specify a previous calculation from which the hazard is read.
Example: *hazard_calculation_id = 42*.
Default: None
hazard_curves_from_gmfs:
Used in scenario/event based calculations. If set, generates hazard curves
from the ground motion fields.
Example: *hazard_curves_from_gmfs = true*.
Default: False
hazard_maps:
Set it to true to export the hazard maps.
Example: *hazard_maps = true*.
Default: False
horiz_comp_to_geom_mean:
Apply the correction to the geometric mean when possible,
depending on the GMPE and the Intensity Measure Component
Example: *horiz_comp_to_geom_mean = true*.
Default: False
ignore_covs:
Used in risk calculations to set all the coefficients of variation of the
vulnerability functions to zero.
Example *ignore_covs = true*
Default: False
ignore_missing_costs:
Accepts exposures with missing costs (by discarding such assets).
Example: *ignore_missing_costs = nonstructural, business_interruption*.
Default: False
iml_disagg:
Used in disaggregation calculations to specify an intensity measure type
and level.
Example: *iml_disagg = {'PGA': 0.02}*.
Default: no default
imt_ref:
Reference intensity measure type used to compute the conditional spectrum.
The imt_ref must belong to the list of IMTs of the calculation.
Example: *imt_ref = SA(0.15)*.
Default: empty string
individual_rlzs:
When set, store the individual hazard curves and/or individual risk curves
for each realization.
Example: *individual_rlzs = true*.
Default: False
individual_curves:
Legacy name for `individual_rlzs`, it should not be used.
infer_occur_rates:
If set infer the occurrence rates from the first probs_occur in
nonparametric sources.
Example: *infer_occur_rates = true*
Default: False
infrastructure_connectivity_analysis:
If set, run the infrastructure connectivity analysis.
Example: *infrastructure_connectivity_analysis = true*
Default: False
inputs:
INTERNAL. Dictionary with the input files paths.
intensity_measure_types:
List of intensity measure types in an event based calculation.
Example: *intensity_measure_types = PGA SA(0.1)*.
Default: empty list
intensity_measure_types_and_levels:
List of intensity measure types and levels in a classical calculation.
Example: *intensity_measure_types_and_levels={"PGA": logscale(0.1, 1, 20)}*.
Default: empty dictionary
interest_rate:
Used in classical_bcr calculations.
Example: *interest_rate = 0.05*.
Default: no default
investigation_time:
Hazard investigation time in years, used in classical and event based
calculations.
Example: *investigation_time = 50*.
Default: no default
job_id:
ID of a job in the database
Example: *job_id = 42*.
Default: 0 (meaning create a new job)
limit_states:
Limit states used in damage calculations.
Example: *limit_states = moderate, complete*
Default: no default
local_timestamp:
Timestamp that includes both the date, time and the time zone information
Example: 2023-02-06 04:17:34+03:00
Default: None
lrem_steps_per_interval:
Used in the vulnerability functions.
Example: *lrem_steps_per_interval = 1*.
Default: 0
mag_bin_width:
Width of the magnitude bin used in disaggregation calculations.
Example: *mag_bin_width = 0.5*.
Default: 1.
master_seed:
Seed used to control the generation of the epsilons, relevant for risk
calculations with vulnerability functions with nonzero coefficients of
variation.
Example: *master_seed = 1234*.
Default: 123456789
max:
Compute the maximum across realizations. Akin to mean and quantiles.
Example: *max = true*.
Default: False
max_aggregations:
Maximum number of aggregation keys.
Example: *max_aggregations = 200_000*
Default: 100_000
max_blocks:
INTERNAL. Used in classical calculations
max_data_transfer:
INTERNAL. Restrict the maximum data transfer in disaggregation calculations.
max_gmvs_chunk:
Maximum number of rows of the gmf_data table per task.
Example: *max_gmvs_chunk = 200_000*
Default: 100_000
max_potential_gmfs:
Restrict the product *num_sites * num_events*.
Example: *max_potential_gmfs = 1E9*.
Default: 2E11
max_potential_paths:
Restrict the maximum number of realizations.
Example: *max_potential_paths = 200*.
Default: 15_000
max_sites_disagg:
Maximum number of sites for which to store rupture information.
In disaggregation calculations with many sites you may be forced to raise
*max_sites_disagg*, that must be greater or equal to the number of sites.
Example: *max_sites_disagg = 100*
Default: 10
max_weight:
INTERNAL
maximum_distance:
Integration distance. Can be give as a scalar, as a dictionary TRT -> scalar
or as dictionary TRT -> [(mag, dist), ...]
Example: *maximum_distance = 200*.
Default: no default
maximum_distance_stations:
Applies only to scenario calculations with conditioned GMFs to discard
stations.
Example: *maximum_distance_stations = 100*.
Default: None
mean:
Flag to enable/disable the calculation of mean curves.
Example: *mean = false*.
Default: True
minimum_asset_loss:
Used in risk calculations. If set, losses smaller than the
*minimum_asset_loss* are consider zeros.
Example: *minimum_asset_loss = {"structural": 1000}*.
Default: empty dictionary
minimum_distance:
If set, distances below the minimum are rounded up.
Example: *minimum_distance = 5*
Default: 0
minimum_intensity:
If set, ground motion values below the *minimum_intensity* are
considered zeros.
Example: *minimum_intensity = {'PGA': .01}*.
Default: empty dictionary
minimum_magnitude:
If set, ruptures below the *minimum_magnitude* are discarded.
Example: *minimum_magnitude = 5.0*.
Default: 0
modal_damage_state:
Used in scenario_damage calculations to export only the damage state
with the highest probability.
Example: *modal_damage_state = true*.
Default: false
mosaic_model:
Used to restrict the ruptures to a given model
Example: *mosaic_model = ZAF*
Default: empty string
num_epsilon_bins:
Number of epsilon bins in disaggregation calculations.
Example: *num_epsilon_bins = 3*.
Default: 1
num_rlzs_disagg:
Used in disaggregation calculation to specify how many outputs will be
generated. `0` means all realizations, `n` means the n closest to the mean
hazard curve.
Example: *num_rlzs_disagg=1*.
Default: 0
number_of_ground_motion_fields:
Used in scenario calculations to specify how many random ground motion
fields to generate.
Example: *number_of_ground_motion_fields = 100*.
Default: no default
number_of_logic_tree_samples:
Used to specify the number of realizations to generate when using logic tree
sampling. If zero, full enumeration is performed.
Example: *number_of_logic_tree_samples = 0*.
Default: 0
oversampling:
When equal to "forbid" raise an error if tot_samples > num_paths in classical
calculations; when equal to "tolerate" do not raise the error (the default).
Example: *oversampling = forbid*
Default: tolerate
poes:
Probabilities of Exceedance used to specify the hazard maps or hazard spectra
to compute.
Example: *poes = 0.01 0.02*.
Default: empty list
poes_disagg:
Alias for poes.
pointsource_distance:
Used in classical calculations to collapse the point sources. Can also be
used in conjunction with *ps_grid_spacing*.
Example: *pointsource_distance = 50*.
Default: {'default': 100}
postproc_func:
Specify a postprocessing function in calculators/postproc.
Example: *postproc_func = compute_mrd.main*
Default: 'dummy.main' (no postprocessing)
postproc_args:
Specify the arguments to be passed to the postprocessing function
Example: *postproc_args = {'imt': 'PGA'}*
Default: {} (no arguments)
prefer_global_site_params:
INTERNAL. Automatically set by the engine.
ps_grid_spacing:
Used in classical calculations to grid the point sources. Requires the
*pointsource_distance* to be set too.
Example: *ps_grid_spacing = 50*.
Default: 0, meaning no grid
quantiles:
List of probabilities used to compute the quantiles across realizations.
Example: quantiles = 0.15 0.50 0.85
Default: empty list
random_seed:
Seed used in the sampling of the logic tree.
Example: *random_seed = 1234*.
Default: 42
reference_backarc:
Used when there is no site model to specify a global backarc parameter,
used in some GMPEs. Can be True or False
Example: *reference_backarc = true*.
Default: False
reference_depth_to_1pt0km_per_sec:
Used when there is no site model to specify a global z1pt0 parameter,
used in some GMPEs.
Example: *reference_depth_to_1pt0km_per_sec = 100*.
Default: no default
reference_depth_to_2pt5km_per_sec:
Used when there is no site model to specify a global z2pt5 parameter,
used in some GMPEs.
Example: *reference_depth_to_2pt5km_per_sec = 5*.
Default: no default
reference_vs30_type:
Used when there is no site model to specify a global vs30 type.
The choices are "inferred" or "measured"
Example: *reference_vs30_type = measured"*.
Default: "inferred"
reference_vs30_value:
Used when there is no site model to specify a global vs30 value.
Example: *reference_vs30_value = 760*.
Default: no default
region:
A list of lon/lat pairs used to specify a region of interest
Example: *region = 10.0 43.0, 12.0 43.0, 12.0 46.0, 10.0 46.0*
Default: None
region_grid_spacing:
Used together with the *region* option to generate the hazard sites.
Example: *region_grid_spacing = 10*.
Default: None
return_periods:
Used in the computation of the loss curves.
Example: *return_periods = 200 500 1000*.
Default: empty list.
reqv_ignore_sources:
Used when some sources in a TRT that uses the equivalent distance term
should not be collapsed.
Example: *reqv_ignore_sources = src1 src2 src3*
Default: empty list
risk_imtls:
INTERNAL. Automatically set by the engine.
risk_investigation_time:
Used in risk calculations. If not specified, the (hazard) investigation_time
is used instead.
Example: *risk_investigation_time = 50*.
Default: None
rlz_index:
Used in disaggregation calculations to specify the realization from which
to start the disaggregation.
Example: *rlz_index = 0*.
Default: None
rupture_dict:
Dictionary with rupture parameters lon, lat, dep, mag, rake, strike, dip
Example: *rupture_dict = {'lon': 10, 'lat': 20, 'dep': 10, 'mag': 6, 'rake': 0}*
Default: {}
rupture_mesh_spacing:
Set the discretization parameter (in km) for rupture geometries.
Example: *rupture_mesh_spacing = 2.0*.
Default: 5.0
sampling_method:
One of early_weights, late_weights, early_latin, late_latin)
Example: *sampling_method = early_latin*.
Default: 'early_weights'
mea_tau_phi:
Save the mean and standard deviations computed by the GMPEs
Example: *mea_tau_phi = true*
Default: False
sec_peril_params:
INTERNAL
secondary_perils:
List of supported secondary perils.
Example: *secondary_perils = HazusLiquefaction, HazusDeformation*
Default: empty list
ses_per_logic_tree_path:
Set the number of stochastic event sets per logic tree realization in
event based calculations.
Example: *ses_per_logic_tree_path = 100*.
Default: 1
ses_seed:
Seed governing the generation of the ground motion field.
Example: *ses_seed = 123*.
Default: 42
shakemap_id:
Used in ShakeMap calculations to download a ShakeMap from the USGS site
Example: *shakemap_id = usp000fjta*.
Default: no default
shakemap_uri:
Dictionary used in ShakeMap calculations to specify a ShakeMap. Must contain
a key named "kind" with values "usgs_id", "usgs_xml" or "file_npy".
Example: shakemap_uri = {
"kind": "usgs_xml",
"grid_url": "file:///home/michele/usp000fjta/grid.xml",
"uncertainty_url": "file:///home/michele/usp000fjta/uncertainty.xml"}.
Default: empty dictionary
shift_hypo:
Used in classical calculations to shift the rupture hypocenter.
Example: *shift_hypo = true*.
Default: false
site_effects:
Used in ShakeMap calculations to turn on GMF amplification based
on the vs30 values in the ShakeMap (site_effects='shakemap') or in the
site collection (site_effects='sitecol').
Example: *site_effects = 'shakemap'*.
Default: 'no'
sites:
Used to specify a list of sites.
Example: *sites = 10.1 45, 10.2 45*.
tile_spec:
INTERNAL
tiling:
Used to force the tiling or non-tiling strategy in classical calculations
Example: *tiling = true*.
Default: None, meaning the engine will decide what to do
smlt_branch:
Used to restrict the source model logic tree to a specific branch
Example: *smlt_branch=b1*
Default: empty string, meaning all branches
soil_intensities:
Used in classical calculations with amplification_method = convolution
source_id:
Used for debugging purposes. When given, restricts the source model to the
given source IDs.
Example: *source_id = src001 src002*.
Default: empty list
source_nodes:
INTERNAL
spatial_correlation:
Used in the ShakeMap calculator. The choics are "yes", "no" and "full".
Example: *spatial_correlation = full*.
Default: "yes"
specific_assets:
INTERNAL
split_sources:
INTERNAL
split_by_gsim:
INTERNAL
outs_per_task:
How many outputs per task to generate (honored in some calculators)
Example: *outs_per_task = 3*
Default: 4
std:
Compute the standard deviation across realizations. Akin to mean and max.
Example: *std = true*.
Default: False
steps_per_interval:
Used in the fragility functions when building the intensity levels
Example: *steps_per_interval = 4*.
Default: 1
tectonic_region_type:
Used to specify a tectonic region type.
Example: *tectonic_region_type = Active Shallow Crust*.
Default: '*'
time_event:
Used in scenario_risk calculations when the occupancy depend on the time.
Valid choices are "avg", "day", "night", "transit".
Example: *time_event = day*.
Default: "avg"
time_per_task:
Used in calculations with task splitting. If a task slice takes longer
then *time_per_task* seconds, then spawn subtasks for the other slices.
Example: *time_per_task=1000*
Default: 600
total_losses:
Used in event based risk calculations to compute total losses and
and total curves by summing across different loss types. Possible values
are "structural+nonstructural", "structural+contents",
"nonstructural+contents", "structural+nonstructural+contents".
Example: *total_losses = structural+nonstructural*
Default: None
truncation_level:
Truncation level used in the GMPEs.
Example: *truncation_level = 0* to compute median GMFs.
Default: no default
uniform_hazard_spectra:
Flag used to generated uniform hazard specta for the given poes
Example: *uniform_hazard_spectra = true*.
Default: False
use_rates:
When set, convert to rates before computing the statistical hazard curves
Example: *use_rates = true*.
Default: False
vs30_tolerance:
Used when amplification_method = convolution.
Example: *vs30_tolerance = 20*.
Default: 0
width_of_mfd_bin:
Used to specify the width of the Magnitude Frequency Distribution.
Example: *width_of_mfd_bin = 0.2*.
Default: None
with_betw_ratio:
Specify the between ratio for GSIMs with only the Total StdDev.
This is necessary in conditioned GMFs calculations.
Example: *with_betw_ratio = 1.7*
Default: None
""" % __version__
PSDIST = float(config.performance.pointsource_distance)
GROUND_MOTION_CORRELATION_MODELS = ['JB2009', 'HM2018']
TWO16 = 2 ** 16 # 65536
TWO32 = 2 ** 32
U16 = numpy.uint16
U32 = numpy.uint32
U64 = numpy.uint64
F32 = numpy.float32
F64 = numpy.float64
ALL_CALCULATORS = ['aftershock',
'classical_risk',
'classical_damage',
'classical',
'custom',
'event_based',
'scenario',
'post_risk',
'ebrisk',
'scenario_risk',
'event_based_risk',
'disaggregation',
'multi_risk',
'classical_bcr',
'preclassical',
'event_based_damage',
'scenario_damage']
COST_TYPES = [
'structural', 'nonstructural', 'contents', 'business_interruption']
ALL_COST_TYPES = [
'+'.join(s) for l_idx in range(len(COST_TYPES))
for s in itertools.combinations(COST_TYPES, l_idx + 1)]
def check_same_levels(imtls):
"""
:param imtls: a dictionary (or dict-like) imt -> imls
:returns: the periods and the levels
:raises: a ValueError if the levels are not the same across all IMTs
"""
if not imtls:
raise ValueError('There are no intensity_measure_types_and_levels!')
imls = imtls[next(iter(imtls))]
for imt in imtls:
if not imt.startswith(('PGA', 'SA')):
raise ValueError('Site amplification works only with '
'PGA and SA, got %s' % imt)
if (imtls[imt] == 0).all():
raise ValueError(
'You forgot to set intensity_measure_types_and_levels!')
elif len(imtls[imt]) != len(imls) or any(
l1 != l2 for l1, l2 in zip(imtls[imt], imls)):
raise ValueError('Site amplification works only if the '
'levels are the same across all IMTs')
periods = [from_string(imt).period for imt in imtls]
return periods, imls
def check_increasing(dframe, *columns):
"""
Make sure the passed columns of the dataframe exists and correspond
to increasing numbers
"""
for col in columns:
arr = dframe[col].to_numpy()
assert (numpy.diff(arr) >= 0).all(), arr
class OqParam(valid.ParamSet):
_input_files = () # set in get_oqparam
KNOWN_INPUTS = {
'rupture_model', 'exposure', 'site_model', 'delta_rates',
'source_model', 'shakemap', 'gmfs', 'gsim_logic_tree',
'source_model_logic_tree', 'geometry', 'hazard_curves',
'insurance', 'reinsurance', 'ins_loss',
'job_ini', 'multi_peril', 'taxonomy_mapping',
'fragility', 'consequence', 'reqv', 'input_zip',
'reqv_ignore_sources', 'amplification', 'station_data',
'nonstructural_vulnerability',
'nonstructural_fragility',
'nonstructural_consequence',
'structural_vulnerability',
'structural_fragility',
'structural_consequence',
'contents_vulnerability',
'contents_fragility',
'contents_consequence',
'business_interruption_vulnerability',
'business_interruption_fragility',
'business_interruption_consequence',
'structural_vulnerability_retrofitted',
'occupants_vulnerability',
'residents_vulnerability',
'area_vulnerability',
'number_vulnerability',
'earthquake_fragility',
'earthquake_vulnerability',
'liquefaction_fragility',
'liquefaction_vulnerability',
'landslide_fragility',
'landslide_vulnerability',
'post_loss_amplification',
}
# old name => new name
ALIASES = {'individual_curves': 'individual_rlzs',
'quantile_hazard_curves': 'quantiles',
'mean_hazard_curves': 'mean',
'max_hazard_curves': 'max'}
hazard_imtls = {}
override_vs30 = valid.Param(valid.positivefloat, None)
aggregate_by = valid.Param(valid.namelists, [])
aggregate_loss_curves_types = valid.Param(
# accepting all comma-separated permutations of 1, 2 or 3 elements
# of the list ['ep', 'aep' 'oep']
valid.Choice(
'ep', 'aep', 'oep',
'ep, aep', 'ep, oep', 'aep, ep', 'aep, oep', 'oep, ep', 'oep, aep',
'ep, aep, oep', 'ep, oep, aep', 'aep, ep, oep', 'aep, oep, ep',
'oep, ep, aep', 'oep, aep, ep'),
'ep')
reaggregate_by = valid.Param(valid.namelist, [])
amplification_method = valid.Param(