openquake.commonlib package¶
calc module¶
Here is an example of how to convert GMFs into mean hazard curves. Works in the case of sampling, when the weights are all equal. It keeps everything in memory and it is extremely fast. NB: parallelization would kill the performance:
def gmvs_to_mean_hcurves(dstore):
# Convert GMFs into mean hazard curves. Works by keeping everything in
# memory and it is extremely fast.
# NB: parallelization would kill the performance.
oq = dstore['oqparam']
N = len(dstore['sitecol'])
M = len(oq.imtls)
L1 = oq.imtls.size // M
gmf_df = dstore.read_df('gmf_data', 'sid')
mean = numpy.zeros((N, 1, M, L1))
for sid, df in gmf_df.groupby(gmf_df.index):
gmvs = [df[col].to_numpy() for col in df.columns
if col.startswith('gmv_')]
mean[sid, 0] = calc.gmvs_to_poes(
gmvs, oq.imtls, oq.ses_per_logic_tree_path)
return mean
-
class
openquake.commonlib.calc.
RuptureImporter
(dstore)[source]¶ Bases:
object
Import an array of ruptures correctly, i.e. by populating the datasets ruptures, rupgeoms, events.
-
check_overflow
(E)[source]¶ Raise a ValueError if the number of sites is larger than 65,536 or the number of IMTs is larger than 256 or the number of ruptures is larger than 4,294,967,296. The limits are due to the numpy dtype used to store the GMFs (gmv_dt). There also a limit of max_potential_gmfs on the number of sites times the number of events, to avoid producing too many GMFs. In that case split the calculation or be smarter.
-
-
openquake.commonlib.calc.
compute_hazard_maps
(curves, imls, poes)[source]¶ Given a set of hazard curve poes, interpolate hazard maps at the specified
poes
.Parameters: - curves – 2D array of floats. Each row represents a curve, where the values
in the row are the PoEs (Probabilities of Exceedance) corresponding to
imls
. Each curve corresponds to a geographical location. - imls – Intensity Measure Levels associated with these hazard
curves
. Type should be an array-like of floats. - poes – Value(s) on which to interpolate a hazard map from the input
curves
. Can be an array-like or scalar value (for a single PoE).
Returns: An array of shape N x P, where N is the number of curves and P the number of poes.
- curves – 2D array of floats. Each row represents a curve, where the values
in the row are the PoEs (Probabilities of Exceedance) corresponding to
-
openquake.commonlib.calc.
convert_to_array
(pmap, nsites, imtls, inner_idx=0)[source]¶ Convert the probability map into a composite array with header of the form PGA-0.1, PGA-0.2 …
Parameters: - pmap – probability map
- nsites – total number of sites
- imtls – a DictArray with IMT and levels
Returns: a composite array of lenght nsites
-
openquake.commonlib.calc.
gmvs_to_poes
(df, imtls, ses_per_logic_tree_path)[source]¶ Parameters: - df – a DataFrame with fields gmv_0, .. gmv_{M-1}
- imtls – a dictionary imt -> imls with M IMTs and L levels
- ses_per_logic_tree_path – a positive integer
Returns: an array of PoEs of shape (M, L)
-
openquake.commonlib.calc.
make_hmap
(pmap, imtls, poes, sid=None)[source]¶ Compute the hazard maps associated to the passed probability map.
Parameters: - pmap – hazard curves in the form of a ProbabilityMap
- imtls – DictArray with M intensity measure types
- poes – P PoEs where to compute the maps
- sid – not None when pmap is actually a ProbabilityCurve
Returns: a ProbabilityMap with size (N, M, P)
hazard_writers module¶
Classes for serializing various NRML XML artifacts.
-
class
openquake.commonlib.hazard_writers.
BaseCurveWriter
(dest, **metadata)[source]¶ Bases:
object
Base class for curve writers.
Parameters: - dest – File path (including filename) or file-like object for results to be saved to.
- metadata –
The following keyword args are required:
- investigation_time: Investigation time (in years) defined in the calculation which produced these results.
The following are more or less optional (combinational rules noted below where applicable):
- statistics: ‘mean’ or ‘quantile’
- quantile_value: Only required if statistics = ‘quantile’.
- smlt_path: String representing the logic tree path which produced these curves. Only required for non-statistical curves.
- gsimlt_path: String represeting the GSIM logic tree path which produced these curves. Only required for non-statisical curves.
-
class
openquake.commonlib.hazard_writers.
DisaggXMLWriter
(dest, **metadata)[source]¶ Bases:
object
Parameters: - dest – File path (including filename) or file-like object for XML results to be saved to.
- metadata –
The following keyword args are required:
- investigation_time: Investigation time (in years) defined in the calculation which produced these results.
- imt: Intensity measure type used to compute these matrices.
- lon, lat: Longitude and latitude associated with these results.
The following attributes define dimension context for the result matrices:
- mag_bin_edges: List of magnitude bin edges (floats)
- dist_bin_edges: List of distance bin edges (floats)
- lon_bin_edges: List of longitude bin edges (floats)
- lat_bin_edges: List of latitude bin edges (floats)
- eps_bin_edges: List of epsilon bin edges (floats)
- tectonic_region_types: List of tectonic region types (strings)
- smlt_path: String representing the logic tree path which produced these results. Only required for non-statistical results.
- gsimlt_path: String represeting the GSIM logic tree path which produced these results. Only required for non-statistical results.
The following are optional, depending on the imt:
- sa_period
- sa_damping
-
BIN_EDGE_ATTR_MAP
= {'mag_bin_edges': 'magBinEdges', 'dist_bin_edges': 'distBinEdges', 'lon_bin_edges': 'lonBinEdges', 'lat_bin_edges': 'latBinEdges', 'eps_bin_edges': 'epsBinEdges', 'tectonic_region_types': 'tectonicRegionTypes'}¶ Maps metadata keywords to XML attribute names for bin edge information passed to the constructor.
-
DIM_LABEL_TO_BIN_EDGE_MAP
= {'Mag': 'mag_bin_edges', 'Dist': 'dist_bin_edges', 'Lon': 'lon_bin_edges', 'Lat': 'lat_bin_edges', 'Eps': 'eps_bin_edges', 'TRT': 'tectonic_region_types'}¶
-
serialize
(data)[source]¶ Parameters: data – A sequence of data where each datum has the following attributes:
- matrix: N-dimensional numpy array containing the disaggregation histogram.
- dim_labels: A list of strings which label the dimensions of a
given histogram. For example, for a Magnitude-Distance-Epsilon
histogram, we would expect dim_labels to be
['Mag', 'Dist', 'Eps']
. - poe: The disaggregation Probability of Exceedance level for which these results were produced.
- iml: Intensity measure level, interpolated from the source hazard
curve at the given
poe
.
-
class
openquake.commonlib.hazard_writers.
HazardCurveXMLWriter
(dest, **metadata)[source]¶ Bases:
openquake.commonlib.hazard_writers.BaseCurveWriter
Hazard Curve XML writer. See
BaseCurveWriter
for a list of general constructor inputs.- The following additional metadata params are required:
- imt: Intensity measure type used to compute these hazard curves.
- imls: Intensity measure levels, which represent the x-axis values of each curve.
- The following parameters are optional:
- sa_period: Only used with imt = ‘SA’.
- sa_damping: Only used with imt = ‘SA’.
-
add_hazard_curves
(root, metadata, data)[source]¶ Add hazard curves stored into data as child of the root element with metadata. See the documentation of the method serialize and the constructor for a description of data and metadata, respectively.
-
serialize
(data)[source]¶ Write a sequence of hazard curves to the specified file.
Parameters: data – Iterable of hazard curve data. Each datum must be an object with the following attributes:
- poes: A list of probability of exceedence values (floats).
- location: An object representing the location of the curve; must have x and y to represent lon and lat, respectively.
-
class
openquake.commonlib.hazard_writers.
HazardMapWriter
(dest, **metadata)[source]¶ Bases:
object
Parameters: - dest – File path (including filename) or a file-like object for results to be saved to.
- metadata –
The following keyword args are required:
- investigation_time: Investigation time (in years) defined in the calculation which produced these results.
- imt: Intensity measure type used to compute these hazard curves.
- poe: The Probability of Exceedance level for which this hazard map was produced.
The following are more or less optional (combinational rules noted below where applicable):
- statistics: ‘mean’ or ‘quantile’
- quantile_value: Only required if statistics = ‘quantile’.
- smlt_path: String representing the logic tree path which produced these curves. Only required for non-statistical curves.
- gsimlt_path: String represeting the GSIM logic tree path which produced these curves. Only required for non-statisical curves.
- sa_period: Only used with imt = ‘SA’.
- sa_damping: Only used with imt = ‘SA’.
-
class
openquake.commonlib.hazard_writers.
HazardMapXMLWriter
(dest, **metadata)[source]¶ Bases:
openquake.commonlib.hazard_writers.HazardMapWriter
NRML/XML implementation of a
HazardMapWriter
.See
HazardMapWriter
for information about constructor parameters.-
serialize
(data)[source]¶ Serialize hazard map data to XML.
See
HazardMapWriter.serialize()
for details about the expected input.
-
-
class
openquake.commonlib.hazard_writers.
SESXMLWriter
(dest)[source]¶ Bases:
object
Parameters: - dest – File path (including filename) or a file-like object for XML results to be saved to.
- sm_lt_path (str) – Source model logic tree branch identifier of the logic tree realization which produced this collection of stochastic event sets.
- gsim_lt_path – GSIM logic tree branch identifier of the logic tree realization which produced this collection of stochastic event sets.
-
serialize
(data, investigation_time)[source]¶ Serialize a collection of stochastic event sets to XML.
Parameters: - data –
A dictionary et_id -> list of
openquake.commonlib.calc.Rupture
objects. Each Rupture should have the following attributes:- rupid
- events_by_ses
- magnitude
- strike
- dip
- rake
- tectonic_region_type
- is_from_fault_source (a bool)
- is_multi_surface (a bool)
- lons
- lats
- depths
If is_from_fault_source is True, the rupture originated from a simple or complex fault sources. In this case, lons, lats, and depths should all be 2D arrays (of uniform shape). These coordinate triples represent nodes of the rupture mesh.
If is_from_fault_source is False, the rupture originated from a point or area source. In this case, the rupture is represented by a quadrilateral planar surface. This planar surface is defined by 3D vertices. In this case, the rupture should have the following attributes:
- top_left_corner
- top_right_corner
- bottom_right_corner
- bottom_left_corner
Each of these should be a triple of lon, lat, depth.
If is_multi_surface is True, the rupture originated from a multi-surface source. In this case, lons, lats, and depths should have uniform length. The length should be a multiple of 4, where each segment of 4 represents the corner points of a planar surface in the following order:
- top left
- top right
- bottom left
- bottom right
Each of these should be a triple of lon, lat, depth.
- investigation_time – Investigation time parameter specified in the job.ini
- data –
-
class
openquake.commonlib.hazard_writers.
UHSXMLWriter
(dest, **metadata)[source]¶ Bases:
openquake.commonlib.hazard_writers.BaseCurveWriter
UHS curve XML writer. See
BaseCurveWriter
for a list of general constructor inputs.- The following additional metadata params are required:
- poe: Probability of exceedance for which a given set of UHS have been
- computed
- periods: A list of SA (Spectral Acceleration) period values, sorted
- ascending order
-
serialize
(data)[source]¶ Write a sequence of uniform hazard spectra to the specified file.
Parameters: data – Iterable of UHS data. Each datum must be an object with the following attributes:
- imls: A sequence of Intensity Measure Levels
- location: An object representing the location of the curve; must have x and y to represent lon and lat, respectively.
-
openquake.commonlib.hazard_writers.
gen_gmfs
(gmf_set)[source]¶ Generate GMF nodes from a gmf_set :param gmf_set: a sequence of GMF objects with attributes imt, sa_period, sa_damping, event_id and containing a list of GMF nodes with attributes gmv and location. The nodes are sorted by lon/lat.
logictree module¶
Logic tree parser, verifier and processor. See specs at https://blueprints.launchpad.net/openquake-old/+spec/openquake-logic-tree-module
A logic tree object must be iterable and yielding realizations, i.e. objects with attributes value, weight, lt_path and ordinal.
-
class
openquake.commonlib.logictree.
BranchTuple
(trt, id, gsim, weight, effective)¶ Bases:
tuple
-
effective
¶ Alias for field number 4
-
gsim
¶ Alias for field number 2
-
id
¶ Alias for field number 1
-
trt
¶ Alias for field number 0
-
weight
¶ Alias for field number 3
-
-
class
openquake.commonlib.logictree.
FullLogicTree
(source_model_lt, gsim_lt)[source]¶ Bases:
object
The full logic tree as composition of
Parameters: - source_model_lt –
SourceModelLogicTree
object - gsim_lt –
GsimLogicTree
object
-
et_ids
(eri)[source]¶ Parameters: eri – effective realization index Returns: array of T group IDs, being T the number of TRTs
-
classmethod
fake
(gsimlt=None)[source]¶ Returns: a fake FullLogicTree instance with the given gsim logic tree object; if None, builds automatically a fake gsim logic tree
-
get_num_rlzs
(sm_rlz=None)[source]¶ Parameters: sm_rlz – a Realization instance (or None) Returns: the number of realizations per source model (or all)
-
get_rlzs_by_gsim_list
(list_of_et_ids)[source]¶ Returns: a list of dictionaries rlzs_by_gsim, one for each grp_id
-
num_samples
¶ Returns: the source_model_lt num_samples
parameter
-
rlzs
¶ Returns: an array of realizations
-
sampling_method
¶ Returns: the source_model_lt sampling_method
parameter
-
seed
¶ Returns: the source_model_lt seed
-
trt_by_et
¶ Returns: a list of TRTs, one for each et_id
- source_model_lt –
-
class
openquake.commonlib.logictree.
GsimLogicTree
(fname, tectonic_region_types=['*'], ltnode=None)[source]¶ Bases:
object
A GsimLogicTree instance is an iterable yielding Realization tuples with attributes value, weight and lt_path, where value is a dictionary {trt: gsim}, weight is a number in the interval 0..1 and lt_path is a tuple with the branch ids of the given realization.
Parameters: - fname (str) – full path of the gsim_logic_tree file
- tectonic_region_types – a sequence of distinct tectonic region types
- ltnode – usually None, but it can also be a
openquake.hazardlib.nrml.Node
object describing the GSIM logic tree XML file, to avoid reparsing it
-
collapse
(branchset_ids)[source]¶ Collapse the GsimLogicTree by using AgvGMPE instances if needed
Parameters: branchset_ids – branchset ids to collapse Returns: a collapse GsimLogicTree instance
-
get_gsims
(trt)[source]¶ Parameters: trt – tectonic region type Returns: sorted list of available GSIMs for that trt
-
get_num_branches
()[source]¶ Return the number of effective branches for tectonic region type, as a dictionary.
-
reduce
(trts)[source]¶ Reduce the GsimLogicTree.
Parameters: trts – a subset of tectonic region types Returns: a reduced GsimLogicTree instance
-
req_site_params
¶
-
class
openquake.commonlib.logictree.
ImtWeight
(branch, fname)[source]¶ Bases:
object
A composite weight by IMTs extracted from the gsim_logic_tree_file
-
class
openquake.commonlib.logictree.
Info
(smpaths, applytosources)¶ Bases:
tuple
-
applytosources
¶ Alias for field number 1
-
smpaths
¶ Alias for field number 0
-
-
class
openquake.commonlib.logictree.
LtRealization
(ordinal, sm_lt_path, gsim_rlz, weight)[source]¶ Bases:
object
Composite realization build on top of a source model realization and a GSIM realization.
-
gsim_lt_path
¶
-
-
class
openquake.commonlib.logictree.
Realization
(value, weight, ordinal, lt_path, samples=1)[source]¶ Bases:
object
Generic Realization object with attributes value, weight, ordinal, lt_path, samples.
-
name
¶ Compact representation for the names
-
pid
¶
-
-
class
openquake.commonlib.logictree.
SourceModelLogicTree
(filename, seed=0, num_samples=0, sampling_method='early_weights')[source]¶ Bases:
object
Source model logic tree parser.
Parameters: filename – Full pathname of logic tree file Raises: LogicTreeError – If logic tree file has a logic error, which can not be prevented by xml schema rules (like referencing sources with missing id). -
FILTERS
= ('applyToTectonicRegionType', 'applyToSources', 'applyToSourceType')¶
-
apply_branchset
(apply_to_branches, lineno, branchset)[source]¶ See superclass’ method for description and signature specification.
Parses branchset node’s attribute
@applyToBranches
to apply following branchests to preceding branches selectively. Branching level can have more than one branchset exactly for this: different branchsets can apply to different open ends.Checks that branchset tries to be applied only to branches on previous branching level which do not have a child branchset yet.
-
bset_values
(sm_rlz)[source]¶ Parameters: sm_rlz – an effective realization Returns: a list of B - 1 pairs (branchset, value)
-
collect_source_model_data
(branch_id, source_model)[source]¶ Parse source model file and collect information about source ids, source types and tectonic region types available in it. That information is used then for
validate_filters()
andvalidate_uncertainty_value()
.
-
on_each_source
¶ True if there is an applyToSources for each source.
-
parse_branches
(branchset_node, branchset)[source]¶ Create and attach branches at
branchset_node
tobranchset
.Parameters: - branchset_node – Same as for
parse_branchset()
. - branchset – An instance of
BranchSet
.
Checks that each branch has
valid
value, unique id and that all branches have total weight of 1.0.Returns: None
, all branches are attached to provided branchset.- branchset_node – Same as for
-
parse_branchset
(branchset_node, depth)[source]¶ Parameters: - node (branchset) –
etree.Element
object with tag “logicTreeBranchSet”. - depth – The sequential number of this branching level, based on 0.
Enumerates children branchsets and call
parse_branchset()
,validate_branchset()
,parse_branches()
and finallyapply_branchset()
for each.Keeps track of “open ends” – the set of branches that don’t have any child branchset on this step of execution. After processing of every branchset only those branches that are listed in it can have child branchsets (if there is one on the next level).
- node (branchset) –
-
parse_filters
(branchset_node, uncertainty_type, filters)[source]¶ See superclass’ method for description and signature specification.
Converts “applyToSources” filter value by just splitting it to a list.
-
parse_tree
(tree_node)[source]¶ Parse the whole tree and point
root_branchset
attribute to the tree’s root.
-
validate_branchset
(branchset_node, depth, branchset)[source]¶ See superclass’ method for description and signature specification.
Checks that the following conditions are met:
- First branching level must contain exactly one branchset, which must be of type “sourceModel”.
- All other branchsets must not be of type “sourceModel” or “gmpeModel”.
-
validate_filters
(branchset_node, uncertainty_type, filters)[source]¶ See superclass’ method for description and signature specification.
Checks that the following conditions are met:
- “sourceModel” uncertainties can not have filters.
- Absolute uncertainties must have only one filter – “applyToSources”, with only one source id.
- All other uncertainty types can have either no or one filter.
- Filter “applyToSources” must mention only source ids that exist in source models.
- Filter “applyToTectonicRegionType” must mention only tectonic region types that exist in source models.
- Filter “applyToSourceType” must mention only source types that exist in source models.
-
-
openquake.commonlib.logictree.
collect_info
(smlt)[source]¶ Given a path to a source model logic tree, collect all of the path names to the source models it contains and build:
- a dictionary source model branch ID -> paths
- a dictionary source model branch ID -> source IDs in applyToSources
Parameters: smlt – source model logic tree file Returns: an Info namedtupled containing the two dictionaries
-
openquake.commonlib.logictree.
get_effective_rlzs
[source]¶ Group together realizations with the same path and yield the first representative of each group.
-
openquake.commonlib.logictree.
get_field
(data, field, default)[source]¶ Parameters: data – a record with a field field, possibily missing
-
openquake.commonlib.logictree.
keyno
(branch_id, no, fname='', chars='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ')[source]¶ Parameters: - branch_id – a branch ID string
- no – number of the branch in the branchset (starting from 0)
Returns: a 1-char string for the branch_id based on the branch number
-
openquake.commonlib.logictree.
read_source_groups
(fname)[source]¶ Parameters: fname – a path to a source model XML file Returns: a list of SourceGroup objects containing source nodes
logs module¶
Set up some system-wide loggers
-
class
openquake.commonlib.logs.
LogDatabaseHandler
(job_id)[source]¶ Bases:
logging.Handler
Log stream handler
-
class
openquake.commonlib.logs.
LogFileHandler
(job_id, log_file)[source]¶ Bases:
logging.FileHandler
Log file handler
-
class
openquake.commonlib.logs.
LogStreamHandler
(job_id)[source]¶ Bases:
logging.StreamHandler
Log stream handler
-
openquake.commonlib.logs.
dbcmd
(action, *args)[source]¶ A dispatcher to the database server.
Parameters: - action (string) – database action to perform
- args (tuple) – arguments
-
openquake.commonlib.logs.
handle
(job_id, log_level='info', log_file=None)[source]¶ Context manager adding and removing log handlers.
Parameters: - job_id – ID of the current job
- log_level – one of debug, info, warn, error, critical
- log_file – log file path (if None, logs on stdout only)
oqvalidation module¶
Full list of configuration parameters¶
Engine Version: 3.11.4
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.
- 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
- amplification_method:
- Used in classical PSHA calculations to amplify the hazard curves with the convolution or kernel method. Example: amplification_method = convolution. Default: None
- 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. 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
- avg_losses:
- Used in risk calculations to compute average losses. Example: avg_losses=false. Default: True
- base_path:
- INTERNAL
- cachedir:
- INTERNAL
- 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
- 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
- float_dmg_dist:
- Flag used in scenario_damage calculations to specify that the damage distributions should be stored as floating point numbers (float32) and not as integers (uint32). Example: float_dmg_dist = true. Default: False
- 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: no default
- cross_correlation:
- Used in ShakeMap calculations. 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 default
- 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
- distance_bin_width:
- In km, used in disaggregation calculations to specify the distance bins. Example: distance_bin_width = 20. Default: no default
- ebrisk_maxsize:
- INTERNAL
- 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
- 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
- individual_curves:
- When set, store the individual hazard curves and/or individual risk curves for each realization. Example: individual_curves = 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
- 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: no default
- 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: 0
- max:
- Compute the maximum across realizations. Akin to mean and quantiles. Example: max = true. Default: False
- max_data_transfer:
- INTERNAL. Restrict the maximum data transfer in disaggregation calculations.
- 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: 100
- 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_sites_per_gmf:
- Restrict the maximum number of sites in event based calculation with GMFs. Example: max_sites_per_gmf = 100_000. Default: 65536
- max_sites_per_tile:
- INTERNAL
- 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
- mean:
- Flag to enable/disable the calculation of mean curves. Example: mean = false. Default: True
- min_weight:
- INTERNAL
- 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_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
- num_epsilon_bins:
- Number of epsilon bins in disaggregation calculations. Example: num_epsilon_bins = 3. Default: no default
- num_rlzs_disagg:
- Used in disaggregation calculation to specify how many outputs will be generated. Example: num_rlzs_disagg=1. Default: None
- 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: no default
- 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: empty dictionary
- 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: no default
- quantiles:
- List of probabilities used to compute the quantiles across realizations. Example: quantiles = 9.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_siteclass:
- Used when there is no site model to specify a global site class. The siteclass is a one-character letter used in some GMPEs, like the McVerry (2006), and has values “A”, “B”, “C” or “D”. Example: reference_siteclass = “A”. Default: “D”
- 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 = inferred”. Default: “measured”
- 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.
- 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_mesh_spacing:
- Set the discretization parameter (in km) for rupture geometries. Example: rupture_mesh_spacing = 2.0. Default: 5.0
- ruptures_per_block:
- INTERNAL
- sampling_method:
- One of early_weights, late_weights, early_latin, late_latin) Example: sampling_method = early_latin. Default: ‘early_weights’
- save_disk_space:
- INTERNAL
- sec_peril_params:
- INTERNAL
- secondary_perils:
- INTERNAL
- secondary_simulations:
- INTERNAL
- sensitivity_analysis:
- Dictionary describing a sensitivity analysis. Example: sensitivity_analysis = {‘maximum_distance’: [200, 300]}. Default: empty dictionary
- 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
- shift_hypo:
- Used in classical calculations to shift the rupture hypocenter. Example: shift_hypo = true. Default: false
- site_effects:
- Flag used in ShakeMap calculations to turn out GMF amplification Example: site_effects = true. Default: False
- sites:
- Used to specify a list of sites. Example: sites = 10.1 45, 10.2 45.
- sites_slice:
- INTERNAL
- 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
- 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
- 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
- time_event:
- Used in scenario_risk calculations when the occupancy depend on the time. Valid choices are “day”, “night”, “transit”. Example: time_event = day. 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
- 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
-
class
openquake.commonlib.oqvalidation.
OqParam
(**names_vals)[source]¶ Bases:
openquake.hazardlib.valid.ParamSet
-
KNOWN_INPUTS
= {'nonstructural_fragility', 'insurance', 'nonstructural_vulnerability', 'nonstructural_consequence', 'consequence', 'contents_consequence', 'amplification', 'reqv', 'shakemap', 'business_interruption_fragility', 'sites', 'multi_peril', 'gmfs', 'gsim_logic_tree', 'business_interruption_consequence', 'structural_consequence', 'hazard_curves', 'contents_fragility', 'business_interruption_vulnerability', 'occupants_vulnerability', 'fragility', 'structural_vulnerability_retrofitted', 'source_model_logic_tree', 'taxonomy_mapping', 'contents_vulnerability', 'structural_vulnerability', 'structural_fragility', 'input_zip', 'rupture_model', 'site_model', 'source_model', 'job_ini', 'exposure'}¶
-
aggregate_by
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
all_cost_types
¶ Return the cost types of the computation (including occupants if it is there) in order.
-
amplification_method
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
area_source_discretization
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ash_wet_amplification_factor
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
asset_correlation
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
asset_hazard_distance
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
asset_life_expectancy
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
assets_per_site_limit
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
avg_losses
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
base_path
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
cachedir
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
calculation_mode
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
collapse_gsim_logic_tree
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
collapse_level
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
compare_with_classical
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
complex_fault_mesh_spacing
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
concurrent_tasks
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
conditional_loss_poes
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
continuous_fragility_discretization
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
coordinate_bin_width
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
correl_model
¶ Return a correlation object. See
openquake.hazardlib.correlation
for more info.
-
cross_correlation
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
description
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
disagg_by_src
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
disagg_outputs
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
discard_assets
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
discard_trts
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
distance_bin_width
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ebrisk_maxsize
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
export_dir
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
exports
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
float_dmg_dist
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ground_motion_correlation_model
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ground_motion_correlation_params
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ground_motion_fields
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
gsim
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
hazard_calculation_id
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
hazard_curves_from_gmfs
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
hazard_imtls
= {}¶
-
hazard_maps
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ignore_covs
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ignore_missing_costs
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
iml_disagg
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
imtls
¶ Returns a DictArray with the risk intensity measure types and levels, if given, or the hazard ones.
-
individual_curves
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
input_dir
¶ Returns: absolute path to where the job.ini is
-
inputs
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
intensity_measure_types
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
intensity_measure_types_and_levels
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
interest_rate
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
investigation_time
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
is_valid_aggregate_by
()[source]¶ At the moment only aggregate_by=id or aggregate_by=site_id are accepted
-
is_valid_complex_fault_mesh_spacing
()[source]¶ The complex_fault_mesh_spacing parameter can be None only if rupture_mesh_spacing is set. In that case it is identified with it.
-
is_valid_export_dir
()[source]¶ export_dir={export_dir} must refer to a directory, and the user must have the permission to write on it.
-
is_valid_geometry
()[source]¶ It is possible to infer the geometry only if exactly one of sites, sites_csv, hazard_curves_csv, region is set. You did set more than one, or nothing.
-
is_valid_intensity_measure_levels
()[source]¶ In order to compute hazard curves, intensity_measure_types_and_levels must be set or extracted from the risk models.
-
is_valid_intensity_measure_types
()[source]¶ If the IMTs and levels are extracted from the risk models, they must not be set directly. Moreover, if intensity_measure_types_and_levels is set directly, intensity_measure_types must not be set.
-
is_valid_poes
()[source]¶ When computing hazard maps and/or uniform hazard spectra, the poes list must be non-empty.
-
is_valid_soil_intensities
()[source]¶ soil_intensities can be set only if amplification_method=convolution
-
is_valid_specific_assets
()[source]¶ Read the special assets from the parameters specific_assets or specific_assets_csv, if present. You cannot have both. The concept is meaninful only for risk calculators.
-
is_valid_truncation_level
()[source]¶ In presence of a correlation model the truncation level must be nonzero
-
is_valid_truncation_level_disaggregation
()[source]¶ Truncation level must be set for disaggregation calculations
-
job_type
¶ ‘hazard’ or ‘risk’
-
loss_dt
(dtype=<class 'numpy.float32'>)[source]¶ Returns: a composite dtype based on the loss types including occupants
-
loss_dt_list
(dtype=<class 'numpy.float32'>)[source]¶ Returns: a data type list [(loss_name, dtype), …]
-
loss_names
¶ Loss types plus insured types, if any
-
lrem_steps_per_interval
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
lti
¶ Dictionary extended_loss_type -> extended_loss_type index
-
mag_bin_width
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
master_seed
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
max
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
max_data_transfer
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
max_potential_gmfs
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
max_potential_paths
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
max_sites_disagg
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
max_sites_per_gmf
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
max_sites_per_tile
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
max_weight
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
maximum_distance
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
mean
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
mean_hazard_curves
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
min_iml
¶ Returns: a dictionary of intensities, one per IMT
-
min_weight
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
minimum_asset_loss
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
minimum_intensity
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
minimum_magnitude
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
modal_damage_state
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
num_epsilon_bins
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
num_rlzs_disagg
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
number_of_ground_motion_fields
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
number_of_logic_tree_samples
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
poes
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
poes_disagg
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
pointsource_distance
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ps_grid_spacing
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
quantile_hazard_curves
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
quantiles
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
random_seed
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
reference_backarc
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
reference_depth_to_1pt0km_per_sec
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
reference_depth_to_2pt5km_per_sec
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
reference_siteclass
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
reference_vs30_type
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
reference_vs30_value
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
region
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
region_grid_spacing
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
return_periods
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
risk_files
¶
-
risk_imtls
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
risk_investigation_time
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
rlz_index
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
rupture_mesh_spacing
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ruptures_per_block
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
sampling_method
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
save_disk_space
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
sec_peril_params
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
secondary_perils
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
secondary_simulations
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
sensitivity_analysis
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ses_per_logic_tree_path
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
ses_ratio
¶ The ratio
risk_investigation_time / investigation_time / ses_per_logic_tree_path
-
ses_seed
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
set_risk_imts
(risklist)[source]¶ Parameters: risklist – a list of risk functions with attributes .id, .loss_type, .kind Set the attribute risk_imtls.
-
shakemap_id
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
shift_hypo
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
site_effects
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
siteparam
= {'vs30measured': 'reference_vs30_type', 'vs30': 'reference_vs30_value', 'z1pt0': 'reference_depth_to_1pt0km_per_sec', 'z2pt5': 'reference_depth_to_2pt5km_per_sec', 'siteclass': 'reference_siteclass', 'backarc': 'reference_backarc'}¶
-
sites
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
sites_slice
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
soil_intensities
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
source_id
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
spatial_correlation
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
specific_assets
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
split_sources
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
std
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
steps_per_interval
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
time_event
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
truncation_level
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
tses
¶ Return the total time as investigation_time * ses_per_logic_tree_path * (number_of_logic_tree_samples or 1)
-
uniform_hazard_spectra
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
vs30_tolerance
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
width_of_mfd_bin
¶ A descriptor for validated parameters with a default, to be used as attributes in ParamSet objects.
Parameters: - validator – the validator
- default – the default value
-
readinput module¶
-
exception
openquake.commonlib.readinput.
DuplicatedPoint
[source]¶ Bases:
Exception
Raised when reading a CSV file with duplicated (lon, lat) pairs
-
class
openquake.commonlib.readinput.
Site
(sid, lon, lat)¶ Bases:
tuple
-
lat
¶ Alias for field number 2
-
lon
¶ Alias for field number 1
-
sid
¶ Alias for field number 0
-
-
openquake.commonlib.readinput.
collect_files
(dirpath, cond=<function <lambda>>)[source]¶ Recursively collect the files contained inside dirpath.
Parameters: - dirpath – path to a readable directory
- cond – condition on the path to collect the file
-
openquake.commonlib.readinput.
extract_from_zip
(path, ext='.ini')[source]¶ Given a zip archive and a function to detect the presence of a given filename, unzip the archive into a temporary directory and return the full path of the file. Raise an IOError if the file cannot be found within the archive.
Parameters: - path – pathname of the archive
- ext – file extension to search for
-
openquake.commonlib.readinput.
get_amplification
(oqparam)[source]¶ Returns: a DataFrame (ampcode, level, PGA, SA() …)
-
openquake.commonlib.readinput.
get_checksum32
(oqparam, h5=None)[source]¶ Build an unsigned 32 bit integer from the hazard input files
Parameters: oqparam – an OqParam instance
-
openquake.commonlib.readinput.
get_composite_source_model
(oqparam, h5=None)[source]¶ Parse the XML and build a complete composite source model in memory.
Parameters: - oqparam – an
openquake.commonlib.oqvalidation.OqParam
instance - h5 – an open hdf5.File where to store the source info
- oqparam – an
-
openquake.commonlib.readinput.
get_crmodel
(oqparam)[source]¶ - Return a
openquake.risklib.riskinput.CompositeRiskModel
instanceParameters: oqparam – an openquake.commonlib.oqvalidation.OqParam
instance
-
openquake.commonlib.readinput.
get_csv_header
(fname, sep=', ')[source]¶ Parameters: - fname – a CSV file
- sep – the separator (default comma)
Returns: the first line of fname
-
openquake.commonlib.readinput.
get_exposure
(oqparam)[source]¶ Read the full exposure in memory and build a list of
openquake.risklib.asset.Asset
instances.Parameters: oqparam – an openquake.commonlib.oqvalidation.OqParam
instanceReturns: an Exposure
instance or a compatible AssetCollection
-
openquake.commonlib.readinput.
get_full_lt
(oqparam)[source]¶ Parameters: oqparam – an openquake.commonlib.oqvalidation.OqParam
instanceReturns: a openquake.commonlib.logictree.FullLogicTree
instance
-
openquake.commonlib.readinput.
get_gsim_lt
(oqparam, trts=('*', ))[source]¶ Parameters: - oqparam – an
openquake.commonlib.oqvalidation.OqParam
instance - trts – a sequence of tectonic region types as strings; trts=[‘*’] means that there is no filtering
Returns: a GsimLogicTree instance obtained by filtering on the provided tectonic region types.
- oqparam – an
-
openquake.commonlib.readinput.
get_imts
(oqparam)[source]¶ Return a sorted list of IMTs as hazardlib objects
-
openquake.commonlib.readinput.
get_input_files
(oqparam, hazard=False)[source]¶ Parameters: - oqparam – an OqParam instance
- hazard – if True, consider only the hazard files
Returns: input path names in a specific order
-
openquake.commonlib.readinput.
get_mesh
(oqparam, h5=None)[source]¶ Extract the mesh of points to compute from the sites, the sites_csv, the region, the site model, the exposure in this order.
Parameters: oqparam – an openquake.commonlib.oqvalidation.OqParam
instance
-
openquake.commonlib.readinput.
get_oqparam
(job_ini, pkg=None, calculators=None, kw={}, validate=1)[source]¶ Parse a dictionary of parameters from an INI-style config file.
Parameters: - job_ini – Path to configuration file/archive or dictionary of parameters
- pkg – Python package where to find the configuration file (optional)
- calculators – Sequence of calculator names (optional) used to restrict the valid choices for calculation_mode
- kw – Dictionary of strings to override the job parameters
- validate – Flag. By default it is true and the parameters are validated
Returns: An
openquake.commonlib.oqvalidation.OqParam
instance containing the validate and casted parameters/values parsed from the job.ini file as well as a subdictionary ‘inputs’ containing absolute paths to all of the files referenced in the job.ini, keyed by the parameter name.
-
openquake.commonlib.readinput.
get_params
(job_ini, kw={})[source]¶ Parse a .ini file or a .zip archive
Parameters: - job_ini – Configuration file | zip archive | URL
- kw – Optionally override some parameters
Returns: A dictionary of parameters
-
openquake.commonlib.readinput.
get_pmap_from_csv
(oqparam, fnames)[source]¶ Parameters: - oqparam – an
openquake.commonlib.oqvalidation.OqParam
instance - fnames – a space-separated list of .csv relative filenames
Returns: the site mesh and the hazard curves read by the .csv files
- oqparam – an
-
openquake.commonlib.readinput.
get_rupture
(oqparam)[source]¶ Read the rupture_model file and by filter the site collection
Parameters: oqparam – an openquake.commonlib.oqvalidation.OqParam
instanceReturns: an hazardlib rupture
-
openquake.commonlib.readinput.
get_ruptures
(fname_csv)[source]¶ Read ruptures in CSV format and return an ArrayWrapper
-
openquake.commonlib.readinput.
get_site_collection
(oqparam, h5=None)[source]¶ Returns a SiteCollection instance by looking at the points and the site model defined by the configuration parameters.
Parameters: oqparam – an openquake.commonlib.oqvalidation.OqParam
instance
-
openquake.commonlib.readinput.
get_site_model
(oqparam)[source]¶ Convert the NRML file into an array of site parameters.
Parameters: oqparam – an openquake.commonlib.oqvalidation.OqParam
instanceReturns: an array with fields lon, lat, vs30, …
-
openquake.commonlib.readinput.
get_sitecol_assetcol
(oqparam, haz_sitecol=None, cost_types=())[source]¶ Parameters: - oqparam – calculation parameters
- haz_sitecol – the hazard site collection
- cost_types – the expected cost types
Returns: (site collection, asset collection, discarded)
-
openquake.commonlib.readinput.
get_source_model_lt
(oqparam)[source]¶ Parameters: oqparam – an openquake.commonlib.oqvalidation.OqParam
instanceReturns: a openquake.commonlib.logictree.SourceModelLogicTree
instance
-
openquake.commonlib.readinput.
reduce_sm
(paths, source_ids)[source]¶ Parameters: - paths – list of source_model.xml files
- source_ids – dictionary src_id -> array[src_id, code]
Returns: dictionary with keys good, total, model, path, xmlns
NB: duplicate sources are not removed from the XML
-
openquake.commonlib.readinput.
reduce_source_model
(smlt_file, source_ids, remove=True)[source]¶ Extract sources from the composite source model.
Parameters: - smlt_file – path to a source model logic tree file
- source_ids – dictionary source_id -> records (src_id, code)
- remove – if True, remove sm.xml files containing no sources
Returns: the number of sources satisfying the filter vs the total
source_reader module¶
-
class
openquake.commonlib.source_reader.
CompositeSourceModel
(full_lt, src_groups)[source]¶ Bases:
object
Parameters: - full_lt – a
FullLogicTree
instance - src_groups – a list of SourceGroups
- event_based – a flag True for event based calculations, flag otherwise
- full_lt – a
-
openquake.commonlib.source_reader.
get_csm
(oq, full_lt, h5=None)[source]¶ Build source models from the logic tree and to store them inside the source_full_lt dataset.
util module¶
-
openquake.commonlib.util.
closest_to_ref
(arrays, ref, cutoff=1e-12)[source]¶ Parameters: - arrays – a sequence of arrays
- ref – the reference array
Returns: a list of indices ordered by closeness
This function is used to extract the realization closest to the mean in disaggregation. For instance, if there are 2 realizations with indices 0 and 1, the first hazard curve having values
>>> c0 = numpy.array([.99, .97, .5, .1])
and the second hazard curve having values
>>> c1 = numpy.array([.98, .96, .45, .09])
with weights 0.6 and 0.4 and mean
>>> mean = numpy.average([c0, c1], axis=0, weights=[0.6, 0.4])
then calling
closest_to_ref
will returns the indices 0 and 1 respectively:>>> closest_to_ref([c0, c1], mean) [0, 1]
This means that the realization 0 is the closest to the mean, as expected, since it has a larger weight. You can check that it is indeed true by computing the sum of the quadratic deviations:
>>> ((c0 - mean)**2).sum() 0.0004480000000000008 >>> ((c1 - mean)**2).sum() 0.0010079999999999985
If the 2 realizations have equal weights the distance from the mean will be the same. In that case both the realizations will be okay; the one that will be chosen by
closest_to_ref
depends on the magic of floating point approximation (theoretically identical distances will likely be different as numpy.float64 numbers) or on the magic of Pythonlist.sort
.
-
openquake.commonlib.util.
compose_arrays
(a1, a2, firstfield='etag')[source]¶ Compose composite arrays by generating an extended datatype containing all the fields. The two arrays must have the same length.
-
openquake.commonlib.util.
get_assets
(dstore)[source]¶ Parameters: dstore – a datastore with keys ‘assetcol’ Returns: an array of records (id, tag1, …, tagN, lon, lat)
-
openquake.commonlib.util.
log
(array, cutoff)[source]¶ Compute the logarithm of an array with a cutoff on the small values
-
openquake.commonlib.util.
max_rel_diff
(curve_ref, curve, min_value=0.01)[source]¶ Compute the maximum relative difference between two curves. Only values greather or equal than the min_value are considered.
>>> curve_ref = [0.01, 0.02, 0.03, 0.05, 1.0] >>> curve = [0.011, 0.021, 0.031, 0.051, 1.0] >>> round(max_rel_diff(curve_ref, curve), 2) 0.1
-
openquake.commonlib.util.
max_rel_diff_index
(curve_ref, curve, min_value=0.01)[source]¶ Compute the maximum relative difference between two sets of curves. Only values greather or equal than the min_value are considered. Return both the maximum difference and its location (array index).
>>> curve_refs = [[0.01, 0.02, 0.03, 0.05], [0.01, 0.02, 0.04, 0.06]] >>> curves = [[0.011, 0.021, 0.031, 0.051], [0.012, 0.022, 0.032, 0.051]] >>> max_rel_diff_index(curve_refs, curves) (0.2, 1)
-
openquake.commonlib.util.
read
(calc_id, username=None)[source]¶ Parameters: - calc_id – a calculation ID
- username – if given, restrict the search to the user’s calculations
Returns: the associated DataStore instance
-
openquake.commonlib.util.
rmsep
(array_ref, array, min_value=0)[source]¶ Root Mean Square Error Percentage for two arrays.
Parameters: - array_ref – reference array
- array – another array
- min_value – compare only the elements larger than min_value
Returns: the relative distance between the arrays
>>> curve_ref = numpy.array([[0.01, 0.02, 0.03, 0.05], ... [0.01, 0.02, 0.04, 0.06]]) >>> curve = numpy.array([[0.011, 0.021, 0.031, 0.051], ... [0.012, 0.022, 0.032, 0.051]]) >>> str(round(rmsep(curve_ref, curve, .01), 5)) '0.11292'
Returns: True if a shared_dir has been set in openquake.cfg, else False
writers module¶
-
class
openquake.commonlib.writers.
CsvWriter
(sep=', ', fmt='%12.8E')[source]¶ Bases:
object
Class used in the exporters to save a bunch of CSV files
-
save
(data, fname, header=(), comment=None, renamedict=None)[source]¶ Save data on fname.
Parameters: - data – numpy array, list of lists or pandas DataFrame
- fname – path name
- header – header to use
- comment – optional dictionary to be converted in a comment
- renamedict – a dictionary for renaming the columns
-
-
openquake.commonlib.writers.
build_header
(dtype)[source]¶ Convert a numpy nested dtype into a list of strings suitable as header of csv file.
>>> imt_dt = numpy.dtype([('PGA', numpy.float32, 3), ... ('PGV', numpy.float32, 4)]) >>> build_header(imt_dt) ['PGA:3', 'PGV:4'] >>> gmf_dt = numpy.dtype([('A', imt_dt), ('B', imt_dt), ... ('idx', numpy.uint32)]) >>> build_header(gmf_dt) ['A~PGA:3', 'A~PGV:4', 'B~PGA:3', 'B~PGV:4', 'idx']
-
openquake.commonlib.writers.
castable_to_int
(s)[source]¶ Return True if the string s can be interpreted as an integer
-
openquake.commonlib.writers.
extract_from
(data, fields)[source]¶ Extract data from numpy arrays with nested records.
>>> imt_dt = numpy.dtype([('PGA', float, 3), ('PGV', float, 4)]) >>> a = numpy.array([([1, 2, 3], [4, 5, 6, 7])], imt_dt) >>> extract_from(a, ['PGA']) array([[1., 2., 3.]])
>>> gmf_dt = numpy.dtype([('A', imt_dt), ('B', imt_dt), ... ('idx', numpy.uint32)]) >>> b = numpy.array([(([1, 2, 3], [4, 5, 6, 7]), ... ([1, 2, 4], [3, 5, 6, 7]), 8)], gmf_dt) >>> extract_from(b, ['idx']) array([8], dtype=uint32) >>> extract_from(b, ['B', 'PGV']) array([[3., 5., 6., 7.]])
-
openquake.commonlib.writers.
parse_header
(header)[source]¶ Convert a list of the form [‘fieldname:fieldtype:fieldsize’,…] into a numpy composite dtype. The parser understands headers generated by
openquake.commonlib.writers.build_header()
. Here is an example:>>> parse_header(['PGA:float32', 'PGV', 'avg:float32:2']) (['PGA', 'PGV', 'avg'], dtype([('PGA', '<f4'), ('PGV', '<f4'), ('avg', '<f4', (2,))]))
Params header: a list of type descriptions Returns: column names and the corresponding composite dtype
-
openquake.commonlib.writers.
write_csv
(dest, data, sep=', ', fmt='%.6E', header=(), comment=None, renamedict=None)[source]¶ Parameters: - dest – None, file, filename or io.StringIO instance
- data – array to save
- sep – separator to use (default comma)
- fmt – formatting string (default ‘%12.8E’)
- header – optional list with the names of the columns to display
- comment – optional comment dictionary