satpy.writers.awips_tiled module

The AWIPS Tiled writer is used to create AWIPS-compatible tiled NetCDF4 files.

The Advanced Weather Interactive Processing System (AWIPS) is a program used by the United States National Weather Service (NWS) and others to view different forms of weather imagery. The original Sectorized Cloud and Moisture Imagery (SCMI) functionality in AWIPS was a NetCDF4 format supported by AWIPS to store one image broken up in to one or more “tiles”. This format has since been expanded to support many other products and so the writer for this format in Satpy is generically called the “AWIPS Tiled” writer. You may still see SCMI referenced in this documentation or in the source code for the writer. Once AWIPS is configured for specific products this writer can be used to provide compatible products to the system.

The AWIPS Tiled writer takes 2D (y, x) geolocated data and creates one or more AWIPS-compatible NetCDF4 files. The writer and the AWIPS client may need to be configured to make things appear the way the user wants in the AWIPS client. The writer can only produce files for datasets mapped to areas with specific projections:

  • lcc

  • geos

  • merc

  • stere

This is a limitation of the AWIPS client and not of the writer. In the case where AWIPS has been updated to support additional projections, this writer may also need to be updated to support those projections.

AWIPS Configuration

Depending on how this writer is used and the data it is provided, AWIPS may need additional configuration on the server side to properly ingest the files produced. This will require administrator privileges to the ingest server(s) and is not something that can be configured on the client. Note that any changes required must be done on all servers that you wish to ingest your data files. The generic “polar” template this writer defaults to should limit the number of modifications needed for any new data fields that AWIPS previously was unaware of. Once the data is ingested, the client can be used to customize how the data looks on screen.

AWIPS requires files to follow a specific naming scheme so they can be routed to specific “decoders”. For the files produced by this writer, this typically means editing the “goesr” decoder configuration in a directory like:


The “goesr” decoder is a subclass of the “satellite” decoder. You may see either name show up in the AWIPS ingest logs. With the correct regular expression in the above file, your files should be passed to the right decoder, opened, and parsed for data.

To tell AWIPS exactly what attributes and variables mean in your file, you’ll need to create or configure an XML file in:


See the existing files in this directory for examples. The “polar” template (see below) that this writer uses by default is already configured in the “Polar” subdirectory assuming that the TOWR-S RPM package has been installed on your AWIPS ingest server.


This writer allows for a “template” to be specified to control how the output files are structured and created. Templates can be configured in the writer YAML file (awips_tiled.yaml) or passed as a dictionary to the template keyword argument. Templates have three main sections:

  1. global_attributes

  2. coordinates

  3. variables

Additionally, you can specify whether a template should produce files with one variable per file by specifying single_variable: true or multiple variables per file by specifying single_variable: false. You can also specify the output filename for a template using a Python format string. See awips_tiled.yaml for examples. Lastly, a add_sector_id_global boolean parameter can be specified to add the user-provided sector_id keyword argument as a global attribute to the file.

The global_attributes section takes names of global attributes and then a series of options to “render” that attribute from the metadata provided when creating files. For example:

    value: "{name}"

For more information see the satpy.writers.awips_tiled.NetCDFTemplate.get_attr_value() method.

The coordinates and variables are similar to each other in that they define how a variable should be created, the attributes it should have, and the encoding to write to the file. Coordinates typically don’t need to be modified as tiled files usually have only x and y dimension variables. The Variables on the other hand use a decision tree to determine what section applies for a particular DataArray being saved. The basic structure is:

    <decision tree matching parameters>
    var_name: "output_netcdf_variable_name"
      <attributes similar to global attributes>
      <xarray encoding parameters>

The “decision tree matching parameters” can be one or more of “name”, “standard_name’, “satellite”, “sensor”, “area_id’, “units”, or “reader”. The writer will choose the best section for the DataArray being saved (the most matches). If none of these parameters are specified in a section then it will be used when no other matches are found (the “default” section).

The “encoding” parameters can be anything accepted by xarray’s to_netcdf method. See xarray.Dataset.to_netcdf() for more information on the encoding` keyword argument.

For more examples see the existing builtin templates defined in awips_tiled.yaml.

Builtin Templates

There are only a few templates provided in Sapty currently.

  • polar: A custom format developed for the CSPP Polar2Grid project at the University of Wisconsin - Madison Space Science and Engineering Center (SSEC). This format is made available through the TOWR-S package that can be installed for GOES-R support in AWIPS. This format is meant to be very generic and should theoretically allow any variable to get ingested into AWIPS.

  • glm_l2_radc: This format is used to produce standard files for the gridded GLM products produced by the CSPP Geo Gridded GLM package. Support for this format is also available in the TOWR-S package on an AWIPS ingest server. This format is specific to gridded GLM on the CONUS sector and is not meant to work for other data.

  • glm_l2_radf: This format is used to produce standard files for the gridded GLM productes produced by the CSPP Geo Gridded GLM package. Support for this format is also available in the TOWR-S package on an AWIPS ingest server. This format is specific to gridded GLM on the Full Disk sector and is not meant to work for other data.

Numbered versus Lettered Grids

By default this writer will save tiles by number starting with ‘1’ representing the upper-left image tile. Tile numbers then increase along the column and then on to the next row.

By specifying lettered_grid as True tiles can be designated with a letter. Lettered grids or sectors are preconfigured in the awips_tiled.yaml configuration file. The lettered tile locations are static and will not change with the data being written to them. Each lettered tile is split into a certain number of subtiles (num_subtiles), default 2 rows by 2 columns. Lettered tiles are meant to make it easier for receiving AWIPS clients/stations to filter what tiles they receive; saving time, bandwidth, and space.

Any tiles (numbered or lettered) not containing any valid data are not created.

Updating tiles

There are some input data cases where we want to put new data in a tile file written by a previous execution. An example is a pre-tiled input dataset that is processed one tile at a time. One input tile may map to one or more output AWIPS tiles, but may not perfectly aligned, leaving empty/unused space in the output tile. The next input tile may be able to fill in that empty space and should be allowed to write the “new” data to the file. This is the default behavior of the AWIPS tiled writer. In cases where data overlaps the existing data in the tile, the newer data has priority.

Shifting Lettered Grids

Due to the static nature of the lettered grids, there is sometimes a need to shift the locations of where these tiles are by up to 0.5 pixels in each dimension to align with the data being processed. This means that the tiles for a 1000m resolution grid may be shifted up to 500m in each direction from the original definition of the lettered “sector”. This can cause differences in the location of the tiles between executions depending on the locations of the input data. In the worst case tile A01 from one execution could be shifted up to 1 grid cell from tile A01 in another execution (one is shifted 0.5 pixels to the left, the other is shifted 0.5 to the right).

This shifting makes the calculations for generating tiles easier and more accurate. By default, the lettered tile locations are changed to match the location of the data. This works well when output tiles will not be updated (see above) in future processing. In cases where output tiles will be filled in or updated with more data the use_sector_reference keyword argument can be set to True to tell the writer to shift the data’s geolocation by up to 0.5 pixels in each dimension instead of shifting the lettered tile locations.

class satpy.writers.awips_tiled.AWIPSNetCDFTemplate(template_dict, swap_end_time=False)[source]

Bases: NetCDFTemplate

NetCDF template renderer specifically for tiled AWIPS files.

Handle AWIPS special cases and initialize template helpers.

_add_sector_id_global(new_ds, sector_id)[source]
static _fill_units_and_standard_name(attrs, units, standard_name)[source]

Fill in units and standard_name if not set in attrs.


Assign projection attributes per CF standard.

static _get_vmin_vmax(var_config, input_data_arr)[source]

Get default global production_location attribute.


Get default global production_location attribute.

_render_variable_attributes(var_config, input_metadata)[source]
_render_variable_encoding(var_config, input_data_arr)[source]
_set_xy_coords_attrs(new_ds, crs)[source]

Swap every use of ‘start_time’ to use ‘end_time’ instead.

apply_area_def(new_ds, area_def)[source]

Apply information we can gather from the AreaDefinition.

apply_misc_metadata(new_ds, sector_id=None, creator=None, creation_time=None)[source]

Add attributes that don’t fit into any other category.

apply_tile_coord_encoding(new_ds, xy_factors)[source]

Add encoding information specific to the coordinate variables.

apply_tile_info(new_ds, tile_info)[source]

Apply attributes associated with the current tile.

render(dataset_or_data_arrays, area_def, tile_info, sector_id, creator=None, creation_time=None, shared_attrs=None, extra_global_attrs=None)[source]

Create a xarray.Dataset from template using information provided.

class satpy.writers.awips_tiled.AWIPSTiledVariableDecisionTree(decision_dicts, **kwargs)[source]

Bases: DecisionTree

Load AWIPS-specific metadata from YAML configuration.

Initialize decision tree with specific keys to look for.

class satpy.writers.awips_tiled.AWIPSTiledWriter(compress=False, fix_awips=False, **kwargs)[source]

Bases: Writer

Writer for AWIPS NetCDF4 Tile files.

See satpy.writers.awips_tiled documentation for more information on templates and produced file format.

Initialize writer and decision trees.

_delay_netcdf_creation(delayed_gen, precompute=True, use_distributed=False)[source]

Workaround random dask and xarray hanging executions.

In previous implementations this writer called ‘to_dataset’ directly in a delayed function. This seems to cause random deadlocks where execution would hang indefinitely.


Handle multi-band images by splitting in to separate products.


Convert sector extents if needed.

static _get_delayed_iter(use_distributed=False)[source]

Get metadata for the current sector if configured.

This is not necessary for numbered grids. If found, the sector info will provide the overall tile layout for this grid/sector. This allows for consistent tile numbering/naming regardless of where the data being converted actually is.

_get_tile_data_info(data_arrs, creation_time, source_name)[source]
_get_tile_generator(area_def, lettered_grid, sector_id, num_subtiles, tile_size, tile_count, use_sector_reference=False)[source]

Get the appropriate tile generator class for lettered or numbered tiles.


Group datasets by their area.

_iter_area_tile_info_and_datasets(area_datasets, template, lettered_grid, sector_id, num_subtiles, tile_size, tile_count, use_sector_reference)[source]
_iter_tile_info_and_datasets(tile_gen, data_arrays, single_variable=True)[source]
_save_nonempty_mfdatasets(datasets_to_save, output_filenames, **kwargs)[source]
_slice_and_update_coords(tile_info, data_arrays)[source]

Split a single RGB dataset in to multiple.

_tile_filler(tile_info, data_arr)[source]

Check if tile exists and report error accordingly.

property enhancer

Get lazy loaded enhancer object only if needed.

get_filename(template, area_def, tile_info, sector_id, **kwargs)[source]

Generate output NetCDF file from metadata.

save_dataset(dataset, **kwargs)[source]

Save a single DataArray to one or more NetCDF4 Tile files.

save_datasets(datasets, sector_id=None, source_name=None, tile_count=(1, 1), tile_size=None, lettered_grid=False, num_subtiles=None, use_end_time=False, use_sector_reference=False, template='polar', check_categories=True, extra_global_attrs=None, environment_prefix='DR', compute=True, **kwargs)[source]

Write a series of DataArray objects to multiple NetCDF4 Tile files.

  • datasets (iterable) – Series of gridded DataArray objects with the necessary metadata to be converted to a valid tile product file.

  • sector_id (str) – Name of the region or sector that the provided data is on. This name will be written to the NetCDF file and will be used as the sector in the AWIPS client for the ‘polar’ template. For lettered grids this name should match the name configured in the writer YAML. This is required for some templates (ex. default ‘polar’ template) but is defined as a keyword argument for better error handling in Satpy.

  • source_name (str) – Name of producer of these files (ex. “SSEC”). This name is used to create the output filename for some templates.

  • environment_prefix (str) – Prefix of filenames for some templates. For operational real-time data this is usually “OR”, “OT” for test data, “IR” for test system real-time data, and “IT” for test system test data. This defaults to “DR” for “Developer Real-time” to avoid anyone accidentally producing files that could be mistaken for the operational system.

  • tile_count (tuple) – For numbered tiles only, how many tile rows and tile columns to produce. Default to (1, 1), a single giant tile. Either tile_count, tile_size, or lettered_grid should be specified.

  • tile_size (tuple) – For numbered tiles only, how many pixels each tile should be. This takes precedence over tile_count if specified. Either tile_count, tile_size, or lettered_grid should be specified.

  • lettered_grid (bool) – Whether to use a preconfigured grid and label tiles with letters and numbers instead of only numbers. For example, tiles will be named “A01”, “A02”, “B01”, and so on in the first row of data and continue on to “A03”, “A04”, and “B03” in the default case where num_subtiles is (2, 2). Letters start in the upper-left corner and will go from A up to Z, if necessary.

  • num_subtiles (tuple) – For lettered tiles only, how many rows and columns to split each lettered tile in to. By default 2 rows and 2 columns will be created. For example, the tile for letter “A” will have “A01” and “A02” in the top row and “A03” and “A04” in the second row.

  • use_end_time (bool) – Instead of using the start_time for the product filename and time written to the file, use the end_time. This is useful for multi-day composites where the end_time is a better representation of what data is in the file.

  • use_sector_reference (bool) – For lettered tiles only, whether to shift the data locations to align with the preconfigured grid’s pixels. By default this is False meaning that the grid’s tiles will be shifted to align with the data locations. If True, the data is shifted. At most the data will be shifted by 0.5 pixels. See satpy.writers.awips_tiled for more information.

  • template (str or dict) – Name of the template configured in the writer YAML file. This can also be a dictionary with a full template configuration. See the satpy.writers.awips_tiled documentation for more information on templates. Defaults to the ‘polar’ builtin template.

  • check_categories (bool) – Whether category and flag products should be included in the checks for empty or not empty tiles. In some cases (ex. data quality flags) category products may look like all valid data (a non-empty tile) but shouldn’t be used to determine the emptiness of the overall tile (good quality versus non-existent). Default is True. Set to False to ignore category (integer dtype or “flag_meanings” defined) when checking for valid data.

  • extra_global_attrs (dict) – Additional global attributes to be added to every produced file. These attributes are applied at the end of template rendering and will therefore overwrite template generated values with the same global attribute name.

  • compute (bool) – Compute and write the output immediately using dask. Default to False.

classmethod separate_init_kwargs(kwargs)[source]

Separate keyword arguments by initialization and saving keyword arguments.

class satpy.writers.awips_tiled.LetteredTileGenerator(area_definition, extents, sector_crs, cell_size=(2000000, 2000000), num_subtiles=None, use_sector_reference=False)[source]

Bases: NumberedTileGenerator

Helper class to generate per-tile metadata for lettered tiles.

Initialize tile information for later generation.

  • area_definition (AreaDefinition) – Area of the data being saved.

  • extents (tuple) – Four element tuple of the configured lettered area.

  • sector_crs (pyproj.CRS) – CRS of the configured lettered sector area.

  • cell_size (tuple) – Two element tuple of resolution of each tile in sector projection units (y, x).


Create generator of individual tile metadata.

_get_tile_properties(tile_shape, tile_count)[source]

Calculate tile information for this particular sector/grid.


Get the X/Y coordinate limits for the full resulting image.

_tile_identifier(ty, tx)[source]

Get tile identifier (name) for a particular tile row/column.

class satpy.writers.awips_tiled.NetCDFTemplate(template_dict)[source]

Bases: object

Helper class to convert a dictionary-based NetCDF template to an xarray.Dataset.

Parse template dictionary and prepare for rendering.

_get_matchable_coordinate_metadata(coord_name, coord_attrs)[source]
_render_attrs(attr_configs, input_metadata, prefix='_')[source]
_render_coordinate_attributes(coord_config, input_metadata)[source]
_render_variable_attributes(var_config, input_metadata)[source]
_render_variable_encoding(var_config, input_data_arr)[source]
get_attr_value(attr_name, input_metadata, value=None, raw_key=None, raw_value=None, prefix='_')[source]

Determine attribute value using the provided configuration information.

If value and raw_key are not provided, this method will search for a method named <prefix><attr_name>, which will be called with one argument (input_metadata) to get the value to return. See the documentation for the prefix keyword argument below for more information.

  • attr_name (str) – Name of the attribute whose value we are generating.

  • input_metadata (dict) – Dictionary of metadata from the input DataArray and other context information. Used to provide information to value or access data from using raw_key if provided.

  • value (Any) – Value to assign to this attribute. If a string, it may be a python format string which will be provided the data from input_metadata. For example, {name} will be filled with the value for the "name" in input_metadata. It can also include environment variables (ex. "${MY_ENV_VAR}") which will be expanded. String formatting is accomplished by the special trollsift.parser.StringFormatter which allows for special common conversions.

  • raw_key (str) – Key to access value from input_metadata, but without any string formatting applied to it. This allows for metadata of non-string types to be requested.

  • raw_value (Any) – Static hardcoded value to set this attribute to. Overrides all other options.

  • prefix (str) – Prefix to use when value and raw_key are both None. Default is "_". This will be used to find custom attribute handlers in subclasses. For example, if value and raw_key are both None and attr_name is "my_attr", then the method self._my_attr will be called as return self._my_attr(input_metadata). See NetCDFTemplate.render_global_attributes() for additional information (prefix is "_global_").

get_filename(base_dir='', **kwargs)[source]

Generate output NetCDF file from metadata.

render(dataset_or_data_arrays, shared_attrs=None)[source]

Create xarray.Dataset from provided data.

class satpy.writers.awips_tiled.NumberedTileGenerator(area_definition, tile_shape=None, tile_count=None)[source]

Bases: object

Helper class to generate per-tile metadata for numbered tiles.

Initialize and generate tile information for this sector/grid for later use.


Get numbered tile metadata.

_get_tile_properties(tile_shape, tile_count)[source]

Generate tile information for numbered tiles.


Get the overall X/Y coordinate variable arrays.


Get the X/Y coordinate limits for the full resulting image.

_tile_identifier(ty, tx)[source]

Get tile identifier for numbered tiles.

_tile_number(ty, tx)[source]

Get tile number from tile row/column.

class satpy.writers.awips_tiled.TileInfo(tile_count, image_shape, tile_shape, tile_row_offset, tile_column_offset, tile_id, tile_number, x, y, xy_factors, tile_slices, data_slices)

Bases: tuple

Create new instance of TileInfo(tile_count, image_shape, tile_shape, tile_row_offset, tile_column_offset, tile_id, tile_number, x, y, xy_factors, tile_slices, data_slices)


Return a new dict which maps field names to their values.

_field_defaults = {}
_fields = ('tile_count', 'image_shape', 'tile_shape', 'tile_row_offset', 'tile_column_offset', 'tile_id', 'tile_number', 'x', 'y', 'xy_factors', 'tile_slices', 'data_slices')
classmethod _make(iterable)

Make a new TileInfo object from a sequence or iterable


Return a new TileInfo object replacing specified fields with new values


Alias for field number 11


Alias for field number 1


Alias for field number 4


Alias for field number 0


Alias for field number 5


Alias for field number 6


Alias for field number 3


Alias for field number 2


Alias for field number 10


Alias for field number 7


Alias for field number 9


Alias for field number 8

class satpy.writers.awips_tiled.XYFactors(mx, bx, my, by)

Bases: tuple

Create new instance of XYFactors(mx, bx, my, by)


Return a new dict which maps field names to their values.

_field_defaults = {}
_fields = ('mx', 'bx', 'my', 'by')
classmethod _make(iterable)

Make a new XYFactors object from a sequence or iterable


Return a new XYFactors object replacing specified fields with new values


Alias for field number 1


Alias for field number 3


Alias for field number 0


Alias for field number 2


Add ‘valid_range’ metadata if not present.

If valid_range or valid_min/valid_max are not present in a DataArrays metadata (.attrs), then lazily compute it with dask so it can be computed later when we write tiles out.

AWIPS requires that scale_factor/add_offset/_FillValue be the same for all tiles. We must do this calculation before splitting the data into tiles otherwise the values will be different.

satpy.writers.awips_tiled._any_notnull(data_arr, check_categories)[source]
satpy.writers.awips_tiled._copy_to_existing(dataset_to_save, output_filename)[source]
satpy.writers.awips_tiled._create_debug_array(sector_info, num_subtiles, font_path='Verdana.ttf')[source]
satpy.writers.awips_tiled._get_factor_offset_fill(input_data_arr, vmin, vmax, encoding)[source]
satpy.writers.awips_tiled._is_empty_tile(dataset_to_save, check_categories)[source]
satpy.writers.awips_tiled._notnull(data_arr, check_categories=True)[source]
satpy.writers.awips_tiled._reapply_factors(dataset_to_save, factors)[source]

Create tile files with tile identifiers “burned” in to the image data for debugging.

satpy.writers.awips_tiled.draw_rectangle(draw, coordinates, outline=None, fill=None, width=1)[source]

Draw simple rectangle in to a numpy array image.


Hack the NetCDF4 files to workaround NetCDF-Java bugs used by AWIPS.

This should not be needed for new versions of AWIPS.


Command line interface mimicing CSPP Polar2Grid.

satpy.writers.awips_tiled.tile_filler(data_arr_data, tile_shape, tile_slices, fill_value)[source]

Create an empty tile array and fill the proper locations with data.

satpy.writers.awips_tiled.to_nonempty_netcdf(dataset_to_save: Dataset, factors: dict, output_filename: str, update_existing: bool = True, check_categories: bool = True)[source]

Save xarray.Dataset to a NetCDF file if not all fills.

In addition to checking certain Dataset variables for fill values, this function can also “update” an existing NetCDF file with the new valid data provided.