跳转到主要内容

Python包,用于确保在处理Xarray类型数据对象时数据格式的一致性。

项目描述

cgul

Common Generalised Uniform and Light. Python包,用于确保在处理Xarray类型数据对象时数据格式的一致性。

用法

cgul中的主要功能是cgul.translate_coords。此功能在xarray.Datasetxarray.DataArray上操作,将坐标转换为指定的坐标模型。该软件包中包含几个坐标模型,建议用户使用默认的CADS坐标模型。一个典型的用例将是

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
)

还可以使用命令行可执行文件来检查文件是否可以调和,或者生成具有调和坐标和元数据的netCDF文件

# 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

开发者/贡献者的工作流程

为了获得最佳体验,请创建一个新的conda环境(例如,DEVELOP),使用Python 3.10

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

在推送到GitHub之前,运行以下命令

  1. 更新conda环境:make conda-env-update
  2. 安装此软件包:pip install -e .
  3. 与最新的模板同步(可选):make template-update
  4. 运行质量保证检查:make qa
  5. 运行测试:make unit-tests
  6. 构建文档(见Sphinx教程):make docs-build

许可证

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

    https://apache.ac.cn/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.

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装软件包的更多信息。

源代码分发

cgul-0.0.4.tar.gz (29.7 kB 查看哈希)

上传时间 源代码

构建分发

cgul-0.0.4-py3-none-any.whl (24.1 kB 查看哈希)

上传时间 Python 3

支持者