[Thread Prev][Thread Next][Index]

Re: Latitude axis read from a ASCII file



Hi Emilie,
             The problem is with the NORTH to SOUTH ordering of the
data instead of ferret's preferred oerdering SOUTH to NORTH. There 
are few nice solutions for this problem...please have a look at

http://ferret.pmel.noaa.gov/Ferret/Mail_Archives/fu_2001/msg00650.html
http://ferret.pmel.noaa.gov/Ferret/Mail_Archives/fu_2000/msg00156.html


Here is an example using the reverse "j" indices to sample data in the
south to north direction.


gpcc.dat contains lon, lat and some dummy values for the variable "ppt"
-----------------------------------------------------------------------
  -20.0  10    10.1
  -10.0  10    10.2
    0.0  10    10.3
   10.0  10    10.4
   20.0  10    10.5
  -20.0  5     5.1
  -10.0  5     5.2
    0.0  5     5.3
   10.0  5     5.4
   20.0  5     5.5
  -20.0  0     0.1
  -10.0  0     0.2
    0.0  0     0.3
   10.0  0     0.4
   20.0  0     0.5
  -20.0  -5    -5.1
  -10.0  -5    -5.2
    0.0  -5    -5.3
   10.0  -5    -5.4
   20.0  -5    -5.5
  -20.0  -10   -10.1
  -10.0  -10   -10.2
    0.0  -10   -10.3
   10.0  -10   -10.4
   20.0  -10   -10.5

ferret script :
--------------

   define axis/x=20W:20E:10/units=longitudes xlon
   define axis/y=10:-10:5/units=latitudes    ylat
   define axis/CALENDAR=360_DAY/t="30-SEP-1993":"30-SEP-1993":30/units=days tdy
   define grid/x=xlon/y=ylat/t=tdy grd

   file/grid=grd/var="lon,lat,ppt" gpcc.dat

   let  jsize = `ppt,r=jend`  ! size of "Y AXIS"
   list jsize                

   let reverse_j = `jsize+1` - j[g=ppt]  ! get the reversed indices for "j"
   list reverse_j

   let ppt_rev_j = samplej(ppt,reverse_j) ! get the data ordered in SOUTH to 
                                          !   NORTH direction
   let pptn = ppt_rev_j[g=grd@asn]        ! impose the lat grid 
   
   set var/title="GPCC precipitation"/units="something" pptn  ! title 

!   now let us have a comparison
 
   list/i=1 ppt   ! variable which is readed in
   list/i=1 pptn  !  variable in ordered south to north along y

! save to a netcdf file for future use
!  save/file=gpcc.nc/append pptn


Hope This Helps

WIth Regards 

Jaison 




On Mon, 19 Jul 2004, Emilie Vanvyve wrote:

> Dear Ferret users,
> 
> I need some help to understand and solve the problem explained 
> hereafter... The point is that Ferret always reads upside down my 
> latitude axis. North Pole becomes South Pole, and South Pole North one.
> 
> I read an ASCII file (GPCC-pre-199309.dat) containing 3 columns of data 
> (longitude, latitude, precipitation) :
> 
> Data         : GPCC 1.0 degree | mean precipitation
> Period       : September  1993
> Area         : global (-180./+180.) (Lon: -180.00 <->  180.00  Lat:  
> -90.00 <->   90.00)
> Output-Id    : 15072004135347_GPCC_VISUALIZER
> Columns      : Lon Lat Value (at grid center)
> Missing-Value: -99999.99
> 
> -179.50   89.50 -99999.99
> -178.50   89.50 -99999.99
> -177.50   89.50 -99999.99
> -176.50   89.50 -99999.99
> -175.50   89.50 -99999.99
> ...       ...   ...
>   175.50  -89.50      0.12
>   176.50  -89.50      0.12
>   177.50  -89.50      0.12
>   178.50  -89.50      0.12
>   179.50  -89.50      0.12
> 
> I have made a script in Ferret to read those values (in order to save 
> them into a NetCDF file). Here is "easy-readable" version of it :
> 
> !spatial and temporal grid
> 
> define axis/X=179.5W:179.5E:1/units=longitude  x_axis
> define axis/Y=89.5N:89.5S:1/units=latidude     y_axis
> define 
> axis/CALENDAR=360_DAY/t="30-SEP-1993":"30-SEP-1993":30/units=days  
> t_axis
> 
> define grid/x=x_axis/y=y_axis/t=t_axis g_grid
> 
> !read variable(s) in ASCII file
> 
> file/grid=g_grid/skip=7/var="lon,lat,PP"   
> "../ascii/GPCC-pre-199309.txt"
> 
> show data
> 
> list PP[j=1,i=355:360]
> list PP[j=180,i=1:5]
> 
> exit
> 
> Here is what Ferret tells me when executing my script :
> 
> yes? go gpcc2nc
> 
> !spatial and temporal grid
> 
> define axis/X=179.5W:179.5E:1/units=longitude  x_axis
> define axis/Y=89.5N:89.5S:1/units=latidude     y_axis
> define 
> axis/CALENDAR=360_DAY/t="30-sep-1993":"30-sep-1993":30/units=days  
> t_axis
> 
> define grid/x=x_axis/y=y_axis/t=t_axis g_grid
> 
> !read variable(s) in ASCII file
> 
> file/grid=g_grid/skip=7/var="lon,lat,PP"   
> "../ascii/GPCC-pre-199309.txt"
>   !-> SET DATA/EZ/grid=g_grid/skip=7/var="lon,lat,PP"   
> "../ascii/GPCC-pre-199309.txt"
> 
> show data
>       currently SET data sets:
>      1> ../ascii/GPCC-pre-199309.txt  (default)
>   name     title                             I         J         K       
>    L
>   LON      LON                              1:360     1:180     ...      
>   1:1
>   LAT      LAT                              1:360     1:180     ...      
>   1:1
>   PP       PP                               1:360     1:180     ...      
>   1:1
> 
> 
> list PP[j=1,i=355:360]
>               VARIABLE : PP
>               FILENAME : GPCC-pre-199309.txt
>               SUBSET   : 6 points (LONGITUDE)
>               LATITUDE : 89.5S
>               TIME     : 30-SEP-1993 00:00
>                     89.5S
>                      1
>   174.5E  / 355: -100000.
>   175.5E  / 356: -100000.
>   176.5E  / 357: -100000.
>   177.5E  / 358: -100000.
>   178.5E  / 359: -100000.
>   179.5E  / 360: -100000.
> list PP[j=180,i=1:5]
>               VARIABLE : PP
>               FILENAME : GPCC-pre-199309.txt
>               SUBSET   : 5 points (LONGITUDE)
>               LATITUDE : 89.5N
>               TIME     : 30-SEP-1993 00:00
>                 89.5N
>                 180
>   179.5W / 1:  0.1600
>   178.5W / 2:  0.1200
>   177.5W / 3:  0.1200
>   176.5W / 4:  0.1200
>   175.5W / 5:  0.1200
> 
> exit
> yes?
> 
> So, values of North Pole shifted to South Pole and ones of South Pole 
> to North Pole! (And I don't know where the 0.1600 does come from.)
> I assume I'm wrong somewhere, but where? It's not the first time that I 
> get that problem. I tried to inverse the definition of the x-axis, to 
> use the /order instruction when reading the data, it does not work. The 
> fact that the longitude axis (1st column) varies more rapidly that the 
> latitude one (2nd column) might be a (the) problem?
> 
> Does anyone have any idea?
> 
> Thanks in advance for any answer!
> 
> Emilie
> 
> 
> ____________________________________________________________
> Emilie VANVYVE
> Physicist, PhD student
> 
> Université catholique de Louvain (UCL)
> Institut d'astronomie et de géophysique G. Lemaître (ASTR)
> Chemin du Cyclotron, 2
> 1348 Louvain-la-Neuve (Belgium)
> Phone : +32-(0)10-473300
> Fax : +32-(0)10-474722
> E-mail : vanvyve@astr.ucl.ac.be
> Web : www.astr.ucl.ac.be

-- 
___________________________________________________

    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