爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4574|回复: 3

linint_Wrap缺测值

[复制链接]

新浪微博达人勋

发表于 2017-7-27 10:10:17 | 显示全部楼层 |阅读模式

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

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

x
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/csm/shea_util.ncl"
begin
        f = addfile("/home/zkf/paper/Gt/data/sst_new.nc","r")
        sst  = f->sst
        time = f->time
        lat  = f->latitude({-90:90})
        lon  = f->longitude({-180:180})
        
        sst!0 = "time"
        sst!1 = "lat"
        sst!2 = "lon"
        sst&time = time
        sst&lat  = lat
        sst&lon  = lon
        ;print(sst&lon)
        ;printVarSummary(sst)     
;************************************************
; interpolate to new grid
;***********************************************
    newlat = fspan(-90.,90.,180)
    newlon = fspan(0.,360.,360)
    newlat@units = "degrees_north"
    newlon@units = "degrees_east"
         
    newsst = linint2_Wrap(lon,lat,sst,True,newlon,newlat,0)
   
    newsst!1   ="lat"   
    newsst!2   ="lon"
    newsst&lat = newlat
    newsst&lon = newlon
以上是我的脚本代码
然后图是:

                               
登录/注册后可看大图

只有东经才出现图,且也有缺测值,但西经就全是。
麻烦各路大神请教

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

新浪微博达人勋

 楼主| 发表于 2017-7-27 10:38:52 | 显示全部楼层
file:///home/zkf/paper/Gt/plot/ave.ps
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-27 16:41:53 | 显示全部楼层
我看不到图。但按你的描述,你的原始数据是-180到180的,但 newlon 是0到360的。可以试试都弄成 -180到180的吧。
做完插值后,假如你真的想要 0 到360 那样的。可以看看 函数lonFlip (https://www.ncl.ucar.edu/Document/Functions/Contributed/lonFlip.shtml)能不能帮你。注意这个函数0和360不能同时重复出现,比如 fspan(-180.,179.,360)
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-7-28 10:49:01 | 显示全部楼层
packard 发表于 2017-7-27 16:41
我看不到图。但按你的描述,你的原始数据是-180到180的,但 newlon 是0到360的。可以试试都弄成 -180到180 ...

嗯嗯,十分感谢,昨天还一直想着有没有这样的函数,结果我是用较笨的方法对它进行转换;
脚本如下:
;数据的转换,传统方式(复杂:将元数据保留)
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/csm/shea_util.ncl"
begin
        f = addfile("/home/zkf/paper/Gt/data/sst_new.nc","r")
        sst  = f->sst
        time = f->time
        lat  = f->latitude
        lon  = f->longitude
        
        sst!0 = "time"
        sst!1 = "lat"
        sst!2 = "lon"
        sst&time = time
        sst&lat  = lat
        sst&lon  = lon
        
;************************************************
; interpolate to new grid
;***********************************************
        mtime = dimsizes(time)
        mlat = dimsizes(lat)
        mlon = dimsizes(lon)
        
        array = new((/mtime,mlat,mlon/),float)
        xlon = fspan(0.5,359.5,360)
        copy_VarMeta(lon,xlon)
        array(:,:,0:(mlon/2-1)) = sst(:,:,(mlon/2):(mlon-1))
        array(:,:,(mlon/2):(mlon-1)) = sst(:,:,0:(mlon/2-1))
        
        array!0 = "TIME"
        array!1 = "LAT"
        array!2 = "LON"
        array&TIME = time
        array&LAT = lat
        array&LON = xlon


        fout = addfile("/home/zkf/paper/Gt/data/sst.nc","c")
        fout->SST = array
               
end
不过这个脚本也让我对数组更加熟悉一点。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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