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

Home » Public Forums » archive » Find Closest Coincident Measurements In Time And Space Between Two Data Sets
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Find Closest Coincident Measurements In Time And Space Between Two Data Sets [message #62909] Mon, 13 October 2008 05:14 Go to previous message
r083r7 is currently offline  r083r7
Messages: 6
Registered: March 2007
Junior Member
I was hoping that somebody could help and apply some magic to this
problem.

I have two sets of satellite measurement data and for dataset A want
to find the value in dataset B that are closest to it in time and
space.

If that's easy enough to speed it it'd also be useful to find ALL
values in databaset B that were within a certain spatial and temporal
distance of each point in dataset A (for example, 5deg lat/lon and 2
hours).

As both datasets are quite large I have a feeling that this problem is
quite similar to the one found here http://www.dfanning.com/code_tips/slowloops.html
but I don't think I understand it quite well enough to solve and
eliminate the FOR loops.

My (working but slow) code is below.

Any help would be great.

Cheers


;datasetA structure contains lat, long, time and values
;datasetB has lat, long, time and value arrays

count=0L
final_lat=fltarr(100000)
final_lon=fltarr(100000)
final_datasetA=fltarr(100000)
final_datasetB=fltarr(100000)
final_time=strarr(100000)
final_date=strarr(100000)

;value in hms of datasetB meas. either side of datasetA meas. time
where time is still considered coincident

time_margin=010000

;value in degrees of datasetB meas. either side of datasetA meas.
location where location is still considered coincident

space_margin=2. ;degrees lat/long

print, ‘Starting to loop through dataset A to find coincident dataset
B points'
FOR i=0L, n_elements(datasetA.lats)-1 DO BEGIN

;find measurement in datasetB that is within time and space margin of
datasetA
coin=where(datasetB_hms GE datasetA.time[i]-time_margin AND
datasetB_hms LE datasetA.time[i]+time_margin AND $
datasetB_lat GE datasetA.lats[i]-space_margin AND
datasetB_lat LE datasetA.lats[i]+space_margin AND $
datasetB_lon GE datasetA.lons[i]-space_margin AND
datasetB_lon LE datasetA.lons[i]+space_margin)

;account for no coincident matches between datasets
if coin[0] NE -1 THEN BEGIN
final_lat[count]=datasetA.lats[i]
final_lon[count]=datasetA.lons[i]
final_datasetA[count]=datasetA.value[i]

;store mean of datasetB values that are coincident to datasetA
measurments
final_datasetB[count]=mean(datasetB_values[coin])
final_time[count]=datasetA.time[i]
final_date[count]=datasetA.date
count=count+1L
END
ENDFOR
print, 'Finished looping through datasetA data to find coincident
datasetB data'
[Message index]
 
Read Message
Read Message
Previous Topic: SFTP with IDLnetURL?
Next Topic: About the Cartesian coordinates of MAP_PROJ_FORWARD

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

Current Time: Fri Oct 10 07:52:47 PDT 2025

Total time taken to generate the page: 0.88349 seconds