Breakthrough-Energy / SwitchWrapper

Wrapper for Switch
MIT License
1 stars 2 forks source link

feat: add logic to build_loads function #61

Closed danielolsen closed 3 years ago

danielolsen commented 3 years ago

Pull Request doc

Purpose

This addresses the generation of the loads.csv file as described in #55.

What the code is doing

Per-zone bus demand is translated to per bus demand following the method in PowerSimData, and then grouped by timepoint, then the mean is taken, and the table is melted to the format expected by Switch.

Testing

Manual testing with the mapping file provided by @YifanLi86 provided output consistent with the example loads.csv file. None is used for the inputs to the still-unused timepoints and timeseries_to_duration parameters of the profiles_to_switch function.

import pandas as pd
from powersimdata import Scenario
from switchwrapper.profiles_to_switch import profiles_to_switch
scenario = Scenario(599)
grid = scenario.get_grid()
profiles = {
    "demand": scenario.get_demand(),
    "hydro": scenario.get_hydro(),
    "solar": scenario.get_solar(),
    "wind": scenario.get_wind(),
}
timestamps_to_timepoints = pd.read_csv("slicing_recovery.csv", index_col=0).squeeze()
profiles_to_switch(grid, profiles, None, None, timestamps_to_timepoints, "profiles_output")

Time estimate

15 minutes.

rouille commented 3 years ago

Do we have time to write tests?