[Thread Prev][Thread Next][Index]

Re: How I can read the ascii file in the reverse orderusing"file command".



Hi-
There may be a simpler way to do this but since you have had no
replies, maybe not.   You can use the sorting and sampling functions
to reorder the depths and the temperature and salinity data.

!  first read the data onto an abstract Z axis (make this long enough
!  for your data, I use 4 points for this example)

define axis/z=1:4 z4
define grid/z=z4 gz4

file/var="dep, temp, sal"/skip=1/grid=gz4 my_file.dat
list dep, temp, sal

             DATA SET: ./my_file.dat
             Z: 0.5 to 4.5
 Column  1: DEP
 Column  2: SAL
 Column  3: TEMP
           DEP    SAL   TEMP
1   / 1:  32.10  31.80  29.69
2   / 2:  30.20  31.80  29.69
3   / 3:  20.60  31.50  29.75
4   / 4:   9.80  31.20  29.78
! Now sort the depths and sample all the variables using the sorted indices.
! Sample temperature and salinity in the same way

let sorted_dep = samplek(dep, sortk(dep))
let sorted_temp = samplek(temp, sortk(dep))
let sorted_sal = samplek (temp, sortk(dep))
list sorted_dep, sorted_temp, sorted_sal

             DATA SET: ./my_file.dat
             Z: 0.5 to 4.5
 Column  1: SORTDEP is SAMPLEK(DEP, SORTK(DEP))
 Column  2: SORTSAL is SAMPLEK (SAL, SORTK(DEP))
 Column  3: SORTTEMP is SAMPLEK(TEMP,SORTK(DEP))
        SORTDEP SORTSAL SORTTEMP
1   / 1:    9.80   31.20   29.78
2   / 2:   20.60   31.50   29.75
3   / 3:   30.20   31.80   29.69
4   / 4:   32.10   31.80   29.69
! Use the sorted depths to define an axis
define axis/Z/depth depax = sorted_dep         ! see DEFINE AXIS/FROM_DATA

! Define variables for the reordered salinity and depth, which you can now use for
! plotting or calculations.
let depsal = sorted_sal[gz=sorted_dep@asn]
let deptemp = sorted_temp[gz=sorted_dep@asn]

plot deptemp
 

Namba Takaya wrote:

Dear sir

I have the CTD data (ascii file) below.

How can I read the data in the reverse order using "file" command?
I want to read the data from the bottom (shallower) to the top(deeper).

depth(m)   temperature       salinity
32.1       29.69             31.8
30.2       29.69             31.8
20.6       29.75             31.5
9.8        29.78             31.2
0.1        29.90             30.7

Thank you in advance.

Takaya Namba
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--
Ansley Manke  Pacific Marine Environmental Laboratory  Seattle WA  (206)526-6246
 
[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement