爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 13213|回复: 16

[作图] NCL绘制CALIPSO L2 VFM图像

[复制链接]

新浪微博达人勋

发表于 2019-4-17 21:03:56 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 灭火器 于 2019-4-18 08:22 编辑

读取数据主要参考了CALIPSO官网、NCL的dim_gbits函数页面,和hdfeos网站的例子:
[1]https://www-calipso.larc.nasa.gov/resources/calipso_users_guide/data_summaries/vfm/
[2]http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_gbits.shtml
[3]hdfeos.org/zoo/index_openLaRC_Examples.php#CALIPSO

需要注意的点有:
(1)读取Latitude数据时,数组大小是(4224,1)。但如果直接用f->Latitude读取,NCL会用hdf文件中大小为63360的fakeDim2作为Latitude的第一维,导致原本的Latitude数组后面多出了许多0值。因此手动用f->Latitude(0:4223, 0)读取。
(2)变量Feature_Classification_Flags的类型是ushort,长度为16 bit。对于一个二进制的数,函数dim_gbits是从左往右读的,而CALIPSO官网所说的1-3 bits表示类型,是从右往左读的。因此使用函数前需要换算一下。
(3)作图时还用上了aerosol subtype中的dust。
(4)图中把-0.5~8.2km,8.2~20.2km的廓线都画了出来。因为直接用数组来画contour时,NCL依据数组的大小而不是coordinate的相对大小来画图,所以把8.2~20.2km内的一个bin分为两个相同的bin来画图。也许用res@sfXArray和res@sfYArray来设置,就不用这么麻烦。
代码在NCL V6.40下运行,具体如下:
  1. ;----------------------------------------------------------------
  2. ;# 2019/04/17
  3. ;# Draw CALIOP feature type and sub type between -0.5km to 20.2 km.
  4. ;# Reference:
  5. ;  https://www-calipso.larc.nasa.gov/resources/calipso_users_guide/data_summaries/vfm/
  6. ;----------------------------------------------------------------
  7. begin
  8.     filename = "../CALIOP/CAL_LID_L2_VFM-Standard-V4-20.2015-04-18T04-57-10ZD.hdf"
  9.     file_vfm = addfile(filename, "r")
  10.    
  11.     ; Dim of Latitude is 0:4223, total 4224.
  12.     latmin = 30.0
  13.     latmax = 40.0
  14.     lat_raw = file_vfm->Latitude(0:4223,0)
  15.     ii = ind(lat_raw .ge. latmin .and. lat_raw .le. latmax)
  16.     lat = lat_raw(ii)
  17.    
  18.     ; -0.5km to 8.2km, profile 0, subscripts are 1165:5514.
  19.     fcf1 = file_vfm->Feature_Classification_Flags(ii,1165:1454)
  20.     dims1 = dimsizes(fcf1)

  21.     ; 8.2km to 20.2km, profile 0, subscripts are 165:364.
  22.     fcf2 = file_vfm->Feature_Classification_Flags(ii, 165:364)
  23.     dims2 = dimsizes(fcf2)

  24.     ; Select 1-3 bits, Feature Type
  25.     ; 0 = invalid
  26.     ; 1 = clear air
  27.     ; 2 = cloud
  28.     ; 3 = aerosol
  29.     ; 4 = stratospheric feature
  30.     ; 5 = surface
  31.     ; 6 = subsurface
  32.     ; 7 = no signal
  33.     fType1 = toint(dim_gbits(fcf1, 13, 3, 13, dims1(1)))
  34.     subType1 = toint(dim_gbits(fcf1, 4, 3, 13, dims1(1)))
  35.     fType2 = toint(dim_gbits(fcf2, 13, 3, 13, dims2(1)))
  36.     subType2 = toint(dim_gbits(fcf2, 4, 3, 13, dims2(1)))
  37.     ; When Feature type = 3 and subtype = 2, then type is dust, let it be 8.
  38.     fType1 = where((fType1 .eq. 3 .and. subType1 .eq. 2), 8, fType1)
  39.     fType2 = where((fType2 .eq. 3 .and. subType2 .eq. 2), 8, fType2)
  40.     ; Reverse the height dim, set index 0 = surface.
  41.     fType1 = fType1(:,::-1)
  42.     fType2 = fType2(:,::-1)

  43.     ; Use array data to store fType1 and fType2.
  44.     ; Note that the vertical resolution of fType2 is twice as long as fType1.
  45.     data = new((/dims1(0), dims1(1)+2*dims2(1)/), integer)
  46.     data(:,0:dims1(1)-1) = fType1
  47.     ; Because NCL draws plot according to the array size rather than coordinate
  48.     ; size, so divide one bin in fType2 into 2 bins.
  49.     do i = 0, dims2(1)-1
  50.         data(:,dims1(1)+2*i) = fType2(:,i)
  51.         data(:,dims1(1)+2*i+1) = fType2(:,i)
  52.     end do

  53.     ; Create altitude.
  54.     ; Height is from -0.5km to 8.2km.
  55.     dz1 = 30.0/1000.0    ; Units is km.
  56.     hgt1 = (ispan(1, 290, 1)-0.5)*dz1 - 0.5

  57.     ; Height2 is from 8.2km to 20.2km.
  58.     dz2 = 60.0/1000.0    ; Units is km.
  59.     hgt2 = (ispan(1, 400, 1)-0.5)*dz1 + 8.2

  60.     hgt = new(690, float)
  61.     hgt(0:289) = hgt1
  62.     hgt(290:689) = hgt2
  63.     hgt@long_name = "Height (km)"
  64.     hgt@units = "km"
  65.    
  66.     ; Create latitude.
  67.     lat@long_name = "Latitude"
  68.     lat@units = "degrees_north"
  69.    
  70.     data!0 = "lat"
  71.     data&lat = lat
  72.     data!1 = "hgt"
  73.     data&hgt = hgt
  74.    
  75.     ; Draw latitude VS height plot.
  76.     picname = "./pic/VFM_v_dust"
  77.     wks = gsn_open_wks("png", picname)
  78.     res = True
  79.     res@gsnDraw = False
  80.     res@gsnFrame = False
  81.     colormap = (/"white", "aliceblue", "lightskyblue", "gold", "red", \
  82.                  "seagreen", "palegreen", "black", "orange4"/)
  83.     levels = (/0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5/)
  84.     lbstring = (/"invalid", "clear air", "cloud", "aerosol", "stratospheric", \
  85.                  "surface", "subsurface", "no signal", "dust"/)

  86.     res@gsnMaximize = True
  87.     res@cnFillOn = True
  88.     res@cnLinesOn = False
  89.     res@cnLineLabelsOn = False
  90.     res@cnFillMode = "RasterFill"
  91.     res@cnMissingValFillColor = 0
  92.     res@cnMissingValFillPattern = 0
  93.     res@cnFillPalette = colormap
  94.     res@cnLevelSelectionMode = "ExplicitLevels"
  95.     res@cnLevels = levels

  96.     res@tmYROn = False
  97.     res@tmXTOn = False
  98.     ; res@tmYLMode = "Explicit"
  99.     ; res@tmYLValues = ispan(0, 20, 5)*1.0
  100.     ; res@tmYLLabels = res@tmYLValues
  101.    
  102.     res@lbLabelAutoStride = True
  103.     res@lbBoxLinesOn = False
  104.     res@lbLabelAlignment = "BoxCenters"
  105.     res@lbLabelStrings = lbstring
  106.     res@lbBoxMinorExtentF = 0.2
  107.     res@lbLabelFontHeightF = 0.009
  108.    
  109.     res@tiMainString = ""
  110.     res@vpWidthF = 0.8
  111.     res@vpHeightF = 0.2
  112.    
  113.     ; Transpose fType so x=lat, y=hgt.
  114.     plot = gsn_csm_contour(wks, transpose(data), res)  

  115.     draw(plot)
  116.     frame(wks)
  117. end
复制代码




TIM截图20190417204413.png
VFM_v_dust.png

评分

参与人数 3金钱 +30 收起 理由
lleoiu + 10
Lizhengpeng + 10 很给力!
Wetter + 10 赞一个!

查看全部评分

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

新浪微博达人勋

发表于 2019-7-20 00:39:03 | 显示全部楼层
写的很赞
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2019-7-26 15:55:21 | 显示全部楼层
请问为什么第19行是1454不是5514呢?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2019-7-26 21:11:01 | 显示全部楼层

请问为什么第19行是1454不是5514呢?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2019-7-31 09:43:19 | 显示全部楼层
meng_xlei 发表于 2019-7-26 21:11
请问为什么第19行是1454不是5514呢?

如图,1165到1454是最左边的一个剖面,5225到5514是最右边的一个剖面。由于CALIPSO的这几个剖面靠得很近,选取一个剖面即可。程序中就选取的最左边的剖面。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2019-7-31 22:33:52 | 显示全部楼层
灭火器 发表于 2019-7-31 09:43
如图,1165到1454是最左边的一个剖面,5225到5514是最右边的一个剖面。由于CALIPSO的这几个剖面靠得很近 ...

哇,学到了,厉害!!!
另外还有一个问题想请教您,用您的程序画了同一轨道、不同纬度范围的两张图,一张范围为35度到42度,另一张范围为42度到48度,但两张图完全相同,这是什么原因呢?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2019-8-1 10:46:29 | 显示全部楼层
谢谢分享,图文并茂
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2019-9-22 21:16:22 | 显示全部楼层
你好,如果想画的是沿卫星轨迹来画的话,用ncl代码应该怎么实现呢?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2019-9-23 08:19:24 | 显示全部楼层
柒HHH 发表于 2019-9-22 21:16
你好,如果想画的是沿卫星轨迹来画的话,用ncl代码应该怎么实现呢?

hdfeos.org/zoo/index_openLaRC_Examples.php#CALIPSO
就照抄这个网址中给出的水平的例子,选取某个高度的bin中的一条ray来画
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2019-12-23 17:13:59 | 显示全部楼层
请教一下,5514表示什么意思?是高度吗?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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