NshmModel (class)
NshmModel(version, title, source_logic_tree, gmcm_logic_tree, hazard_config)
¶
Bases: Generic[HazardConfigType]
An NshmModel instance represents a complete National Seismic Hazard Model version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version
|
str
|
Describes version of the model being developed / used. |
required |
tite
|
A title for the model. |
required | |
source_logic_tree
|
SourceLogicTree
|
The seismicity rate model (SRM) logic tree. |
required |
gmcm_logic_tree
|
GMCMLogicTree
|
The ground motion characterization model (GMCM) logic tree. |
required |
hazard_config
|
HazardConfig
|
The hazard engine (calculator) configuration. |
required |
Source code in nzshm_model/model.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
from_files(version, title, slt_json, gmm_json, hazard_config_json)
classmethod
¶
Create a new NshmModel instance from files.
NB library users will typically never use this, rather they will obtain a model instance
using static method: get_model_version
.
Source code in nzshm_model/model.py
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 |
|
get_model_version(version)
classmethod
¶
Retrieve an existing model by its specific version
Examples:
>>> from nzshm_model import NshmModel
>>> model = NshmModel.get_model_version("NSHM_v1.0.4")
>>> print(model.title)
>>>
NSHM version 1.0.4, corrected fault geometry
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version
|
str
|
The unique identifier for the model version. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when the version does not exist. |
Returns:
Type | Description |
---|---|
NshmModel
|
the model instance. |
Source code in nzshm_model/model.py
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 |
|
get_source_branch_sets(short_names=None)
¶
get an iterator for the SourceBranchSets matching the specified branch set(s)
Examples:
>>> model = get_model_version("NSHM_v1.0.4")
>>> for branch_set in model.get_source_branch_sets(['CRU', 'PUY']):
print(branch_set.short_name, len(branch_set.branches))
>>>
CRU 36
PUY 3
Parameters:
Name | Type | Description | Default |
---|---|---|---|
short_names
|
Union[List[str], str, None]
|
list of short_names for branch_set(s) (eg. 'HIK', 'CRU', 'PUY', 'SLAB') |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
when a branch short_name is not found. |
Yields:
Type | Description |
---|---|
SourceBranchSet
|
iterator of branch_set objects |
Source code in nzshm_model/model.py
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 |
|
psha_adapter(provider, **kwargs)
¶
get a PSHA adapter for this instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider
|
Type[ModelPshaAdapterInterface]
|
the adapter class |
required |
**kwargs
|
Optional[Dict]
|
additional arguments required by the provider class |
{}
|
Returns:
Type | Description |
---|---|
ModelPshaAdapterInterface
|
a PSHA Adapter instance |
Source code in nzshm_model/model.py
171 172 173 174 175 176 177 178 179 180 181 182 183 |
|