diff --git a/PV_scenarios_2050/Scenarios_hourly.ipynb b/PV_scenarios_2050/Scenarios_hourly.ipynb index 3b06b09..5d7be0d 100644 --- a/PV_scenarios_2050/Scenarios_hourly.ipynb +++ b/PV_scenarios_2050/Scenarios_hourly.ipynb @@ -1,1182 +1,1591 @@ { "cells": [ { "cell_type": "code", "execution_count": 1, "id": "extended-parallel", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import xarray as xr \n", "\n", "%matplotlib notebook\n", "import matplotlib.pyplot as plt\n", "\n", "from demand_mapping import get_yearly_sum\n", "\n", "import os\n", "import time" ] }, { "cell_type": "code", "execution_count": 2, "id": "sixth-protection", "metadata": {}, "outputs": [], "source": [ "SCENARIO_FP = '/work/hyenergy/output/solar_potential/scenarios_2050'" ] }, { "cell_type": "code", "execution_count": 3, - "id": "herbal-dealer", + "id": "hispanic-sampling", "metadata": {}, "outputs": [], "source": [ - "YEAR = 2019" + "YEAR = 2020" ] }, { "cell_type": "code", - "execution_count": 6, - "id": "senior-bubble", + "execution_count": 4, + "id": "toxic-secret", "metadata": {}, "outputs": [], "source": [ "PV_FP = '/work/hyenergy/output/solar_potential/hourly_potential/'" ] }, { "cell_type": "code", - "execution_count": 20, - "id": "distributed-beach", + "execution_count": 5, + "id": "worth-bankruptcy", "metadata": {}, "outputs": [], "source": [ "hourly_FP_EW = '/scratch/walch/workdir_solar_EW_scenarios'\n", "hourly_FP = '/scratch/walch/workdir_solar_hourly'" ] }, { "cell_type": "markdown", "id": "roman-exhibit", "metadata": {}, "source": [ "# Load data" ] }, { "cell_type": "markdown", "id": "mathematical-today", "metadata": {}, "source": [ "Load base scenario and EW roofs" ] }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 6, "id": "passing-initial", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/walch/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/lib/arraysetops.py:580: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n", " mask |= (ar1 == a)\n" ] } ], "source": [ "roofs_EW = pd.read_csv(os.path.join(PV_FP, '%d_annual_roofs_flat_EW.csv' %(YEAR)), index_col = 0)\n", "roofs = pd.read_csv(os.path.join(PV_FP, '%d_annual_roofs.csv' %(YEAR)), index_col = 0)" ] }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 7, "id": "nuclear-coverage", "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", "
available_areaavailable_area_stdBFS_NUMMERsuitableGt_kWh_m2EPV_kWh
DF_UID
72.1157332.3157952823.001014.36084298.698151031.4386304.00772
3312.0982843.8997592823.01809.074771384.71190824.83461413.21520
4915.38474810.2307192887.01903.293201938.98750923.25361983.89230
50391.32809147.0036962886.011124.5244062210.242001143.265663308.27700
51335.26952449.6488872886.011071.3262050888.320001089.549851804.19500
\n", "
" ], "text/plain": [ - " available_area available_area_std BFS_NUMMER suitable Gt_kWh_m2 \\\n", - "DF_UID \n", - "7 2.115733 2.315795 2823.0 0 1014.36084 \n", - "33 12.098284 3.899759 2823.0 1 809.07477 \n", - "49 15.384748 10.230719 2887.0 1 903.29320 \n", - "50 391.328091 47.003696 2886.0 1 1124.52440 \n", - "51 335.269524 49.648887 2886.0 1 1071.32620 \n", + " available_area available_area_std BFS_NUMMER suitable Gt_kWh_m2 \\\n", + "DF_UID \n", + "7 2.115733 2.315795 2823.0 0 1031.4386 \n", + "33 12.098284 3.899759 2823.0 1 824.8346 \n", + "49 15.384748 10.230719 2887.0 1 923.2536 \n", + "50 391.328091 47.003696 2886.0 1 1143.2656 \n", + "51 335.269524 49.648887 2886.0 1 1089.5498 \n", "\n", " EPV_kWh \n", "DF_UID \n", - "7 298.69815 \n", - "33 1384.71190 \n", - "49 1938.98750 \n", - "50 62210.24200 \n", - "51 50888.32000 " + "7 304.00772 \n", + "33 1413.21520 \n", + "49 1983.89230 \n", + "50 63308.27700 \n", + "51 51804.19500 " ] }, - "execution_count": 28, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "roofs_EW.head()" ] }, { "cell_type": "markdown", "id": "romance-collapse", "metadata": {}, "source": [ "Create annual dataset of full EW scenario" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "id": "equivalent-penetration", "metadata": {}, "outputs": [], "source": [ "annual_EW = roofs.copy()\n", "annual_EW.loc[ roofs_EW.index ] = roofs_EW.copy()" ] }, { "cell_type": "markdown", - "id": "greater-trade", - "metadata": {}, - "source": [ - "Load hourly data" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "id": "assumed-galaxy", - "metadata": {}, - "outputs": [], - "source": [ - "PV_hourly_EW = xr.open_mfdataset(os.path.join( hourly_FP_EW, 'tmp_%d' %YEAR, 'pv_potential_*.nc'), \n", - " chunks = {'DF_UID' : 10000})\n", - "PV_hourly_base = xr.open_mfdataset(os.path.join( hourly_FP, 'tmp_%d' %YEAR, 'pv_potential_*.nc'),\n", - " chunks = {'DF_UID' : 10000})" - ] - }, - { - "cell_type": "markdown", - "id": "fabulous-hybrid", + "id": "acquired-winter", "metadata": {}, "source": [ "Load scenario file" ] }, { "cell_type": "code", - "execution_count": 14, - "id": "sitting-quarter", + "execution_count": 9, + "id": "broadband-benjamin", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/walch/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/lib/arraysetops.py:580: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n", " mask |= (ar1 == a)\n" ] } ], "source": [ "scenarios = pd.read_csv(os.path.join( SCENARIO_FP, 'MMH_cumsum_for_scenarios.csv' ), index_col = 0)" ] }, { "cell_type": "code", - "execution_count": 16, - "id": "funky-deviation", + "execution_count": 10, + "id": "transparent-silicon", "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", "
available_areaBFS_NUMMERsuitableGt_kWh_m2EPV_kWhEPV_cumsum_TWh
DF_UID
686769578533.9870015922.011076.406011923870.00.011924
684322648406.9951785919.011172.56087974506.50.019898
686216044153.6871305938.011120.89436962978.50.026861
871241246188.6418192534.011043.64946785268.50.033647
630548239787.4966762053.011173.70756531450.50.040178
\n", "
" ], "text/plain": [ " available_area BFS_NUMMER suitable Gt_kWh_m2 EPV_kWh \\\n", "DF_UID \n", "6867695 78533.987001 5922.0 1 1076.4060 11923870.0 \n", "6843226 48406.995178 5919.0 1 1172.5608 7974506.5 \n", "6862160 44153.687130 5938.0 1 1120.8943 6962978.5 \n", "8712412 46188.641819 2534.0 1 1043.6494 6785268.5 \n", "6305482 39787.496676 2053.0 1 1173.7075 6531450.5 \n", "\n", " EPV_cumsum_TWh \n", "DF_UID \n", "6867695 0.011924 \n", "6843226 0.019898 \n", "6862160 0.026861 \n", "8712412 0.033647 \n", "6305482 0.040178 " ] }, - "execution_count": 16, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scenarios.head()" ] }, + { + "cell_type": "markdown", + "id": "greater-trade", + "metadata": {}, + "source": [ + "Load hourly data" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "assumed-galaxy", + "metadata": {}, + "outputs": [], + "source": [ + "PV_hourly_EW = xr.open_mfdataset(os.path.join( hourly_FP_EW, 'tmp_%d' %YEAR, 'pv_potential_*.nc'), \n", + " chunks = {'DF_UID' : 10000})\n", + "PV_hourly_base = xr.open_mfdataset(os.path.join( hourly_FP, 'tmp_%d' %YEAR, 'pv_potential_*.nc'),\n", + " chunks = {'DF_UID' : 10000})" + ] + }, { "cell_type": "markdown", "id": "coral-arbitration", "metadata": {}, "source": [ "# Loop over communes (scenario: all roofs)" ] }, { "cell_type": "code", "execution_count": 22, "id": "cutting-filter", "metadata": {}, "outputs": [], "source": [ "# SCENARIO DEFINITION\n", "MIN_AREA = 8\n", "# no restriction for roof tilt and roof aspect" ] }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "id": "incorporate-shore", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Processed commune 50 of 2309 in 141.11s\n" - ] - }, - { - "ename": "KeyboardInterrupt", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;31m# Baseline scenario\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mDF_UIDs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mroofs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mroofs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mBFS_NUMMER\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mcommune\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m&\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mroofs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mavailable_area\u001b[0m \u001b[0;34m>=\u001b[0m \u001b[0mMIN_AREA\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mcommune_pot_base\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPV_hourly_base\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mDF_UID\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mDF_UIDs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpv_potential\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdim\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'DF_UID'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_series\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;31m# Baseline scenario (flat roofs only)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/xarray/core/dataarray.py\u001b[0m in \u001b[0;36mto_series\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 2688\u001b[0m \"\"\"\n\u001b[1;32m 2689\u001b[0m \u001b[0mindex\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcoords\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2690\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSeries\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2691\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2692\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mto_masked_array\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMaskedArray\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/xarray/core/dataarray.py\u001b[0m in \u001b[0;36mvalues\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 632\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 633\u001b[0m \u001b[0;34m\"\"\"The array's data as a numpy.ndarray\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 634\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvariable\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 635\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 636\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msetter\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/xarray/core/variable.py\u001b[0m in \u001b[0;36mvalues\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 552\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 553\u001b[0m \u001b[0;34m\"\"\"The variable's data as a numpy.ndarray\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 554\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_as_array_or_item\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_data\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 555\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 556\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msetter\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/xarray/core/variable.py\u001b[0m in \u001b[0;36m_as_array_or_item\u001b[0;34m(data)\u001b[0m\n\u001b[1;32m 285\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 286\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 287\u001b[0;31m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 288\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 289\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkind\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"M\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/core/_asarray.py\u001b[0m in \u001b[0;36masarray\u001b[0;34m(a, dtype, order)\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 82\u001b[0m \"\"\"\n\u001b[0;32m---> 83\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0morder\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 84\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 85\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/array/core.py\u001b[0m in \u001b[0;36m__array__\u001b[0;34m(self, dtype, **kwargs)\u001b[0m\n\u001b[1;32m 1481\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1482\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__array__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1483\u001b[0;31m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcompute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1484\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdtype\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdtype\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1485\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mastype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/base.py\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 281\u001b[0m \u001b[0mdask\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcompute\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 282\u001b[0m \"\"\"\n\u001b[0;32m--> 283\u001b[0;31m \u001b[0;34m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcompute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtraverse\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 284\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 285\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/base.py\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 563\u001b[0m \u001b[0mpostcomputes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__dask_postcompute__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 564\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 565\u001b[0;31m \u001b[0mresults\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mschedule\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdsk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkeys\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 566\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mrepack\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpostcomputes\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 567\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/threaded.py\u001b[0m in \u001b[0;36mget\u001b[0;34m(dsk, result, cache, num_workers, pool, **kwargs)\u001b[0m\n\u001b[1;32m 82\u001b[0m \u001b[0mget_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0m_thread_get_id\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0mpack_exception\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpack_exception\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 84\u001b[0;31m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 85\u001b[0m )\n\u001b[1;32m 86\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/local.py\u001b[0m in \u001b[0;36mget_async\u001b[0;34m(apply_async, num_workers, dsk, result, cache, get_id, rerun_exceptions_locally, pack_exception, raise_exception, callbacks, dumps, loads, **kwargs)\u001b[0m\n\u001b[1;32m 474\u001b[0m \u001b[0;31m# Main loop, wait on tasks to finish, insert new ones\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 475\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0mstate\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"waiting\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mstate\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"ready\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mstate\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"running\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 476\u001b[0;31m \u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mres_info\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfailed\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mqueue_get\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mqueue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 477\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mfailed\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 478\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mloads\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mres_info\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/local.py\u001b[0m in \u001b[0;36mqueue_get\u001b[0;34m(q)\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 132\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mqueue_get\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 133\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 134\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 135\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/queue.py\u001b[0m in \u001b[0;36mget\u001b[0;34m(self, block, timeout)\u001b[0m\n\u001b[1;32m 168\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 169\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_qsize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 170\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnot_empty\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwait\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 171\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 172\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"'timeout' must be a non-negative number\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/threading.py\u001b[0m in \u001b[0;36mwait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 294\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# restore state no matter what (e.g., KeyboardInterrupt)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 295\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 296\u001b[0;31m \u001b[0mwaiter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0macquire\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 297\u001b[0m \u001b[0mgotit\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 298\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyboardInterrupt\u001b[0m: " - ] - } - ], + "metadata": { + "scrolled": false + }, + "outputs": [], "source": [ "commune_pot_EW = {}\n", "\n", "tt = time.time()\n", "for i, commune in enumerate(roofs.BFS_NUMMER.unique()):\n", " \n", " # Baseline scenario\n", " DF_UIDs = roofs[(roofs.BFS_NUMMER == commune) & (roofs.available_area >= MIN_AREA)].index\n", " commune_pot_base = PV_hourly_base.sel(DF_UID = DF_UIDs).pv_potential.sum(dim = 'DF_UID').to_series()\n", " \n", " # Baseline scenario (flat roofs only)\n", " DF_UIDs_flat = roofs_EW[roofs_EW.index.isin( DF_UIDs )].index\n", " commune_pot_flat_base = PV_hourly_base.sel(DF_UID = DF_UIDs_flat).pv_potential.sum(dim = 'DF_UID').to_series()\n", " \n", " # EW scenario (flat roofs only)\n", " DF_UIDs_flat_EW = roofs_EW[(roofs_EW.BFS_NUMMER == commune) & (roofs_EW.available_area >= MIN_AREA)].index\n", " commune_pot_flat_EW = PV_hourly_EW.sel(DF_UID = DF_UIDs_flat_EW).pv_potential.sum(dim = 'DF_UID').to_series()\n", " \n", " commune_pot_EW[commune] = commune_pot_base - commune_pot_flat_base + commune_pot_flat_EW\n", " \n", " if ((i+1) % 50) == 0:\n", " print('Processed commune %d of %d in %.2fs' %((i+1), len( roofs.BFS_NUMMER.unique()), time.time()-tt))\n", " tt = time.time()\n", " \n", "# Merge all commune potentials\n", "commune_pot_EW = pd.DataFrame(commune_pot_EW) " ] }, { "cell_type": "markdown", - "id": "guided-compilation", + "id": "chubby-landscape", "metadata": {}, "source": [ "## Verify coherence with annual data" ] }, { "cell_type": "code", "execution_count": 9, "id": "proud-scope", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "41.447183715959234" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "annual_EW[annual_EW.available_area >= 8].dropna(subset = ['BFS_NUMMER']).EPV_kWh.sum() / 1e9" ] }, { "cell_type": "code", "execution_count": 10, "id": "refined-installation", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray ()>\n",
        "array(41.44718838)
" ], "text/plain": [ "\n", "array(41.44718838)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "get_yearly_sum(commune_pot_EW.sum(axis = 1).to_xarray(), week_weighting = False) / 1e12" ] }, { "cell_type": "markdown", "id": "spoken-agriculture", "metadata": {}, "source": [ "# Save output data" ] }, { "cell_type": "code", "execution_count": 12, "id": "specified-haven", "metadata": {}, "outputs": [], "source": [ "outfile = ( os.path.join( SCENARIO_FP, '%d_PV_communes_all.csv' %YEAR) )\n", "(commune_pot_EW/1e6).to_csv( outfile )" ] }, { "cell_type": "markdown", "id": "accessible-strain", "metadata": {}, "source": [ "# Scenarios:" ] }, { "cell_type": "code", "execution_count": 36, "id": "engaging-tracy", "metadata": { "scrolled": false }, "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", "
available_areaBFS_NUMMERsuitableGt_kWh_m2EPV_kWhEPV_cumsum_TWh
DF_UID
686769578533.9870015922.011076.406011923870.00.011924
684322648406.9951785919.011172.56087974506.50.019898
686216044153.6871305938.011120.89436962978.50.026861
871241246188.6418192534.011043.64946785268.50.033647
630548239787.4966762053.011173.70756531450.50.040178
\n", "
" ], "text/plain": [ " available_area BFS_NUMMER suitable Gt_kWh_m2 EPV_kWh \\\n", "DF_UID \n", "6867695 78533.987001 5922.0 1 1076.4060 11923870.0 \n", "6843226 48406.995178 5919.0 1 1172.5608 7974506.5 \n", "6862160 44153.687130 5938.0 1 1120.8943 6962978.5 \n", "8712412 46188.641819 2534.0 1 1043.6494 6785268.5 \n", "6305482 39787.496676 2053.0 1 1173.7075 6531450.5 \n", "\n", " EPV_cumsum_TWh \n", "DF_UID \n", "6867695 0.011924 \n", "6843226 0.019898 \n", "6862160 0.026861 \n", "8712412 0.033647 \n", "6305482 0.040178 " ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scenarios.head()" ] }, { "cell_type": "code", "execution_count": 38, "id": "suffering-oliver", "metadata": {}, "outputs": [], "source": [ "def aggregate_scenario_to_communes(roofs_base, roofs_flat_EW, PV_hourly_base, PV_hourly_EW, DF_UID_scenario,\n", " MIN_AREA = 8):\n", " # Select all roofs in DF_UID_scenario for the EW option for flat roofs and all roofs < 10° considered flat \n", " # All roofs in DF_UID_scenario are considered suitable except those with an available area < MIN_AREA\n", " # IMPORTANT: the roofs_base and roofs_flat_EW must have the DF_UID as index,\n", " # and the BFS_NUMMER as commune ID and the available_area as attributes\n", " \n", " commune_pot_EW = {}\n", " suitable_DF_UIDs_commune = lambda roofs, communeID: roofs[ (roofs.BFS_NUMMER == communeID) \n", " & (roofs.available_area >= MIN_AREA)\n", " & (roofs.index.isin( DF_UID_scenario )) ].index\n", " commune_IDs = roofs_base.BFS_NUMMER.unique()\n", "\n", " tt = time.time()\n", " for i, commune in enumerate(commune_IDs):\n", "\n", " # Baseline scenario\n", " DF_UIDs = suitable_DF_UIDs_commune( roofs_base, commune ) \n", " commune_pot_base = PV_hourly_base.sel(DF_UID = DF_UIDs).pv_potential.sum(dim = 'DF_UID').to_series()\n", "\n", " # Baseline scenario (flat roofs only)\n", " DF_UIDs_flat = roofs_flat_EW[ roofs_flat_EW.index.isin( DF_UIDs ) ].index\n", " commune_pot_flat_base = PV_hourly_base.sel(DF_UID = DF_UIDs_flat).pv_potential.sum(dim = 'DF_UID').to_series()\n", "\n", " # EW scenario (flat roofs only)\n", " DF_UIDs_flat_EW = suitable_DF_UIDs_commune( roofs_flat_EW, commune ) \n", " commune_pot_flat_EW = PV_hourly_EW.sel( DF_UID = DF_UIDs_flat_EW).pv_potential.sum(dim = 'DF_UID').to_series()\n", "\n", " commune_pot_EW[commune] = commune_pot_base - commune_pot_flat_base + commune_pot_flat_EW\n", "\n", " if ((i+1) % 20) == 0:\n", " print('Processed commune %d of %d in %.2fs' %((i+1), len( commune_IDs ), time.time()-tt))\n", " tt = time.time()\n", "\n", " # Merge all commune potentials\n", " return pd.DataFrame(commune_pot_EW) / 1e6 " ] }, { "cell_type": "code", - "execution_count": 39, + "execution_count": null, "id": "exterior-perception", + "metadata": { + "scrolled": false + }, + "outputs": [], + "source": [ + "for target_PV in [15, 25, 35]:\n", + " tt = time.time()\n", + " scenario_UIDs = scenarios[scenarios.EPV_cumsum_TWh <= target_PV].index.values\n", + " \n", + " commune_PV_scenario = aggregate_scenario_to_communes( roofs, roofs_EW, \n", + " PV_hourly_base, PV_hourly_EW, scenario_UIDs )\n", + " \n", + " outfile = ( os.path.join( SCENARIO_FP, '%d_PV_communes_%d_TWh.csv' %(YEAR, target_PV) ) )\n", + " commune_PV_scenario.to_csv( outfile )\n", + " print('Computed and saved %s in %.2fs' %(outfile, time.time()-tt))" + ] + }, + { + "cell_type": "markdown", + "id": "mature-feeding", "metadata": {}, + "source": [ + "# CHECK AND POSTPROCESS RESULTS" + ] + }, + { + "cell_type": "markdown", + "id": "toxic-devil", + "metadata": {}, + "source": [ + "## CORRECT ALL TIMESTAMPS" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "municipal-collapse", + "metadata": { + "scrolled": true + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Processed commune 20 of 2309 in 55.33s\n", - "Processed commune 40 of 2309 in 50.15s\n", - "Processed commune 60 of 2309 in 46.93s\n", - "Processed commune 80 of 2309 in 37.45s\n", - "Processed commune 100 of 2309 in 67.89s\n" + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2010-01-01 08:00:00 0.401085 0.056092 0.202465 0.140103 0.075368\n", + "2010-01-01 09:00:00 1.164141 0.164486 0.576082 0.451822 0.242240\n", + "2010-01-01 10:00:00 1.203159 0.166736 0.596952 0.491640 0.262022\n", + "2010-01-01 11:00:00 0.813273 0.108335 0.399956 0.333870 0.166874\n", + "2010-01-01 12:00:00 0.740450 0.101305 0.377458 0.364116 0.146045\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2010_PV_communes_all.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2010-01-01 08:00:00 0.139721 0.004495 0.044514 0.029658 0.022811\n", + "2010-01-01 09:00:00 0.401282 0.012763 0.126100 0.093042 0.070956\n", + "2010-01-01 10:00:00 0.412992 0.012868 0.129441 0.100378 0.076367\n", + "2010-01-01 11:00:00 0.276653 0.008163 0.086204 0.067542 0.048346\n", + "2010-01-01 12:00:00 0.251024 0.007273 0.085982 0.073015 0.042226\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2010_PV_communes_15_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2010-01-01 08:00:00 0.219235 0.015912 0.094669 0.064531 0.037062\n", + "2010-01-01 09:00:00 0.632191 0.045770 0.265181 0.205052 0.117075\n", + "2010-01-01 10:00:00 0.650347 0.045894 0.272667 0.221941 0.125833\n", + "2010-01-01 11:00:00 0.435883 0.029551 0.181943 0.149883 0.079845\n", + "2010-01-01 12:00:00 0.394644 0.027337 0.176000 0.162264 0.069758\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2010_PV_communes_25_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2010-01-01 08:00:00 0.325245 0.040503 0.159367 0.103943 0.057621\n", + "2010-01-01 09:00:00 0.939520 0.117666 0.449473 0.331565 0.183338\n", + "2010-01-01 10:00:00 0.967615 0.117847 0.462805 0.359263 0.197160\n", + "2010-01-01 11:00:00 0.651655 0.076074 0.309021 0.243037 0.125143\n", + "2010-01-01 12:00:00 0.592996 0.071173 0.293311 0.263924 0.109422\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2010_PV_communes_35_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2016-01-01 08:00:00 1.758777 0.231467 0.900034 0.932055 0.403170\n", + "2016-01-01 09:00:00 3.832418 0.521839 1.896139 1.218903 0.603852\n", + "2016-01-01 10:00:00 4.478135 0.636215 2.429833 1.297116 0.601701\n", + "2016-01-01 11:00:00 5.912643 0.813390 3.180205 1.603402 0.922647\n", + "2016-01-01 12:00:00 6.161373 0.832591 3.041107 1.077894 0.818499\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2016_PV_communes_all.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2016-01-01 08:00:00 0.522388 0.017544 0.185117 0.162322 0.104965\n", + "2016-01-01 09:00:00 1.256816 0.034911 0.408935 0.240545 0.168133\n", + "2016-01-01 10:00:00 1.540767 0.042586 0.515152 0.266938 0.175489\n", + "2016-01-01 11:00:00 2.048467 0.053153 0.677064 0.336474 0.263489\n", + "2016-01-01 12:00:00 2.143245 0.054894 0.629980 0.230919 0.227330\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2016_PV_communes_15_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2016-01-01 08:00:00 0.894772 0.071482 0.454805 0.382917 0.187671\n", + "2016-01-01 09:00:00 2.048104 0.153237 0.917248 0.540140 0.292212\n", + "2016-01-01 10:00:00 2.441250 0.185171 1.149586 0.590217 0.293561\n", + "2016-01-01 11:00:00 3.246967 0.238535 1.517805 0.742061 0.452038\n", + "2016-01-01 12:00:00 3.409071 0.245463 1.441528 0.512996 0.399065\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2016_PV_communes_25_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2016-01-01 08:00:00 1.424100 0.179998 0.751585 0.690364 0.318581\n", + "2016-01-01 09:00:00 3.158933 0.399646 1.566436 0.913073 0.472970\n", + "2016-01-01 10:00:00 3.716360 0.484625 2.001229 0.968715 0.463363\n", + "2016-01-01 11:00:00 4.949354 0.624556 2.646840 1.205334 0.722323\n", + "2016-01-01 12:00:00 5.168808 0.639755 2.529564 0.817251 0.643744\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2016_PV_communes_35_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2017-01-01 08:00:00 1.941675 0.244167 0.945904 1.068332 0.459955\n", + "2017-01-01 09:00:00 4.234482 0.580368 2.173382 2.049036 0.997748\n", + "2017-01-01 10:00:00 6.083260 0.831546 3.106133 2.815748 1.423663\n", + "2017-01-01 11:00:00 7.183801 0.961171 3.669805 3.304552 1.682798\n", + "2017-01-01 12:00:00 7.293878 0.965039 3.743707 3.318602 1.715047\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2017_PV_communes_all.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2017-01-01 08:00:00 0.571949 0.018838 0.192838 0.181782 0.118060\n", + "2017-01-01 09:00:00 1.371867 0.038077 0.471620 0.391441 0.269552\n", + "2017-01-01 10:00:00 2.081174 0.053435 0.702161 0.590688 0.403140\n", + "2017-01-01 11:00:00 2.496082 0.061117 0.823975 0.707763 0.476034\n", + "2017-01-01 12:00:00 2.533651 0.058868 0.821198 0.712047 0.479191\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2017_PV_communes_15_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2017-01-01 08:00:00 0.985623 0.076213 0.481377 0.433417 0.213187\n", + "2017-01-01 09:00:00 2.252107 0.172403 1.064905 0.885186 0.482897\n", + "2017-01-01 10:00:00 3.333039 0.245204 1.532742 1.296301 0.707022\n", + "2017-01-01 11:00:00 3.970631 0.283417 1.805473 1.539809 0.840101\n", + "2017-01-01 12:00:00 4.031252 0.286061 1.833543 1.548253 0.858520\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2017_PV_communes_25_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2017-01-01 08:00:00 1.572168 0.190809 0.793717 0.790996 0.365624\n", + "2017-01-01 09:00:00 3.495904 0.448881 1.812123 1.543845 0.797774\n", + "2017-01-01 10:00:00 5.099389 0.645156 2.605747 2.182861 1.147001\n", + "2017-01-01 11:00:00 6.056603 0.745851 3.088106 2.566463 1.361562\n", + "2017-01-01 12:00:00 6.150407 0.747512 3.153779 2.572082 1.393616\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2017_PV_communes_35_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2018-01-01 08:00:00 1.636478 0.170674 0.665772 0.735138 0.376623\n", + "2018-01-01 09:00:00 3.418323 0.373668 1.284704 1.436628 0.658652\n", + "2018-01-01 10:00:00 5.031509 0.674925 2.429542 2.414174 1.082087\n", + "2018-01-01 11:00:00 6.074809 0.846555 3.242469 2.933829 1.461862\n", + "2018-01-01 12:00:00 5.463978 0.708292 2.755114 2.507379 1.318279\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2018_PV_communes_all.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2018-01-01 08:00:00 0.494437 0.011853 0.146090 0.132909 0.100108\n", + "2018-01-01 09:00:00 1.117743 0.024066 0.308783 0.279054 0.183846\n", + "2018-01-01 10:00:00 1.728149 0.043920 0.566388 0.501539 0.310157\n", + "2018-01-01 11:00:00 2.114725 0.054757 0.728137 0.624372 0.416258\n", + "2018-01-01 12:00:00 1.889376 0.044718 0.609174 0.532694 0.371369\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2018_PV_communes_15_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2018-01-01 08:00:00 0.837434 0.050304 0.335945 0.307675 0.176317\n", + "2018-01-01 09:00:00 1.818892 0.106052 0.643629 0.623224 0.318628\n", + "2018-01-01 10:00:00 2.750627 0.195733 1.204365 1.098594 0.534082\n", + "2018-01-01 11:00:00 3.350614 0.247352 1.584405 1.359962 0.726564\n", + "2018-01-01 12:00:00 2.998912 0.205657 1.335375 1.160761 0.654885\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2018_PV_communes_25_TWh.csv\n" ] }, { - "ename": "KeyboardInterrupt", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m commune_PV_scenario = aggregate_scenario_to_communes( roofs, roofs_EW, \n\u001b[0;32m----> 6\u001b[0;31m PV_hourly_base, PV_hourly_EW, scenario_UIDs )\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0moutfile\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mSCENARIO_FP\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'MMH_PV_communes_%d_TWh.csv'\u001b[0m \u001b[0;34m%\u001b[0m\u001b[0mtarget_PV\u001b[0m \u001b[0;34m)\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36maggregate_scenario_to_communes\u001b[0;34m(roofs_base, roofs_flat_EW, PV_hourly_base, PV_hourly_EW, DF_UID_scenario, MIN_AREA)\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;31m# EW scenario (flat roofs only)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0mDF_UIDs_flat_EW\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msuitable_DF_UIDs_commune\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mroofs_flat_EW\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcommune\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 27\u001b[0;31m \u001b[0mcommune_pot_flat_EW\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPV_hourly_EW\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msel\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mDF_UID\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mDF_UIDs_flat_EW\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpv_potential\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdim\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'DF_UID'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_series\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 28\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0mcommune_pot_EW\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mcommune\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcommune_pot_base\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mcommune_pot_flat_base\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mcommune_pot_flat_EW\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/xarray/core/dataarray.py\u001b[0m in \u001b[0;36mto_series\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 2688\u001b[0m \"\"\"\n\u001b[1;32m 2689\u001b[0m \u001b[0mindex\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcoords\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2690\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSeries\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2691\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2692\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mto_masked_array\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMaskedArray\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/xarray/core/dataarray.py\u001b[0m in \u001b[0;36mvalues\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 632\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 633\u001b[0m \u001b[0;34m\"\"\"The array's data as a numpy.ndarray\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 634\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvariable\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 635\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 636\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msetter\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/xarray/core/variable.py\u001b[0m in \u001b[0;36mvalues\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 552\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 553\u001b[0m \u001b[0;34m\"\"\"The variable's data as a numpy.ndarray\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 554\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_as_array_or_item\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_data\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 555\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 556\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msetter\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/xarray/core/variable.py\u001b[0m in \u001b[0;36m_as_array_or_item\u001b[0;34m(data)\u001b[0m\n\u001b[1;32m 285\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 286\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 287\u001b[0;31m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 288\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 289\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkind\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"M\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/core/_asarray.py\u001b[0m in \u001b[0;36masarray\u001b[0;34m(a, dtype, order)\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 82\u001b[0m \"\"\"\n\u001b[0;32m---> 83\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0morder\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 84\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 85\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/array/core.py\u001b[0m in \u001b[0;36m__array__\u001b[0;34m(self, dtype, **kwargs)\u001b[0m\n\u001b[1;32m 1481\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1482\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__array__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1483\u001b[0;31m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcompute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1484\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdtype\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdtype\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1485\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mastype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/base.py\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 281\u001b[0m \u001b[0mdask\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcompute\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 282\u001b[0m \"\"\"\n\u001b[0;32m--> 283\u001b[0;31m \u001b[0;34m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcompute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtraverse\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 284\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 285\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/base.py\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 563\u001b[0m \u001b[0mpostcomputes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__dask_postcompute__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 564\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 565\u001b[0;31m \u001b[0mresults\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mschedule\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdsk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkeys\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 566\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mrepack\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpostcomputes\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 567\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/threaded.py\u001b[0m in \u001b[0;36mget\u001b[0;34m(dsk, result, cache, num_workers, pool, **kwargs)\u001b[0m\n\u001b[1;32m 82\u001b[0m \u001b[0mget_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0m_thread_get_id\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0mpack_exception\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpack_exception\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 84\u001b[0;31m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 85\u001b[0m )\n\u001b[1;32m 86\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/local.py\u001b[0m in \u001b[0;36mget_async\u001b[0;34m(apply_async, num_workers, dsk, result, cache, get_id, rerun_exceptions_locally, pack_exception, raise_exception, callbacks, dumps, loads, **kwargs)\u001b[0m\n\u001b[1;32m 474\u001b[0m \u001b[0;31m# Main loop, wait on tasks to finish, insert new ones\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 475\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0mstate\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"waiting\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mstate\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"ready\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mstate\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"running\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 476\u001b[0;31m \u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mres_info\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfailed\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mqueue_get\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mqueue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 477\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mfailed\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 478\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mloads\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mres_info\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/site-packages/dask/local.py\u001b[0m in \u001b[0;36mqueue_get\u001b[0;34m(q)\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 132\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mqueue_get\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 133\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 134\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 135\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/queue.py\u001b[0m in \u001b[0;36mget\u001b[0;34m(self, block, timeout)\u001b[0m\n\u001b[1;32m 168\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 169\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_qsize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 170\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnot_empty\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwait\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 171\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 172\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"'timeout' must be a non-negative number\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/miniconda3/envs/py3_all/lib/python3.7/threading.py\u001b[0m in \u001b[0;36mwait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 294\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# restore state no matter what (e.g., KeyboardInterrupt)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 295\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 296\u001b[0;31m \u001b[0mwaiter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0macquire\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 297\u001b[0m \u001b[0mgotit\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 298\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyboardInterrupt\u001b[0m: " + "name": "stdout", + "output_type": "stream", + "text": [ + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2018-01-01 08:00:00 1.323934 0.130142 0.550955 0.545291 0.297267\n", + "2018-01-01 09:00:00 2.806052 0.280159 1.056126 1.070717 0.517034\n", + "2018-01-01 10:00:00 4.191119 0.516053 2.021608 1.850436 0.859753\n", + "2018-01-01 11:00:00 5.090479 0.649787 2.705386 2.260693 1.172253\n", + "2018-01-01 12:00:00 4.560279 0.537019 2.283488 1.918774 1.056977\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2018_PV_communes_35_TWh.csv\n", + " time 2823.0 2887.0 2886.0 2869.0\n", + "0 2019-01-01 08:00:00 0.728006 0.097477 0.337424 0.196788\n", + "1 2019-01-01 09:00:00 1.118406 0.118843 0.396026 0.340598\n", + "2 2019-01-01 10:00:00 0.619173 0.069453 0.254603 0.239012\n", + "3 2019-01-01 11:00:00 0.289316 0.047697 0.187637 0.135651\n", + "4 2019-01-01 12:00:00 0.289533 0.037838 0.142366 0.130284\n", + "Skipping /work/hyenergy/output/solar_potential/scenarios_2050/2019_PV_communes_all.csv\n", + " time 2823.0 2887.0 2886.0 2869.0\n", + "0 2019-01-01 08:00:00 0.242089 0.007435 0.073478 0.040055\n", + "1 2019-01-01 09:00:00 0.372501 0.009003 0.087081 0.068663\n", + "2 2019-01-01 10:00:00 0.207364 0.005351 0.051829 0.048368\n", + "3 2019-01-01 11:00:00 0.098617 0.003629 0.037851 0.027327\n", + "4 2019-01-01 12:00:00 0.098673 0.002675 0.032456 0.026205\n", + "Skipping /work/hyenergy/output/solar_potential/scenarios_2050/2019_PV_communes_15_TWh.csv\n", + " time 2823.0 2887.0 2886.0 2869.0\n", + "0 2019-01-01 08:00:00 0.389016 0.027663 0.159259 0.090217\n", + "1 2019-01-01 09:00:00 0.595579 0.032684 0.182408 0.152863\n", + "2 2019-01-01 10:00:00 0.330270 0.019116 0.112700 0.106600\n", + "3 2019-01-01 11:00:00 0.155142 0.013159 0.082783 0.060791\n", + "4 2019-01-01 12:00:00 0.155045 0.010171 0.066442 0.058232\n", + "Skipping /work/hyenergy/output/solar_potential/scenarios_2050/2019_PV_communes_25_TWh.csv\n", + " time 2823.0 2887.0 2886.0 2869.0\n", + "0 2019-01-01 08:00:00 0.590709 0.071720 0.268689 0.146768\n", + "1 2019-01-01 09:00:00 0.905409 0.084761 0.308746 0.249402\n", + "2 2019-01-01 10:00:00 0.501988 0.048849 0.195601 0.174158\n", + "3 2019-01-01 11:00:00 0.231917 0.033519 0.143885 0.098727\n", + "4 2019-01-01 12:00:00 0.231985 0.026569 0.110635 0.094625\n", + "Skipping /work/hyenergy/output/solar_potential/scenarios_2050/2019_PV_communes_35_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2020-01-01 08:00:00 1.923827 0.242412 0.940110 1.081695 0.461322\n", + "2020-01-01 09:00:00 4.270090 0.582917 2.193787 2.072125 1.012027\n", + "2020-01-01 10:00:00 6.147459 0.836935 3.126982 2.825039 1.438667\n", + "2020-01-01 11:00:00 7.212720 0.966796 3.675542 3.298008 1.700230\n", + "2020-01-01 12:00:00 7.291962 0.966838 3.724036 3.310389 1.711270\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2020_PV_communes_all.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2020-01-01 08:00:00 0.567446 0.018721 0.191653 0.183186 0.119120\n", + "2020-01-01 09:00:00 1.383686 0.038070 0.476539 0.395575 0.274837\n", + "2020-01-01 10:00:00 2.102304 0.053816 0.706785 0.592959 0.408903\n", + "2020-01-01 11:00:00 2.502070 0.061571 0.826641 0.706335 0.481310\n", + "2020-01-01 12:00:00 2.531916 0.059002 0.820421 0.709902 0.478507\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2020_PV_communes_15_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2020-01-01 08:00:00 0.976792 0.075713 0.479050 0.437290 0.214435\n", + "2020-01-01 09:00:00 2.271336 0.173349 1.076670 0.894962 0.491113\n", + "2020-01-01 10:00:00 3.369663 0.247036 1.543744 1.301484 0.715893\n", + "2020-01-01 11:00:00 3.983614 0.285058 1.809932 1.538093 0.848829\n", + "2020-01-01 12:00:00 4.028150 0.286507 1.827640 1.544997 0.856986\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2020_PV_communes_25_TWh.csv\n", + " 2823.0 2887.0 2886.0 2869.0 2863.0\n", + "time \n", + "2020-01-01 08:00:00 1.557884 0.189660 0.789426 0.800430 0.367319\n", + "2020-01-01 09:00:00 3.527282 0.451196 1.831393 1.562149 0.810494\n", + "2020-01-01 10:00:00 5.156467 0.649932 2.624826 2.191260 1.160540\n", + "2020-01-01 11:00:00 6.079169 0.750071 3.093598 2.561829 1.375358\n", + "2020-01-01 12:00:00 6.149002 0.749003 3.138964 2.565229 1.390407\n", + "Saved /work/hyenergy/output/solar_potential/scenarios_2050/2020_PV_communes_35_TWh.csv\n" ] } ], "source": [ - "for target_PV in [15, 25, 35]:\n", - " tt = time.time()\n", - " scenario_UIDs = scenarios[scenarios.EPV_cumsum_TWh <= target_PV].index.values\n", + "for year in [2010, 2016, 2017, 2018, 2019, 2020]:\n", " \n", - " commune_PV_scenario = aggregate_scenario_to_communes( roofs, roofs_EW, \n", - " PV_hourly_base, PV_hourly_EW, scenario_UIDs )\n", - " \n", - " outfile = ( os.path.join( SCENARIO_FP, '%d_PV_communes_%d_TWh.csv' %(YEAR, target_PV) ) )\n", - " commune_PV_scenario.to_csv( outfile )\n", - " print('Computed and saved %s in %.2fs' %(outfile, time.time()-tt))" + " # Load the original hourly commune aggregate of year to get the correct timestamp\n", + " time_EW = pd.read_csv(os.path.join(PV_FP, '%d_commune_hourly_pv_EW.csv' %year), usecols = [0])\n", + " time_EW['time' ] = pd.to_datetime(time_EW.time)\n", + " time_EW['day' ] = time_EW['time'].dt.day\n", + " time_EW['hour' ] = time_EW['time'].dt.hour\n", + " time_EW['month'] = time_EW['time'].dt.month\n", + "\n", + " hourly_timestamp = time_EW.set_index(['month','day','hour'])\n", + "\n", + " for scenario in ['all', '15_TWh', '25_TWh', '35_TWh']:\n", + " file = os.path.join(SCENARIO_FP, '%d_PV_communes_%s.csv' %(year,scenario))\n", + " \n", + " # load commune data\n", + " communes = pd.read_csv( file )\n", + " \n", + " if 'time' in communes.columns:\n", + " print(communes.iloc[:,:5].head())\n", + " print('Skipping %s' %file)\n", + " continue\n", + " \n", + " communes['timestamp'] = pd.to_datetime( communes['timestamp'] )\n", + " \n", + " # Extract hour and month to concatenate real timestamp\n", + " communes['hour' ] = communes['timestamp'].dt.hour\n", + " communes['month'] = communes['timestamp'].dt.month\n", + " \n", + " communes = communes.drop(columns = 'timestamp').set_index(['month','day','hour'])\n", + " \n", + " # Set the correct timestamp\n", + " commune_corrected = pd.concat([communes, hourly_timestamp], \n", + " axis = 1).dropna(subset = ['time']).set_index('time')\n", + " \n", + " commune_corrected.to_csv(file)\n", + " print(commune_corrected.iloc[:,:5].head())\n", + " print('Saved %s' %file)" + ] + }, + { + "cell_type": "markdown", + "id": "right-begin", + "metadata": {}, + "source": [ + "## CHECK ALL FILES" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "loving-therapy", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/walch/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/lib/arraysetops.py:580: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n", + " mask |= (ar1 == a)\n" + ] + } + ], + "source": [ + "scenarios = pd.read_csv(os.path.join( SCENARIO_FP, 'MMH_cumsum_for_scenarios.csv' ), index_col = 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "solid-faculty", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sum of annual totals (2020, all): 43.3503\n", + "Sum of hourly communes (2020, all): 43.3503\n", + "\n", + "Sum of annual totals (2020, 15_TWh): 15.6342\n", + "Sum of hourly communes (2020, 15_TWh): 15.6342\n", + "\n", + "Sum of annual totals (2020, 25_TWh): 26.0191\n", + "Sum of hourly communes (2020, 25_TWh): 26.0191\n", + "\n", + "Sum of annual totals (2020, 35_TWh): 36.3744\n", + "Sum of hourly communes (2020, 35_TWh): 36.3744\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/walch/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/lib/arraysetops.py:580: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n", + " mask |= (ar1 == a)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sum of annual totals (2019, all): 42.4116\n", + "Sum of hourly communes (2019, all): 42.4116\n", + "\n", + "Sum of annual totals (2019, 15_TWh): 15.2966\n", + "Sum of hourly communes (2019, 15_TWh): 15.2966\n", + "\n", + "Sum of annual totals (2019, 25_TWh): 25.4562\n", + "Sum of hourly communes (2019, 25_TWh): 25.4562\n", + "\n", + "Sum of annual totals (2019, 35_TWh): 35.5901\n", + "Sum of hourly communes (2019, 35_TWh): 35.5901\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/walch/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/lib/arraysetops.py:580: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n", + " mask |= (ar1 == a)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sum of annual totals (2018, all): 42.8350\n", + "Sum of hourly communes (2018, all): 42.8350\n", + "\n", + "Sum of annual totals (2018, 15_TWh): 15.4201\n", + "Sum of hourly communes (2018, 15_TWh): 15.4201\n", + "\n", + "Sum of annual totals (2018, 25_TWh): 25.6637\n", + "Sum of hourly communes (2018, 25_TWh): 25.6637\n", + "\n", + "Sum of annual totals (2018, 35_TWh): 35.9041\n", + "Sum of hourly communes (2018, 35_TWh): 35.9041\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/walch/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/lib/arraysetops.py:580: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n", + " mask |= (ar1 == a)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sum of annual totals (2017, all): 43.2124\n", + "Sum of hourly communes (2017, all): 43.2124\n", + "\n", + "Sum of annual totals (2017, 15_TWh): 15.6041\n", + "Sum of hourly communes (2017, 15_TWh): 15.6041\n", + "\n", + "Sum of annual totals (2017, 25_TWh): 25.9413\n", + "Sum of hourly communes (2017, 25_TWh): 25.9413\n", + "\n", + "Sum of annual totals (2017, 35_TWh): 36.2524\n", + "Sum of hourly communes (2017, 35_TWh): 36.2524\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/walch/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/lib/arraysetops.py:580: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n", + " mask |= (ar1 == a)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sum of annual totals (2016, all): 39.5194\n", + "Sum of hourly communes (2016, all): 39.5194\n", + "\n", + "Sum of annual totals (2016, 15_TWh): 14.2193\n", + "Sum of hourly communes (2016, 15_TWh): 14.2193\n", + "\n", + "Sum of annual totals (2016, 25_TWh): 23.6716\n", + "Sum of hourly communes (2016, 25_TWh): 23.6716\n", + "\n", + "Sum of annual totals (2016, 35_TWh): 33.1307\n", + "Sum of hourly communes (2016, 35_TWh): 33.1307\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/walch/miniconda3/envs/py3_all/lib/python3.7/site-packages/numpy/lib/arraysetops.py:580: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n", + " mask |= (ar1 == a)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sum of annual totals (2010, all): 38.0644\n", + "Sum of hourly communes (2010, all): 38.0644\n", + "\n", + "Sum of annual totals (2010, 15_TWh): 13.7124\n", + "Sum of hourly communes (2010, 15_TWh): 13.7124\n", + "\n", + "Sum of annual totals (2010, 25_TWh): 22.8092\n", + "Sum of hourly communes (2010, 25_TWh): 22.8092\n", + "\n", + "Sum of annual totals (2010, 35_TWh): 31.9057\n", + "Sum of hourly communes (2010, 35_TWh): 31.9057\n", + "\n" + ] + } + ], + "source": [ + "for year in [2020, 2019, 2018, 2017, 2016, 2010]:\n", + " roofs_EW = pd.read_csv(os.path.join(PV_FP, '%d_annual_roofs_flat_EW.csv' %(year)), index_col = 0)\n", + " roofs = pd.read_csv(os.path.join(PV_FP, '%d_annual_roofs.csv' %(year)), index_col = 0)\n", + "\n", + " annual_EW = roofs.copy()\n", + " annual_EW.loc[ roofs_EW.index ] = roofs_EW.copy()\n", + "\n", + " for scenario in ['all', '15_TWh', '25_TWh', '35_TWh']:\n", + " communes = pd.read_csv( os.path.join(SCENARIO_FP, '%d_PV_communes_%s.csv' %(year,scenario)), \n", + " index_col = [0] )\n", + "\n", + " if scenario == 'all':\n", + " UUID = annual_EW[annual_EW.available_area >= 8].index.values\n", + " else:\n", + " scenario_TWh = int(scenario.split('_')[0])\n", + " UUID = scenarios[scenarios.EPV_cumsum_TWh <= scenario_TWh].index.values\n", + "\n", + " annual_sum = ( annual_EW[annual_EW.available_area >= 8].loc[UUID]\n", + " .dropna(subset = ['BFS_NUMMER']).EPV_kWh.sum() / 1e9 )\n", + " commune_sum = communes.sum().sum() / 1e6\n", + " print('Sum of annual totals (%d, %s): %.4f' %(year, scenario, annual_sum))\n", + " print('Sum of hourly communes (%d, %s): %.4f\\n' %(year, scenario, commune_sum))" ] }, { "cell_type": "code", "execution_count": null, - "id": "southern-fellow", + "id": "continued-fitting", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.7" } }, "nbformat": 4, "nbformat_minor": 5 } diff --git a/PV_scenarios_2050/Scenarios_hourly.py b/PV_scenarios_2050/Scenarios_hourly.py index d1e3e5f..52a3281 100644 --- a/PV_scenarios_2050/Scenarios_hourly.py +++ b/PV_scenarios_2050/Scenarios_hourly.py @@ -1,145 +1,137 @@ #!/usr/bin/env python # coding: utf-8 # In[1]: import pandas as pd import numpy as np import xarray as xr -from demand_mapping import get_yearly_sum - import os import time import sys ### INPUTS YEAR = int(sys.argv[1]) ### FILE PATHS SCENARIO_FP = '/work/hyenergy/output/solar_potential/scenarios_2050' PV_FP = '/work/hyenergy/output/solar_potential/hourly_potential/' hourly_FP_EW = '/scratch/walch/workdir_solar_EW_scenarios' hourly_FP = '/scratch/walch/workdir_solar_hourly' # # Load data # Load base scenario and EW roofs roofs_EW = pd.read_csv(os.path.join(PV_FP, '%d_annual_roofs_flat_EW.csv' %(YEAR)), index_col = 0) roofs = pd.read_csv(os.path.join(PV_FP, '%d_annual_roofs.csv' %(YEAR)), index_col = 0) # Create annual dataset of full EW scenario annual_EW = roofs.copy() annual_EW.loc[ roofs_EW.index ] = roofs_EW.copy() # Load hourly data PV_hourly_EW = xr.open_mfdataset(os.path.join( hourly_FP_EW, 'tmp_%d' %YEAR, 'pv_potential_*.nc'), chunks = {'DF_UID' : 10000}) PV_hourly_base = xr.open_mfdataset(os.path.join( hourly_FP, 'tmp_%d' %YEAR, 'pv_potential_*.nc'), chunks = {'DF_UID' : 10000}) # Load scenario file scenarios = pd.read_csv(os.path.join( SCENARIO_FP, 'MMH_cumsum_for_scenarios.csv' ), index_col = 0) # # Loop over communes (scenario: all roofs) # SCENARIO DEFINITION MIN_AREA = 8 # no restriction for roof tilt and roof aspect commune_pot_EW = {} tt = time.time() for i, commune in enumerate(roofs.BFS_NUMMER.unique()): # Baseline scenario DF_UIDs = roofs[(roofs.BFS_NUMMER == commune) & (roofs.available_area >= MIN_AREA)].index commune_pot_base = PV_hourly_base.sel(DF_UID = DF_UIDs).pv_potential.sum(dim = 'DF_UID').to_series() # Baseline scenario (flat roofs only) DF_UIDs_flat = roofs_EW[roofs_EW.index.isin( DF_UIDs )].index commune_pot_flat_base = PV_hourly_base.sel(DF_UID = DF_UIDs_flat).pv_potential.sum(dim = 'DF_UID').to_series() # EW scenario (flat roofs only) DF_UIDs_flat_EW = roofs_EW[(roofs_EW.BFS_NUMMER == commune) & (roofs_EW.available_area >= MIN_AREA)].index commune_pot_flat_EW = PV_hourly_EW.sel(DF_UID = DF_UIDs_flat_EW).pv_potential.sum(dim = 'DF_UID').to_series() commune_pot_EW[commune] = commune_pot_base - commune_pot_flat_base + commune_pot_flat_EW if ((i+1) % 50) == 0: print('Processed commune %d of %d in %.2fs' %((i+1), len( roofs.BFS_NUMMER.unique()), time.time()-tt)) tt = time.time() # Merge all commune potentials commune_pot_EW = pd.DataFrame(commune_pot_EW) - -# ## Verify coherence with annual data - -print(annual_EW[annual_EW.available_area >= 8].dropna(subset = ['BFS_NUMMER']).EPV_kWh.sum() / 1e9) -print(get_yearly_sum(commune_pot_EW.sum(axis = 1).to_xarray(), week_weighting = False) / 1e12) - # # Save output data outfile = ( os.path.join( SCENARIO_FP, '%d_PV_communes_all.csv' %YEAR) ) (commune_pot_EW/1e6).to_csv( outfile ) # # Scenarios: def aggregate_scenario_to_communes(roofs_base, roofs_flat_EW, PV_hourly_base, PV_hourly_EW, DF_UID_scenario, MIN_AREA = 8): # Select all roofs in DF_UID_scenario for the EW option for flat roofs and all roofs < 10° considered flat # All roofs in DF_UID_scenario are considered suitable except those with an available area < MIN_AREA # IMPORTANT: the roofs_base and roofs_flat_EW must have the DF_UID as index, # and the BFS_NUMMER as commune ID and the available_area as attributes commune_pot_EW = {} suitable_DF_UIDs_commune = lambda roofs, communeID: roofs[ (roofs.BFS_NUMMER == communeID) & (roofs.available_area >= MIN_AREA) & (roofs.index.isin( DF_UID_scenario )) ].index commune_IDs = roofs_base.BFS_NUMMER.unique() tt = time.time() for i, commune in enumerate(commune_IDs): # Baseline scenario DF_UIDs = suitable_DF_UIDs_commune( roofs_base, commune ) commune_pot_base = PV_hourly_base.sel(DF_UID = DF_UIDs).pv_potential.sum(dim = 'DF_UID').to_series() # Baseline scenario (flat roofs only) DF_UIDs_flat = roofs_flat_EW[ roofs_flat_EW.index.isin( DF_UIDs ) ].index commune_pot_flat_base = PV_hourly_base.sel(DF_UID = DF_UIDs_flat).pv_potential.sum(dim = 'DF_UID').to_series() # EW scenario (flat roofs only) DF_UIDs_flat_EW = suitable_DF_UIDs_commune( roofs_flat_EW, commune ) commune_pot_flat_EW = PV_hourly_EW.sel( DF_UID = DF_UIDs_flat_EW).pv_potential.sum(dim = 'DF_UID').to_series() commune_pot_EW[commune] = commune_pot_base - commune_pot_flat_base + commune_pot_flat_EW if ((i+1) % 20) == 0: print('Processed commune %d of %d in %.2fs' %((i+1), len( commune_IDs ), time.time()-tt)) tt = time.time() # Merge all commune potentials return pd.DataFrame(commune_pot_EW) / 1e6 for target_PV in [15, 25, 35]: tt = time.time() scenario_UIDs = scenarios[scenarios.EPV_cumsum_TWh <= target_PV].index.values commune_PV_scenario = aggregate_scenario_to_communes( roofs, roofs_EW, PV_hourly_base, PV_hourly_EW, scenario_UIDs ) outfile = ( os.path.join( SCENARIO_FP, '%d_PV_communes_%d_TWh.csv' %(YEAR, target_PV) ) ) commune_PV_scenario.to_csv( outfile ) print('Computed and saved %s in %.2fs' %(outfile, time.time()-tt)) diff --git a/PV_scenarios_2050/Scenarios_hourly.py b/PV_scenarios_2050/Scenarios_hourly_lesopbpc58.py similarity index 90% copy from PV_scenarios_2050/Scenarios_hourly.py copy to PV_scenarios_2050/Scenarios_hourly_lesopbpc58.py index d1e3e5f..6980b87 100644 --- a/PV_scenarios_2050/Scenarios_hourly.py +++ b/PV_scenarios_2050/Scenarios_hourly_lesopbpc58.py @@ -1,145 +1,137 @@ #!/usr/bin/env python # coding: utf-8 # In[1]: import pandas as pd import numpy as np import xarray as xr -from demand_mapping import get_yearly_sum - import os import time import sys ### INPUTS YEAR = int(sys.argv[1]) ### FILE PATHS -SCENARIO_FP = '/work/hyenergy/output/solar_potential/scenarios_2050' -PV_FP = '/work/hyenergy/output/solar_potential/hourly_potential/' +SCENARIO_FP = '/raid/alina/solar/scenarios_EW_2050' +PV_FP = '/raid/alina/solar/hourly_potential_results' -hourly_FP_EW = '/scratch/walch/workdir_solar_EW_scenarios' -hourly_FP = '/scratch/walch/workdir_solar_hourly' +hourly_FP_EW = '/raid/alina/solar/hourly_flat_ew' +hourly_FP = '/raid/alina/solar/hourly_base' # # Load data # Load base scenario and EW roofs roofs_EW = pd.read_csv(os.path.join(PV_FP, '%d_annual_roofs_flat_EW.csv' %(YEAR)), index_col = 0) roofs = pd.read_csv(os.path.join(PV_FP, '%d_annual_roofs.csv' %(YEAR)), index_col = 0) # Create annual dataset of full EW scenario annual_EW = roofs.copy() annual_EW.loc[ roofs_EW.index ] = roofs_EW.copy() # Load hourly data PV_hourly_EW = xr.open_mfdataset(os.path.join( hourly_FP_EW, 'tmp_%d' %YEAR, 'pv_potential_*.nc'), chunks = {'DF_UID' : 10000}) PV_hourly_base = xr.open_mfdataset(os.path.join( hourly_FP, 'tmp_%d' %YEAR, 'pv_potential_*.nc'), chunks = {'DF_UID' : 10000}) # Load scenario file scenarios = pd.read_csv(os.path.join( SCENARIO_FP, 'MMH_cumsum_for_scenarios.csv' ), index_col = 0) # # Loop over communes (scenario: all roofs) # SCENARIO DEFINITION MIN_AREA = 8 # no restriction for roof tilt and roof aspect commune_pot_EW = {} tt = time.time() for i, commune in enumerate(roofs.BFS_NUMMER.unique()): # Baseline scenario DF_UIDs = roofs[(roofs.BFS_NUMMER == commune) & (roofs.available_area >= MIN_AREA)].index commune_pot_base = PV_hourly_base.sel(DF_UID = DF_UIDs).pv_potential.sum(dim = 'DF_UID').to_series() # Baseline scenario (flat roofs only) DF_UIDs_flat = roofs_EW[roofs_EW.index.isin( DF_UIDs )].index commune_pot_flat_base = PV_hourly_base.sel(DF_UID = DF_UIDs_flat).pv_potential.sum(dim = 'DF_UID').to_series() # EW scenario (flat roofs only) DF_UIDs_flat_EW = roofs_EW[(roofs_EW.BFS_NUMMER == commune) & (roofs_EW.available_area >= MIN_AREA)].index commune_pot_flat_EW = PV_hourly_EW.sel(DF_UID = DF_UIDs_flat_EW).pv_potential.sum(dim = 'DF_UID').to_series() commune_pot_EW[commune] = commune_pot_base - commune_pot_flat_base + commune_pot_flat_EW if ((i+1) % 50) == 0: print('Processed commune %d of %d in %.2fs' %((i+1), len( roofs.BFS_NUMMER.unique()), time.time()-tt)) tt = time.time() # Merge all commune potentials commune_pot_EW = pd.DataFrame(commune_pot_EW) - -# ## Verify coherence with annual data - -print(annual_EW[annual_EW.available_area >= 8].dropna(subset = ['BFS_NUMMER']).EPV_kWh.sum() / 1e9) -print(get_yearly_sum(commune_pot_EW.sum(axis = 1).to_xarray(), week_weighting = False) / 1e12) - # # Save output data outfile = ( os.path.join( SCENARIO_FP, '%d_PV_communes_all.csv' %YEAR) ) (commune_pot_EW/1e6).to_csv( outfile ) # # Scenarios: def aggregate_scenario_to_communes(roofs_base, roofs_flat_EW, PV_hourly_base, PV_hourly_EW, DF_UID_scenario, MIN_AREA = 8): # Select all roofs in DF_UID_scenario for the EW option for flat roofs and all roofs < 10° considered flat # All roofs in DF_UID_scenario are considered suitable except those with an available area < MIN_AREA # IMPORTANT: the roofs_base and roofs_flat_EW must have the DF_UID as index, # and the BFS_NUMMER as commune ID and the available_area as attributes commune_pot_EW = {} suitable_DF_UIDs_commune = lambda roofs, communeID: roofs[ (roofs.BFS_NUMMER == communeID) & (roofs.available_area >= MIN_AREA) & (roofs.index.isin( DF_UID_scenario )) ].index commune_IDs = roofs_base.BFS_NUMMER.unique() tt = time.time() for i, commune in enumerate(commune_IDs): # Baseline scenario DF_UIDs = suitable_DF_UIDs_commune( roofs_base, commune ) commune_pot_base = PV_hourly_base.sel(DF_UID = DF_UIDs).pv_potential.sum(dim = 'DF_UID').to_series() # Baseline scenario (flat roofs only) DF_UIDs_flat = roofs_flat_EW[ roofs_flat_EW.index.isin( DF_UIDs ) ].index commune_pot_flat_base = PV_hourly_base.sel(DF_UID = DF_UIDs_flat).pv_potential.sum(dim = 'DF_UID').to_series() # EW scenario (flat roofs only) DF_UIDs_flat_EW = suitable_DF_UIDs_commune( roofs_flat_EW, commune ) commune_pot_flat_EW = PV_hourly_EW.sel( DF_UID = DF_UIDs_flat_EW).pv_potential.sum(dim = 'DF_UID').to_series() commune_pot_EW[commune] = commune_pot_base - commune_pot_flat_base + commune_pot_flat_EW if ((i+1) % 20) == 0: print('Processed commune %d of %d in %.2fs' %((i+1), len( commune_IDs ), time.time()-tt)) tt = time.time() # Merge all commune potentials return pd.DataFrame(commune_pot_EW) / 1e6 for target_PV in [15, 25, 35]: tt = time.time() scenario_UIDs = scenarios[scenarios.EPV_cumsum_TWh <= target_PV].index.values commune_PV_scenario = aggregate_scenario_to_communes( roofs, roofs_EW, PV_hourly_base, PV_hourly_EW, scenario_UIDs ) outfile = ( os.path.join( SCENARIO_FP, '%d_PV_communes_%d_TWh.csv' %(YEAR, target_PV) ) ) commune_PV_scenario.to_csv( outfile ) print('Computed and saved %s in %.2fs' %(outfile, time.time()-tt)) diff --git a/PV_scenarios_2050/re_paste_PV_data.sh b/PV_scenarios_2050/re_paste_PV_data.sh new file mode 100644 index 0000000..33012b6 --- /dev/null +++ b/PV_scenarios_2050/re_paste_PV_data.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +echo STARTING AT $(date) +echo + +TARGET_PATH=walch@fidis:/scratch/walch +SOURCE_PATH=/raid/alina/solar + +TARGET_EW=workdir_solar_EW_scenarios +SOURCE_EW=hourly_flat_ew + +TARGET_BASE=workdir_solar_hourly +SOURCE_EW=hourly_base + +for YEAR in 2010 2016 2017 2018 +do + scp $SOURCE_PATH\/$SOURCE_EW\/tmp_$YEAR\/pv_potential_*.nc $TARGET_PATH\/$TARGET_EW\/tmp_$YEAR\/. + scp $SOURCE_PATH\/$SOURCE_BASE\/tmp_$YEAR\/pv_potential_*.nc $TARGET_PATH\/$TARGET_BASE\/tmp_$YEAR\/. +done \ No newline at end of file