def initialize_sets(self):
        o = self.config_model
        d = self.data
        path = o.data_path
        #
        # t: Timesteps set
        #
        table_t = pd.read_csv(os.path.join(path, 'set_t.csv'), header=None,
                              index_col=1, parse_dates=[1])
        table_t.columns = ['t_int']
        if self.config_run.get_key('subset_t', default=False):
            table_t = table_t.loc[self.config_run.subset_t[0]:
                                  self.config_run.subset_t[1]]
            self.slice = slice(table_t.iat[0, 0], table_t.iat[-1, 0] + 1)
        else:
            self.slice = slice(None)
        _t = pd.Series([int(t) for t in table_t['t_int'].tolist()])
        d._dt = pd.Series(table_t.index, index=_t.tolist())
        # First set time_res_data and time_res_static across all data
        # `time_res_data` never changes, so always reflects the spacing
        # of time step indices
        d.time_res_data = self.get_timeres()
        # `time_res_static` is updated after time resolution adjustments,
        # so does not reflect the spacing of time step indicex
        d.time_res_static = d.time_res_data
        d.time_res_native = 1  # In the beginning, time_res is native
        # From time_res_data, initialize time_res_series
        d.time_res_series = pd.Series(d.time_res_data, index=d._dt.index)
        # Last index t for which model may still use startup exceptions
        d.startup_time_bounds = d._dt.index[int(o.startup_time
                                                / d.time_res_data)]

        #
        # x: Locations set
        #
        d._x = list(o.locations.keys())
        if self.config_run.get_key('subset_x', default=False):
            d._x = [x for x in d._x if x in self.config_run.subset_x]

        #
        # y: Technologies set
        #
        d._y = set()
        try:
            for k, v in o.locations.items():
                for y in v.techs:
                    if y in o.techs:
                        d._y.add(y)
                    else:
                        e = exceptions.ModelError
                        raise e('Location `{}` '
                                'uses undefined tech `{}`.'.format(k, y))
        except __HOLE__:
            e = exceptions.ModelError
            raise e('The region `' + k + '` does not allow '
                    'any technologies via `techs`. Must give '
                    'at least one technology per region.')
        d._y = list(d._y)
        if self.config_run.get_key('subset_y', default=False):
            d._y = [y for y in d._y if y in self.config_run.subset_y]
        # Subset of transmission technologies, if any defined
        # Used to initialized transmission techs further below
        # (not yet added to d._y here)
        if ('links' in o) and (o.links is not None):
            d._y_transmission = transmission.get_transmission_techs(o.links)
            d.transmission_y = list(set([list(v.keys())[0]
                                    for k, v in o.links.items()]))
        else:
            d._y_transmission = []
            d.transmission_y = []
        # Subset of conversion technologies
        d._y_conversion = [y for y in d._y if self.ischild(y, of='conversion')]
        # Subset of supply, demand, storage technologies
        d._y_pc = [y for y in d._y
                   if not self.ischild(y, of='conversion')
                   or self.ischild(y, of='transmission')]
        # Subset of technologies that define es_prod/es_con
        d._y_prod = ([y for y in d._y if not self.ischild(y, of='demand')]
                     + d._y_transmission)
        d._y_con = ([y for y in d._y if not self.ischild(y, of='supply')]
                    + d._y_transmission)

        # Subset of technologies that allow rb
        d._y_rb = []
        for x in d._x:
            if self.get_option(y + '.constraints.allow_rb', x=x) is True:
                d._y_rb.append(y)
                break  # No need to look at other x

        # Subset of technologies with parasitics (carrier efficiency != 1.0)
        d._y_p = []
        for x in d._x:
            if self.get_option(y + '.constraints.c_eff', x=x) != 1.0:
                d._y_p.append(y)
                break  # No need to look at other x

        #
        # Locations settings matrix and transmission technologies
        #
        d.locations = locations.generate_location_matrix(o.locations,
                                                         techs=d._y)
        # For simplicity, only keep the locations that are actually in set `x`
        d.locations = d.locations.loc[d._x, :]

        #
        # c: Carriers set
        #
        d._c = set()
        for y in d._y:  # Only add carriers for allowed technologies
            d._c.update([self.get_option(y + '.carrier')])
            if self.get_option(y + '.source_carrier'):
                d._c.update([self.get_option(y + '.source_carrier')])
        d._c = list(d._c)

        #
        # Initialize transmission technologies
        #
        self._initialize_transmission()
        #
        # self.data._y is now complete, ensure that all techs conform to the
        # rule that only "head" techs can be used in the model
        #
        for y in self.data._y:
            if self.get_option(y + '.parent') in self.data._y:
                e = exceptions.ModelError
                raise e('Only technologies without children can be used '
                        'in the model definition '
                        '({}, {}).'.format(y, self.get_option(y + '.parent')))
        #
        # k: Cost classes set
        #
        classes = [list(o.techs[k].costs.keys()) for k in o.techs
                   if k != 'defaults'  # Prevent 'default' from entering set
                   if 'costs' in o.techs[k]]
        # Flatten list and make sure 'monetary' is in it
        classes = ([i for i in itertools.chain.from_iterable(classes)]
                   + ['monetary'])
        d._k = list(set(classes))  # Remove any duplicates with a set roundtrip
dataset/ETHPy150Open calliope-project/calliope/calliope/core.py/Model.initialize_sets