前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >WRF后处理:图片美化

WRF后处理:图片美化

作者头像
MeteoAI
发布2021-11-12 16:58:52
1.5K0
发布2021-11-12 16:58:52
举报
文章被收录于专栏:MeteoAIMeteoAI

做WRF后处理软件的过程中主要关注了整体流程拉通和产品输出,画的图片比较粗糙,今天静下心来(被迫营业)慢慢修图,经过小组会议的讨论,总结的问题主要可以归纳为以下几点:

  • y轴的纬度标签长短不一
  • 省界过于突出
  • 数据分辨率过高,整体不美观
  • 色标标签值太长
  • 图片边缘留白过大

这里以能见度为例:

以下是具体的修改内容:

  • 调整y轴纬度标签格式
代码语言:javascript
复制
; res@pmTickMarkDisplayMode = "Always" 先取消默认的设置
xlonval = ispan(toint(10*res@mpMinLonF),toint(10*res@mpMaxLonF),5) *.1
ylatval = ispan(toint(10*res@mpMinLatF),toint(10*res@mpMaxLatF),5) *.1

res@tmXBMode    = "Explicit"
res@tmXBValues  = xlonval
res@tmXBLabels  = sprintf("%4.1f",xlonval) + "~S~o~N~E"

res@tmYLMode    = "Explicit"
res@tmYLValues  =  ylatval
res@tmYLLabels  =  sprintf("%4.1f",ylatval) + "~S~o~N~N"
  • 调整行政边界
代码语言:javascript
复制
;res@mpOutlineOn           = False   
;>--------------增加行政边界------------------------------<
shp_city                   ="xxx/boundary/city.shp"
city_res                   = True
city_res@gsLineColor       = "DimGray"
city_res@gsLineDashPattern = 0
city_res@gsLineThicknessF  = 2.0
city_plot                  = gsn_add_shapefile_polylines(wks,plot,shp_city,city_res)

shp_prov                   = "xxx/boundary/province.shp"
prov_res                   = True
prov_res@gsLineColor       = "black"
prov_res@gsLineDashPattern = 0
prov_res@gsLineThicknessF  = 3.0
prov_plot                  = gsn_add_shapefile_polylines(wks,plot,shp_prov,prov_res)
  • 数据平滑
代码语言:javascript
复制
wrf_smooth_2d(vis, 9)
  • 数据量级调整&色标标签格式设置
代码语言:javascript
复制
vis = vis / 1000.
res@cnLevels        = (/200, 500, 1000, 1500, 2000, 3000, 4000, 5000, 10000/)  / 1000.
res@lbLabelStrings  = sprintf("%4.1f",res@cnLevels)
  • 添加mark
代码语言:javascript
复制
;>--------------增加站点------------------------------<
mstring    = "z"
fontnum    = 35
xoffset    = 0.0
yoffset    = 0.0625
ratio      = 1.0
size       = 0.5
angle      = 0.0
solidstar  = NhlNewMarker(wks2,mstring,fontnum,xoffset,yoffset,ratio,size,angle)

pmres                = True
pmres@gsMarkerColor  = "red"
pmres@gsMarkerSizeF  = 0.028    
pmres@gsMarkerIndex  = solidstar
plat = xxx
plon = xxx
dum  = gsn_add_polymarker(wks,plot,plon,plat,pmres)
  • 裁减图片白边

这里主要是利用python的PIL库来进行图片白边的裁减

代码语言:javascript
复制
import sys, os
from PIL import Image, ImageOps

def crop_margin(img_fileobj, out, padding=(0, 0, 0, 0)):
    image = Image.open(img_fileobj).convert('RGB')
    ivt_image = ImageOps.invert(image)
    bbox = ivt_image.getbbox()
    left = bbox[0] - padding[0]
    top = bbox[1] - padding[1]
    right = bbox[2] + padding[2]
    bottom = bbox[3] + padding[3]
    cropped_image = image.crop([left, top, right, bottom])
    cropped_image.save(out)
    return 

dirs = r"C:\Users\jiaobf\Desktop\ZJ"
fils = os.listdir(dirs)

for fn in fils:
    if not fn.endswith('png'):continue
    fp = os.path.join(dirs, fn)
    crop_margin(fp,fp)

修改后的图片:

以上工作感谢师门的师弟师妹!


图形美化可进一步参考:

https://confluence.ecmwf.int/display/METV/Metview

http://www.caps.ou.edu/wx/casa/r/casa_dfw/fcst/

https://aviationweather.gov/

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-11-09,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 MeteoAI 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档