diff --git a/README.md b/README.md index 0a2b1c5..25cb940 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,14 @@

This repository contains an open source library that provides modelling of multi-degree-of-freedom systems and assessment via nonlinear time-history analyses for regional vulnerability and risk calculations. The vulnerability toolkit is developed by the Global Earthquake Model (GEM) Foundation and its collaborators.
- Explore the docs » + Explore the docs »

- View Demos + View Demos · - Report Bug + Report Bug · - Request Feature + Request Feature

@@ -93,6 +93,9 @@ It is highly recommended to use a **virtual environment** to install this tool. source .venv/Scripts/activate # On Linux ``` +Logo + + ### 3. Install Dependencies Install the required packages listed in `requirements.txt`. @@ -114,12 +117,18 @@ It is highly recommended to use a **virtual environment** to install this tool. python --version ``` +Logo + + ### 4. Install the Package Install the `oq-vmtk` package in editable mode: ```bash pip install -e . ``` +Logo + + ## 📼 Demos The repository includes demo scripts that showcase the functionality of the vulnerability-modellers-toolkit (oq-vmtk). You can find them in the demos folder of the repository. diff --git a/demos/README.md b/demos/README.md index 0375d95..8a3ef17 100644 --- a/demos/README.md +++ b/demos/README.md @@ -5,13 +5,10 @@ This folder contains an ensemble of example python notebooks demonstrating vario ## Example 1: Ground-Motion Record Processing This example provides a workflow for processing ground-motion records, such as spectral analysis and identification if intensity measure values for distinct intensity measure types (e.g., PGA, Arias Intensity, etc.). -## Example 2: Nonlinear Time-History Analysis on an MDOF System using Cloud Analysis -This example performs nonlinear time-history analysis on a multi-degree-of-freedom (MDOF) structural system calibrated using SDOF global capacity and using cloud analysis to assess seismic performance. +## Example 2: End-to-End Vulnerability Analysis of an MDOF System using Cloud Analysis +This example performs nonlinear time-history analysis on a multi-degree-of-freedom (MDOF) structural system calibrated using SDOF global capacity and using cloud analysis to assess seismic performance. The example additionally demonstrates postprocessing of cloud analysis results, including fragility curve estimation and vulnerability assessment visualization. -## Example 3: Postprocessing and Visualizing Cloud Analysis Results for Fragility and Vulnerability Analysis -This example demonstrates postprocessing of cloud analysis results, including fragility curve estimation and vulnerability assessment visualization. - -## Example 4: Generating and Visualizing Storey Loss Functions +## Example 3: Generating and Visualizing Storey Loss Functions This example focuses on computing and visualizing storey loss functions, providing insights into seismic damage assessment and economic loss estimation. Each example includes relevant scripts, input data, and instructions to guide users through the analysis. Feel free to explore and modify them to suit your specific needs! diff --git a/demos/example_1.ipynb b/demos/example_1.ipynb index c527581..44163a4 100644 --- a/demos/example_1.ipynb +++ b/demos/example_1.ipynb @@ -46,22 +46,10 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "3aa0f9f2-68c4-4201-b9ef-5d90031e4477", "metadata": {}, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'openquake.vmtk'", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 8\u001b[39m\n\u001b[32m 5\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mmatplotlib\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mpyplot\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mplt\u001b[39;00m\n\u001b[32m 7\u001b[39m \u001b[38;5;66;03m# Import the IMCalculator class\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m8\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mopenquake\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mvmtk\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mim_calculator\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m IMCalculator \n\u001b[32m 9\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mopenquake\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mvmtk\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mutilities\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m sorted_alphanumeric, export_to_pkl\n", - "\u001b[31mModuleNotFoundError\u001b[39m: No module named 'openquake.vmtk'" - ] - } - ], + "outputs": [], "source": [ "import os\n", "import sys\n", @@ -162,8 +150,8 @@ "for i in range(len(gmrs)):\n", " \n", " ### Load the acceleration time-histories and the time-step files\n", - " current_acc = pd.read_csv(os.path.join(gm_directory,'acc',f'acc_{i}.csv'), header=None).to_numpy()\n", - " current_dts = pd.read_csv(os.path.join(gm_directory,'dts',f'dts_{i}.csv'), header=None).to_numpy()\n", + " current_acc = pd.read_csv(os.path.join(gm_directory,'acc',f'acc_{i}.csv'), header=None).to_numpy().flatten()\n", + " current_dts = pd.read_csv(os.path.join(gm_directory,'dts',f'dts_{i}.csv'), header=None).to_numpy().flatten()\n", " \n", " ### Define the time-step of the acceleration time-history\n", " dt_gm = (current_dts[1] - current_dts[0]).item() # Subtract any consecutive rows of the time-step file\n", diff --git a/imgs/packaging.gif b/imgs/packaging.gif new file mode 100644 index 0000000..a12a417 Binary files /dev/null and b/imgs/packaging.gif differ diff --git a/imgs/requirements.gif b/imgs/requirements.gif new file mode 100644 index 0000000..7ebac69 Binary files /dev/null and b/imgs/requirements.gif differ diff --git a/imgs/virtual-env.gif b/imgs/virtual-env.gif new file mode 100644 index 0000000..369d440 Binary files /dev/null and b/imgs/virtual-env.gif differ diff --git a/openquake/vmtk/slf_generator.py b/openquake/vmtk/slf_generator.py index b6016f2..674d420 100644 --- a/openquake/vmtk/slf_generator.py +++ b/openquake/vmtk/slf_generator.py @@ -579,7 +579,7 @@ def _validate_component_data_schema(self): # Validate base fields id_set = set() for row in component_data: - model = component_data_model.parse_obj(row) + model = component_data_model.model_validate(row) if model.Component_ID is not None and model.Component_ID in id_set: raise ValueError(f'Duplicate ITEM: {model.Component_ID}') id_set.add(model.Component_ID) @@ -613,7 +613,7 @@ def _validate_correlation_tree_schema(self, # Validate base fields id_set = set() for row in corr_dict: - model = correlation_tree_model.parse_obj(row) + model = correlation_tree_model.model_validate(row) if model.ITEM in id_set: raise ValueError(f'Duplicate ITEM: {model.ITEM}') id_set.add(model.ITEM)