#!/usr/bin/bash

set -euo pipefail

python3 manage.py migrate

python3 manage.py load_probability --filename "${1}/events/probabilistic/tornado/F0_prob_probabilities_4326_inverted_v3.tif" --format tiff --hazard tornado:Tornado --severity 0:Storm\ Force
python3 manage.py load_probability --filename "${1}/events/probabilistic/tornado/F1_prob_probabilities_4326_inverted_v3.tif" --format tiff --hazard tornado:Tornado --severity 1:Storm\ Force
python3 manage.py load_probability --filename "${1}/events/probabilistic/tornado/F2_prob_probabilities_4326_inverted_v3.tif" --format tiff --hazard tornado:Tornado --severity 2:Storm\ Force
python3 manage.py load_probability --filename "${1}/events/probabilistic/tornado/F3_prob_probabilities_4326_inverted_v3.tif" --format tiff --hazard tornado:Tornado --severity 3:Storm\ Force
python3 manage.py load_probability --filename "${1}/events/probabilistic/tornado/F4_prob_probabilities_4326_inverted_v3.tif" --format tiff --hazard tornado:Tornado --severity 4:Storm\ Force
python3 manage.py load_probability --filename "${1}/events/probabilistic/tornado/F5_prob_probabilities_4326_inverted_v3.tif" --format tiff --hazard tornado:Tornado --severity 5:Storm\ Force

python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.0_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.0:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.1_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.1:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.2_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.2:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.3_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.3:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.4_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.4:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.5_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.5:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.6_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.6:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.7_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.7:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.8_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.8:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_5.9_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 5.9:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.0_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.0:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.1_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.1:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.2_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.2:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.3_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.3:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.4_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.4:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.5_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.5:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.6_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.6:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.7_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.7:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.8_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.8:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_6.9_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 6.9:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.0_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.0:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.1_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.1:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.2_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.2:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.3_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.3:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.4_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.4:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.5_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.5:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.6_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.6:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.7_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.7:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.8_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.8:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_7.9_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 7.9:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_8.0_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 8.0:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_8.1_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 8.1:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_8.2_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 8.2:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_8.3_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 8.3:Magnitudes
python3 manage.py load_probability --zip-filename "${1}/events/probabilistic/earthquake/eq_rates_rasters.zip" --filename mag_rate_8.4_0_999.tif --format tiff --hazard earthquake:Earthquake --severity 8.4:Magnitudes

python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/CMCC-CM2-VHR4_highresSST-present_r1i1p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/CNRM-CM6-1-HR_highresSST-present_r1i1p1f2_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/CNRM-CM6-1_highresSST-present_r1i1p1f2_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/EC-Earth3P-HR_highresSST-present_r3i1p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/EC-Earth3P_highresSST-present_r1i1p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/EC-Earth3P_highresSST-present_r3i1p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-HM_highresSST-present_r1i1p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-HM_highresSST-present_r1i2p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-HM_highresSST-present_r1i3p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-LM_highresSST-present_r1i14p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-LM_highresSST-present_r1i15p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-LM_highresSST-present_r1i1p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-LM_highresSST-present_r1i2p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-LM_highresSST-present_r1i3p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-MM_highresSST-present_r1i1p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-MM_highresSST-present_r1i2p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/HadGEM3-GC31-MM_highresSST-present_r1i3p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/MPI-ESM1-2-HR_highresSST-present_r1i1p1f1_footprints.csv --sparse 251
python3 manage.py load_events_winterstorm --zip-filename "${1}/events/stochastic/winterstorm/Winterstorm.zip" --filename Winterstorm/MPI-ESM1-2-XR_highresSST-present_r1i1p1f1_footprints.csv --sparse 251

python3 manage.py load_events_tornado --zip-filename "${1}/events/stochastic/tornado/Tornado.zip" --filename Tornado/tornado_hazard_model5000_bendy_v2.csv

for i in {0..917}
 do
  python3 manage.py load_events_earthquake --filename PGA_${i}_eql.csv --zip-filename "${1}/events/stochastic/Earthquake/eq_stochastic/events_${i}.zip" --relative-path "PGA_${i}_{:d}.tif" --footprint-num-offset -1
done

echo "loading big curve list"
python3 manage.py load_curves --filename "${1}/vulnerability/VulnDB_Europe_Input.xlsx" --sheet Sheet1 --clear-existing
echo "loading A21 curves, earthquake"
python3 manage.py load_curves --filename "${1}/vulnerability/A21_vulnerabilities_earthquake.xlsx" --sheet Tabelle1
echo "loading A21 curves, tornado"
python3 manage.py load_curves --filename "${1}/vulnerability/A21_vulnerabilities_tornado.xlsx" --sheet Tabelle1
echo "loading A21 curves, wind"
python3 manage.py load_curves --filename "${1}/vulnerability/A21_vulnerabilities_wind.xlsx" --sheet Tabelle1

echo "loading tourism"
python3 manage.py add_datasets_tourism --format gpkg-sqlite --filename "${1}/tourism/NUTS3/FINAL_NUTS3_1568_ESPG4326_tourism_indicators.gpkg"

echo "loading danube"
python3 manage.py add_dataset --format gpkg-sqlite --filename "${1}/danube/danube_scenario.gpkg" --table-metadata "${1}/danube/danube_metadata.json"

echo "FINAL_drought_Population_CapitalStock_TourismExpenditure_GDP.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_drought_Population_CapitalStock_TourismExpenditure_GDP.gpkg"
echo "FINAL_Earthquake_CapitalStock_ALL.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_Earthquake_CapitalStock_ALL.gpkg"
echo "FINAL_Earthquake.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_Earthquake.gpkg"
echo "FINAL_flood_CapitalStock.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_flood_CapitalStock.gpkg"
echo "FINAL_flood_GDP.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_flood_GDP.gpkg"
echo "FINAL_flood_Population.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_flood_Population.gpkg"
echo "FINAL_flood_TourismExpenditure.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_flood_TourismExpenditure.gpkg"
echo "FINAL_landslide_Population_CapitalStock_GDP_TourismExpenditure.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_landslide_Population_CapitalStock_GDP_TourismExpenditure.gpkg"
echo "FINAL_ls_paneur_Population_CapitalStock_GDP_TourismExpenditure.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_ls_paneur_Population_CapitalStock_GDP_TourismExpenditure.gpkg"
echo "FINAL_stormsurge_CapitalStockA-J.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_stormsurge_CapitalStockA-J.gpkg"
echo "FINAL_stormsurge_CapitalStockK-T.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_stormsurge_CapitalStockK-T.gpkg"
echo "FINAL_stormsurge_GDP.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_stormsurge_GDP.gpkg"
echo "FINAL_stormsurge_Population.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_stormsurge_Population.gpkg"
echo "FINAL_stormsurge_TourismExpenditure.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_stormsurge_TourismExpenditure.gpkg"
echo "FINAL_tc_CapitalStock.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tc_CapitalStock.gpkg"
echo "FINAL_tc_GDP.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tc_GDP.gpkg"
echo "FINAL_tc_Population_avg_POP2050.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tc_Population_avg_POP2050.gpkg"
echo "FINAL_tc_Population.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tc_Population.gpkg"
echo "FINAL_tc_TourismExpenditure.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tc_TourismExpenditure.gpkg"
echo "FINAL_tsunami_CapitalStock.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tsunami_CapitalStock.gpkg"
echo "FINAL_tsunami_GDP.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tsunami_GDP.gpkg"
echo "FINAL_tsunami_Population.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tsunami_Population.gpkg"
echo "FINAL_tsunami_TourismExpenditure.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tsunami_TourismExpenditure.gpkg"
echo "FINAL_wildfire_Population_CapitalStock_TourismExpenditure_GDP.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_wildfire_Population_CapitalStock_TourismExpenditure_GDP.gpkg"
echo "FINAL_wind_Population_CapitalStock_TourismExpenditure_GDP.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_wind_Population_CapitalStock_TourismExpenditure_GDP.gpkg"
echo "FINAL_Winterstorm.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_Winterstorm.gpkg"
echo "NEW_FINAL_Hail_CapitalStock.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/NEW_FINAL_Hail_CapitalStock.gpkg"
echo "NEW_FINAL_Hail.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/NEW_FINAL_Hail.gpkg"
echo "NEW_FINAL_Tornado.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/NEW_FINAL_Tornado.gpkg"

echo "FINAL_tasmax30_CapStock_histo_A-J.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tasmax30_CapStock_histo_A-J.gpkg"
echo "FINAL_tasmax30_histo.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tasmax30_histo.gpkg"
echo "FINAL_tasmax30_histo_CapStock_K-T.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tasmax30_histo_CapStock_K-T.gpkg"
echo "FINAL_tasmax30_ssp.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tasmax30_ssp.gpkg"
echo "FINAL_tasmax30_ssp_CapStock_A-J.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tasmax30_ssp_CapStock_A-J.gpkg"
echo "FINAL_tasmax30_ssp_CapStock_K-T.gpkg"
python3 manage.py add_dataset --format gpkg-sqlite --table-metadata "${1}/risk/parameters.json" --filename "${1}/risk/FINAL_tasmax30_ssp_CapStock_K-T.gpkg"


echo "A21_A"
python3 manage.py add_exposure --key A21_A --label "A21 A (Agriculture, forestry and fishing)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_A_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_A

echo "A21_B"
python3 manage.py add_exposure --key A21_B --label "A21 B (Mining and quarrying)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_B_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_B

echo "A21_C"
python3 manage.py add_exposure --key A21_C --label "A21 C (Manufacturing)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_C_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_C

echo "A21_D"
python3 manage.py add_exposure --key A21_D --label "A21 D (Electricity, gas, steam, and air conditioning supply)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_D_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_D

echo "A21_E"
python3 manage.py add_exposure --key A21_E --label "A21 E (Water supply; sewerage, waste management and remediation activities)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_E_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_E

echo "A21_F"
python3 manage.py add_exposure --key A21_F --label "A21 F (Construction)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_F_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_F

echo "A21_G"
python3 manage.py add_exposure --key A21_G --label "A21 G (Wholesale and retail trade; repair of motor vehicles and motorcycles)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_G_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_G

echo "A21_H"
python3 manage.py add_exposure --key A21_H --label "A21 H (Transportation and storage)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_H_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_H

echo "A21_I"
python3 manage.py add_exposure --key A21_I --label "A21 I (Accommodation and food service activities)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_I_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_I

echo "A21_J"
python3 manage.py add_exposure --key A21_J --label "A21 J (Information and communication)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_J_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_J

echo "A21_K"
python3 manage.py add_exposure --key A21_K --label "A21 K (Financial and insurance activities)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_K_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_K

echo "A21_L"
python3 manage.py add_exposure --key A21_L --label "A21 L (Real estate activities)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_L_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_L

echo "A21_M"
python3 manage.py add_exposure --key A21_M --label "A21 M (Professional, scientific and technical activities)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_M_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_M

echo "A21_N"
python3 manage.py add_exposure --key A21_N --label "A21 N (Administrative and support service activities)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_N_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_N

echo "A21_O"
python3 manage.py add_exposure --key A21_O --label "A21 O (Public administration and defence; compulsory social security)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_O_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_O

echo "A21_P"
python3 manage.py add_exposure --key A21_P --label "A21 P (Education)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_P_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_P

echo "A21_Q"
python3 manage.py add_exposure --key A21_Q --label "A21 Q (Human health and social work activities)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_Q_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_Q

echo "A21_R"
python3 manage.py add_exposure --key A21_R --label "A21 R (Arts, entertainment, and recreation)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_R_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_R

echo "A21_S"
python3 manage.py add_exposure --key A21_S --label "A21 S (Other service activities)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_S_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_S

echo "A21_ALL"
python3 manage.py add_exposure --key A21_ALL --label "A21 ALL (all combined)" \
  --raster-filename "${1}/exposure/CapitalStock_A21/raster/EURO_NUTS3_CapitalStock__A21_ALL_distr.tif" \
  --raster-format tiff \
  --nuts3-filename "${1}/exposure/CapitalStock_A21/NUTS3/FINAL_NUTS3_1568_EPSG4326_CapitalStockA21.gpkg" \
  --nuts3-format gpkg-sqlite --nuts3-gpkg-identifier A21_ALL

python3 manage.py add_scenarios "${1}/scenario/scenario_config.json"

cp "${1}/danube/mrvi-plugin.zip" ./vulnerability_index_editor/static/
