Skip to content

Saving cube with Proleptic Datetime changes time axis #576

Description

@felixcremer

When I am saving a data cube with a nanosecond resolution to disk this is some how scrambled and I get a date time back with strange values.
I can't use the prefer_datetime keyword in the Cube constructor but I would have expected that it would recognize it automatically.

julia> path = "/home/fcremer/Documents/EOPF.jl/data/S1A_IW_GRDH_1SDV_20250626T053421_20250626T053446_059813_076DB6_D372.zarr/S01SIWGRD_20250626T053421_0025_A342_D372_076DB6_VH/measurements/"
"/home/fcremer/Documents/EOPF.jl/data/S1A_IW_GRDH_1SDV_20250626T053421_20250626T053446_059813_076DB6_D372.zarr/S01SIWGRD_20250626T053421_0025_A342_D372_076DB6_VH/measurements/"

julia> zopen(path)^C

julia> c = Cube(path)
┌ 26533×16668 YAXArray{UInt16, 2} measurement data set for GRD IW ┐
├─────────────────────────────────────────────────────────────────┴─────────────────────────────────────────── dims ┐
  ↓ ground_range Sampled{Float64} 0.0:10.0:265320.0 ForwardOrdered Regular Points,
  → azimuth_time Sampled{CFTime.DateTimeProlepticGregorian{CFTime.Period{Int64, Val{1}(), Val{-9}()}, Val{(2025, 6, 26, 5, 34, 21, 819, 152)}()}} [DateTimeProlepticGregorian(2025-06-26T05:34:21.819152), …, DateTimeProlepticGregorian(2025-06-26T05:34:46.817343)] ForwardOrdered Irregular Points
├───────────────────────────────────────────────────────────────────────────────────────────────────────── metadata ┤
  Dict{String, Any} with 5 entries:
  "dtype"       => "<u2"
  "coordinates" => "line pixel"
  "name"        => "grd"
  "long_name"   => "measurement data set for GRD IW"
  "_eopf_attrs" => Dict{String, Any}("dtype"=>"<u2", "coordinates"=>Any["azimuth_time", "line", "pixel", "ground_ran…
├──────────────────────────────────────────────────────────────────────────────────────────────────── loaded lazily ┤
  data size: 843.53 MB
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

julia> subc = c[azimuth_time=1:100, ground_range=1:100]
┌ 100×100 YAXArray{UInt16, 2} measurement data set for GRD IW ┐
├─────────────────────────────────────────────────────────────┴─────────────────────────────────────────────── dims ┐
  ↓ ground_range Sampled{Float64} 0.0:10.0:990.0 ForwardOrdered Regular Points,
  → azimuth_time Sampled{CFTime.DateTimeProlepticGregorian{CFTime.Period{Int64, Val{1}(), Val{-9}()}, Val{(2025, 6, 26, 5, 34, 21, 819, 152)}()}} [DateTimeProlepticGregorian(2025-06-26T05:34:21.819152), …, DateTimeProlepticGregorian(2025-06-26T05:34:21.967638284)] ForwardOrdered Irregular Points
├───────────────────────────────────────────────────────────────────────────────────────────────────────── metadata ┤
  Dict{String, Any} with 5 entries:
  "dtype"       => "<u2"
  "coordinates" => "line pixel"
  "name"        => "grd"
  "long_name"   => "measurement data set for GRD IW"
  "_eopf_attrs" => Dict{String, Any}("dtype"=>"<u2", "coordinates"=>Any["azimuth_time", "line", "pixel", "ground_ran…
├──────────────────────────────────────────────────────────────────────────────────────────────────── loaded lazily ┤
  data size: 19.53 KB
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

julia> subc_saved = savecube(subc, "testdatasub.zarr")
┌ 100×100 YAXArray{UInt16, 2} measurement data set for GRD IW ┐
├─────────────────────────────────────────────────────────────┴─────────────────────────────────────────────── dims ┐
  ↓ ground_range Sampled{Float64} 0.0:10.0:990.0 ForwardOrdered Regular Points,
  → azimuth_time Sampled{CFTime.DateTimeProlepticGregorian{CFTime.Period{Int64, Val{1}(), Val{-9}()}, Val{(2025, 6, 26, 5, 34, 21, 819, 152)}()}} [DateTimeProlepticGregorian(2025-06-26T05:34:21.819152), …, DateTimeProlepticGregorian(2025-06-26T05:34:21.967638284)] ForwardOrdered Irregular Points
├───────────────────────────────────────────────────────────────────────────────────────────────────────── metadata ┤
  Dict{String, Any} with 5 entries:
  "dtype"       => "<u2"
  "coordinates" => "line pixel"
  "name"        => "grd"
  "long_name"   => "measurement data set for GRD IW"
  "_eopf_attrs" => Dict{String, Any}("dtype"=>"<u2", "coordinates"=>Any["azimuth_time", "line", "pixel", "ground_ran…
├──────────────────────────────────────────────────────────────────────────────────────────────────── loaded lazily ┤
  data size: 19.53 KB
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

julia> subc_loaded = Cube("testdatasub.zarr/")
┌ 100×100 YAXArray{UInt16, 2} measurement data set for GRD IW ┐
├─────────────────────────────────────────────────────────────┴─────────────────────────────────────────────── dims ┐
  ↓ ground_range Sampled{Float64} 0.0:10.0:990.0 ForwardOrdered Regular Points,
  → azimuth_time Sampled{DateTime} [DateTime("45487464-11-02T23:32:31.872"), …, DateTime("45487464-11-04T16:47:18.272")] ForwardOrdered Irregular Points
├───────────────────────────────────────────────────────────────────────────────────────────────────────── metadata ┤
  Dict{String, Any} with 6 entries:
  "dtype"       => "<u2"
  "coordinates" => "line pixel"
  "name"        => "grd"
  "long_name"   => "measurement data set for GRD IW"
  "_eopf_attrs" => Dict{String, Any}("dtype"=>"<u2", "coordinates"=>Any["azimuth_time", "line", "pixel", "ground_ran…
  "_FillValue"  => 0xffff
├──────────────────────────────────────────────────────────────────────────────────────────────────── loaded lazily ┤
  data size: 19.53 KB
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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