Line spectra in interstellar clouds. II. CH and CH$sup +$ in Ophiuchus