![]() |
![]() |
Suppose we want to put 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. We could simply order MOD021KM data; however, 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 (i.e. by setting both latlon_src and ancil_src to 1); however we decide to order the corresponding MOD03 granules as well in order to minimize interpolation error.
NOTE: To run this example, you'll need a machine with at least 100 MB of memory and about 1 GB of free disk space.
Let's assume that we happen to 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. You can use the following values for performing the search using the EDG:
Data Set
MODIS/TERRA CALIBRATED RADIANCES 5-MIN L1B SWATH 1KM
MODIS/TERRA GEOLOCATION FIELDS 5-MIN L1A SWATH 1KM
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:
MOD021KM.A2000153.1445.002.2000156075718.hdf
MOD021KM.A2000153.1450.002.2000156075717.hdf
MOD03.A2000153.1445.002.2000156061125.hdf
MOD03.A2000153.1450.002.2000156062025.hdf
Note that June 1, 2000 is day-of-year 153.
Order and download the above files to some directory we'll call the tutorial_1 directory where you have at least 1 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.
Create a text file in the tutorial_1 directory called gl1_2000153_1445.csh containing 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):
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 only gridding 1 km ancillary data, then we would list the MOD03 files in listfile since there would be no need for reading the MOD021KM files.
See Points, Pixels, Grids, and Cells for a description of the gpd and mpp file formats used by the mapx library in defining a grid and its associated map projection. See All About EASE-Grid for a description of the AVHRR Polar Pathfinder 1.25 km Northern Hemisphere EASE-Grid whose grid parameter definitions file is Na1.gpd which in turn refers to N200correct.mpp which defines the associated map projection. Both of these files are included in the ms2gt/grids directory. Note that Na1.gpd defines a 7220 column x 7220 row grid. We wish to create a gpd file that we'll call Gl1250.gpd that defines a region within this grid that contains Greenland. 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. We would like to know what column and row numbers in Na1.gpd have these coordinates. To do this we can use an interactive program called gtest that was built during the MS2GT installation. This program can perform forward (lat-lon to col-row) and inverse (col-row to lat-lon) calculations given a gpd file. Here is a transcript of a gtest session that does what we want (what we type is shown in bold):
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 the upper left corner our region is at column 1660, row 3860, and the 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 (if you don't want to type the file in, then just copy 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 is used to define 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, we can use gtest again to check that the latitude and longitude values of the upper left and lower right corners are about what we expect:
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 containing the following four lines:
1 reflectance
2 reflectance
31 temperature
32 temperature
Here we 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 specify that we want two more output grids (in addition to the four grids we specified in the chanfile) to be created containing sensor zenith and solar zenith, respectively. Each file will consist 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, namely "avg" and "0", just as they were in chanfile.
Run the shell script containing the mod02.pl command by changing to the tutorial_1 directory, and then typing:
gl1_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:
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 would like to know the latitude and longitude of each cell in the grid defined by Gl1250.gpd. For individual cells in the grid, you can 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, you can use a C program called gridloc that was built during the MS2GT installation. This program can create 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
So 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.
Last updated: January 2, 2002 by
Terry Haran
NSIDC-CIRES
449 UCB
University of Colorado
Boulder, CO 80309-0449
tharan@nsidc.org