class_docstr: A file handler class for VIIRS compact format.
class_docstr_tok: ["A","file","handler","class","for","VIIRS","compact","format","."]
docstr: Read a dataset.
docstr_tok: ["Read","a","dataset","."]
code: def read_dataset(self, dataset_key, info):
      """Read a dataset."""
      h5f = self.h5f
      channel = _channels_dict[dataset_key["name"]]
      chan_dict = dict(
          [
              (key.split("-")[1], key)
              for key in h5f["All_Data"].keys()
              if key.startswith("VIIRS")
          ]
      )
  
      h5rads = h5f["All_Data"][chan_dict[channel]]["Radiance"]
      chunks = h5rads.chunks or CHUNK_SIZE
      rads = xr.DataArray(
          da.from_array(h5rads, chunks=chunks),
          name=dataset_key["name"],
          dims=["y", "x"],
      ).astype(np.float32)
      h5attrs = h5rads.attrs
      scans = h5f["All_Data"]["NumberOfScans"][0]
      rads = rads[: scans * 16, :]
      rads = rads.where(rads <= 65526)
      try:
          rads = xr.where(
              rads <= h5attrs["Threshold"],
              rads * h5attrs["RadianceScaleLow"]
              + h5attrs["RadianceOffsetLow"],
              rads * h5attrs["RadianceScaleHigh"]
              + h5attrs["RadianceOffsetHigh"],
          )
      except (KeyError, AttributeError):
          logger.info("Missing attribute for scaling of %s.", channel)
          pass
      unit = "W m-2 sr-1 μm-1"
      if dataset_key["calibration"] == "counts":
          raise NotImplementedError("Can't get counts from this data")
      if dataset_key["calibration"] in [
          "reflectance",
          "brightness_temperature",
      ]:
          # do calibrate
          try:
              # First guess: VIS or NIR data
              a_vis = h5attrs["EquivalentWidth"]
              b_vis = h5attrs["IntegratedSolarIrradiance"]
              dse = h5attrs["EarthSunDistanceNormalised"]
              rads *= 100 * np.pi * a_vis / b_vis * (dse**2)
              unit = "%"
          except KeyError:
              # Maybe it's IR data?
              try:
                  a_ir = h5attrs["BandCorrectionCoefficientA"]
                  b_ir = h5attrs["BandCorrectionCoefficientB"]
                  lambda_c = h5attrs["CentralWaveLength"]
                  rads *= 1e6
                  rads = (h * c) / (
                      k
                      * lambda_c
                      * np.log(
                          1
                          + (2 * h * c**2) / ((lambda_c**5) * rads)
                      )
                  )
                  rads *= a_ir
                  rads += b_ir
                  unit = "K"
              except KeyError:
                  logger.warning("Calibration failed.")
  
      elif dataset_key["calibration"] != "radiance":
          raise ValueError(
              "Calibration parameter should be radiance, "
              "reflectance or brightness_temperature"
          )
      rads = rads.clip(min=0)
      rads.attrs = self.mda
      rads.attrs["units"] = unit
      return rads
  
imports: import logging
  from contextlib import suppress
  from datetime import datetime, timedelta
  import dask.array
  import h5py
  import numpy
  import xarray
  from satpy.readers.file_handlers import BaseFileHandler
  from satpy.readers.utils import np2str
  from satpy.utils import angle2xyz, get_legacy_chunk_size, lonlat2xyz, xyz2angle, xyz2lonlat
label_desc: Use image node_id 8 for calling the VIIRSCompactFileHandler obj's underlying member method code with example usage: obj.read_dataset(dataset_key, info) and returns: rads