@@ -130,12 +130,12 @@ def write_tables(**args):
130130 # double-check that arguments are valid
131131 cur = db_cursor ()
132132 cur .execute (
133- 'select * from generator_costs_by_year where cap_cost_scen_id = %(cap_cost_scen_id )s' ,
133+ 'select * from generator_costs_by_year where tech_scen_id = %(tech_scen_id )s' ,
134134 args
135135 )
136136 if len ([r for r in cur ]) == 0 :
137137 print "================================================================"
138- print "WARNING: no records found in generator_costs_by_year for cap_cost_scen_id ='{}'" .format (args ['cap_cost_scen_id ' ])
138+ print "WARNING: no records found in generator_costs_by_year for tech_scen_id ='{}'" .format (args ['tech_scen_id ' ])
139139 print "================================================================"
140140 time .sleep (2 )
141141 del cur
@@ -155,7 +155,8 @@ def write_tables(**args):
155155 SELECT DISTINCT
156156 CONCAT_WS('_', load_zone, p.technology, nullif(site, 'na'), nullif(orientation, 'na'))
157157 AS "GENERATION_PROJECT",
158- p.*
158+ p.*,
159+ g.tech_scen_id
159160 FROM project p
160161 JOIN generator_info g USING (technology)
161162 CROSS JOIN study_length
@@ -167,22 +168,25 @@ def write_tables(**args):
167168 )
168169 -- projects that could be built during the study
169170 LEFT JOIN generator_costs_by_year c ON (
170- c.cap_cost_scen_id = %(cap_cost_scen_id)s
171+ c.tech_scen_id = g.tech_scen_id
171172 AND c.technology = g.technology
172173 AND (g.min_vintage_year IS NULL OR c.year >= g.min_vintage_year)
173174 AND c.year >= study_start
174175 AND c.year < study_end
175176 )
176177 WHERE (e.project_id IS NOT NULL OR c.technology IS NOT NULL)
177178 AND p.load_zone in %(load_zones)s
179+ AND g.tech_scen_id IN ('all', %(tech_scen_id)s)
178180 AND g.technology NOT IN %(exclude_technologies)s;
179181
180182 DROP TABLE IF EXISTS study_generator_info;
181183 CREATE TEMPORARY TABLE study_generator_info AS
182184 SELECT DISTINCT g.*
183- FROM generator_info g JOIN study_projects p USING (technology);
185+ FROM generator_info g JOIN study_projects p USING (tech_scen_id, technology);
184186 """ .format (with_period_length ), args )
185187
188+ # import pdb; pdb.set_trace()
189+
186190 #########################
187191 # financials
188192
@@ -345,11 +349,6 @@ def write_tables(**args):
345349 # Some of these are actually single-fuel, but this approach is simpler than sorting
346350 # them out within each query, and it doesn't add any complexity to the model.
347351
348- if args .get ('connect_cost_per_mw_km' , 0 ):
349- print (
350- "WARNING: ignoring connect_cost_per_mw_km specified in arguments; using"
351- "project.connect_cost_per_mw and generator_info.connect_cost_per_kw_generic instead."
352- )
353352 if args .get ('wind_capital_cost_escalator' , 0.0 ) or args .get ('pv_capital_cost_escalator' , 0.0 ):
354353 # user supplied a non-zero escalator
355354 raise ValueError (
@@ -389,7 +388,7 @@ def write_tables(**args):
389388 "GENERATION_PROJECT",
390389 load_zone AS gen_load_zone,
391390 technology AS gen_tech,
392- connect_cost_per_mw AS gen_connect_cost_per_mw,
391+ spur_line_cost_per_mw + 1000 * substation_cost_per_kw AS gen_connect_cost_per_mw,
393392 max_capacity AS gen_capacity_limit_mw,
394393 unit_size as gen_unit_size,
395394 max_age_years as gen_max_age,
@@ -440,14 +439,12 @@ def write_tables(**args):
440439 c.capital_cost_per_kw * 1000.0
441440 * power(1.0+%(inflation_rate)s, %(base_financial_year)s-c.base_year)
442441 AS gen_overnight_cost,
443- CASE WHEN i.gen_storage_efficiency IS NULL THEN NULL ELSE 0.0 END
444- AS gen_storage_energy_overnight_cost,
445- i.fixed_o_m * 1000.0 * power(1.0+%(inflation_rate)s, %(base_financial_year)s-i.base_year)
442+ c.capital_cost_per_kwh AS gen_storage_energy_overnight_cost,
443+ c.fixed_o_m * 1000.0 * power(1.0+%(inflation_rate)s, %(base_financial_year)s-i.base_year)
446444 AS gen_fixed_o_m,
447- i.min_vintage_year
445+ i.min_vintage_year -- used for build_year filter below
448446 FROM study_generator_info i
449- JOIN generator_costs_by_year c USING (technology)
450- WHERE c.cap_cost_scen_id = %(cap_cost_scen_id)s
447+ JOIN generator_costs_by_year c USING (technology, tech_scen_id)
451448 ORDER BY 1, 2
452449 )
453450 SELECT -- costs specified in proj_existing_builds
0 commit comments