comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » xyz triplet array to a "flat" 2D array?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
xyz triplet array to a "flat" 2D array? [message #18664] Fri, 21 January 2000 00:00
T Bowers is currently offline  T Bowers
Messages: 56
Registered: May 1998
Member
Does anybody have a quickie that'll convert data in xyz triplets
to "flat" format? e.g.

x y z to 89.5 89.6 89.7 89.8
89.7 20.1 00.1 20.1 00.1
89.6 20.3 00.2 20.2 00.3
89.8 20.2 00.3 20.3 00.4 00.2
89.5 20.3 00.4

with x running across the top and y down the first column, blanks
are NaN's or whatever. Like it's been interpolated, but without
the interpolation ;).

I've come close, but no cuban. Here's what I was playing around
with last night. I gave up cause I just don't see it.

Thanks alot all

;///////////////
function colsToFlat, dataInCols

xData = dataInCols[0,*]
yData = dataInCols[1,*]
zData = dataInCols[2,*]

sortedXData = xData[sort(xData)]
sortedYData = yData[sort(yData)]
sortedUniqXData = xData[uniq(xData,sort(xData))]
sortedUniqYData = yData[uniq(yData,sort(yData))]
xSortOrder = sort(xData)
ySortOrder = sort(yData)

numDataPtsInX = n_elements(uniq(xData,sort(xData)))
numDataPtsInY = n_elements(uniq(yData,sort(yData)))

xFlat = sortedXData ;sortedUniqXData
yFlat = sortedYData ;sortedUniqYData
zFlat = fltarr(n_elements(xFlat), n_elements(yFlat))
zFlat[xSortOrder,ySortOrder] = zData[*]

; +1 in next line to make room for x row and y column. dataFlat[0,0] just
; unused
dataFlat = fltarr((n_elements(xFlat)+1), (n_elements(yFlat)+1))
dataFlat[*] = !Values.F_NaN

dataFlat[1:*,0] = xFlat
dataFlat[0,1:*] = yFlat
dataFlat[1:*,1:*] = zFlat

;//Need to remove duplicate x and/or y entries

return, dataFlat
end
;///////////////
[Message index]
 
Read Message
Previous Topic: Re: 24 bit color without connecting to X server
Next Topic: 24 bit color without connecting to X server

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 02:54:36 PDT 2025

Total time taken to generate the page: 7.99875 seconds