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

Home » Public Forums » archive » Re: matching fields in ascii or text files.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: matching fields in ascii or text files. [message #26090 is a reply to message #26088] Fri, 03 August 2001 15:25 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
patrick@es.ucsc.edu (Patrick McEnaney) writes:

> Folks, suggestions needed for going about the following problem:
>
> I have columnar oceanographic data in two different data files. One is
> a txt file, the other ascii. I want to compare depth values in a
> column from one file to depth values in a column from a second file,
> then write all values associated with a specific depth in other
> columns such as temperature, conductivity, nutrients, etc, to another
> file. Should I attempt some sort of boolean expression to search
> through the two files to match values or is there a more efficient
> method that someone can suggest?

Hi Patrick--

I think what you are trying to do is match up the rows of two files
based on a shared column. If you really need to match them exactly,
then perhaps the best route is to SORT both arrays by depth, and then
step through the lists in tandem.

depth1 = ...
depth2 = ...
ds1 = sort(depth1) & ds2 = sort(depth2)
j = 0L
for i = 0, n_elements(ds1)-1 do begin ;; Step through list 1
while depth2(ds2(j)) LT depth1(ds1(i)) do j = j + 1 ;; Find in list 2
; ... process
endfor

You don't say whether you want to match them exactly however. Another
really good solution is often spline interpolation. The is especially
useful when you have two files sampled on two different time grids (or
depth grids in your case). Then you would do,

y2 = spl_interp(depth1, y1, spl_init(depth1, y1), depth2)

which interpolates the values of Y1, measured on the DEPTH1 grid, onto
the DEPTH2 grid. Whew!

Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: polar contour plots
Next Topic: PV-WAVE 7.5 is now available

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

Current Time: Sat Oct 11 21:15:45 PDT 2025

Total time taken to generate the page: 1.51979 seconds