Skip to main content

Python package which will be used to ensure consistent data format when working with Xarray type data objects.

Project description

cgul

Common Generalised Uniform and Light. Python package which will be used to ensure consistent data format when working with Xarray type data objects.

Usage

The primary function in cgul is cgul.translate_coords. This function operates on an xarray.Dataset or xarray.DataArray and translates the coordinates to the specified coordinate model. Several coordinate models are included in the package, and users are recommended to use the default CADS coordinate model. A typical use case woould be:

import xarray as xr
import cgul

infile = 'data_file.nc'
data = xr.open_dataset(infile)

# To harmonise the coordinates and unit names:
data_cgul = cgul.harmonise(
    data,
    coord_model=cgul.coordinate_models.CADS  # This is the default value, so optional in this case
)

# To just harmonise the coordinates:
data_cgul = cgul.translate_coordinates(
    data,
    coord_model=cgul.coordinate_models.CADS  # This is the default value, so optional in this case
)

It is is also possible to use command line executables to check files can be harmonised, or to produce netCDF files with harmonised coordinates and metadata:

# To check that $INFILE has contents that can be harmonised,
# this will print out the harmonised xarray.Dataset:
cgul harmonise --check $INFILE

# To produce an ouput file, $OUTFILE, which contains the harmonised version of
# the contents of $INFILE:
cgul harmonise --output $OUTFILE $INFILE

Workflow for developers/contributors

For best experience create a new conda environment (e.g. DEVELOP) with Python 3.10:

conda create -n DEVELOP -c conda-forge python=3.10
conda activate DEVELOP

Before pushing to GitHub, run the following commands:

  1. Update conda environment: make conda-env-update
  2. Install this package: pip install -e .
  3. Sync with the latest template (optional): make template-update
  4. Run quality assurance checks: make qa
  5. Run tests: make unit-tests
  6. Build the documentation (see Sphinx tutorial): make docs-build

License

Copyright 2017-2022, European Union.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cgul-0.0.2.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

cgul-0.0.2-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file cgul-0.0.2.tar.gz.

File metadata

  • Download URL: cgul-0.0.2.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for cgul-0.0.2.tar.gz
Algorithm Hash digest
SHA256 45bbf1e0e948e9cec3a861d8a7fca62bd22fa0376a85252710ebdf8b0f72723c
MD5 e8b2a1abac12da0e6110bd2ae8482d74
BLAKE2b-256 e78c229bb3af95e1686f1964be0b0a48925976c0c9fe0ee1079775dc634418fa

See more details on using hashes here.

File details

Details for the file cgul-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: cgul-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for cgul-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c58c4c4e0e7e2d6e5fcc507d8cd7e384e82ba0a3c865e1f14894e6f4285a3d66
MD5 7de62a729f10493f95e15156cc26b97f
BLAKE2b-256 49ecaddd33bd039b3a0ad8ac1d720f7a7ae268150c1939acdfbeec52652ff2e3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page