{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "9c8094c5-399d-4d72-ba38-cdb831f8fe9e", "metadata": {}, "source": [ "# Prepare OpenQuake Liquefaction Scenarios" ] }, { "cell_type": "code", "execution_count": 29, "id": "3488aa53", "metadata": {}, "outputs": [], "source": [ "# Import dependencies\n", "import os, glob\n", "import pandas as pd\n", "import copy\n", "from openquake.engine.engine import create_jobs\n", "\n", "# Ruptures information\n", "rup_info = pd.read_csv('rupture_trts.csv')" ] }, { "cell_type": "code", "execution_count": 30, "id": "8b92bf57-450e-4705-8456-e20f2ac33a81", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#Event NameMwTRT (in repo)TRT (JSON ref)RakegmmLTgmmLT-Lana
011664_N_Bang7.70ascractive shallow crust90gmmLT_ascrgmpe_logic_tree_ascr
121762_arakan8.50subdsubdcution interface90subduction interfacegmpe_logic_tree_subd
2318227.10subdactive shallow crust90gmmLT_ascrgmpe_logic_tree_ascr
341869_cachar7.30ascractive shallow crust90gmmLT_ascrgmpe_logic_tree_ascr
451885_manikganj7.20ascractive shallow crust90subduction interfacegmpe_logic_tree_ascr
561897_Dauki8.70subdactive shallow crust90gmmLT_ascrgmpe_logic_tree_subd
671918_Srimangal7.40ascrsubduction interface90subduction interfacegmpe_logic_tree_subd
78chittagong_north8.20subdsubduction interface90subduction interfacegmpe_logic_tree_subd
89chittagong_thrust_smaller7.25ascrsubduction interface90gmmLT_ascrgmpe_logic_tree_ascr
910sikkim_mht8.50subdsubduction interface90subduction interfacegmpe_logic_tree_subd
1011western_deformation_front_partial7.70ascractive shallow crust90gmmLT_ascrgmpe_logic_tree_ascr
1112western_deformation_front8.50ascractive shallow crust90gmmLT_ascrgmpe_logic_tree_ascr
\n", "
" ], "text/plain": [ " # Event Name Mw TRT (in repo) \\\n", "0 1 1664_N_Bang 7.70 ascr \n", "1 2 1762_arakan 8.50 subd \n", "2 3 1822 7.10 subd \n", "3 4 1869_cachar 7.30 ascr \n", "4 5 1885_manikganj 7.20 ascr \n", "5 6 1897_Dauki 8.70 subd \n", "6 7 1918_Srimangal 7.40 ascr \n", "7 8 chittagong_north 8.20 subd \n", "8 9 chittagong_thrust_smaller 7.25 ascr \n", "9 10 sikkim_mht 8.50 subd \n", "10 11 western_deformation_front_partial 7.70 ascr \n", "11 12 western_deformation_front 8.50 ascr \n", "\n", " TRT (JSON ref) Rake gmmLT gmmLT-Lana \n", "0 active shallow crust 90 gmmLT_ascr gmpe_logic_tree_ascr \n", "1 subdcution interface 90 subduction interface gmpe_logic_tree_subd \n", "2 active shallow crust 90 gmmLT_ascr gmpe_logic_tree_ascr \n", "3 active shallow crust 90 gmmLT_ascr gmpe_logic_tree_ascr \n", "4 active shallow crust 90 subduction interface gmpe_logic_tree_ascr \n", "5 active shallow crust 90 gmmLT_ascr gmpe_logic_tree_subd \n", "6 subduction interface 90 subduction interface gmpe_logic_tree_subd \n", "7 subduction interface 90 subduction interface gmpe_logic_tree_subd \n", "8 subduction interface 90 gmmLT_ascr gmpe_logic_tree_ascr \n", "9 subduction interface 90 subduction interface gmpe_logic_tree_subd \n", "10 active shallow crust 90 gmmLT_ascr gmpe_logic_tree_ascr \n", "11 active shallow crust 90 gmmLT_ascr gmpe_logic_tree_ascr " ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rup_info" ] }, { "cell_type": "code", "execution_count": 31, "id": "1aa2b37d", "metadata": {}, "outputs": [], "source": [ "# Configuration file template\n", "job_template = '''\n", "[General]\n", "description = Bangladesh scenario {NAME} - liquefaction\n", "calculation_mode = scenario\n", "random_seed = 113\n", "\n", "[site_params]\n", "site_model_file = ../Site_model.csv\n", "region_grid_spacing = 5\n", "\n", "[rupture]\n", "rupture_model_file = {RUPTURE_FILE}\n", "rupture_mesh_spacing = 2.0\n", "\n", "[Secondary perils]\n", "sensitivity_analysis = {'secondary_perils': ['AllstadtEtAl2022Liquefaction', 'TodorovicSilva2022NonParametric']}\n", "\n", "[Calculation parameters]\n", "intensity_measure_types = PGV, PGA\n", "cross_correlation = Bradley2012\n", "truncation_level = 3\n", "maximum_distance = 300\n", "number_of_ground_motion_fields = 1000\n", "gsim_logic_tree_file = ../gmmLT_ref/{gmpe_file}\n", "extreme_gmv = {\"PGV\": 150, \"PGA\": 2.5}\n", "'''" ] }, { "cell_type": "code", "execution_count": 32, "id": "0ce91f0f-5718-4aa8-8402-c9b7e6c1eafa", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "job file saved for: 1664_N_Bang\n", "job file saved for: 1762_arakan\n", "job file saved for: 1822\n", "job file saved for: 1869_cachar\n", "job file saved for: 1885_manikganj\n", "job file saved for: 1897_Dauki\n", "job file saved for: 1918_Srimangal\n", "job file saved for: chittagong_north\n", "job file saved for: chittagong_thrust_smaller\n", "job file saved for: sikkim_mht\n", "job file saved for: western_deformation_front_partial\n", "job file saved for: western_deformation_front\n" ] } ], "source": [ "# Create job files for each rupture\n", "for i, event in enumerate(rup_info['Event Name']):\n", " job = copy.deepcopy(job_template) \n", " # Remove spaces from the event name to create the rupture name\n", " rupture = f'bangladesh_{event.replace(\" \", \"_\")}_scenario_rupture.xml'\n", "\n", " # Fetch the required information from the CSV file\n", " gsimLT = rup_info.loc[rup_info['Event Name'] == event, 'gmmLT-Lana'].values[0]\n", " gsimLT += \".xml\"\n", " \n", " job = job.replace(\n", " '{NAME}', event).replace(\n", " '{RUPTURE_FILE}', rupture).replace(\n", " '{gmpe_file}', gsimLT)\n", " \n", " with open(f'job_{event}.ini', 'w', encoding=\"utf-8\") as f:\n", " f.write(job)\n", " \n", " print('job file saved for:', event)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "f4ca3b39", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.13" }, "vscode": { "interpreter": { "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" } } }, "nbformat": 4, "nbformat_minor": 5 }