<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Dennis,
<div class=""><br class="">
</div>
<div class="">Thanks. ndtooned is what I thought would work, but I wasn’t sure if the ndtooned would put “Humpty Dumpty” back together again correctly. </div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class="">-Jonathan</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On May 11, 2021, at 2:54 PM, Dennis Shea <<a href="mailto:shea@ucar.edu" class="">shea@ucar.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="">Is this what you want?</div>
<div class=""><br class="">
</div>
<div class="">nlat = dimsizes(lat)<br class="">
mlon = dimsizes(lon)<br class="">
nmdl = dimsizes(model)<br class="">
npct = dimsizes(percentile)<br class="">
nst4 = dimsizes(statfour)<br class="">
ngrd = nlat*mlon<br class="">
percentileStatsT = new((/ngrd,nmdl,npct,nst4/),"double")<br class="">
<br class="">
pST_1d = ndtooned(percentileStatsT)<br class="">
pST_5d = onedtond(pST_1d,(/nlat,mlon,nmdl,npct,nst4/))</div>
<div class="">delete([/percentileStatsT, pST_1d/] ) ; <== only if memory is a problem<br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, May 11, 2021 at 1:36 AM Buzan, Jonathan via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" class="">ncl-talk@mailman.ucar.edu</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi NCL-Talk,<br class="">
<br class="">
My script is taking forever to execute because of loops. <br class="">
I am attempting to remedy this situation by using ndtooned, then executing the commands, followed by rebuilding the array back to nd.<br class="">
<br class="">
In my example below percentileStatsT is an array 4d array that is percentileStatsT(lat*lon,model,percentile,statistics), but I need to convert the lat*lon to lat, lon aka a 5d array:<br class="">
nd_T_percentileStats(lat,lon,model,percentile,statistics)<br class="">
<br class="">
However, I am not sure how to convert lat*lon into lat,lon. Is there a command in ncl that will do this?<br class="">
<br class="">
Cheers,<br class="">
-Jonathan<br class="">
<br class="">
<br class="">
Code snippet:<br class="">
ex.<br class="">
T(time,lat,lon) ;my data of temperatures<br class="">
<br class="">
;;;create new array to store statistics.;;;;;<br class="">
model = ispan(0,0,1) ; this will be the unlimited domain<br class="">
model!0 = "model"<br class="">
model&model = model<br class="">
model@long_name = "model"<br class="">
<br class="">
percentile = ispan(1,99,1)<br class="">
percentile!0 = "percentile"<br class="">
percentile&percentile = percentile<br class="">
percentile@long_name = "percentile"<br class="">
<br class="">
statfour = ispan(0,3,1)<br class="">
statfour!0 = "statfour"<br class="">
statfour&statfour = statfour<br class="">
statfour@long_name = "Mean, SD, Skewness, Kurtosis"<br class="">
<br class="">
percentileStatsT = new((/dimsizes(lat)*dimsizes(lon),dimsizes(model),dimsizes(percentile),dimsizes(statfour)/), "double")<br class="">
<br class="">
<br class="">
;;;;; manipulate data to calculate statistics;;;;;;<br class="">
T_1d = ndtooned(T(lat|:,lon|:,time|:) ; reorder dimensions and convert to 1d <br class="">
<br class="">
;;;;; operate on data;;;;;;;<br class="">
;;;;; breaks;;;;;;;<br class="">
do k = 0, (dimsizes(lat) * dimsizes(lon) -1) <br class="">
index_time_st = dimsizes(time) * k <br class="">
index_time_end = dimsizes(time) * k + (dimsizes(time) -1) <br class="">
onedT = T_1d(index_time_st:index_time_end) <br class="">
workT_Index = dim_pqsort_n(onedT,2,0) <br class="">
manip_T = onedT(workT_Index) ; reorder data from lowest to highest<br class="">
percentile = new((/99/),"integer”) <br class="">
do l = 0, dimsizes(percentile) -1 ; time is 29200 data points. dividing the array into percentiles<br class="">
starti = 292*l + 146<br class="">
endi = 292*(l+1) + 146 -1<br class="">
percentileStatsT(k,:,l,:) = dim_stat4(onedT(starti:endi))<br class="">
end do<br class="">
end do<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank" class="">ncl-talk@mailman.ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>