-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a feature to apply timestamp-to-timepoint mappings to profiles to create input temporal data #55
Comments
See if this is useful for you: import os, sys, csv from PowerSimData2Switch import inv_period, grid, scenario, scenario_sy, grid_sy from powersimdata.scenario.scenario import Scenario pre-populate slicing_recovery_fileslicing = [] Processing demand data slicing.demand_sy_tps = demand_sy.join(slicing['timepoint']).pivot_table(index = 'timepoint') Demand bus distribution factor calculation for each bus.zone_pd = grid.bus.pivot_table(index = 'zone_id', aggfunc = np.sum)['Pd'].to_frame() write loads.csv file.with open('loads.csv', 'w', newline='') as loads_file:
write variable_capacity_factors.csv file.solar_tps = solar.join(slicing['timepoint']).pivot_table(index = 'timepoint') with open('variable_capacity_factors.csv', 'w', newline='') as variable_capacity_factor_file:
|
@YifanLi86 your code snippet relies on an unknown script/module Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\DanielOlsen\Dropbox (Gates Ventures)\BreakthroughEnergySciences\Explorations\DanielO\Capacity Expansion\PowerSimData2Switch.py", line 307, in <module>
if AveFuelCost(df_ave_fuel_cost.index[j], fuel[k], inv_period[i]) == 0:
File "C:\Users\DanielOlsen\Dropbox (Gates Ventures)\BreakthroughEnergySciences\Explorations\DanielO\Capacity Expansion\PowerSimData2Switch.py", line 176, in AveFuelCost
ave_fuel_cost = ave_fuel_cost * (interest_rate**(int(year) - int(base_year)))
OverflowError: (34, 'Result too large') Maybe you have a different working version in your local machine. Looking at the rest of the code, we get another error with this line: >>> demand.join(slicing['timepoint']).pivot_table(index="timepoint")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list indices must be integers or slices, not str since Looking at the structure of the temporal CSVs, it seems like they will be pretty straightforward to construct. The biggest open question I had when I wrote the Issue is what MW value we pick for a timepoint that represents multiple timestamps, but it looks like you use |
@danielolsen The PR code is exactly what I am running with....the overflow error "results too large" is something that I have not seen. A little bit weird, but I will look into it. Or you can see what variable it needs, inv_period, grid, scenario, scenario_sy, grid_sy are all needed from the grid, so just pre-populate you should be able to by pass. The slicing variable need to be pre-populated based on the csv format. So the way I am doing things now is to manually develop a slicing method, and then read it into memory, then run rest of the code line-by-line. This is the best I have so far, it is broken but I thought it has some logics on large file generating so just shared per your request. I hope if can have some help but if not, just ignore. In the PR code I mention "# Refer to TemporalSlicing.py for time series related input data development.", but this is just some placeholder that I need to work on this in the next. Thinking about finishing the prototype last week but but did not actually get a chance to finish. |
The code was helpful in answering my question of how to combine many timestamps into a single value, since it showed me that you're using the default mean aggregation of the pandas |
@YifanLi86 the sample timeseries.csv file has a column |
|
For other years, do we have more timepoints? It seems that in timepoints.csv, each timepoint is mapped to a timeseries, and the timeseries are names following the pattern |
They have to go to 2032_x or 2034_x. |
In that case, it seems like the |
Yes, currently we have been focusing on a single year operation, single year investment model. But it definitely needs user specification for multiple years or single year that is not 2030. |
It sounds like we will need a validation step between the |
🚀
Describe the workflow you want to enable
I wish I could take profile dataframes/CSVs (demand, hydro, solar, wind, indexed by timestamp, columns are zones/generators as appropriate) and a mapping of timestamps to timepoints to create the temporal input files required by Switch. This is one part of Issues #11, #12, and #14; the other part is generating the mapping. For now, let us assume we have a mapping (we may start by using a hardcoded one for now) and want to apply it.
Describe your proposed implementation
We should create four new internal functions to perform this mapping, plus one user-facing function which launches all of them. If the user provides:
Then we can generate each of the required input files:
LOAD_ZONE
) and timepoint (column is namedTIMEPOINT
), and the value is the demand at that bus during that timepoint (column namedzone_demand_mw
). The logic behind how we collapse many timestamp values to a single value is currently unknown: we could start with a simple mean and iterate as necessary.timepoint_id
, a column namedtimestamp
with a unique name for each timepoint, although this does not appear to be used elsewhere, and a column namedtimeseries
which is not unique).timeseries
column of timepoints.csv (this column is namedTIMESERIES
), a year (column name ists_period
, in the example file all entries are2030
), a duration (this column is namedts_duration_of_tp
, in the example file all entries are6
), the number of entries of this name within thetimeseries
column of timepoints.csv (this column is namedts_num_tps
, in the example file all entries are4
), and the number of times that this timepoint was mapped to a timestamp in the original data (this column is namedts_scale_to_period
).GENERATION_PROJECT
) and timepoint (column is namedtimepoint
), and the value is the generation from that variable generator at that time point, normalized by the generator capacity (i.e. all values are in the range [0, 1]), and this column is namedgen_max_capacity_factor
.The text was updated successfully, but these errors were encountered: