def _update_slits(self, hdr):
        """Recreate slits"""

        # Slits.
        # For the moment we will fuse only reference slits

        # clean existing slits
        self.slits = {}
        mm = []
        for idx in self.LBARS:

            # References from header
            try:
                slit_t = hdr["SLIFL%d" % idx]
                target_type = TargetType(slit_t)
            except KeyError:
                target_type = TargetType.UNKNOWN

            xref = hdr.get("XRSLI%d" % idx, -100) - 1
            yref = hdr.get("YRSLI%d" % idx, -100) - 1
            target_coordinates = (xref, yref)

            xref = hdr.get("XVSLI%d" % idx, -100) - 1
            yref = hdr.get("YVSLI%d" % idx, -100) - 1
            target_coordinates_v = (xref, yref)

            mm.append((idx, target_type, target_coordinates, target_coordinates_v))

        bag = merge_slits(mm, max_slits=3, tol=1e-2)

        for idx, l_ids in bag.items():
            r_ids = [lid + EMIR_NBARS for lid in l_ids]

            lbars = {lid: self.bars[lid] for lid in l_ids}
            rbars = {rid: self.bars[rid] for rid in r_ids}

            this = LogicalSlit(idx, lbars=lbars, rbars=rbars)
            # References from header
            ref = mm[l_ids[0] - 1]
            this.target_type = ref[1]
            this.target_coordinates = ref[2]
            this.target_coordinates_v = ref[3]
            self.slits[idx] = this
Recreate slits