docstr: Instantiate a new SPE file plugin object
  
  Parameters
  ----------
  request : Request
      A request object representing the resource to be operated on.
  check_filesize : bool
      If True, compute the number of frames from the filesize, compare it
      to the frame count in the file header, and raise a warning if the
      counts don't match. (Certain software may create files with
  char_encoding : str
      Deprecated. Exists for backwards compatibility; use ``char_encoding`` of
      ``metadata`` instead.
  sdt_meta : bool
      Deprecated. Exists for backwards compatibility; use ``sdt_control`` of
      ``metadata`` instead.
docstr_tok: ["Instantiate","a","new","SPE","file","plugin","object","Parameters","--","--","--","--","--","request",":","Request","A","request","object","representing","the","resource","to","be","operated","on",".","check_filesize",":","bool","If","True",",","compute","the","number","of","frames","from","the","filesize",",","compare","it","to","the","frame","count","in","the","file","header",",","and","raise","a","warning","if","the","counts","do","n't","match",".","(","Certain","software","may","create","files","with","char_encoding",":","str","Deprecated",".","Exists","for","backwards","compatibility",";","use","``","char_encoding","``","of","``","metadata","``","instead",".","sdt_meta",":","bool","Deprecated",".","Exists","for","backwards","compatibility",";","use","``","sdt_control","``","of","``","metadata","``","instead","."]
code: def __init__(
      self,
      request: Request,
      check_filesize: bool = True,
      char_encoding: Optional[str] = None,
      sdt_meta: Optional[bool] = None,
  ) -> None:
      """Instantiate a new SPE file plugin object
  
      Parameters
      ----------
      request : Request
          A request object representing the resource to be operated on.
      check_filesize : bool
          If True, compute the number of frames from the filesize, compare it
          to the frame count in the file header, and raise a warning if the
          counts don't match. (Certain software may create files with
      char_encoding : str
          Deprecated. Exists for backwards compatibility; use ``char_encoding`` of
          ``metadata`` instead.
      sdt_meta : bool
          Deprecated. Exists for backwards compatibility; use ``sdt_control`` of
          ``metadata`` instead.
  
      """
  
      super().__init__(request)
      if request.mode.io_mode == IOMode.write:
          raise InitializationError("cannot write SPE files")
  
      if char_encoding is not None:
          warnings.warn(
              "Passing `char_encoding` to the constructor is deprecated. "
              "Use `char_encoding` parameter of the `metadata()` method "
              "instead.",
              DeprecationWarning,
          )
      self._char_encoding = char_encoding
      if sdt_meta is not None:
          warnings.warn(
              "Passing `sdt_meta` to the constructor is deprecated. "
              "Use `sdt_control` parameter of the `metadata()` method "
              "instead.",
              DeprecationWarning,
          )
      self._sdt_meta = sdt_meta
  
      self._file = self.request.get_file()
  
      try:
          # Spec.basic contains no string, no need to worry about character
          # encoding.
          info = self._parse_header(Spec.basic, "latin1")
          self._file_header_ver = info["file_header_ver"]
          self._dtype = Spec.dtypes[info["datatype"]]
          self._shape = (info["ydim"], info["xdim"])
          self._len = info["NumFrames"]
  
          if check_filesize:
              # Some software writes incorrect `NumFrames` metadata.
              # To determine the number of frames, check the size of the data
              # segment -- until the end of the file for SPE<3, until the
              # xml footer for SPE>=3.
              if info["file_header_ver"] >= 3:
                  data_end = info["xml_footer_offset"]
              else:
                  self._file.seek(0, os.SEEK_END)
                  data_end = self._file.tell()
              line = data_end - Spec.data_start
              line //= (
                  self._shape[0] * self._shape[1] * self._dtype.itemsize
              )
              if line != self._len:
                  warnings.warn(
                      f"The file header of {self.request.filename} claims there are "
                      f"{self._len} frames, but there are actually {line} frames."
                  )
                  self._len = min(line, self._len)
          self._file.seek(Spec.data_start)
      except Exception:
          raise InitializationError(
              "SPE plugin cannot read the provided file."
          )
  
imports: from datetime import datetime
  import logging
  import os
  from typing import Any, Callable, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple, Union
  import warnings
  import numpy
  from ..core.request import Request, IOMode, InitializationError
  from ..core.v3_plugin_api import PluginV3, ImageProperties
label_desc: Use image node_id 1 to create a new SpePlugin object from inherited base classes: PluginV3 with example: obj = SpePlugin(request, check_filesize, char_encoding, sdt_meta)