爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 47430|回复: 24

[其他] [求助]【已解决】NCL地图坐标设置问题

[复制链接]

新浪微博达人勋

发表于 2016-3-30 15:13:00 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 xuebiz 于 2016-6-7 16:42 编辑

数据文件问nc格式,其中经纬度定义如下:
    lat = 361 ;
    lon = 723 ;

    float lat(lat) ;
        lat:units = "degrees_north" ;
    float lon(lon) ;
        lon:units = "degrees_east" ;

lat = -89.75, -89.25, -88.75, -88.25, -87.75, -87.25, -86.75, -86.25,
    ......
    87.25, 87.75, 88.25, 88.75, 89.25, 89.75, 90.25 ;

lon = 0.25, 0.75, 1.25, 1.75, 2.25, 2.75, 3.25, 3.75, 4.25, 4.75, 5.25,
    ......
    357.75, 358.25, 358.75, 359.25, 359.75, 360.25, 360.75, 361.25 ;

NCL画图的时候,总是提示:
(0)    check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all.
(0)    A valid latitude coordinate array should have a 'units' attribute equal to one of the following values:
(0)        'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0)    check_for_lon_coord: Warning: Data either does not contain a valid longitude coordinate array or doesn't contain one at all.
(0)    A valid longitude coordinate array should have a 'units' attribute equal to one of the following values:
(0)        'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'

我把经纬度最后4个值切掉了也不行,画出来的图经纬度有偏差,WHY?
  lon = fc->lon(0:718)
  lat = fc->lat(0:356)




错位图WHY

错位图WHY
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-11-12 21:48:13 | 显示全部楼层
遇到了相同的问题,与楼主解决方式不同,最后发现是因为我在画等值线的函数中直接把变量乘了1000(单位转换),进行计算后属性会消失,与我类似情况的可以作为参考检查下,找问题找不到的感觉着实难受。
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2016-3-30 19:45:11 | 显示全部楼层
这些行没有意义
  lon = fc->lon(0:718)
  lon@units = "degrees_north"
  lat = fc->lat(0:356)
  lat@units = "degrees_east"

下面改掉这些行  temp@_FillValue = temp@missing_value
  Tarr = temp * temp@scale_factor   



  temp = short2flt(temp)



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

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2016-3-30 15:25:56 | 显示全部楼层
前面读入数据文件省略......

lon = fc->lon(0:718)
  lon@units = "degrees_north"
  lat = fc->lat(0:356)
  lat@units = "degrees_east"
   
  temp = fc->tz_h(0,0,0:356,0:718)
  temp@_FillValue = temp@missing_value
  Tarr = temp * temp@scale_factor   

  res@mpMinLonF = 0.
  res@mpMaxLonF = 360.
  res@mpMinLatF = -90.
  res@mpMaxLatF = 90.
  res@mpCenterLonF = 180.

  res@gsnMaximize = True                        ; maximize plot in frame
  res@mpFillOn    = False                       ; turn map fill off
  res@mpOutlineOn = True                        ; turn the map outline on
  res@cnFillOn    = True                        ; turn on color fill
  res@cnLinesOn   = False                       ; turn off the contour lines
  res@cnLineLabelsOn = False                    ; turn the line labels off

; plot = gsn_csm_contour_map_ce(wks,Tarr,res)   

plot = gsn_csm_contour_map(wks, Tarr, res)


新手,代码是拼凑的

2个plot效果是一样一样的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-3-30 16:46:58 | 显示全部楼层
lat = 361 ; lon = 723 ;
有那么多格点吗?  经度和纬度的个数弄错了。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-4-1 09:28:35 | 显示全部楼层
本帖最后由 xuebiz 于 2016-4-1 09:32 编辑

经纬度,就是那么多,唉,手欠挑错了demo数据,等我换个小范围数据试试手

就是因为经纬度太多,而且出现了lat=90.25 lon=360.25, 360.75, 361.25 的情况,我才想lon、lat不取最后几个值避开。。。

----------------------------------------------------------------------------------------------------------------------------------------
fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:["Execute.c":8567]:Execute: Error occurred at or near line 13 in file test.ncl

line13就是:  temp = short2flt(temp)
nc文件里确实是定义的    short
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-4-1 10:11:16 | 显示全部楼层
本帖最后由 xuebiz 于 2016-4-1 10:13 编辑

  res@mpMinLonF = 0.
  res@mpMaxLonF = 360.
  res@mpMinLatF = -90.
  res@mpMaxLatF = 90.
  res@mpCenterLonF = 180.

  res@gsnMaximize = True                        ; maximize plot in frame
  res@mpFillOn    = False                       ; turn map fill off
  res@mpOutlineOn = True                        ; turn the map outline on

plot = gsn_csm_contour_map(wks, Tarr, res)
-------------------------------------------------------------------------------------------------------
换了另外一个区域其他数据,
发现上面那一些是相关的,画全球海陆的黑线用的,
都屏蔽掉用下面一句就ok:
plot = gsn_contour(wks,Tarr,res)
但是他给我画了个正方形的图,正方的... xy轴按变量个数标的...为么不给矩形的...

-------------------------------------------------------------------------------------------------------
找个适合自己数据的参数很重要啊,比如:
plot = gsn_
res@{:eb328:}
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-4-1 11:49:41 | 显示全部楼层
本帖最后由 xuebiz 于 2016-4-1 12:30 编辑

有进步了,颜色看着就比之前的正确,哈哈,但是地图还是没匹配起来,WHY?

plot = gsn_csm_contour_map_ce(wks,Tarr,res)   
plot = gsn_csm_contour_map(wks, Tarr, res)
这2个plot一样的效果

plot = gsn_contour(wks,Tarr,res)
这个plot就是XY按个数的正方形图,正方形...

报错依旧:怎么破
(0)    check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all.
(0)    A valid latitude coordinate array should have a 'units' attribute equal to one of the following values:
(0)        'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0)    check_for_lon_coord: Warning: Data either does not contain a valid longitude coordinate array or doesn't contain one at all.
(0)    A valid longitude coordinate array should have a 'units' attribute equal to one of the following values:
(0)        'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'

-------------------------------------------------------------------

  temp = fc->tz_h(0,0,:,:)
  Tarr = temp * temp@scale_factor   

;---------------------------------------
  res = True
  res@mpCenterLonF = 180.      

  res@cnFillOn    = True                        ; turn on color fill
  res@cnLinesOn   = False                       ; turn off the contour lines
res@cnLineLabelsOn = False                    ; turn the line labels off

; plot = gsn_csm_contour_map_ce(wks,Tarr,res)   
  plot = gsn_csm_contour_map(wks, Tarr, res)
;  plot = gsn_contour(wks,Tarr,res)
temp-ce.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-4-1 15:23:17 | 显示全部楼层
风子 发表于 2016-3-30 19:45
这些行没有意义
  lon = fc->lon(0:718)
  lon@units = "degrees_north"

如果加上  temp = short2flt(temp),就会报错:
fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:["Execute.c":8567]:Execute: Error occurred at or near line 13 in file test.ncl

line13就是:  temp = short2flt(temp)
nc文件里确实是定义的    short
---------------------------------------------------------
如果用temp = short2flt(f->temp(0,0,:,:)),就会报错,画图显示没有数据:
warning:Attempt to reference attribute (scale_factor) which is undefined
warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]
warning:mpCenterLonF is not a valid resource in pngfilename at this time

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

新浪微博达人勋

 楼主| 发表于 2016-4-1 15:23:24 | 显示全部楼层
本帖最后由 xuebiz 于 2016-4-1 15:26 编辑
风子 发表于 2016-3-30 19:45
这些行没有意义
  lon = fc->lon(0:718)
  lon@units = "degrees_north"

如果加上  temp = short2flt(temp),就会报错:
fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:["Execute.c":8567]:Execute: Error occurred at or near line 13 in file test.ncl

line13就是:  temp = short2flt(temp)
nc文件里确实是定义的    short
---------------------------------------------------------
如果用temp = short2flt(f->temp(0,0,:,:)),就会报错属性找不到,画图显示没有数据:
warning:Attempt to reference attribute (scale_factor) which is undefined
warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]
warning:mpCenterLonF is not a valid resource in pngfilename at this time

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

新浪微博达人勋

发表于 2016-4-1 23:26:52 | 显示全部楼层
xuebiz 发表于 2016-4-1 11:49
有进步了,颜色看着就比之前的正确,哈哈,但是地图还是没匹配起来,WHY?

plot = gsn_csm_co ...

我说错了
  1. temp := short2flt(temp)

  2. ;或者
  3.   temp = short2flt(fc->tz_h(0,0,0:356,0:718))
复制代码
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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