satpy.writers.core.image module
Shared objects for writing image-like output.
- class satpy.writers.core.image.ImageWriter(name=None, filename=None, base_dir=None, enhance=None, **kwargs)[source]
Bases:
WriterBase writer for image file formats.
Initialize image writer object.
- Parameters:
name (str) – A name for this writer for log and error messages. If this writer is configured in a YAML file its name should match the name of the YAML file. Writer names may also appear in output file attributes.
filename (str) –
Filename to save data to. This filename can and should specify certain python string formatting fields to differentiate between data written to the files. Any attributes provided by the
.attrsof a DataArray object may be included. Format and conversion specifiers provided by thetrollsiftpackage may also be used. Any directories in the provided pattern will be created if they do not exist. Example:{platform_name}_{sensor}_{name}_{start_time:%Y%m%d_%H%M%S}.tif
base_dir (str | Path) – Base destination directories for all created files.
enhance (bool or Enhancer) – Whether to automatically enhance data to be more visually useful and to fit inside the file format being saved to. By default, this will default to using the enhancement configuration files found using the default
Enhancerclass. This can be set to False so that no enhancements are performed. This can also be an instance of theEnhancerclass if further custom enhancement is needed.kwargs (dict) – Additional keyword arguments to pass to the
Writerbase class.
Changed in version 0.10: Deprecated enhancement_config_file and ‘enhancer’ in favor of enhance. Pass an instance of the Enhancer class to enhance instead.
- __init__(name=None, filename=None, base_dir=None, enhance=None, **kwargs)[source]
Initialize image writer object.
- Parameters:
name (str) – A name for this writer for log and error messages. If this writer is configured in a YAML file its name should match the name of the YAML file. Writer names may also appear in output file attributes.
filename (str) –
Filename to save data to. This filename can and should specify certain python string formatting fields to differentiate between data written to the files. Any attributes provided by the
.attrsof a DataArray object may be included. Format and conversion specifiers provided by thetrollsiftpackage may also be used. Any directories in the provided pattern will be created if they do not exist. Example:{platform_name}_{sensor}_{name}_{start_time:%Y%m%d_%H%M%S}.tif
base_dir (str | Path) – Base destination directories for all created files.
enhance (bool or Enhancer) – Whether to automatically enhance data to be more visually useful and to fit inside the file format being saved to. By default, this will default to using the enhancement configuration files found using the default
Enhancerclass. This can be set to False so that no enhancements are performed. This can also be an instance of theEnhancerclass if further custom enhancement is needed.kwargs (dict) – Additional keyword arguments to pass to the
Writerbase class.
Changed in version 0.10: Deprecated enhancement_config_file and ‘enhancer’ in favor of enhance. Pass an instance of the Enhancer class to enhance instead.
- save_dataset(dataset, filename=None, fill_value=None, overlay=None, decorate=None, compute=True, units=None, **kwargs)[source]
Save the
datasetto a givenfilename.This method creates an enhanced image using
get_enhanced_image(). The image is then passed tosave_image(). See both of these functions for more details on the arguments passed to this method.
- save_image(img, filename=None, compute=True, **kwargs)[source]
Save Image object to a given
filename.- Parameters:
img (trollimage.xrimage.XRImage) – Image object to save to disk.
filename (str) – Optionally specify the filename to save this dataset to. It may include string formatting patterns that will be filled in by dataset attributes.
compute (bool) – If True (default), compute and save the dataset. If False return either a Dask Delayed object or tuple of (source, target). See the return values below for more information.
**kwargs – Other keyword arguments to pass to this writer.
- Returns:
Value returned depends on compute. If compute is True then the return value is the result of computing a Dask Delayed object or running
dask.array.store(). If compute is False then the returned value is either a Dask Delayed object that can be computed using delayed.compute() or a tuple of (source, target) that should be passed todask.array.store(). If target is provided the the caller is responsible for calling target.close() if the target has this method.