def overplot_lines(ax,
                   catlines_all_wave,
                   list_valid_islitlets,
                   rectwv_coeff,
                   global_integer_offset_x_pix, global_integer_offset_y_pix,
                   ds9_file, debugplot):
    """Overplot lines (arc/OH).

    Parameters
    ----------
    ax : matplotlib axes
        Current plot axes.
    catlines_all_wave : numpy array
        Array with wavelengths of the lines to be overplotted.
    list_valid_islitlets : list of integers
        List with numbers of valid slitlets.
    rectwv_coeff : RectWaveCoeff instance
        Rectification and wavelength calibration coefficients for the
        particular CSU configuration.
    global_integer_offset_x_pix : int
        Global offset in the X direction to be applied after computing
        the expected location.
    global_integer_offset_y_pix : int
        Global offset in the Y direction to be applied after computing
        the expected location.
    ds9_file : file handler or None
        File handler to ds9 region file where the location of lines
        must be saved.
    debugplot : int
        Debugging level for messages and plots. For details see
        'numina.array.display.pause_debugplot.py'.

    """

    for islitlet in list_valid_islitlets:
        crval1_linear = rectwv_coeff.contents[islitlet - 1]['crval1_linear']
        cdelt1_linear = rectwv_coeff.contents[islitlet - 1]['cdelt1_linear']
        crvaln_linear = crval1_linear + (EMIR_NAXIS1 - 1) * cdelt1_linear
        bb_ns1_orig = rectwv_coeff.contents[islitlet - 1]['bb_ns1_orig']
        ttd_order = rectwv_coeff.contents[islitlet - 1]['ttd_order']
        aij = rectwv_coeff.contents[islitlet - 1]['ttd_aij']
        bij = rectwv_coeff.contents[islitlet - 1]['ttd_bij']
        min_row_rectified = float(
            rectwv_coeff.contents[islitlet - 1]['min_row_rectified']
        )
        max_row_rectified = float(
            rectwv_coeff.contents[islitlet - 1]['max_row_rectified']
        )
        mean_row_rectified = (min_row_rectified + max_row_rectified) / 2
        wpoly_coeff = rectwv_coeff.contents[islitlet - 1]['wpoly_coeff']
        x0 = []
        y0 = []
        x1 = []
        y1 = []
        x2 = []
        y2 = []
        for line in catlines_all_wave:
            if crval1_linear <= line <= crvaln_linear:
                tmp_coeff = np.copy(wpoly_coeff)
                tmp_coeff[0] -= line
                tmp_xroots = np.polynomial.Polynomial(tmp_coeff).roots()
                for dum in tmp_xroots:
                    if np.isreal(dum):
                        dum = dum.real
                        if 1 <= dum <= EMIR_NAXIS1:
                            x0.append(dum)
                            y0.append(mean_row_rectified)
                            x1.append(dum)
                            y1.append(min_row_rectified)
                            x2.append(dum)
                            y2.append(max_row_rectified)
        xx0, yy0 = fmap(ttd_order, aij, bij, np.array(x0), np.array(y0))
        xx0 -= global_integer_offset_x_pix
        yy0 += bb_ns1_orig
        yy0 -= global_integer_offset_y_pix
        xx1, yy1 = fmap(ttd_order, aij, bij, np.array(x1), np.array(y1))
        xx1 -= global_integer_offset_x_pix
        yy1 += bb_ns1_orig
        yy1 -= global_integer_offset_y_pix
        xx2, yy2 = fmap(ttd_order, aij, bij, np.array(x2), np.array(y2))
        xx2 -= global_integer_offset_x_pix
        yy2 += bb_ns1_orig
        yy2 -= global_integer_offset_y_pix

        if abs(debugplot) % 10 != 0:
            if abs(debugplot) == 22:
                for xx1_, xx2_, yy1_, yy2_ in zip(xx1, xx2, yy1, yy2):
                    ax.plot([xx1_, xx2_], [yy1_, yy2_], 'c-', linewidth=2.0)
            else:
                ax.plot(xx0, yy0, 'c.')

        if ds9_file is not None:
            ds9_file.write(
                '#\n# islitlet...........: {0}\n'.format(islitlet)
            )
            for xx0_, yy0_ in zip(xx0, yy0):
                ds9_file.write(
                    'circle {0} {1} 2 # fill=1\n'.format(
                        xx0_, yy0_)
                )