pro WREADIMG, dtype, st, len, wd, image ;+ ; NAME: ; WREADIMG ; ; PURPOSE: ; This procedure reads in two files- one byte (image) and one ascii- that ; hold a two-d dataset and the description of that dataset. ; ; CATEGORY: ; Wavelets ; ; CALLING SEQUENCE: ; WREADIMG, dtype, st, len, wd, image ; ; INPUTS: ; st = a string that directly relates to the ; two files we will open: ; st+'.asc' = the data file ; st+'.doc' = the documentation file ; wd = the working directory ; len = the square size of the image ; dtype = 1(given) or 2(user-defined); ; ;OUTPUTS: ; len = the length of the data image ; Prints out the contents of the st+'.doc' file to ; the screen. ; image = image array to be plotted ; ; EXAMPLE: ; To read a user defined Image dataset (2) with 'st' as the file ; identifier (e.g. st='phone'), and working directory wd (string) ; Type: ; ; IDL> WREADIMG, 2, st, len, wd, image ; ; The output will len = length on a side and image array in addition ; to plot in window. ; ; MODIFICATION HISTORY: ; Written by: Amara Graps September 1995 ; copyright (c) Amara Graps 1995, 1996. ;- ;Read dataset ;Don't need to know delim after all ;tos = STRUPCASE(STRTRIM(!version.os,2)) ;CASE tos OF ; 'MACOS': delim = ':' ; 'UNIX': delim = '/' ;<- verify ; 'WINDOW': delim = '\' ;<- verify ; 'VMS': delim = '' ;<- verify! ;(Note: I'm assuming VMS DEVICE:[NAME.DIR] has been set) ;ENDCASE CD, wd ;change user to working directory ;change user to data directory CASE dtype OF ;change user to specified data directory 1: CD, 'twoddata' 2: CD, 'u2ddata' ENDCASE ;Open data documentation file GET_LUN,alun flname = STRLOWCASE(st)+'.doc' ;Now read OPENR, alun, flname ;Read length of dataset (first row) len = 0 READF, alun, len ;Read and print rest of contents a = ' ' WHILE not(eof(alun)) DO BEGIN READF, alun, a txt = STRTRIM(a,2) PRINT, txt END CLOSE, alun FREE_LUN, alun ;Open data file GET_LUN,alun ;get logical unit number flname = STRLOWCASE(st)+'.raw' OPENR, alun, flname ;Read data file msg = 'Reading '+st+' File. a = ASSOC(alun, BYTARR(len, len)) image = a(0) CLOSE, alun FREE_LUN, alun CD, wd end ;of procedure WREADIMG ;****************************************************************************