爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 9998|回复: 6

用站点降水资料画图,提示数据有误

[复制链接]

新浪微博达人勋

发表于 2014-7-14 16:58:53 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图: -
问题概况: 想用NCL画站点降水图然后与WRF画出来的降水作对比,但是提示读入的站点数据有误,
我看过提问的智慧: 看过
自己思考时长(天): 2

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

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

x
本帖最后由 黄小仙儿 于 2014-7-14 17:03 编辑

想用NCL画站点降水图然后与WRF画出来的降水作panel图对比,但是提示读入的站点数据有误,请大神帮忙看看
提示错误:

warning:stringtofloat: a bad value was passed; input strings must contain numerc digits, replacing with missing value
warning:stringtofloat: a bad value was passed; input strings must contain numerc digits, replacing with missing value
warning:stringtofloat: a bad value was passed; input strings must contain numerc digits, replacing with missing value
warning:stringtofloat: a bad value was passed; input strings must contain numerc digits, replacing with missing value
warning:stringtofloat: a bad value was passed; input strings must contain numerc digits, replacing with missing value
(0)     icObjAnal: all input data are missing
fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading X
fatal:["Execute.c":8567]:Execute: Error occurred at or near line 12232 in file  NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl

fatal:["Execute.c":8567]:Execute: Error occurred at or near line 66 in file /hoe/Huanglei/station_1.ncl

我的脚本如下:
; This example reads in station data represented by
; 1D arrays, and generates a filled contour plot
; via the triangular mesh capability in NCL.
;
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
;
; Data is stored in four columns:  station_name  lat  lon  pwv
; Read in each line as a string, and use "str_get_field" to
; read in the fields of interest.
;
  fname = "/home/Huanglei/data/rainstation.txt"
  lines = asciiread(fname,-1,"string")

;
; Use "str_get_field" to indicate which fields to read in. Each field
; is separated by spaces.
;
  lat = stringtofloat(str_get_field(lines(1:),2," "))
  lon = stringtofloat(str_get_field(lines(1:),3," "))
  pwv = stringtofloat(str_get_field(lines(1:),4," "))
  rain = stringtofloat(str_get_field(lines(1:),5," "))
;
; This second file is not so tricky.  The 2D lat/lon data is sorted with
; lat values first, and then lon values.
;
  olon = new(66,"float");
  olat = new(40,"float");
  data1 = new((/40,66/),"float")
  do i=0,65
     olon(i) =72+i
  end do
  do l=0,39
     olat(l) = 17+l
  end do

     olon!0          = "lon"
     olon@long_name  = "lon"
     olon@units      = "degrees-east"
     olon&lon        = olon
     olat!0          = "lat"
     olat@long_name  = "lat"
     olat@units      = "degrees_north"
     olat&lat        = olat

  rain@_FillValue = 999999.000000  
  rscan = (/10,5,3/)   ;连续的有效半径大小,最大为10,依次递减
  data1 = obj_anal_ic_deprecated(lon,lat,rain,olon,olat,rscan, False)  ;Creanm插值


a=addfile("/home/Huanglei/data/d032"+".nc","r")


times=wrf_user_getvar(a,"times",-1)
ntime=dimsizes(times)
rainnc1= wrf_user_getvar(a,"RAINNC",35)
rainc1 = wrf_user_getvar(a,"RAINC",35)
rain1 = rainnc1 + rainc1
rainnc2= wrf_user_getvar(a,"RAINNC",ntime-1)
rainc2 = wrf_user_getvar(a,"RAINC",ntime-1)
rain2 = rainnc2 + rainc2
rain=rain2-rain1
lat2=wrf_user_getvar(a,"XLAT",-1)
lon2=wrf_user_getvar(a,"XLONG",-1)
rain@lat2d=lat2(1,:,:)
rain@lon2d=lon2(1,:,:)




  wks = gsn_open_wks("ps","station")
gsn_define_colormap(wks, "cmp_haxby")  
res=True
res@gsnSpreadColors      = True         ; spread out color table
res@cnFillOn = True            ; turn on color
res@cnLinesOn = False   
res@lbLabelBarOn        = False
res@cnInfoLabelOn       = False
res@cnLineLabelsOn      = False

res@mpPerimOn   = True
res@gsnMaximize=True
res@pmTickMarkDisplayMode   = "Always"
res@gsnDraw   = False        ; don't draw yet
res@gsnFrame  = False
res@mpGeophysicalLineColor = "Black"
res@mpNationalLineColor    = "Black"
res@mpDataSetName         = "Earth..4"
res@mpDataBaseVersion     = "MediumRes"
res@mpOutlineSpecifiers = ("China:states")
res@mpNationalLineThicknessF= 0.1
res@mpOutlineDrawOrder    = "PostDraw"
res@mpLimitMode = "LatLon"    ; Limit the map view.
res@mpMinLonF   = min(lon2)
res@mpMaxLonF   = max(lon2)
res@mpMinLatF   = min(lat2)
res@mpMaxLatF   = max(lat2)
res1=res
res2=res
res1@gsnLeftString = "(a):WRF"
res1@gsnRightString = ""
res1@sfXCStartV = min(lon2)   ; Define where contour
res1@sfXCEndV   = max(lon2)
res1@sfYCStartV = min(lat2)
res1@sfYCEndV   = max(lat2)
res2@gsnLeftString = "(b):OBS"
res2@gsnRightString = ""
resP                     = True         ; modify the panel plot
resP@gsnMaximize         = False
resP@gsnPanelLabelBar    = True
resP@pmLabelBarWidthF   = 0.8
resP@lbLabelFontHeightF = 0.01
resP@lbBoxLinesOn           = False
resP@lbTitleOn        =  True                ; turn on title
resP@lbTitleString    = "mm"
;resP@lbTitlePosition  = "Right"              ; title position
resP@lbTitleFontHeightF= .015                ; make title smaller
;resP@lbTitleDirection = "Across"
plot=new(2,graphic)
plot(0)=gsn_csm_contour_map(wks,rain,res1)
plot(1)=gsn_csm_contour_map(wks,data1,res2)

gsn_panel(wks,plot,(/1,2/),resP)
end

我的数据是这样排列的(站号,纬度,经度,海拔高度,累积降水量),截取了一部分如下:
57206        32.43        105.85        513.8        97.8
57204        32.58        105.23        800.5        95.5
57217        32.23        106.28        485.7        11.1
57208        32.02        105.48        536.1        144.9
57303        31.73        105.92        459.9        28.1
56196        31.47        104.68        522.7        58.9
56193        32.42        104.52        893.2        18.4
56194        31.78        104.43        678.9        84.5

请大家帮忙看看,实在是当局者迷。

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

新浪微博达人勋

发表于 2014-7-14 17:40:12 | 显示全部楼层
黄小仙儿 发表于 2014-7-14 17:29
多谢多谢,好人呐~

数据有两个问题:
1. 末尾有多行空行,删除掉;
2. 分割符不是空格,而是tab。

  delim = str_get_tab()
  lat = stringtofloat(str_get_field(lines(1:),2,delim))
  lon = stringtofloat(str_get_field(lines(1:),3,delim))
  pwv = stringtofloat(str_get_field(lines(1:),4,delim))
  rain = stringtofloat(str_get_field(lines(1:),5,delim))
密码修改失败请联系微信:mofangbao
回复 支持 2 反对 0

使用道具 举报

新浪微博达人勋

发表于 2014-7-14 17:27:48 | 显示全部楼层
黄小仙儿 发表于 2014-7-14 17:26
又检查了一遍,还是没有发现我的数据有什么不对

呵呵,把数据以附件形式发上来,我帮你查!
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2014-7-14 17:20:56 | 显示全部楼层
先检查下数据吧!warning说明,数据里面有非数字字符。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-7-14 17:26:08 | 显示全部楼层
longlivehj 发表于 2014-7-14 17:20
先检查下数据吧!warning说明,数据里面有非数字字符。

又检查了一遍,还是没有发现我的数据有什么不对
QQ图片20140714172445.jpg
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-7-14 17:29:40 | 显示全部楼层
longlivehj 发表于 2014-7-14 17:27
呵呵,把数据以附件形式发上来,我帮你查!

多谢多谢,好人呐~

rainstation.txt

4.59 KB, 下载次数: 155

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

新浪微博达人勋

 楼主| 发表于 2014-7-14 17:55:10 | 显示全部楼层
longlivehj 发表于 2014-7-14 17:40
数据有两个问题:
1. 末尾有多行空行,删除掉;
2. 分割符不是空格,而是tab。

哇,多谢大神~
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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