Skip to contents

pizzarr can read Zarr stores in both V2 and V3 format. This vignette demonstrates opening the same dataset (BCSD climate observations) stored in each format and shows the data are identical.

Open V2 and V3 stores

library(pizzarr)

v2_root <- pizzarr_sample("bcsd")
v3_root <- pizzarr_sample("bcsd_v3")

v2 <- zarr_open(v2_root)
v3 <- zarr_open(v3_root)

Compare group attributes

v2_attrs <- v2$get_attrs()$to_list()
v3_attrs <- v3$get_attrs()$to_list()

identical(v2_attrs, v3_attrs)
#> [1] TRUE

Compare arrays

# Precipitation array
v2_pr <- v2$get_item("pr")$as.array()
v3_pr <- v3$get_item("pr")$as.array()

identical(v2_pr, v3_pr)
#> [1] TRUE

# Temperature array
v2_tas <- v2$get_item("tas")$as.array()
v3_tas <- v3$get_item("tas")$as.array()

identical(v2_tas, v3_tas)
#> [1] TRUE

# Coordinate arrays
identical(v2$get_item("latitude")$as.array(), v3$get_item("latitude")$as.array())
#> [1] TRUE
identical(v2$get_item("longitude")$as.array(), v3$get_item("longitude")$as.array())
#> [1] TRUE
identical(v2$get_item("time")$as.array(), v3$get_item("time")$as.array())
#> [1] TRUE

Inspect an array

v3$get_item("pr")$get_shape()
#> [1] 12 33 81

v3$get_item("pr")$get_attrs()$to_list()
#> $`_ARRAY_DIMENSIONS`
#> $`_ARRAY_DIMENSIONS`[[1]]
#> [1] "time"
#> 
#> $`_ARRAY_DIMENSIONS`[[2]]
#> [1] "latitude"
#> 
#> $`_ARRAY_DIMENSIONS`[[3]]
#> [1] "longitude"
#> 
#> 
#> $coordinates
#> [1] "time latitude longitude "
#> 
#> $long_name
#> [1] "monthly_sum_pr"
#> 
#> $name
#> [1] "pr"
#> 
#> $units
#> [1] "mm/m"