def convert(self): """ return values from raw_values that are converted to units consistent with output units - energy and annual """ if self.definition == 'absolute': if self.time_unit is None: self.time_unit = 'year' self.values = UnitConverter.unit_convert( self.raw_values, unit_from_num=self.energy_unit, unit_from_den=self.time_unit, unit_to_num=cfg.calculation_energy_unit, unit_to_den='year') self.values = util.remove_df_levels(self.values, cfg.removed_demand_levels, agg_function='mean') if self.demand_tech_unit_type == 'service demand': self.values = UnitConverter.unit_convert( self.values, unit_from_num=self.unit, unit_to_num=self.service_demand_unit) self.absolute = True else: self.values = self.raw_values.copy() self.absolute = False
def convert(self): model_energy_unit = cfg.calculation_energy_unit model_time_step = cfg.getParam('time_step') if self.time_unit is not None: # if sales has a time_unit, then the unit is energy and must be converted to capacity self.values = UnitConverter.unit_convert(self.values, unit_from_num=self.capacity_or_energy_unit, unit_from_den=self.time_unit, unit_to_num=model_energy_unit, unit_to_den=model_time_step) else: # if sales is a capacity unit, the model must convert the unit type to an energy unit for conversion () unit_from_num = self.capacity_or_energy_unit + "_" + model_time_step self.values = UnitConverter.unit_convert(self.values, unit_from_num=unit_from_num, unit_from_den=model_time_step, unit_to_num=model_energy_unit, unit_to_den=model_time_step)
def convert(self): if self.input_type == 'total': self.values = UnitConverter.unit_convert(self.raw_values, unit_from_num=self.unit, unit_to_num=self.unit_to) else: self.values = self.raw_values
def convert(self): """ return values from raw_values that are converted to units consistent with output units """ if self.definition == 'absolute': if self.is_numerator_service: # if the numerator is service, definition has to be flipped in order to make the numerator an energy unit self.values = 1 / self.raw_values numerator_unit = self.denominator_unit denominator_unit = self.numerator_unit self.flipped = True else: self.values = self.raw_values numerator_unit = self.numerator_unit denominator_unit = self.denominator_unit self.flipped = False self.values = UnitConverter.unit_convert( self.values, unit_from_num=numerator_unit, unit_from_den=denominator_unit, unit_to_num=cfg.calculation_energy_unit, unit_to_den=self.service_demand_unit) self.absolute = True else: self.values = self.raw_values.copy() self.absolute = False
def convert_units(self): if self.name is not None: unit_factor = UnitConverter.unit_convert( 1, unit_from_den=self.energy_unit, unit_to_den=cfg.calculation_energy_unit) self.values *= unit_factor
def convert(self): """converts energy units to model energy units and service units to subsector service demand units""" self.values = UnitConverter.unit_convert( self.raw_values, unit_from_num=self.energy_unit, unit_from_den=self.denominator_unit, unit_to_num=cfg.calculation_energy_unit, unit_to_den=self.service_demand_unit)
def convert(self): """ convert raw_values to model currency and capacity (energy_unit/time_step) """ model_energy_unit = cfg.calculation_energy_unit model_time_step = cfg.getParam('time_step') if hasattr(self, 'time_unit') and self.time_unit is not None: # if a cost has a time_unit, then the unit is energy and must be converted to capacity self.values = UnitConverter.unit_convert(self.raw_values, unit_from_den=self.capacity_or_energy_unit, unit_from_num=self.time_unit, unit_to_den=model_energy_unit, unit_to_num=model_time_step) else: # if a cost is a capacity unit, the model must convert the unit type to an energy unit for conversion () unit_from_den = self.capacity_or_energy_unit + "_" + model_time_step self.values = UnitConverter.unit_convert(self.raw_values, unit_from_den=unit_from_den, unit_from_num=model_time_step, unit_to_den=model_energy_unit, unit_to_num=model_time_step) if self.definition == 'absolute': self.values = UnitConverter.currency_convert(self.values, self.currency, self.currency_year) self.absolute = True else: self.absolute = False
def convert(self): """ convert values to model currency and capacity (energy_unit/time_step) """ if self.values is not None: model_energy_unit = cfg.calculation_energy_unit model_time_step = cfg.getParam('time_step') if self.time_unit is not None: self.values = UnitConverter.unit_convert(self.values/self.input_timestep, unit_from_num=self.capacity_or_energy_unit, unit_from_den=self.time_unit, unit_to_num=model_energy_unit, unit_to_den=model_time_step) else: unit_from_num = self.capacity_or_energy_unit + "_" + model_time_step self.values = UnitConverter.unit_convert(self.values/self.input_timestep, unit_from_num=unit_from_num, unit_from_den=model_time_step, unit_to_num=model_energy_unit, unit_to_den=model_time_step)
def convert(self): """ return values from raw_values that are converted to units consistent with output units """ if self.definition == 'absolute': self.values = UnitConverter.unit_convert(self.raw_values, unit_from_num=self.input_unit, unit_to_num=self.output_unit) self.absolute = True else: self.values = self.raw_values.copy() self.absolute = False
def convert(self): """ convert raw_values to model currency and capacity (energy_unit/time_step) """ model_energy_unit = cfg.calculation_energy_unit self.values = UnitConverter.unit_convert(self.raw_values, unit_from_den=self.energy_unit,unit_to_den=model_energy_unit) if self.definition == 'absolute': self.values = UnitConverter.currency_convert(self.values, self.currency, self.currency_year) self.absolute = True else: self.absolute = False
def convert_cost(self): """ convert raw_values to model currency and energy """ self.values = UnitConverter.unit_convert( self.raw_values, unit_from_den=self.cost_denominator_unit, unit_to_den=self.unit_to) self.values = UnitConverter.currency_convert(self.values, self.currency, self.currency_year)
def __init__(self, dispatch_feeders, dispatch_geography, dispatch_geographies, scenario): # Todo, this doesn't seem necessary because we can put these things in the config # #TODO replace 1 with a config parameter # for col, att in util.object_att_from_table('DispatchConfig', 1): # setattr(self, col, att) self.node_config_dict = dict() for supply_node in util.csv_read_table('DispatchNodeConfig', 'supply_node', return_iterable=True): self.node_config_dict[supply_node] = DispatchNodeConfig(supply_node) self.set_dispatch_orders() # self.dispatch_window_dict = dict(util.csv_read_table('DispatchWindows')) # todo doesn't seem used self.curtailment_cost = UnitConverter.unit_convert(0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit) self.unserved_capacity_cost = UnitConverter.unit_convert(10000.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit) self.dist_net_load_penalty = UnitConverter.unit_convert(15000.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit) # this bulk penalty is mostly for transmission self.bulk_net_load_penalty = UnitConverter.unit_convert(5000.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit) self.ld_upward_imbalance_penalty = UnitConverter.unit_convert(150.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit) self.ld_downward_imbalance_penalty = UnitConverter.unit_convert(50.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit) self.dispatch_feeders = dispatch_feeders self.feeders = ['bulk'] + dispatch_feeders self.dispatch_geography = dispatch_geography self.dispatch_geographies = dispatch_geographies self.stdout_detail = getParamAsBoolean('stdout_detail', 'opt') self.transmission = dispatch_transmission.DispatchTransmission(cfg.transmission_constraint, scenario) self.solve_kwargs = {"keepfiles": False, "tee": False}
def convert(self): """ convert raw_values to model currency and capacity (energy_unit/time_step) """ self.values = UnitConverter.currency_convert(self.values, self.currency, self.currency_year) model_energy_unit = cfg.calculation_energy_unit model_time_step = cfg.getParam('time_step') if self.time_unit is not None: # if a cost has a time_unit, then the unit is energy and must be converted to capacity self.values = UnitConverter.unit_convert( self.values, unit_from_den=self.self.capacity_or_energy_unit, unit_from_num=self.time_unit, unit_to_den=model_energy_unit, unit_to_num=model_time_step) else: self.values = UnitConverter.unit_convert( self.values, unit_from_den=self.capacity_or_energy_unit + "_" + model_time_step, unit_to_den=model_energy_unit)
def convert_and_remap(self, unit_type, stock_unit): """convert service demand to stock unit for stocks defined as service demand""" if unit_type == 'service demand': self.remap(map_to='int_values', converted_geography=GeoMapper.demand_primary_geography, fill_timeseries=False) self.int_values = UnitConverter.unit_convert( self.int_values, unit_from_num=self.unit, unit_to_num=stock_unit) self.unit = stock_unit self.current_data_type = self.input_type self.projected = False else: raise ValueError( "should not have called this function for this demand stock unit type" )
def convert_cost(self): """ convert raw_values to model currency and capacity (energy_unit/time_step) """ if self.demand_tech_unit_type == 'service demand': if self.tech_time_unit is None: self.time_unit = 'year' self.values = UnitConverter.unit_convert( self.raw_values, unit_from_num=self.tech_time_unit, unit_from_den=self.unit, unit_to_num=self.stock_time_unit, unit_to_den=self.service_demand_unit) else: self.values = copy.deepcopy(self.raw_values) if self.definition == 'absolute': self.values = UnitConverter.currency_convert( self.values, self.currency, self.currency_year) self.absolute = True else: self.absolute = False
def set_max_min_flex_loads(self, flex_pmin, flex_pmax): self.flex_load_penalty_short = UnitConverter.unit_convert(cfg.getParamAsFloat('flex_load_penalty_short', 'opt'), unit_from_den='megawatt_hour', unit_to_den=cfg.calculation_energy_unit) self.flex_load_penalty_long = UnitConverter.unit_convert(cfg.getParamAsFloat('flex_load_penalty_long', 'opt'), unit_from_den='megawatt_hour', unit_to_den=cfg.calculation_energy_unit) if self.has_flexible_load: self.max_flex_load = flex_pmax.squeeze().to_dict() self.min_flex_load = flex_pmin.squeeze().to_dict()