Skip to main content

Common Data Model reader and mapper toolbox

Project description

Versions

Python Package Index Build Supported Python Versions

Documentation and Support

Documentation Status

Open Source

License DOI

fair-software OpenSSF Scorecard

Coding Standards

Python Black Ruff pre-commit.ci status CodeFactor

OpenSSf Best Practices FOSSA

Development Status

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Build Status Coveralls

Funding

Funding

NOC UKMCAS

The cdm_reader_mapper toolbox is a python tool designed for:

  • to read data files compliant with a user specified data model

  • to map observed variables and its associated metadata from a data model or models combination to the C3S CDS Common Data Model (CDM) format

  • detect and flag or remove duplicated observations

It was developed to read the IMMA (International Maritime Meteorological Archive) data format, but it has been enhanced to account for meteorological data formats in the case of:

  • Data that is stored in a human-readable manner: “ASCII” format.

  • Data is stored in a Network Common Data Format: “NetCDF” format.

  • Data that is organized in single line reports

  • Reports that have a coherent internal structure and can be modelised.

  • Reports that have a fixed width or field delimited types

  • Reports that can be organized in sections, in which case each section can be of different types (fixed width of delimited)

Installation

Installation using pip

You can install the package directly from pip:

pip install cdm_reader_mapper

If you want to contribute, we recommend cloning the repository and installing the package in development mode, e.g.

git clone https://github.com/glamod/cdm_reader_mapper
cd cdm_reader_mapper
pip install -e .

This will install the package but you can still edit it and you don’t need the package in your PYTHONPATH

Installation using uv

You can install the package using uv package manager, this will add the library to your active environment:

uv add cdm_reader_mapper

To develop the package using uv, the following will create a virtual environment, uv defaults to .venv:

git clone https://github.com/glamod/cdm_reader_mapper
cd cdm_reader_mapper
uv venv --python 3.12      # Create an environment with the recommended python version
source .venv/bin/activate  # Load the virtual environment (for bash or zsh)
uv sync

Documentation

The official documentation is at https://cdm-reader-mapper.readthedocs.io/

How to make the most of cdm_reader_mapper:

Logging

By default, cdm_reader_mapper outputs logging information to stdout. To tell cdm_reader_mapper to output logs to a file, set the CDM_LOG_FILE environment variable before loading cdm_reader_mapper.

import os

os.environ["CDM_LOG_FILE"] = "log_file.log"

import cdm_reader_mapper as cdm

This will set the file log_file.log as the output for all logging information from cdm_reader_mapper, including the initial logging on loading of the package.

Run a test

Read imma data with the cdm_reader_mapper.read_mdf function:

from cdm_reader_mapper import read_mdf
from cdm_reader_mapper.data import test_data

imodel = "icoads_r300_d701"
data = test_data.test_icoads_r300_d701.get("source")

db_imma = read(filepath, imodel=imodel, sections=["core", "c1", "c98"])

Map this data to a CDM build for the same deck (in this case deck 704: US Marine Metereological Journal collection of data):

db_cdm = db_imma.map_model(
    data_raw,
    imodel=imodel,
    log_level="DEBUG",
)

Detect and flag duplicated observations:

imma_bundle.duplicate_check(inplace=True)

db_flagged = imma_bundle.flag_duplicates()

df_flagged = db_flagged.data

For more details on how to use the cdm_reader_mapper toolbox see the following jupyter example notebooks.

Contributing to cdm_reader_mapper

If you’re interested in participating in the development of cdm_reader_mapper by suggesting new features, new indices or report bugs, please leave us a message on the issue tracker.

If you would like to contribute code or documentation (which is greatly appreciated!), check out the Contributing Guidelines before you begin!

How to cite this library

If you wish to cite cdm_reader_mapper in a research publication, we kindly ask that you refer to Zenodo: https://zenodo.org/records/17403676.

License

This is free software: you can redistribute it and/or modify it under the terms of the Apache License 2.0. A copy of this license is provided in the code repository (LICENSE).

Credits

cdm_reader_mapper development is funded through Copernicus Climate Change Service (C3S).

Furthermore, acknowledgments go to National Oceanography Centre (NOC) and UK Marine and Climate Advisory Service (UKMCAS).

This package was created with Cookiecutter and the audreyfeldroy/cookiecutter-pypackage project template.

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

cdm_reader_mapper-2.3.0.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdm_reader_mapper-2.3.0-py3-none-any.whl (366.3 kB view details)

Uploaded Python 3

File details

Details for the file cdm_reader_mapper-2.3.0.tar.gz.

File metadata

  • Download URL: cdm_reader_mapper-2.3.0.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cdm_reader_mapper-2.3.0.tar.gz
Algorithm Hash digest
SHA256 158da5abccc2c6477f46f2080ce7962994b43d6caab860792c47f3f9a1dc2fcc
MD5 0eb6cded069de8a69999eecd6c260ac9
BLAKE2b-256 9d4e032081610c7c1a1bc9be141b4e3052b3233bc7a36c0c962d208c84332012

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdm_reader_mapper-2.3.0.tar.gz:

Publisher: publish-pypi.yml on glamod/cdm_reader_mapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cdm_reader_mapper-2.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cdm_reader_mapper-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be2e72f1d6cd6bd5063920f0459b87aef78d0e9a709e54c15bd2c6482b2cc471
MD5 e0e137b7d720501f12f738ee42f5513f
BLAKE2b-256 86cf35273ed5fca597b63e98c2692a089722f06b2d1f201506d948e74eef150b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdm_reader_mapper-2.3.0-py3-none-any.whl:

Publisher: publish-pypi.yml on glamod/cdm_reader_mapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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