def calculate(self, vintages, years): self.vintages = vintages self.years = years if self.data and self.raw_values is not None: self.remap(time_index_name='vintage') self.values.replace(0,1,inplace=True) util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values', reverse=True)
def levelize_costs(self): if hasattr(self, 'is_levelized'): inflation = float(cfg.cfgfile.get('case', 'inflation_rate')) rate = self.cost_of_capital - inflation if self.is_levelized == 0: self.values_level = -np.pmt(rate, self.book_life, 1, 0, 'end') * self.values util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) else: self.values_level = self.values.copy() util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values else: raise ValueError( 'Supply Technology id %s needs to indicate whether costs are levelized ' % self.id)
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self.data and self.raw_values is not None: self.remap(time_index_name='vintage') util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values', reverse=True) elif self.data is False: index = pd.MultiIndex.from_product([cfg.geo.geographies[cfg.cfgfile.get('case','primary_geography')],self.vintages], names=[cfg.cfgfile.get('case', 'primary_geography'),'vintage']) self.values = util.empty_df(index,columns=years,fill_value=0.0) self.data = True
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self._has_data and self.raw_values is not None: self.remap(time_index_name='vintage', converted_geography=GeoMapper.supply_primary_geography) util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values', reverse=True) elif not self._has_data: index = pd.MultiIndex.from_product([GeoMapper.geography_to_gau[GeoMapper.supply_primary_geography],self.vintages], names=[GeoMapper.supply_primary_geography,'vintage']) self.values = util.empty_df(index,columns=years,fill_value=0.0) self._has_data = True
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self.data and self.raw_values is not None: self.remap(map_from='raw_values', map_to='values', time_index_name='vintage') util.convert_age(self, reverse=True, vintages=self.vintages, years=self.years) if self.data is False: self.absolute = False if self.raw_values is None: # if the class is empty, then there is no data for conversion, so the class is considered converted self.absolute = True
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self.data and self.raw_values is not None: self.remap(time_index_name='vintage') self.values.replace(0, 1, inplace=True) util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values', reverse=True)
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self._has_data and self.raw_values is not None and (cfg.rio_supply_run is not True or 'vintage' in self.raw_values.index.names): self.remap(time_index_name='vintage', converted_geography=GeoMapper.supply_primary_geography,fill_value=np.nan) self.values.replace(0,1,inplace=True) util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values', reverse=True) elif self._has_data and self.raw_values is not None and cfg.rio_supply_run==True: self.remap(time_index_name='year', converted_geography=GeoMapper.supply_primary_geography, fill_value=np.nan) self.values.replace(0, 1, inplace=True) self.values = util.add_and_set_index(self.values,'vintage',self.vintages,index_location=-1) self.values = self.values.squeeze().unstack(level='year')
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self._has_data and self.raw_values is not None: self.convert() self.remap(map_from='values', map_to='values', converted_geography=GeoMapper.supply_primary_geography, time_index_name='vintage') util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values_level', reverse=False) if not self._has_data: self.absolute = False if self.raw_values is None: # if the class is empty, then there is no data for conversion, so the class is considered converted self.absolute = True
def levelize_costs(self): if hasattr(self, 'is_levelized'): inflation = float(cfg.cfgfile.get('case', 'inflation_rate')) rate = self.cost_of_capital - inflation if self.is_levelized == 0: self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) else: self.values_level = self.values.copy() util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values else: raise ValueError('Supply Technology id %s needs to indicate whether costs are levelized ' %self.id)
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self.data: self.remap(map_from='raw_values', map_to='values', time_index_name='vintage') util.convert_age(self, reverse=True, vintages=self.vintages, years=self.years) elif self.data is False: setattr(self, 'converted', False) if self.empty is True: # if the class is empty, then there is no data for conversion, so the class is considered converted self.converted = True else: self.empty = False
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self.data and self.empty is False: self.convert() self.remap(map_from='values', map_to='values', time_index_name='vintage') util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values', reverse=True) elif self.data is False: setattr(self, 'converted', False) else: self.converted = False # adds fixed output shapes for technologies which are not dispatchable if self.empty is True: # if the class is empty, then there is no data for conversion, so the class is considered converted self.converted = True else: self.empty = False
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self.data and self.raw_values is not None: self.convert() self.remap(map_from='values', map_to='values', time_index_name='vintage') util.convert_age(self, reverse=True, vintages=self.vintages, years=self.years) self.values = util.remove_df_levels(self.values, cfg.removed_demand_levels, agg_function='mean') if self.data is False: self.absolute = False if self.raw_values is None: # if the class is empty, then there is no data for conversion, so the class is considered converted self.absolute = True
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self.data and self.empty is False: self.remap() util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values', reverse=True) elif self.data is False: index = pd.MultiIndex.from_product([cfg.geo.geographies[cfg.cfgfile.get('case','primary_geography')],self.vintages], names=[cfg.cfgfile.get('case', 'primary_geography'),'vintage']) self.values = util.empty_df(index,columns=years,fill_value=1.0) self.data = True self.empty = False setattr(self, 'converted', False) else: self.converted = False # adds fixed output shapes for technologies which are not dispatchable if self.empty is True: # if the class is empty, then there is no data for conversion, so the class is considered converted self.converted = True else: self.empty = False
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self._has_data and self.raw_values is not None and cfg.rio_supply_run and 'year' in self.raw_values.index.names: self.remap(map_from='raw_values', map_to='values', current_geography=cfg.rio_geography,converted_geography=GeoMapper.supply_primary_geography, time_index_name='year', lower=None, missing_intensity_geos=False) self.values = self.values.unstack('year') self.values.columns = self.values.columns.droplevel() self.values = pd.concat([self.values] *len(self.vintages),keys=self.vintages,names=['vintage']) self.values['efficiency_type'] = 'consumed' self.values = self.values.set_index('efficiency_type',append=True) elif self._has_data and self.raw_values is not None: self.convert() self.remap(map_from='values', map_to='values', converted_geography=GeoMapper.supply_primary_geography, time_index_name='vintage', lower=None,missing_intensity_geos=False) util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values', attr_to='values', reverse=True) if not self._has_data: self.absolute = False if self.raw_values is None: # if the class is empty, then there is no data for conversion, so the class is considered converted self.absolute = True
def levelize_costs(self): if self.is_levelized == 1: inflation = float(cfg.cfgfile.get('case', 'inflation_rate')) rate = self.cost_of_capital - inflation if self.is_levelized == 0: self.values_level = -np.pmt(rate, self.book_life, 1, 0, 'end') * self.values util.convert_age(self, attr_from='values_level', attr_to='values_level', reverse=False, vintages=self.vintages, years=self.years) else: self.values_level = self.values.copy() util.convert_age(self, attr_from='values_level', attr_to='values_level', reverse=False, vintages=self.vintages, years=self.years) self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values else: util.convert_age(self, reverse=False, vintages=self.vintages, years=self.years)
def levelize_costs(self): if hasattr(self, 'is_levelized') and ( self.definition == 'absolute' or (self.definition == 'relative' and self.reference_tech_operation == 'add')): inflation = cfg.getParamAsFloat('inflation_rate') rate = self.cost_of_capital - inflation if self.is_levelized == 0: self.values_level = -np.pmt(rate, self.book_life, 1, 0, 'end') * self.values util.convert_age(self, attr_from='values_level', attr_to='values_level', reverse=False, vintages=self.vintages, years=self.years) else: self.values_level = self.values.copy() util.convert_age(self, attr_from='values_level', attr_to='value_level', reverse=False, vintages=self.vintages, years=self.years) self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values else: util.convert_age(self, attr_from='values', attr_to='values_level', reverse=False, vintages=self.vintages, years=self.years)
def calculate(self, vintages, years): self.vintages = vintages self.years = years if self._has_data and self.raw_values is not None: self.remap(map_from='raw_values', map_to='values', time_index_name='vintage', converted_geography=GeoMapper.demand_primary_geography) util.convert_age(self, attr_from='values', attr_to='values', reverse=False, vintages=self.vintages, years=self.years) self.values = util.remove_df_levels(self.values, cfg.removed_demand_levels, agg_function='mean') if not self._has_data: self.absolute = False if self.raw_values is None: # if the class is empty, then there is no data for conversion, so the class is considered converted self.absolute = True
def levelize_costs(self): if hasattr(self, 'is_levelized'): inflation = float(cfg.cfgfile.get('case', 'inflation_rate')) rate = self.cost_of_capital - inflation if self.is_levelized == 0: self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) else: self.values_level = self.values.copy() util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values else: util.convert_age(self, vintages=self.vintages, years=self.years, reverse=False)
def levelize_costs(self): if hasattr(self, 'is_levelized'): inflation = cfg.getParamAsFloat('inflation_rate') try: rate = self.cost_of_capital - inflation except: pdb.set_trace() if self.is_levelized == 0: self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) elif self.is_levelized==1: self.values_level = self.values.copy() util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values elif self.definition == 'relative': self.values_level = self.values.copy() util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False) else: raise ValueError("no specification of whether the technology cost is levelized") else: raise ValueError('Supply Technology id %s needs to indicate whether costs are levelized ' %self.name)