Skip to content

data values not right when opening Xarray-generated zarr with ncdump #2449

@christine-e-smit

Description

@christine-e-smit

ncdump version: 4.8.1 of Apr 25 2022 (this is what came with netCDF4-python 1.6.0 when I installed that)
xarray version: 2022.3.0
operating system: Mac OS Monterey
python version: 3.10.5

I found this issue using the netCDF4-python library, but I think it must be at the netcdf-c level because I'm seeing the same weird data values with ncdump. That's why I'm submitting the ticket here rather than in the netCDF-python project.

To reproduce the issue:

1. Create two directories: "download" for the netCDF file and "generated" for the zarr store.

2. Download the netcdf file into the download directory. Call it "GLDAS_NOAH025_3H.A20000101.0300.021.nc4": "https://hydro1.gesdisc.eosdis.nasa.gov/opendap/GLDAS/GLDAS_NOAH025_3H.2.1/2000/001/GLDAS_NOAH025_3H.A20000101.0300.021.nc4.nc4?time[0:1:0],lon[0:1:1439],lat[0:1:599],Rainf_tavg[0:1:0][0:1:599][0:1:1439]"

You will need to have earthdata login credentials download this URL. If you don't already have an earthdata login credential, you can create one for free here: https://urs.earthdata.nasa.gov/

3. Generate zarr using python's Xarray library. Verify that the latitude variable has values between -59.875 and 89.875

import xarray as xr
# read in the netCDF file
ds = xr.load_dataset("download/GLDAS_NOAH025_3H.A20000101.0300.021.nc4")

# check that latitude values look good. They should range from -59.875 to 89.875
print("Latitudes in original NetCDF4/HDF file:")
print(ds["lat"].values[:])

# write out zarr
ds.to_zarr("generated")

# read it in zarr using xarray
ds_from_zarr = xr.open_zarr("generated")

# print the latitudes again
print("Latitudes in zarr store, according to xarray:")
print(ds_from_zarr["lat"].values[:])

4. Now run ncdump on that zarr store:

ncdump -v lat "file://`pwd`/generated/#mode=nczarr,zarr"

ncdump gives me:

netcdf \#mode\=nczarr\,zarr {
dimensions:
	time = 1 ;
	lat = 600 ;
	lon = 1440 ;
variables:
	float Rainf_tavg(time, lat, lon) ;
		Rainf_tavg:cell_methods = "time: mean" ;
		Rainf_tavg:long_name = "Rain precipitation rate" ;
		Rainf_tavg:missing_value = -9999. ;
		Rainf_tavg:standard_name = "rainfall_flux" ;
		Rainf_tavg:units = "kg m-2 s-1" ;
		Rainf_tavg:vmax = 0.00333840004168451 ;
		Rainf_tavg:vmin = 0. ;
	float lat(lat) ;
		lat:axis = "Y" ;
		lat:long_name = "latitude" ;
		lat:standard_name = "latitude" ;
		lat:units = "degrees_north" ;
	float lon(lon) ;
		lon:axis = "X" ;
		lon:long_name = "longitude" ;
		lon:standard_name = "longitude" ;
		lon:units = "degrees_east" ;
	double time(time) ;
		time:axis = "T" ;
		time:bounds = "time_bnds" ;
		time:calendar = "standard" ;
		time:long_name = "time" ;
		time:standard_name = "time" ;
		time:units = "minutes since 2000-01-01T03:00:00" ;

// global attributes:
		:CDI = "Climate Data Interface version 1.9.8 (https://mpimet.mpg.de/cdi)" ;
		:CDO = "Climate Data Operators version 1.9.8 (https://mpimet.mpg.de/cdo)" ;
		:Conventions = "CF-1.6" ;
		:DODS_EXTRA.Unlimited_Dimension = "time" ;
		:DX = 0.25 ;
		:DY = 0.25 ;
		:MAP_PROJECTION = "EQUIDISTANT CYLINDRICAL" ;
		:SOUTH_WEST_CORNER_LAT = -59.875 ;
		:SOUTH_WEST_CORNER_LON = -179.875 ;
		:acc_definision_ = "past 3-hour accumulation" ;
		:comment = "website: https://ldas.gsfc.nasa.gov/gldas, [https://lis.gsfc.nasa.gov/"](https://lis.gsfc.nasa.gov/%22) ;
		:conventions = "CF-1.6" ;
		:history = "created on date: 2019-11-04T10:06:10.461\n2022-07-06 15:11:10 GMT Hyrax-1.16.3 [https://hydro1.gesdisc.eosdis.nasa.gov/opendap/GLDAS/GLDAS_NOAH025_3H.2.1/2000/001/GLDAS_NOAH025_3H.A20000101.0300.021.nc4.nc4?time[0:1:0],lon[0:1:1439],lat[0:1:599],Rainf_tavg[0:1:0][0:1:599][0:1:1439]"](https://hydro1.gesdisc.eosdis.nasa.gov/opendap/GLDAS/GLDAS_NOAH025_3H.2.1/2000/001/GLDAS_NOAH025_3H.A20000101.0300.021.nc4.nc4?time[0:1:0],lon[0:1:1439],lat[0:1:599],Rainf_tavg[0:1:0][0:1:599][0:1:1439]%22) ;
		:inst_definision_ = "instantaneous" ;
		:institution = "NASA GSFC" ;
		:missing_value = -9999. ;
		:references = "Rodell_etal_BAMS_2004, Kumar_etal_EMS_2006, Peters-Lidard_etal_ISSE_2007" ;
		:source = "Noah_v3.6 forced with GDAS-AGRMET-GPCPv13rA1" ;
		:tavg_definision_ = "past 3-hour average" ;
		:title = "GLDAS2.1 LIS land surface model output" ;
data:

 lat = 1.892592e-36, 3.363116e-42, 3.363116e-42, 1.027152e-42, 2.802597e-44, 
    1.821688e-44, 9.187894e-41, 1.301912e+10, 0, 1.040324e-41, 4.706426e-38, 
    2.879904e-39, 2.32714e-29, 6.779446e-31, 2.734375, 5.36916e+08, 
    -3.011738, 1.592435e-37, 1.849173e+28, 7.11524e+25, 2.731982e+23, 
    1.048661e+21, 4.023993e+18, 1.543614e+16, 5.919361e+13, 2.269132e+11, 
    8.695368e+08, 3330835, 12754.07, 48.81667, 0.1867685, 0.000714246, 
    2.730185e-06, 1.043104e-08, 3.98332e-11, 1.520318e-13, 5.799419e-16, 
    2.210975e-18, 8.424034e-21, 3.207596e-23, 1.220529e-25, 4.640977e-28, 
    1.763385e-30, 6.694873e-33, 2.539658e-35, 9.625514e-38, -4.236914e+37, 
    -6.286951e+32, -9.282427e+27, -1.368977e+23, -2.016553e+18, 
    -2.966634e+13, -4.358293e+08, -6393.224, -0.09363129, -1.368862e-06, 
    -1.997411e-11, -2.908485e-16, -4.225408e-21, -6.123076e-26, 
    -8.848101e-31, -1.274586e-35, 3.303676e+35, 7.206622e+25, 1.564891e+16, 
    3380374, 0.00072578, 1.547172e-13, 3.270122e-23, 6.840453e-33, 
    -1.59729e+32, -7.589868e+12, -3.516092e-07, -1.581693e-26, 4.694368e+24, 
    1.022974e-14, -3.22165e+10, 1.902141e-19, -2.000046, -1.05047e-09, 
    1.769917e-24, 8.805741e+14, -2.041029e-31, -4.678544e-12, -1.031469e+08, 
    -2.213423e+27, 2.463612e-35, 1.179822e-25, 5.624584e-16, 2.655094e-06, 
    12431.56, 5.780842e+13, 2.672488e+23, 1.229273e+33, -7.610976e-37, 
    -5.297439e-32, -3.67447e-27, -2.540968e-22, -1.752325e-17, -1.20547e-12, 
    -8.27416e-08, -0.005667652, -387.498, -2.644775e+07, -1.802269e+12, 
    -1.226348e+17, -8.333297e+21, -5.655496e+26, -3.833648e+31, 
    -2.595822e+36, 2.369355e-38, 6.207163e-36, 1.637371e-33, 4.315412e-31, 
    1.136424e-28, 2.990341e-26, 7.862878e-24, 2.066044e-21, 5.425129e-19, 
    1.423664e-16, 3.733745e-14, 9.786652e-12, 2.563819e-09, 6.712972e-07, 
    0.0001756818, 0.04595492, 12.01544, 3140.204, 820340.4, 2.142179e+08, 
    5.591773e+10, 1.45909e+13, 3.805914e+15, 9.92399e+17, 2.586839e+20, 
    6.74083e+22, 1.755994e+25, 4.57302e+27, 1.190578e+30, 3.098784e+32, 
    8.063204e+34, 2.097541e+37, -1.180068e-38, -1.917611e-37, -3.115383e-36, 
    -5.060139e-35, -8.217065e-34, -1.334065e-32, -2.16544e-31, -3.514201e-30, 
    -5.701917e-29, -9.24978e-28, -1.500239e-26, -2.432821e-25, -3.944415e-24, 
    -6.394106e-23, -1.036344e-21, -1.679409e-20, -2.721068e-19, 
    -4.408132e-18, -7.140087e-17, -1.156346e-15, -1.872445e-14, 
    -3.031579e-13, -4.907593e-12, -7.943455e-11, -1.285562e-09, 
    -2.080273e-08, 5.115416e-39, -39.75, 4.658682e-20, 3.355623e+07, 
    1.607556e-40, 7.018674e-38, -0.1259727, 0.7431449, 0.7470588, 3.003921, 
    4.82226e-40, 3.547074e-38, 39.82422, 2.778307e+10, 48.5647, 9.24857e-44, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0 ;
}

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions