04/30/2005 20:41

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 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 interest, 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.

pro get_ascii_avhrr, data
;USER: please supply infilename, outfilename, xdim, ydim and zdim.
; infilename=avhrr.ascii file of interest
; outfilename=avhrr.bin binary output file
; xdim = number of columns
; ydim = number of rows
; zdim = number of channels PLUS 1 for lat and 1 for lon (e.g., zdim=5 for
; a file containing lat, lon, and channels 3, 4 and 5).
infilename='avhrr.ascii'
outfilename='avhrr.bin'
xdim=100
ydim=100
zdim=5
data=fltarr(xdim,ydim,zdim)
openr,1,infilename & readf,1,data & close,1 ;ingest ascii data
openw,1,outfilename & writeu,1,data & close,1 ;output binary data
return
end
_________________________________________________________________________________

SEE ALSO: http://www.geo.mtu.edu/great_lakes/ice/registration.html