Extracting array with same date, lat, long [message #94382] |
Tue, 02 May 2017 09:40  |
michelle.tomlinson
Messages: 1 Registered: May 2017
|
Junior Member |
|
|
I have a structure of data which contains multiple reading for the same date and location. For example:
-76.4347 37.2563 9/26/2016
-76.4347 37.2563 9/26/2016
-76.4347 37.2563 9/26/2016
-76.4347 37.2563
-76.4347 37.2563
-76.4347 37.2563
-76.4347 37.2563
-76.4347 37.2563
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
-76.5069 37.2385
|
|
|
Re: Extracting array with same date, lat, long [message #94385 is a reply to message #94382] |
Wed, 03 May 2017 06:50  |
Markus Schmassmann
Messages: 129 Registered: April 2016
|
Senior Member |
|
|
On 05/02/2017 06:40 PM, michelle.tomlinson@noaa.gov wrote:
> I have a structure of data which contains multiple reading for the same date and location. For example:
It's not really clear what you want, but maybe this helps:
;----- file: ord.pro
function ord, array
;+
; Calculates the ordinal of each value of an array in terms of the
; sorted values.
; inspired by jbiu's ord & uniqify
; IDL> result=ord(array)
;-
compile_opt defint32, strictarr
return, reform( value_locate(array[uniq(array,sort(array))],array),$
size(array,/dimensions),/overwrite)
end
;----- EOF
ord1=ord(lon)
ord2=ord(lat)
ord3=ord(date)
idx=ord1+(max(ord1)+1)*(ord2+(max(ord2)+1)*ord3)
ord4=ord(idx)
h=histogram(ord4,reverse_indices=ri)
for j=0,n_elements(h)-1 do begin
w=ri[ri[j]:ri[j+1]-1]
print, lon[w[0]], lat[w[0]], date[w[0]]
array=data[w,*]
;do something with the array of data for this triple of lon,lat,date
endfor
;-----
good luck, Markus
|
|
|