[Thread Prev][Thread Next][Index]

Re: ascii import



Hi Joerg,
          Your mail went unanswered (in the forum)...may be
nobody like this ascii files!!!!

          It is assumed that in the original ascii file, for
all depth levels, data exists only for the "common latitude
points".
          It is not easy to read your ascii data "as is" in
Ferret since there are comments between the data. So first
step is get rid of those comments and save "only the data" to
an intermediate file and open/read this file in Ferret. Say
your original ascii file (ascii_read.dat) is like

# Meridional streamfunction (Sv)
# Depth level = 1
# latitude depth global ocean Atlantic Ocean Indo-Pacific Ocean
90.00 6.00 -999.999 -999.999 -999.999
88.20 6.00    0.0      0.0   -999.999
86.40 6.00   10.0     20.0     30.0
# Depth level = 2
# latitude depth global ocean Atlantic Ocean Indo-Pacific Ocean
90.00 18.00 -999.999 -999.999 -999.999
88.20 18.00    0.0       0.0  -999.999
86.40 18.00   40.0      50.0    60.0

then use linux commnad "sed" to delete all lines with a "#" in
the first column :

[user@machine]$ sed -e '/^#/d' ./ascii_read.dat > junk.dat

Now junk.dat will look like :

90.00 6.00 -999.999 -999.999 -999.999
88.20 6.00    0.0      0.0   -999.999
86.40 6.00   10.0     20.0     30.0
90.00 18.00 -999.999 -999.999 -999.999
88.20 18.00    0.0       0.0  -999.999
86.40 18.00   40.0      50.0    60.0

Now junk.dat have only two Z-points  ==> 6 & 18
              &      thrre Y-points  ==> 86.4, 88.2 & 90.0

Again there is a problem....the latitudes are in the decreasing
order ..but Ferret needs it in the increasing order....
The following Ferret script will fix all these problems and will
read the data on to proper Y-Z grid...


! modify the points to zax or yax as required..but the values
!    should be in the "INCREASING" order !!!

     define axis/z/units=meters    zax=ZSEQUENCE({6,18})
     define axis/y/units=latitudes yax=YSEQUENCE({86.4,88.2,90.0})
     define grid/z=zax/y=yax gfile

! read in the data (the modified one)

     FILE/grid=gfile/var="ylat,zdep,gl,at,in" junk.dat

! to get data in the increasing order of latitude...sample it
!    in the reverse order of J

     let j_size = `y[gy=yax],r=jend`       ! number of lat points
     let rev_j  = (j_size + 1) - j[gy=yax] ! reverse J indices

     let gl_rev = SAMPLEJ(gl,rev_j) ! sample it in reverse order
     let at_rev = SAMPLEJ(at,rev_j) !           "
     let in_rev = SAMPLEJ(in,rev_j) !           "

     let global   = gl_rev[gy=yax@ASN] ! assign proper lat/Y axis
     let atlantic = at_rev[gy=yax@ASN] !       "
     let indo_pac = in_rev[gy=yax@ASN] !       "

     set var/bad=-999.999 global       ! set missing value
     set var/bad=-999.999 atlantic     !       "
     set var/bad=-999.999 indo_pac     !       "

! now the variables global, atlantic, indo_pac are on proper
!     YZ grid...assign "title" and "units"

     set var/title="Something in Global Ocean"/units="ppt"    global
     set var/title="Something in Atlantic Ocean"/units="ppt"  atlantic
     set var/title="Something in Indo-Pacific Ocean"/units="ppt" indo_pac

     list atlantic

! save the required variables to a NetCDF file for future use..
!     strongly recommended !!!!!

     ! sp rm -f myfile.nc
     ! save/file=myfile.nc/append global,atlantic,indo_pac

! after these you can delete the intermediate ascii file "junk.dat"

     sp rm -f junk.dat

! end of Ferret Script



Hope This Helps

With Regards

Jaison



On Tue, 24 May 2005, Joerg Franke wrote:

Hi ferreters,
I want to use an ascii file wich looks like the following:

# Meridional streamfunction (Sv)
# Depth level = 1
# latitude depth global ocean Atlantic Ocean Indo-Pacific Ocean
90.00 6.00 -999.999 -999.999 -999.999 88.20 6.00 0.00000 0.00000 -999.999
86.40 6.00 -0.409342E-001 -0.409342E-001 -999.999
...
# Depth level = 2
# latitude depth global ocean Atlantic Ocean Indo-Pacific Ocean
90.00 18.00 -999.999 -999.999 -999.999
88.20 18.00 0.00000 0.00000 -999.999
86.40 18.00 -0.409342E-001 -0.409342E-001 -999.999
84.60 18.00 -0.231117 -0.231117 -999.999 ...

I managed to read the data into 5 different variables (FILE/VAR="...) but of cause I only want the 3. - 5. column as a variable and the 1. column as y-coordinate (J-axis) and the 2. column as z-coordinate (k-axis). How can I import the data correctly.

Thanks in advance
Cheers
Jörg

--
___________________________________________________

    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-22932505 Extn. 229
        +91-80-23600450
    Fax:+91-80-23600865
___________________________________________________

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement