pro tpcal_add2m,filename restore,filename nf = 86 ; Read in the existing TPCAL record from the EPHEM directory openr,lun,/get_lun,!defaults.ephemdir+'tpcal.rec' a = assoc(lun,intarr(1024)) data = a(0) data2 = a(1) free_lun,lun ; Fill in record tls02m = tl_encode(tls) data[24:35] = tls02m ; Time/Label field of 2-m data epoch h_all = findgen(nf)+5 h = nint(f*5) ; Loop over frequency, scaling the TP and RMS data to the ND_eff value and ; converting to units of 1/10 of a unit/SFU. Replace all bad (-99) data ; with 'FFFF'x for i = 0, 48 do begin j = where(h eq h_all[i],h_exists) if (h_exists eq 0) then begin tpdat = ['FFFF'x,'FFFF'x,'FFFF'x] endif else begin bad = where(cal[*,j] lt 0,nbad) tpdat = uint(reform(cal[*,j]>0)*100.) if (nbad gt 0) then tpdat(bad) = 'FFFF'x endelse tprmsdat = ['FFFF'x,'FFFF'x,'FFFF'x] ; TPDAT now contains the 3 scaled calibration factors for feeds 4I, 5I, and 6I. ; not yet-->TPRMSDAT now contains the 4 scaled rms values corresponding to these feeds. ; To get back the actual calibration factors in units/SFU, read the byte data, ; square it, and multiply by 0.1. ; Pack the results for the 2-m telescopes into the data record words. The bytes ; are packed in inverse order to match what comes from the FORTH system on the CPC. wrdoff = 36 + i*20 data[wrdoff+4] = tpdat data[wrdoff+14] = tprmsdat endfor for i = 49, nf-1 do begin j = where(h eq h_all[i],h_exists) if (h_exists eq 0) then begin tpdat = ['FFFF'x,'FFFF'x,'FFFF'x] endif else begin bad = where(cal[*,j] lt 0,nbad) tpdat = uint(reform(cal[*,j]>0)*100.) if (nbad gt 0) then tpdat(bad) = 'FFFF'x endelse tprmsdat = ['FFFF'x,'FFFF'x,'FFFF'x] ; TPDAT now contains the 3 scaled calibration factors for feeds 4I, 5I, and 6I. ; not yet-->TPRMSDAT now contains the 4 scaled rms values corresponding to these feeds. ; To get back the actual calibration factors in units/SFU, read the byte data, ; square it, and multiply by 0.1. ; Pack the results for the 2-m telescopes into the data record words. The bytes ; are packed in inverse order to match what comes from the FORTH system on the CPC. wrdoff = 12 + (i-49)*20 data2[wrdoff+4] = tpdat data2[wrdoff+14] = tprmsdat endfor spawn,'del '+!defaults.ephemdir+'tpcal.old' spawn,'ren '+!defaults.ephemdir+'tpcal.rec '+!defaults.ephemdir+'tpcal.old' ; Write out new TPCAL record into the EPHEM directory openw,lun,/get_lun,!defaults.ephemdir+'tpcal.rec' a = assoc(lun,intarr(1024)) a(0) = data a(1) = data2 free_lun,lun return en