The coding is confusing.
Is the objective:
For each file, regress y (lat of max values)
onto x (lon of max values)?
--- If so, maybe the attached is what you want. On 11/20/13 7:50 AM, Melissa Lazenby wrote: > Hi All > > I have managed to get my regression line program to print out many outputs, however they are all the same values and I want them to be outputs from the individual files in the folder therefore they should be different. I must be doing something wrong with my loops. > If anyone can help, I would really appreciate it! > 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 in Precip Data. > ;************************************************ > ;diri = "/mnt/nfs2/geog/ml382/melphd/eofmodelz/ACCESS1-0/" ; input directory > ;fili = "/pr_Amon_ACCESS1-0_historical_safrica_1950_climDJF.nc" ; data > > ;=================================================; > ; Read all file names in directory > ;=================================================; > diri = "/mnt/nfs2/geog/ml382/melphd/eofmodelz/ACCESS1-0/" ; 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") > pr = f->pr(0,0,:,:) > lat = f->lat ; get lat > 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 > ;************************************************************** > > dimpr = dimsizes(pr) > nlat = dimpr(0) > mlon = dimpr(1) > > prMaxLon = new ( mlon, typeof(pr), pr@_FillValue) > > do nf=0,nfili-1 > f = addfile(diri+fili(nf), "r") > pr = f->pr(0,0,:,:) > lat = f->lat ; get lat > do ml=0,mlon-1 > imax = maxind(pr(:,ml)) > prMaxLon(ml) = dble2flt(lat(imax)) > end do > end do > > ;print(prMaxLon) > ;print(pr&lon) > > ;print("-------------------------------") > ;print("prMaxLon: "+pr&lon+" "+prMaxLon) > > ;Regression Line > > rcMaxLon = regline(pr&lon,prMaxLon) > > do nf=0,nfili-1 > f = addfile(diri+fili(nf), "r") > pr = f->pr(0,0,:,:) > lat = f->lat > print(rcMaxLon) > end do > > ;print(rcMaxLon@yave) > > bMaxLon = rcMaxLon@yintercept > ;print(bMaxLon) > > xMaxLon = pr&lon > ;print(xMaxLon) > yMaxLon = rcMaxLon*pr&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 >
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2.1.8 : Fri Nov 22 2013 - 09:36:32 MST