Skip to content

Tools for converting between xray.Dataset and nested dictionaries/JSON #432

@shoyer

Description

@shoyer

This came up in discussion with @freeman-lab -- xray does not have direct support for converting datasets to or from nested dictionaries (i.e., as could be serialized in JSON).

This is quite straightforward to implement oneself, of course, but there's something to be said for making this more obvious. I'm thinking of a serialization format that looks something like this:

{
    'variables': {
        'temperature': {
            'dimensions': ['x'],
            'data': [1, 2, 3],
            'attributes': {}
            }
        ...
    }
    'attributes': {
        'title': 'My example dataset',
        ...
    }
}

The solution here would be to either:

  1. add a few examples to the IO documentation of how to roll this one-self, or
  2. create a few helper methods/functions to make this even easier: xray.Dataset.to_dict/xray.read_dict.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions