satpy.writers.ninjotiff module

Writer for TIFF images compatible with the NinJo visualization tool (NinjoTIFFs).

NinjoTIFFs can be color images or monochromatic. For monochromatic images, the physical units and scale and offsets to retrieve the physical values are provided. Metadata is also recorded in the file.

In order to write ninjotiff files, some metadata needs to be provided to the writer. Here is an example on how to write a color image:

chn = "airmass"
ninjoRegion = load_area("areas.def", "nrEURO3km")

filenames = glob("data/*__")
global_scene = Scene(reader="hrit_msg", filenames=filenames)
global_scene.load([chn])
local_scene = global_scene.resample(ninjoRegion)
local_scene.save_dataset(chn, filename="airmass.tif", writer='ninjotiff',
                      sat_id=6300014,
                      chan_id=6500015,
                      data_cat='GPRN',
                      data_source='EUMCAST',
                      nbits=8)

Here is an example on how to write a color image:

chn = "IR_108"
ninjoRegion = load_area("areas.def", "nrEURO3km")

filenames = glob("data/*__")
global_scene = Scene(reader="hrit_msg", filenames=filenames)
global_scene.load([chn])
local_scene = global_scene.resample(ninjoRegion)
local_scene.save_dataset(chn, filename="msg.tif", writer='ninjotiff',
                      sat_id=6300014,
                      chan_id=900015,
                      data_cat='GORN',
                      data_source='EUMCAST',
                      physic_unit='K',
                      nbits=8)

The metadata to provide to the writer can also be stored in a configuration file (see pyninjotiff), so that the previous example can be rewritten as:

chn = "IR_108"
ninjoRegion = load_area("areas.def", "nrEURO3km")

filenames = glob("data/*__")
global_scene = Scene(reader="hrit_msg", filenames=filenames)
global_scene.load([chn])
local_scene = global_scene.resample(ninjoRegion)
local_scene.save_dataset(chn, filename="msg.tif", writer='ninjotiff',
                      # ninjo product name to look for in .cfg file
                      ninjo_product_name="IR_108",
                      # custom configuration file for ninjo tiff products
                      # if not specified PPP_CONFIG_DIR is used as config file directory
                      ninjo_product_file="/config_dir/ninjotiff_products.cfg")
class satpy.writers.ninjotiff.NinjoTIFFWriter(tags=None, **kwargs)[source]

Bases: ImageWriter

Writer for NinjoTiff files.

Inititalize the writer.

save_dataset(dataset, filename=None, fill_value=None, compute=True, convert_temperature_units=True, **kwargs)[source]

Save a dataset to ninjotiff format.

This calls save_image in turn, but first preforms some unit conversion if necessary and desired. Unit conversion can be suppressed by passing convert_temperature_units=False.

save_image(img, filename=None, compute=True, **kwargs)[source]

Save the image to the given filename in ninjotiff format.

satpy.writers.ninjotiff.convert_units(dataset, in_unit, out_unit)[source]

Convert units of dataset.

Convert dataset units for the benefit of writing NinJoTIFF. The main background here is that NinJoTIFF would like brightness temperatures in °C, but satellite data files are in K. For simplicity of implementation, this function can only convert from K to °C.

This function will convert input data from K to °C and write the new unit in the "units" attribute. When output and input units are equal, it returns the input dataset.

Parameters:
  • dataset (xarray DataArray) – Dataarray for which to convert the units.

  • in_unit (str) – Unit for input data.

  • out_unit (str) – Unit for output data.

Returns:

dataset, possibly with new units.