Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect length of Time dim #341

Open
kongdd opened this issue Oct 7, 2023 · 1 comment
Open

incorrect length of Time dim #341

kongdd opened this issue Oct 7, 2023 · 1 comment

Comments

@kongdd
Copy link
Contributor

kongdd commented Oct 7, 2023

using Zarr, YAXArrays
using DimensionalData
using CFTime
# chunksize(c) = Cubes.cubechunks(c)

store ="gs://cmip6/CMIP6/ScenarioMIP/DKRZ/MPI-ESM1-2-HR/ssp585/r1i1p1f1/3hr/tas/gn/v20190710/"
@time g = open_dataset(zopen(store, consolidated=true))
c = g.tas

@time kelvinCube = c[time=Between(DateTime("2030-01-01"), DateTime("2030-04-01"))]
@time savecube(kelvinCube, "temp-02.zarr")
julia> kelvinCube
384×192×721 YAXArray{Float32,3} with dimensions: 
  Dim{:lon} Sampled{Float64} 0.0:0.9375:359.0625 ForwardOrdered Regular Points,
  Dim{:lat} Sampled{Float64} Float64[-89.28422753251364, -88.35700351866494, , 88.35700351866494, 89.28422753251364] ForwardOrdered Irregular Points,
  Ti Sampled{DateTime} DateTime[2030-01-01T00:00:00, , 2030-04-01T00:00:00] ForwardOrdered Irregular Points
units: K
name: tas
Total size: 202.78 MB

Ti should has a length of 721.
However, the length of time dimension in the zarr file is 880

ds = Cube("temp-02.zarr") # correct if open by YAXArrays
ds.Time

julia> # length of time is 880
       times = zopen("temp-02.zarr/Time")[:]
       CFTime.timedecode(times, "days since 1980-01-01", "standard")
880-element Vector{DateTime}:
 2029-12-12T03:00:00
 2029-12-12T06:00:00
 2029-12-12T09:00:00
 2029-12-12T12:00:00
 2029-12-12T15:00:00
 2029-12-12T18:00:00
 2029-12-12T21:00:00
 2029-12-13T00:00:00
 2029-12-13T03:00:00
 2029-12-13T06:00:00
 2029-12-13T09:00:00
 2029-12-13T12:00:00
 2029-12-13T15:00:00
 
 2030-03-30T12:00:00
 2030-03-30T15:00:00
 2030-03-30T18:00:00
 2030-03-30T21:00:00
 2030-03-31T00:00:00
 2030-03-31T03:00:00
 2030-03-31T06:00:00
 2030-03-31T09:00:00
 2030-03-31T12:00:00
 2030-03-31T15:00:00
 2030-03-31T18:00:00
 2030-03-31T21:00:00
 2030-04-01T00:00:00

Double check in Python

import xarray as xr

ds = xr.open_dataset("./temp-02.zarr", engine = "zarr")
ds

image

@kongdd kongdd changed the title incorrect length of dim Time incorrect length of Time dim Oct 7, 2023
@felixcremer
Copy link
Member

I can reproduce this locally, but I have no idea where it comes from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants