[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: matching fields in ascii or text files.



Patrick McEnaney wrote:
> 
> "Pavel A. Romashkin" <pavel.romashkin@noaa.gov> wrote in message news:<3B6AD991.5669DE2B@noaa.gov>...
> > Are you attempting this in IDL? Or is it a general data handling
> > question? It seems to me that TXT file and ASCII is the same kind of
> > file. To compare the columns by scrolling them in a window, Excel will do.
> > Cheers,
> > Pavel
> >
> Greetings Pavel-
> 
> I'm writing an idl gui script to cycle through fairly long files of
> data that are collected from a ctd and compare them with chlorophyll
> measurements from insitu sampling. I want to select the data from a
> specific depth for chlorophyll  and and write all values for that
> depth in another file. Just putting the data into excel files would be
> very cumbersome because the data are collected over a month long
> cruise and there are alot of measurements. Ultimately I'll use the
> script whenever I need to compare fields from cruise data. Can you
> suggest a way to construct such a matching routine in idl?

The first question that came to my mind (apart from "aren't TXT and ASCII the same thing?"
:o) was: what do you mean by compare? Do you have a depth tolerance? e.g. given a depth
value from one file is +/- 10m from another file considered the "same" depth?

Also when you said:

"I want to select the data from a specific depth for chlorophyll and and write all values
for that depth in another file."

did you mean:

"I want to select the data from a specific depth for chlorophyll and write all **the ctd**
values for that depth in another file."

??

My first cut at something like this would be to pick the dataset with the least number of
depth values, say the chlorophyll stuff - you can loop through those depths. Then you can
use where to find the corresponding depths for the ctd data, like:

IDL> ctd_depth = findgen(10000)/100. & chlorophyll_depth = 20.0
IDL> help, ctd_depth, chlorophyll_depth
CTD_DEPTH       FLOAT     = Array[10000]
CHLOROPHYLL_DEPTH
                FLOAT     =       20.0000

IDL> depth_tolerance=0.1  ; metres, for example
IDL> loc = where( abs(ctd_depth-chlorophyll_depth) lt depth_tolerance, count )

and loc should give those ctd_depths that are within your tolerance for matching
chlorophyll depth.

IDL> print, ctd_depth[loc]
      19.9100      19.9200      19.9300      19.9400      19.9500
      19.9600      19.9700      19.9800      19.9900      20.0000
      20.0100      20.0200      20.0300      20.0400      20.0500
      20.0600      20.0700      20.0800      20.0900

adn then write all the data asociated with those ctd depths (using loc) to another file.

Is this the sort of thing you mean?? If so, why would you need a gui?

paulv

p.s. If you have to read in simple columnar ASCII data files (that just contain numbers),
you might want to have a look at DDREAD.PRO - it's a piece of IDL code (written by a
feller called Fred Knight) that I find indispensible for simply reading in column ASCII
numbers.

-- 
Paul van Delst           A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP        Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274  There shallow draughts intoxicate the brain,
Fax:(301)763-8545        And drinking largely sobers us again.
                                         Alexander Pope.