Skip to content

Overwriting zarr using mode='w' converts unmodified data to nan. #11159

@bweeding

Description

@bweeding

What is your issue?

When I overwrite a zarr using mode='w' (that I've modified), all the unmodified data in the zarr is converted to nan. Perhaps I've misunderstood the purpose of mode='w', but I thought it would just overwrite with whatever data is in the zarr when it's open in xarray and being saved?

An example is as follows:

# open the file and check the contents
ds_ex = xr.open_zarr('/scratch/bweeding/AMOS_2026_wind_data/franklin_square/CSIRO_BOM_ACCESS1_0/MBCn/2040_2060/example.zarr')
ds_ex.UTCI.isel(timestamp=5).plot()
Image

ds_ex.Tmrt.isel(timestamp=5).plot()

Image
# modify some data and check the contents
ds['UTCI'] = ds.UTCI*20
ds_ex.UTCI.isel(timestamp=5).plot()
Image

ds_ex.Tmrt.isel(timestamp=5).plot()

Image
# overwrite , reopen, and check
ds_ex.to_zarr('/scratch/bweeding/AMOS_2026_wind_data/franklin_square/CSIRO_BOM_ACCESS1_0/MBCn/2040_2060/example.zarr',mode='w')
ds_ex = xr.open_zarr('/scratch/bweeding/AMOS_2026_wind_data/franklin_square/CSIRO_BOM_ACCESS1_0/MBCn/2040_2060/example.zarr')
ds_ex.UTCI.isel(timestamp=5).plot()
Image

ds_ex.Tmrt.isel(timestamp=5).plot()

Image

Have I misunderstood what w does? Or is this a bug?

Cheers
Ben

example.zarr.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions