Procedure Notes: TeraScan images to IDL

(Lake Superior. Merged SSM/I an d AVHRR. RGB=directional filter AVHRR band 4, SSM/I 85v, SSM/I 37h.)

Getting AVHRR data from SAA into Terascan

Begin with a Level 1b AVHRR data set from SAA (Satellite Active Archive). Ingest the scene into TeraScan using lac. Note that instead of having TeraScan go to the tape drive for data, it must look in your working directory; i.e., ./filename. Most other fields are default values or easy to figure out. After ingesting using lac, register the scene using fastreg and the appropriate Master file.

Exporting registered TeraScan AVHRR (or SSM/I) scenes for ingestion into IDL/ENVI

The idea is to produce data in a form amenable to ENVI (or IDL). TeraScan exports a wierd form of binary that I can't figure out at present. So instead, export an ascii image from TeraScan, import it into IDL, export it as a binary, then import it into ENVI. Convoluted but robust.

From xvu, go to Select, then to Locations. Make a box, so select Boxes, name an Output File (perhaps something like something.box), keep Output Mode as Safest, highlight Lat/Lon, and hit Run. Now select the area of interest (often the entire image) by clicking and dragging the left mouse button. A black outline box will appear. Once it covers the area of interst, click the right mouse button to terminate the operation. Then Quit .

Then again Select, then Points List then select the data file of interest from File List, the variable of interest from Variables, then the point file you just made (something.box) from PointsFile, name an output file (this is the image), select Boxes from Points Are:, and Save Coords: Yes, hit Run then Quit.

Now go to Utils, then to Export Ascii, select the file you just created from File List, the variables of interest from Variables, name an Output File, Sort By : AllDims, then List Dims: No, hit Run, then Quit.

In theory, you now have an ascii file of lat, lon, and whatever AVHRR bands you selected (probably 1-5 if daytime and clear, and 3-5 if nighttime). Be sure to get the dimensions of your AVHRR subset (perhaps using Describe) so you can import the file into IDL.

Remove null characters (***) from ascii TeraScan file

TeraScan uses *** or ***** as null characters in data files. Null characters are used where data should appear but don't (as in the case of the sensor failing to record data). This will cause IDL to choke when importing the ascii data file into IDL. You can determine the number of asterisks by using more or cat on the file (generally these files are too big to use vi) (ergo the use of sed, stream editor). You must convert the asterisks to some numerical value that a) IDL can ingest and b) won't confuse the image statistics (if this is important). Use one of the following sed commands:

sed '/\*\*\*/s//0.01/g' terascan_outfile.ascii > file.idl

or,

sed '/\*\*\*\*\*/s//0.01/g' terascan_outfile.ascii > file.idl

where 0.0001 is a dummy value to replace the ***. Choose the dummy value with care, as it may or may not be relevant to subsequent calculations peformed on the image. Note that it should be unique, and you should be able to identify it later should the need arise. (Generally you can identify it later by where it occurs in the image.)

Importing AVHRR into IDL

You will probably want to write an IDL procedure to import the ascii data and export binary data. Here is an example.

Importing into ENVI

Now you can import the avhrr.bin file into ENVI. Start ENVI from IDL by typing envi, or from an xterm by typing envi_rt. Go to File, then Open Image File. Select the file of interest. The Header Information widget will appear in which you must enter the number of Samples (columns), the number of Lines (rows), Data Type (usually Floating Point), and the Interleave (BSQ)(usually band sequential). Hit OK.

If all goes well, the Available Bands List widget will appear and you can display the image. If there is a problem, you will be prompted to correct some error (usually dimensions of image), or you must Edit ENVI Header from the File box. Fix whatever is wrong. If you were able to display an image, but its nonsense, try adjusting the Interleave from BSQ to BIL or BIP.

Example of a Misregistered AVHRR image

Here's an example of a registered AVHRR image. This is a highly magnified AVHRR image of the end of the Keweenaw Peninsula from Bete Gris to Keweenaw Point. Keweenaw Point on the image is the leftmost white pixel. The UTM coordinates of Keweenaw Point on the Hancock 1:250,000 topographic map is shown by the rightmost white pixel. The separation of the two white pixels demonstrates the amount of misregistration of the AVHRR image. In this case, the AVHRR image is shifted about 5.6 km west of where it should be. The amount of misregistration tolerated depends on the application. This is a 'moderately good' registration, based on 15 ground control points selected along the Lake Superior shoreline. The points were selected so that they could also be identified on an SSM/I image (85 GHz, 12.5 km pixels) for subsequent coregistration of the SSM/I image to the AVHRR base image. Probably the AVHRR image should be re-registered with more and better control points, and de facto limit the coregistration of the SSM/I image to the AVHRR image with whatever subset of points can be identified in the SSM/I image.

Importing binary SSM/I image files into TeraScan for georegistration