Skip to content

A library for encoding and decoding coverageJSON files/objects of meteorlogical features such as vertical profiles and time series.

License

Notifications You must be signed in to change notification settings

ecmwf/covjsonkit

Repository files navigation

⚠️ This project is BETA and will be experimental for the foreseeable future. Interfaces and functionality are likely to change. DO NOT use this software in any project/software that is operational.


covjsonkit

ci

ConceptInstallationExampleTesting

Concept

Covjsonkit is an ECMWF library for encoding and decoding coverageJSON files/objects of meteorlogical features such as vertical profiles and time series.

  • Encodes and decodes CoverageJSON objects
  • Convert CoverageJSON files to and from xarray
  • Works in conjunction with ECMWFs Polytope feature extraction library

Current features implemented:

  • Time Series
  • Vertical Profile
  • Bounding Box
  • Frame
  • Path
  • Wkt Polygons
  • Shapefiles

Installation

Install the covjsonkit with Python 3 (>=3.7) from GitHub directly with the command

python3 -m pip install git+ssh://[email protected]/ecmwf/covjsonkit.git@develop

or from PyPI with the command

python3 -m pip install covjsonkit

Example

The library consists of an encoder and a decoder element. The decoder can be used to decode valid coverageJSON files that can be then be edited and accessed via the api. It can also be used to convert to ther formats such as xarray.

Decoder

from covjsonkit.api import Covjsonkit

decoder = Covjsonkit().decode(coverage.covjson)

print(decoder.type)
print(decoder.parameters)
print(decoder.get_referencing())

ds = decoder.to_xarray()

Encoder

The following example encodes data output from the polytope feature extraction library assuming polytope_output is a valid output from polytope.

from covjsonkit.api import Covjsonkit

encoder = Covjsonkit().encode("CoverageCollection", "BoundingBox")
res = encoder.from_polytope(polytope_output)

Config

Covjsonkit uses a config to determine what parameter metadata to use, an example can be found in example_config.json. This will automatically be loaded at runtime to point to the correct parameter metadata files.

The example config has to be stored in one of the following places:

  1. System-wide configuration in /etc/covjsonkit/config.json (and yaml)
  2. User configuration in ~/.covjsonkit.json (and yaml)

Users can add their own parameter metadata in the data directory by add ing a new directory containing a param.json, param_id.json, and units.json in a format the same as can be found in ecmwf directory. Then edit the config to point to your newly named directory.

If users want to pass in their own config tehy can do this as a python dictioanry in the following way:

encoder = Covjsonkit(cf).encode("CoverageCollection", "BoundingBox")

Where cf is a valid covjsonkit config.

Testing

Python unit tests can be run with pytest:

python -m pytest 

When a pull request is merged into develop or main a github actions CI pipeline is triggered to test formatting and unit tests.

About

A library for encoding and decoding coverageJSON files/objects of meteorlogical features such as vertical profiles and time series.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published