6464end
6565
6666@testset " Reading Zarr" begin
67- p = " gs ://cmip6/CMIP6/HighResMIP/CMCC/CMCC-CM2-HR4/highresSST-present/r1i1p1f1/6hrPlev/psl/gn/v20170706/ "
68- ds_zarr = to_dataset (p,driver= :zarr )
69- vn = get_varnames (ds_zarr)
70- @test sort (vn) == [" lat" , " lat_bnds " , " lon" , " lon_bnds " , " psl " , " time" , " time_bnds " ]
71- @test get_var_dims (ds_zarr, " psl " ) == [" lon" , " lat" , " time" ]
72- @test get_var_dims (ds_zarr, " time" ) == [" time" ]
73- @test get_var_dims (ds_zarr, " time_bnds " ) == [ " bnds " , " time " ]
74- @test get_var_attrs (ds_zarr," psl " )[ " long_name " ] == " Sea Level Pressure "
75- h = get_var_handle (ds_zarr, " psl " )
76- @test YAXArrayBase . iscompressed (h )
77- @test all ( isapprox .(h[ 1 : 2 , 1 : 2 , 1 ], [ 99360.8 99334.9 ; 99360.8 99335.4 ]))
78- @test allow_parallel_write (ds_zarr) == true
79- @test allow_missings (ds_zarr) == false
67+ p = " https ://s3.bgc-jena.mpg.de:9000/esdl-esdc-v3.0.2/esdc-16d-2.5deg-46x72x1440-3.0.2.zarr "
68+ for ds_zarr in [ to_dataset (p,driver= :zarr ), to_dataset ( zopen (p))]
69+ vn = get_varnames (ds_zarr)
70+ @test sort (vn) == [" aerosol_optical_thickness_550 " , " air_temperature_2m " , " bare_soil_evaporation " , " burnt_area " , " cot " , " cth " , " ctt " , " evaporation " , " evaporation_era5 " , " evaporative_stress " , " gross_primary_productivity " , " interception_loss " , " kndvi " , " lat" , " latent_energy " , " lon" , " max_air_temperature_2m " , " min_air_temperature_2m " , " nbar_blue " , " nbar_green " , " nbar_nir " , " nbar_red " , " nbar_swir1 " , " nbar_swir2 " , " nbar_swir3 " , " ndvi " , " net_ecosystem_exchange " , " net_radiation " , " nirv " , " open_water_evaporation " , " potential_evaporation " , " precipitation_era5 " , " radiation_era5 " , " root_moisture " , " sensible_heat " , " sif_gome2_jj " , " sif_gome2_pk " , " sif_gosif " , " sif_rtsif " , " sm " , " snow_sublimation " , " surface_moisture " , " terrestrial_ecosystem_respiration " , " time" , " transpiration " ]
71+ @test get_var_dims (ds_zarr, " sm " ) == [" lon" , " lat" , " time" ]
72+ @test get_var_dims (ds_zarr, " time" ) == [" time" ]
73+ @test get_var_attrs (ds_zarr," sm " )[ " long_name " ] == " Volumetric Soil Moisture "
74+ h = get_var_handle (ds_zarr, " air_temperature_2m " )
75+ @test YAXArrayBase . iscompressed (h )
76+ @test all ( isapprox .(h[ 1 : 2 , 1 : 2 , 1 ], [ - 28.8662 - 23.4534 ; - 28.8041 - 23.1681 ]) )
77+ @test allow_parallel_write (ds_zarr) == true
78+ @test allow_missings (ds_zarr) == false
79+ end
8080end
8181@testset " Reading ArchGDAL" begin
8282 using ArchGDAL
@@ -99,19 +99,27 @@ function test_write(T)
9999 add_var (ds, 0.5 : 1 : 9.5 , " lon" , (" lon" ,), Dict (" units" => " degrees_east" ))
100100 add_var (ds, 20 : - 1.0 : 1 , " lat" , (" lat" ,), Dict (" units" => " degrees_north" ))
101101 v = add_var (ds, Float32, " tas" , (10 ,20 ), (" lon" , " lat" ), Dict {String,Any} (" units" => " Celsius" ))
102- w = add_var (ds, Rational{Int}, " tas2" , (10 ,20 ), (" lon" , " lat" ), Dict {String,Any} (" units" => " Celsius" ))
102+ # This is needed, since netcdf can not write rationals.
103+ if T == YAXArrayBase. backendlist[:zarr ]
104+ w = add_var (ds, Rational{Int}, " tas2" , (10 ,20 ), (" lon" , " lat" ), Dict {String,Any} (" units" => " Celsius" ))
105+ w[:,:] = collect (reshape (1 : 200 , 10 , 20 )) .// 2
106+ w = get_var_handle (ds, " tas2" )
107+ @test w[1 : 2 ,1 : 2 ] == [1 11 ; 2 12 ] .// 2
108+ w = get_var_handle (ds, " tas2" )
109+ @test w[1 : 2 ,1 : 2 ] == [1 11 ; 2 12 ] .// 2
110+ @test sort (get_varnames (ds)) == [" lat" ," lon" ," tas" , " tas2" ]
111+ else
112+ @test sort (get_varnames (ds)) == [" lat" ," lon" ," tas" ]
113+ end
103114 v[:,:] = collect (reshape (1 : 200 , 10 , 20 ))
104- w[:,:] = collect (reshape (1 : 200 , 10 , 20 )) .// 2
105- @test sort (get_varnames (ds)) == [" lat" ," lon" ," tas" , " tas2" ]
115+
106116 @test get_var_dims (ds, " tas" ) == [" lon" , " lat" ]
107117 @test get_var_dims (ds, " lon" ) == [" lon" ]
108118 @test get_var_attrs (ds," tas" )[" units" ] == " Celsius"
109119 h = get_var_handle (ds, " lon" )
110120 @test h[:] == 0.5 : 1 : 9.5
111121 v = get_var_handle (ds, " tas" )
112122 @test v[1 : 2 ,1 : 2 ] == [1 11 ; 2 12 ]
113- w = get_var_handle (ds, " tas2" )
114- @test w[1 : 2 ,1 : 2 ] == [1 11 ; 2 12 ] .// 2
115123end
116124
117125@testset " Writing NetCDF" begin
0 commit comments