Skip to main content

A graph tool for CEMC/CMA.

Project description

cedarkit-plots

Maturity-Sandbox GitHub Release PyPI - Version GitHub License GitHub Action Workflow Status

A plotting tool for meteorology data.

Install

Install using pip:

pip install cedarkit-plots

Or download the latest source code from GitHub and install manually.

Getting started

The following example uses CMA-GFS data to draw a 2m temperature contour fill plot.

Set some variables:

import pandas as pd

graph_name = "2m Temperature (C)"
system_name = "CMA-GFS"
start_time = pd.to_datetime("2024-11-09")
forecast_time = pd.to_timedelta("24h")

Get local data file path using reki:

from reki.data_finder import find_local_file

data_file_path = find_local_file(
    "cma_gfs_gmf/grib2/orig",
    start_time=start_time,
    forecast_time=forecast_time,
)

Load 2m temperature field from file and convert unit:

from reki.format.grib.eccodes import load_field_from_file

field_t_2m = load_field_from_file(
    data_file_path,
    parameter="2t",
) - 273.15

Create contour style, including levels and colormap. In this example, a NCL colormap embedded in the project is used.

import numpy as np
import matplotlib.colors as mcolors
from cedarkit.plots.colormap import get_ncl_colormap
from cedarkit.plots.style import ContourStyle

t_2m_level = [-24, -20, -16, -12, -8, -4, 0, 4, 8, 12, 16, 20, 24, 28, 32]

color_map = get_ncl_colormap("BlAqGrYeOrReVi200")
color_index = np.array([2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152]) - 2
t_2m_color_map = mcolors.ListedColormap(color_map(color_index))

t_2m_style = ContourStyle(
    colors=t_2m_color_map,
    levels=t_2m_level,
    fill=True,
)

Create a build-in template EastAsiaMapTemplate. A template is a pre-defined layout to put title, text info, colorbar in some position.

from cedarkit.plots.domains import EastAsiaMapTemplate

domain = EastAsiaMapTemplate()

Create plot panel and plot the field:

from cedarkit.plots.chart import Panel

panel = Panel(domain=domain)
panel.plot(field_t_2m, style=t_2m_style)

Add title and colorbar:

domain.set_title(
    panel=panel,
    graph_name=graph_name,
    system_name=system_name,
    start_time=start_time,
    forecast_time=forecast_time,
)
domain.add_colorbar(panel=panel, style=t_2m_style)

Show the picture:

panel.show()

LICENSE

Copyright © 2021-2026, developers at cemc-oper.

cedarkit-plots is licensed under Apache License V2.0

Third party

cedarkit/plots/resources/map/china-shapefiles is from project dongli/china-shapefiles.

cedarkit/plots/resources/colormap/ncl is from project NCL.

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

cedarkit_plots-2026.7.0.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

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

cedarkit_plots-2026.7.0-py3-none-any.whl (2.1 MB view details)

Uploaded Python 3

File details

Details for the file cedarkit_plots-2026.7.0.tar.gz.

File metadata

  • Download URL: cedarkit_plots-2026.7.0.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cedarkit_plots-2026.7.0.tar.gz
Algorithm Hash digest
SHA256 f234d43f3f0ada09b4b2833c6b510d9ab526a75c867abc26b35122dbfa5686a5
MD5 f80620b66bb651ed72a74f25f4c3f9cb
BLAKE2b-256 4d0defb51ebd9bee268f302201e2d5f8b50a2c39bd93245bcb384911550fd2b6

See more details on using hashes here.

File details

Details for the file cedarkit_plots-2026.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cedarkit_plots-2026.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1be672262bf56c683804bca8bc89cf8db453d1f9fcd9ca5d067e1f1e17410831
MD5 32da6f3b3328bb8408998f7a7589689d
BLAKE2b-256 ec0dde78b39566910fa945583808a7587c957a855145d302fc478c5c0cc5b510

See more details on using hashes here.

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