#NEWLINE# def initialize_sets( self ) : #NEWLINE# #INDENT# o = self . config_model #NEWLINE# d = self . data #NEWLINE# path = o . data_path #NEWLINE# table_t = pd . read_csv ( os . path . join ( path , 'set_t.csv' ) , header = None , index_col = 1 , parse_dates = [ 1 ] ) #NEWLINE# table_t . columns = [ 't_int' ] #NEWLINE# if self . config_run . get_key ( 'subset_t' , default = False ) : #NEWLINE# #INDENT# table_t = table_t . loc [ self . config_run . subset_t [ 0 ] : self . config_run . subset_t [ 1 ] ] #NEWLINE# self . slice = slice ( table_t . iat [ ( 0 , 0 ) ] , ( table_t . iat [ ( ( - 1 ) , 0 ) ] + 1 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . slice = slice ( None ) #NEWLINE# #UNINDENT# _t = pd . Series ( [ int ( t ) for t in table_t [ 't_int' ] . tolist ( ) ] ) #NEWLINE# d . _dt = pd . Series ( table_t . index , index = _t . tolist ( ) ) #NEWLINE# d . time_res_data = self . get_timeres ( ) #NEWLINE# d . time_res_static = d . time_res_data #NEWLINE# d . time_res_native = 1 #NEWLINE# d . time_res_series = pd . Series ( d . time_res_data , index = d . _dt . index ) #NEWLINE# d . startup_time_bounds = d . _dt . index [ int ( ( o . startup_time / d . time_res_data ) ) ] #NEWLINE# d . _x = list ( o . locations . keys ( ) ) #NEWLINE# if self . config_run . get_key ( 'subset_x' , default = False ) : #NEWLINE# #INDENT# d . _x = [ x for x in d . _x if ( x in self . config_run . subset_x ) ] #NEWLINE# #UNINDENT# d . _y = set ( ) #NEWLINE# try : #NEWLINE# #INDENT# for ( k , v ) in o . locations . items ( ) : #NEWLINE# #INDENT# for y in v . techs : #NEWLINE# #INDENT# if ( y in o . techs ) : #NEWLINE# #INDENT# d . _y . add ( y ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# e = exceptions . ModelError #NEWLINE# raise e ( 'Location `{}` uses undefined tech `{}`.' . format ( k , y ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# e = exceptions . ModelError #NEWLINE# raise e ( ( ( 'The region `' + k ) + '` does not allow any technologies via `techs`. Must give at least one technology per region.' ) ) #NEWLINE# #UNINDENT# d . _y = list ( d . _y ) #NEWLINE# if self . config_run . get_key ( 'subset_y' , default = False ) : #NEWLINE# #INDENT# d . _y = [ y for y in d . _y if ( y in self . config_run . subset_y ) ] #NEWLINE# #UNINDENT# if ( ( 'links' in o ) and ( o . links is not None ) ) : #NEWLINE# #INDENT# d . _y_transmission = transmission . get_transmission_techs ( o . links ) #NEWLINE# d . transmission_y = list ( set ( [ list ( v . keys ( ) ) [ 0 ] for ( k , v ) in o . links . items ( ) ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# d . _y_transmission = [ ] #NEWLINE# d . transmission_y = [ ] #NEWLINE# #UNINDENT# d . _y_conversion = [ y for y in d . _y if self . ischild ( y , of = 'conversion' ) ] #NEWLINE# d . _y_pc = [ y for y in d . _y if ( ( not self . ischild ( y , of = 'conversion' ) ) or self . ischild ( y , of = 'transmission' ) ) ] #NEWLINE# d . _y_prod = ( [ y for y in d . _y if ( not self . ischild ( y , of = 'demand' ) ) ] + d . _y_transmission ) #NEWLINE# d . _y_con = ( [ y for y in d . _y if ( not self . ischild ( y , of = 'supply' ) ) ] + d . _y_transmission ) #NEWLINE# d . _y_rb = [ ] #NEWLINE# for x in d . _x : #NEWLINE# #INDENT# if ( self . get_option ( ( y + '.constraints.allow_rb' ) , x = x ) is True ) : #NEWLINE# #INDENT# d . _y_rb . append ( y ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# d . _y_p = [ ] #NEWLINE# for x in d . _x : #NEWLINE# #INDENT# if ( self . get_option ( ( y + '.constraints.c_eff' ) , x = x ) != 1.0 ) : #NEWLINE# #INDENT# d . _y_p . append ( y ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# d . locations = locations . generate_location_matrix ( o . locations , techs = d . _y ) #NEWLINE# d . locations = d . locations . loc [ d . _x , : ] #NEWLINE# d . _c = set ( ) #NEWLINE# for y in d . _y : #NEWLINE# #INDENT# d . _c . update ( [ self . get_option ( ( y + '.carrier' ) ) ] ) #NEWLINE# if self . get_option ( ( y + '.source_carrier' ) ) : #NEWLINE# #INDENT# d . _c . update ( [ self . get_option ( ( y + '.source_carrier' ) ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# d . _c = list ( d . _c ) #NEWLINE# self . _initialize_transmission ( ) #NEWLINE# for y in self . data . _y : #NEWLINE# #INDENT# if ( self . get_option ( ( y + '.parent' ) ) in self . data . _y ) : #NEWLINE# #INDENT# e = exceptions . ModelError #NEWLINE# raise e ( 'Only technologies without children can be used in the model definition ({}, {}).' . format ( y , self . get_option ( ( y + '.parent' ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# classes = [ list ( o . techs [ k ] . costs . keys ( ) ) for k in o . techs if ( k != 'defaults' ) if ( 'costs' in o . techs [ k ] ) ] #NEWLINE# classes = ( [ i for i in itertools . chain . from_iterable ( classes ) ] + [ 'monetary' ] ) #NEWLINE# d . _k = list ( set ( classes ) )