[Thread Prev][Thread Next][Index]

Re: [ferret_users] problem in reading and regriding ASCII data file

Hi Yogesh,
First the easier part of your question.  Once you have two datasets initialized in Ferret, you can regrid a variable from one dataset to the grid of another with a definition of a variable, including the regridding operation in the definition.  If dataset 1 contains a data variable called AOD on a 1x1 grid and datasets 2 contains O3 data on a 5x5 grid, then you can define

   LET AOD5 = AOD[d=1,gxy=O3[d=2]]

This says, define the new variable AOD5 which is AOD from dataset 1, regridded to the x and y grid of O3 from dataset 2.

As to reading the data, Ferret does not have any syntax to read ASCII data that's organized like yours in blocks of data, skipping the sub-headers  for each latitude. One way to proceed is to use other software to reformat the files into a form that could be read using the ideas and examples in the Users Guide Chapter 2 Section 5.1, "Reading ASCII files"

Another method might be to use Ferret to read in the data and convert it to a netCDF file. This would be similar to what's in the Users Guide, if you look in the index under "append, slab to NetCDF file".  The example in that section describes adding multiple Z levels to a netcdf file, but here we would be adding longitudes to the file. 

Here is an outline of what you would need to do, with some example commands below.

First you would define the longitude and latitude grid corresponding to the data in the file, then read the data for one latitude at a time, using /SKIP to get to the correct record at each step. I am guessing about the axis definitions; use the correct ones for the data.

On the FILE commands, you read in the ASCII data. You will need to work out how to read all of the longitudes for a degree of latitude, so you will need to determine the values to use in /SKIP= and /COLUMNS= and perhaps a /FORMAT= .   Use a LIST command to check that you're reading the data correctly.

I have not tested whether it works to start with 89.5 north and append data for 88.5,  then 87.5 and so on, as I start to do below.  You might need to start by skipping to the end of the file and reading the data for the southernmost latitude first, -89.5 or whatever it is, and then skip to -88.5, -87.5, always skipping fewer lines, filling in the netcdf file from south to north as you go.

yes? ! Define the grid of the entire data set
yes? DEF AXIS/x=0.5:359.5:1/units=degrees xaxis
yes? DEF AXIS/y=-89.5:89.5/units=degrees yaxis

yes? ! Define the grid for one latitude
yes? DEF GRID/X=xaxis/Y=yaxis xy_grid
yes? DEF AXIS/Y=89.5:89.5:1 yaxis1
yes? DEF GRID/LIKE=xy_grid_grid/y=yaxis1  xy_grid1

yes? ! read in the first longitude
yes? FILE/GRID=xy_grid1/VAR="a"/skip=/format=/columns  aod_file.dat

yes? ! Put it onto the whole grid and write to the file.
yes? ! Here is where you can set the missing data flag for the variable
yes? LET/TITLE="AOD"/BAD=-999 AOD = a[G=xy_grid]

yes? SAVE/FILE=aod.cdf/
JLIMITS=1:180/J=180 aod

yes? CANCEL DATA aod_file.dat
yes? DEF AXIS/y=88.5:88.5:1 yaxis1
yes? FILE/GRID=xy_grid1/VAR="aod"
/skip=/format=/columns aod_file.dat
yes? SAVE/FILE=aod.cdf/APPEND/J=179 aod

yes? CANCEL DATA aod_file.dat
yes? DEF AXIS/y=87.5:87.5:1 yaxis1

. . .

! The above sequence could be put into a REPEAT loop, once you have
! worked out how to read each latitude.

! Cancel definitions before using new file 


yes? USE aod.cdf

Yogesh Tiwari wrote:
Hello Ferret Users,
I have two data sets i) TOMS aerosol optical depth and ii) TOMS ozone.
AOD data is on 1x1 grid and O3 data is on 5x5 grid.
First I want to read AOD and O3 and then I want to regrid AOD on 5x5 grid.
Reading is first problem.
AOD data is in following format:
Latitute: 89.5
167 0 0 0 0 0 182 0 0 0 0 0 0 0 0 0 0 0 0 200 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 155 0 0 0 0 0 156  0 0 0 0 0 0
Latitude: 88.5
Latitude: -88.5
180 0 0 0 0 0 182 0 0 0 0 0 0 0 0 0 0 0 0 500 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 655 0 0 0 0 0 156  0 0 0 0 0 0
After each latitude header there is 360 AOD values (1x1 grid). This is monthly mean data. I have many years of data file.
So the first problem is how to read the data by omiting latitude header ?
And second, how to regrid the above AOD data on 5x5 grid. Currently it is on 1x1 grid ?
Ozone data as well has the similar header (Month index: 0 , Month index: 1........).
Many thanks for yours help.
Dr. Yogesh K. Tiwari,
Scientist 'B',
Indian Institute of Tropical Meteorology,
Homi Bhabha Road,

Phone: 0091-99 2273 9513 (Cell)
         : 0091-20-258 93 600 (O) ( Ext.250)
Fax    : 0091-20-258 93 825


~>   ~>   ~>   ~>   ~>   ~>   ~>   ~>   ~>   ~>   ~> 

Ansley Manke, NOAA/PMEL   ansley.b.manke@xxxxxxxx
7600 Sand Point Way NE, Seattle WA
Phone 206-526-6246,  FAX 206-526-6744

[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement