From e7c7c3c98181c2fd87873132a760706954bde61b Mon Sep 17 00:00:00 2001 From: lukasschirren Date: Thu, 4 Jul 2024 17:27:53 +0100 Subject: [PATCH] Package error of rasterio solved by importing gdal (get_weather_data, map_costs, optimize_hydrogen_plant) Two warnings in optimize_hydrogen_plant.py solved Accessing series by position with .iloc, and Non-integer 'periods' in 'pd.date_range' --- get_weather_data.py | 1 + map_costs.py | 1 + optimize_hydrogen_plant.py | 7 ++++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/get_weather_data.py b/get_weather_data.py index f52293b..2f742e8 100644 --- a/get_weather_data.py +++ b/get_weather_data.py @@ -18,6 +18,7 @@ """ import logging +from osgeo import gdal import atlite # import geopandas as gpd import pandas as pd diff --git a/map_costs.py b/map_costs.py index 6cdf583..0966830 100644 --- a/map_costs.py +++ b/map_costs.py @@ -8,6 +8,7 @@ This script visualizes the spatial cost of hydrogen for each demand center. """ +from osgeo import gdal import geopandas as gpd import cartopy.crs as ccrs import matplotlib.pyplot as plt diff --git a/optimize_hydrogen_plant.py b/optimize_hydrogen_plant.py index 06ff42c..f6c93b8 100644 --- a/optimize_hydrogen_plant.py +++ b/optimize_hydrogen_plant.py @@ -9,6 +9,7 @@ """ +from osgeo import gdal import atlite import geopandas as gpd import pypsa @@ -60,9 +61,9 @@ def demand_schedule(quantity, transport_state, transport_excel_path, # schedule for trucking annual_deliveries = quantity/truck_capacity quantity_per_delivery = quantity/annual_deliveries - index = pd.date_range(start_date, end_date, periods=annual_deliveries) + index = pd.date_range(start_date, end_date, periods=int(annual_deliveries)) trucking_demand_schedule = pd.DataFrame(quantity_per_delivery, index=index, columns = ['Demand']) - trucking_hourly_demand_schedule = trucking_demand_schedule.resample('H').sum().fillna(0.) + trucking_hourly_demand_schedule = trucking_demand_schedule.resample('h').sum().fillna(0.) # schedule for pipeline index = pd.date_range(start_date, end_date, freq = 'H') @@ -171,7 +172,7 @@ def optimize_hydrogen_plant(wind_potential, pv_potential, times, demand_profile, ) # Output results - lcoh = n.objective/(n.loads_t.p_set.sum()[0]/39.4*1000) # convert back to kg H2 + lcoh = n.objective/(n.loads_t.p_set.sum().iloc[0]/39.4*1000) # convert back to kg H2 wind_capacity = n.generators.p_nom_opt['Wind'] solar_capacity = n.generators.p_nom_opt['Solar'] electrolyzer_capacity = n.links.p_nom_opt['Electrolysis']