Skip to content

Hazard Curves

These models represent aggregated hazard curves derived from OpenQuake PSHA engine outputs.

Hazard Aggregate Curve

The core model for aggregated hazard curve data, stored as PyArrow parquet datasets.

Bases: BaseModel

Generally these are aggregated realisation curves.

Attributes:

Name Type Description
compatible_calc_id str

for hazard-calc equivalence.

model_id str

the model that these curves represent.

nloc_001 str

the location string to three places e.g. "-38.330~17.550".

nloc_0 str

the location string to zero places e.g. "-38.0~17.0" (used for partitioning).

imt str

the imt label e.g. 'PGA', 'SA(5.0)'

vs30 int

the VS30 integer

aggr str

the aggregation type

values List[float]

a list of the 44 IMTL values

Source code in toshi_hazard_store/model/hazard_models_pydantic.py
 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
class HazardAggregateCurve(BaseModel):
    """Generally these are aggregated realisation curves.

    Attributes:
        compatible_calc_id: for hazard-calc equivalence.
        model_id: the model that these curves represent.
        nloc_001:  the location string to three places e.g. "-38.330~17.550".
        nloc_0:  the location string to zero places e.g.  "-38.0~17.0" (used for partitioning).
        imt: the imt label e.g. 'PGA', 'SA(5.0)'
        vs30: the VS30 integer
        aggr: the aggregation type
        values: a list of the 44 IMTL values
    """

    compatible_calc_id: str
    hazard_model_id: str
    nloc_001: str
    nloc_0: str
    imt: str
    vs30: int
    aggr: str
    values: List[float]

    @field_validator("values", mode="before")
    @classmethod
    def validate_len_values(cls, value: List) -> List:
        if not len(value) == 44:
            raise ValueError(f"expected 44 values but there are {len(value)}")
        return value

    @staticmethod
    def pyarrow_schema() -> pa.schema:
        """A pyarrow schema for aggregate hazard curve datasets.

        built dynamically from the pydantic model, using lancedb helper method.
        """

        # Convert the Pydantic model to a PyArrow schema
        arrow_schema = pydantic_to_schema(HazardAggregateCurve)
        if not USE_64BIT_VALUES:
            arrow_schema = arrow_schema.set(
                arrow_schema.get_field_index("vs30"),
                pa.lib.field("vs30", pa.int32(), nullable=False),
            )
            arrow_schema = arrow_schema.set(
                arrow_schema.get_field_index("values"),
                pa.lib.field("values", pa.list_(pa.float32()), nullable=False),
            )

        return arrow_schema

PyArrow Schema

The HazardAggregateCurve model can be converted to a PyArrow schema for dataset I/O:

from toshi_hazard_store.model.hazard_models_pydantic import HazardAggregateCurve
schema = HazardAggregateCurve.pyarrow_schema()

The schema includes:

  • compatible_calc_id (string) - Compatible calculation identifier
  • hazard_model_id (string) - Model identifier (e.g., "NSHM_v1.0.4")
  • nloc_001 (string) - Location to 3 decimal places (e.g., "-38.330~17.550")
  • nloc_0 (string) - Location to 0 decimal places (e.g., "-38.0~17.0") for partitioning
  • imt (string) - Intensity measure type (e.g., "PGA", "SA(5.0)")
  • vs30 (int32) - VS30 value
  • aggr (string) - Aggregation type (e.g., "mean", "0.9", "std")
  • values (list of float32) - 44 IMT level values

Constraint Enums

These enumerations define valid values for model fields:

Aggregation Enum

Bases: Enum

Defines the values available for aggregations.

Source code in toshi_hazard_store/model/constraints.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class AggregationEnum(Enum):
    """Defines the values available for aggregations."""

    MEAN = 'mean'
    COV = 'cov'
    STD = 'std'
    _005 = '0.005'
    _01 = '0.01'
    _025 = '0.025'
    _05 = '0.05'
    _10 = '0.1'
    _20 = '0.2'
    _30 = '0.3'
    _40 = '0.4'
    _50 = '0.5'
    _60 = '0.6'
    _70 = '0.7'
    _80 = '0.8'
    _90 = '0.9'
    _95 = '0.95'
    _975 = '0.975'
    _99 = '0.99'
    _995 = '0.995'

Intensity Measure Type Enum

Bases: Enum

Defines the values available for IMTs.

Source code in toshi_hazard_store/model/constraints.py
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
class IntensityMeasureTypeEnum(Enum):
    """
    Defines the values available for IMTs.
    """

    PGA = 'PGA'
    SA_0_1 = 'SA(0.1)'
    SA_0_15 = 'SA(0.15)'
    SA_0_2 = 'SA(0.2)'
    SA_0_25 = 'SA(0.25)'
    SA_0_3 = 'SA(0.3)'
    SA_0_35 = 'SA(0.35)'
    SA_0_4 = 'SA(0.4)'
    SA_0_5 = 'SA(0.5)'
    SA_0_6 = 'SA(0.6)'
    SA_0_7 = 'SA(0.7)'
    SA_0_8 = 'SA(0.8)'
    SA_0_9 = 'SA(0.9)'
    SA_1_0 = 'SA(1.0)'
    SA_1_25 = 'SA(1.25)'
    SA_1_5 = 'SA(1.5)'
    SA_1_75 = 'SA(1.75)'
    SA_2_0 = 'SA(2.0)'
    SA_2_5 = 'SA(2.5)'
    SA_3_0 = 'SA(3.0)'
    SA_3_5 = 'SA(3.5)'
    SA_4_0 = 'SA(4.0)'
    SA_4_5 = 'SA(4.5)'
    SA_5_0 = 'SA(5.0)'
    SA_6_0 = 'SA(6.0)'
    SA_7_5 = 'SA(7.5)'
    SA_10_0 = 'SA(10.0)'

VS30 Enum

Bases: Enum

Defines the values available for VS30.

Source code in toshi_hazard_store/model/constraints.py
 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
class VS30Enum(Enum):
    """
    Defines the values available for VS30.
    """

    _0 = 0  # indicates that this value is not used
    _150 = 150
    _175 = 175
    _200 = 200
    _225 = 225
    _250 = 250
    _275 = 275
    _300 = 300
    _350 = 350
    _375 = 375
    _400 = 400
    _450 = 450
    _500 = 500
    _525 = 525
    _550 = 550
    _600 = 600
    _650 = 650
    _700 = 700
    _750 = 750
    _800 = 800
    _850 = 850
    _900 = 900
    _950 = 950
    _1000 = 1000
    _1050 = 1050
    _1100 = 1100
    _1500 = 1500

Probability Enum

Bases: Enum

Defines the values available for probabilities.

store values as float representing probability in 1 year

Source code in toshi_hazard_store/model/constraints.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class ProbabilityEnum(Enum):
    """
    Defines the values available for probabilities.

    store values as float representing probability in 1 year
    """

    _86_PCT_IN_50YRS = 3.8559e-02
    _63_PCT_IN_50YRS = 1.9689e-02
    _39_PCT_IN_50YRS = 9.8372e-03
    _18_PCT_IN_50YRS = 3.9612e-03
    _10_PCT_IN_50YRS = 2.1050e-03
    _5_PCT_IN_50YRS = 1.0253e-03
    _2_PCT_IN_50YRS = 4.0397e-04
    _1_PCT_IN_50YRS = 2.0099e-04
    _05_PCT_IN_50YRS = 1.0025e-04