爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
楼主: muyuzio

[作图] ncl中shapefile_mask_data的使用

[复制链接]

新浪微博达人勋

 楼主| 发表于 2023-3-13 15:35:51 | 显示全部楼层
shapefile_mask_data.ncl
rain_count_dali.png

shapefile_mask_data.ncl

13.52 KB, 下载次数: 12, 下载积分: 金钱 -5

售价: 1 贡献  [记录]

如题

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

使用道具 举报

新浪微博达人勋

发表于 2023-3-31 12:21:27 | 显示全部楼层
你好,我想请教下我想mask中国地区的数据,用的是wrf模式的wrfout模拟结果,但是绘图整体偏移了,我想大概是wrf模式的投影是兰波托投影,用于mask的shp是地理经纬度的缘故,我试着把shp也定义为兰波托投影,但是还是一样的,但是不知道怎们修改,你有空可以帮忙看下吗
load"./shapefile_utils.ncl"
begin
a = addfile("/data/wrfout/wrfout_huodian/wrfout_d01_2020-01-01_00:00:00"+".nc","r")

tc2 = wrf_user_getvar(a,"T2",0)     ; T2 in Kelvin
  tc2 = tc2-273.16
  tc2@units = "~F35~J~F~C"
  printVarSummary(tc2)
  xlat = a->XLAT(0,:,0)
  xlon = a->XLONG(0,0,:)

  mask_data  = tc2
  mask_data!0   = "lat"
  mask_data!1  = "lon"
  mask_data&lat = xlat
  mask_data&lon = xlon


  shp_file = "/data/wrfout/map/Province_9.shp"
   tes       = True
   tes@return_mask  = True
   land_mask = shapefile_mask_data(mask_data,shp_file,tes)


land_mask_cg = where(land_mask .eq. 1,tc2,tc2@_FillValue)

  type = "png"
  wks = gsn_open_wks(type,"t2_test01")
  gsn_define_colormap(wks,"Rainbow")
  res   =   True

  ;;plot
   cnres = res
   cnres@cnFillOn  = True
   cnres@cnLinesOn = False

   cnres@gsnLeftString = " "
    cnres@gsnRightString = ""

      contour_tc = gsn_csm_contour(wks,land_mask_cg,cnres)

    pltres            = True   ; Basic overlay plot options
    pltres@PanelPlot  = True   ; Tells wrf_map_overlays not to remove overlays

    mpres             = True   ; Set map options
    mpres@mpOutlineOn = False  ; Turn off map outlines
    mpres@mpFillOn    = False  ; Turn off map fill

    plot = wrf_map_overlays(a,wks,(/contour_tc/),pltres,mpres)

     shp_name = "/data/wrfout/map/Province_9.shp"

    lnres                  = True
    lnres@gsLineColor      = "black"

    lnres@gsLineThicknessF = 8.0

    cz_id = gsn_add_shapefile_polylines(wks,plot,shp_name,lnres)

  draw(plot)       ; This will draw the map and the shapefile outlines.
  frame(wks)       ; Advance the frame

end



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

使用道具 举报

新浪微博达人勋

发表于 2023-4-7 21:14:41 | 显示全部楼层
言洪雪 发表于 2023-2-6 21:37
求分享一份脚本,我看另外一个帖子加载的是load "$NCARG_ROOT/lib/ncarg/nclscripts/shp_mask/shapefile_ ...

https://github.com/tabishumarans ... shapefile_utils.ncl这个
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2023-6-6 19:56:38 | 显示全部楼层
bree115 发表于 2022-11-24 17:50
我也是这个问题,请问解决了吗?

没有,用这种方法应该只能画出边界范围内的值,并不是将区域外的地图叠加在等值线图上
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2023-6-15 11:39:59 | 显示全部楼层
请问用shapefile_mask_data要load什么语句呀?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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