NCL多文件读写+单位改变+得出nino3.4

NCL多文件读写+单位改变+得出nino3.4


(注:本文仅为个人笔记)

多文件读写

fns = systemfunc(“ls /data/ACCESS_rlilp1_1/rcp45_???.nc”)
infile = addfiles(fns,“r”)
ListSetType(infile,“cat”) ;将所有年份rcp45资料整合到一个文件,维度不变
st = infile[:]->tos ;将整合好的文件中tos输出为st

单位改变

sst = st - 273.15 ;将K转变为C

sst!0 = “time” ;when doing simple calculation, build an array
sst&time = st&time
sst!1 = “lat”
sst&lat = st&latitude
sst!2 = “lon”
sst&lon = st&longitude

sst@units = “C”
sst@long_name = “sea surface temperature[C]”

Nino3.4

latS = -70.0
latN = 70.0
lonL = 30.0
lonR = 290.0
yrStrt = 2006
yrLast = 2100
yrClimStrt = 2010
yrClimLast = 2030
time = infile[:]->time
lat = infile[:]->latitude
lon = infile[:]->longitude

utc_date = cd_calendar(time,0)
YYYY = tointeger(utc_date(:,0))
istime = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
cltime = ind(YYYY.ge.yrClimStrt .and. YYYY.le.yrClimLast)

sst_selc = sst(istime , {latS:latN} , {lonL:lonR})
sst_clm = sst(cltime , {latS:latN} , {lonL:lonR})

sstClm = clmMonTLL(sst_clm) ;calculate monthly anomaly
ssta = calcMonAnomTLL (sst_selc, sstClm)
copy_VarCoords(sst_selc,ssta) ;copy coodinate to ssta

nino34 = dim_avg_n_Wrap(ssta(:,{-5:5},{190:240}),(/1,2/))
nino34_3 = runave(nino34,3,0)

存入txt

title = [/“nino34”,“nino34_3”/]
alist = [/nino34,nino34_3/]
write_table("/home/ACCESS1-3.txt",“w”,title,"%s,%s")
write_table("/home/ACCESS1-3.txt",“a”,title,"%8.4f,%8.4f")

猜你喜欢

转载自blog.csdn.net/rainbow_hahaha/article/details/106993645
3.4