Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Cartopy: latitude axis gridlines disappear when stand_lon is changed in namelist.wps

未关闭
#132 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python

调研方向

首先,使用 WRF geogrid.exe 的输出以及设置了不同 stand_lon 值的 namelist.wps,复现 issue 中描述的 Python Cartopy 绘图工作流。比较纬度网格线标签和经度标签,并确定截断发生在 wrf-python 中还是绘图库依赖项中;当在报告的投影设置下纬度标签仍然可见时即完成。

由索引模型根据 Issue 内容生成。

描述

Hi!

I was unsure whether to share this on the Cartopy Github page, but because the issue occurs due to a change related to WPS, it seemed appropriate to bring it up here.

I am using Cartopy 0.18.0 to plot out my WRF domains on a map. My process is running geogrid.exe and then executing a Python script that calls Cartopy to create the basemap.

In namelist.wps, I have been toying with the stand_lon variable - I would like it to deviate largely from ref_lon. However, when I set the value to be far enough away from ref_lon, run geogrid.exe, then try to plot the basemap with domain boxes overlaid, the latitude axis labels disappear! I want to have a much higher stand_lon so that my domains exclude higher-level terrain (the Rockies).

I use matplotlib.ticker.FixedLocator (Matplotlib 3.3.2) to add specific y-axis labels, but the issue seems to occur regardless of what tick method I choose. This is a specific issue for the y-axis only, as the longitudes on the x-axis seem fine. I did a test to see the extent of the problem by plotting a bunch of latitudes - and there seems to be a cutoff where Cartopy stops adding axis labels. Strange!

Initial figure: stand_lon = -123.5 = ref_lon
my_domain_1

Final figure: stand_lon = -88.5, ref_lon = -123.5
my_domain_2

Below are some lines of code connected to this problem.
Thanks so much for your help!

  • Anthony

` import cartopy.crs as ccrs
from cartopy.feature import BORDERS, COASTLINE, COLORS, LAKES, NaturalEarthFeature
from matplotlib.ticker import FixedLocator, MultipleLocator
import numpy as np

states = NaturalEarthFeature(category='cultural', scale='50m', name='admin_1_states_provinces_shp', facecolor='none')
ax.add_feature(states, edgecolor='k', linewidth=0.3)
ax.add_feature(COASTLINE, edgecolor='k', linewidth=0.5)
ax.add_feature(LAKES, edgecolor='k', facecolor='none', linewidth=0.5)
ax.add_feature(BORDERS, edgecolor='k', linewidth=0.5)

minlon = int(5*np.ceil(lons[(0,0)]/5))
maxlon = int(5*np.ceil(lons[(0,-1)]/5))
minlat = int(4*np.floor(lats[(0,0)]/4))
maxlat = int(4*np.ceil(lats[(-1,0)]/4))
lonticks = range(minlon,maxlon+1,5)
latticks = range(minlat,maxlat+1,4)

glnolabs = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=False, linewidth=1.5, linestyle='--')
glnolabs.xlocator = MultipleLocator(base=5)
glnolabs.ylocator = MultipleLocator(base=5)

gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth=1.5, linestyle='--')
gl.top_labels = False
gl.right_labels = False
gl.x_inline = False
gl.y_inline = False
gl.xlocator = FixedLocator(lonticks)
gl.ylocator = FixedLocator([40,41,42,43,44,45,46,47,48,49,50,51,52])

gl.xlabel_style = {'size':lblsz,  'color':'black',  'rotation':0}
gl.ylabel_style = {'size':lblsz,  'color':'black',  'rotation':0}

`

主要语言
Python
星标
498
派生
178
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NCAR/wrf-python 的其他 Issue

查看 NCAR/wrf-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。