GithubHelp home page GithubHelp logo

keduba / commondatamodel.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juliageo/commondatamodel.jl

0.0 0.0 0.0 214 KB

CommonDataModel.jl is a module that defines types common to NetCDF and GRIB data

License: MIT License

Python 0.86% Julia 99.14%

commondatamodel.jl's Introduction

Build Status codecov.io documentation stable documentation dev

This package contains abstracts type definition for loading and manipulating GRIB, NetCDF, geoTiff and Zarr files. This package aims to follow the Common Data Model and the CF (climate and forecast models) Metadata Conventions.

Format Package read support write support
NetCDF NCDatasets
OPeNDAP NCDatasets -
GRIB GRIBDatasets -
geoTIFF TIFFDatasets -
Zarr ZarrDatasets

Features include:

  • query and edit metadata of arrays and datasets
  • virtually concatenating multiple files along a given dimension
  • create a virtual subset (view) by indices or by values of coordinate variables (CommonDataModel.select, CommonDataModel.@select)
  • group, map and reduce a variable (CommonDataModel.groupby, CommonDataModel.@groupby) and rolling reductions like running means CommonDataModel.rolling)

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 = ds.dim["time"] # or 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 = ds.attrib["title"]  # or CDM.attribs(ds)["title"]
close(ds)

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.

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("https://github.com/JuliaGeo/GRIBDatasets.jl/raw/98356af026ea39a5ec0b5e64e4289105492321f8/test/sample-data/era5-levels-members.grib")
netcdf_file = "test.nc"
NCDataset(netcdf_file,"c") do ds
   NCDatasets.write(ds,GRIBDataset(grib_file))
end

commondatamodel.jl's People

Contributors

alexander-barth avatar dependabot[bot] avatar tcarion avatar yeesian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.