base_functions
base_functions
¶
This module provides basic functions for parsing intensity measure type strings and probability-rate conversions.
calculate_hazard_at_poe(poe: float, imtls: npt.NDArray, poes: npt.NDArray) -> float
¶
Calculate the hazard at a given probability of exceedance using interpolation.
A hazard curve and a desired probablity at which to calculate hazard are provided. No conversion of time is performed (e.g. if the hazard curve is in annual PoE, the desired poe must also be annual), use the convert_poe function to convert probabilty investigation times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poe
|
float
|
The probability of exceedance at which to calculate hazard. |
required |
imtls
|
npt.NDArray
|
The shaking values of the hazard curve. |
required |
poes
|
npt.NDArray
|
The probability values of the hazard curve. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The hazard (shaking value) at the desired probablity of exceedance. |
convert_poe(poe_in: float, inv_time_in: float, inv_time_out: float) -> float
¶
Convert probablity of exceedance from one investigation time to another.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poe_in
|
float
|
Origional probability of exceedance. |
required |
inv_time_in
|
float
|
Origional investigation time. |
required |
inv_time_out
|
float
|
Desired investigation time. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The probability of exceedance for inv_time_out. |
imt_from_period(period: float, imt_type: Literal['acc', 'vel', 'disp']) -> str
¶
Convert shaking period to an intensity measure type string.
Valid values of the IMT type are "acc", "vel", and "disp".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period
|
float
|
The shaking period in seconds. |
required |
imt_type
|
Literal['acc', 'vel', 'disp']
|
The type of intensity measure ("acc", "vel", "disp"). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The intensity measure type string. |
period_from_imt(imt: str) -> float
¶
Convert intensity measure type string to a time period.
Peak values (e.g. "PGA", "PGV") are converted to 0 seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
imt
|
str
|
The intensity measure type (e.g. "PGA", "SA(1.0)", "SD(5.0)"). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The period in seconds. |
poe_from_rp(rp: float, inv_time: float) -> float
¶
Convert a return period to a propability of exceedance using the Poison probablity function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rp
|
float
|
Return period. |
required |
inv_time
|
float
|
Inverstigation time. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Fractional probability of exceedance. |
Example
To find the probability of exceedance in 50 years for a return period of 500 years
>>> poe_from_rp(500.0, 50.0)
0.09516258196404048
prob_to_rate(prob: npt.NDArray, inv_time: float) -> npt.NDArray
¶
Convert probability of exceedance to rate assuming Poisson distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prob
|
npt.NDArray
|
probability of exceedance |
required |
inv_time
|
float
|
time period for probability (e.g. 1.0 for annual probability) |
required |
Returns:
| Type | Description |
|---|---|
npt.NDArray
|
return rate in inv_time |
rate_to_prob(rate: npt.NDArray, inv_time: float) -> npt.NDArray
¶
Convert rate to probabiility of exceedance assuming Poisson distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rate
|
npt.NDArray
|
rate over inv_time |
required |
inv_time
|
float
|
time period of rate (e.g. 1.0 for annual rate) |
required |
Returns:
| Type | Description |
|---|---|
npt.NDArray
|
probability of exceedance in inv_time |
rp_from_poe(poe: float, inv_time: float) -> float
¶
Convert a proability of exceedance to a return period using the Poison proability function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poe
|
float
|
The fractional probability of exceedance. |
required |
inv_time
|
float
|
The investigation time. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The repeat period in the same units as inv_time (e.g. years). |
Example
To find the return period for a 10% probability of exceedance in 50 years
>>> rp_from_poe(0.1, 50)
474.56107905149526