MODIS Data at NSIDCHome | Data Summaries | Versions | Image Gallery | Order Data | News | V004 CMG Browse | Research | FAQs | Terra vs. Aqua |
![]() |
The MS2GT installation provides most of the files you will need for the tutorials. The tutorial shows the process you need to use to create the files when performing operations on data files. The MS2GT installation does not provide the data files, so you will need to find and order the data through the EDG.
For this tutorial, we will place some MODIS 1 km Level 1b swath data covering all of Greenland into a region of the same grid used by the AVHRR Polar Pathfinder Twice-Daily 1.25 km EASE-Grid Composites. We want to grid reflective channels 1 and 2, thermal channels 31 and 32, and ancillary data channels sensor zenith and solar zenith. You will need to order MOD021KM data and the corresponding MOD03 granules.
(We could simply order MOD021KM data; but as we can see in Supported Data Sets, both the ancillary data and the lat-lon data are stored at only 5-km resolution in MOD021KM granules. We could have mod02.pl work with only the MOD021KM granules (by setting both latlon_src and ancil_src to 1); but we decide to order the corresponding MOD03 granules as well, to minimize interpolation error.
NOTE: To run this example, you will need a computer with at least 100 MB of memory and about 1 GB of free disk space.
We know that the afternoon of June 1, 2000 was fairly clear, so we use the EDG to order two MOD021KM and the corresponding two MOD03 granules acquired on June 1, 2000 at 1445 and 1450 that appear to cover Greenland.
In a browser, navigate to the EDG. Use the following values for performing the EDG search:
Data Set
MODIS/TERRA CALIBRATED RADIANCES 5-MIN L1B SWATH 1 Km
MODIS/TERRA GEOLOCATION FIELDS 5-MIN L1A SWATH 1 Km
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 four granules having the following names:
Note that June 1, 2000 is day-of-year 153.
Order the data sets. Download the files to ms2gt/tutorial_1 directory. (You may download the *.met files that accompany the *.hdf files, but the MS2GT software does not use them.)
In the tutorial_1 directory, create a text file and name it gl1_2000153_1445.csh. In the file, add the following two lines:
mod02.pl . gl1_2000153_1445 listfile.txt Gl1250.gpd chanfile.txt
\
ancilfile.txt 3
3
This command specifies the following information (see mod02.pl):
| Parameter | Value | Description |
|---|---|---|
| dirinout | "." | The current directory will contain the input and output files when gl1_2000153_1445.csh is invoked. |
| tag | gl1_2000153_1445 | All output filenames containing gridded data created by mod02.pl will begin with the string "gl1_2000153_1445". |
| listfile | listfile.txt | The text file contains a list of the MOD02 files to process. (See Creating the listfile.) |
| gpdfile | Gl1250.gpd | The gdp file contains a specification of the grid and the associated map projection to use in gridding the data. (See Creating the gpd and mpp files.) |
| chanfile | chanfile.txt | The text file contains a list of the channels to be gridded, and specifies how to process each channel. (See Creating the chanfile.) |
| ancilfile | ancilfile.txt | The text file contains a list of the ancillary parameters to grid, as well as how to process each ancillary parameter. (See Creating the ancilfile.) |
| latlon_src | 3 | The value indicates that for each MOD021KM file specified in the listfile, a corresponding MOD03 file is read, and the 1-km latitude and longitude data in the MOD03 file is used instead of the 5-km latitude and longitude data in the MOD021KM file. |
| ancil_src | 3 | The value indicates that for each MOD021KM file specified in the listfile, a corresponding MOD03 file is read, and the 1-km ancillary data in the MOD03 file is used instead of the 5-km ancillary data in the MOD021KM file. |
| keep | not specified | The default value of "0" is used, which indicates that intermediate chan, lat, lon, col, and row files are deleted. |
| rind | not specified | The default value of "50" is used. If you see holes in the final grid that seem to correspond to the boundaries between adjacent swath granules, then you can try increasing the rind value. |
Make gl1_2000153_1445.csh executable by typing:
chmod +x gl1_2000153_1445.csh
Create a text file called listfile.txt in the tutorial_1 directory containing the following two lines:
MOD021KM.A2000153.1445.002.2000156075718.hdf
MOD021KM.A2000153.1450.002.2000156075717.hdf
Note that we list only the MOD021KM files to be gridded, not the MOD03 files, since we are gridding channel data as well as ancillary data. If we were gridding only 1-km ancillary data, then we would list the MOD03files in listfile since there would be no need for reading the MOD021KM files.
To learn about gdp and mpp files used by the mapx library in defining a grid and its associated map projection, see Points, Pixels, Grids, and Cells.
For a description of the AVHRR Polar Pathfinder 1.25-km Northern Hemisphere EASE-Grid, see All About EASE-Grid. The grid parameter definitions file is Na1.gpd, which refers to the N200correct.mpp. (These files were installed in the /ms2gt/grids directory.) Note that Na1.gpd defines a 7220 column x 7220 row grid.
By consulting a map of Greenland oriented in the same way as shown in All About EASE-Grid, we determine that the upper left corner of our grid should be at about 67.70 N, 82.68 W and the lower right corner should be at about 67.41 N and 2.60 W.
The Gl1250.gpd was installed in the ms2gt/tutorial_1 directory. his file defines a region within the grid that contains Greenland. The file defines what column and row numbers in Na1.gpd have the previously defined coordinates.
The following steps will create a gpd file that we will name Gl1250.gpd. This file defines a region within the grid that contains Greenland.
An interactive program, gtest, was built during the MS2GT installation. We will use gtest to find out what column and row numbers in Na1.gpd have the previously defined coordinates. The gtest program can perform forward (lat-lon to col-row) and inverse (col-row to lat-lon) calculations given a gpd file. The following example is a transcript of a gtest session. (The bold is the text that you enter):
gtest
enter .gpd file name: Na1.gpd
> assuming old style fixed format file
gpd: /export/data/ms2gt/grids/Na1.gpd
mpp:/export/data/ms2gt/grids/N200correct.mpp
forward_grid:
enter lat lon: 67.70 -82.68
col,row = 1659.541626 3859.987305 status = 1
lat,lon = 67.699997 -82.680000 status = 1
enter lat lon: 67.41 -2.60
col,row = 3519.172363 5598.667480 status = 1
lat,lon = 67.410004 -2.600002 status = 1
enter lat lon:
inverse_grid:
enter r s:
enter .gpd file name:
Rounding off these column and row values, we see that:
upper left corner is at column 1660, row 3860
lower right corner is at column 3519, row 5599.
Thus, the dimensions of our region are 3519 - 1660 + 1 = 1860 columns and 5599 - 3860 + 1 = 1740 rows.
Note that the origin (in this case the north pole) of Na1.gpd is at column 3609.5, row 3609.5. Thus the origin of our region will be at 3609.5 - 1660 = column 1949.5 and 3609.5 - 3860 = row -250.5.
We now have all the information we need to create Gl1250.gpd in the ms2gt/grids directory. (The text of the file is contained in Gl1250.gpd from the ms2gt/tutorial_1 directory to the ms2gt/grids directory):
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 can view N200correct.mpp by typing:
cat $PATHMPP/N200correct.mpp
Azimuthal Equal-Area
90.0 0.0 lat0 lon0
0.0
rotation
200.5402 scale (km/pixel)
90.00 00.00 center lat lon
0.00 90.00 lat min max
-180.00 180.00 lon min max
15.00 30.00 grid
0.00 00.00 label lat lon
1 0 0
cil bdy riv
Note that N200correct.mpp defines the same map projection (an Azimuthal Equal Area projection centered at the north pole with 0 degrees longitude extending straight down) in Gl1250.gpd as in Na1.gpd, and that the resolution (200.5402 km/pixel from N200correct.mpp divided by 160 grid cells per map unit =~ 1.25 km/pixel) is also the same. Once Gl1250.gpd has been created in the ms2gt/grids directory, use gtest again to check that the latitude and longitude values of the upper left and lower right corners are as expected:
gtest
enter .gpd file name: Gl1250.gpd
> assuming old style fixed format file
gpd: /export/data/ms2gt/grids/Gl1250.gpd
mpp:/export/data/ms2gt/grids/N200correct.mpp
forward_grid:
enter lat lon:
inverse_grid:
enter r s: 0 0
lat,lon = 67.705200 -82.677933 status = 1
col,row = 0.000000 -0.000092 status = 1
enter r s: 1859 1739
lat,lon = 67.406090 -2.604522 status = 1
col,row = 1859.000000 1739.000244 status = 1
enter r s:
enter .gpd file name:
Note that the upper left corner (column 0, row 0) is close to 67.70N, 82.68 W, and that the lower right corner (column 1859, row 1739) is close to 67.41 N and 2.60 W.
Create a text file in the tutorial_1 directory called chanfile.txt. Enter the following four lines in the file:
1 reflectance
2 reflectance
31 temperature
32 temperature
The lines above specify that we want four output grids to be created containing channel 1 reflectance, channel 2 reflectance, channel 31 temperature, and channel 32 temperature, 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". The weight type parameter refers to the kind of subsampling that will be employed. For data parameters that have continuous values, weighted average subsampling is best. For data parameters that have discreet values (i.e. coded data), maximum weighting should be used since this will not introduce any intermediate values that may not be valid codes. The fill value refers to the output value to which input data having a value of "fill" will be mapped. Input fill values are specified in the input hdf files.
Create a text file in the tutorial_1 directory called ancilfile.txt containing the following two lines:
seze scaled
soze scaled
Here we specified that we want to create two more output grids (in addition to the four grids we specified in the chanfile). These grids contain sensor zenith and solar zenith, respectively. Each file consists of an array of binary floating-point numbers in degrees. Since we didn't specify weight type or fill, they are set to their default values, "avg" and "0", just as in chanfile.
To run the shell script containing the mod02.pl command, change to the tutorial_1 directory, and then type:
gl1_2000153_1445.csh
Messages display while the mod02.pl script runs various IDL and C programs.
In this example, the programs include:
The final message should contain the string:
MOD02: MESSAGE: done
Enter the command:
ls -l *.img
You should see something like this:
-rw-r--r-- 1 haran nsidc
12945600 Apr 19 14:24 gl1_2000153_1445_refa_ch01_01860_01740.img
-rw-r--r-- 1 haran nsidc
12945600 Apr 19 14:24 gl1_2000153_1445_refa_ch02_01860_01740.img
-rw-r--r-- 1 haran nsidc
12945600 Apr 19 14:25 gl1_2000153_1445_scaa_seze_01860_01740.img
-rw-r--r-- 1 haran nsidc
12945600 Apr 19 14:25 gl1_2000153_1445_scaa_soze_01860_01740.img
-rw-r--r-- 1 haran nsidc
12945600 Apr 19 14:24 gl1_2000153_1445_tema_ch31_01860_01740.img
-rw-r--r-- 1 haran nsidc
12945600 Apr 19 14:25 gl1_2000153_1445_tema_ch32_01860_01740.img
Each file contains a gridded array of 1860 columns and 1740 rows of binary floating-point values (1860 * 1740 * 4 = 12945600 bytes).
The file naming convention for gridded MOD02 channel files is as follows:
<tag>_<conversion><weight_type>_<chxx>_<columns>_<rows>.img
The file naming convention for gridded MOD02 and MOD03 ancillary files is as follows:
<tag>_<conversion><weight_type>_<ancil>_<columns>_<rows>.img
Suppose you want to know the latitude and longitude of each cell in the grid defined by Gl1250.gpd. For individual cells in the grid, use gtest as described in Creating the gpd and mpp files, above. If you want to know the latitude and longitude of every cell in the grid, use a C program called gridloc that was built during the MS2GT installation. This program creates binary floating-point arrays of latitude and longitude values. You can view the usage of gridloc by typing it without any arguments:
gridloc
usage: gridloc [-pmq -o output_name] file.gpd
input : file.gpd - grid parameters definition file
output: grid of signed decimal latitudes and/or longitudes
4 byte floats by row
option: o - write data to file output_name.WIDTHxHEIGHTxNBANDS.float
otherwise output goes to stdout
p - do latitudes only
m - do longitudes only
pm - do latitudes followed by longitudes
mp - do longitudes followed by latitudes (default)
q - quiet
To create latitude and longitude files for the Gl1250.gpd grid, type the following two commands:
gridloc -p Gl1250.gpd >gl1_lat_01860_01740.img
gridloc -m Gl1250.gpd >gl1_lon_01860_01740.img
Each of these commands creates a gridded array containing 1860 columns and 1740 rows of binary floating-point values. The latitude values are stored in gl1_lat_01860_01740.img and the longitude values in gl1_lon_01860_01740.img.