class_docstr: Reader for AVHRR L1B files created from the AAPP software.
class_docstr_tok: ["Reader","for","AVHRR","L1B","files","created","from","the","AAPP","software","."]
docstr: Calibrate the data.
code: def calibrate(
      self, dataset_id, pre_launch_coeffs=False, calib_coeffs=None
  ):
      """Calibrate the data."""
      if calib_coeffs is None:
          calib_coeffs = {}
  
      units = {
          "reflectance": "%",
          "brightness_temperature": "K",
          "counts": "",
          "radiance": "W*m-2*sr-1*cm ?",
      }
  
      if dataset_id["name"] in ("3a", "3b") and self._is3b is None:
          # Is it 3a or 3b:
          line_chunks = get_aapp_chunks((self._data.shape[0], 2048))[0]
          self._is3a = (
              da.bitwise_and(
                  da.from_array(
                      self._data["scnlinbit"], chunks=line_chunks
                  ),
                  3,
              )
              == 0
          )
          self._is3b = (
              da.bitwise_and(
                  da.from_array(
                      self._data["scnlinbit"], chunks=line_chunks
                  ),
                  3,
              )
              == 1
          )
  
      try:
          vis_idx = ["1", "2", "3a"].index(dataset_id["name"])
          ir_idx = None
      except ValueError:
          vis_idx = None
          ir_idx = ["3b", "4", "5"].index(dataset_id["name"])
  
      mask = True
      if vis_idx is not None:
          coeffs = calib_coeffs.get("ch" + dataset_id["name"])
          if dataset_id["name"] == "3a":
              mask = self._is3a[:, None]
          ds = create_xarray(
              _vis_calibrate(
                  self._data,
                  vis_idx,
                  dataset_id["calibration"],
                  pre_launch_coeffs,
                  coeffs,
                  mask=mask,
              )
          )
      else:
          if dataset_id["name"] == "3b":
              mask = self._is3b[:, None]
          ds = create_xarray(
              _ir_calibrate(
                  self._header,
                  self._data,
                  ir_idx,
                  dataset_id["calibration"],
                  mask=mask,
              )
          )
  
      ds.attrs["units"] = units[dataset_id["calibration"]]
      ds.attrs.update(dataset_id._asdict())
      return ds
  
imports: import functools
  import logging
  from datetime import datetime, timedelta
  import dask.array
  import numpy
  import xarray
  from dask import delayed
  from satpy.readers.file_handlers import BaseFileHandler
  from satpy.utils import get_chunk_size_limit
label_desc: Use image node_id 16 for calling the AVHRRAAPPL1BFile obj's underlying member method code with example usage: obj.calibrate(dataset_id, pre_launch_coeffs, calib_coeffs) and returns: ds