爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7736|回复: 6

如何设置mpLimitMode = "Corners" 来选取指定范围的数据?

[复制链接]
回帖奖励 40 金钱 回复本帖可获得 10 金钱奖励! 每人限 1 次

新浪微博达人勋

发表于 2019-4-16 02:55:49 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 yysunnyboy 于 2019-4-16 03:45 编辑

      大家好,我想使用North American Regional Reanalysis (NARR)的数据进行气温的绘制,NARR的数据范围涵盖整个北美,而我只需要画出加拿大范围内的。由于NARR的特殊投影方式(Lambert Conformal),NARR以及NCL都建议使用 res@mpLimitMode = "Corners"来选取指定区域的数据。这个例子可以在NCL官网找到,链接如下:https://www.ncl.ucar.edu/Applications/narr.shtml
; open file and read in data
;-----------------------------------------------
  diri    = "./"                              ; input directory
  f       = addfile (diri+"air.200001.nc", "r")
                                              ; convert short=>float
;
; This file has two missing values, which are not the same.
; The _FillValue is -32767, while missing_value is 32766.
; Fix this by setting _FillValue to missing_value, so that
; all values equal to 32766 get marked as missing, and then
; convert to float using short2flt.
;
  x_short            = f->air(10,:,:,:)       ; (11th time index,lev,lat,lon)
  x_short@_FillValue = x_short@missing_value  ; fix missing value
  x                  = short2flt( x_short )   ; apply scale and offset attributes
  delete(x_short)

  printVarSummary(x)
  printMinMax(x,0)

  lat2d   = f->lat                            ; coordinates
  lon2d   = f->lon
  dimlc   = dimsizes(lat2d)                   ; dimension sizes
  nlat    = dimlc(0)
  mlon    = dimlc(1)

;-----------------------------------------------
; Create plots
;-----------------------------------------------
  wks  = gsn_open_wks ("png", "narr")             ; send graphics to PNG file  
  cmap = read_colormap_file("gui_default")        ; read color data

  res                        = True               ; plot mods desired for original grid
  res@cnFillOn               = True               ; color fill  
  res@cnFillPalette          = cmap(2:,:)         ; set color map
  res@cnLinesOn              = False              ; no contour lines
  res@mpGridAndLimbOn        = True
  res@pmTickMarkDisplayMode  = "Always"           ; turn on tickmarks
  res@tmXTOn                 = False  
  res@gsnAddCyclic           = False              ; regional data

  res@mpLimitMode            = "Corners"          ; choose range of map
  res@mpLeftCornerLatF       = lat2d(0,0)
  res@mpLeftCornerLonF       = lon2d(0,0)
  res@mpRightCornerLatF      = lat2d(nlat-1,mlon-1)
  res@mpRightCornerLonF      = lon2d(nlat-1,mlon-1)
  res@tfDoNDCOverlay         = True
  res@mpProjection           = "LambertConformal"

  res@mpLambertParallel1F    = f->Lambert_Conformal@standard_parallel(0)        
  res@mpLambertParallel2F    = f->Lambert_Conformal@standard_parallel(1)
  res@mpLambertMeridianF     = f->Lambert_Conformal@longitude_of_central_meridian

  res@gsnCenterString         = "T@"+x&level(3) + "hPa"          ; draw center subtitle
  res@gsnLeftString           = "Original grid"                  ; draw left subtitle

  plot = gsn_csm_contour_map(wks,x(3,:,:),res)               ; Draw original grid on map
  end


narr_2_lg.png

以上的脚本文件可以正确画出北美的气温图,然而,当我想更改mpLimitMode = "Corners" 的参数来画出加拿大范围内的数据时,就会出错。例如,加拿大范围内本来没有红色,但下面的图中加拿大却出现了红色。并且,y轴的纬度刻度也是错误的,请问大家该如何解决呢?谢谢。以下是我修改的脚本,其余与上面的脚本一样。
  res@mpLimitMode            = "Corners"            
  res@mpLeftCornerLatF       = lat2d(100,100)         
  res@mpLeftCornerLonF       = lon2d(0,0)           
  res@mpRightCornerLatF      = lat2d(150,200)   
  res@mpRightCornerLonF      = lon2d(nlat-1,mlon-1) narr2.png



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

新浪微博达人勋

发表于 2020-9-27 16:08:06 | 显示全部楼层

回帖奖励 +10 金钱

lat2d   = f->lat                            ; coordinates
  lon2d   = f->lon
  dimlc   = dimsizes(lat2d)                   ; dimension sizes
  nlat    = dimlc(0)
  mlon    = dimlc(1)
我觉得你在这里就写错了,  dimlc   = dimsizes(lat2d)  ,   lat2d 应该是一个1维数组,mlon值不对,

应该是
  dimlc = dimsize(x) ;x是一个三维数组
  nlat    = dimlc(1)
  mlon    = dimlc(2)

不知道是不是这样的问题。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-11-2 14:41:51 | 显示全部楼层

回帖奖励 +10 金钱

学习了
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2020-11-9 14:50:50 | 显示全部楼层

回帖奖励 +10 金钱

学习了,谢谢楼主
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-11-9 17:48:22 | 显示全部楼层

回帖奖励 +10 金钱

正好用上,感恩
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-11-13 15:44:41 | 显示全部楼层

回帖奖励 +10 金钱

谢谢楼主了,嘿嘿嘿,白嫖一波钱
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-12-16 15:08:37 | 显示全部楼层

回帖奖励 +10 金钱

学习了,谢谢楼主!
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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