[Thread Prev][Thread Next][Index]

Re: [ferret_users] uneven grid from ASCII file



Hi Leticia,

On 07/28/2011 09:29 AM, Leticia Cotrim da Cunha wrote:
> Hi Ferreters,
> I am in trouble trying to read an ASCII file (space) that contains the
> following columns:
> 
> lon,lat,var1,...,var18
> 
> Number of lines: 1010, first line contains labels
> 
> Missing value is -1.00E+034
> 
> My problem is that lon+lat are unevenly spaced (but listed ascending). 
> 
> I managed save lon,lat in a separate cdf file like this (hint from the
> user's list):
> yes? define axis/npoints=1009/x=274.738:293.97 ax1
> yes? define axis/npoints=1009/y=-12.4167:-55.05 ay1
> yes? define grid/x=ax1/y=ay1 gg1
> yes? file/var="lat,lon"/skip=1/g=gg1/ord=xy Surface_data_CHILE.csv
> save/file=saved_lon_lat.cdf lon,lat ! (I have tested it, and the lon,lat
> values are listed ok)
> 
> I have tried to copy the variable to a dummy file, then open the it using
> the grid gg1, like this:
> 
> yes?file/var="lon,lat,TOC,CN,d15N,TP,d13Corg,BSi,CaCO3,BSiO2flx,N,P_alata,P_alata_ind,Coast_PKT,Benthic,Trop_sutrop,Upwelling,S_diat,Diatoms_valves,Freshwater"/skip=1/g=gg1/ord=xy
> Surface_data_CHILE.csv
> 
> yes? list/nohead/format="comma"/file=dummy.dat
> TOC,CN,d15N,TP,d13Corg,BSi,CaCO3,BSiO2flx,N,P_alata,P_alata_ind,Coast_PKT,Benthic,Trop_sutrop,Upwelling,S_diat,Diatoms_valves,Freshwater
> 
> Then tried to read it, and got the following:
> yes? file/format="comma"/var=TOC/g= gg1/col=1/ord=xy dummy.dat
> 
> yes? sha toc[g=gg1]
>  **TMAP ERR: Function not implemented
>  Last or next-to-last record read:
> 274.738 /
> 1:0.45,-1.E+34,-1.E+34,-1.E+34,-1.E+34,-1.E+34,-1.E+34,-1.E+34,-1.E
>  Data set: ./dummy.dat
>  Data file: ./dummy.dat
> yes? sho data 2
>  currently SET data sets:
>  2> ./dummy.dat (default)
>  name title I J K L
>  TOC TOC 1:1009 1:1009 ... ...
>  
> yes? list toc[i=1:10,j=1:10]
>  **TMAP ERR: Success
>  during SKIP reads
>  Data set: ./dummy.dat
>  Data file: ./dummy.dat
> 
> I have tried to have a look on the "scat2gridlaplace_xy" but I am afraid I
> didn't understand it quite well...

You can use scat2gridlaplace_xy() or scat2gridgauss_xy() to map your
data to a regular grid.

Here is an example for a 1x1 degree grid:

----------
! Load your raw data (without defining a grid)
file/var="lon,lat,TOC,CN,..."/skip=1 Surface_data_CHILE.csv

! Load some data on a 1x1 grid (alternatively you could define the
! grid by yourself, but I find it more convenient to do it this way)
use etopo60

! Define a new variable with the interpolated data on the 1x1 grid.
! ('rose' is the variable in etopo60 and is used here only to inherit
! its grid definition)
let TOC_1x1 =
scat2gridlaplace_xy(lon[d=1],lat[d=1],TOC[d=1],x[g=rose[d=2]],y[g=rose[d=2]],5,5)

! Now you can use the interpolated data
shade TOC_1x1
-------------

You maybe have to adjust the parameters for the interpolation. Have a
look at the documentation and experiment with the settings:

http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/variables-xpressions/XPRESSIONS#_VPINDEXENTRY_370

http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/variables-xpressions/XPRESSIONS#_VPINDEXENTRY_376

Hope that helps,
Marco

-- 
***************************************
Marco Steinacher

Climate and Environmental Physics
Physics Institute, University of Bern
Sidlerstrasse 5, CH-3012 Bern

Phone ++41 (0)31 631 34 02
Fax   ++41 (0)31 631 87 42
steinacher@xxxxxxxxxxxxxxxx
http://www.climate.unibe.ch/~steinach
OpenPGP Key ID: 0x62937F7F
***************************************


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement