1+ -- Friday, Sept 23, 2020
2+ -- PHG
3+
4+ -- First we create a draft table to receive the data from the csv:
5+ -- Make sure to choose the next available demand_scenario_id for each scenario from evolved
6+ -- The last scenario seems to be 152 (you can check by looking at switch.demand_scenario)
7+ create table public .demands_from_evolved(
8+ load_zone_id INT ,
9+ demand_scenario_id INT , -- change this for each scenario
10+ raw_timepoint_id INT ,
11+ load_zone_name VARCHAR (30 ),
12+ timestamp_utc timestamp without time zone ,
13+ demand_mw double precision ,
14+ primary key (load_zone_id, demand_scenario_id, raw_timepoint_id)
15+ );
16+
17+ -- Then we copy the data in the csv file (it is expecting headers)
18+ COPY public .demands_from_evolved
19+ FROM ' path_in_the_servwer_to_file_ending_in.csv'
20+ DELIMITER ' ,' NULL AS ' NULL' CSV HEADER;
21+
22+
23+ -- Create new demand scenario in the appropriate table:
24+ -- Change the name and description so it reflects the scenario
25+ INSERT INTO switch .demand_scenario
26+ VALUES (153 , ' [GridLab] Reference scen' , ' Write a description here' );
27+
28+ -- Now we can insert the data into the official SWITCH table
29+ INSERT INTO switch .demand_timeseries
30+ SELECT * FROM public .demands_from_evolved ;
31+ -- WHERE demand_scenario_id = 154; -- I added this comment because it will help when you upload more scenarios
32+
33+ -- Create new scenario to pull data using get_inputs:
34+ -- edit ids to create the scenario of interest.
35+ -- Edit the name and description text so you can recall the data it is pulling
36+ -- (WECC emissions? zero or 80% reductions from 2005? RPS? etc)
37+ INSERT INTO switch .scenario
38+ VALUES (201 ,
39+ ' [GridLab] ...' ,
40+ ' 2035 (2033 - 2037), year_round, WECC zero emissions, no RPS, NREL ATB 2020, updated gen listings (env cat 3), 2017 fuel costs from EIA, 2018 dollars, supply curve for Bio_Solid' ,
41+ 30 , -- study_timeframe_id
42+ 30 , -- time_sample_id
43+ 115 , -- demand_scenario_id
44+ 4 , -- fuel_simple_price_scenario, without Bio_Solid costs, because they are provided by supply curve
45+ 23 , -- generation_plant_scenario_id
46+ 25 , -- generation_plant_cost_scenario_id
47+ 21 , -- generation_plant_existing_and_planned_scenario_id
48+ 23 , -- hydro_simple_scenario_id
49+ 9 , -- carbon_cap_scenario_id
50+ 2 , -- supply_curve_scenario_id
51+ 1 , -- regional_fuel_market_scenario_id
52+ NULL , -- rps_scenario_id
53+ NULL , -- enable_dr
54+ NULL , -- enable_ev
55+ 2 , -- transmission_base_capital_cost_scenario_id
56+ NULL , -- ca_policies_scenario_id
57+ 0 , -- enable_planning_reserves
58+ 2 , -- generation_plant_technologies_scenario_id
59+ 3 , -- variable_o_m_cost_scenario_id
60+ NULL -- wind_to_solar_ratio
61+ );
62+
63+
64+
65+ -- Notes on what to change when you repeat this process for new scenarios:
66+
67+ -- When you repeat this process for the other two demand scenarios, you should not run the CREATE
68+ -- statement from line 7, as the table will already exist.
69+ -- You need to change the demand_scenario_id in line 26.
70+ -- In lines 29-30, when you insert the data, now you should add a WHERE statement so it only adds
71+ -- the new rows you are copying into the public.demands_from_evolved table.
72+ -- In line 38 onwards you need to edit accordingly
0 commit comments