Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active May 8, 2025 13:09
Show Gist options
  • Save mdsumner/f3665e6d8eed6f9d7ad29935a8f061eb to your computer and use it in GitHub Desktop.
Save mdsumner/f3665e6d8eed6f9d7ad29935a8f061eb to your computer and use it in GitHub Desktop.
zarr_json_nasa.md

Here's some examples of using the new NASA experimental json Zarr

with xarray

import xarray 
## no
#import earthaccess
#earthaccess.login()  ## use env vars ??
#fs = earthaccess.get_s3_filesystem(daac="podaac")
#so = {"remote_options": fs.storage_options}
#ds = xarray.open_dataset(u, engine="kerchunk", storage_options=so)
# sigh ... https://github.com/earth-mover/icechunk/issues/939#issuecomment-2862997146
#import earthaccess
#earthaccess.login()
#mapper = earthaccess.get_virtual_reference(short_name = "CCMP_WINDS_10M6HR_L4_V3.1")
#ds  = xarray.open_dataset(mapper, engine="zarr", chunks={}, backend_kwargs={"consolidated":False})


u = "https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-docs/ccmp/open/L4_V3.1/docs/CCMP_WINDS_10M6HR_L4_V3.1_combined-ref.json"
ds = xarray.open_dataset(u, engine="kerchunk")



xarray.open_dataset("https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-docs/ccmp/open/L4_V3.1/docs/CCMP_WINDS_10M6HR_L4_V3.1_combined-ref.json", engine = "kerchunk")
<xarray.Dataset> Size: 775GB
Dimensions:    (time: 46696, latitude: 720, longitude: 1440)
Coordinates:
  * latitude   (latitude) float32 3kB -89.88 -89.62 -89.38 ... 89.38 89.62 89.88
  * longitude  (longitude) float32 6kB 0.125 0.375 0.625 ... 359.4 359.6 359.9
  * time       (time) datetime64[ns] 374kB 1993-01-02 ... 2024-12-31T18:00:00
Data variables:
    ws         (time, latitude, longitude) float32 194GB ...
    nobs       (time, latitude, longitude) float32 194GB ...
    uwnd       (time, latitude, longitude) float32 194GB ...
    vwnd       (time, latitude, longitude) float32 194GB ...
Attributes: (12/44)
    Conventions:                   CF-1.7 ACDD-1.3
    comment:                       none
    contact:                       Remote Sensing Systems, support@remss.com
    contributor_name:              Carl Mears, Tong Lee, Frank Wentz
    contributor_role:              Principal-Investigator, Co-Investigator, C...
    creator_email:                 support@remss.com
    ...                            ...
    publisher_url:                 https://podaac.jpl.nasa.gov
    references:                    Mears, C.; Lee, T.; Ricciardulli, L.; Wang...
    source:                        blend of satellite and ERA-5 winds
    standard_name_vocabulary:      NetCDF Climate and Forecast (CF) Metadata ...
    summary:                       RSS VAM 6-hour analyses using ERA-5 wind r...
    title:                         RSS CCMP V3.1 6-hourly surface winds (Leve...

with GDAL multidim

## use GDAL_HTTP_HEADER_FILE or GDAL_HTTP_HEADERS for earthdata auth
from osgeo import gdal
gdal.UseExceptions()
gdal.OpenEx("ZARR:https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-docs/ccmp/open/L4_V3.1/docs/CCMP_WINDS_10M6HR_L4_V3.1_combined-ref.json", gdal.OF_MULTIDIM_RASTER)
ds = gdal.OpenEx("ZARR:\"/vsicurl/https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-docs/ccmp/open/L4_V3.1/docs/CCMP_WINDS_10M6HR_L4_V3.1_combined-ref.json\"", gdal.OF_MULTIDIM_RASTER)
[dim.GetSize() for dim in ds.GetRootGroup().OpenMDArray("uwnd").GetDimensions()]
#[46696, 720, 1440]


slc = ds.GetRootGroup().OpenMDArray("uwnd").GetView("[1,:,:]")
bytes = slc.Read()  ## I'm having numpy version issues as usual so can't use ReadAsArray ...
bytes[0:10]
bytearray(b'\x00<\x1c\xc6\x00<\x1c\xc6\x00<')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment