Skip to content

Instantly share code, notes, and snippets.

@gmaze
Created May 24, 2024 12:49
Show Gist options
  • Save gmaze/9b98726da291f15ae18c8c2c7f1b079b to your computer and use it in GitHub Desktop.
Save gmaze/9b98726da291f15ae18c8c2c7f1b079b to your computer and use it in GitHub Desktop.
Convert an Argo multi-prof netcdf into zarr
#!/usr/bin/env python
# coding: utf-8
import xarray as xr
import argopy
from argopy.stores import httpstore
# Convert an Argo multi-prof netcdf into zarr
# 1st we get the url toward the netcdf file:
uri = argopy.DataFetcher(src='gdac').float(6902914).uri[0]
# Then we load data in memory as a xarray dataset:
ds = httpstore().open_dataset(uri, xr_opts={'engine': 'argo'})
# And we convert to a zarr file:
ds.to_zarr('6902914_prof.zarr')
# Open the zarr file
xr.open_dataset('6902914_prof.zarr', engine='zarr')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment