[Thread Prev][Thread Next][Index]
Re: Ascii file: switching X Y data
Hi Kek,
The problems associated with the format of your ascii data are
1. Due to the prescence of "Time/Depth" & "08:00:00" fields in the
first column we need to use the qualifiers
FORMAT=DELIMITED/DELIMITER=" " along with the file command.
In this case /COLUMNS won't be effective to read along a row
instead of the default columnwise reading.
2. It is not possible to skip first column and read the remaining
data block along rows using /COLUMNS qualifier to a single
variable.
Here is one way to tackle this (ofcourse not a 'neat' one). I took a case
with 8 depth points and 5 time points exactly like the format you specified.
-----datafile.dat------------------------------------------
Time/Depth 2.0 4.0 9.0 15 25 40 75 100
08:00:00 33.3 32.2 31.4 31.0 30.3 30.0 29.6 29.4
09:00:00 35.3 31.2 30.4 29.5 29.0 28.4 28.2 27.4
10:00:00 39.3 37.2 37.4 36.3 35.2 34.4 33.2 32.4
15:00:00 32.3 35.2 33.4 32.3 31.2 30.4 29.4 29.0
17:00:00 31.3 31.2 31.4 31.0 30.5 30.0 29.6 29.0
----end of datafile.dat------------------------------------
!----example.jnl--------------
!
! Read only the depth values from 1st row and then convert this
! values to a 1D array. Then use this values to define a depth
! axis
define symbol com = FORMAT=DELIMITED/DELIMITER=" " ! to make command lines
! shorter
define axis/x=1:1:1 xax
define grid/x=xax grd
file/grid=grd/($com)/var="-,d1,d2,d3,d4,d5,d6,d7,d8" datafile.dat
let dep = ZSEQUENCE({`d1`,`d2`,`d3`,`d4`,`d5`,`d6`,`d7`,`d8`})
define axis/z/units="meters"/DEPTH/from_data zdep=dep
! Read time from second row onwards and define a time axis.
! it is assumed that the data is for 01-JAN-2003.
file/skip=1/($com)/type=time/var=tim datafile.dat
define axis/t/units=hours/T0="01-JAN-2003"/from_data thr=tim
! Read the data values of the variable('-' is to skip the time data)
! and write it to a dummy file. Then read it back onto a grid defined by
! those depth and time axes from the dummy file
file/skip=1/($com)/var="-,v1,v2,v3,v4,v5,v6,v7,v8"
sp rm -f dummy.dat ! initial clean-up
list/nohead/quiet/file=dummy.dat/format=(8(f5.2,2x))/append v1,v2,v3,v4,v5,v6,v7,v8
define grid/z=zdep/t=thr vgrd
file/grid=vgrd/columns=8/var=myvar dummy.dat
set var/title="My Variable"/units="my units" myvar
! Now the data is on proper grid; do the plotting/calculation steps.
! I would strongly recommend you to save this data to a netCDF file using
! "SAVE" commad for later use.
plot/l=1 myvar
! save/file=myvar.nc/append myvar
! Remove the dummy file
sp rm -f dummy.dat
!--------------end of example.jnl--------------
Hope this Helps
With Regards
Jaison
On Sat, 21 Aug 2004 hengkek@nus.edu.sg wrote:
> Greetings all
>
> I have the following ascii file.
>
> ---------- start file -----------
> Time/Depth 2.0 4.0 9.0 ...
> 08:00:00 33.3 32.2 31.4 ...
> 09:00:00 35.3 31.2 30.4 ...
> 10:00:00 39.3 37.2 37.4 ...
> 15:00:00 32.3 35.2 33.4 ...
> 17:00:00 31.3 31.2 31.4 ...
> ...
> ---------- end file -----------
> File Description:
> 1st col: time values
> 1st row: depth values
> Other vals: measurements at the given time and depth
>
> I'm able to plot the timeseries at each depth. My difficulty now is in
> plotting the measurements against depth without transposing the ascii
> file. I.e. Y axis to be "depth" and X axis to be "measurement".
>
> I did the following for the timeseries. How do I proceed to plot
> against depth? I know I must now not skip the 1st row to get the depth
> values. Thanks in advance for any pointers or leads.
> -----
> columns/skip=1/type=time,numeric,numeric,numeric,numeric,numeric,\
> numeric,numeric,numeric,numeric,numeric,numeric,numeric, \
> numeric,numeric,numeric,numeric,numeric,numeric,numeric, \
> numeric,numeric,numeric,numeric,numeric,numeric,numeric, \
> numeric,numeric,numeric,numeric,numeric,numeric,numeric, \
> numeric,numeric,numeric,numeric EW_010804.txt
> plot/vs/line v1,v2,v3,v4,v5,v6,v7,v8
> -----
>
> Regards
> -Kek
> Tropical Marine Science Institute
> Singapore
>
--
___________________________________________________
Jaison Kurian
Centre for Atmospheric and Oceanic Sciences
Indian Institute of Science
B A N G A L O R E 560 012
Ph: +91-80-3942505
+91-80-3600450
Fax:+91-80-3600865
___________________________________________________
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement