Пример #1
0
def imhead(ObitObj):
    """
    List header

    * ObitObj    = Obit or ParselTongue data object
    """
    ################################################################
    if ObitObj.__class__ == AIPSData.AIPSImage:
        # AIPS Image
        tmp = Image.newPAImage("AIPS Image",ObitObj.name, ObitObj.klass, ObitObj.disk, \
                               ObitObj.seq, True, err)
        tmp.Header(err)
        del tmp
    elif ObitObj.__class__ == FITSData.FITSImage:
        # FITS Image
        tmp = Image.newPFImage("FITS Image", ObitObj.filename, ObitObj.disk,
                               True, err)
        tmp.Header(err)
        del tmp
    elif ObitObj.__class__ == AIPSData.AIPSUVData:
        # AIPS UVData
        tmp = UV.newPAImage("AIPS UVData",ObitObj.name, ObitObj.klass, ObitObj.disk, \
                               ObitObj.seq, True, err)
        tmp.Header(err)
        del tmp
    elif ObitObj.__class__ == FITSData.FITSUVData:
        # FITS UVData
        tmp = UV.newPFImage("FITS UVData", ObitObj.filename, ObitObj.disk,
                            True, err)
        tmp.Header(err)
        del tmp
    else:
        # Presume it's an Obit object
        ObitObj.Header(err)
Пример #2
0
def window(image):
    """
    Make a window object for an image
    
    Returns OWindow object

    * image  = Obit image object
    """
    ################################################################
    if Image.IsA(image):
        # Obit/Image
        naxis = image.Desc.Dict["inaxes"][0:2]
    elif image.__class__ == AIPSData.AIPSImage:
        # AIPS Image
        tmp = Image.newPAImage("AIPS Image",image.name, image.klass, image.disk, \
                               image.seq, True, err)
        naxis = tmp.Desc.Dict["inaxes"][0:2]
        del tmp
    elif image.__class__ == FITSData.FITSImage:
        # FITS Image
        tmp = Image.newPFImage("FITS Image", image.filename, image.disk, True,
                               err)
        naxis = tmp.Desc.Dict["inaxes"][0:2]
        del tmp
    return OWindow.PCreate1("Window", naxis, err)
Пример #3
0
def imhead (ObitObj):
    """ List header

    ObitObj    = Obit or ParselTongue data object
    """
    ################################################################
    if ObitObj.__class__==AIPSData.AIPSImage:
        # AIPS Image
        tmp = Image.newPAImage("AIPS Image",ObitObj.name, ObitObj.klass, ObitObj.disk, \
                               ObitObj.seq, True, err)
        tmp.Header(err)
        del tmp
    elif ObitObj.__class__==FITSData.FITSImage:
        # FITS Image
        tmp = Image.newPFImage("FITS Image",ObitObj.filename, ObitObj.disk, True, err)
        tmp.Header(err)
        del tmp
    elif ObitObj.__class__==AIPSData.AIPSUVData:
        # AIPS UVData
        tmp = UV.newPAImage("AIPS UVData",ObitObj.name, ObitObj.klass, ObitObj.disk, \
                               ObitObj.seq, True, err)
        tmp.Header(err)
        del tmp
    elif ObitObj.__class__==FITSData.FITSUVData:
        # FITS UVData
        tmp = UV.newPFImage("FITS UVData",ObitObj.filename, ObitObj.disk, True, err)
        tmp.Header(err)
        del tmp
    else:
        # Presume it's an Obit object
        ObitObj.Header(err)
Пример #4
0
def PAllDest(disk, err, Atype="  ", Aname=None, Aclass=None, Aseq=0):
    """
    Delete selected AIPS catalog entries
    
    Entries can be selected using Atype, Aname, Aclass, Aseq,
    using AIPS wildcards
    A "?" matches one of any character, "*" matches any string
    all blanks matches anything

    * disk     = AIPS disk number, 0=>all
    * err      = Python Obit Error/message stack
    * type     = optional file type
    * Aname    = desired name, using AIPS wildcards, None -> don't check
    * Aclass   = desired class, using AIPS wildcards, None -> don't check
    * Aseq     = desired sequence, 0=> any
    * first    = optional first slot number (1-rel)
    * last     = optional last slot number
    * giveList = If true, return list of CNOs matching
    """
    ################################################################
    # Checks
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be an OErr"
    #
    if (disk < 0) or (disk > (len(AIPS.AIPS.disks) + 1)):
        raise RuntimeError, "Disk " + str(disk) + " out of range"
    # disks
    if disk > 0:
        disks = [disk]
    else:
        disks = range(1, len(AIPS.AIPS.disks))
    user = OSystem.PGetAIPSuser()
    # loop over disks
    for dsk in disks:
        ncno = PNumber(dsk, user, err)
        OErr.printErrMsg(err, "Error getting number of cnos")

        for cno in range(1, ncno):
            line = PInfo(dsk, user, cno, err)
            OErr.printErrMsg(err, "Error reading entry")
            if WantDir(line, type=Atype, Aname=Aname, Aclass=Aclass,
                       Aseq=Aseq):
                # parse directory string
                Tname = line[0:12]
                Tclass = line[13:19]
                Tseq = int(line[20:25])
                Ttype = line[26:28]
                z = None
                if Ttype == 'MA':
                    z = Image.newPAImage("Zap image", Tname, Tclass, dsk, Tseq, True, err, \
                               verbose=False)
                    print "Zap AIPS Image", Tname, Tclass, dsk, Tseq
                elif Ttype == 'UV':
                    z = UV.newPAUV("Zap UV data", Tname, Tclass, dsk, Tseq, True, err, \
                                   verbose=False)
                    print "Zap AIPS UV", Tname, Tclass, dsk, Tseq
                # Delete entry
                if z:
                    z.Zap(err)
                    del z
Пример #5
0
def getname(cno, disk=Adisk):
    """
    Return Obit object for AIPS file in cno on disk

    * cno       = AIPS catalog slot number 
    * disk      = AIPS disk number
    """
    ################################################################
    Adisk = disk
    user = AIPS.AIPS.userno
    s = AIPSDir.PInfo(disk, user, cno, err)
    OErr.printErrMsg(err, "Error with AIPS catalog")
    # parse returned string
    Aname = s[0:12]
    Aclass = s[13:19]
    Aseq = int(s[20:25])
    Atype = s[26:28]
    if Atype == 'MA':
        out = Image.newPAImage("AIPS image", Aname, Aclass, disk, Aseq, True,
                               err)
        print("AIPS Image", Aname, Aclass, disk, Aseq)
    elif Atype == 'UV':
        out = UV.newPAUV("AIPS UV data", Aname, Aclass, disk, Aseq, True, err)
        print("AIPS UV", Aname, Aclass, disk, Aseq)
    out.Aname = Aname
    out.Aclass = Aclass
    out.Aseq = Aseq
    out.Atype = Atype
    out.Disk = disk
    out.Acno = cno
    return out
Пример #6
0
def getname(cno, disk=Adisk):
    """ Return Obit object for AIPS file in cno on disk

    cno       = AIPS catalog slot number 
    disk      = AIPS disk number
    """
    ################################################################
    Adisk = disk
    user =  AIPS.AIPS.userno
    s = AIPSDir.PInfo(disk, user, cno, err)
    OErr.printErrMsg(err, "Error with AIPS catalog")
    # parse returned string
    Aname = s[0:12]
    Aclass = s[13:19]
    Aseq = int(s[20:25])
    Atype = s[26:28]
    if Atype == 'MA':
        out = Image.newPAImage("AIPS image", Aname, Aclass, disk, Aseq, True, err)
        print "AIPS Image",Aname, Aclass, disk, Aseq
    elif Atype == 'UV':
        out = UV.newPAUV("AIPS UV data", Aname, Aclass, disk, Aseq, True, err)
        print "AIPS UV",Aname, Aclass, disk, Aseq
    out.Aname  = Aname
    out.Aclass = Aclass
    out.Aseq   = Aseq 
    out.Atype  = Atype
    out.Disk   = disk
    out.Acno   = cno
    return out
Пример #7
0
def PAllDest(disk, err, Atype = "  ",  Aname=None, Aclass=None, Aseq=0):
    """ Delete selected AIPS catalog entries

    Entries can be selected using Atype, Aname, Aclass, Aseq,
    using AIPS wildcards
    A "?" matches one of any character, "*" matches any string
    all blanks matches anything
    disk     = AIPS disk number, 0=>all
    err      = Python Obit Error/message stack
    type     = optional file type
    Aname    = desired name, using AIPS wildcards, None -> don't check
    Aclass   = desired class, using AIPS wildcards, None -> don't check
    Aseq     = desired sequence, 0=> any
    first    = optional first slot number (1-rel)
    last     = optional last slot number
    giveList = If true, return list of CNOs matching
    """
    ################################################################
    # Checks
    if not OErr.OErrIsA(err):
        raise TypeError,"err MUST be an OErr"
    #
    if (disk<0) or (disk>(len(AIPS.AIPS.disks)+1)):
        raise RuntimeError,"Disk "+str(disk)+" out of range"
    # disks
    if disk>0:
        disks=[disk]
    else:
        disks= range(1,len(AIPS.AIPS.disks))
    user = OSystem.PGetAIPSuser()
    # loop over disks
    for dsk in disks:
        ncno = PNumber (dsk, user, err)
        OErr.printErrMsg(err, "Error getting number of cnos")
        
        for cno in range(1, ncno):
            line=PInfo(dsk, user, cno, err);
            OErr.printErrMsg(err, "Error reading entry")
            if WantDir(line, type=Atype, Aname=Aname, Aclass=Aclass,
                       Aseq=Aseq):
                # parse directory string
                Tname = line[0:12]
                Tclass = line[13:19]
                Tseq = int(line[20:25])
                Ttype = line[26:28]
                z = None
                if Ttype == 'MA':
                    z = Image.newPAImage("Zap image", Tname, Tclass, dsk, Tseq, True, err, \
                               verbose=False)
                    print "Zap AIPS Image",Tname, Tclass, dsk, Tseq
                elif Ttype == 'UV':
                    z = UV.newPAUV("Zap UV data", Tname, Tclass, dsk, Tseq, True, err, \
                                   verbose=False)
                    print "Zap AIPS UV",Tname, Tclass, dsk, Tseq
                # Delete entry
                if z:
                    z.Zap(err)
                    del z
Пример #8
0
 def _init(self, desc, verbose=True):
     userno = OSystem.PGetAIPSuser()
     OSystem.PSetAIPSuser(desc['userno'])
     image = Image.newPAImage(desc['name'], desc['name'], desc['klass'],
                              desc['disk'], desc['seq'], True, self.err,
                              verbose = verbose)
     OSystem.PSetAIPSuser(userno)
     if not image.isOK:  # Exception if something went wrong
         raise OErr.OErr
     OErr.printErrMsg(self.err, "Error with AIPSImage")
     return image
Пример #9
0
def tvlod(image, window=None):
    """ display image

    image  = Obit Image, created with getname, getFITS
    window = Optional window for image to edit
    """
    ################################################################
    if Image.PIsA(image):
        # Obit/Image
        ODisplay.PImage(disp, image, err, window=window)
    elif image.__class__==AIPSData.AIPSImage:
        # AIPS Image
        tmp = Image.newPAImage("AIPS Image",image.name, image.klass, image.disk, \
                               image.seq, True, err)
        ODisplay.PImage(disp, tmp, err, window=window)
        del tmp
    elif image.__class__==FITSData.FITSImage:
        # FITS Image
        tmp = Image.newPFImage("FITS Image",image.filename, image.disk, True, err)
        ODisplay.PImage(disp, tmp, err, window=window)
        del tmp
Пример #10
0
def tvlod(image, window=None):
    """
    display image

    * image  = Obit Image, created with getname, getFITS
    * window = Optional window for image to edit
    """
    ################################################################
    if Image.PIsA(image):
        # Obit/Image
        ODisplay.PImage(disp, image, err, window=window)
    elif image.__class__==AIPSData.AIPSImage:
        # AIPS Image
        tmp = Image.newPAImage("AIPS Image",image.name, image.klass, image.disk, \
                               image.seq, True, err)
        ODisplay.PImage(disp, tmp, err, window=window)
        del tmp
    elif image.__class__==FITSData.FITSImage:
        # FITS Image
        tmp = Image.newPFImage("FITS Image",image.filename, image.disk, True, err)
        ODisplay.PImage(disp, tmp, err, window=window)
        del tmp
Пример #11
0
def window (image):
    """ Make a window object for an image

    Returns OWindow object
    image  = Obit image object
    """
    ################################################################
    if Image.IsA(image):
        # Obit/Image
        naxis = image.Desc.Dict["inaxes"][0:2]
    elif image.__class__==AIPSData.AIPSImage:
        # AIPS Image
        tmp = Image.newPAImage("AIPS Image",image.name, image.klass, image.disk, \
                               image.seq, True, err)
        naxis = tmp.Desc.Dict["inaxes"][0:2]
        del tmp
    elif image.__class__==FITSData.FITSImage:
        # FITS Image
        tmp = Image.newPFImage("FITS Image",image.filename, image.disk, True, err)
        naxis = tmp.Desc.Dict["inaxes"][0:2]
        del tmp
    return OWindow.PCreate1("Window", naxis, err)
Пример #12
0
def fitsout(inimagedata, outfile):

    err = OErr.OErr()

    x = Image.newPAImage(inimagedata[0], inimagedata[0], inimagedata[1],
                         inimagedata[2], inimagedata[3], True, err)

    #inimage=makeaipsimage(inimagedata)
    if os.path.exists(outfile):
        print 'Cannot create ' + outfile
        raise IOError
    xf = EVLAImFITS(x, outfile, 0, err)
    #fittp         = AIPSTask('fittp')
    #fittp.indata  = inimage
    #fittp.dataout = outfile
    #fittp.go()

    # Correct an AIPS bug with NaN pixels.
    outimage = pyfits.open(outfile, mode='update')
    #print numpy.nanmin(outimage[0].data)
    outimage[0].header.set('datamin', numpy.nanmin(outimage[0].data))
    outimage[0].header.set('datamax', numpy.nanmax(outimage[0].data))
    outimage.flush()
    outimage.close()
Пример #13
0
def VLAPolCal(uv, InsCals, RLCal, RLPhase, err, RM=0.0, \
              doCalib=2, gainUse=0, flagVer=-1, \
              soltype="APPR", fixPoln=False, avgIF=False, \
              solInt=0.0, refAnt=0, \
              pmodel=[0.0,0.0,0.0,0.0,0.0,0.0,0.0], \
              FOV=0.05, niter = 100, \
              nThreads=1, noScrat=[], logfile = ""):
    """ Polarization calibration, both instrumental and orientation

    Do Instrumental and R-L calibration
    Instrumental cal uses PCAL, R-L cal is done by imaging each IF in Q and U
    and summing the CLEAN components.
    uv       = UV data object to calibrate
    InsCals  = Instrumental poln calibrators, name or list of names
               If None no instrumental cal
    RLCal    = R-L (polarization angle) calibrator,
               If None no R-L cal
    RLPhase  = R-L phase of RLCal (deg) at 1 GHz
    err      = Obit error/message stack
    RM       = Rotation measure of RLCal
    doCalib  = Apply prior calibration table, positive=>calibrate
    gainUse  = CL/SN table to apply
    flagVer  = Input Flagging table version
    soltype  = solution type
    fixPoln  = if True, don't solve for source polarization in ins. cal
    avgIF    = if True, average IFs in ins. cal.
    solInt   = instrumental solution interval (min), 0=> scan average
    refAnt   = Reference antenna
    pmodel   = Instrumental poln cal source poln model.
               pmodel[0] = I flux density (Jy)
               pmodel[1] = Q flux density (Jy)
               pmodel[2] = U flux density (Jy)
               pmodel[3] = V flux density (Jy)
               pmodel[4] = X offset in sky (arcsec)
               pmodel[5] = Y offset in sky (arcsec)
    FOV      = field of view radius (deg) needed to image RLCal
    niter    = Number  of iterations of CLEAN in R-L cal
    nThreads = Number of threads to use in imaging
    noScrat  = list of disks to avoid for scratch files
    logfile  = Log file for task
    """
    ################################################################
    # Instrumental calibrtation
    if InsCals != None:
        pcal = AIPSTask.AIPSTask("pcal")
        pcal.logFile = logfile
        setname(uv, pcal)
        if type(InsCals) == list:
            pcal.calsour[1:] = InsCals
        else:
            pcal.calsour[1:] = [InsCals]
        pcal.docalib = doCalib
        pcal.gainuse = gainUse
        pcal.flagver = flagVer
        pcal.soltype = soltype
        pcal.solint = solInt
        pcal.refant = refAnt
        if fixPoln:
            pcal.bparm[10] = 1.0
        if avgIF:
            pcal.cparm[1] = 1.0
        pcal.pmodel[1:] = pmodel
        pcal.i
        pcal.g
        # end instrumental poln cal

    # R-L phase cal
    if RLCal != None:
        img = ObitTask.ObitTask("Imager")
        img.logFile = logfile
        setname(uv, img)
        img.doCalib = doCalib
        img.gainUse = gainUse
        img.flagVer = flagVer
        img.doPol = True
        img.Sources[0] = RLCal
        img.Stokes = "IQU"
        img.FOV = FOV
        img.Niter = niter
        img.autoWindow = True
        img.dispURL = "None"
        img.Catalog = "None"
        img.nThreads = nThreads
        img.noScrat = noScrat
        # Temporary output files
        if img.DataType == "AIPS":
            img.outName = "TEMP"
            img.outClass = "IPOLCL"
            img.outDisk = img.inDisk
            img.outSeq = 6666
            img.out2Name = "TEMP"
            img.out2Class = "IPOLCL"
            img.out2Disk = img.inDisk
            img.out2Seq = 7777
        elif img.DataType == "FITS":
            img.outFile = "TEMPPOLCAL.fits"
            img.outDisk = img.inDisk
            img.out2File = "TEMPPOLCAL2.uvtab"
            img.out2Disk = img.inDisk
    # How many IFs?
        h = uv.Desc.Dict
        if h["jlocif"] >= 0:
            nif = h["inaxes"][h["jlocif"]]
        else:
            nif = 1

        # Lists of flux densities and RMSes
        IFlux = []
        IRMS = []
        QFlux = []
        QRMS = []
        UFlux = []
        URMS = []

        # Loop over IF imaging I,Q, U
        for iif in range(1, nif + 1):
            img.BIF = iif
            img.EIF = iif
            #img.dispURL    = "ObitView"  # DEBUG
            #img.debug=True               # DEBUG
            img.g

            # Get fluxes from inner quarter of images
            if img.DataType == "AIPS":
                outName = (img.Sources[0].strip() + "TEMP")[0:12]
                outDisk = img.outDisk
                outSeq = 6666
                # Stokes I
                outClass = "IPOLCL"
                x = Image.newPAImage("I", outName, outClass, outDisk, outSeq,
                                     True, err)
                h = x.Desc.Dict
                blc = [h["inaxes"][0] / 4, h["inaxes"][1] / 4]
                trc = [3 * h["inaxes"][0] / 4, 3 * h["inaxes"][1] / 4]
                stat = imstat(x, err, blc=blc, trc=trc)
                IFlux.append(stat["Flux"])
                IRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Stokes Q
                outClass = "QPOLCL"
                x = Image.newPAImage("Q", outName, outClass, outDisk, outSeq,
                                     True, err)
                stat = imstat(x, err, blc=blc, trc=trc)
                QFlux.append(stat["Flux"])
                QRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Stokes U
                outClass = "UPOLCL"
                x = Image.newPAImage("U", outName, outClass, outDisk, outSeq,
                                     True, err)
                stat = imstat(x, err, blc=blc, trc=trc)
                UFlux.append(stat["Flux"])
                URMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Delete UV output
                out2Name = (img.Sources[0].strip() + "TEMP")[0:12]
                out2Class = "IPOLCL"
                out2Disk = img.inDisk
                out2Seq = 7777
                u = UV.newPAUV("UV", out2Name, out2Class, out2Disk, out2Seq,
                               True, err)
                u.Zap(err)
                del u
            elif img.DataType == "FITS":
                # Stokes I
                outFile = img.Sources[0].strip() + "ITEMPPOLCAL.fits"
                x = Image.newPFImage("I", outFile, img.outDisk, True, err)
                h = x.Desc.Dict
                blc = [h["inaxes"][0] / 4, h["inaxes"][1] / 4]
                trc = [3 * h["inaxes"][0] / 4, 3 * h["inaxes"][1] / 4]
                stat = imstat(x, err, blc=blc, trc=trc)
                IFlux.append(stat["Flux"])
                IRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Stokes Q
                outFile = img.Sources[0].strip() + "ITEMPPOLCAL.fits"
                x = Image.newPFImage("Q", outFile, img.outDisk, True, err)
                stat = imstat(x, err, blc=blc, trc=trc)
                IFlux.append(stat["Flux"])
                IRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Stokes U
                outFile = img.Sources[0].strip() + "ITEMPPOLCAL.fits"
                x = Image.newPFImage("Q", outFile, img.outDisk, True, err)
                stat = imstat(x, err, blc=blc, trc=trc)
                IFlux.append(stat["Flux"])
                IRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                out2File = img.Sources[0].strip() + "TEMPPOLCAL2.uvtab"
                u = UV.newPFUV("UV", outFile, img.outDisk, True, err)
                u.Zap(err)
                del u
        # End accumulate statistics by file type
        # End loop over IF

        # Give results, compute R-L correction
        RLCor = []
        import math
        mess = " IF     IFlux    IRMS    QFlux   QRMS    UFlux  URMS  R-L Corr"
        printMess(mess, logfile)
        for i in range(0, len(IFlux)):
            # REALLY NEED RM Correction!!!!!
            cor = RLPhase - 57.296 * math.atan2(UFlux[i], QFlux[i])
            RLCor.append(cor)
            mess = "%3d  %8.3f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f "%\
                (i+1, IFlux[i], IRMS[i], QFlux[i], QRMS[i], UFlux[i], URMS[i], cor)
            printMess(mess, logfile)
        # Copy highest CL table
        hiCL = uv.GetHighVer("AIPS CL")

        # Apply R-L phase corrections
        clcor = AIPSTask.AIPSTask("clcor")
        clcor.logFile = logfile
        setname(uv, clcor)
        clcor.opcode = "POLR"
        clcor.gainver = hiCL
        clcor.gainuse = hiCL + 1
        clcor.clcorprm[1:] = RLCor
        clcor.g
Пример #14
0
import OErr, Image, OWindow, ODisplay, FArray
BlankImage = None

# Define image
Aname = 'Arcade_A'
Aclass = '3secHG'
disk = 1
seq = 1
offs = [0, 0]
Aname = 'Arcade_BC'
Aclass = 'Blank'
disk = 1
seq = 1
offs = [-139, -169]
plane = [1, 1, 1, 1, 1]
image = Image.newPAImage("Im", Aname, Aclass, disk, seq, True, err)
OErr.printErr(err)

# Read image
image.GetPlane(None, plane, err)
OErr.printErr(err)

# Define blanking interactively defining a OWindow
naxis = image.Desc.Dict['inaxes'][0:2]
win = OWindow.PCreate1('wind', naxis, err)
ODisplay.PImage(disp, image, err, window=win)
OErr.printErr(err)
wlist = OWindow.PGetList(win, 1, err)
OErr.printErr(err)

# Apply
Пример #15
0
def VLAPolCal(uv, InsCals, RLCal, RLPhase, err, RM=0.0, \
              doCalib=2, gainUse=0, flagVer=-1, \
              soltype="APPR", fixPoln=False, avgIF=False, \
              solInt=0.0, refAnt=0, \
              pmodel=[0.0,0.0,0.0,0.0,0.0,0.0,0.0], \
              FOV=0.05, niter = 100, \
              nThreads=1, noScrat=[], logfile = ""):
    """ Polarization calibration, both instrumental and orientation

    Do Instrumental and R-L calibration
    Instrumental cal uses PCAL, R-L cal is done by imaging each IF in Q and U
    and summing the CLEAN components.
    uv       = UV data object to calibrate
    InsCals  = Instrumental poln calibrators, name or list of names
               If None no instrumental cal
    RLCal    = R-L (polarization angle) calibrator,
               If None no R-L cal
    RLPhase  = R-L phase of RLCal (deg) at 1 GHz
    err      = Obit error/message stack
    RM       = Rotation measure of RLCal
    doCalib  = Apply prior calibration table, positive=>calibrate
    gainUse  = CL/SN table to apply
    flagVer  = Input Flagging table version
    soltype  = solution type
    fixPoln  = if True, don't solve for source polarization in ins. cal
    avgIF    = if True, average IFs in ins. cal.
    solInt   = instrumental solution interval (min), 0=> scan average
    refAnt   = Reference antenna
    pmodel   = Instrumental poln cal source poln model.
               pmodel[0] = I flux density (Jy)
               pmodel[1] = Q flux density (Jy)
               pmodel[2] = U flux density (Jy)
               pmodel[3] = V flux density (Jy)
               pmodel[4] = X offset in sky (arcsec)
               pmodel[5] = Y offset in sky (arcsec)
    FOV      = field of view radius (deg) needed to image RLCal
    niter    = Number  of iterations of CLEAN in R-L cal
    nThreads = Number of threads to use in imaging
    noScrat  = list of disks to avoid for scratch files
    logfile  = Log file for task
    """
    ################################################################
    # Instrumental calibrtation
    if InsCals!=None:
        pcal = AIPSTask.AIPSTask("pcal")
        pcal.logFile = logfile
        setname(uv,pcal)
        if type(InsCals)==list:
            pcal.calsour[1:] = InsCals
        else:
            pcal.calsour[1:] = [InsCals]
        pcal.docalib = doCalib
        pcal.gainuse = gainUse
        pcal.flagver = flagVer
        pcal.soltype = soltype
        pcal.solint  = solInt
        pcal.refant  = refAnt
        if fixPoln:
            pcal.bparm[10]=1.0
        if avgIF:
            pcal.cparm[1]=1.0
        pcal.pmodel[1:]  = pmodel
        pcal.i
        pcal.g
        # end instrumental poln cal

    # R-L phase cal
    if RLCal!=None:
        img = ObitTask.ObitTask("Imager")
        img.logFile    = logfile
        setname(uv,img)
        img.doCalib    = doCalib
        img.gainUse    = gainUse
        img.flagVer    = flagVer
        img.doPol      = True
        img.Sources[0] = RLCal
        img.Stokes     = "IQU"
        img.FOV        = FOV
        img.Niter      = niter
        img.autoWindow = True
        img.dispURL    = "None"
        img.Catalog    = "None"
        img.nThreads   = nThreads
        img.noScrat    = noScrat
        # Temporary output files
        if img.DataType=="AIPS":
            img.outName = "TEMP"
            img.outClass= "IPOLCL"
            img.outDisk = img.inDisk
            img.outSeq  = 6666
            img.out2Name = "TEMP"
            img.out2Class= "IPOLCL"
            img.out2Disk = img.inDisk
            img.out2Seq  = 7777
        elif img.DataType=="FITS":
            img.outFile  = "TEMPPOLCAL.fits"
            img.outDisk  = img.inDisk
            img.out2File = "TEMPPOLCAL2.uvtab"
            img.out2Disk = img.inDisk
       # How many IFs?
        h = uv.Desc.Dict
        if h["jlocif"]>=0:
            nif = h["inaxes"][h["jlocif"]]
        else:
            nif = 1

        # Lists of flux densities and RMSes
        IFlux = []
        IRMS  = []
        QFlux = []
        QRMS  = []
        UFlux = []
        URMS  = []
        
        # Loop over IF imaging I,Q, U
        for iif in range (1, nif+1):
            img.BIF = iif
            img.EIF = iif
            #img.dispURL    = "ObitView"  # DEBUG
            #img.debug=True               # DEBUG
            img.g
            
            # Get fluxes from inner quarter of images
            if img.DataType=="AIPS":
                outName = (img.Sources[0].strip()+"TEMP")[0:12]
                outDisk = img.outDisk
                outSeq  = 6666
                # Stokes I
                outClass="IPOLCL"
                x =  Image.newPAImage("I",outName, outClass, outDisk,outSeq,True,err)
                h = x.Desc.Dict
                blc = [h["inaxes"][0]/4,h["inaxes"][1]/4]
                trc = [3*h["inaxes"][0]/4,3*h["inaxes"][1]/4]
                stat = imstat(x, err, blc=blc,trc=trc)
                IFlux.append(stat["Flux"])
                IRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Stokes Q
                outClass="QPOLCL"
                x =  Image.newPAImage("Q",outName, outClass, outDisk,outSeq,True,err)
                stat = imstat(x, err, blc=blc,trc=trc)
                QFlux.append(stat["Flux"])
                QRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Stokes U
                outClass="UPOLCL"
                x =  Image.newPAImage("U",outName, outClass, outDisk,outSeq,True,err)
                stat = imstat(x, err, blc=blc,trc=trc)
                UFlux.append(stat["Flux"])
                URMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Delete UV output
                out2Name = (img.Sources[0].strip()+"TEMP")[0:12]
                out2Class="IPOLCL"
                out2Disk = img.inDisk
                out2Seq  = 7777
                u =  UV.newPAUV("UV",out2Name,out2Class,out2Disk,out2Seq,True,err)
                u.Zap(err)
                del u
            elif img.DataType=="FITS":
                # Stokes I
                outFile  = img.Sources[0].strip()+"ITEMPPOLCAL.fits"
                x =  Image.newPFImage("I",outFile,img.outDisk,True,err)
                h = x.Desc.Dict
                blc = [h["inaxes"][0]/4,h["inaxes"][1]/4]
                trc = [3*h["inaxes"][0]/4,3*h["inaxes"][1]/4]
                stat = imstat(x, err, blc=blc,trc=trc)
                IFlux.append(stat["Flux"])
                IRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Stokes Q
                outFile  = img.Sources[0].strip()+"ITEMPPOLCAL.fits"
                x =  Image.newPFImage("Q",outFile,img.outDisk,True,err)
                stat = imstat(x, err, blc=blc,trc=trc)
                IFlux.append(stat["Flux"])
                IRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                # Stokes U
                outFile  = img.Sources[0].strip()+"ITEMPPOLCAL.fits"
                x =  Image.newPFImage("Q",outFile,img.outDisk,True,err)
                stat = imstat(x, err, blc=blc,trc=trc)
                IFlux.append(stat["Flux"])
                IRMS.append(stat["RMSHist"])
                x.Zap(err)  # Cleanup
                del x
                out2File = img.Sources[0].strip()+"TEMPPOLCAL2.uvtab"
                u =  UV.newPFUV("UV",outFile,img.outDisk,True,err)
                u.Zap(err)
                del u
           # End accumulate statistics by file type
        # End loop over IF

        # Give results, compute R-L correction
        RLCor = []
        import math
        mess = " IF     IFlux    IRMS    QFlux   QRMS    UFlux  URMS  R-L Corr"
        printMess(mess, logfile)
        for i in range (0,len(IFlux)):
            # REALLY NEED RM Correction!!!!!
            cor = RLPhase - 57.296 * math.atan2(UFlux[i],QFlux[i])
            RLCor.append(cor)
            mess = "%3d  %8.3f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f "%\
                (i+1, IFlux[i], IRMS[i], QFlux[i], QRMS[i], UFlux[i], URMS[i], cor)
            printMess(mess, logfile)
        # Copy highest CL table
        hiCL = uv.GetHighVer("AIPS CL")

        # Apply R-L phase corrections
        clcor = AIPSTask.AIPSTask("clcor")
        clcor.logFile  = logfile
        setname(uv,clcor)
        clcor.opcode   = "POLR"
        clcor.gainver  = hiCL
        clcor.gainuse  = hiCL+1
        clcor.clcorprm[1:] = RLCor
        clcor.g
Пример #16
0
    disk += 1

disk = 0
for fd in fdirs:
    FITS.FITS.disks.append(FITS.FITSDisk(None, disk, ad))
    disk += 1

# List directories
#ObitTalkUtil.ListAIPSDirs()
#ObitTalkUtil.ListFITSDirs()

print("AIPS.AIPS.disks",AIPS.AIPS.disks)
#DAMN print "AIPSData",help(AIPSData.AIPSCat)
#DAMN AMcat(1)

import Image,FitModel,FitRegion, Obit, ODisplay, OErr
err=OErr.OErr()
from OTObit import newDisplay, tvlod, AMcat, getFITS
AMcat(1)
##disp=ODisplay.ODisplay(8765)
#url = "http://localhost:8765/RPC2" 
#disp = ODisplay.ODisplay("ObitView", url, err) 
#tvlod(x)
x=Image.newPAImage('cc','DemoTest','I',1,1,True,err)
if err.isErr:
    printErr(err)
#x.TVFit(disp,err)
x.Header(err)
#import FitModel
#m=FitModel.FitModel(mtype=1, Peak=0.00054, DeltaX=14, DeltaY=17, parms=[5.0, 5.0, 0.0])
Пример #17
0
err=OErr.OErr()
ObitSys=OSystem.OSystem ("TestHist", 1, 100, 1, ["../AIPSdata/"], 1, ["../PythonData/"], 1, 0, err)
OErr.printErrMsg(err, "Error with Obit startup")

# Files (FITS)
inDisk = 1
inFile   = 'HiTest.fits'
outFile  = 'GaussTest.fits'
# AIPS test AIPS image user 100 C346R422    .POLI  .   2,, disk 8/142
aname = "C346R422"
aclass = "POLI"
aseq = 2

# Set data
inImage   = Image.newPImage("Input image", inFile,  inDisk,   1, err)
outImage   = Image.newPAImage("Output image", aname, aclass, inDisk, aseq, 1, err)
OErr.printErrMsg(err, "Error initializing")

# For debugging
#Obit.Bomb()

# Make history
inInfo = Image.PGetList(inImage)
outInfo = Image.PGetList(outImage)
history = History.History("history", outInfo, err)
OErr.printErrMsg(err, "Error initializing history")
History.POpen(history, 3, err)
History.PTimeStamp(history,"Label",err)
History.PTimeStamp(history,"Something longer",err)
str = History.PReadRec(history,144,err)
print "Read ",str
Пример #18
0
def makeobitimage(data, err, check=True):

    image = Image.newPAImage(data[0], data[0], data[1], data[2], data[3],
                             check, err)
    return image