Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

全球区域

全球区域底图布局 (cedarkit.plots.domains.GlobalAreaMapTemplate) 绘制全球范围任意区域的图形,继承自全球底图布局 (GlobalMapDomain),并增加了国境线。

准备

导入需要的包

import numpy as np
import pandas as pd

from cedarkit.plots.chart import Panel
from cedarkit.plots.domains import GlobalAreaMapTemplate
from cedarkit.plots.map import set_default_map_loader_package
from cedarkit.plots.style import ContourStyle
from cedarkit.plots.colormap import get_ncl_colormap
from cedarkit.plots.types import AreaRange
start_time = pd.Timestamp.now().normalize() - pd.Timedelta(days=2)
forecast_time = pd.to_timedelta("24h")

设置使用 CEMC 地图包

set_default_map_loader_package("cedarkit.plots.map.cemc")
'cedarkit.plots.map.cemc'

定义绘图样式

t_contour_lev = np.array([0, 4, 8, 12, 16, 20, 24, 28, 32, 36])
colormap = get_ncl_colormap(
    "WhBlGrYeRe", index=np.array([2, 8, 14, 20, 45, 55, 65, 72, 80, 90, 100]))
t_style = ContourStyle(
    colors=colormap,
    levels=t_contour_lev,
    fill=True,
)

绘制

定义绘图区域

area = AreaRange.from_tuple((45, 110, -10, 45))

绘制底图布局

domain = GlobalAreaMapTemplate(area=area)
panel = Panel(domain=domain)

domain.set_title(
    panel=panel,
    graph_name=r"2m Temperature ($^\circ$C,shadow)",
    system_name="CMA-GFS",
    start_time=start_time,
    forecast_time=pd.Timedelta(hours=24),
)
domain.add_colorbar(panel, style=t_style)

panel.show()
<Figure size 3200x3200 with 1 Axes>