爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6139|回复: 1

[作图] 【已解决】兰伯特投影插值为等经纬度投影问题(wrfout数据)

[复制链接]

新浪微博达人勋

发表于 2022-2-22 21:27:49 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 阿羊出没请注意 于 2022-4-1 10:12 编辑

在绘制24累计降水量时,画出来的图经纬度是斜着的
Precip_NSLL_24hourly_grid_62.png
我想画成经纬度是直线的,类似于这样
等经纬度.png


在家园搜索了很久,试了rcm2rgrid方法,也试了用gsn_csm_contour_map代替wrf函数画map的方法,都失败了。

求大神看看问题出在哪里,下面附上我的脚本。
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;load "./WRFUserARW.ncl"

begin
;
; 读取数据
  DATADir = "F:/work3_dblw_LLP/NSLL/"
  FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d02_2021-06-02*")
  numFILES = dimsizes(FILES)
  a = addfiles(FILES+".nc","r")

  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file
  lat2d= wrf_user_getvar(a, "XLAT", 0)   ;lat is 3d,should change to 2d,第三维选择时间为0.如果-1就是三维
  lon2d= wrf_user_getvar(a, "XLONG", 0)
  rain_exp = wrf_user_getvar(a,"RAINNC",-1)
  rain_con = wrf_user_getvar(a,"RAINC",-1)

;插值
  lat = fspan(25,55,120)   
  lon = fspan(110,140,120) ; create longitudes or read from file  ; 6values

  rain_exp_grd = rcm2rgrid(lat2d, lon2d, rain_exp, lat, lon, 0)
  rain_con_grd = rcm2rgrid(lat2d, lon2d, rain_con, lat, lon, 0)
  rain_tot_grd = rain_exp_grd+rain_con_grd
  rain_tot_hour=rain_tot_grd
  rain_tot_hour@description = "Total Precipitation"

;画图
  wks = gsn_open_wks("png","Precip_NSLL_24hourly_grid_62")

  res = True
  res@MainTitle = "REAL-TIME WRF"   ;在左上角的标题
  res@mpProjection = "Mercator"
  pltres = True
  mpres = True
  mpres@mpGeophysicalLineColor   = "Black"
  mpres@mpNationalLineColor      = "Black"
  mpres@mpUSStateLineColor       = "Black"
  mpres@mpGridLineColor          = "Black"
  mpres@mpLimbLineColor          = "Black"
  mpres@mpPerimLineColor         = "Black"
  mpres@mpGridSpacingF           = 10
  mpres@pmTickMarkDisplayMode   = "Always"
  mpres@tmYROn                  = False
  mpres@tmYLOn                  = True
  mpres@tmXBOn                  = True
  mpres@tmXTOn                  = False
;==============================================
   mpres@mpOutlineBoundarySets  = "National"   ; turn on country boundaries
   mpres@mpOutlineSpecifiers    = (/"China:states","Taiwan"/)
   mpres@mpDataSetName          = "Earth..4"
   mpres@mpDataBaseVersion      = "MediumRes"
   mpres@mpGeophysicalLineColor   = "Black"
   mpres@mpNationalLineColor      = "Black"
   mpres@mpFillAreaSpecifiers        = (/"China"/)
   mpres@mpSpecifiedFillColors       = (/"White"/)
   mpres@mpGeophysicalLineThicknessF = 2.0   ; for Offshore Line thickness
   mpres@mpNationalLineThicknessF    = 2.0   ; for National Line thickness

   ; mpres@gsnAddCyclic           =False
   mpres@mpGridLatSpacingF = 10 ; grid line spacing on plot
   mpres@mpGridLonSpacingF = 10
   mpres@pmTickMarkDisplayMode = "Always" ; display tick marks
   mpres@tmXTLabelsOn = False ; turn off tick-marks labels at top of plot
   mpres@tmYRLabelsOn = False ; trun off tick-marks labels at right of plot
   mpres@tmXTOn = False ; turn off top tick marks
   mpres@tmYROn = False; turn off right tick marks
   mpres@mpGridAndLimbOn = True ; set to true if you want grid lines to show
   mpres@mpGridLineDashPattern = 2 ; make grid lines dash

   mpres@mpLimbLineColor                = "Black"
   mpres@mpPerimLineColor               = "Black"

   mpres@mpCountyLineThicknessF      = 2.
   mpres@mpProvincialLineThicknessF  = 1.


;计算24h累计降水,因为逐10min输出一次,所以一共144个文件
  do it =143,ntimes-1,143    ; Let's skip the first time as rain is 0 here

    rain_tot_hour(143,:,:)=rain_tot_grd(it,:,:)-rain_tot_grd(it-143,:,:)
    print("Working on time: " + times(it) )
    res@TimeLabel = times(it)   ; Set Valid time to use on plots


  ; Plotting options for Precipitation
    opts_r = res                        
    opts_r@UnitLabel            = "mm"
    opts_r@cnLevelSelectionMode = "ExplicitLevels"
    opts_r@cnLevels             = (/ .1, .5, 1, 2, 3, 4, 5, \
                                    6, 8, 10, 20, 40, 60/)
    ; cmap = read_colormap_file("BlGrYeOrReVi200")
    opts_r@cnFillColors         = (/"White","royal blue","DeepSkyBlue", \
                                    "Chartreuse3","Green","ForestGreen", \
                                    "Yellow","gold","Orange","OrangeRed","Red","firebrick","Violet"/)

    opts_r@cnConstFLabelOn      = False
    opts_r@cnFillOn             = True

    contour_tot = wrf_contour(a[it],wks, rain_tot_hour(it,:,:), opts_r)

    opts_r@SubFieldTitle = "from " + times(it-1) + " to " + times(it)

    opts_r@cnFillOn = False
    opts_r@cnLineColor = "Red4"

    delete(opts_r)



  ; MAKE PLOTS                                       

    ; Total Precipitation
      plot = wrf_map_overlays(a[it],wks,contour_tot,pltres,mpres)
  end do



  end

precip.txt

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

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2023-7-20 11:37:52 | 显示全部楼层
你好请问怎么解决的呀?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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