diff --git a/config/config.default.yaml b/config/config.default.yaml index 22a5ac2b..dfd57a72 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -42,7 +42,7 @@ scenario: ll: - vopt clusters: - - 38 + - 39 - 128 - 256 opts: @@ -56,7 +56,7 @@ scenario: - 2050 # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#countries -countries: ['AL', 'AT', 'BA', 'BE', 'BG', 'CH', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'ME', 'MK', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'SE', 'SI', 'SK'] +countries: ['AL', 'AT', 'BA', 'BE', 'BG', 'CH', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'ME', 'MK', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'SE', 'SI', 'SK', 'XK'] # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#snapshots snapshots: diff --git a/config/examples/config.entsoe-all.yaml b/config/examples/config.entsoe-all.yaml index 4e7edd03..9f52094d 100644 --- a/config/examples/config.entsoe-all.yaml +++ b/config/examples/config.entsoe-all.yaml @@ -15,7 +15,7 @@ scenario: ll: - vopt clusters: - - 39 + - 41 - 128 - 256 opts: @@ -26,7 +26,7 @@ scenario: - '' # TODO add Turkey (TR) -countries: ['AL', 'AT', 'BA', 'BE', 'BG', 'CH', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'ME', 'MD', 'MK', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'SE', 'SI', 'SK', 'UA'] +countries: ['AL', 'AT', 'BA', 'BE', 'BG', 'CH', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'ME', 'MD', 'MK', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'SE', 'SI', 'SK', 'UA', 'XK'] electricity: custom_powerplants: true diff --git a/data/district_heat_share.csv b/data/district_heat_share.csv index 07d4f51d..ad47fb3b 100644 --- a/data/district_heat_share.csv +++ b/data/district_heat_share.csv @@ -25,7 +25,7 @@ SE,50.4, GB,2, BY,70, EE,52,5406 -KO,3,207 +XK,3,207 RO,23,9962 SK,54,15000 NL,4,9800 diff --git a/data/era5-annual-HDD-per-country.csv b/data/era5-annual-HDD-per-country.csv index 5f6ad45d..4bb02806 100644 --- a/data/era5-annual-HDD-per-country.csv +++ b/data/era5-annual-HDD-per-country.csv @@ -29,6 +29,7 @@ PL,1615,1584,1275,1356,1364,1378,1517,1290,1230,1296,1249,1438,1294,1478,1446,15 PT,114,114,102,113,86,110,95,79,94,96,107,103,99,109,80,131,106,93,93,97,78,106,104,115,103,98,103,97,112,110,115,116,106,109,109,109,99,139,107,102,89,90,95,104,99,108,85,89,75,87,104,96,104,85,66,88,62,82,96,90,90,78,87,97,103,90,91,91,84,96,80,101,100,81,79,87,79,96,81,72,78,98,75 RO,931,939,801,813,874,851,839,815,799,780,736,811,883,948,822,968,810,789,826,731,744,826,890,867,873,706,791,776,858,792,787,798,838,782,752,855,772,836,780,880,801,811,763,807,917,815,882,827,710,700,846,801,848,701,806,869,842,805,740,710,760,721,844,754,799,780,684,695,695,757,793,781,709,662,681,721,720,690,624,648,740,973,611 RS,292,305,246,274,285,276,265,263,261,239,222,252,273,300,249,313,248,249,254,231,226,270,283,271,274,233,253,243,267,254,251,246,272,242,243,265,233,265,241,273,251,255,244,253,275,256,268,254,231,220,275,243,263,223,250,270,259,250,237,217,234,217,262,238,265,247,217,214,222,229,251,244,214,192,222,223,232,211,197,212,234,306,192 +XK,292,305,246,274,285,276,265,263,261,239,222,252,273,300,249,313,248,249,254,231,226,270,283,271,274,233,253,243,267,254,251,246,272,242,243,265,233,265,241,273,251,255,244,253,275,256,268,254,231,220,275,243,263,223,250,270,259,250,237,217,234,217,262,238,265,247,217,214,222,229,251,244,214,192,222,223,232,211,197,212,234,306,192 SK,221,219,199,207,209,201,212,202,189,189,178,210,195,217,208,228,192,193,185,185,178,208,213,211,219,179,187,192,203,200,192,188,195,178,178,197,188,204,193,215,191,190,180,193,212,198,207,187,172,173,202,186,191,171,186,204,193,184,177,162,184,174,190,184,191,182,163,161,170,188,175,179,174,142,161,170,176,157,152,158,180,231,150 SI,81,77,66,74,72,71,72,69,61,65,61,72,67,73,69,78,65,66,62,61,59,75,75,73,73,62,65,67,71,69,67,68,71,62,61,69,62,71,68,74,67,65,65,69,73,71,71,63,59,58,70,61,63,55,61,71,63,62,62,54,59,55,65,63,67,61,54,57,57,65,58,59,59,46,55,57,58,53,52,53,61,77,51 SE,4509,4537,3713,3939,4134,4059,4374,3918,3633,4015,3891,4219,3560,3919,4426,4488,3950,4223,3662,3988,3814,4451,4260,4021,4358,4613,3929,4280,4255,4254,4043,3806,3975,3634,3625,4238,4132,4314,4246,4287,4301,3913,3840,3819,4588,4139,4376,3931,3476,3446,3785,3695,3893,3991,3916,4073,3757,3950,3781,3446,3898,3778,3755,3769,3632,3561,3606,3590,3806,4397,3474,3935,3675,3452,3421,3635,3693,3705,3689,3247,3807,5084,3769 diff --git a/data/era5-annual-runoff-per-country.csv b/data/era5-annual-runoff-per-country.csv index 862ff743..f160f043 100644 --- a/data/era5-annual-runoff-per-country.csv +++ b/data/era5-annual-runoff-per-country.csv @@ -29,6 +29,7 @@ PL,19040.141287526196,13600.003649707409,4232.940272903036,6263.550300160282,117 PT,17389.910347609384,7956.13238827081,8339.728858321132,2075.556471824434,3081.9400195534536,5428.965709165979,13519.093138173732,8266.183051247071,2305.611210847845,4751.414112923152,8372.129135066036,5969.31083523099,2397.6586063764958,3916.9962424030286,9654.699566273128,9603.363148222781,4163.162870337118,9179.465624121007,12131.854156488425,23406.646477036124,10635.077955993413,11029.404714084018,16475.917880350513,12087.55769685171,9804.492049893286,26178.184180984652,5669.820254013018,7559.528320921835,15405.930172416956,11163.387795923936,7088.025310785357,10191.330496756716,7128.069257230898,9335.631563569985,5236.13128329125,4572.251664471752,32605.577182903042,149323.86523586328,34294.81803755196,6061.11721308257,5836.654497517657,4843.7020037722705,7814.782411245904,9395.759000250582,14057.157961109715,8192.288977642056,7655.760207241933,9203.645337709624,7637.7450966202805,7971.812432879156,7421.37678917759,2935.2871895485287,6329.939163930326,8820.796560748415,8944.109217212255,14719.27363438586,11050.779819799696,8379.75073967695,5590.525909815882,10485.131539563748,20476.028147427794,7715.162648805314,11939.81827695821,5116.2596877306005,3047.0903835389504,9273.489011971804,5135.313604526994,3331.418010762715,6338.048693933388,12105.616460835923,7097.468638389797,3348.213951094401,11773.920694867731,13465.586888738457,4379.602415677836,11394.463621230614,3104.8789319036796,7216.150544702967,6653.765864361187,5720.580737490315,6685.493238874142,8486.079863634486,8329.192253601708 RO,46545.50823036229,35517.718755954746,12007.97895282227,19448.903832688356,20440.973051620913,15132.394486734484,21523.767710605425,32075.68337603852,20312.088233477134,14653.654680967496,19346.344374357534,19295.50358149612,27702.617554877004,24644.67023787785,52797.882559506776,42262.7162454671,34689.01143849651,42583.74114324521,28973.147767939397,36882.64868179707,29063.471368254675,39575.626278602576,31898.858414072816,36283.98261870408,42207.50410750205,41714.957670180156,43270.313090823794,40474.54716426176,53565.91349208634,74865.02611452111,48190.11154819992,57257.26135564704,46523.80416861758,44300.83791323246,54901.1701096736,47361.27151969814,49156.09266449866,56461.30009557872,56062.45724028393,58506.511677323855,48499.732173446595,45901.64074770707,33171.12855766741,38310.49272614435,39377.41586450999,28638.803870927226,29424.553978129992,39429.14347226504,39300.73151290347,27525.04968129815,47095.77682827757,30948.90232192865,32939.14262154816,30155.99148400138,35067.04977301419,35592.25066656211,45790.67404045973,42596.77718301701,39223.35618808953,25767.93476452563,30963.38609617001,30034.908201595936,23323.05819720473,28517.276888551194,41560.85308154171,43999.15897330077,21427.19650317167,25084.131072037453,18450.764512377853,38182.39266803458,20422.517191285966,14090.243196787245,21998.55223596247,30809.187151501046,22071.90474198888,31906.454754357772,20763.073093214778,25620.747974742615,19248.368008063957,23289.011422937554,26669.846131314298,27207.74766143675,29386.08741874402 RS,12898.821957973714,11760.375115749226,5762.823681912337,10868.645457667955,6851.647476795101,6489.091511565737,8016.427124526303,11096.059611708006,8784.092785314235,6844.044739629848,5968.673897869134,7450.873145908507,8457.218084424714,10466.134979346216,18700.932768467817,18783.264457747777,9647.157790116991,14650.396388121844,12360.14810912279,11640.673528541236,8882.446980807292,14762.619600006037,18399.930168952076,13646.806400326906,14489.119148714197,14104.804002759012,15462.34970923992,10894.228431882033,15095.088711819322,17853.281396922546,12916.46431873845,14207.379133135786,14418.834370720482,12752.5957180177,15544.588217112372,15820.904121022999,13534.055257847373,15215.146639151637,12996.626380040323,13029.919161637963,10196.668003968522,10284.440766030819,7022.693160251435,8401.249663323453,8435.803252725058,10265.915943082338,8623.546341166757,7782.429841191159,9309.259412625106,4849.32865233776,9480.40891035497,8237.330612702019,6688.9341497267815,7113.796951355988,8945.392918392941,11391.406447517316,8770.78174795334,7797.074404297926,11205.567652241964,7490.638744688466,6890.626375097134,8721.152535625733,6986.899718851523,10014.515393386338,11863.685949406314,12576.12226693591,6930.903954576986,6933.68818306879,8436.351253425808,11680.836931112251,5673.257881932308,4512.930178739657,6094.8735580904795,11616.485592765608,8423.704814584986,9582.260510301834,6280.960312130538,10196.683253538626,5869.428152205924,6637.126459584064,8223.324863109141,9163.49600405833,11744.973584261521 +XK,12898.821957973714,11760.375115749226,5762.823681912337,10868.645457667955,6851.647476795101,6489.091511565737,8016.427124526303,11096.059611708006,8784.092785314235,6844.044739629848,5968.673897869134,7450.873145908507,8457.218084424714,10466.134979346216,18700.932768467817,18783.264457747777,9647.157790116991,14650.396388121844,12360.14810912279,11640.673528541236,8882.446980807292,14762.619600006037,18399.930168952076,13646.806400326906,14489.119148714197,14104.804002759012,15462.34970923992,10894.228431882033,15095.088711819322,17853.281396922546,12916.46431873845,14207.379133135786,14418.834370720482,12752.5957180177,15544.588217112372,15820.904121022999,13534.055257847373,15215.146639151637,12996.626380040323,13029.919161637963,10196.668003968522,10284.440766030819,7022.693160251435,8401.249663323453,8435.803252725058,10265.915943082338,8623.546341166757,7782.429841191159,9309.259412625106,4849.32865233776,9480.40891035497,8237.330612702019,6688.9341497267815,7113.796951355988,8945.392918392941,11391.406447517316,8770.78174795334,7797.074404297926,11205.567652241964,7490.638744688466,6890.626375097134,8721.152535625733,6986.899718851523,10014.515393386338,11863.685949406314,12576.12226693591,6930.903954576986,6933.68818306879,8436.351253425808,11680.836931112251,5673.257881932308,4512.930178739657,6094.8735580904795,11616.485592765608,8423.704814584986,9582.260510301834,6280.960312130538,10196.683253538626,5869.428152205924,6637.126459584064,8223.324863109141,9163.49600405833,11744.973584261521 SK,10526.703178382486,6581.841291454129,2779.6437301689157,6043.293021386589,8068.711762338472,4716.572547513843,4263.788112757618,7436.446538154413,5733.7942336519345,5091.94458281141,6885.47211985414,6956.591212284293,7116.928783228905,4573.269245439668,8169.130903254093,6799.092645889461,7190.199390340817,8819.311158887818,6679.080394471699,8681.76846617681,6714.688996801623,8780.135433744465,9674.052829336924,7510.89080672348,12315.672504913706,11551.288938768861,10658.095118642217,7760.467099195778,7334.701885838525,11743.053621084162,9101.455526104724,11252.254293590808,7089.2297957961755,11692.575497480175,11870.620362608648,8320.411050776946,12664.612697391287,10840.053026355938,9544.145158945727,8285.851845920657,6554.955003499832,6014.385824757616,5119.229272436076,5566.197178944401,8283.751441606055,4576.739002618681,5529.727054286627,4884.285979430572,7030.767074231632,6380.185010419688,6092.06334940043,4789.6919845964085,3988.728835990378,6100.445127127096,6174.336930810738,5839.492530664778,6739.897695678873,6073.547495791424,6239.663814901599,5985.626769812626,5946.910319392802,5350.4706690989715,2897.742723724252,3812.447551889599,5110.734824948982,5466.7571969447445,3822.1224333717755,4189.745228198809,3608.9397299109723,8925.718578619328,5520.297117401385,2338.023634704523,3634.014208205775,5079.021357670912,3789.3939110245783,3599.858750509022,4222.707040620564,3096.1701009538024,2158.8092391216674,4542.203594136759,4220.210061470592,2961.7796555712353,3705.0055429796116 SI,8932.252857660058,6769.672897729603,3971.443731895907,6727.0196008878875,5996.060296331706,4552.96378417224,7787.375795346372,9548.071392837826,4890.204133819321,7094.028640574649,11752.798116380785,9378.602450871665,7169.30972105447,8221.267552376507,10568.142173580174,7705.119699907013,8559.440940655051,9496.2682906945,10641.418485889739,13644.09405840664,8756.865265119286,10877.994032024846,13095.473005855994,10408.222250010325,17110.767148034232,13257.44359305617,10163.420442559087,10743.809603872312,11213.570708968457,12419.028940460184,8518.188189494229,14975.496301661744,10217.449212514946,10521.007791805137,10759.209828867228,9699.803414833696,14530.647692616923,14530.715084460895,12439.143395173185,11990.046930204517,9001.647305603035,10111.423546501868,6824.172499114327,10267.968760960974,10233.709492652128,9562.175707725224,11231.941186997657,8178.692540046128,8568.526412713521,8103.883097000008,9639.895318751553,9157.43571368136,6814.50158997294,8089.913064615838,8170.645053083449,10765.044719853075,6713.170108103339,8936.8362631332,9542.147586182518,8964.110093884974,8653.114721452737,8353.75428643612,4558.589088593759,9432.405903987477,6927.92152111369,7408.760392367348,5834.871486466167,9336.912851251047,8839.494837985663,10766.693939731143,5073.937522450624,6475.598951785893,9482.419717110955,13414.771212079502,5906.5584945059145,9942.151265372298,7696.092255607837,9521.835825354157,8476.124990692872,6361.010018809483,7504.908031281684,6349.444363482254,12494.86342976942 SE,97729.33612275522,104893.13349064675,152164.30605691054,147567.81837152236,172633.569885874,142454.06079467706,109264.12507808255,145966.80578917114,158733.59492028368,161670.6171803483,134822.12256461562,136958.6213484757,175679.6273876132,133962.36617697845,126787.36233921513,130861.49290945902,151133.2982760823,140247.52694114187,130508.52271890236,137421.63579450184,164132.0529341604,142467.57286064525,135886.87305352974,163762.3962091317,161128.38161511483,148196.28633931337,167892.87677861055,132017.696130452,105953.99289036485,119407.22923207263,147139.6039546916,151309.55114963037,164893.61323375857,137608.18237925606,149284.78771947857,108749.15747050248,131859.531763871,117290.48017785426,131751.97960784068,111117.27409251402,110551.615114603,81550.1135393761,114677.940027603,102356.46697333359,128977.80283219383,94483.98267503879,114937.96457142044,93256.91327642264,96751.29026217168,91074.34139788701,87931.96567208324,96560.83822983531,116746.94389793588,64626.25905820224,75156.91767736348,51489.37512699482,74729.26978432719,134673.01513808029,110440.65771030058,149033.9827088587,143576.83069821307,93040.02354987273,64075.160200006496,102493.08906248632,106664.82884715112,90351.43771324471,94801.81222609026,92445.93458012305,88919.20770998915,108111.72872590217,127440.80298482065,124444.06618883039,98961.91573013023,87913.90602563386,115956.48217115598,95526.84265190935,103459.08985036932,86058.90377748368,99040.9103276256,110493.22773914765,94182.7249029169,169752.66741900297,99896.09236620825 diff --git a/data/existing_infrastructure/existing_heating_raw.csv b/data/existing_infrastructure/existing_heating_raw.csv index 18774460..5e2581c9 100644 --- a/data/existing_infrastructure/existing_heating_raw.csv +++ b/data/existing_infrastructure/existing_heating_raw.csv @@ -28,4 +28,5 @@ United Kingdom,160.49,1.26,7.39,13.81,0.81,0.21 Norway,,,,,2.91,0.334 Switzerland,,,,,1,0.849 Serbia,,,,,, +Kosovo,,,,,, Bosnia Herzegovina,,,,,, diff --git a/doc/configtables/countries.csv b/doc/configtables/countries.csv index 6a386416..41ddd8e9 100644 --- a/doc/configtables/countries.csv +++ b/doc/configtables/countries.csv @@ -1,2 +1,2 @@ ,Unit,Values,Description -countries,--,"Subset of {'AL', 'AT', 'BA', 'BE', 'BG', 'CH', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'ME', 'MK', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'SE', 'SI', 'SK'}","European countries defined by their `Two-letter country codes (ISO 3166-1) `_ which should be included in the energy system model." +countries,--,"Subset of {'AL', 'AT', 'BA', 'BE', 'BG', 'CH', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'ME', 'MK', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'SE', 'SI', 'SK', 'XK'}","European countries defined by their `Two-letter country codes (ISO 3166-1) `_ which should be included in the energy system model." diff --git a/doc/release_notes.rst b/doc/release_notes.rst index d7a6e344..8c460357 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -11,6 +11,8 @@ Release Notes Upcoming Release ================ +* Represent Kosovo (XK) as separate country. + * Added data on the locations and capacities of ammonia plants in Europe. This data is used as a spatial distribution key for the ammonia demand. The data manually collected with sources noted in ``data/ammonia_plants.csv``. diff --git a/scripts/_helpers.py b/scripts/_helpers.py index a3b77c1c..f79d9258 100644 --- a/scripts/_helpers.py +++ b/scripts/_helpers.py @@ -507,7 +507,8 @@ def generate_periodic_profiles(dt_index, nodes, weekly_profile, localize=None): week_df = pd.DataFrame(index=dt_index, columns=nodes) for node in nodes: - timezone = pytz.timezone(pytz.country_timezones[node[:2]][0]) + ct = node[:2] if node[:2] != "XK" else "RS" + timezone = pytz.timezone(pytz.country_timezones[ct][0]) tz_dt_index = dt_index.tz_convert(timezone) week_df[node] = [24 * dt.weekday() + dt.hour for dt in tz_dt_index] week_df[node] = week_df[node].map(weekly_profile) diff --git a/scripts/build_biomass_potentials.py b/scripts/build_biomass_potentials.py index b69fcfbe..4c7752e4 100644 --- a/scripts/build_biomass_potentials.py +++ b/scripts/build_biomass_potentials.py @@ -88,9 +88,11 @@ def build_nuts_population_data(year=2013): pop = pd.concat([pop, pd.concat(swiss)]).to_frame("total") # add missing manually - pop["AL"] = 2893 - pop["BA"] = 3871 - pop["RS"] = 7210 + pop["AL"] = 2778 + pop["BA"] = 3234 + pop["RS"] = 6664 + pop["ME"] = 617 + pop["XK"] = 1587 pop["ct"] = pop.index.str[:2] @@ -149,10 +151,6 @@ def enspreso_biomass_potentials(year=2020, scenario="ENS_Low"): bio = dff.groupby(["NUTS2", "commodity"]).potential.sum().unstack() - # currently Serbia and Kosovo not split, so aggregate - bio.loc["RS"] += bio.loc["XK"] - bio.drop("XK", inplace=True) - return bio @@ -199,7 +197,7 @@ def build_nuts2_shapes(): ) countries = gpd.read_file(snakemake.input.country_shapes).set_index("name") - missing_iso2 = countries.index.intersection(["AL", "RS", "BA"]) + missing_iso2 = countries.index.intersection(["AL", "RS", "XK", "BA"]) missing = countries.loc[missing_iso2] nuts2.rename(index={"ME00": "ME", "MK00": "MK"}, inplace=True) diff --git a/scripts/build_electricity_demand.py b/scripts/build_electricity_demand.py index 622fdafa..d3334ec8 100755 --- a/scripts/build_electricity_demand.py +++ b/scripts/build_electricity_demand.py @@ -192,9 +192,9 @@ def manual_adjustment(load, fn_load, countries): if "ME" in load: load["BA"] = load.HR * (11.0 / 16.2) - if ("KV" not in load or load.KV.isnull().values.all()) and "KV" in countries: + if "XK" not in load and "XK" in countries: if "RS" in load: - load["KV"] = load["RS"] * (4.8 / 27.0) + load["XK"] = load["RS"] * (4.8 / 27.0) copy_timeslice(load, "GR", "2015-08-11 21:00", "2015-08-15 20:00", Delta(weeks=1)) copy_timeslice(load, "AT", "2018-12-31 22:00", "2019-01-01 22:00", Delta(days=2)) @@ -311,8 +311,8 @@ if __name__ == "__main__": logger.info("Supplement missing data with synthetic data.") fn = snakemake.input.synthetic synthetic_load = pd.read_csv(fn, index_col=0, parse_dates=True) - # "UA" does not appear in synthetic load data - countries = list(set(countries) - set(["UA", "MD"])) + # UA, MD, XK do not appear in synthetic load data + countries = list(set(countries) - set(["UA", "MD", "XK"])) synthetic_load = synthetic_load.loc[snapshots, countries] load = load.combine_first(synthetic_load) diff --git a/scripts/build_energy_totals.py b/scripts/build_energy_totals.py index 24ba86bb..2802d8b3 100644 --- a/scripts/build_energy_totals.py +++ b/scripts/build_energy_totals.py @@ -1102,7 +1102,7 @@ def build_co2_totals( co2 = eea_co2.reindex(countries) for ct in pd.Index(countries).intersection( - ["BA", "RS", "AL", "ME", "MK", "UA", "MD"] + ["BA", "RS", "XK", "AL", "ME", "MK", "UA", "MD"] ): mappings = { "electricity": (ct, "+", "Electricity & heat generation", np.nan), @@ -1455,10 +1455,10 @@ def update_residential_from_eurostat(energy: pd.DataFrame) -> pd.DataFrame: for nrg_name, (code, siec) in nrg_type.items(): # Select energy balance type, rename columns and countries to match IDEES data, - # convert TJ to TWh, and drop XK data already since included in RS data + # convert TJ to TWh col_to_rename = {"geo": "country", "TIME_PERIOD": "year", "OBS_VALUE": nrg_name} idx_to_rename = {v: k for k, v in idees_rename.items()} - drop_geo = ["EU27_2020", "EA20", "XK"] + drop_geo = ["EU27_2020", "EA20"] nrg_data = eurostat_households.query( "nrg_bal == @code and siec == @siec and geo not in @drop_geo and OBS_VALUE > 0" ).copy() diff --git a/scripts/build_hydro_profile.py b/scripts/build_hydro_profile.py index 6a0315c7..2d0d2e52 100644 --- a/scripts/build_hydro_profile.py +++ b/scripts/build_hydro_profile.py @@ -82,7 +82,7 @@ def get_eia_annual_hydro_generation(fn, countries, capacities=False): countries=["Czechia", "Slovakia"], start=1980, end=1992 ), "Former Serbia and Montenegro": dict( - countries=["Serbia", "Montenegro"], start=1992, end=2005 + countries=["Serbia", "Montenegro", "Kosovo"], start=1992, end=2005 ), "Former Yugoslavia": dict( countries=[ @@ -90,6 +90,7 @@ def get_eia_annual_hydro_generation(fn, countries, capacities=False): "Croatia", "Bosnia and Herzegovina", "Serbia", + "Kosovo", "Montenegro", "North Macedonia", ], @@ -111,9 +112,8 @@ def get_eia_annual_hydro_generation(fn, countries, capacities=False): ) df.loc["Germany"] = df.filter(like="Germany", axis=0).sum() - df.loc["Serbia"] += df.loc["Kosovo"].fillna(0.0) df = df.loc[~df.index.str.contains("Former")] - df.drop(["Europe", "Germany, West", "Germany, East", "Kosovo"], inplace=True) + df.drop(["Europe", "Germany, West", "Germany, East"], inplace=True) df.index = cc.convert(df.index, to="iso2") df.index.name = "countries" @@ -122,6 +122,8 @@ def get_eia_annual_hydro_generation(fn, countries, capacities=False): factor = 1e3 if capacities else 1e6 df = df.T[countries] * factor + df.ffill(axis=0, inplace=True) + return df @@ -129,7 +131,7 @@ def correct_eia_stats_by_capacity(eia_stats, fn, countries, baseyear=2019): cap = get_eia_annual_hydro_generation(fn, countries, capacities=True) ratio = cap / cap.loc[baseyear] eia_stats_corrected = eia_stats / ratio - to_keep = ["AL", "AT", "CH", "DE", "GB", "NL", "RS", "RO", "SK"] + to_keep = ["AL", "AT", "CH", "DE", "GB", "NL", "RS", "XK", "RO", "SK"] to_correct = eia_stats_corrected.columns.difference(to_keep) eia_stats.loc[:, to_correct] = eia_stats_corrected.loc[:, to_correct] diff --git a/scripts/build_industrial_production_per_country.py b/scripts/build_industrial_production_per_country.py index ccb4feca..b7f98d76 100644 --- a/scripts/build_industrial_production_per_country.py +++ b/scripts/build_industrial_production_per_country.py @@ -345,5 +345,7 @@ if __name__ == "__main__": separate_basic_chemicals(demand, year) + demand.fillna(0.0, inplace=True) + fn = snakemake.output.industrial_production_per_country demand.to_csv(fn, float_format="%.2f") diff --git a/scripts/build_population_layouts.py b/scripts/build_population_layouts.py index 4cabdc7c..b9af8d85 100644 --- a/scripts/build_population_layouts.py +++ b/scripts/build_population_layouts.py @@ -20,8 +20,6 @@ logger = logging.getLogger(__name__) cc = coco.CountryConverter() -coco.logging.getLogger().setLevel(coco.logging.CRITICAL) - if __name__ == "__main__": if "snakemake" not in globals(): from _helpers import mock_snakemake @@ -32,6 +30,7 @@ if __name__ == "__main__": configure_logging(snakemake) set_scenario_config(snakemake) + coco.logging.getLogger().setLevel(coco.logging.CRITICAL) cutout = atlite.Cutout(snakemake.input.cutout) @@ -56,6 +55,8 @@ if __name__ == "__main__": urban_fraction = ( urban_fraction.query("iso2 in @countries").set_index("iso2")["2019"].div(100) ) + if "XK" in countries: + urban_fraction["XK"] = urban_fraction["RS"] # population in each grid cell pop_cells = pd.Series(I.dot(nuts3["pop"])) diff --git a/scripts/build_retro_cost.py b/scripts/build_retro_cost.py index c6dd31cf..42144c1a 100755 --- a/scripts/build_retro_cost.py +++ b/scripts/build_retro_cost.py @@ -198,6 +198,7 @@ def prepare_building_stock_data(): "Iceland": "IS", "Montenegro": "ME", "Serbia": "RS", + "Kosovo": "XK", "Albania": "AL", "United Kingdom": "GB", "Bosnia and Herzegovina": "BA", @@ -1073,6 +1074,7 @@ if __name__ == "__main__": "AL": ["BG", "RO", "GR"], "BA": ["HR"], "RS": ["BG", "RO", "HR", "HU"], + "KV": ["RS"], "MK": ["BG", "GR"], "ME": ["BA", "AL", "RS", "HR"], "CH": ["SE", "DE"], diff --git a/scripts/build_shapes.py b/scripts/build_shapes.py index 4de5370a..2370f2ae 100644 --- a/scripts/build_shapes.py +++ b/scripts/build_shapes.py @@ -106,8 +106,6 @@ def _simplify_polys(polys, minarea=0.1, tolerance=None, filterremote=True): def countries(naturalearth, country_list): - if "RS" in country_list: - country_list.append("KV") df = gpd.read_file(naturalearth) @@ -116,15 +114,12 @@ def countries(naturalearth, country_list): df[x].where(lambda s: s != "-99") for x in ("ISO_A2", "WB_A2", "ADM0_A3") ) df["name"] = reduce(lambda x, y: x.fillna(y), fieldnames, next(fieldnames)).str[:2] + df.replace({"name": {"KV": "XK"}}, inplace=True) df = df.loc[ df.name.isin(country_list) & ((df["scalerank"] == 0) | (df["scalerank"] == 5)) ] s = df.set_index("name")["geometry"].map(_simplify_polys).set_crs(df.crs) - if "RS" in country_list: - s["RS"] = s["RS"].union(s.pop("KV")) - # cleanup shape union - s["RS"] = Polygon(s["RS"].exterior.coords) return s @@ -195,7 +190,9 @@ def nuts3(country_shapes, nuts3, nuts3pop, nuts3gdp, ch_cantons, ch_popgdp): df = df.join(pd.DataFrame(dict(pop=pop, gdp=gdp))) - df["country"] = df.index.to_series().str[:2].replace(dict(UK="GB", EL="GR")) + df["country"] = ( + df.index.to_series().str[:2].replace(dict(UK="GB", EL="GR", KV="XK")) + ) excludenuts = pd.Index( ( @@ -217,13 +214,18 @@ def nuts3(country_shapes, nuts3, nuts3pop, nuts3gdp, ch_cantons, ch_popgdp): "FR9", ) ) - excludecountry = pd.Index(("MT", "TR", "LI", "IS", "CY", "KV")) + excludecountry = pd.Index(("MT", "TR", "LI", "IS", "CY")) df = df.loc[df.index.difference(excludenuts)] df = df.loc[~df.country.isin(excludecountry)] manual = gpd.GeoDataFrame( - [["BA1", "BA", 3871.0], ["RS1", "RS", 7210.0], ["AL1", "AL", 2893.0]], + [ + ["BA1", "BA", 3234.0], + ["RS1", "RS", 6664.0], + ["AL1", "AL", 2778.0], + ["XK1", "XK", 1587.0], + ], columns=["NUTS_ID", "country", "pop"], geometry=gpd.GeoSeries(), crs=df.crs, @@ -234,7 +236,7 @@ def nuts3(country_shapes, nuts3, nuts3pop, nuts3gdp, ch_cantons, ch_popgdp): df = pd.concat([df, manual], sort=False) - df.loc["ME000", "pop"] = 650.0 + df.loc["ME000", "pop"] = 617.0 return df diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 0e966538..3e3e117c 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -281,7 +281,7 @@ def co2_emissions_year( eurostat = build_eurostat(input_eurostat, countries) - # this only affects the estimation of CO2 emissions for BA, RS, AL, ME, MK + # this only affects the estimation of CO2 emissions for BA, RS, AL, ME, MK, XK eurostat_co2 = build_eurostat_co2(eurostat, year) co2_totals = build_co2_totals(countries, eea_co2, eurostat_co2)