### Create Zarr File Store Source: https://github.com/juliageo/zarrdatasets.jl/blob/main/docs/src/index.md Demonstrates how to create a Zarr file store using ZarrDatasets.jl. It includes defining dimensions, variables, assigning data, and setting attributes. The store is created in a specified directory. ```julia using ZarrDatasets # sample data data = [i+j for i = 1:3, j = 1:5] directoryname = "/tmp/test-zarr" mkdir(directoryname) ds = ZarrDataset(directoryname,"c") defDim(ds,"lon",size(data,1)) defDim(ds,"lat",size(data,2)) zv = defVar(ds,"varname",Int64,("lon","lat")) zv[:,:] = data zv.attrib["units"] = "m" close(ds) ``` -------------------------------- ### ZarrDatasets API Documentation Source: https://github.com/juliageo/zarrdatasets.jl/blob/main/docs/src/index.md Provides an overview of the ZarrDatasets module, referencing the full documentation available in CommonDataModel.jl. This section is intended as a quick reference for core functionalities. ```APIDOC Modules = [ZarrDatasets] # Reference to full documentation: # https://juliageo.org/CommonDataModel.jl/stable/ # Core functionalities include: # - Creating Zarr stores (ZarrDataset constructor, defDim, defVar) # - Reading data and attributes from Zarr stores (indexing ds["varname"]) # - Closing Zarr stores (close(ds)) ``` -------------------------------- ### Load Zarr File Store Source: https://github.com/juliageo/zarrdatasets.jl/blob/main/docs/src/index.md Shows how to load data and metadata from an existing Zarr file store using ZarrDatasets.jl. It demonstrates accessing variable data and attributes by indexing the dataset structure. ```julia using ZarrDatasets directoryname = "/tmp/test-zarr" ds = ZarrDataset(directoryname) data = ds["varname"][:,:] data_units = ds["varname"].attrib["units"] ``` -------------------------------- ### Wrap Existing Zarr Array or Store Source: https://github.com/juliageo/zarrdatasets.jl/blob/main/README.md Shows how to create a ZarrDataset by wrapping an existing Zarr array or a manually constructed Zarr store. ```julia zg = zopen("/path/to/zarr") zd = ZarrDataset(zg) ``` -------------------------------- ### Load and Subset Copernicus Marine Data Source: https://github.com/juliageo/zarrdatasets.jl/blob/main/README.md Demonstrates how to fetch a dataset URL from the Copernicus Marine Service STAC catalog, open it with ZarrDataset, subset the data based on time, longitude, and latitude, and save the selection to a NetCDF file. ```julia using CommonDataModel: @select using Dates using NCDatasets using STAC using ZarrDatasets # get the data set URL from product_id and dataset_id and the STAC catalog function copernicus_marine_catalog(product_id,dataset_id, stac_url = "https://stac.marine.copernicus.eu/metadata/catalog.stac.json", asset = "timeChunked") cat = STAC.Catalog(stac_url); item_canditates = filter(startswith(dataset_id),collect(keys(cat[product_id].items))) # use last version per default dataset_version_id = sort(item_canditates)[end] item = cat[product_id].items[dataset_version_id] return href(item.assets[asset]) end product_id = "MEDSEA_MULTIYEAR_PHY_006_004" dataset_id = "med-cmcc-ssh-rean-d" url = copernicus_marine_catalog(product_id,dataset_id) ds = ZarrDataset(url); # longitude, latitude and time are the coordinate variables defined in the # zarr dataset ds_sub = @select(ds, time == DateTime(2001,1,1) && 7 <= longitude <= 11 && 42.3 <= latitude <= 44.5) # save selection as a NetCDF file NCDataset("$(dataset_id)_selection.nc","c") do ds_nc write(ds_nc,ds_sub) end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.