def _get_origin_slice(self, group, component, source_id=None, dust_id=None, n_scat=None):

        track_origin = group.attrs['track_origin'].decode('utf-8')

        if track_origin == 'no' and component != 'total':
            raise Exception("cannot extract component=%s - file only contains total flux" % component)

        if track_origin != 'detailed':
            if source_id is not None:
                raise Exception("cannot specify source_id since track_origin was not set to 'detailed'")
            if dust_id is not None:
                raise Exception("cannot specify dust_id since track_origin was not set to 'detailed'")

        if track_origin in ['basic', 'detailed']:

            if component == 'source_emit':
                io = 0
            elif component == 'dust_emit':
                io = 1
            elif component == 'source_scat':
                io = 2
            elif component == 'dust_scat':
                io = 3
            else:
                raise ValueError("component should be one of total/source_emit/dust_emit/source_scat/dust_scat since track_origin='{0}'".format(track_origin))

            if track_origin == 'detailed':

                if isinstance(source_id, basestring) and source_id != 'all':
                    try:
                        source_id = self.get_available_sources().index(source_id)
                    except ValueError:
                        raise ValueError("No source named {0}".format(source_id))

                ns = group.attrs['n_sources']
                nd = group.attrs['n_dust']

                io = ((io - (io + 1) % 2 + 1) * ns + (io - io % 2) * nd) / 2

                if component.startswith('source'):
                    if source_id is None or source_id == 'all':
                        io = (io, io + ns)
                    else:
                        if source_id < 0 or source_id >= ns:
                            raise ValueError("source_id should be between 0 and %i" % (ns - 1))
                        io = io + source_id
                else:
                    if dust_id is None or dust_id == 'all':
                        io = (io, io + nd)
                    else:
                        if dust_id < 0 or dust_id >= nd:
                            raise ValueError("dust_id should be between 0 and %i" % (nd - 1))
                        io = io + dust_id

        elif track_origin == 'scatterings':

            if 'track_n_scat' in group.attrs:
                track_n_scat = group.attrs['track_n_scat']
            else:
                track_n_scat = 0

            if component == 'source':
                io = 0
            elif component == 'dust':
                io = track_n_scat + 2
            else:
                raise ValueError("component should be one of total/source/dust since track_origin='scatterings'")

            if n_scat is None:
                # We need to remember to take into account the additional slice
                # that contains the remaining flux. The upper bound of the
                # slice is exclusive.
                io = (io, io + track_n_scat + 2)
            else:
                if n_scat >= 0 and n_scat <= track_n_scat:
                    io += n_scat
                else:
                    raise ValueError("n_scat should be between 0 and {0}".format(track_n_scat))

        else:

            raise ValueError("track_origin should be one of basic/detailed/scatterings")

        return io
dataset/ETHPy150Open hyperion-rt/hyperion/hyperion/model/model_output.py/ModelOutput._get_origin_slice/original