Created
May 24, 2024 12:49
-
-
Save gmaze/9b98726da291f15ae18c8c2c7f1b079b to your computer and use it in GitHub Desktop.
Convert an Argo multi-prof netcdf into zarr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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