Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Save to netCDF #16

@TomNicholas

Description

@TomNicholas

xarray.Dataset.to_netcdf() allows you to save a dataset into a netcdf file as a group, but to make a DataTree.to_netcdf() we need to save many groups into the same file. I'm not sure how to do this with xarray.Dataset.to_netcdf(), and xarray's backends code is pretty complicated. It could probably be done with the netCDF4 python library at a lower level but I havent' really tried that yet, and it would be nice to not have to use that.

The hard bit is saving multiple groups to the same file, actually iterating over the groups is easy, just something like

def to_netcdf(dt, filepath):
    for node in dt.subtree_nodes:
        group_name = node.pathstr
        
        node.ds.to_netcdf(filepath, group=group_name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions