예제 #1
0
 def __init__(self, id, subsector_id, service_demand_unit, stock_time_unit, cost_of_capital, scenario=None, **kwargs):
     self.id = id
     self.subsector_id = subsector_id
     self.scenario = scenario
     StockItem.__init__(self)
     self.service_demand_unit = service_demand_unit
     self.stock_time_unit = stock_time_unit
     for col, att in util.object_att_from_table('DemandTechs', self.id):
         setattr(self, col, att)
     # if cost_of_capital at the technology level is None, it uses subsector defaults
     if self.cost_of_capital is None:
         self.cost_of_capital = cost_of_capital
     else:
         pass
     # we can have multiple sales shares because sales share may be specific
     # to the transition between two technolog)
     self.reference_sales_shares = {}
     if self.id in util.sql_read_table('DemandSalesData', 'demand_technology_id', return_unique=True, return_iterable=True):
         self.reference_sales_shares[1] = SalesShare(id=self.id, subsector_id=self.subsector_id, reference=True,
                                                     sql_id_table='DemandSales', sql_data_table='DemandSalesData',
                                                     primary_key='subsector_id', data_id_key='demand_technology_id',
                                                     scenario=scenario)
     self.book_life()
     self.add_class()
     self.min_year()
     if self.shape_id is not None:
         self.shape = shape.shapes.data[self.shape_id]
예제 #2
0
 def add_sales_share_measures(self):
     self.sales_shares = {}
     sales_share_ids = self.scenario.get_measures('DemandSalesShareMeasures', self.subsector_id, self.id)
     for sales_share_id in sales_share_ids:
         self.sales_shares[sales_share_id] = SalesShare(id=sales_share_id, subsector_id=self.subsector_id,
                                                        reference=False, sql_id_table='DemandSalesShareMeasures',
                                                        sql_data_table='DemandSalesShareMeasuresData',
                                                        primary_key='id', data_id_key='parent_id',
                                                        scenario=self.scenario)
 def add_sales_share_measures(self, package_id):
     self.sales_shares = {}
     measure_ids = util.sql_read_table('DemandSalesMeasurePackagesData', 'measure_id', package_id=package_id,
                                       return_iterable=True)
     for measure_id in measure_ids:
         sales_share_ids = util.sql_read_table('DemandSalesMeasures', 'id', demand_tech_id=self.id, id=measure_id,
                                               return_iterable=True)
         for sales_share_id in sales_share_ids:
             self.sales_shares[sales_share_id] = SalesShare(id=sales_share_id, subsector_id=self.subsector_id,
                                                            reference=False, sql_id_table='DemandSalesMeasures',
                                                            sql_data_table='DemandSalesMeasuresData')