SUBROUTINE DATPOL (IA1, IA2, TIME, VIS, IERR) C----------------------------------------------------------------------- C! Apply polarization corrections to data. C# Calibration C----------------------------------------------------------------------- C; Copyright (C) 1995-1998, 2007, 2010, 2012-2014, 2017-2018 C; Associated Universities, Inc. Washington DC, USA. C; C; This program is free software; you can redistribute it and/or C; modify it under the terms of the GNU General Public License as C; published by the Free Software Foundation; either version 2 of C; the License, or (at your option) any later version. C; C; This program is distributed in the hope that it will be useful, C; but WITHOUT ANY WARRANTY; without even the implied warranty of C; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the C; GNU General Public License for more details. C; C; You should have received a copy of the GNU General Public C; License along with this program; if not, write to the Free C; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, C; MA 02139, USA. C; C; Correspondence concerning AIPS should be addressed as follows: C; Internet email: aipsmail@nrao.edu. C; Postal address: AIPS Project Office C; National Radio Astronomy Observatory C; 520 Edgemont Road C; Charlottesville, VA 22903-2475 USA C----------------------------------------------------------------------- C Applies polarization correction to data. This operation is only C really defined if KNCOR = 4. However, it will also apply the C parallel hand corrections if KNCOR = 2. C Inputs: C IA1 I First antenna number C IA2 I Second antenna number C TIME R Time in days; used for parallactic angle. C Inputs from common in DSEL.INC C PARTIM R Time of current parallactic angles. C PARAGL R(2,*) Cos and sin of the parallactic angles of C antennas. C PARSOU I Source ID for current parallactic angles. C IFR R(*) Ionospheric Faraday RM for each antenna C LAMBDA R(*) Wavelength of each channel and IF C STNPST C*8 Polarization model type NOW IGNORED C SOLTYP I Model type numeric code NOW USED (from POLSET) C POLCAL R(2,*) Polarization correction C Values in order: C By baseline C By IF (EIF-BIF+1) C A 4x4 complex matrix to be multiplied by C the observed polarization vector C (RR,LL,RL,LR or XX,YY,XY,YX) to produce C the corrected data. C Indexing scheme: an entry defined by ant1 2 check for C any missing correlations IF ((MOD(DOPOL,10).EQ.3) .OR. (MOD(DOPOL,10).EQ.8)) THEN LIMIT = 2 * KNCOR DO 100 IPOL = 1, LIMIT, 2 IF (VIS(JOFF+OFF2(IPOL)+2).LE.0.0) WFLAG = .TRUE. 100 CONTINUE END IF C Check for blanked IFR IF ((IFR(IA1).EQ.FBLANK) .OR. (IFR(IA2).EQ.FBLANK)) THEN WFLAG = .TRUE. END IF C Flag all output data if C both par. hands missing or C (DOPOL > 2) and any polzn. C correlations are missing. C Also flag output data if C IFR corrections are blanked IF (WFLAG) THEN LIMIT = 2 * KNCOR DO 120 IPOL = 1, LIMIT, 2 VIS(JOFF+OFF2(IPOL)+2) = 0.0 120 CONTINUE END IF C Save old data LIMIT = 8 * KNCOR DO 150 IPOL = 1,LIMIT JNDEX = JOFF + OFF(IPOL) VTEMPX(IPOL) = VIS(JNDEX) 150 CONTINUE C Clear XTEMP (in case KNCOR < 4) CALL RFILL (2*16, 0.0, XTEMP) C Matrix x vector multiply PP = BLPNT + PPOLCL LIMIT = 4 * KNCOR CALL RCOPY (2*LIMIT, POLCAL(PP), PDBG) DO 200 IPOL = 1,LIMIT IF ((POLCAL(PP).NE.FBLANK) .AND. * (POLCAL(PP+1).NE.FBLANK)) THEN XTEMP(1,IPOL) = VTEMP(1,IPOL) * POLCAL(PP) - * VTEMP(2,IPOL) * POLCAL(PP+1) XTEMP(2,IPOL) = VTEMP(1,IPOL) * POLCAL(PP+1) + * VTEMP(2,IPOL) * POLCAL(PP) ELSE XTEMP(1,IPOL) = FBLANK XTEMP(2,IPOL) = FBLANK END IF PP = PP + 2 200 CONTINUE IF (PDVER.GT.0) BLPNT = BLPNT + 32 C sum INDEX = 1 LIMIT = KNCOR * 2 DO 250 IPOL = 1,LIMIT INDEX = ((IPOL-1)/2) + 1 IPNT = PNT(IPOL) JNDEX = JOFF + OFF2(IPOL) IF ((XTEMP(IPNT,INDEX).NE.FBLANK) .AND. * (XTEMP(IPNT,INDEX+4).NE.FBLANK) .AND. * (XTEMP(IPNT,INDEX+8).NE.FBLANK) .AND. * (XTEMP(IPNT,INDEX+12).NE.FBLANK)) THEN VIS(JNDEX) = XTEMP(IPNT,INDEX) + XTEMP(IPNT,INDEX+4) + * XTEMP(IPNT,INDEX+8) + XTEMP(IPNT,INDEX+12) ELSE VIS(JNDEX) = 0.0 VIS(JOFF+OFF2(IPOL)+2) = 0.0 END IF 250 CONTINUE C Done if 'ORI-ELI' IF (DOORI) GO TO 300 C Done if not 4 polarizations IF (KNCOR.LT.4) GO TO 300 C special for linears C DGHEAD makes DOPOL>0 C be >10 for linear input IF (DOPOL.GT.10) GO TO 300 IF (ICOR0.LT.-4) GO TO 300 C PARALLACTIC angle GR = PARAGL(1,IA1) * PARAGL(1,IA2) - PARAGL(2,IA1) * * PARAGL(2,IA2) GI = PARAGL(1,IA1) * PARAGL(2,IA2) + PARAGL(2,IA1) * * PARAGL(1,IA2) C Correct RL,LR for parallactic C angle and ionospheric Faraday C rotation: LOFF = (IIF - 1) * NLAMDA + IFQ GR1 = GR * COS (LAMBDA(LOFF)**2 * (IFR(IA1) + IFR(IA2))) - * GI * SIN (LAMBDA(LOFF)**2 * (IFR(IA1) + IFR(IA2))) GI1 = GI * COS (LAMBDA(LOFF)**2 * (IFR(IA1) + IFR(IA2))) + * GR * SIN (LAMBDA(LOFF)**2 * (IFR(IA1) + IFR(IA2))) C Correct RL IPNT = 5 TR = VIS(JOFF+OFF2(IPNT)) TI = VIS(JOFF+OFF2(IPNT+1)) VIS(JOFF+OFF2(IPNT)) = TR * GR1 + TI * GI1 VIS(JOFF+OFF2(IPNT+1)) = TI * GR1 - TR * GI1 C Correct LR IPNT = 7 TR = VIS(JOFF+OFF2(IPNT)) TI = VIS(JOFF+OFF2(IPNT+1)) VIS(JOFF+OFF2(IPNT)) = TR * GR1 - TI * GI1 VIS(JOFF+OFF2(IPNT+1)) = TI * GR1 + TR * GI1 300 CONTINUE 400 CONTINUE C 999 RETURN END