CommonDataModel.jl is a module that defines types common to NetCDF and GRIB data
Author JuliaGeo
5 Stars
Updated Last
12 Months Ago
Started In
March 2023

Build Status documentation dev

This package contains abstracts type definition to ensure compatibility of the package GRIBDatasets and NCDatasets for manipulating GRIB and NetCDF files. This package aims to follow the Common Data Model and the CF (climate and forecast models) Metadata Conventions.

This package is at a very early state of developpement.

Here is minimal example for loading GRIB or NetCDF files.

import CommonDataModel as CDM
import SomeDatasets # where SomeDatasets is either GRIBDatasets or NCDatasets

ds = SomeDatasets.Dataset("file_name")

# ntime is the number of time instances
ntime = CDM.dims(ds)["time"]

# create an array-like structure v corresponding to variable temperature
v = ds["temperature"]

# load a subset
subdata = v[10:30,30:5:end]

# load all data
data = v[:,:]

# load a global attribute
title = CDM.attribs(ds)["title"]

Most users would typically import GRIBDatasets and NCDatasets directly and not CommonDataModel. One should import CommonDataModel only to extent the functionality of GRIBDatasets and NCDatasets.

As a proof-of-concept, there is also an TIFFDatasets package for GeoTIFF files.

File conversions

By implementing a common interface, GRIB files can be converted to NetCDF files using NCDatasets.write:

using NCDatasets
using GRIBDatasets
using Downloads: download

grib_file = download("")
netcdf_file = ""