[daip] CALIB problems ( + CLBPA )

Olaf Wucknitz wucknitz at astro.uni-bonn.de
Fri Aug 29 07:57:50 EDT 2008


Hi there,

yesterday I ran into some problems with CALIB in a case where many solutions
failed. For the final data analysis, I will use different parameters so that
CALIB succeeds, but the problems are nevertheless relevant in more general
cases.

I am using 31DEC08 with the latest MNJ done a few days ago.


1. AVERAGING OF POLARISATIONS
=============================

When using aparm(3)=1 [ AVGPOL=TRUE in CALIB.FOR and IC=0 in CALIB.FOR and
CLBPA.FOR ] to average LL+RR, I found that sometimes failed solutions
are noted only for the first polarisation but are not propagated to the
second.


[ additional minor issue: a comment in line 3162 of CALIB.FOR refers to CLNPA
which should probably read CLBPA ]


According to my (maybe incompetent) analysis, the reason lies in CLBPA.FOR

If the solution fails completely, the following lines set the weight to
negative. [ The gain itself is already initialised as FBLANK. ]

line 246 and following:

C                                       Solution failed
               IF (IERR.NE.0) THEN
                  TEMP = -1.0
                  IF (IERR.EQ.1) TEMP = -2.0
                  DO 100 IANT = 1,NUMANT
                     CWT(IST,CIF,IANT) = TEMP
 100                 CONTINUE
                  GO TO 500
                  END IF


If Stokes LL+RR are averaged, however, the block starting at line 284 
propagates the common solution (assigned to Stokes 1) to Stokes 2:

C                                       IC=0 means Stokes' averaged.
            IF (IC.EQ.0) THEN
               DO 160 IANT = 1,NUMANT
                  CREAL(2,CIF,IANT) = CREAL(1,CIF,IANT)
                  CIMAG(2,CIF,IANT) = CIMAG(1,CIF,IANT)
                  CWT(2,CIF,IANT) = CWT(1,CIF,IANT)
 160              CONTINUE
               REFAN(2,CIF) = REFAN(1,CIF)
               END IF
 500        CONTINUE


The problem here is that the "Solution failed" GO TO above jumps to line 500
and skips this Stokes 1->2 copy.
I suggest to modify these two blocks like follows:

C                                       Solution failed
               IF (IERR.NE.0) THEN
                  TEMP = -1.0
                  IF (IERR.EQ.1) TEMP = -2.0
                  DO 100 IANT = 1,NUMANT
                     CWT(IST,CIF,IANT) = TEMP
 100                 CONTINUE
                  GO TO 155
                  END IF


and the second:

 155        CONTINUE
C                                       IC=0 means Stokes' averaged.
            IF (IC.EQ.0) THEN
               DO 160 IANT = 1,NUMANT
                  CREAL(2,CIF,IANT) = CREAL(1,CIF,IANT)
                  CIMAG(2,CIF,IANT) = CIMAG(1,CIF,IANT)
                  CWT(2,CIF,IANT) = CWT(1,CIF,IANT)
 160              CONTINUE
               REFAN(2,CIF) = REFAN(1,CIF)
               END IF
 500        CONTINUE


In this way the values (which are FBLANK for the gain and negative for the
weight in this case) are still copied even for failed solutions.



2. Counting good and bad solutions
==================================

This does not really cause a problem for me at the moment. Still I am not sure
if the following bit of code in CALIB.FOR is correct. Starting at line 3231 we
find:


C                                       Count good and bad solns
            IF (GOTANT(IANT)) THEN
               IF (CWT(1,IIF,IANT).GE.SNRMIN) THEN
                  CNTOK = CNTOK + 1
               ELSE IF ((ABS (CWT(1,IIF,IANT)).LT.0.1) .AND.
     *            (CWT(1,IIF,IANT).NE.0.0)) THEN
                  CNTFEW = CNTFEW + 1
               ELSE IF (CWT(2,IIF,IANT).GT.-1.1) THEN
                  CNTBAD = CNTBAD + 1
                  END IF
C                                       Second poln.
               IF (NUMPOL.GT.1) THEN
                  IF (CWT(2,IIF,IANT).GE.SNRMIN) THEN
                     CNTOK = CNTOK + 1
                  ELSE IF ((ABS (CWT(2,IIF,IANT)).LT.0.1) .AND.
     *               (CWT(2,IIF,IANT).NE.0.0)) THEN
                     CNTFEW = CNTFEW + 1
                  ELSE IF (CWT(2,IIF,IANT).GT.-1.1) THEN
                     CNTBAD = CNTBAD + 1
                     END IF
                  END IF
               END IF

So this seems to count for Stokes=1 and then for Stokes=2, but the Stokes
numbers are not entirely consistent. The last comparison in the first block
actually refers to Stokes 2 instead of 1.



3. SETTING BAD SOLUTIONS TO (1,0)
=================================

With APARM(9)=1 [ DOPASS=TRUE in CALIB.FOR ]  I can ask CALIB to set bad
solutions to unity. I know one should be very careful with this, but in my
particular case it makes sense to use it.

This is done in lines 3253 and following in CALIB.FOR :


C                                       Keep bad solutions?
            IF (DOPASS) THEN
               IF (CWT(1,IIF,IANT).LT.SNRMIN) THEN
                  CREAL(1,IIF,IANT) = 1.0
                  CIMAG(1,IIF,IANT) = 0.0
                  CWT(1,IIF,IANT) = 1.0
                  END IF
               IF (CWT(2,IIF,IANT).LT.SNRMIN) THEN
                  CREAL(2,IIF,IANT) = 1.0
                  CIMAG(2,IIF,IANT) = 0.0
                  CWT(2,IIF,IANT) = 1.0
                  END IF
               END IF

First question: Should one not in the second block ask if there are two
polarisations at all (NUMPOL.GT.1) ? Maybe doing pol 2 does not hurt, even
if it does not exist.


But the real problem here has to do with the special treatment for the
reference antenna. Here the weights are set to SNRMIN+1 if they are not
already above that value. Since the gains themselves are still at FBLANK, this
probably does not affect the calibration later, but the DOPASS block above
does not work anymore, because failed solutions are no longer noticed from
their weights. Still it means that bad solutions will have weights > SNRMIN.


The reference antenna stuff starts at line 3213 in CALIB.FOR :

C                                       Loop over antennae
      DO 420 IANT = 1,NUMANT
         DO 410 IIF = 1,NUMIF
C                                       Keep track of reference ants
            IREF = REFAN(1,IIF)
            IF ((IREF.GT.0) .AND. (IREF.LE.NUMANT)) THEN
               REFUSE(IREF) = REFUSE(IREF) + 1
C                                       Deal with ref SNR
               IF (CWT(1,IIF,IREF).LT.(SNRMIN+1.0))
     *            CWT(1,IIF,IREF) = SNRMIN + 1.0
               END IF
C                                        Second polarization
            IREF = REFAN(2,IIF)
            IF ((IREF.GT.0) .AND. (IREF.LE.NUMANT)) THEN
               REFUSE(IREF) = REFUSE(IREF) + 1
               IF (CWT(2,IIF,IREF).LT.(SNRMIN+1.0))
     *            CWT(2,IIF,IREF) = SNRMIN + 1.0
               END IF


I don't entirely understand why the weights are modified at all, nor why this
is done within the IANT do loop (the IIF loop is obviously needed).

In any case it screws up the DOPASS bit (that is what caused my current
problem) and probably also the counting of good and bad solutions.

If setting the weights to SNRMIN+1 is really required, a naive solution would
be to do the DOPASS thing first, before the reference-antenna stuff. But I am
not sure about any side effects of that.



I hope these comments help to fix the problems without too much trouble.
In my current case the suggested patches did help.


Cheers,
Olaf




More information about the Daip mailing list