做WRF后处理软件的过程中主要关注了整体流程拉通和产品输出,画的图片比较粗糙,今天静下心来(被迫营业)慢慢修图,经过小组会议的讨论,总结的问题主要可以归纳为以下几点:
这里以能见度为例:
以下是具体的修改内容:
; 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"
;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)
wrf_smooth_2d(vis, 9)
vis = vis / 1000.
res@cnLevels = (/200, 500, 1000, 1500, 2000, 3000, 4000, 5000, 10000/) / 1000.
res@lbLabelStrings = sprintf("%4.1f",res@cnLevels)
;>--------------增加站点------------------------------<
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库来进行图片白边的裁减
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/