class_docstr: Tests for the AHI HSD file handler.
class_docstr_tok: ["Tests","for","the","AHI","HSD","file","handler","."]
docstr: Test masking of space pixels.
docstr_tok: ["Test","masking","of","space","pixels","."]
code: def test_read_band(self, calibrate, *mocks):
      """Test masking of space pixels."""
      nrows = 25
      ncols = 100
      calibrate.return_value = np.ones((nrows, ncols))
      with _fake_hsd_handler() as fh:
          fh.data_info["number_of_columns"] = ncols
          fh.data_info["number_of_lines"] = nrows
          with warnings.catch_warnings():
              # The header isn't valid
              warnings.filterwarnings(
                  "ignore",
                  category=UserWarning,
                  message=r"Actual .* header size",
              )
              im = fh.read_band(mock.MagicMock(), mock.MagicMock())
          # Note: Within the earth's shape get_geostationary_mask() is True but the numpy.ma mask
          # is False
          mask = im.to_masked_array().mask
          ref_mask = np.logical_not(
              get_geostationary_mask(fh.area).compute()
          )
          np.testing.assert_equal(mask, ref_mask)
  
          # Test attributes
          orb_params_exp = {
              "projection_longitude": 140.7,
              "projection_latitude": 0.0,
              "projection_altitude": 35785863.0,
              "satellite_actual_longitude": 140.657,
              "satellite_actual_latitude": 0.0,
              "satellite_actual_altitude": 35786850,
              "nadir_longitude": 140.252539,
              "nadir_latitude": 0.01674775,
          }
          actual_obs_params = im.attrs["orbital_parameters"]
          for key, value in orb_params_exp.items():
              assert key in actual_obs_params
              np.testing.assert_allclose(value, actual_obs_params[key])
  
          time_params_exp = {
              "nominal_start_time": datetime(2018, 10, 22, 3, 0, 0, 0),
              "nominal_end_time": datetime(2018, 10, 22, 3, 0, 0, 0),
              "observation_start_time": datetime(
                  2018, 10, 22, 3, 0, 20, 596896
              ),
              "observation_end_time": datetime(
                  2018, 10, 22, 3, 0, 53, 947296
              ),
          }
          actual_time_params = im.attrs["time_parameters"]
          for key, value in time_params_exp.items():
              assert key in actual_time_params
              assert value == actual_time_params[key]
  
          # Test if masking space pixels disables with appropriate flag
          fh.mask_space = False
          with mock.patch(
              "satpy.readers.ahi_hsd.AHIHSDFileHandler._mask_space"
          ) as mask_space:
              with warnings.catch_warnings():
                  # The header isn't valid
                  warnings.filterwarnings(
                      "ignore",
                      category=UserWarning,
                      message=r"Actual .* header size",
                  )
                  fh.read_band(mock.MagicMock(), mock.MagicMock())
              mask_space.assert_not_called()
  
imports: from __future__ import annotations
  import contextlib
  import unittest
  import warnings
  from datetime import datetime
  from typing import Any, Dict
  from unittest import mock
  import dask.array
  import numpy
  import pytest
  from satpy.readers.ahi_hsd import AHIHSDFileHandler
  from satpy.readers.utils import get_geostationary_mask
  from satpy.tests.utils import make_dataid
label_desc: Use image node_id 4 for calling the TestAHIHSDFileHandler obj's underlying member method code with example usage: obj.test_read_band(calibrate) without return types