shnitsel.data.dataset_containers.xr_conversion ============================================== .. py:module:: shnitsel.data.dataset_containers.xr_conversion Functions --------- .. autoapisummary:: shnitsel.data.dataset_containers.xr_conversion.data_to_xarray_dataset shnitsel.data.dataset_containers.xr_conversion.xr_dataset_to_shnitsel_format Module Contents --------------- .. py:function:: data_to_xarray_dataset(raw_data, metadata) Support function to convert simple, non-hierarchical data structures (that could be in trees) to xarray datasets. :param raw_data: Any type of raw data that should be converted. See type hints for supported types. All explicitly listed types will also be supported by deserialization. If the type is only supported through the `SupportsToXrConversion` interface, the type needs to be registered using the `xr_io_compatibility.register_custom_xr_input_type()` function before the conversion is attempted. Types not explicitly listed and not supporting the io conversion protocol will trigger an error. :type raw_data: xr.DataArray | xr.Dataset | Trajectory | Frames | InterState | PerState | None | SupportsToXrConversion :param metadata: Metadata attributes to update according to the performed conversion. :type metadata: dict[str, Any] :returns: * *xr.Dataset | None* -- The converted dataset result or none if no conversion was possible * *dict[str, Any]* -- The updated metadata dictionary :raises ValueError: If an unsupported type is provided for conversion. .. py:function:: xr_dataset_to_shnitsel_format(raw_data, metadata) Function to support abstract deserialization of various types that could appear in a shnitsel style hierarchical tree structure. Will attempt to read type information from the `metadata` dict :param raw_data: The raw dataset input that should be deserialized. :type raw_data: xr.Dataset :param metadtata: Metadata dictionary for this entry. Should have a field `_shnitsel_data_type` with a type tag identifying the type that has been serialized in the provided `raw_data` parameter. For custom types, should also have a field `_shnitsel_data_type_meta` if metadata is required for deserialization but will be initialized to an empty dict if not provided. :type metadtata: dict[str, Any] :returns: A deserialized object of a core shnitsel tools type, core xarray type or a type registered with `xr_io_compatibility.register_custom_xr_input_type()`. If deserialization failed, will be returned as dataset :rtype: Trajectory | Frames | InterState | PerState | xr.Dataset | xr.DataArray | SupportsFromXrConversion