class_docstr: Writer for NinjoTiff files.
class_docstr_tok: ["Writer","for","NinjoTiff","files","."]
docstr: Save the image to the given *filename* in ninjotiff_ format.
  
  .. _ninjotiff: http://www.ssec.wisc.edu/~davidh/polar2grid/misc/NinJo_Satellite_Import_Formats.html
docstr_tok: ["Save","the","image","to","the","given","*","filename","*","in","ninjotiff_","format",".","..","_ninjotiff",":","http",":","\/\/www.ssec.wisc.edu\/~davidh\/polar2grid\/misc\/NinJo_Satellite_Import_Formats.html"]
code: def save_image(
      self, img, filename=None, compute=True, **kwargs
  ):  # floating_point=False,
      """Save the image to the given *filename* in ninjotiff_ format.
  
      .. _ninjotiff: http://www.ssec.wisc.edu/~davidh/polar2grid/misc/NinJo_Satellite_Import_Formats.html
      """
      filename = filename or self.get_filename(**img.data.attrs)
      if img.mode.startswith("L") and (
          "ch_min_measurement_unit" not in kwargs
          or "ch_max_measurement_unit" not in kwargs
      ):
          try:
              scale, offset = img.get_scaling_from_history()
              scale, offset = invert_scale_offset(scale, offset)
          except ValueError as err:
              logger.warning(str(err))
          else:
              try:
                  # Here we know that the data if the image is scaled between 0 and 1
                  dmin = offset
                  dmax = scale + offset
                  (
                      ch_min_measurement_unit,
                      ch_max_measurement_unit,
                  ) = np.minimum(dmin, dmax), np.maximum(dmin, dmax)
                  kwargs[
                      "ch_min_measurement_unit"
                  ] = ch_min_measurement_unit
                  kwargs[
                      "ch_max_measurement_unit"
                  ] = ch_max_measurement_unit
              except KeyError:
                  raise NotImplementedError(
                      "Don't know how to handle non-scale/offset-based enhancements yet."
                  )
      if img.mode.startswith("P"):
          img.data = img.data.astype(np.uint8)
      return nt.save(
          img,
          filename,
          data_is_scaled_01=True,
          compute=compute,
          **kwargs,
      )
  
file_path: satpy/satpy/writers/ninjotiff.py
imports: import logging
  import numpy
  import pyninjotiff.ninjotiff
  import xarray
  from trollimage.xrimage import invert_scale_offset
  from satpy.writers import ImageWriter
label_desc: Use image node_id 2 for calling the NinjoTIFFWriter obj's underlying member method code with example usage: obj.save_image(img, filename, compute) and returns: nt