Skip to content

Examples

Alexander Bürger edited this page Apr 21, 2023 · 1 revision

Fimex Examples

Writing zarr with libnetcdf

Zarr does not support unlimited dimensions. You may need to set unlimited=false for some dimensions, e.g. with ncml like

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <dimension name="time" length="61" isUnlimited="false" />
</netcdf>

In version 4.8.1, libnetcdf does not support compressed zarr chunks. You probably have to disable compression with a netcdf writer config xml file similar to:

<?xml version="1.0" encoding="UTF-8"?>
<cdm_ncwriter_config>
  <default compressionLevel="0" />
</cdm_ncwriter_config>

The fimex command would then be something like

fimex \
    --input.file "input.nc" \
    --input.config "no_unlimited_dim.ncml" \
    --output.file "file:///path/to/output#mode=nczarr,file" \
    --output.config "nc_writer_no_compression.xml" \
    --output.type nc4

Please note that using libnetcdf to write zarr will still use a lock on libnetcdf function calls, i.e. there will only be one thread at a time reading or writing.

Datasets that were written like this do not seem to be readable with the same url (observed with netcdf 4.8.1), but reading appears to work with mode=zarr,file (i.e., not nczarr).

See the libnetcdf zarr documentation for more details on zarr support in libnetcdf.

Clone this wiki locally