Tutorial 2: Gridding MODIS 250 m Level 1b Data over Greenland Using mod02.pl

Requirements

Suppose we want to put some MODIS 250 m Level 1b swath data covering all of Greenland into the same grid used in Tutorial 1, except that we want to change the resolution of the grid from 1.25 km to 250 m. We want to grid reflective channels 1 and 2, which are the only MODIS channels available at 250m. We need to order MOD02QKM data; however, as we can see in Supported Data Sets, the lat-lon data are stored at only 1 km resolution in MOD02QKM granules. Therefore, mod02.pl will need to interpolate the 1 km lat-lon data in the MOD02QKM granules to 250 m resolution. There is no need to work with MOD03 granules since the lat-lon data are also at 1 km resolution in MOD03 granules and we're not gridding any ancillary data.

NOTE: To run this example, you'll need a machine with at least 750 MB of memory and about 1.5 GB of free disk space.

Searching for the Data

Let's assume that we want to use data from the same date and time as in Tutorial 1, except that this time we want to search for MOD02QKM granules rather than MOD021KM and MOD03 granules. We use the EDG to order two MOD02QKM granules acquired on June 1, 2000 at 1445 and 1450 that appear to cover Greenland. You can use the following values for performing the search using the EDG:

Data Set
MODIS/TERRA CALIBRATED RADIANCES 5-MIN L1B SWATH 250M

Search Area
Type in Lat/Lon Range:
Northern latitude: 85.0000
Southern latitude: 60.0000
Western longitude: -80.0000
Eastern longitude: 10.0000

Start Date: 2000-06-01  Time (UTC): 14:00:00
End Date:   2000-06-01  Time (UTC): 15:00:00

The search should find two granules having the following names:

MOD02QKM.A2000153.1445.002.2000156075718.hdf
MOD02QKM.A2000153.1450.002.2000156075717.hdf

Note that June 1, 2000 is day-of-year 153.

Ordering and Downloading the Data

Order and download the above files to some directory we'll call the tutorial_2 directory where you have at least 1.5 GB of free disk space. Note that you can also download the *.met files that accompany the *.hdf files, but the MS2GT software doesn't use them.

Creating the mod02.pl Command File

Create a text file in the tutorial_2 directory called gl250_2000153_1445.csh containing the following line:

mod02.pl . gl250_2000153_1445 listfile.txt Gl0250.gpd chanfile.txt none Q

This command specifies the following information (see mod02.pl):

Make gl250_2000153_1445.csh executable by typing:

chmod +x gl250_2000153_1445.csh

Creating the listfile

Create a text file called listfile.txt in the tutorial_2 directory containing the following two lines:

MOD02QKM.A2000153.1445.002.2000156075718.hdf
MOD02QKM.A2000153.1450.002.2000156075717.hdf

Note that we list the MOD02QKM files to be gridded.

Creating the gpd and mpp files

Let's review the Gl1250.gpd file we created in Tutorial 1:

N200correct.mpp map projection parameters       # EASE-Grid
1860 1740       columns rows                    # Greenland
160             grid cells per map unit         # 1.25 km
1949.5  -250.5  map origin column,row

We wish now to create Gl0250.gpd which will specify the same grid but at 250 m resolution rather than 1.25 km. The mpp file will be the same, namely N200correct.mpp. Note that 1250 / 250 = 5, so the number of columns and rows in Gl0250.gpd will be 5 * 1860 = 9300 columns and 5 * 1740 = 8700 rows. The grid cells per map unit will be 5 * 160 = 800. The map origin column will be 5 * (1949.5 + 0.5) - 0.5 = 9749.5 and the map origin row will be 5 * (-250.5 + 0.5) - 0.5 = -1250.5. We now have all the information we need to create Gl0250.gpd in the ms2gt/grids directory (if you don't want to type the file in, then just copy Gl0250.gpd from the ms2gt/tutorial_2 directory to the ms2gt/grids directory):

N200correct.mpp map projection parameters       # EASE-Grid
9300 8700       columns rows                    # Greenland
800             grid cells per map unit         # 250 m
9749.5  -1250.5 map origin column,row

Once Gl0250.gpd has been created in the ms2gt/grids directory, we can use gtest again to check that the latitude and longitude values of the upper left and lower right corners match those in Gl1250.gpd:

gtest

enter .gpd file name: Gl1250.gpd
> assuming old style fixed format file

gpd: /hosts/snow/AVHRR/pathfinder/grids/Gl1250.gpd
mpp:/hosts/snow/AVHRR/pathfinder/grids/N200correct.mpp

forward_grid:
enter lat lon:

inverse_grid:
enter r s: -0.5 -0.5
lat,lon = 67.700233 -82.694237    status = 1
col,row = -0.500000 -0.499863    status = 1
enter r s: 1859.5 1739.5
lat,lon = 67.400612 -2.589502    status = 1
col,row = 1859.500000 1739.500000    status = 0
enter r s:

enter .gpd file name: Gl0250.gpd
> assuming old style fixed format file

gpd: Gl0250.gpd
mpp:/hosts/snow/AVHRR/pathfinder/grids/N200correct.mpp

forward_grid:
enter lat lon:

inverse_grid:
enter r s: -0.5 -0.5
lat,lon = 67.700233 -82.694237    status = 1
col,row = -0.500000 -0.499390    status = 1
enter r s: 9299.5 8699.5
lat,lon = 67.400612 -2.589502    status = 1
col,row = 9299.500000 8699.500000    status = 0
enter r s:

enter .gpd file name:

Note that we used -0.5 -0.5 to specify the upper left corner of the upper left pixel (rather than 0 0 which would be the center of the upper left pixel) for both Gl1250.gpd and Gl0250.gpd, and that the resulting latitude and longitude values were the same, namely 67.700233 N and 82.694237 W, respectively. Similarly, we used 1859.5 1739.5 for the lower right corner of the lower right pixel for Gl1250.gpd and 9299.5 8699.5 for the lower right corner of the lower right pixel for Gl0250.gpd, and that the resulting latitude and logitude values were the same, namely 67.400612 N and 2.589502 W, respectively.

Creating the chanfile

Create a text file in the tutorial_2 directory called chanfile.txt containing the following two lines:

1 reflectance
2 reflectance

Here we specify that we want two output grids to be created containing channel 1 reflectance and channel 2 reflectance, respectively. Each file will consist of an array of binary floating-point numbers. Since we didn't specify weight type or fill, they are set to their default values, namely "avg" and "0".

Running the mod02.pl Command File

Run the shell script containing the mod02.pl command by changing to the tutorial_2 directory, and then typing:

gl250_2000153_1445.csh

You'll see lots of messages displayed while the mod02.pl script runs various IDL and C programs. In this example, the programs include:

  1. extract_latlon - an IDL procedure for extracting latitude and longitude data from a MOD02 or MOD03 file. This program calls another IDL procedure, modis_ancillary_read. In this example, extract_latlon is called twice, once for each of the two MOD02QKM files. Two binary floating-point files are created per call containing latitude and longitude data, respectively. The mod02.pl script concatenates the two latitude files and the two longitude files to create a single latitude file and a single longitude file, and the pre-concatenated files are deleted.
  2. ll2cr - a C program for converting latitude, longitude pairs to column, row pairs for a particular grid. The grid specified in this example is Gl0250.gpd. The concatenated latitude and longitude files are read and two binary floating-point files are created containing column and row numbers, respectively. The mod02.pl script then deletes the concatenated latitude and longitude files.
  3. interp_colrow - an IDL procedure for interpolating column, row pairs from a lower resolution swath format to a higher resolution swath format, in this case from 1 km to 250 m. The interpolation must be performed on a scan's worth of data at a time because the column and row numbers have discontinuities at scan boundaries. The interp_colrow procedure calls a function called congridx for each scan's worth of column and row arrays. The congridx function is called once for the column array and once for the row array. The congridx function first performs an extrapolation of the given array to a slightly expanded array, which it then interpolates (bicubic interpolation is used here) to a fully expanded array. The final array is extracted from the fully expanded array. The mod02.pl script then deletes the pre-interpolated column and row files.
  4. extract_chan - an IDL procedure for extracting channel data from a MOD02 file. This program calls another IDL procedure, modis_level1b_read. In this example, extract_chan is called two times, once for each of the two MOD02QKM files; on each call, channel 1 or channel 2 is extracted, and the result is converted to reflectance. One binary floating-point file is created per call containing the channel data. The mod02.pl script concatenates the pair of channel files, creates one concatenated channel file, and then deletes the pre-concatenated channel files.
  5. fornav - a C program for performing forward navigation from a swath to a grid. In this example, fornav is called two times, once for each of the two concatenated channel files. On each call, the interpolated column and row files are read as well. An elliptical weighted averaging algorithm is applied during forward navigation to minimize holes and aliasing in the gridded data. One binary floating-point file is created per call containing the gridded data. The mod02.pl script then deletes the concatenated channel files as well as the interpolated column and row files.
The final message should contain the string:

MOD02: MESSAGE: done

Examining the Results

Enter the command:

ls -l *.img

You should see something like this:

-rw-r--r--    1 haran    nsidc     323640000 Apr 23 13:26 gl250_2000153_1445_refa_ch01_09300_08700.img
-rw-r--r--    1 haran    nsidc     323640000 Apr 23 13:29 gl250_2000153_1445_refa_ch02_09300_08700.img

Each file contains a gridded array of 9300 columns and 8700 rows of binary floating-point values (9300 * 8700 * 4 = 323640000 bytes).

The file naming convention for gridded channel files can be found in Tutorial 1.


Last updated: May 31, 2001 by
Terry Haran
NSIDC-CIRES
449 UCB
University of Colorado
Boulder, CO 80309-0449
303-492-1847
tharan@colorado.edu