djura.hazard_consistency

Hazard-consistent intensity measure analysis.

class djura.hazard_consistency.hazard_consistency.HazardConsistency(conditional_intensities, conditional_rps=None, conditional_mafes=None, conditional_poes=None, conditional_apoes=None, investigation_time=50)[source]

Bases: object

check(rs_imi_intensities, num_im=500)[source]

Check hazard consistency

Parameters:
  • rs_imi_intensities (List) – Intensity measure values of the ground motions with the shape = (number of intensity levels, number of ground motions)

  • num_im (int) – Number of intensity measures, by default 500

Returns:

poe_envelope: Envelope of each POE im_range: Intensity range

Return type:

tuple[ndarray, ndarray, float]

class djura.hazard_consistency.hazard_model.HazardModel(method='analytical-sac-fema')[source]

Bases: object

read_hazard(filename)[source]

Reads provided hazard data

Parameters:

filename (Union[Path, str])

Returns:

data

s: list

intensity measure values in [g]

poe: list

Probability of exceedance (PoE)

Return type:

dict

fit_hazard_model(s, mafe, iterator=None, dbe=475.0, mce=10000.0)[source]

Runs the fitting function

Parameters:
  • s (List) – intensity measure values in [g]

  • mafe (List) – Mean annual frequency of exceeding an IM value (MAFE)

  • iterator (List[int]) – List of 3 integer values where the fitting will be prioritized Necessary only for method=”analytical-sac-fema”

  • dbe (float) – First return period Only for haz_fit=’power-law’

  • mce (float) – Second return period Only for haz_fit=’power-law’

Returns:

sList

Original IM range

mafeList

Original MAFE

s_fitList

Fitted IM range

mafe_fitList

Fitted MAFE

coefList[float]
if method is ‘analytical’:

Fitting coefficients [H_asy, s_asy, alpha]

if method is ‘power-law’:

SAC/FEMA-compatible coefficients, [k0, k1]

else:

SAC/FEMA-compatible coefficients, [k0, k1, k2]

methodstr

Fitting method name

Return type:

HazardModelSchema

get_return_period(poe=None, apoe=None, mafe=None, investigation_time=50.0)[source]

Get Return Period

Parameters:
  • poe (float) – Probability of exceedance (POE), by default None

  • apoe (float) – Annual probability of exceedance (APOE), by default None

  • mafe (float) – Mean annual frequency of exceeding (MAFE) an IM value, by default None

  • investigation_time (float) – Investigation time in years, by default 50

Returns:

Return period

Return type:

float

Raises:

ValueError – Must provide one of the following input arguments: poe, apoe, mafe

get_poe(return_period=None, apoe=None, mafe=None, investigation_time=50.0)[source]

Get probability of exceedance (POE)

Parameters:
  • return_period (float) – Return period, by default None

  • apoe (float) – Annual probability of exceedance (APOE), by default None

  • mafe (float) – Mean annual frequency of exceeding (MAFE) an IM value, by default None

  • investigation_time (float) – Investigation time in years, by default 50

Returns:

Probability of exceedance (POE)

Return type:

float

Raises:

ValueError – Must provide one of the following input arguments: return_period, apoe, mafe

get_apoe(return_period=None, poe=None, mafe=None, investigation_time=50.0)[source]

Get annual probability of exceedance (APOE)

Parameters:
  • return_period (float) – Return period, by default None

  • poe (float) – Probability of exceedance (POE), by default None

  • mafe (float) – Mean annual frequency of exceeding (MAFE) an IM value, by default None

  • investigation_time (float) – Investigation time in years, by default 50

Returns:

Annual probability of exceedance (APOE)

Return type:

float

Raises:

ValueError – Must provide one of the following input arguments: return_period, poe, mafe

get_mafe(return_period=None, poe=None, apoe=None, investigation_time=50.0)[source]

Get mean annual frequency (rate) of exceeding (MAFE) an IM value

Parameters:
  • return_period (float) – Return period, by default None

  • poe (float) – Probability of exceedance (POE), by default None

  • apoe (float) – Annual probability of exceedance (APOE), by default None

  • investigation_time (float) – Investigation time in years, by default 50

Returns:

Mean annual frequency of exceeding (MAFE) an IM value

Return type:

float

Raises:

ValueError – Must provide one of the following input arguments: return_period, apoe, poe

get_mafe_limit_state(k0, k1, k2=0.0, s=None, return_period=None, beta=0.0)[source]

Derive mean annual frequency of exceeding a limit state

Parameters:
  • k0 (float) – SAC/FEMA-compatible coefficient

  • k1 (float) – SAC/FEMA-compatible coefficient

  • k2 (float) – SAC/FEMA-compatible coefficient, by default 0.

  • s (float) – Intensity measure level, by default None

  • return_period (float) – Return period level, by default None

  • beta (float) – Aleatory uncertainty, by default 0.0

Returns:

Mean annual frequency of exceedance of a limit state

Return type:

float

Raises:

ValueError – If both ‘s’ and ‘return_period’ are None

get_im(mafe, k0, k1, k2=0.0)[source]

Get intensity measure (IM) value

Parameters:
  • mafe (float) – Mean annual frequency of exceeding (MAFE) an IM value

  • k0 (float) – SAC/FEMA-compatible coefficient

  • k1 (float) – SAC/FEMA-compatible coefficient

  • k2 (float) – SAC/FEMA-compatible coefficient, by default 0.

Returns:

intensity measure (IM)

Return type:

float

get_im_ls(mafe_ls, k0, k1, k2=0.0, beta=0.0)[source]

Get intensity measure (IM) value for Limit state

Parameters:
  • mafe (float) – Mean annual frequency of exceeding (MAFE) an IM value

  • k0 (float) – SAC/FEMA-compatible coefficient

  • k1 (float) – SAC/FEMA-compatible coefficient

  • k2 (float) – SAC/FEMA-compatible coefficient, by default 0.

Returns:

intensity measure (IM)

Return type:

float

get_beta_ls(mafe_ls, k0, k1, k2=0.0, mu=0.0)[source]

Get intensity measure (IM) value for Limit state

Parameters:
  • mafe (float) – Mean annual frequency of exceeding (MAFE) an IM value

  • k0 (float) – SAC/FEMA-compatible coefficient

  • k1 (float) – SAC/FEMA-compatible coefficient

  • k2 (float) – SAC/FEMA-compatible coefficient, by default 0.

Returns:

intensity measure (IM)

Return type:

float

djura.hazard_consistency.hazard_fit.analytical_mafe(s, k0, k1, k2=0.0)[source]

Compute mean annual frequency of exceedance (MAFE) of an intensity measure (IM) value based on SAC/FEMA-compatible coefficients

Parameters:
  • s (float) – Intensity measure level

  • k0 (float) – SAC/FEMA-compatible coefficient

  • k1 (float) – SAC/FEMA-compatible coefficient

  • k2 (float) – SAC/FEMA-compatible coefficient, by default 0.

Returns:

Mean annual frequency of exceeding an IM value (MAFE)

Return type:

float

djura.hazard_consistency.hazard_fit.solve_for_im(s, mafe, k0, k1, k2=0.0)[source]
Return type:

float

djura.hazard_consistency.hazard_fit.error_function(x, s, a)[source]
class djura.hazard_consistency.hazard_fit.HazardFit(im_range, s, mafe)[source]

Bases: object

analytical_sac_fema(return_periods=None)[source]

SAC/FEMA-compatible Hazard fitting function

Parameters:

return_periods (List[float]) – List of 3 integer values where the fitting will be prioritized, by default selects return periods at indices [0, 3, 9]

Returns:

Dictionary with keys:

  • s: Original IM range

  • mafe: Original MAFE

  • s_fit: Fitted IM range

  • mafe_fit: Fitted MAFE

  • coef: SAC/FEMA-compatible coefficients [k0, k1, k2]

  • return_periods: Return periods used for fitting

Return type:

dict

least_squares()[source]

Hazard fitting function using least squares method

Returns:

sList

Original IM range

mafeList

Original MAFE

s_fitList

Fitted IM range

mafe_fitList

Fitted MAFE

coefList[float]

SAC/FEMA-compatible coefficients, [k0, k1, k2]

Return type:

dict

power_law(dbe=465.0, mce=10000.0)[source]

Performs fitting on a loglinear power law constrained at two return periods

Parameters:
  • dbe (float) – First conditioning return period, by default 465

  • mce (float) – Second conditioning return period, by default 10000

Returns:

sList

Original IM range

mafeList

Original MAFE

s_fitList

Fitted IM range

mafe_fitList

Fitted MAFE

coefList[float]

SAC/FEMA-compatible coefficients for a first-order law, [k0, k1]

Return type:

dict

analytical()[source]

Performs fitting following the approach of Bradley et al., 2008

Returns:

sList

Original IM range

mafeList

Original MAFE

s_fitList

Fitted IM range

mafe_fitList

Fitted MAFE

coefList[float]

Fitting coefficients [H_asy, s_asy, alpha]

Return type:

dict

class djura.hazard_consistency.models.HazardModelSchema(**data)[source]

Bases: BaseModel

s: List[float]
mafe: List[float]
s_fit: List[float]
mafe_fit: List[float]
method: str
coef: List[float]
return_periods: List[float]
class ConfigDict[source]

Bases: object

extra = 'forbid'
classmethod check_coef_length(coef, values)[source]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class djura.hazard_consistency.models.HazardSchema(**data)[source]

Bases: BaseModel

s: List[float]
poe: List[float]
class ConfigDict[source]

Bases: object

extra = 'forbid'
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class djura.hazard_consistency.models.HazardBatchSchema(**data)[source]

Bases: BaseModel

root: Dict[str, HazardSchema]
class ConfigDict[source]

Bases: object

arbitrary_types_allowed = True
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].