generate_load_factors.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. wind_data = pd.read_csv("data/ninja_wind_europe_v1.1_current_on-offshore.csv")
  2. solar_data = pd.read_csv("data/ninja_pv_europe_v1.1_merra2.csv")
  3. wind_data['time'] = pd.to_datetime(wind_data['time'], format="%Y-%m-%d %H:%M:%S")
  4. solar_data['time'] = pd.to_datetime(solar_data['time'], format="%Y-%m-%d %H:%M:%S")
  5. regions_labels = sorted(list(solar_data.columns))
  6. regions_labels.remove("time")
  7. offshore_labels = {x for x in wind_data.columns if '_OFF' in x}
  8. missing_offshore = {f"{x}_OFF" for x in regions_labels} - offshore_labels
  9. for x in missing_offshore:
  10. wind_data[x] = 0
  11. offshore_labels = [x for x in wind_data.columns if '_OFF' in x]
  12. onshore_labels = [x for x in wind_data.columns if '_ON' in x]
  13. offshore = wind_data[["time"] + offshore_labels]
  14. onshore = wind_data[["time"] + onshore_labels]
  15. solar = solar_data.set_index("time").stack().rename("solar")
  16. print(solar.index.names)
  17. solar.index.names = ["time", "region"]
  18. offshore.set_index("time", inplace=True)
  19. offshore.columns = map(lambda x: x.replace("_OFF", ""), offshore.columns)
  20. offshore = offshore.stack().rename("offshore")
  21. offshore.index.names = ["time", "region"]
  22. onshore.set_index("time", inplace=True)
  23. onshore.columns = map(lambda x: x.replace("_ON", ""), onshore.columns)
  24. onshore = onshore.stack().rename("onshore")
  25. onshore.index.names = ["time", "region"]
  26. potential = pd.DataFrame(offshore)
  27. print(potential)
  28. potential = potential.merge(pd.DataFrame(onshore), left_index=True, right_index=True, how="outer")
  29. print(potential)
  30. potential = potential.merge(pd.DataFrame(solar), left_index=True, right_index=True, how="outer")
  31. print(potential)
  32. potential.sort_values(["time", "region"], inplace=True)
  33. potential.to_parquet("data/potential.parquet")