{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# RA2CE feature: Single link losses analysis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Single link losses Analysis" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "c:\\Users\\hauth\\anaconda3\\envs\\ra2ce_env\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] } ], "source": [ "from pathlib import Path\n", "from ra2ce.ra2ce_handler import Ra2ceHandler\n", "import geopandas as gpd\n", "\n", "# Import config data\n", "root_dir = Path(\"data\", \"single_link_losses\")\n", "assert root_dir.exists()\n", "\n", "# Load network data.\n", "from ra2ce.network.network_config_data.network_config_data_reader import NetworkConfigDataReader\n", "_network_config_data = NetworkConfigDataReader().read(root_dir.joinpath(\"network.ini\"))\n", "\n", "# Load analysis data.\n", "from ra2ce.analysis.analysis_config_data.analysis_config_data_reader import AnalysisConfigDataReader\n", "_analysis_config_data = AnalysisConfigDataReader().read(root_dir.joinpath(\"analysis.ini\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Modify the analysis config data with custom properties" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from ra2ce.analysis.analysis_config_data.analysis_config_data import AnalysisSectionLosses\n", "\n", "# Modify the first analysis (assuming it's the only one)\n", "_found_analysis: AnalysisSectionLosses = _analysis_config_data.analyses[0]\n", "_input_analysis_path = root_dir.joinpath(\"input_analysis_data\")\n", "_found_analysis.traffic_intensities_file = _input_analysis_path.joinpath(\"traffic_intensities.csv\")\n", "_found_analysis.resilience_curves_file = _input_analysis_path.joinpath(\"resilience_curve.csv\")\n", "_found_analysis.values_of_time_file = _input_analysis_path.joinpath(\"values_of_time.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Configure network" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's have a look first at the hazard overlay to locate the road segments for which losses will be expected. We run only the network configuration." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "handler = Ra2ceHandler.from_config(_network_config_data, _analysis_config_data)\n", "handler.configure()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | ID | \n", "u | \n", "v | \n", "key | \n", "EV1_fr | \n", "EV1_ma | \n", "alt_nodes | \n", "alt_time | \n", "avgspeed | \n", "bridge | \n", "... | \n", "node_B | \n", "rfid | \n", "rfid_c | \n", "time | \n", "vlh_business_EV1_ma | \n", "vlh_commute_EV1_ma | \n", "vlh_freight_EV1_ma | \n", "vlh_other_EV1_ma | \n", "vlh_EV1_ma_total | \n", "geometry | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "86 | \n", "2 | \n", "42 | \n", "0 | \n", "0.014318 | \n", "1.369213 | \n", "[2, 0, 11, 12, 10, 7, 6, 9, 75, 121, 118, 5, 3... | \n", "0.099722 | \n", "59.0 | \n", "yes | \n", "... | \n", "42 | \n", "125 | \n", "127 | \n", "0.043763 | \n", "433.125000 | \n", "303.333333 | \n", "5775.000000 | \n", "5133.333333 | \n", "11644.791667 | \n", "LINESTRING (34.86702 -19.83164, 34.86711 -19.8... | \n", "
1 | \n", "30 | \n", "29 | \n", "31 | \n", "0 | \n", "0.079975 | \n", "0.345044 | \n", "[29, 30, 82, 31] | \n", "0.009356 | \n", "59.0 | \n", "yes | \n", "... | \n", "31 | \n", "91 | \n", "93 | \n", "0.003898 | \n", "5.156250 | \n", "3.750000 | \n", "5.000000 | \n", "35.833333 | \n", "49.739583 | \n", "LINESTRING (34.83997 -19.83592, 34.84019 -19.8... | \n", "
2 | \n", "100 | \n", "30 | \n", "82 | \n", "0 | \n", "0.100808 | \n", "0.654458 | \n", "[30, 29, 31, 82] | \n", "0.005288 | \n", "30.0 | \n", "yes | \n", "... | \n", "82 | \n", "233 | \n", "241 | \n", "0.007967 | \n", "-40.781250 | \n", "-18.437500 | \n", "-81.250000 | \n", "-106.250000 | \n", "-246.718750 | \n", "LINESTRING (34.84149 -19.83431, 34.84137 -19.8... | \n", "
3 | \n", "85 | \n", "42 | \n", "73 | \n", "0 | \n", "0.027676 | \n", "0.409945 | \n", "nan | \n", "NaN | \n", "60.0 | \n", "yes | \n", "... | \n", "73 | \n", "208 | \n", "216 | \n", "0.016917 | \n", "46.375000 | \n", "51.187500 | \n", "24.500000 | \n", "210.000000 | \n", "332.062500 | \n", "LINESTRING (34.87145 -19.82349, 34.87126 -19.8... | \n", "
4 | \n", "264 | \n", "46 | \n", "51 | \n", "0 | \n", "0.002634 | \n", "0.766717 | \n", "[46, 48, 47, 160, 51] | \n", "0.008829 | \n", "60.0 | \n", "nan | \n", "... | \n", "51 | \n", "151 | \n", "153 | \n", "0.002183 | \n", "39.785156 | \n", "13.125000 | \n", "80.208333 | \n", "69.270833 | \n", "202.389323 | \n", "LINESTRING (34.85650 -19.83019, 34.85714 -19.8... | \n", "
5 rows × 27 columns
\n", "