class_docstr: Extract metadata written by the SDT-control software
  
  Some of it is encoded in the comment strings
  (see :py:meth:`parse_comments`). Also, date and time are encoded in a
  peculiar way (see :py:meth:`get_datetime`). Use :py:meth:`extract_metadata`
  to update the metadata dict.
docstr: Extract SDT-control metadata from SPE metadata
  
  SDT-control stores some metadata in comments and other fields.
  Extract them and remove unused entries.
  
  Parameters
  ----------
  meta
      SPE file metadata. Modified in place.
  char_encoding
      Character encoding used to decode strings in the metadata.
docstr_tok: ["Extract","SDT-control","metadata","from","SPE","metadata","SDT-control","stores","some","metadata","in","comments","and","other","fields",".","Extract","them","and","remove","unused","entries",".","Parameters","--","--","--","--","--","meta","SPE","file","metadata",".","Modified","in","place",".","char_encoding","Character","encoding","used","to","decode","strings","in","the","metadata","."]
code: def extract_metadata(meta: Mapping, char_encoding: str = "latin1"):
      """Extract SDT-control metadata from SPE metadata
  
      SDT-control stores some metadata in comments and other fields.
      Extract them and remove unused entries.
  
      Parameters
      ----------
      meta
          SPE file metadata. Modified in place.
      char_encoding
          Character encoding used to decode strings in the metadata.
      """
      comver = __class__.get_comment_version(meta["comments"])
      if any(c < 0 for c in comver):
          # This file most likely was not created by SDT-control
          logger.debug("SDT-control comments not found.")
          return
  
      sdt_meta = __class__.parse_comments(meta["comments"], comver)
      meta.pop("comments")
      meta.update(sdt_meta)
  
      # Get date and time in a usable format
      dt = __class__.get_datetime(meta["date"], meta["time_local"])
      if dt:
          meta["datetime"] = dt
          meta.pop("date")
          meta.pop("time_local")
  
      sp4 = meta["spare_4"]
      try:
          meta["modulation_script"] = sp4.decode(char_encoding)
          meta.pop("spare_4")
      except UnicodeDecodeError:
          warnings.warn(
              "Failed to decode SDT-control laser "
              "modulation script. Bad char_encoding?"
          )
  
      # Get rid of unused data
      meta.pop("time_utc")
      meta.pop("exposure_sec")
  
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 4 for calling the SDTControlSpec obj's underlying member method code with example usage: obj.extract_metadata(meta, char_encoding) without return types