Skip to content

dataframe_models

dataframe_models

This module defines the dataframes returned by solvis.

  • We use the panderas library to define the dataframe schemas and solvis testing validates that dataframes have the expected columns names and types.
  • currenty schema attributes are NOT the actual dataframe column names, For these see the code and the `Field(alias={column_name}) value. See below...
  • refactoring of column names is expected in a future release, but legacy column names will be supported.

Fault models

FaultSectionSchemaBase

Bases: pda.DataFrameModel

A base schema for common dataframe columns.

This is not used directly, but is reused in other schema.

Attributes:

Name Type Description
section_id Series[pd.Int32Dtype]

unique section id.

section_name Series[str]

the fault section name.

dip_angle Series[pd.Float64Dtype]

dip angle of the section (degrees).

rake Series[pd.Float64Dtype]

rake angle of the section (degrees).

lower_depth Series[pd.Float64Dtype]

lower section depth (meters).

upper_depth Series[pd.Float64Dtype]

upper section depth (meters).

aseismic_slip_factor Series[pd.Float64Dtype]

ratio of slip that is considered aseismic.

coupling_coefficient Series[pd.Float64Dtype]

coupling coefficient.

parent_fault_id Series[pd.Int32Dtype]

unique id of th parent fault.

parent_fault_name Series[str]

unique name of ther parent fault.

dip_direction Series[pd.Float64Dtype]

dip direciton (degrees).

geometry Series[geometry]

A set of coordinates defining the section surface trace.

target_slip_rate Series[pd.Float64Dtype]

the target slip reate used in the grand inversion.

target_slip_rate_stddev Series[pd.Float64Dtype]

the target slip rate stddev used in the grand inversion.

Source code in solvis/solution/dataframe_models.py
 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
class FaultSectionSchemaBase(pda.DataFrameModel):
    """A base schema for common dataframe columns.

    This is not used directly, but is reused in other schema.

    Attributes:
        section_id: unique section id.
        section_name: the fault section name.
        dip_angle: dip angle of the section (degrees).
        rake: rake angle of the section (degrees).
        lower_depth: lower section depth (meters).
        upper_depth: upper section depth (meters).
        aseismic_slip_factor: ratio of slip that is considered aseismic.
        coupling_coefficient: coupling coefficient.
        parent_fault_id: unique id of th parent fault.
        parent_fault_name: unique name of ther parent fault.
        dip_direction: dip direciton (degrees).
        geometry: A set of coordinates defining the section surface trace.
        target_slip_rate: the target slip reate used in the grand inversion.
        target_slip_rate_stddev: the target slip rate stddev used in the grand inversion.
    """

    section_id: Series[pd.Int32Dtype] = pda.Field(alias='FaultID')
    section_name: Series[str] = pda.Field(alias='FaultName')
    dip_angle: Series[pd.Float64Dtype] = pda.Field(alias='DipDeg')
    rake: Series[pd.Float64Dtype] = pda.Field(alias='Rake')
    lower_depth: Series[pd.Float64Dtype] = pda.Field(alias='LowDepth')
    upper_depth: Series[pd.Float64Dtype] = pda.Field(alias='UpDepth')
    aseismic_slip_factor: Series[pd.Float64Dtype] = pda.Field(alias='AseismicSlipFactor')
    coupling_coefficient: Series[pd.Float64Dtype] = pda.Field(alias='CouplingCoeff')
    parent_fault_id: Series[pd.Int32Dtype] = pda.Field(alias='ParentID')
    parent_fault_name: Series[str] = pda.Field(alias='ParentName')
    dip_direction: Series[pd.Float64Dtype] = pda.Field(alias='DipDir')
    geometry: Series['geometry']
    target_slip_rate: Series[pd.Float64Dtype] = pda.Field(alias='Target Slip Rate')
    target_slip_rate_stddev: Series[pd.Float64Dtype] = pda.Field(alias='Target Slip Rate StdDev')

FaultSectionSchema

Bases: FaultSectionSchemaBase

A Dataframe schema for fault_section.

Notes
  • this just adds an index to the base class FaultSectionSchema.

Attributes:

Name Type Description
index Index[pd.Int64Dtype]

on section id.

Source code in solvis/solution/dataframe_models.py
103
104
105
106
107
108
109
110
111
112
113
114
115
116
class FaultSectionSchema(FaultSectionSchemaBase):
    """A Dataframe schema for `fault_section`.

    Notes:
     - this just adds an index to the base class FaultSectionSchema.

    Attributes:
        index: on section id.
    """

    class Config:
        strict = True

    index: Index[pd.Int64Dtype] = pda.Field(alias='section_id')

FaultSectionWithSolutionSlipRate

Bases: FaultSectionSchemaBase

A Dataframe schema for fault_sections_with_solution_slip_rates.

Notes
  • this just adds an index and one column to the base class FaultSectionSchema.

Attributes:

Name Type Description
index Index[pd.Int64Dtype]

on section id.

solution_slip_rate Series[pd.Float64Dtype]

the slip rate calculated in the Opensha grand inversion.

Source code in solvis/solution/dataframe_models.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
class FaultSectionWithSolutionSlipRate(FaultSectionSchemaBase):
    """A Dataframe schema for `fault_sections_with_solution_slip_rates`.

    Notes:
     - this just adds an index and one column to the base class FaultSectionSchema.

    Attributes:
        index: on section id.
        solution_slip_rate: the slip rate calculated in the Opensha grand inversion.
    """

    class Config:
        strict = True

    index: Index[pd.Int64Dtype] = pda.Field(alias='section_id')
    solution_slip_rate: Series[pd.Float64Dtype] = pda.Field(alias='Solution Slip Rate')

FaultSectionRuptureRateSchema

Bases: FaultSectionSchemaBase

A Dataframe schema for fault_sections_with_rupture_rates.

This table joins each permutation of rupture_id and section_id with their aggregated rates across all the inversion solution branches.

Todo
  • why is this schema used in inversion_solution_file, shouldn't it exclusivly on fault_system_solution ??

Attributes:

Name Type Description
fault_system_idx Index[pd.CategoricalDtype]

index on fault system

section_idx Index[pd.Int64Dtype]

index on section id.

rupture Index[pd.Int64Dtype]

the rupture id.

section Series[pd.Int32Dtype]

the fault_section id.

key_0 Series[pd.UInt32Dtype]

Todo: drop this please!!

fault_system Series[str]

fault system short code eg 'CRU'

rupture_id Series[pd.UInt32Dtype]

the id of each rupture

rate_count Series[pd.Int64Dtype]

count of aggregate ruptures with rate.

rate_max Series[pd.Float32Dtype]

max rate of aggregate ruptures with rate.

rate_min Series[pd.Float32Dtype]

min rate of aggregate ruptures with rate.

rate_weighted_mean Series[pd.Float32Dtype]

rate weighted mean of aggregate ruptures with rate.

magnitude Series[pd.Float32Dtype]

the rupture magnitude.

mean_rake Series[pd.Float32Dtype]

the mean rake angle of the ruptures fault sections (degrees).

area Series[pd.Float32Dtype]

rupture area (meters^2).

length Series[pd.Float32Dtype]

rupture length (meters).

section Series[pd.Int32Dtype]

Series[pd.Int32Dtype]

Note

remaining attributes are inherited from FaultSectionSchemaBase

Source code in solvis/solution/dataframe_models.py
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
class FaultSectionRuptureRateSchema(FaultSectionSchemaBase):
    """A Dataframe schema for `fault_sections_with_rupture_rates`.

    This table joins each permutation of rupture_id and section_id
    with their aggregated rates across all the inversion solution branches.

    Todo:
     - why is this schema used in inversion_solution_file, shouldn't it exclusivly on fault_system_solution ??

    Attributes:
     fault_system_idx: index on fault system
     section_idx: index on section id.

     rupture: the rupture id.
     section: the fault_section id.
     key_0: Todo: drop this please!!

     fault_system: fault system short code eg 'CRU'
     rupture_id: the id of each rupture
     rate_count: count of aggregate ruptures with rate.
     rate_max: max rate of aggregate ruptures with rate.
     rate_min: min rate of aggregate ruptures with rate.
     rate_weighted_mean: rate weighted mean of aggregate ruptures with rate.
     magnitude: the rupture magnitude.
     mean_rake: the mean rake angle of the ruptures fault sections (degrees).
     area: rupture area (meters^2).
     length: rupture length (meters).
     section: Series[pd.Int32Dtype]

    Note:
     remaining attributes are inherited from FaultSectionSchemaBase
    """

    class Config:
        strict = True
        # provide multi index options in the config
        multiindex_name = "fault_system_fault_section_index"
        multiindex_strict = True
        multiindex_coerce = True

    fault_system_idx: Index[pd.CategoricalDtype] = pda.Field(alias='fault_system', coerce=True)
    section_idx: Index[pd.Int64Dtype] = pda.Field(alias='Rupture Index', coerce=True)

    key_0: Series[pd.UInt32Dtype]
    fault_system: Series['str']
    rupture_id: Series[pd.UInt32Dtype] = pda.Field(alias='Rupture Index')
    rate_count: Series[pd.Int64Dtype]
    rate_max: Series[pd.Float32Dtype]
    rate_min: Series[pd.Float32Dtype]
    rate_weighted_mean: Series[pd.Float32Dtype]
    magnitude: Series[pd.Float32Dtype] = pda.Field(alias='Magnitude')
    mean_rake: Series[pd.Float32Dtype] = pda.Field(alias='Average Rake (degrees)')
    area: Series[pd.Float32Dtype] = pda.Field(alias='Area (m^2)')
    length: Series[pd.Float32Dtype] = pda.Field(alias='Length (m)')
    section: Series[pd.Int32Dtype]

Rupture models

RuptureBaseSchema

Bases: pda.DataFrameModel

A Dataframe schema base.

Attributes:

Name Type Description
magnitude Series[pd.Float32Dtype]

the rupture magnitude.

mean_rake Series[pd.Float32Dtype]

the mean rake angle of the ruptures' fault sections (degrees).

area Series[pd.Float32Dtype]

rupture area (meters^2).

length Series[pd.Float32Dtype]

rupture length (meters).

Source code in solvis/solution/dataframe_models.py
213
214
215
216
217
218
219
220
221
222
223
224
225
226
class RuptureBaseSchema(pda.DataFrameModel):
    """A Dataframe schema base.

    Attributes:
     magnitude: the rupture magnitude.
     mean_rake: the mean rake angle of the ruptures' fault sections (degrees).
     area: rupture area (meters^2).
     length: rupture length (meters).
    """

    magnitude: Series[pd.Float32Dtype] = pda.Field(alias='Magnitude')
    mean_rake: Series[pd.Float32Dtype] = pda.Field(alias='Average Rake (degrees)')
    area: Series[pd.Float32Dtype] = pda.Field(alias='Area (m^2)')
    length: Series[pd.Float32Dtype] = pda.Field(alias='Length (m)')

RuptureRateSchema

Bases: pda.DataFrameModel

A Dataframe schema for InversionSolutionFile.rupture_rates.

Attributes:

Name Type Description
index Index[pd.Int64Dtype]

unique index on rupture_id.

rupture_id Series[pd.UInt32Dtype]

the id of each rupture

annual_rate Series[pd.Float32Dtype]

the rupture rate

Source code in solvis/solution/dataframe_models.py
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
class RuptureRateSchema(pda.DataFrameModel):
    """A Dataframe schema for `InversionSolutionFile.rupture_rates`.

    Attributes:
     index: unique index on rupture_id.
     rupture_id: the id of each rupture
     annual_rate: the rupture rate
    """

    class Config:
        strict = True

    index: Index[pd.Int64Dtype]
    rupture_id: Series[pd.UInt32Dtype] = pda.Field(alias='Rupture Index')
    annual_rate: Series[pd.Float32Dtype] = pda.Field(alias='Annual Rate')

RuptureSectionSchema

Bases: pda.DataFrameModel

A Dataframe schema for rupture_section.

This is a join table iterating all permutations of rupture_id and section_id.

Attributes:

Name Type Description
index Index[pd.Int64Dtype]

unique index.

rupture_id Series[pd.Int64Dtype]

the id of each rupture

section_id Series[pd.Int32Dtype]

the id of each fault_section

Source code in solvis/solution/dataframe_models.py
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
class RuptureSectionSchema(pda.DataFrameModel):
    """A Dataframe schema for `rupture_section`.

    This is a `join` table iterating all permutations of rupture_id and section_id.

    Attributes:
     index: unique index.
     rupture_id: the id of each rupture
     section_id: the id of each fault_section
    """

    class Config:
        strict = True

    index: Index[pd.Int64Dtype]
    rupture_id: Series[pd.Int64Dtype] = pda.Field(alias='rupture')
    section_id: Series[pd.Int32Dtype] = pda.Field(alias='section')

RupturesWithRuptureRatesSchema

Bases: RuptureBaseSchema

A Dataframe schema for InversionSolution.ruptures_with_rupture_rates.

Attributes:

Name Type Description
index Index[pd.Int64Dtype]

integer id.

rupture_id Series[pd.UInt32Dtype]

same as index.

annual_rate Series[pd.Float32Dtype]

annual rupture rate.

magnitude Series[pd.Float32Dtype]

the rupture magnitude.

mean_rake Series[pd.Float32Dtype]

the mean rake angle of the ruptures' fault sections (degrees).

area Series[pd.Float32Dtype]

rupture area (meters^2).

length Series[pd.Float32Dtype]

rupture length (meters).

Source code in solvis/solution/dataframe_models.py
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
class RupturesWithRuptureRatesSchema(RuptureBaseSchema):
    """A Dataframe schema for `InversionSolution.ruptures_with_rupture_rates`.

    Attributes:
     index: integer id.
     rupture_id: same as index.
     annual_rate: annual rupture rate.
     magnitude: the rupture magnitude.
     mean_rake: the mean rake angle of the ruptures' fault sections (degrees).
     area: rupture area (meters^2).
     length: rupture length (meters).
    """

    class Config:
        strict = True

    index: Index[pd.Int64Dtype]
    rupture_id: Series[pd.UInt32Dtype] = pda.Field(alias='Rupture Index')
    annual_rate: Series[pd.Float32Dtype] = pda.Field(alias='Annual Rate')

RuptureSectionsWithRuptureRatesSchema

Bases: RuptureBaseSchema

A Dataframe schema for InversionSolution.rs_with_rupture_rates.

Source code in solvis/solution/dataframe_models.py
270
271
272
273
274
275
276
277
278
279
280
281
class RuptureSectionsWithRuptureRatesSchema(RuptureBaseSchema):
    """A Dataframe schema for `InversionSolution.rs_with_rupture_rates`."""

    class Config:
        strict = True

    # index: Index[pd.Int64Dtype]

    key_0: Series[pd.UInt32Dtype]
    rupture_id: Series[pd.UInt32Dtype] = pda.Field(alias='Rupture Index')
    section_id: Series[pd.Int32Dtype] = pda.Field(alias='section')
    annual_rate: Series[pd.Float32Dtype] = pda.Field(alias='Annual Rate')

Participation models

SectionParticipationSchema

Bases: pda.DataFrameModel

A Dataframe schema for section_participation_rate.

Attributes:

Name Type Description
section Index[pd.Int32Dtype]

unique index on section_id.

participation_rate Series[pd.Float32Dtype]

sum of the ruptures involving each fault section.

Source code in solvis/solution/dataframe_models.py
20
21
22
23
24
25
26
27
28
29
30
31
32
class SectionParticipationSchema(pda.DataFrameModel):
    """A Dataframe schema for `section_participation_rate`.

    Attributes:
        section: unique index on section_id.
        participation_rate: sum of the ruptures involving each fault section.
    """

    class Config:
        strict = True

    section: Index[pd.Int32Dtype]
    participation_rate: Series[pd.Float32Dtype]

ParentFaultParticipationSchema

Bases: pda.DataFrameModel

A Dataframe schema for fault_participation_rate.

Attributes:

Name Type Description
parent_fault_id Index[pd.Int32Dtype]

unique index on parent fault id.

participation_rate Series[pd.Float32Dtype]

sum of the ruptures involving each parent fault.

Source code in solvis/solution/dataframe_models.py
35
36
37
38
39
40
41
42
43
44
45
46
47
class ParentFaultParticipationSchema(pda.DataFrameModel):
    """A Dataframe schema for `fault_participation_rate`.

    Attributes:
        parent_fault_id: unique index on parent fault id.
        participation_rate: sum of the ruptures involving each parent fault.
    """

    class Config:
        strict = True

    parent_fault_id: Index[pd.Int32Dtype] = pda.Field(alias='ParentID')
    participation_rate: Series[pd.Float32Dtype]