[Thread Prev][Thread Next][Index]

[ferret_users] Re: Netcdf Conversion (ASCII sampled depths and times onto a grid)



Hi Akshay,

Please send questions of this sort to the ferret_users email list (cc'ed here).  I'll get you started here, but you'll have to read and experiment to finish the job. 

Two things make your file challenging to work with
  • date and time are encoded into one long string -- e.g. "05-Aug-1988 07:10:00 AM"
  • the range of depths at each station is not constant (i.e. the data as presented do not form a grid)
Using the /delimited option you can break "05-Aug-1988 07:10:00 AM" into separate fields day, month (text), year, time, AM/PM (text).  From this you will b able to re-assemble a time value with a Ferret definition.   The simple act of *reading* the file is then easy enough.  Like this:
yes? columns/skip=1/delim="\t,\b,-"/type="numeric,numeric,numeric,numeric,numeric,text,numeric,time,text,latitude,longitude,text,numeric,numeric,numeric" akshay_nc_data.txt
yes? list/nohead v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15
              V1    V2     V3     V4     V5     V6    V7     V8    V9    V10    V11  V12   V13    V14    V15
1    /  1:  748.0   1.00  43.00   1.00  5.000 "Aug"  1988.  7.167 "AM"   9.98  68.03 "o"   1.00  28.25  36.42
2    /  2:  748.0   1.00  43.00   1.00  5.000 "Aug"  1988.  7.167 "AM"   9.98  68.03 "o"   5.00  28.26  36.42
3    /  3:  748.0   1.00  43.00   1.00  5.000 "Aug"  1988.  7.167 "AM"   9.98  68.03 "o"  10.00  28.23  36.43
4    /  4:  748.0   1.00  43.00   1.00  5.000 "Aug"  1988.  7.167 "AM"   9.98  68.03 "o"  15.00  28.22  36.43
5    /  5:  748.0   1.00  43.00   1.00  5.000 "Aug"  1988.  7.167 "AM"   9.98  68.03 "o"  20.00  28.20  36.42
6    /  6:  748.0   1.00  43.00   1.00  5.000 "Aug"  1988.  7.167 "AM"   9.98  68.03 "o"  25.00  28.19  36.43
7    /  7:  748.0   1.00  43.00   1.00  5.000 "Aug"  1988.  7.167 "AM"   9.98  68.03 "o"  30.00  28.18  36.43
8    /  8:  748.0   2.00  43.00   2.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"   1.00  28.25  36.42
9    /  9:  748.0   3.00  43.00   3.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"   5.00  28.26  36.42
10   / 10:  748.0   4.00  43.00   4.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  10.00  28.23  36.43
11   / 11:  748.0   5.00  43.00   5.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  15.00  28.22  36.43
12   / 12:  748.0   6.00  43.00   6.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  20.00  28.20  36.42
13   / 13:  748.0   7.00  43.00   7.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  25.00  28.19  36.43
14   / 14:  748.0   8.00  43.00   8.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  30.00  28.18  36.43
15   / 15:  748.0   9.00  43.00   9.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  35.00  28.25  36.42
16   / 16:  748.0  10.00  43.00  10.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  40.00  28.26  36.42
17   / 17:  748.0  11.00  43.00  11.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  45.00  28.23  36.43
18   / 18:  748.0  12.00  43.00  12.00  6.000 "Aug"  1988.  7.167 "AM"  10.98  69.03 "o"  50.00  28.22  36.43
19   / 19:   ....   ....   ....   ....   .... " "     ....   .... " "    ....   .... " "   ....   ....   ....
The real work is in giving meaning to the variables.  Using the Ferret internal function SCAT2GRIDLAPLACE_ZT you can place the data onto a grid. The Ferret script needed will resemble this, but needs much more:
columns/skip=1/delim="\t,\b,-"/type="numeric,numeric,numeric,numeric,numeric,text,numeric,time,text,latitude,longitude,text,numeric,numeric,numeric" akshay_nc_data.txt

! assemble the date/time back together
let month = if v6 eq "Aug" then 8
let year = v7
let day = v5
let time = if v9 eq "AM" then v8 else v8+12
let time1900 = DAYS1900(year,month,day) + time/24

define axis/z/units=meters zax = {1,5,10,15,20,25,30,35,40,45,50} 
define axis/t="5-aug-1988 07:10:00":"10-aug-1988 07:10:00":1/unit=days/t0=1-jan-1900 tax ! is this right?

! other variables treated like this, too
set var/name=temperature/units="degrees C" v14 
set var/name=depth/units=meters V13

! then put it onto a grid
let gridded_temp = SCAT2GRIDLAPLACE_ZT(depth,time1900,temperature,Z[gz=zax],T[gt=tax],0,2)
set variable/title="gridded temperature"/units="degrees C" gridded_temp

! save it to netCDF
SAVE/file=my_netcdf.nc gridded_temp
    - Steve



On 11/6/2012 12:56 AM, Akshay Hegde wrote:
Dear Sir,

Kindly observe the data file properly, here latitude, longitude, date and time are changing after some station number, please do one simple program for me. I still have confusion about the netcdf, I didn't understand it, here program has to read a file which is containing temperature and salinity data of all stations not like a one after another datafile file.

1. How can I create netcdf for this type of file
2. How to fill the missing value
3. How to make grid for this type of data
4. How station 2 data can be accessed and filled in grid.


Kindly prepare one sample program ( Either in C or in ferret ) for my data file and send me .

Looking forward for your positive reply,




With Best Regards,

Akshay Hegde,
Project Assistant,
Data and Information Center,
National Institute of Oceanography,
Dona Paula, Panjim,
Goa - 403004, India
+91-9741787004
ahegde@xxxxxxx





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

Privacy Policy | Disclaimer | Accessibility Statement