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/cnmap/cnmap.ncl"
begin
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;input
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PDataSST=addfile("~/data/HadISST_sst.nc","r")
sst=PDataSST->sst
target_month=8
sst!1="lat"
sst!2="lon"
latmin=-30
latmax=40
lonmin=30
lonmax=135
sst_for_eof_1=sst(lat|:,lon|:,time|1307+target_month:1739:12)
sst_for_eof_1_clim=clmMonLLT(sst_for_eof_1)
sst_for_eof_2=calcMonAnomLLT(sst_for_eof_1,sst_for_eof_1_clim)
sst_for_eof_dtrend=dtrend_n(sst_for_eof_2,False,2)
copy_VarCoords(sst_for_eof_1,sst_for_eof_dtrend)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;process
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;pre-process
; =================================================================
; create weights: sqrt(cos(lat)) [or sqrt(gw) ]
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
rad = 4.*atan(1.)/180.
clat = PDataSST->latitude
clat = sqrt( cos(rad*clat) ) ; gw for gaussian grid
clat!0 = "lat"
sst_for_eof_dtrend_weighted = sst_for_eof_dtrend ; copy meta data
sst_for_eof_dtrend_weighted = sst_for_eof_dtrend*conform(sst_for_eof_dtrend, clat, 0)
;sst_for_eof_dtrend_weighted@long_name = "Wgt: "+sst_for_eof_dtrend_weighted@long_name
sst_for_eof=sst_for_eof_dtrend_weighted({lat|latmin:latmax},{lon|lonmin:lonmax},time|:)
neof=3
optEOF=True
;optEOF@jopt=1
sst_eof_v=eofunc_Wrap(sst_for_eof,neof,optEOF)
sst_eof_ts=eofunc_ts_Wrap(sst_for_eof,sst_eof_v,False)
printVarSummary(sst_eof_v)
printVarSummary(sst_eof_ts)
asciiwrite("eof_ts_1_"+target_month+".txt",sst_eof_ts(0,:))
stddev_eof_ts_1=dim_stddev_Wrap(sst_eof_ts(0,:))
print(stddev_eof_ts_1)
sst_rebuild_1=sst_eof_v*stddev_eof_ts_1*2.5
copy_VarCoords(sst_eof_v,sst_rebuild_1)
sst_rebuild=sst_rebuild_1(0,:,:)
printVarSummary(sst_rebuild)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;resourse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
res=True
res@gsnFrame=False
res@gsnDraw=False
res@gsnAddCyclic = False ; data not cyclic
res@gsnSpreadColors = True
;res@gsnSpreadColorStart=-1
;res@gsnSpreadColorEnd=2
res@cnFillOn=True
res@cnLinesOn=False
res@cnLineLabelsOn=False
res@cnLevelSelectionMode="ExplicitLevels"
res@cnLevels=fspan(-0.8,0.8,17)
res@mpMinLatF = latmin
res@mpMaxLatF = latmax
res@mpMinLonF = lonmin
res@mpMaxLonF = lonmax
res@mpDataSetName = "Earth..4" ; This new database contains
res@mpDataBaseVersion = "MediumRes" ; Medium resolution database
res@mpOutlineOn = True ; Turn on map outlines
res@mpOutlineSpecifiers = (/"China:states","Taiwan"/) ;China:states
res@gsnLeftString=""
res@lbLabelBarOn=True
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;plot
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
wks=gsn_open_wks("png",get_script_prefix_name+"_"+target_month)
;gsn_define_colormap(wks,"matlab_jet")
res@gsnRightString = sprintf("%5.1f", sst_eof_v@pcvar(0)) +"%"
;plot=gsn_csm_contour_map(wks,sst_eof_v(0,:,:),res)
plot=gsn_csm_contour_map(wks,sst_rebuild,res)
draw(plot)
frame(wks)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;add to amip clm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PInputData=addfile("./amip2_sst.data.climo.nc","r")
;system ("rm -f "+"~/FAMIL/exp/iobm/input/ocn/sst/amip2_sst.data.climo.nc")
;POutputData=addfile("~/FAMIL/exp/iobm/input/ocn/sst/amip2_sst.data.climo.nc","c")
system ("rm -f "+"./amip2_sst.data.climo.nc")
POutputData=addfile("./amip2_sst.data.climo.nc","c")
;weights matrix
weight_dim=dimsizes(sst_rebuild)
weight=new(weight_dim,float)
weight=0
bond_wid=5
do i=1,bond_wid
weight(i:weight_dim(0)-i,i:weight_dim(1)-i)=weight(i:weight_dim(0)-i,i:weight_dim(1)-i)+1./bond_wid
end do
copy_VarCoords(sst_rebuild,weight)
sst_rebuild=sst_rebuild*weight
sst_mod=short2flt(PInputData->sst)
printVarSummary(sst_mod(time|:,{lat|latmin:latmax},{lon|lonmin:lonmax}))
sst_mod(time|target_month-1,{lat|latmin:latmax},{lon|lonmin:lonmax})=sst_mod(time|target_month-1,{lat|latmin:latmax},{lon|lonmin:lonmax})+sst_rebuild
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;output
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dim_names = (/"time","lat","lon"/)
;time dimension is unlimited, but currently set to 1.
dim_sizes = dimsizes(sst)
dim_unlimited = (/True,False,False/)
print("Defining dimension sizes to be " + dim_sizes)
filedimdef(POutputData,dim_names,dim_sizes,dim_unlimited)
att_names = getvaratts(PInputData) ; get CCM file's global attributes
if(.not.all(ismissing(att_names))) then
do i = 0,dimsizes(att_names)-1
print("copy_fileatts: global attributes->" + att_names(i))
POutputData@$att_names(i)$ = PInputData@$att_names(i)$ ; copy CCM file's global att ributes
end do
end if
names = getfilevarnames(PInputData) ; get CCM file's variable names and print them
print (names)
;
; loop over variables and copy to netCDF file
;
do i=0, 2
print("writing POutputData: i,name="+ i+ " "+ names(i))
POutputData->$names(i)$ = PInputData->$names(i)$
end do
POutputData->sst= sst_mod
do i=4, dimsizes(names)-1
print("writing POutputData: i,name="+ i+ " "+ names(i))
POutputData->$names(i)$ = PInputData->$names(i)$
end do
print (POutputData) ; print overview of contents of netCDF file
end
modify sst; read and write as it is
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)史汗,“玉大人琼掠,你說(shuō)我怎么就攤上這事⊥W玻” “怎么了瓷蛙?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我速挑,道長(zhǎng),這世上最難降的妖魔是什么副硅? 我笑而不...
- 正文 為了忘掉前任姥宝,我火速辦了婚禮,結(jié)果婚禮上恐疲,老公的妹妹穿的比我還像新娘腊满。我一直安慰自己,他們只是感情好培己,可當(dāng)我...
- 文/花漫 我一把揭開(kāi)白布碳蛋。 她就那樣靜靜地躺著,像睡著了一般省咨。 火紅的嫁衣襯著肌膚如雪肃弟。 梳的紋絲不亂的頭發(fā)上,一...
- 那天零蓉,我揣著相機(jī)與錄音笤受,去河邊找鬼。 笑死敌蜂,一個(gè)胖子當(dāng)著我的面吹牛箩兽,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播章喉,決...
- 文/蒼蘭香墨 我猛地睜開(kāi)眼汗贫,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了秸脱?” 一聲冷哼從身側(cè)響起落包,我...
- 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎撞反,沒(méi)想到半個(gè)月后妥色,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡遏片,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年嘹害,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片吮便。...
- 正文 年R本政府宣布,位于F島的核電站微渠,受9級(jí)特大地震影響搭幻,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜逞盆,卻給世界環(huán)境...
- 文/蒙蒙 一檀蹋、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧云芦,春花似錦俯逾、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至琉历,卻和暖如春坠七,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背善已。 一陣腳步聲響...
- 正文 我出身青樓悉稠,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親艘包。 傳聞我的和親對(duì)象是個(gè)殘疾皇子的猛,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- Day 12 神句文檔 The team contends that these bear more than a...
- There Is a Lady Sweet and Kind有一位女郎甜美和善 There is a lady s...
- EventBus 學(xué)習(xí) 官方網(wǎng)址:http://greenrobot.org/eventbus/ Github網(wǎng)址...
- 天亮了卦尊,唯安才意識(shí)到自己一夜沒(méi)睡。 他搖頭舌厨,想甩掉腦海里那些亂七八糟的想法岂却。 不知過(guò)了多久,他睜開(kāi)眼裙椭,那個(gè)念頭變得...