class_docstr: A file handler class for VIIRS compact format.
class_docstr_tok: ["A","file","handler","class","for","VIIRS","compact","format","."]
docstr: Initialize the reader.
docstr_tok: ["Initialize","the","reader","."]
code: def __init__(self, filename, filename_info, filetype_info):
      """Initialize the reader."""
      super(VIIRSCompactFileHandler, self).__init__(
          filename, filename_info, filetype_info
      )
      self.h5f = h5py.File(self.filename, "r")
      self.finfo = filename_info
      self.lons = None
      self.lats = None
      if filetype_info["file_type"] == "compact_m":
          self.ch_type = "MOD"
      elif filetype_info["file_type"] == "compact_dnb":
          self.ch_type = "DNB"
      else:
          raise IOError("Compact Viirs file type not recognized.")
  
      geo_data = self.h5f["Data_Products"][
          "VIIRS-%s-GEO" % self.ch_type
      ]["VIIRS-%s-GEO_Gran_0" % self.ch_type]
      self.min_lat = geo_data.attrs["South_Bounding_Coordinate"].item()
      self.max_lat = geo_data.attrs["North_Bounding_Coordinate"].item()
      self.min_lon = geo_data.attrs["West_Bounding_Coordinate"].item()
      self.max_lon = geo_data.attrs["East_Bounding_Coordinate"].item()
  
      self.switch_to_cart = (abs(self.max_lon - self.min_lon) > 90) or (
          max(abs(self.min_lat), abs(self.max_lat)) > 60
      )
  
      self.scans = self.h5f["All_Data"]["NumberOfScans"][0]
      self.geography = self.h5f["All_Data"][
          "VIIRS-%s-GEO_All" % self.ch_type
      ]
  
      for key in self.h5f["All_Data"].keys():
          if key.startswith("VIIRS") and key.endswith("SDR_All"):
              channel = key.split("-")[1]
              break
  
      # This supposes there is only one tiepoint zone in the track direction.
      channel_path = f"All_Data/VIIRS-{channel}-SDR_All"
      self.scan_size = (
          self.h5f[channel_path].attrs["TiePointZoneSizeTrack"].item()
      )
      self.track_offset = self.h5f[channel_path].attrs[
          "PixelOffsetTrack"
      ][()]
      self.scan_offset = self.h5f[channel_path].attrs[
          "PixelOffsetScan"
      ][()]
  
      try:
          self.group_locations = self.geography[
              "TiePointZoneGroupLocationScanCompact"
          ][()]
      except KeyError:
          self.group_locations = [0]
  
      self.tpz_sizes = da.from_array(
          self.h5f[channel_path].attrs["TiePointZoneSizeScan"], chunks=1
      )
      if len(self.tpz_sizes.shape) == 2:
          if self.tpz_sizes.shape[1] != 1:
              raise NotImplementedError(
                  "Can't handle 2 dimensional tiepoint zones."
              )
          self.tpz_sizes = self.tpz_sizes.squeeze(1)
      self.nb_tiepoint_zones = self.geography[
          "NumberOfTiePointZonesScan"
      ][()]
      self.c_align = da.from_array(
          self.geography["AlignmentCoefficient"],
          chunks=tuple(self.nb_tiepoint_zones),
      )
      self.c_exp = da.from_array(
          self.geography["ExpansionCoefficient"],
          chunks=tuple(self.nb_tiepoint_zones),
      )
      self.nb_tiepoint_zones = da.from_array(
          self.nb_tiepoint_zones, chunks=1
      )
      self._expansion_coefs = None
  
      self.cache = {}
  
      self.mda = {}
      short_name = np2str(self.h5f.attrs["Platform_Short_Name"])
      self.mda["platform_name"] = short_names.get(
          short_name, short_name
      )
      self.mda["sensor"] = "viirs"
  
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 1 to create a new VIIRSCompactFileHandler object from inherited base classes: BaseFileHandler with example: obj = VIIRSCompactFileHandler(filename, filename_info, filetype_info)