djura.slf
Storey loss function generation.
Storey-loss-function (SLF) Generator
The tool allows the automatic production of SLFs based on input fragility,
consequence and quantity data.
Considerations for double counting should be done at the input level and the
consequence function should mirror it.
SLF estimation procedure: Ramirez and Miranda 2009, CH.3 Storey-based
building-specific loss estimation (p. 17)
FEMA P-58 for fragilities: https://femap58.atcouncil.org/reports
For consequence functions: https://femap58.atcouncil.org/reports
EDP: Engineering Demand Parameter
DV: Decision Variable
DS: Damage State
-
class djura.slf.slf.SLF(inventory, edp, correlations=None, edp_range=None, edp_bin=None, do_grouping=True, conversion=1.0, realizations=20, replacement_cost=1.0, regression='Weibull', storey=None, directionality=None, seed=None, max_psd=10, max_pfa=5, n_prev=0)[source]
Bases: object
Storey-loss-function (SLF) Generator for Storey-Based Loss Assessment
The tool allows the automatic production of SLFs based on input fragility,
consequence and quantity data.
Considerations for double counting should be done at the input level and
the consequence function should mirror it.
SLF estimation procedure: Ramirez and Miranda 2009,
CH.3 Storey-based building-specific loss estimation (p. 17)
FEMA P-58 for fragilities: https://femap58.atcouncil.org/reports
For consequence functions: https://femap58.atcouncil.org/reports
EDP: Engineering Demand Parameter
DV: Decision Variable
DS: Damage State
-
NEGLIGIBLE = 1e-08
-
fragility_function()[source]
Derives fragility functions
- Returns:
Fragility functions associated with each damage state and component
- Return type:
tuple[FragilityModel, ndarray, ndarray]
-
perform_monte_carlo(fragilities)[source]
Performs Monte Carlo simulations and simulates damage state(DS) for
each engineering demand parameter (EDP) value
- Parameters:
fragilities (FragilityModel) – Fragility functions of all components at all DSs
- Returns:
Sampled damage states of each component for each simulation
- Return type:
DamageStateModel
-
enforce_ds_dependent(damage_state)[source]
Enforces new DS for each dependent component
- Parameters:
damage_state (DamageStateModel) – Sampled damage states of each component for each simulation
- Returns:
Sampled DS of each component for each simulation after enforcing
DS for dependent components if a correlation matrix is provided
- Return type:
DamageStateModel
-
calculate_costs(damage_state)[source]
Evaluates the damage cost on the individual i-th component at each
EDP level for each n-th simulation
- Parameters:
damage_state (DamageStateModel) – Sampled damage states
- Return type:
tuple[CostModel, CostModel, SimulationModel]
- Returns:
CostModel – Total replacement costs in absolute values
CostModel – Total replacement costs as a ratio of replacement cost
SimulationModel – Repair costs associated with each component and simulation
-
perform_regression(loss, loss_ratio, percentiles=None)[source]
Performs regression and outputs final fitted results as
storey-loss functions (SLFs)
- Parameters:
loss (CostModel) – Total loss for the floor segment in absolute values
loss_ratio (CostModel) – Total loss for the floor segment as a ratio of replacement cost
percentiles (List[float]) – Percentiles to estimate, by default [0.16, 0.50, 0.84],
‘mean’ is always included
- Return type:
tuple[LossModel, FittedLossModel, FittingParametersModel]
- Returns:
LossModel – Loss quantiles in terms of both absolute values and ratio
to replacement cost
FittedLossModel – Fitted loss functions
FittingParametersModel – Fitting parameters or each quantiles and mean
-
estimate_accuracy(y, yhat)[source]
Estimate prediction accuracy
- Parameters:
-
- Returns:
Maximum error in %, and Cumulative error in %
- Return type:
tuple[float, float]
-
generate_slfs()[source]
Genearte SLFs
- Returns:
SLFs per each performance group
- Return type:
Dict[str, SLFPGModel]
-
export_to_json(out, export_path)[source]
- Return type:
None
-
class djura.slf.models.ComponentDataModel(**data)[source]
Bases: BaseModel
-
id: int
-
name: str
-
EDP: str
-
Component: str
-
Group: int | None
-
Quantity: float
-
damage_states: int
-
median_demand: List[float]
-
total_dispesion: List[float]
-
repair_cost: List[float]
-
cost_dispersion: List[float]
-
best_fit: List[str | None]
-
classmethod allow_none(v)[source]
-
model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.CorrelationTreeModel(**data)[source]
Bases: BaseModel
-
id: int
-
dependent_on_item: str
-
min_ds: List[str]
-
model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.ItemBase(root=PydanticUndefined, **data)[source]
Bases: RootModel
-
root: Dict[str, ndarray]
-
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.ItemsModel(root=PydanticUndefined, **data)[source]
Bases: RootModel
-
root: Dict[int, ItemBase]
-
model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.FragilityModel(**data)[source]
Bases: BaseModel
-
EDP: ndarray
-
ITEMs: ItemsModel
-
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.DamageStateModel(root=PydanticUndefined, **data)[source]
Bases: RootModel
-
root: Dict[int, Dict[int, ndarray]]
-
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.CostModel(root=PydanticUndefined, **data)[source]
Bases: RootModel
-
root: Dict[int, ndarray]
-
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.SimulationModel(root=PydanticUndefined, **data)[source]
Bases: RootModel
-
root: Dict[int, CostModel]
-
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.FittingModelBase(**data)[source]
Bases: BaseModel
-
popt: ndarray | List
-
pcov: ndarray | List
-
multiplier: float | None
-
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.FittingParametersModel(root=PydanticUndefined, **data)[source]
Bases: RootModel
-
root: Dict[str, FittingModelBase]
-
model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.FittedLossModel(root=PydanticUndefined, **data)[source]
Bases: RootModel
-
root: Dict[str, ndarray]
-
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.LossModel(**data)[source]
Bases: BaseModel
-
loss: Dict[int, Dict[int | str, float]]
-
loss_ratio: Dict[int, Dict[int | str, float]]
-
model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.SLFModel(**data)[source]
Bases: BaseModel
-
directionality: int | None
-
component_type: str
-
storey: int | List[int] | None
-
edp: str
-
edp_range: List[float]
-
slf: List[float]
-
fitting_parameters: Dict[str, FittingModelBase] | None
-
model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
class djura.slf.models.SLFPGModel(root=PydanticUndefined, **data)[source]
Bases: RootModel
-
root: Dict[str, SLFModel]
-
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
djura.slf.regression_methods.weibull(x, popt)[source]
-
djura.slf.regression_methods.papadopoulos(x, popt)[source]
-
djura.slf.utilities.aggregate_values(row, columns, key)[source]
-
djura.slf.utilities.convert_inv(df)[source]
-
djura.slf.utilities.convert_corr(df)[source]
-
djura.slf.utilities.slf_aggregator(*args)[source]
Aggregates input SLFs into a list supported by the loss assessment
module and creates interpolation functions for the EDP vs Loss
relationships
Each argument must have a specific structure:
{
'group name': {
'Directionality': null,
'Storey': null,
'edp': 'edp_name',
'edp_range': list(),
'slf': list()
}
}
- Return type:
list