function proc2, fnum, len, offset SPAWN, 'ls mcords.rec009*', txt OPENR, lun, txt[fnum], /GET_LUN POINT_LUN, lun, 0 ;find first four headers mcd = ['DE'XB,'AD'XB,'BE'XB,'EF'XB] tmp = BYTARR(4) ind = ULONARR(10) cnt = 0 i = 0L WHILE (cnt LT 10) DO BEGIN POINT_LUN, lun, i READU, lun, tmp IF TOTAL(tmp EQ mcd) EQ 4 THEN BEGIN ind[cnt] = i cnt = cnt + 1 ENDIF i = i + 1 ENDWHILE nbytes = ind[1]-ind[0] POINT_LUN, lun, ind[0]+LONG(nbytes)*LONG(offset) ;determine number of waveforms in the file finfo = FSTAT(lun) nrec = (finfo.size-ind[0])/nbytes ;define template npts = nbytes/2-80-24 ;print, npts temp = REPLICATE({magic:0UL, $ version:0UL, $ seconds:0UL, $ fractions:0UL, $ epri:0UL, $ temp:UINTARR(70), $ wave:UINTARR(npts+24)},len); just do len (really should nrec) readu,lun, temp CLOSE, lun FREE_LUN, lun ;reformat data (config file specific - 16 waveforms) w00 = swap_endian(temp.wave[0:2775])-8192.0 w01 = swap_endian(temp.wave[2777:9440])-8192.0 w02 = swap_endian(temp.wave[9442:12216])-8192.0 w03 = swap_endian(temp.wave[12218:18883])-8192.0 iout = where(abs(w03) GT 1000, count) if count GT 0 then w03(iout) = 0; ; window, 0, xs=1600, ys=500, retain=2 ; tvscl, 20*alog10(congrid(abs(w01[2000:*,*]-mean(w01[2000:*,*])),1600,500)+200) RETURN, w03 END