[Thread Prev][Thread Next][Index]

Re: [ferret_users] EASE-Grid Data in Ferret



Hi John,
Ferret can read this data, and there are a couple of possible ways to regrid it to a rectilinear grid. Here's a script that shows how to read the data and do a regridding.


! The first problem is reading this ascii data, getting
! the 12 columns of data which contain the precip data
! into a single variable in X-T with X being the cell number,
! and the columns representing months.

! Define an x axis with the number of records, and a time
! axis.  (Note there are a number of ways that a monthly
! axis can be defined: are the data centered on each month,
! or at the start of each month?  Does this represent model
! data where the months were defined as equal-length? I'll do
! just a very simple definition, equally-spaced with the first
! month centered on the middle of January 1990 but you should
! read the documentation and look into what's correct for
! this data.)

yes? DEFINE AXIS/X=1:39926:1 xax
yes? DEFINE AXIS/T=1:12:1/UNITS=months/T0="15-jan-1990:12:00"/UNITS=months tax

! First read the longitude and latitude data from the file
! and save them to a netCDF file. This command reads the
! cell number, but we don't need it so I'll ignore it.
! longitude and latitude are on an x grid only:

yes? DEFINE GRID/X=xax xgrid
yes? FILE/SKIP=2/GRID=xgrid/VAR="nn,lat,lon"/GRID=xgrid td9813_prcp_1990.txt

! We need to read the input ascii data in two different ways,
! so save these variables to a file, and then go back and
! read the ascii data again.

yes? SAVE/CLOBBER/FILE=precip_1990.nc lon, lat

! Now we'll do a second read on the file, and get the
! precip data onto an XT grid. The format statement skips
! over the first part of each record and reads only the
! 12 months.  See Section 2.5 in the Users Guide, examples
! reading ascii data - this is like the example of 1 variable,
! 2 dimensions

yes? CANCEL DATA/ALL
yes? DEFINE GRID/X=xax/T=tax xtgrid
yes? FILE/SKIP=2/FORMAT=(36X,12F8.1)/COLUMNS=12/GRID=xtgrid/VAR=precip td9813_prcp_1990.txt

! Add this to the netCDF file

yes? SAVE/APPEND/FILE=precip_1990.nc precip

! Now the data is in a file, 1-dimensional lon and lat, and
! 2-dimensional variable precip.

yes? CANCEL DATA/ALL
yes? CANCEL VARIABLE/ALL

yes? USE precip_1990
yes? SHOW data

!     currently SET data sets:
!    1> ./precip_1990.nc  (default)
! name     title      I         J       K       L
! LON      LON       1:39926   ...     ...     ...
! LAT      LAT       1:39926   ...     ...     ...
! PRECIP   PRECIP    1:39926   ...     ...     1:12

! Let's take a look at the location data:

yes? PLOT/VS lon, lat
yes? PAUSE

! This plot makes me think this is a curvilinear grid -
! Ferret has tools for dealing with such data, but only when
! it's on a 2-D curviliear grid (see Chapter 8, section 8 in
! the Users Guide). If the data is available in that form,
! we can work with that. Plowing on, however, let's just
! regrid this to a rectilinear grid.

yes? DEFINE AXIS/X=-180:179:1/UNIT=deg longax
yes? DEFINE AXIS/Y=45:85:1/UNIT=deg latax

! Here's one way this data could be regridded to the rectilinear
! grid. Again, please check the documentation on the scat2grid
! functions to choose the arguments for the regridding:

yes? LET precip_grid = SCAT2GRIDGAUSS_XY (lon, lat, precip, x[gx=longax], y[gy=latax], 2, 2, 2, 0)

! Give the variable a title explaining where it came from.
yes? SET VAR/TITLE="Precipitation interpolated from Groisman archive, regridded" precip_grid

yes? SHADE/L=1 precip_grid

yes? SAVE/CLOBBER/FILE=precip_regridded.nc precip_grid



This could be repeated for more years, appending the regridded data to the file. Again, you'll want to take some care about the definition of the time axis.

Ansley

John Krasting wrote:
Dear Ferret Users:

I was wondering if you could help show me how to import data like this
into Ferret.  It is on an 25-km EASE-Grid.

The first columns give the record number, lat, lon, etc.,  and the
remaining columns are precipitation for each month.  Ultimately I
would like to regrid these data to a uniform 1 degree lat-lon grid.

I have a total of 50 files like this that I would need to import. It
would also be nice to aggregate all 600 months onto the same time axis
in the same file.

Can this be done???

Thanks,
John

PS - The attached file has more than 39,000 records. I only pasted the first 20 lines as an example.


[Thread Prev][Thread Next][Index]

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

Privacy Policy | Disclaimer | Accessibility Statement