class_docstr: Test the HRITJMAFileHandler.
class_docstr_tok: ["Test","the","HRITJMAFileHandler","."]
docstr: Test calibration.
docstr_tok: ["Test","calibration","."]
code: def test_calibrate(self):
      """Test calibration."""
      # Generate test data
      counts = np.linspace(0, 1200, 25).reshape(5, 5)
      counts[-1, -1] = 65535
      counts = DataArray(da.from_array(counts, chunks=5))
      refl = np.array(
          [
              [-0.1, 4.79247312, 9.68494624, 14.57741935, 19.46989247],
              [
                  24.36236559,
                  29.25483871,
                  34.14731183,
                  39.03978495,
                  43.93225806,
              ],
              [
                  48.82473118,
                  53.7172043,
                  58.60967742,
                  63.50215054,
                  68.39462366,
              ],
              [
                  73.28709677,
                  78.17956989,
                  83.07204301,
                  87.96451613,
                  92.85698925,
              ],
              [97.74946237, 100.0, 100.0, 100.0, np.nan],
          ]
      )
      bt = np.array(
          [
              [
                  329.98,
                  320.20678397,
                  310.43356794,
                  300.66035191,
                  290.88713587,
              ],
              [
                  281.11391984,
                  271.34070381,
                  261.56748778,
                  251.79427175,
                  242.02105572,
              ],
              [
                  232.24783969,
                  222.47462366,
                  212.70140762,
                  202.92819159,
                  193.15497556,
              ],
              [
                  183.38175953,
                  173.6085435,
                  163.83532747,
                  154.06211144,
                  144.28889541,
              ],
              [134.51567937, 130.02, 130.02, 130.02, np.nan],
          ]
      )
  
      # Choose an area near the subsatellite point to avoid masking
      # of space pixels
      mda = self._get_mda(
          nlines=5, ncols=5, loff=1375.0, coff=1375.0, segno=0
      )
      reader = self._get_reader(mda=mda)
  
      # 1. Counts
      res = reader.calibrate(data=counts, calibration="counts")
      assert np.all(counts.values == res.values)
  
      # 2. Reflectance
      res = reader.calibrate(data=counts, calibration="reflectance")
      np.testing.assert_allclose(refl, res.values)  # also compares NaN
  
      # 3. Brightness temperature
      mda_bt = self._get_mda(
          nlines=5,
          ncols=5,
          loff=1375.0,
          coff=1375.0,
          segno=0,
          vis=False,
      )
      reader_bt = self._get_reader(mda=mda_bt)
      res = reader_bt.calibrate(
          data=counts, calibration="brightness_temperature"
      )
      np.testing.assert_allclose(bt, res.values)
  
imports: import unittest
  from unittest import mock
  import dask.array
  import numpy
  from xarray import DataArray
  from satpy.tests.utils import make_dataid
label_desc: Use image node_id 7 for calling the TestHRITJMAFileHandler obj's underlying member method code with example usage: obj.test_calibrate() without return types