code: def _apply_data_mask(self, data):
          
  
          data = self._format_data(data)
  
          masked_data, pixels_affected = [], 0
          data_mask = self._configuration.get("masks", {}).get("data", [])
          for spectrum in data:
              masked_spectrum = spectrum.copy()
              for start, end in data_mask:
                  idx = np.clip(
                      masked_spectrum.disp.searchsorted([start, end]) + [0, 1],
                      0, masked_spectrum.disp.size)
                  masked_spectrum.flux[idx[0]:idx[1]] = np.nan
                  pixels_affected += np.clip(np.ptp(idx) - 1, 0, None)
              masked_data.append(masked_spectrum)
          
          logger.debug("{0} observed pixels were masked according to the data "
              "mask: {1}".format(pixels_affected, data_mask))
  
          return (masked_data, pixels_affected)
docs: Apply pre-defined masks to the data.