爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索

[经验总结] Python完美白化

  [复制链接]

新浪微博达人勋

发表于 2021-5-8 08:18:47 | 显示全部楼层

厉害,厉害!!
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2021-5-8 22:45:48 | 显示全部楼层
lovechang1314 发表于 2016-3-22 17:02
简单测试了以下,可以用。
有个问题,projection='cyl' 应该是不需要转换坐标的吧?
如果用'stere'这个时 ...

散点图怎么白化
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-5-14 12:56:14 | 显示全部楼层
请问为什么所有的地方都被覆盖掉了
还有错误/home/jareau/miniconda3/envs/123/lib/python3.7/site-packages/cartopy/mpl/geoaxes.py:782: MatplotlibDeprecationWarning: Passing the minor parameter of set_ticks() positionally is deprecated since Matplotlib 3.2; the parameter will become keyword-only two minor releases later.
  return super(GeoAxes, self).set_xticks(xticks, minor)/home/jareau/miniconda3/envs/123/lib/python3.7/site-packages/cartopy/mpl/geoaxes.py:829: MatplotlibDeprecationWarning: Passing the minor parameter of set_ticks() positionally is deprecated since Matplotlib 3.2; the parameter will become keyword-only two minor releases later.  return super(GeoAxes, self).set_yticks(yticks, minor)

Out[3]:

<matplotlib.colorbar.Colorbar at 0x7fc74c125b50>


/home/jareau/miniconda3/envs/123/lib/python3.7/site-packages/cartopy/mpl/geoaxes.py:388: MatplotlibDeprecationWarning: The 'inframe' parameter of draw() was deprecated in Matplotlib 3.3 and will be removed two minor releases later. Use Axes.redraw_in_frame() instead. If any parameter follows 'inframe', they should be passed as keyword, not positionally.  inframe=inframe)

  1. from scipy.interpolate import  Rbf
  2. import matplotlib.pyplot as plt
  3. import cartopy.crs as ccrs
  4. import cartopy.feature as cfeature
  5. from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
  6. import cartopy.mpl.ticker as cticker
  7. import cartopy.io.shapereader as shpreader
  8. import maskout
  9. fig_2=plt.figure(figsize=(15,10))
  10. proj = ccrs.PlateCarree(central_longitude=115)
  11. leftlon,rightlon,lowerlat,upperlat=(70,137.5,15,52.5)
  12. lon_formatter = cticker.LongitudeFormatter(zero_direction_label=False)
  13. lat_formatter = cticker.LatitudeFormatter()
  14. f= fig_2.add_axes([0.1,0.1,0.9,0.9],projection = proj)
  15. f.xaxis.set_major_formatter(lon_formatter)
  16. f.yaxis.set_major_formatter(lat_formatter)
  17. f.set_extent([leftlon, rightlon, lowerlat, upperlat], crs=ccrs.PlateCarree())
  18. f.add_feature(cfeature.COASTLINE.with_scale('50m'))
  19. f.add_feature(cfeature.LAKES, alpha=0.5)
  20. f.set_xticks(np.arange(leftlon,rightlon+5,5), crs=ccrs.PlateCarree())
  21. f.set_yticks(np.arange(lowerlat,upperlat+5,5), crs=ccrs.PlateCarree())
  22. china = shpreader.Reader('country1.dbf').geometries()
  23. f.add_geometries(china,ccrs.PlateCarree(),facecolor='none', edgecolor='black',zorder = 1)
  24. f.set_title('EU&tem',loc='left',fontsize =20)
  25. c2=f.contourf(slon,slat,r2_new[:],levels=np.arange(-1,1.1,0.1), zorder=0,cmap=plt.cm.coolwarm,transform=ccrs.PlateCarree())
  26. c2_=f.contourf(slon,slat,p2_new,[np.min(p2_new),0.05,np.max(p2_new)],zorder=1,hatches=['.',None],colors="none",transform=ccrs.PlateCarree())
  27. clip=maskout.shp2clip(c2,f,'country1','China')
  28. cbposition=fig_2.add_axes([0.1,0.05,0.9,0.07])
  29. fig_2.colorbar(c2,cax=cbposition,orientation='horizontal',format='%.1f')
复制代码

密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-5-14 13:01:51 | 显示全部楼层
图是这样的
Snipaste_2021-05-14_13-00-27.jpg
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-5-21 21:49:16 | 显示全部楼层

自行解决了,把中心纬度设置在0度就可以了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-6-10 15:36:25 | 显示全部楼层
马克Mark一下
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-6-19 21:46:55 | 显示全部楼层
请问我想mark中国区,但是画图的时候只画[37-47N,75-125E]范围,然后画出来就会是这样,应该怎么改比较好阿T T

代码就只用了一行
clip = shp2clip(plot2,ax2,r'e:\\python\\package\\mask\\country1.shp','China')
C:\Users\NEU\Desktop\20210619214405

20210619214405.png
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-6-20 10:23:36 | 显示全部楼层
AFFan 发表于 2021-6-19 21:46
请问我想mark中国区,但是画图的时候只画[37-47N,75-125E]范围,然后画出来就会是这样,应该怎么改比较好阿 ...

害 计算的时候把范围限制在要画图的范围内就好了,感恩
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-6-28 15:03:44 | 显示全部楼层
Jareau 发表于 2021-5-21 21:49
自行解决了,把中心纬度设置在0度就可以了

请问是改这里吗“proj = ccrs.PlateCarree(central_longitude=115)”,就把115改成0就可以了是吗
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-8-13 20:17:29 | 显示全部楼层
紫依 发表于 2020-8-31 16:28
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte
请问总是 ...

兄弟你解决了吗,我现在也遇到这个问题了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表