Hi All
I am trying to find an effective and efficient way to do the same regline analysis on 44 CMIP5 models for 55 years each. I want to just print the output of the regline (slope and latitude) for each model for each year and am battling with the code as it keeps saying there is an error with my loop
"Dimension sizes of left hand side and right hand side of assignment do not match"
My code is attached below and any help with these do loops would be greatly appreciated.
Many thanks!
Kind Regards
Melissa
;*************************************************
; regline.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"
begin
;=================================================;
; Read all file names in directory
;=================================================;
diri = "/mnt/nfs2/geog/ml382/melphd/eofmodelz/" ; input directory
fili = systemfunc("cd "+diri+" ; ls *climDJF.nc")
print(fili) ; all file names
nfili = dimsizes(fili)
print(nfili)
;=================================================;
; Establish list of all possible files; *no* reading is done
; 'f' is a variable of type 'list'; index via [...]
;=================================================;
do nf=0,nfili-1
f = addfile(diri+fili(nf), "r")
x = f->pr
end do
;f = addfile (fili , "r") ; add file
;lat = f->lat ; get lat
;lon = f->lon ; get lon
;time = f->time ; get time
;level = f->z ; get level
;pr = f->pr ; get precip
;printVarSummary(pr)
pr2 = pr(time|0, z|0, {lat|-30:0}, {lon|10:50})
printVarSummary(pr2)
;*************************************************************
;Calculations of max precip for lat and lon values
;**************************************************************
dimpr2 = dimsizes(pr2)
nlat = dimpr2(0)
mlon = dimpr2(1)
pr2MaxLon = new ( mlon, typeof(pr2), pr2@_FillValue)
do ml=0,mlon-1
imax = maxind(pr2(:,ml))
pr2MaxLon(ml) = dble2flt(lat(imax))
end do
;print(pr2MaxLon)
;print(pr2&lon)
;print("-------------------------------")
;print("pr2MaxLon: "+pr2&lon+" "+pr2MaxLon)
;Regression Line
rcMaxLon = regline(pr2&lon,pr2MaxLon)
print(rcMaxLon)
;print(rcMaxLon@yave)
bMaxLon = rcMaxLon@yintercept
;print(bMaxLon)
xMaxLon = pr2&lon
;print(xMaxLon)
yMaxLon = rcMaxLon*pr2&lon + bMaxLon
;print(yMaxLon)
;print("-------------------------------")
;print(xMaxLon+" "+yMaxLon)
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 20 06:57:00 2013
This archive was generated by hypermail 2.1.8 : Fri Nov 22 2013 - 09:36:32 MST