[ncl-talk] Lopping procedure

Sri nandini bax8609 at uni-hamburg.de
Wed Aug 19 02:54:45 MDT 2020


Hello dear ncl users

I had a question on proper looping procedure for my method below.

I have 3 datasets of different dimensions and i wish to loop them over.

a) Original Hist data ==>hist_anom [time,nens,lat,lon] ==>Sea surface 
elevation (m) : min=1.05246   max=5.27844

b) Trend data ==>pi_trend [lat,lon]

c) csv file ==> [100] ;contains 100 different start years

I want to correct each ensemble member by subtracting pi_trend from each 
ensemble member start year.for e.g. take member #50, it is initialized 
with the control state at year 3140 while member #1 at control year 1898.
    ;To correct #50 you multiply the 1242 yrs difference with the 
pi_trend and subtract this from #50
    ;a) corrected data #50=original data #50 -(pi_trend * (3140 - 1898)) 
;I want to subtract all start years with the #1 start year which is 1898

My looping code is here:

    pi_trend==>min=0.0308835   max=0.0309578 [lat,lon]

    nens= 100

    PI_trend_yrs = pi_trend
    do n=0,nens-1
    PI_trend_yrs = (ens_yrs(n)-1898)*pi_trend
    end do
    PI_trend_yrs at long_name = "PI_trend_yrs"
    printMinMax( PI_trend_yrs ,True)    ===>PI_trend_yrs (m/year) 
[lat,lon]: min=50.0313   max=50.1516
    printVarSummary(PI_trend_yrs)

    ;Here the Hist data is trend corrected for each ensemble over lat 
and lon gridpoints.
    hist_avg=dim_avg_n_Wrap(hist_anom,0)
    printMinMax(hist_avg ,True)
    printVarSummary(hist_avg)

    hist_ens_trend=hist_avg
    do n=0,nens-1
    ;do nt=0, ntim-1
    hist_ens_trend(n,:,:) = hist_avg(n,:,:) - PI_trend_yrs
     ;end do
    end do
    hist_ens_trend at long_name = "hist_ens_trend"
    printMinMax(hist_ens_trend ,True)  ===>hist_ens_trend (m) 
[nens,lat,lon]: min=-48.8754   max=-45.2733
    printVarSummary(hist_ens_trend)

There is no error but the numbers i get in the are simply too large 
because of a mistake in my above loop because in the end i want to use 
my original data which is in the format of [time,nens,lat,lon].

Can someone please help me understand this?

Sri




More information about the ncl-talk mailing list