, grid, mdv_field_names=None, field_write_order=None)[source]#

Write grid object to MDV file.

Create a MDV file containing data from the provided grid instance.

The MDV file will contain parameters from the ‘source’ key if contained in grid.metadata. If this key or parameters related to the radar location and name are not present in the grid a default or sentinel value. will be written in the MDV file in the place of the parameter.

Grid fields will be saved in float32 unless the _Write_as_dtype key is present.

  • filename (str or file-like object.) – Filename of MDV file to create. If a file-like object is specified data will be written using the write method.

  • grid (Grid) – Grid object from which to create MDV file.

  • mdv_field_names (dict or None, optional) – Mapping between grid fields and MDV data type names. Field names mapped to None or with no mapping will be excluded from writing. If None, the same field names will be used.

  • field_write_order (list or None, optional) – Order in which grid fields should be written out in the MDV file. None, the default, will determine a valid order automatically.


Do to limitations of the MDV format, not all grid objects are writable. To write a grid the following conditions must be satisfied:

  • XY grid must be regular (equal spacing), Z can be irregular.

  • The number of Z levels must not exceed 122.

  • Fields can be encoded in the file using the ‘_Write_as_dtype’ key specifying one of ‘uint8’, ‘uint16’ or ‘float32’. Use the ‘scale_factor’ and ‘add_offset’ keys to specify scaling. Field data in the Grid object should be uncompressed, that is to say it has had the scaling applied.