中国区域#
中国区域 (cedarkit.maps.domains.CnAreaMapTemplate
) 继承自东亚区域 (cedarkit.maps.domains.EastAsiaMapTemplate
),默认不绘制南海子图。
准备#
导入需要的包
import pandas as pd
import matplotlib.colors as mcolors
from cedarkit.maps.chart import Panel
from cedarkit.maps.domains import CnAreaMapTemplate
from cedarkit.maps.map import set_default_map_loader_package
from cedarkit.maps.style import ContourStyle
from cedarkit.maps.colormap import get_ncl_colormap
from cedarkit.maps.util import AreaRange
设置使用 CEMC 地图包
set_default_map_loader_package("cedarkit.maps.map.cemc")
'cedarkit.maps.map.cemc'
定义绘图样式
color_map = get_ncl_colormap("BlAqGrYeOrReVi200")
t_2m_level = [-24, -20, -16, -12, -8, -4, 0, 4, 8, 12, 16, 20, 24, 28, 32]
color_index = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152]
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,
)
绘制#
定义华北区域
area = AreaRange.from_tuple((105, 125, 34, 45))
绘制底图布局
domain = CnAreaMapTemplate(area=area)
panel = Panel(domain=domain)
domain.add_colorbar(panel=panel, style=t_2m_style)
domain.set_title(
panel=panel,
graph_name="2m Temperature (C)",
system_name="CMA-MESO",
start_time=pd.to_datetime("2024-03-20 00:00"),
forecast_time=pd.to_timedelta("24h"),
)
panel.show()
