Closed danielolsen closed 3 years ago
Per @BainanXia's suggestion, we now return a dict of dicts. The new demo code is:
import pandas as pd
import pickle
from powersimdata import Scenario
from switchwrapper.switch_to_grid import construct_grids_from_switch_results
from switchwrapper.switch_to_profiles import reconstruct_input_profiles
# Get dict of Grids for each investment year
scenario = Scenario(599)
grid = scenario.get_grid()
filename = "path_to_results_file/results.pickle"
with open(filename, "rb") as f:
results = pickle.load(f)
all_grids = construct_grids_from_switch_results(grid, results)
# Get inputs required to un-map
loads = pd.read_csv("path_to_prepared_inputs/loads.csv")
variable_capacity_factors = pd.read_csv("path_to_prepared_inputs/variable_capacity_factors.csv")
timestamps_to_timepoints = pd.read_csv("path_to_timestamp_mapping/slicing_recovery.csv", index_col=0).squeeze()
# New functionality from this feature
profiles = reconstruct_input_profiles(all_grids, loads, variable_capacity_factors, timestamps_to_timepoints)
Pull Request doc
Purpose
To have a MockScenario (#51) that can be used to calculate curtailment (e.g. #41), we need input profiles. This PR uses the inputs to SwitchWrapper, the inputs to Switch, and the Grid that comes from the expansion results to construct a set of profiles that are consistent with the output Grid.
What the code is doing
For loads:
For hydro/solar/wind/plants:
Usage Example/Visuals
Validation
Subtracting the original scenario profiles from the reconstructed profiles shows that the indices and columns are the same, but the values are different (to be expected, since the temporal reduction averaged the values of many timepoints together). Comparing the sums shows that the overall differences are rounding errors (since in this particular example, Switch does not choose to build any new hydro/wind/solar plants, choosing to build only ten natural gas plants instead).
Time estimate
15-30 minutes.