; This IDL program lists the scan numbers and observed object names from ; all of the files under /home/gbtdata for the specified project ID and ; device. The default device is the spectral processor. The default ; output is stdout, but the output may be directed to a file named in the ; third argument. ; To run from the IDL prompt: ; IDL> list_scans, 'AGBT02A_069_01' ; IDL> list_scans, 'AGBT02A_069_01', 'Antenna' ; IDL> list_scans, 'AGBT02A_069_01', out_file='testlist pro list_scans, project, device, out_file if N_params() LT 3 then begin out_file = '' endif if N_params() LT 2 then begin device = 'SpectralProcessor' endif ; assemble the directory path name and get a list of file names path = '/home/gbtdata/' + project + '/' + device SPAWN, 'ls ' + path, ls sz = SIZE(ls) if sz(1) LE 1 then begin return endif file_num = 0 ; if file output has been requested, open the file if out_file NE '' then begin GET_LUN, fd OPENW, fd, out_file endif ; step through every file in the list for fn = 0, sz(1) - 1, 1 do begin ; if it's not a FITS file, skip it if (STRPOS(ls(fn), 'fits') GT 0) then begin file_num = file_num + 1 fpn = path + '/' + ls(fn) ; open the file main header to the fitsio access mhdr = HEADFITS(fpn, EXTEN=0) ; retrieve the SCAN and OBJECT keyword values in the main header scan = fxpar(mhdr, 'SCAN') object = fxpar(mhdr, 'OBJECT') if (scan EQ 0) then GOTO, endloop ; if it's a spectral pocessor FITS file, skip to the second and ; fourth HDU's, and pick up the number of receivers and number ; of records (integrations) in the data table if device EQ 'SpectralProcessor' then begin fxbopen, t1, fpn, 1, ehdr num_rcvrs = fxpar(ehdr, 'NAXIS2') fxbclose, t1 fxbopen, t1, fpn, 3, ehdr num_records = fxpar(ehdr, 'NAXIS2') fxbclose, t1 ; assemble the output string line = ('Scan ' + STRTRIM(STRING(scan), 2) + ' ' + $ STRTRIM(object, 2) + ' - ' + $ STRTRIM(STRING(num_rcvrs), 2) + ' receivers ' + $ STRTRIM(STRING(num_records), 2) + ' records') endif else begin line = 'Scan ' + STRTRIM(STRING(scan), 2) + STRTRIM(object, 2) endelse ; print or write the output line if (out_file EQ '') then begin print, line endif else begin printf, fd, line endelse endif endloop: ; repeat until no more files endfor ; Tell how many FITS files and files of all sort were found in this ; directory print, STRTRIM(STRING(file_num), 2) + ' FITS files in this directory' print, 'Total number of files: ' + STRTRIM(STRING(sz(1)), 2) ; if necessary, close the output file if (out_file NE '') then begin close, fd endif end