shnitsel.data.xr_io_registry#

Attributes#

Functions#

register_custom_xr_input_type(cls[, io_type_tag])

Function to register a custom type that can be parsed from an xarray Dataset

get_registered_input_handler(io_type_tag)

Function to look up a potentially registered input handler for a previously serialized data type.

setup_defaults()

Helper function to register all default shnitsel data types with the xr io compatibility registry.

Module Contents#

Readable#
INPUT_TYPE_REGISTRY: dict[str, type[shnitsel.data.xr_io_compatibility.SupportsFromXrConversion]]#
register_custom_xr_input_type(cls, io_type_tag=None)#

Function to register a custom type that can be parsed from an xarray Dataset using the SupportsFromXrConversion protocol definition to support input from xarray style netcdf files.

Parameters:
  • cls (type[Readable]) – A class supporting the SupportsFromXrConversion protocol to be invoked to deserialize an object from a xr.Dataset instance when reading a netcdf file.

  • io_type_tag (str, optional) – The string type tag to be used to mark this class as the executing instance for deserialization. If not set, will use get_type_marker() on the registered class.

Returns:

True if registration succeeded. False if there was a clash with the io_type_tag of an existing type.

Return type:

bool

get_registered_input_handler(io_type_tag)#

Function to look up a potentially registered input handler for a previously serialized data type.

If no input handler is registered, will return None

Parameters:

io_type_tag (str) – The type tag under which the type was registered in the system with register_custom_xr_input_type().

Returns:

Either a class object that supports the protocol of an input handler or None if no handler was found.

Return type:

type[SupportsFromXrConversion]

setup_defaults()#

Helper function to register all default shnitsel data types with the xr io compatibility registry.