[ncl-talk] Advice on extracting point locations from array

Will Hobbs will.hobbs at utas.edu.au
Mon Oct 15 23:52:55 MDT 2018


Hi all

This one is for the NCL ‘Brains Trust’. I’m extracting a large number of ocean profiles from a 4-d array (dimensioned time,depth,lat,lon), using coordinate triplets based on time,lat and lon, (i.e. a 2-d array of indices dimensioned nprofile, 3),  but it’s a slow process and I wonder if anyone has any smart ideas on speeding it up.

At the moment (partly to manage memory), I’m reading each profile in a loop, viz:


Tprof = new((/nlev,nprofile/),float)
do i = 0, nprofile-1
     Tprof(:,i) = fi->T(pInd(i,0),:,pInd(i,1),pInd(i,2))    ;pInd is an array with coord triplets
end do

Obviously one obvious way of speeding things up would be to read the entire array of input data and extract the locations, to avoid multiple i/o calls. What I really want to do though is somehow get rid of the loop entirely. Is there any way of extracting coordinate pairs (or in this case triplets) without looping through each profile?

The only way I can think of is to turn the input array (T in my example above) into a 1-d array, and somehow convert ‘pInd’ into the elements of that 1-d array – this seems fraught with opportunity for error though. Catastrophic error I can deal with – it’s the sneaky, inobvious error that scares me….

Hoping someone has a great idea….

Will


University of Tasmania Electronic Communications Policy (December, 2014).
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181016/58a832d3/attachment.html>


More information about the ncl-talk mailing list