pypsa-meets-earth / documentation

Contains hackathon material, jupyter notebook visualizations and images
GNU General Public License v3.0
16 stars 68 forks source link

Include a section on hydro in the build_renewable_profile notebook #61

Closed asolavi closed 1 year ago

asolavi commented 1 year ago

Closes [#54 ]

This PR aims to create a section on hydro in the build_renewable_profile.ipynb notebook, detailing the process made to create the hydro time series. Currently, built_renewable_profile.ipynb focuses on wind and solar.

Hydro modelling is done in three steps:

  1. Preparation of hydro-potential data with atlite: ERA5 reanalysis dataset is used, runoff is being integrated across hydrobasins assuming some flow speed and put into cutout. This is done here. More details in the methodology used by atlite can be found here.

  2. The output of the time series obtained in step 1 (cutout hydro potential) is normalized in pypsa-earth using the normalization procedure described here. This is done to match country statistics. The result is stored in resources/renewable_profiles/profile_hydro.nc.

  3. Attach_hydro in add_electricity, as described here. Specifies how the different hydro types (runoff river (ror), hydro dams (hydro), and pumped storage (PHS) are added to the network in add_electricity.

Checklist

asolavi commented 1 year ago

One question for the experts:

  1. Are inflows from the xarray in resources/renewable_profiles/profile_hydro.nc in MW or in a "water unit" (e.g., depth of water in meters if it were spread over the corresponding region/cell)?
ekatef commented 1 year ago

One question for the experts:

  1. Are inflows from the xarray in resources/renewable_profiles/profile_hydro.nc in MW or in a "water unit" (e.g., depth of water in meters if it were spread over the corresponding region/cell)?

Hello @asolavi! Fantastic work 😄

Great to have well-elaborated explanation of details of hydro calculations. To me, our hydro calculations still have a bit of mystery :)

According to the docstring, the hydro profiles inflows are in MW.

That simplifies work with hydro generation, e.g. we need only account for GWh -> W transformation when doing normalisation of hydro.

Although, I can't say that unit transformation is absolutely evident for me from atlite source code, where shift_and_aggregate_runoff_for_plants() function is used to translate water depth per cell area into MW.

asolavi commented 1 year ago

Thank you @ekatef. I've been further looking into this and, from my understanding, it seems that:

  1. cutouts/{cutout_name}-2013-era5.nc has the surface runoff in depth of water in meters if it were spread over the corresponding region/cell.

  2. As you mentioned above, the docstring in build_renewable_profiles.py suggests that inflows are in MW already.

  3. The file data/eia_hydro_annual_generation.csv is expressed in billions kWh per year. This is one of the possibile sources to do the normalization.

I also don't see exactly where the transformation from depth of water per area to an energy unit happens. I suspect that it takes place indirectly in the normalization. This is because the normalization makes the total hydro generation equal to the total generation of an energy metric (MWh or another one), while preserving the local distribution across several regions from the ERA5 dataset.

What do you think? Is this reasonable?

ekatef commented 1 year ago

Thank you @ekatef. I've been further looking into this and, from my understanding, it seems that:

  1. cutouts/{cutout_name}-2013-era5.nc has the surface runoff in depth of water in meters if it were spread over the corresponding region/cell.

  2. As you mentioned above, the docstring in build_renewable_profiles.py suggests that inflows are in MW already.

  3. The file data/eia_hydro_annual_generation.csv is expressed in billions kWh per year. This is one of the possibile sources to do the normalization.

I also don't see exactly where the transformation from depth of water per area to an energy unit happens. I suspect that it takes place indirectly in the normalization. This is because the normalization makes the total hydro generation equal to the total generation of an energy metric (MWh or another one), while preserving the local distribution across several regions from the ERA5 dataset.

What do you think? Is this reasonable?

I think you may be absolutely right. It looks like we silently assume during normalisation that hydropower generation linearly depends on runoff, and scaling is used both for value and unit transformation. If that is the case, probably the docstring can be a bit clarified in part where inflows are introduced.

I'd suggest to discuss it during today's meeting, as it feels like a major question.

asolavi commented 1 year ago

Hi @ekatef and @tacwebservices,

as per the discussion yesterday, I've improved the description on the units used for water inflows at every step of the process. I think it is now ready to merge :). Let me know if you agree, or if there is anything that should be changed.

ekatef commented 1 year ago

Hey @asolavi and @tacwebservices! Great and very helpful work 🙂

A couple of minor comments (sorry, can't paste it into the code, as git complains on big diff size).

Otherwise, looks perfect to me 🙂 @davide-f would you have any comments?

davide-f commented 1 year ago

Hello @asolavi and @tacwebservices ! :D Great job as always! You are amazing in documentation!!!

The PR is in good state,I'd have few comments:

The rest is perfect :) Great job!

asolavi commented 1 year ago

Thank you for your detailed feedback @ekatef and @davide-f. I believe it has now been implemented and it is ready to merge :). Let me know what you think

davide-f commented 1 year ago

Looks good to me :) If Katia agrees we can merge. Amazing! :D

ekatef commented 1 year ago

Agree that the PR looks ready to go :) Great work @tacwebservices and @asolavi!

davide-f commented 1 year ago

Merged, fantastic job! :D

asolavi commented 1 year ago

Great, thank you for your help and feedback @davide-f @ekatef