Beispiel #1
0
 def setup_contingency_detail(self, options, stats_manager: StatsManager):
     _round = self._round
     line_path = os.path.join(options.output_directory,
                              'contingency_detail.csv')
     line_file = open(line_path, 'w', newline='')
     line_entries_per_hour = lambda ops: ops.observed_contingency_flow_levels.keys(
     )
     line_columns = {
         'Date':
         lambda ops, c_l: str(ops.timestamp.date()),
         'Hour':
         lambda ops, c_l: ops.timestamp.hour,
         'Minute':
         lambda ops, c_l: ops.timestamp.minute,
         'Contingency':
         lambda ops, c_l: c_l[0],
         'Line':
         lambda ops, c_l: c_l[1],
         'Flow':
         lambda ops, c_l: _round(ops.observed_contingency_flow_levels[c_l]),
         'Violation':
         lambda ops, c_l: _round(
             ops.observed_contingency_flow_violation_levels[c_l]),
     }
     line_writer = CsvMultiRowReporter.from_dict(line_file,
                                                 line_entries_per_hour,
                                                 line_columns)
     stats_manager.register_for_sced_stats(line_writer.write_record)
     stats_manager.register_for_overall_stats(
         lambda overall: line_file.close())
Beispiel #2
0
 def setup_virtual_detail(self, options, stats_manager: StatsManager):
     _round = self._round
     virtual_production_path = os.path.join(options.output_directory,
                                            'virtual_detail.csv')
     virtual_production_file = open(virtual_production_path,
                                    'w',
                                    newline='')
     virtual_production_entries_per_hour = lambda ops: ops.observed_virtual_dispatch_levels.keys(
     )
     virtual_production_columns = {
         'Date':       lambda ops,g: str(ops.timestamp.date()),
         'Hour':       lambda ops,g: ops.timestamp.hour,
         'Minute':     lambda ops,g: ops.timestamp.minute,
         'Generator':  lambda ops,g: g,
         'Output':     lambda ops,g: _round(ops.observed_virtual_dispatch_levels[g]),
         'Output DA':  lambda ops,g: _round(ops.virtual_gen_cleared_DA[g]) \
                 if options.compute_market_settlements else None,
         'Unit Market Revenue': lambda ops,g: _round(ops.virtual_gen_revenue[g]) \
                 if options.compute_market_settlements else None,
         'Unit Uplift Payment': lambda ops,g: _round(ops.virtual_uplift[g]) \
                 if options.compute_market_settlements else None,
        }
     virtual_production_writer = CsvMultiRowReporter.from_dict(
         virtual_production_file, virtual_production_entries_per_hour,
         virtual_production_columns)
     stats_manager.register_for_sced_stats(
         virtual_production_writer.write_record)
     stats_manager.register_for_overall_stats(
         lambda overall: virtual_production_file.close())
Beispiel #3
0
 def setup_bus_detail(self, options, stats_manager: StatsManager):
     _round = self._round
     bus_path = os.path.join(options.output_directory, 'bus_detail.csv')
     bus_file = open(bus_path, 'w', newline='')
     bus_entries_per_hour = lambda ops: ops.observed_bus_mismatches.keys()
     bus_columns = {
         'Date':       lambda ops,b: str(ops.timestamp.date()),
         'Hour':       lambda ops,b: ops.timestamp.hour,
         'Minute':     lambda ops,b: ops.timestamp.minute,
         'Bus':        lambda ops,b: b,
         'Demand':     lambda ops,b: _round(ops.bus_demands[b]),
         'Shortfall':  lambda ops,b: _round(ops.observed_bus_mismatches[b]) \
                 if ops.observed_bus_mismatches[b] > 0.0 else 0.0,
         'Overgeneration':  lambda ops,b: _round(-ops.observed_bus_mismatches[b]) \
                 if ops.observed_bus_mismatches[b] < 0.0 else 0.0,
         'LMP':        lambda ops,b: _round(ops.observed_bus_LMPs[b]),
         'LMP DA':     lambda ops,b: _round(ops.planning_energy_prices[b]) \
                 if options.compute_market_settlements else None,
        }
     bus_writer = CsvMultiRowReporter.from_dict(bus_file,
                                                bus_entries_per_hour,
                                                bus_columns)
     stats_manager.register_for_sced_stats(bus_writer.write_record)
     stats_manager.register_for_overall_stats(
         lambda overall: bus_file.close())
Beispiel #4
0
 def setup_thermal_detail(self, options, stats_manager: StatsManager):
     _round = self._round
     thermal_details_path = os.path.join(options.output_directory,
                                         'thermal_detail.csv')
     thermal_details_file = open(thermal_details_path, 'w', newline='')
     thermal_details_columns = {
         'Date':       lambda ops,g: str(ops.timestamp.date()),
         'Hour':       lambda ops,g: ops.timestamp.hour,
         'Minute':     lambda ops,g: ops.timestamp.minute,
         'Generator':  lambda ops,g: g,
         'Dispatch':   lambda ops,g: _round(ops.observed_thermal_dispatch_levels[g]),
         'Dispatch DA':lambda ops,g: _round(ops.thermal_gen_cleared_DA[g]) \
                 if options.compute_market_settlements else None,
         'Headroom':   lambda ops,g: _round(ops.observed_thermal_headroom_levels[g]),
         'Unit State': lambda ops,g: ops.observed_thermal_states[g],
         'Unit Cost':  lambda ops,g: _round(ops.observed_costs[g]),
         'Unit Market Revenue': lambda ops,g: _round(
             ops.thermal_gen_revenue[g] + ops.thermal_reserve_revenue[g]) \
             if options.compute_market_settlements else None,
         'Unit Uplift Payment': lambda hourly,g: _round(hourly.thermal_uplift[g])\
                 if options.compute_market_settlements else None,
        }
     thermal_details_entries_per_report = lambda stats: stats.observed_thermal_dispatch_levels.keys(
     )
     thermal_details_writer = CsvMultiRowReporter.from_dict(
         thermal_details_file, thermal_details_entries_per_report,
         thermal_details_columns)
     stats_manager.register_for_sced_stats(
         thermal_details_writer.write_record)
     stats_manager.register_for_overall_stats(
         lambda overall: thermal_details_file.close())
Beispiel #5
0
 def setup_reserves_detail(self, options, stats_manager: StatsManager):
     _round = self._round
     path = os.path.join(options.output_directory, 'reserves_detail.csv')
     file = open(path, 'w', newline='')
     columns = {
            'Date': lambda ops,r: str(ops.timestamp.date()),
            'Hour': lambda ops,r: ops.timestamp.hour,
          'Minute': lambda ops,r: ops.timestamp.minute,
         'Reserve': lambda ops,r: r.reserve_name,
           'Scope': lambda ops,r: r.scope,
       'Magnitude': lambda ops,r: _round(ops.reserve_requirements[r]) \
                                  if r in ops.rt_reserve_products \
                                  else None,
       'Shortfall': lambda ops,r: _round(ops.reserve_shortfalls[r]) \
                                  if r in ops.rt_reserve_products \
                                  else None,
           'Price': lambda ops,r: _round(ops.reserve_RT_prices[r]) \
                                  if r in ops.rt_reserve_products \
                                  else None,
     }
     if options.compute_market_settlements:
         columns.update({'DA Magnitude': lambda ops,r: _round(ops.DA_reserve_requirements[r]) \
                                                       if r in ops.da_reserve_products \
                                                       else None,
                         'DA Shortfall': lambda ops,r: _round(ops.DA_reserve_shortfalls[r]) \
                                                       if r in ops.da_reserve_products \
                                                       else None,
                             'DA Price': lambda ops,r: _round(ops.DA_reserve_prices[r]) \
                                                       if r in ops.da_reserve_products \
                                                       else None,
                        })
     rows_per_ops = lambda ops: ops.all_reserve_products
     writer = CsvMultiRowReporter.from_dict(file, rows_per_ops, columns)
     stats_manager.register_for_sced_stats(writer.write_record)
     stats_manager.register_for_overall_stats(lambda overall: file.close())
Beispiel #6
0
 def setup_thermal_detail(self, options, stats_manager: StatsManager):
     thermal_details_path = os.path.join(options.output_directory,
                                         'thermal_detail.csv')
     thermal_details_file = open(thermal_details_path, 'w', newline='')
     thermal_details_entries_per_hour = lambda hourly: hourly.observed_thermal_dispatch_levels.keys(
     )
     thermal_details_columns = {"Date":       lambda hourly,g: str(hourly.date),
                                "Hour":       lambda hourly,g: hourly.hour + 1,
                                'Generator':  lambda hourly,g: g,
                                'Dispatch':   lambda hourly,g: hourly.observed_thermal_dispatch_levels[g],
                                'Dispatch DA': lambda hourly,g: hourly.thermal_gen_cleared_DA[g] if options.compute_market_settlements else None,
                                'Headroom':   lambda hourly,g: hourly.observed_thermal_headroom_levels[g],
                                'Unit State': lambda hourly,g: hourly.observed_thermal_states[g],
                                'Unit Cost':  lambda hourly,g: hourly.observed_costs[g],
                                'Unit Market Revenue': lambda hourly,g: hourly.thermal_gen_revenue[g] + hourly.thermal_reserve_revenue[g] \
                                                              if options.compute_market_settlements else None,
                                'Unit Uplift Payment': lambda hourly,g: hourly.thermal_uplift[g] if options.compute_market_settlements else None,
                               }
     thermal_details_writer = CsvMultiRowReporter.from_dict(
         thermal_details_file, thermal_details_entries_per_hour,
         thermal_details_columns)
     stats_manager.register_for_hourly_stats(
         thermal_details_writer.write_record)
     stats_manager.register_for_overall_stats(
         lambda overall: thermal_details_file.close())
Beispiel #7
0
 def setup_line_detail(self, options, stats_manager: StatsManager):
     line_path = os.path.join(options.output_directory, 'line_detail.csv')
     line_file = open(line_path, 'w', newline='')
     line_entries_per_hour = lambda ops: ops.observed_flow_levels.keys()
     line_columns = {
         'Date': lambda ops, l: str(ops.timestamp.date()),
         'Hour': lambda ops, l: ops.timestamp.hour,
         'Minute': lambda ops, l: ops.timestamp.minute,
         'Line': lambda ops, l: l,
         'Flow': lambda ops, l: ops.observed_flow_levels[l]
     }
     line_writer = CsvMultiRowReporter.from_dict(line_file,
                                                 line_entries_per_hour,
                                                 line_columns)
     stats_manager.register_for_sced_stats(line_writer.write_record)
     stats_manager.register_for_overall_stats(
         lambda overall: line_file.close())
Beispiel #8
0
 def setup_renewables_detail(self, options, stats_manager: StatsManager):
     renewables_production_path = os.path.join(options.output_directory,
                                               'renewables_detail.csv')
     renewables_production_file = open(renewables_production_path,
                                       'w',
                                       newline='')
     renewables_production_entries_per_hour = lambda hourly: hourly.observed_renewables_levels.keys(
     )
     renewables_production_columns = {
         'Date':
         lambda hourly, g: str(hourly.date),
         'Hour':
         lambda hourly, g: hourly.hour + 1,
         'Generator':
         lambda hourly, g: g,
         'Output':
         lambda hourly, g: hourly.observed_renewables_levels[g],
         'Output DA':
         lambda hourly, g: hourly.renewable_gen_cleared_DA[g]
         if options.compute_market_settlements else None,
         'Curtailment':
         lambda hourly, g: hourly.observed_renewables_curtailment[g],
         'Unit Market Revenue':
         lambda hourly, g: hourly.renewable_gen_revenue[g]
         if options.compute_market_settlements else None,
         'Unit Uplift Payment':
         lambda hourly, g: hourly.renewable_uplift[g]
         if options.compute_market_settlements else None,
     }
     renewables_production_writer = CsvMultiRowReporter.from_dict(
         renewables_production_file, renewables_production_entries_per_hour,
         renewables_production_columns)
     stats_manager.register_for_hourly_stats(
         renewables_production_writer.write_record)
     stats_manager.register_for_overall_stats(
         lambda overall: renewables_production_file.close())