Skip to content

The xarray-compatible zarr output only contains last item #141

Description

@j08lue

#135 added an option --write_xarray_compatible_zarr to write explicit coordinate arrays along with the image transform / crs attributes (see also #66).

The intention was that this output should be compatible with that you get when not setting this flag, but also be readable with standard CF client libraries like Xarray.

However, the writer function currently uses xarray.DataSet.to_zarr(..., mode="w", group="chronic_heat/osc/v2"), i.e. the group is constant.

This causes to_zarr to delete the group every time a new array should be written into it, leaving at the end of subsequent writes to the same group only the last array.

You can reproduce this with the following command:

CEDA_USERNAME=<username> CEDA_PASSWORD=<password> os_climate_hazard degree_days_indicator --store ./uk_12km_dd_28 --source_dataset UKCP18 --source_dataset_kwargs "{'resolution':'60km','domain':'uk'}" --gcm_list "[ukcp18]" --scenario_list "[rcp85]" --threshold_list "[]" --threshold_temperature 28 --central_year_list "[2030,2040,2050,2060,2070,2080,2090]" --central_year_historical 2005 --window_years 20 --write_xarray_compatible_zarr true --dask_cluster_kwargs "{'n_workers': 1, 'threads_per_worker': 1}"

The expected behavior is the following structure:

/chronic_heat/osc/v2/
├── longitude
│   └── 0.0.0.0
├── latitude
│   └── 0.0.0.0
├── mean_degree_days_v2_above_28c_ukcp18_rcp85_2030
│   └── 0.0.0.0
├── mean_degree_days_v2_above_28c_ukcp18_rcp85_2040
│   └── 0.0.0.0
...
├── mean_degree_days_v2_above_28c_ukcp18_rcp85_2090
│   └── 0.0.0.0
└── spatial_ref

but only mean_degree_days_v2_above_28c_ukcp18_rcp85_2090 is present.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions