data
Functions for loading realizations and saving aggregations.
get_batch_table(dataset, compatibility_key, sources_digests, gmms_digests, vs30, nloc_0, imts)
¶
Get the realization datatable for a batch of aggregation jobs.
Filtering is done for comatibility key, branch digests, vs30, nloc_0, and (multiple) imts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
the realization dataset. |
required |
compatibility_key
|
str
|
the toshi-hazard-store compatibility key. |
required |
sources_digests
|
list[str]
|
the digests of the source branches. |
required |
gmms_digests
|
list[str]
|
the digests of the gmcm branches. |
required |
vs30
|
int
|
the vs30 of the sites. |
required |
nloc_0
|
str
|
the nloc_0 (1.0 degree location code). |
required |
imts
|
list[str]
|
the intensity measure types. |
required |
Returns:
Type | Description |
---|---|
Table
|
The filtered datatable. |
Source code in toshi_hazard_post/data.py
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 |
|
get_job_datatable(batch_datatable, location, imt, n_expected)
¶
Get the realization datatable for a specific aggregation job (one IMT, location, etc.).
The batch_datatable is expected to be produced by get_batch_table which will have applied broader filters on the dataset for vs30, nloc_0, etc.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_datatable
|
Table
|
the pre-filtered datatable to be further filtered for a specific aggregation job. |
required |
location
|
CodedLocation
|
the location of the site. |
required |
imt
|
str
|
the intensity measure type. |
required |
n_expected
|
int
|
the number of records expected (typically the number of branches). |
required |
Returns:
Type | Description |
---|---|
Table
|
The filtered data table. |
Source code in toshi_hazard_post/data.py
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 |
|
get_realizations_dataset(vs30=None, nloc_0=None, rlz_dir=None)
¶
Get a pyarrow Dataset for realizations.
Optional parameters take advantage of partitioning of dataset for faster retrieval. The partitioning is assumed to be vs30/nloc_0. See toshi-hazard-store documentation for details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vs30
|
Optional[int]
|
the site vs30 |
None
|
nloc_0
|
Optional[str]
|
the 1 degree grid location (e.g. '-41.0~175.0') |
None
|
rlz_dir
|
Optional[str | Path]
|
location of realization dataset. If not passed, function will use env var. |
None
|
Returns:
Name | Type | Description |
---|---|---|
dataset |
Dataset
|
the relization dataset |
Source code in toshi_hazard_post/data.py
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 |
|
save_aggregations(hazard, location, vs30, imt, agg_types, hazard_model_id, compatibility_key)
¶
Save the aggregated hazard to the database.
Converts hazard as rates to proabilities before saving.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hazard
|
NDArray
|
the aggregate hazard rates (not proabilities) |
required |
location
|
CodedLocation
|
the site location |
required |
vs30
|
int
|
the site vs30 |
required |
imt
|
str
|
the intensity measure type (e.g. "PGA", "SA(1.5)") |
required |
agg_types
|
list[str]
|
the statistical aggregate types (e.g. "mean", "0.5") |
required |
hazard_model_id
|
str
|
the model id for storing in the database |
required |
compatibility_key
|
str
|
the toshi-hazard-store compatibility key. |
required |
Source code in toshi_hazard_post/data.py
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 |
|