function rsl_nsig_scanmode, nsig_file ;+ ; Return a string containing the scan mode for the Sigmet raw file. ; ; Syntax: ; result = rsl_nsig_scanmode(nsig_file) ; ; Input argument: ; nsig_file: The name of the Sigmet raw file. ; ; Return value: ; One of the following strings is returned: ; 'PPI Sector' ; 'RHI' ; 'Manual' ; 'PPI Continuous' ; 'File controlled' ; In the case of an error, the empty string ('') is returned. ; ; Written by Bart Kelley, SSAI, September 2, 2014 ;- catch, errcode if errcode ne 0 then begin catch, /cancel print,!error_state.msg_prefix+!error_state.msg if !error_state.sys_msg ne '' then print, ' '+!error_state.sys_msg if n_elements(iunit) gt 0 then begin fs = fstat(iunit) if fs.open then free_lun, iunit endif return, '' endif iunit = rsl_open_radar_file(nsig_file, error=error) if error then return, '' ; Read first 2 bytes and test to determine nsig version. ; If not Sigmet raw file, issue error and return. nsigid = bytarr(2) readu, iunit, nsigid if (nsigid[0] eq 0 and nsigid[1] eq 27) or $ (nsigid[0] eq 27 and nsigid[1] eq 0) then nsig_ver = 2 $ else if (nsigid[0] eq 7 and nsigid[1] eq 0) or $ (nsigid[0] eq 0 and nsigid[1] eq 7) then nsig_ver = 1 $ else message, 'First two bytes of file do not contain valid Sigmet ID' point_lun, iunit, 0 ; rewind file ; Define version dependent structures. if nsig_ver eq 2 then nsig_v2_define_structs else nsig_v1_define_structs ; Determine if byte-swapping is needed. This is necessary if data was ; written on a machine with different endian than current one. big_endian_data = nsigid[0] eq 0 and nsigid[1] gt 6 big_endian_1 = bytarr(4) big_endian_1[3] = 1 big_endian_machine = long(big_endian_1,0) eq 1L needswap = big_endian_data xor big_endian_machine ; Read header records (first 2 records). product_hdr = {nsig_record1} readu, iunit, product_hdr ingest_hdr = {nsig_record2} readu, iunit, ingest_hdr free_lun, iunit ; Byte-swap 2-byte words in headers. if needswap then begin byteorder, product_hdr, /sswap byteorder, ingest_hdr, /sswap endif scan_mode = ingest_hdr.task_config.scan_info.ant_scan_mode scan_label = ['Invalid','PPI Sector','RHI','Manual','PPI Continuous', $ 'File controlled'] return, scan_label[scan_mode] end