; ;========================================================================== ; ; FILE: uf_read_dwell.pro ; ; USAGE: UF_read_dwell, unit, ufbuf, /RDSS ; ARGUMENTS: unit Logical unit number for input UF file ; ufbuf An array of UF words (IDL integers) for one dwell ; /RDSS Optional keyword for NCAR RDSS style files ; ; ABSTRACT: Read current dwell in UF format from a disk file into an IDL ; array. Note that Universal Format assumes unit origin indexing ; whereas IDL prefers zero origin indexing. ; The easiest way to deal with this is to create an IDL array ; one element larger than required, and load the UF data ; beginning at IDL element zero. Therefore, the first element ; in the array is never accessed. ; WARNING: Sizing the UF array in IDL will give a misleading number ; ; AUTHOR: I. Jeff Caylor ; Science Systems and Applications, Inc. ; 5900 Princess Garden Parkway, Suite 300 ; Lanham, MD 20706 ; ; at: NASA Goddard Space Flight Center ; Code 912 ; Greenbelt, MD 20771 ; Voice: (301) 286-3767 ; Fax: (301) 286-1762 ; Email: jeff.caylor@gsfc.nasa.gov ; ; CREATED: 17 March 1995 ; ; MODIFIED: 12 March 1996 - IJC ; Added hdr2 test and also the dwell size fix for WSR-88D files ; ;========================================================================== ; ; ; Read a dwell (beam) of UF data ; PRO UF_read_dwell, infile, dwell, RDSS=RDSS IF KEYWORD_SET(RDSS) THEN BEGIN hdr1 = 0L READU, infile, hdr1 ; ; There is sometimes a pair of zeros at the end of the WSR-88D ; files generated by nex2uf ; IF hdr1 EQ 0 THEN BEGIN READU, infile, hdr2 IF hdr1 EQ hdr2 THEN RETURN ENDIF ENDIF ; Read UF code UFword1 = 0 READU, infile, UFword1 byteorder, hdr1, /swap_if_little_endian ; 21830 is the numeric value of the "UF" ID string IF (UFword1 EQ 21830) THEN BEGIN ; Read number of words in the beam UFword2 = 0 READU, infile, UFword2 byteorder, hdr1, /swap_if_little_endian ; ; This is a fix for the Level II WSR-88D UF files generated by nex2uf ; For some reason, the dwell size in the mandatory header is wrong ; on occasion but the header size is correct.....go figure ; IF KEYWORD_SET(RDSS) THEN UFword2 = FIX(hdr1 / 2) ; ; Build an array tmp = INTARR(UFword2 - 2) READU, infile, tmp sdwell = size(dwell) IF NOT (sdwell(1) EQ (UFword2 + 1) ) THEN $ dwell = INTARR(UFword2 + 1) dwell(0) = 0 ; This array element is never accessed dwell(1) = UFword1 dwell(2) = UFword2 dwell(3:*) = tmp IF KEYWORD_SET(RDSS) THEN BEGIN hdr2 = 0L READU, infile, hdr2 IF hdr1 NE hdr2 THEN print, '**** UF-ERROR **** Header size mismatch' ENDIF ENDIF ELSE begin print, '**** UF-ERROR **** This is not a UF file' stop end RETURN END