class_docstr: The base class for the FengYun4 AGRI and GHI readers.
class_docstr_tok: ["The","base","class","for","the","FengYun4","AGRI","and","GHI","readers","."]
docstr: Calibrate to reflectance [%].
docstr_tok: ["Calibrate","to","reflectance","[","%","]","."]
code: def calibrate_to_reflectance(self, data, channel_index, ds_info):
      """Calibrate to reflectance [%]."""
      logger.debug("Calibrating to reflectances")
      # using the corresponding SCALE and OFFSET
      if self.sensor != "AGRI" and self.sensor != "GHI":
          raise ValueError(f"Unsupported sensor type: {self.sensor}")
  
      coeffs = self.reflectance_coeffs
      num_channel = coeffs.shape[0]
  
      if self.sensor == "AGRI" and num_channel == 1:
          # only channel_2, resolution = 500 m
          channel_index = 0
      data.data = da.where(
          data.data == data.attrs["FillValue"].item(), np.nan, data.data
      )
      data.attrs["scale_factor"] = coeffs[channel_index, 0].item()
      data.attrs["add_offset"] = coeffs[channel_index, 1].item()
      data = self.scale(
          data, data.attrs["scale_factor"], data.attrs["add_offset"]
      )
      data *= 100
      ds_info["valid_range"] = (
          data.attrs["valid_range"] * data.attrs["scale_factor"]
          + data.attrs["add_offset"]
      )
      ds_info["valid_range"] = ds_info["valid_range"] * 100
      return data
  
imports: import logging
  from datetime import datetime
  import dask.array
  import numpy
  import xarray
  from satpy._compat import cached_property
  from satpy.readers._geos_area import get_area_definition, get_area_extent
  from satpy.readers.hdf5_utils import HDF5FileHandler
label_desc: Use image node_id 7 for calling the FY4Base obj's underlying member method code with example usage: obj.calibrate_to_reflectance(data, channel_index, ds_info) and returns: data