! ! 1.1 Open the file if (FILE_NAME.ne."not yet defined") then sic\sic user if ("'sys_info'".eq."observer") then sys "~observer/.set_project "'file_name' @ "/users/oper/observer/set_project.clic" endif on error FILE BO "!"'FILE_NAME' FILE BO 'FILE_NAME' if old_file.ne.FILE_NAME then if exist(RF_USB) then DELETE /VARIABLE RF_USB RF_LSB endif if exist(amp_err) then DELETE /VARIABLE AMP_ERR endif if exist(pha_err) then DELETE /VARIABLE PHA_ERR endif IF (EXIST(JYPK)) THEN DELETE /VARIABLE JYPK ENDIF IF (EXIST(CEFF)) THEN DELETE /VARIABLE CEFF ENDIF endif LET OLD_FILE 'FILE_NAME' else SAY "E-SELECT2, Please define the file name (Press FILE or LET FILE_NAME)" return endif SET TIME * ! ! 1.2 Define additional parameters ! SIC PREC DOUBLE ! ! Reset CLIC defaults ! SET DEFAULT set flux all /reset set quality 'min_qual' if do_atm then set phase atm else set phase noatm endif set level 6 set receiver * SET PHAS ANTENNA ABS SET RF ANTENNA OFF SET AMPL ANTENNA ABS SET PHAS CONTINUOUS SET PLOT BAR IF (EXIST(first_scan)) THEN DELETE /VARIABLE BAND_SOURCE FIRST_SCAN LAST_scan CAL_BAND - b_flux fhii frghz ENDIF define integer ir DEFINE INTEGER FIRST_scan LAST_scan /GLOBAL DEFINE CHARACTER CAL_BAND*3[2] BAND_SOURCE*12 /GLOBAL define double b_flux[2] fhii[2,2] frghz[2] /global DEFINE INTEGER FSCAN ! IF (.NOT.EXIST(NBAS)) THEN VARIABLE CONFIG ON ENDIF IF (.NOT.EXIST(IN_FILE)) THEN VARIABLE READ_WRITE ON ENDIF IF (.NOT.EXIST(N_LINE_BANDS)) THEN VAR LINE ON ENDIF IF (.NOT.EXIST(FLUX)) THEN VAR POSITION ON ENDIF IF (.NOT.EXIST(ISB)) THEN VAR RF ON ENDIF IF (.NOT.EXIST(GAIN_IMAGE)) THEN VAR ATM ON ENDIF IF (.NOT.EXIST(PROJECT)) THEN VAR GENE ON ENDIF IF (.NOT.EXIST(NREC_MON)) THEN VARIABLE MONITOR ON ENDIF ! SET AVER SCAN ! ! Check receivers ! ! patch for let receiver 1 instead of 1 0 ... ! if irec[2].eq.irec[1] then let irec[2] 0 endif ! for kr 1 to 2 let ir irec[kr] if ir.gt.0 then set rece ir FIND /type 'caltype' /proc corr if found.eq.0 then say "No data from receiver "'ir'": Please redefine the receivers" say "Use 1 0 (or 2 0) for only one receiver." return endif endif NEXT ! ! 2 --- Define the subbands ! SET SCAN SCAN_RANGE[1] SCAN_RANGE[2] FIND GET FIRST /header SET BASE ALL set sub all if .not.exist(rf_usb) then DEFINE REAL RF_USB[2,NBAS,2] RF_LSB[2,NBAS,2] /GLOBAL endif if .not.exist(amp_err) then DEFINE REAL AMP_ERR[NBAS,2] /GLOBAL endif if .not.exist(PHA_ERR) then define real PHA_ERR[NBAS,2] /GLOBAL endif if .not.exist(jypk) then DEFINE double JYPK[NANT,2] /GLOBAL endif if .not.exist(ceff) then DEFINE double CEFF[NANT,2] /GLOBAL endif ! ! Find previous results if any ! if do_recover then on error continue @ 'short_file' on error endif set quality 'min_qual' if do_atm then set phase atm else set phase noatm endif ! ! 3 --- Find the useful range ! set sort scan set rece * def integer i1 i2 let first_scan scan_range[1] let last_scan scan_range[2] ! ! Force the first useful scan to be the one following the last GAIN scan: ! find /proc gain if found.ne.0 then get cx_num[1] /header let i1 scan get cx_num[found] /header let i2 scan let first_scan max(i2+1,scan_range[1]) if scan_range[2].eq.10000 then let last_scan min(scan_range[2],mod(i2+3000,9999)+1) endif ! ! override 10000 or 0 if the other limit has been specified. else if (first_scan.gt.0).and.(last_scan.eq.10000) then let last_scan mod(first_scan+3000,9999)+1 else if (first_scan.eq.0).and.(last_scan.lt.10000) then let first_scan mod(last_scan+7000,9999)+1 endif ! ! get the actual limits ! find /scan first_scan last_scan /type * get cx_num[1] /header let first_scan scan get cx_num[found] /header let last_scan scan say first_scan last_scan say 'first_scan' 'last_scan' ! ! -- useful observations ignored ? set sort receiver fin /scan last_scan+1 first_scan-1 /proc corr /type o if (found.ne.0) then say " " say "W-SELECT: ignoring source scans:" list /short get cx_num[1] /header let i1 scan get cx_num[found] /header let i2 scan if (i1.gt.scan_range[1]).or.(i2.lt.scan_range[2]) then say " _ There are probably too many GAIN scans:" say " if significant source scans are ignored, then the last GAIN scans " say " should be ignored (use STORE QUALITY); or may be should the data " say " be split into two parts." say " [type C to Continue]" say " " stop endif endif set scan first_scan last_scan say " " say "Useful scan range is from " 'first_scan' to 'last_scan' set sort receiver ! ! 4 --- Find the bandpass calibrator ! say " " SAY "Building the Flux list..." FIND /SOURCE * /TYPE 'caltype' /PROC CORR FIND append /PROC CORR /TYPE O /SOURCE MWC349 FIND append /PROC CORR /TYPE O /SOURCE CRL618 LIST /SOURCE if n_source.le.0 then say "No calibrators" return endif if .not.exist(n_cals) then def integer n_cals /global endif if n_source.ne.n_cals then let n_cals n_source if exist(rdi_flux) then del /var rdi_flux cal_source cal_flux in_flux fix_flux endif define double rdi_flux[n_source,2] cal_flux[n_source,2] - in_flux[n_source,2] /global define logical fix_flux[n_source,2] /global def char cal_source*20[n_source] /global let fix_flux NO let in_flux 0 endif for i 1 to n_source for kr 1 to 2 let ir irec[kr] if irec[kr].gt.0 then set rece irec[kr] FIND /SOURCE 'C_SOURCE[I]' /PROC CORR GET FIRST /header LET rdi_FLUX[I,ir] 0.001*nint(1000.*abs(FLUX)) let frghz[ir] frequency|1000. LET cal_source[I] 'C_SOURCE[I]' endif next NEXT let in_flux rdi_flux LET B_FLUX 0 let ir irec[1] FOR I 1 TO N_SOURCE SAY "Source " 'I' 'cal_SOURCE[I]' " Fluxes " - rdi_FLUX[i,1] rdi_FLUX[i,2] " Jy" /format a i2 a12 a f6.2 f6.2 a IF (rdi_FLUX[i,ir].GT.B_FLUX[ir]) THEN LET BAND_SOURCE 'C_SOURCE[I]' LET B_FLUX rdi_FLUX[i,1] rdi_FLUX[i,2] ENDIF NEXT SAY " " SAY "Found Bandpass Calibrator "'BAND_SOURCE' DEFINE REAL A for kr 1 to 2 let ir irec[kr] if irec[kr].gt.0 then ! if frghz[ir].lt.150. then let fhii[1,ir] 1.55 else let fhii[1,ir] 2.00 endif !RL 25-feb-1998 let fhii[2,ir] 0.01*nint(155.*(frghz[ir]|227.)^0.6) let fhii[2,ir] 0.01*nint(95.*(frghz[ir]|87.)^0.6) !RL 25-feb-1998! ! set rece irec[kr] FIND /SOURCE 'band_source' /PROC CORR !! POIN FOCU get f /header let a 10. for i 1 to nant let a min(a,gain_image[i]) next IF (A.LT.0.2) THEN IF (ISB.EQ.-1) THEN ! Signal == LSB LET CAL_BAND[ir] LSB ELSE LET CAL_BAND[ir] USB ENDIF ELSE LET CAL_BAND[ir] DSB ENDIF SAY " " SAY 'CAL_BAND[ir]'" tuning for receiver "'ir' endif next