コード例 #1
0
def PCVel (inUV, outUV, RestFreq, err, scratch=False, \
           VLSR=0.0, refDate="0000-00-00", refChan=-9999.):
    """ Doppler correct a UV data set

    inUV     = Input UV data, any calibration/editing/selection parameters
               should be entered on the List member.
    outUV    = Output UV data, should be defined but not instantiated
               if not scratch
    RestFreq = Rest Frequency (GHz)
    err      = Obit error/message object
    scratch  = True if output a scratch file (destroyed on object deletion)
    VLSR     = desired center LSR velocity (km/s)
    refDate  = reference date for reference channel as 'yyyy-mm-dd'
               defaults to observation date.
    refChan  = reference channel (-9999=> compute)
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError, "inUV MUST be a Python ObitUV"
    if not UV.PIsA(outUV):
        raise TypeError, "outUV MUST be a Python ObitUV"
    #
    if scratch:
        lscratch = 1
    else:
        lscratch = 0
        # set parameters
    info = inUV.List
    info.set("RestFreq", RestFreq * 1.0e9, ttype="double")
    info.set("VelLSR", VLSR * 1000)
    info.set("JDref", UVDesc.PDate2JD(refDate), ttype="double")
    info.set("refChan", refChan)
    # Correct data
    Obit.DopplerCVel(inUV.me, lscratch, outUV.me, err.me)
コード例 #2
0
ファイル: AddSource.py プロジェクト: mauch/Obit
def UVAddSource(inUV, outUV, err):
    """ 
    Add a Source table to a UV data
    
    Source information is derived from the UV descriptor and a Source
    random parameter added if needed.
    * inUV        = input Obit UV object
    * outUV       = output Obit UV object, defined but not instantiated
                    Onlyt really works for AIPS
    * err         = Obit error/message stack
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError, "inUV MUST be a Python Obit UV"
    if not UV.PIsA(outUV):
        raise TypeError, "outUV MUST be a defined Python Obit UV"
    # Patch UV Descriptor
    DescAddSource(inUV, outUV, err)
    OErr.printErrMsg(err, "Error updating Descriptor")
    CreateSU(inUV, outUV, err)
    OErr.printErrMsg(err, "Error creating SU Table")
    # Copy data
    CopyData(inUV, outUV, err)
    # Update
    # outUV.UpdateDesc(err)
    outUV.Header(err)  # show results
    OErr.printErrMsg(err, "Error copying")
コード例 #3
0
def PCreate(name, inUV, residUV, outUV, input=RFIXizeInput):
    """ Create the parameters and underlying structures of a UVRFIXize.

    Returns UVRFIXize created.
    name      = Name to be given to object
                Most control parameters are in InfoList member
    inUV      = Input Python uv data to be corrected
    residUV   = Input Python residual uv data
    outUV     = Output Python uv data to be written
    err       = Python Obit Error/message stack
    input     = control parameters:
    solInt      = Counter rotated SN table interval [def 1 min]
    doInvert    = If True invert solution [def False]
    timeInt     = Data integration time in sec [def 10 sec]
    timeAvg     = Time interval (min) over which to average residual.
    minRot      = Min. fringe rotation (turns) in an integration,
                  data with smaller values flagged if > minRFI
                  Only reduce this if a very good model has been
                  subtracted to make the residual data.
    maxRot      = Max. fringe rotation (turns) in an integration 
                  to estimate RFI 
    minRFI      = Minimum RFI amplitude to subtract
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError("inUV MUST be a Python Obit UV")
    if not UV.PIsA(residUV):
        raise TypeError("residUV MUST be a Python Obit UV")
    if not UV.PIsA(outUV):
        raise TypeError("outUV MUST be a Python Obit UV")
    #
    # Create
    out = UVRFIXize(name)
    out.me = Obit.UVRFIXizeCreate(name, inUV.me, residUV.me, outUV.me)
    # Set RFIXize control values on out
    inInfo = PGetList(out)  #
    dim = [1, 1, 1, 1, 1]
    # Set control values on RFIXize
    InfoList.PAlwaysPutFloat(inInfo, "solInt", dim, [input["solInt"]])
    InfoList.PAlwaysPutBoolean(inInfo, "doInvert", dim, [input["doInvert"]])
    InfoList.PAlwaysPutFloat(inInfo, "timeInt", dim, [input["timeInt"]])
    InfoList.PAlwaysPutFloat(inInfo, "timeAvg", dim, [input["timeAvg"]])
    InfoList.PAlwaysPutFloat(inInfo, "minRFI", dim, [input["minRFI"]])
    InfoList.PAlwaysPutFloat(inInfo, "minRot", dim, [input["minRot"]])
    InfoList.PAlwaysPutFloat(inInfo, "maxRot", dim, [input["maxRot"]])
    #
    return out
コード例 #4
0
def PInvertSN (SNTab, outUV, outVer, doRepl, err):
    """ Invert the calibration in an SN table

    Routine to reverse the effects of the calibration in the
    input SN table and create a new SN table on outUV
    Returns new SN table
    SNTab     = Input Python AIPS SN Table to invert
    outUV     = output UV data to which to attach the new SN table
    outVer    = Output SN table version number, 0=> create new
    doRepl    = If True, replace failed solutions with (1,0)
    err       = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not Table.PIsA(SNTab):
        raise TypeError("SNTab MUST be a Python Obit Table")
    if not UV.PIsA(outUV):
        raise TypeError('outUV Must be UV data ')
    if not OErr.OErrIsA(err):
        raise TypeError("err MUST be an OErr")
    #
    # Create output
    outSN  = Table.Table("None")
    # invert table
    outSN.me = Obit.SNInvert (SNTab.me, outUV.me, outVer, doRepl, err.me)
    if err.isErr:
        printErrMsg(err, "Error inverting solutions")
    return outSN
コード例 #5
0
def PReimage (inCleanVis, uvdata, err):
    """
    See if an image needs to be remade
    
    See if an image needs to be remade because a source which exceeds
    the flux  threshold is not centered (as determined by moments)
    on the reference pixel (within toler pixel).
    A new (96x96) field is added centered on the offending source and a negative
    clean window added to the position of the source in its original window.
    Avoid duplicates of the same source and ensure that all occurances of this 
    source in any exant field has a negative clean window added.
    Multiple centering sources per facet are allowed
    A boolean entry "autoCenField" with value True is added to the info member of any
    image members added to the mosaic member.

    * inCleanVis  = Python CleanVis object
    * uvdata      = Python uv data from which image is made
    * err         = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not PIsA(inCleanVis):
        raise TypeError,"inCleanVis MUST be a Python ObitCleanVis"
    if not UV.PIsA(uvdata):
        raise TypeError,"uvData MUST be a Python Obit UV"
    #
    out = Obit.CleanVisReimage(inCleanVis.me, uvdata.me, err.me)
    if err.isErr:
        OErr.printErrMsg(err, "Error in Reimage")
    return out
コード例 #6
0
ファイル: UVPolnUtil.py プロジェクト: mauch/Obit-1
def GetFreqArr(inUV, err, inc = 1):
    """
    Get Array of channel frequencies in data
    
    Return list of channel Frequencies (Hz)
    * inUV     = Obit UV data with tables
    * err      = Python Obit Error/message stack
    * inc      = increment in channel
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        print("Actually ",inUV.__class__)
        raise TypeError("inUV MUST be a Python Obit UV")
    d = inUV.Desc.Dict # UV data descriptor dictionary
    refFreq = d["crval"][ d["jlocf"]]    # reference frequency
    nchan   = d["inaxes"][ d["jlocf"]]   # Number of channels per IF
    nif     = d["inaxes"][ d["jlocif"]]  # Number of IFs
    chwid   = abs(d["cdelt"][ d["jlocf"]]) # channel width from header
    fqtab = inUV.NewTable(Table.READONLY,"AIPS FQ",1,err)
    fqtab.Open(Table.READONLY,err)
    fqrow = fqtab.ReadRow(1, err)   # Only bother with first
    OErr.printErrMsg(err) # catch table errors
    IFfreq   = fqrow['IF FREQ']     # IF offset
    ChWidth  = fqrow['CH WIDTH']    # IF channel width
    sideband = fqrow['SIDEBAND']    # IF sizeband, 1=USB, -1=LSB
    freqs = []
    for iif in range(0,nif):
        for ifq in range(0,nchan,inc):
            frq =  refFreq + IFfreq[iif] + sideband[iif] * ifq * min (chwid, ChWidth[iif])
            freqs.append(frq)
    # End loops
    return freqs
コード例 #7
0
ファイル: ImageUtil.py プロジェクト: bill-cotton/Obit
def PMakeImage(inUV, outImage, channel, doBeam, doWeight, err):
    """
    Grids UV, FFTs and makes corrections for the gridding convolution.

    * inUV     = Input Python uv data. Should be in form of Stokes to be imaged
      will all calibration and selection applied.
    * outImage = Python Image to be written.  Must be previously instantiated.
      Beam normalization factor is written to output Beam infoList as SUMWTS
    * channel  = Which frequency channel to image, 0->all.
    * doBeam   = if TRUE also make beam.  Will make the myBeam member of outImage.
      If FALSE, and myGrid->BeamNorm 0.0 then reads SUMWTS value from beam infolist
    * doWeigh  = if TRUE Apply uniform weighting corrections to uvdata before imaging
    * err      = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError("inUV MUST be a Python Obit UV")
    if not Image.PIsA(outImage):
        print("Actually ", outImage.__class__)
        raise TypeError("outImage MUST be a Python Obit Image")
    if not err.IsA():
        raise TypeError("err MUST be an OErr")
    #
    Obit.ImageUtilMakeImage(inUV.me, outImage.me, channel, doBeam, doWeight,
                            err.me)
    if err.isErr:
        OErr.printErrMsg(err, "Error creating Image from UV data")
コード例 #8
0
ファイル: IonCal.py プロジェクト: mauch/Obit-1
def PIoN2SolNTableConvert(inUV, outSNVer, NITable, pos, err):
    """
    Evaluate Ionospheric model table at pos and convert to SN table
    
    Returns resultant SN table

    * inUV     = UV data for output SN table.
      Control parameters on inUV info member:

      ========== ================ ================================
      "doAntOff" OBIT_bool scalar True if correctionss for antenna
                                  offset from array center wanted [def False]
      ========== ================ ================================

    * outSNVer = Desired output SN table version, 0=> new
    * NITable  = Ionospheric model table to evaluate
    * pos      = [RA, Dec] shift (deg) in which NITable to be evaluated.
    * err      = Obit Error stack, returns if not empty.
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError('PIoN2SolNTableConvert: Bad input UV data')
    if not Table.PIsA(NITable):
        raise TypeError('PIoN2SolNTableConvert: Bad NI input table')

    # Create output SN table object
    outSNTable = Table.Table("None")

    # Evaluate
    outSNTable.me = Obit.IoN2SolNTableConvert (inUV.me, outSNVer, \
                                               NITable.me, pos, err.me)
    if err.isErr:
        OErr.printErrMsg(err, "Error Converting NI to SN table")
    return outSNTable
コード例 #9
0
def UVAddIF(inUV, outUV, nIF, err):
    """ 
    Create outUV like inUV but divided into nIF IFs
    
    
    * inUV        = input Obit UV object
    * outUV       = output Obit UV object, defined but not instantiated
                    Onlyt really works for AIPS
    * nIF         = number of desired output IFs
                    MUST be the same number of channels per IF
    * err         = Obit error/message stack
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError("inUV MUST be a Python Obit UV")
    if not UV.PIsA(outUV):
        raise TypeError("outUV MUST be a defined Python Obit UV")
    # Input can have 1 or no IFs defined
    jlocif = inUV.Desc.Dict["jlocif"]
    if jlocif >= 0 and inUV.Desc.Dict["inaxes"][jlocif] > 1:
        raise RuntimeError("Input UV has excessive IFs already:" \
              +str(inUV.Desc.Dict["inaxes"][jlocif]))
    # Check number of requested IFs
    if nIF < 2:
        raise RuntimeError("Too few output IFs requested: " + str(nIF))
    # Must be an even number of channels per output IF
    jlocf = inUV.Desc.Dict["jlocf"]
    nchan = inUV.Desc.Dict["inaxes"][jlocf]
    if (nchan % nIF) != 0:
        raise RuntimeError("Unequal numbers of channels per " + str(nIF) +
                           " IFs")

    # Patch UV Descriptor
    DescAddIF(inUV, outUV, nIF, err)
    # Convert FG Table
    UpdateFQ(inUV, outUV, nIF, err)
    # Convert AN Table
    UpdateAN(inUV, outUV, nIF, err)
    # Convert SU Table
    UpdateSU(inUV, outUV, nIF, err)
    # Copy data
    CopyData(inUV, outUV, err)
    # Update
    outUV.UpdateDesc(err)
    OErr.printErrMsg(err, "Error updating output")
    print("Any CL tables need to be regenerated")
コード例 #10
0
ファイル: VLACal.py プロジェクト: mauch/Obit
def VLAUVFITS(inUV, filename, outDisk, err, compress=False, \
              exclude=["AIPS HI", "AIPS AN", "AIPS FQ", "AIPS SL", "AIPS PL"], \
                  include=[], headHi=False):
    """ Write UV data as FITS file
    
    Write a UV data set as a FITAB format file
    History written to header
    inUV       = UV data to copy
    filename   = name of FITS file
    inDisk     = FITS directory number
    err        = Python Obit Error/message stack
    exclude    = List of table types NOT to copy
                 NB: "AIPS HI" isn't really a table and gets copied anyway
    include    = List of table types to copy (FQ, AN always done )
                 Exclude has presidence over include
    headHi     = if True move history to header, else leave in History table
    returns FITS UV data object
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError, "inUV MUST be a Python Obit UV"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be an OErr"
    #
    # Set output
    outUV = UV.newPFUV("FITS UV DATA", filename, outDisk, False, err)
    if err.isErr:
        OErr.printErrMsg(err, "Error creating FITS data")
    #Compressed?
    if compress:
        inInfo = UV.PGetList(outUV)  #
        dim = [1, 1, 1, 1, 1]
        InfoList.PAlwaysPutBoolean(inInfo, "Compress", dim, [True])
    # Copy
    UV.PCopy(inUV, outUV, err)
    if err.isErr:
        OErr.printErrMsg(err, "Error copying UV data to FITS")
    # History
    inHistory = History.History("inhistory", outUV.List, err)
    outHistory = History.History("outhistory", outUV.List, err)
    # Add history
    outHistory.Open(History.READWRITE, err)
    outHistory.TimeStamp(" Start Obit uvtab", err)
    outHistory.WriteRec(
        -1, "uvtab   / FITS file " + filename + " disk " + str(outDisk), err)
    outHistory.Close(err)
    # History in header?
    if headHi:
        History.PCopy2Header(inHistory, outHistory, err)
        OErr.printErrMsg(err, "Error with history")
        # zap table
        outHistory.Zap(err)
    # Copy Tables
    UV.PCopyTables(inUV, outUV, exclude, include, err)
    return outUV  # return new object
コード例 #11
0
def UVMakeIF(outUV, nIF, err, solInt=10.):
    """ 
    Change number of IFs from 1 to nIF
    
    Operation done in place
    * outUV       = output Obit UV object
                    Only really works for AIPS
    * nIF         = number of desired output IFs
                    MUST be the same number of channels per IF
    * err         = Obit error/message stack
    * solInt      = Solution interval for remade CL table.
    """
    ################################################################
    # Checks
    if not UV.PIsA(outUV):
        raise TypeError("outUV MUST be a defined Python Obit UV")
    # Input can have 1 or no IFs defined
    jlocif = outUV.Desc.Dict["jlocif"]
    if jlocif >= 0 and outUV.Desc.Dict["inaxes"][jlocif] > 1:
        raise RuntimeError("Input UV has excessive IFs already:" \
              +str(outUV.Desc.Dict["inaxes"][jlocif]))
    # Check number of requested IFs
    if nIF < 2:
        raise RuntimeError("Too few output IFs requested: " + str(nIF))
    # Must be an even number of channels per output IF
    jlocf = outUV.Desc.Dict["jlocf"]
    nchan = outUV.Desc.Dict["inaxes"][jlocf]
    if (nchan % nIF) != 0:
        raise RuntimeError("Unequal numbers of channels per " + str(nIF) +
                           " IFs")

    # Patch UV Descriptor
    DescMakeIF(outUV, nIF, err)
    # Convert FQ Table
    UpdateFQ2(outUV, nIF, err)
    # Convert AN Table
    maxant = UpdateAN2(outUV, nIF, err)
    # Convert SU Table
    UpdateSU2(outUV, nIF, err)
    # Regenerate CL table 1 - delete any old
    outUV.ZapTable("AIPS CL", -1, err)
    print('(Re) generate CL table')
    UV.PTableCLfromNX(outUV, maxant, err, calInt=solInt)
    # dummy FG 1
    print('Dummy entry in Flag table 1')
    UV.PFlag(outUV,
             err,
             timeRange=[-10., -9.],
             Ants=[200, 200],
             Stokes='0000',
             Reason='Dummy')
    # Update
    outUV.UpdateDesc(err)
    OErr.printErrMsg(err, "Error updating output")
コード例 #12
0
ファイル: OSurvey.py プロジェクト: mauch/Obit-1
def PGenPrint(printer, data, err, VLVer=1, first=True, last=True):
    """ 
    Print selected contents of a generic VL format catalog

    Returns logical quit to indicate user wants to quit
    * printer    = Printer for output
    * data       = OData to to which VL table is attached
                   will cast from Image or UV types
                   with control parameters on the info:
        Object    string  Name of object
        equinCode long    Epoch code for output, 
                          1=>B1950, 2=>J2000, 3=>Galactic [def 2]
        Fitted    bool    If True give fitted values [def F]
        doraw     bool    If True give raw values from table, else 
                          corrected/deconvolved.[def F]
        RA        double  RA center of search, degrees in equinCode [def 0]
        Dec       double  Dec center of search, degrees in equinCode [def 0]
        Search    double  Search radius in arcsec, <= 0 => all selected. [def 15] 
        Box       double[2] RA and Dec halfwidth of search 
                          rectangle in hr,deg [0,0]
        Silent    double  Half width asec of silent search box. [def 720]
        minFlux   float   Minimum peak flux density. [def 0]
        maxFlux   float   Maximum peak flux density. [def LARGE]
        minGlat   float   Minimum abs galactic latitude [def any]
        maxGlat   float   Minimum abs galactic latitude [def any]
        Calibration Parameters
        fluxScale float Flux density scaling factor, def 1.0
        biasRA    float RA position bias in deg, def 0.0
        biasDec   float Dec position bias in deg, def 0.0
        calRAEr   float Cal component of RA position error (squared), def 0.0
        calDecEr  float Cal component of Dec position error (squared), def 0.0
        ClnBiasAv float Mean CLEAN bias in Jy, def 0.0
        ClnBiasEr float Uncertainty in CLEAN bias in Jy, def 0.0
        calAmpEr  float Cal component of amplitude error as fraction, def 0.03
        calSizeEr float Cal component of amplitude error as fraction, def 0.02
        calPolEr  float Cal component of polarization error, def 0.003
    * err        = Python Obit Error/message stack
    * VLVer      = VL table version
    * first      = True if this first write to printer
    * last       = True if this is the last write to printer
    """
    ################################################################
    # Checks
    if not OPrinter.PIsA(printer):
        raise TypeError("printer MUST be a Python Obit printer")
    # cast data if necessary
    if Image.PIsA(data) or UV.PIsA(data):
        ldata = data.cast("ObitData")
    else:
        ldata = data
    ret = Obit.OSurveyGenPrint(printer.me, ldata.me, VLVer, first, last,
                               err.me)
    return ret != 0
コード例 #13
0
ファイル: ImageUtil.py プロジェクト: bill-cotton/Obit
def PICreateImage(inUV, fieldNo, doBeam, err):
    """
    Create an image from information on an ObitUV
    
    returns  Python Image

    * inUV     = Python UV object, following read from InfoList member 

       ======== ================== =============================================
       "nChAvg" OBIT_int (1,1,1)   number of channels to average.
                                   This is for spectral line observations and
                                   is ignored if the IF axis on the uv data has
                                   more than one IF.  Default is continuum =
                                   average all freq/IFs. 0=> all.
       "rotate" OBIT_float (?,1,1) Desired rotation on sky (from N thru E) in
                                   deg. [0]
       "nx"     OBIT_int (?,1,1)   Dimension of image in RA [no default].
                                   This and the following are arrays with one
                                   entry per field.
       "nxBeam" OBIT_int (?,1,1)   Dimension of beam in RA, [def. nx]
       "ny"     OBIT_int (?,1,1)   Dimension of image in declination[no default]
       "nyBeam" OBIT_int (?,1,1)   Dimension of beam in declination, [def. ny]
       "xCells" OBIT_float (?,1,1) X (=RA) cell spacing in degrees [no default]
       "yCells" OBIT_float (?,1,1) Y (=dec) cell spacing in degrees [no default]
       "xShift" OBIT_float (?,1,1) Desired shift in X (=RA) in degrees. [0]
       "yShift" OBIT_float (?,1,1) Desired shift in Y (=dec) in degrees. [0]
       "nuGrid" OBIT_int (1,1,1)   Size in pixels of weighting grid for uniform
                                   weighting
       ======== ================== =============================================

    * fieldNo  = Which field (1-rel) in imaging parameter arrays.
    * doBeam   = if TRUE also create beam as the myBeam member of returned image.
    * err      = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError("inUV MUST be a Python Obit UV")
    if not err.IsA():
        raise TypeError("err MUST be an OErr")
    #
    out = Image("None")
    out.me = Obit.ImageUtilCreateImage(inUV.me, fieldNo, doBeam, err.me)
    if err.isErr:
        OErr.printErrMsg(err, "Error Creating Image")
    return out
コード例 #14
0
ファイル: OSurvey.py プロジェクト: mauch/Obit-1
def PNVSSPrint(printer, data, err, VLVer=1, first=True, last=True):
    """ 
    Print selected contents of an NVSS (VLA 1.4 GHz D config) catalog

    Returns logical quit to indicate user wants to quit
    * printer    = Printer for output
    * data       = OData to to which VL table is attached
                   will cast from Image or UV types
                   with control parameters on the info:
        Object    string  Name of object
        equinCode long    Epoch code for output, 
                          1=>B1950, 2=>J2000, 3=>Galactic [def 2]
        Fitted    bool    If True give fitted values [def F]
        doraw     bool    If True give raw values from table, else 
                          corrected/deconvolved.[def F]
        RA        double  RA center of search, degrees in equinCode [def 0]
        Dec       double  Dec center of search, degrees in equinCode [def 0]
        Search    double  Search radius in arcsec, <= 0 => all selected. [def 15] 
        Box       double[2] RA and Dec halfwidth of search 
                          rectangle in hr,deg [0,0]
        Silent    double  Half width asec of silent search box. [def 720]
        minFlux   float   Minimum peak flux density. [def 0]
        maxFlux   float   Maximum peak flux density. [def LARGE]
        minPol    float   Minimum percent integrated polarization [def 0]
        minGlat   float   Minimum abs galactic latitude [def any]
        maxGlat   float   Minimum abs galactic latitude [def any]
    * err        = Python Obit Error/message stack
    * VLVer      = VL table version
    * first      = True if this first write to printer
    * last       = True if this is the last write to printer
    """
    ################################################################
    # Checks
    if not OPrinter.PIsA(printer):
        raise TypeError("printer MUST be a Python Obit printer")
    # cast data if necessary
    if Image.PIsA(data) or UV.PIsA(data):
        ldata = data.cast("ObitData")
    else:
        ldata = data
    ret = Obit.OSurveyNVSSPrint(printer.me, ldata.me, VLVer, first, last,
                                err.me)
    return ret != 0
コード例 #15
0
ファイル: ImageMosaic.py プロジェクト: mauch/Obit-1
def PDefine(inImageM, uvData, doBeam, err):
    """
    Define the parameters and underlying structures of a set of images.

    * inImageM  = Python ImageMosaic object
    * uvData    = Python uv data from which the image mosaic will be derived
    * doBeam    = if True then make dirty beams
    * err       = Python Obit err stack.
    """
    ################################################################
    # Checks
    if not PIsA(inImageM):
        raise TypeError("inImageM MUST be a Python Obit ImageMosaic")
    if not UV.PIsA(uvData):
        raise TypeError("uvData MUST be a Python Obit UV")
    if err.isErr:  # existing error?
        return
    #
    Obit.ImageMosaicDefine(inImageM.me, uvData.me, doBeam, err.me)
コード例 #16
0
ファイル: ImageMosaic.py プロジェクト: mauch/Obit-1
def PCreate(name, uvData, err):
    """
    Create the parameters and underlying structures of a set of images.

    * name      = Name to be given to object
    * uvData    = Python uv data from which the image mosaic will be derived
                Most control parameters are in InfoList member
    * err       = Python Obit err stack.
    """
    ################################################################
    # Checks
    if not UV.PIsA(uvData):
        raise TypeError("uvData MUST be a Python Obit UV")
    #
    out = ImageMosaic("None", 1)
    if err.isErr:  # existing error?
        return out
    out.me = Obit.ImageMosaicCreate(name, uvData.me, err.me)
    return out
コード例 #17
0
def PInvertSN(SNTab, outUV, outVer, doRepl, err):
    """ Invert the calibration in an SN table

    Routine to reverse the effects of the calibration in the
    input SN table and create a new SN table on outUV
    Returns new SN table
    SNTab     = Input Python AIPS SN Table to invert
    outUV     = output UV data to which to attach the new SN table
    outVer    = Output SN table version number, 0=> create new
    doRepl    = If True, replace failed solutions with (1,0)
    err       = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not Table.PIsA(SNTab):
        raise TypeError("SNTab MUST be a Python Obit Table")
    if not UV.PIsA(outUV):
        raise TypeError('outUV Must be UV data ')
    if not OErr.OErrIsA(err):
        raise TypeError("err MUST be an OErr")
    #
    # Create output
    outSN = Table.Table("None")
    # invert table
    outSN.me = Obit.SNInvert(SNTab.me, outUV.me, outVer, doRepl, err.me)
    if err.isErr:
        printErrMsg(err, "Error inverting solutions")
    # Write history
    inHistory = History.History("history", outUV.List, err)
    # Add this programs history
    inHistory.Open(History.READWRITE, err)
    inHistory.TimeStamp(" Start Obit InvertSN", err)
    inHistory.WriteRec(-1, "InvertSN / inTab = " + Table.PGetName(SNTab), err)
    inHistory.WriteRec(-1, "InvertSN / outVer = " + str(outVer), err)
    if doRepl:
        inHistory.WriteRec(-1, "InvertSN / doRepl = True", err)
    else:
        inHistory.WriteRec(-1, "InvertSN / doRepl = False", err)
    inHistory.Close(err)
    return outSN
コード例 #18
0
def PSNSmo (inSC, err, input=UVSelfSNSmoInput):
    """ Smooth SN table possibly replacing blanked soln.

    inSC    = Selfcal object
    err     = Python Obit Error/message stack
    input   = input parameter dictionary
    
    Input dictionary entries:
    InData   = Input Python UV data 
    InTable  = Input SN table
    isuba    = Desired subarray, 0=> 1 
    smoType  = Smoothing type MWF, GAUS or BOX, def BOX
    smoAmp   = Amplitude smoothing time in min
    smpPhase = Phase smoothing time in min. (0 => fix failed only')
    """
    ################################################################
    # Get input parameters
    InData    = input["InData"]
    InTable   = input["InTable"]
    isuba     = input["isuba"]
    #
    # Checks
    if not UV.PIsA(InData):
        raise TypeError('PCal: Bad input UV data')
    if not Table.PIsA(InTable):
        raise TypeError('PCal: Bad input table')
    # Set control values on UV 
    dim[0] = 1;
    inInfo = UV.PGetList(InData)  # Add control to UV data
    dim[0] = len(input["smoType"]);
    InfoList.PAlwaysPutString  (inInfo, "smoType", dim, [input["smoType"]])
    dim[0] = 1;
    InfoList.PPutFloat   (inInfo, "smoAmp",  dim, [input["smoAmp"]],  err)
    InfoList.PPutFloat   (inInfo, "smoPhase",dim, [input["smoPhase"]],err)
    # Smooth
    Obit.UVSolnSNSmo(InTable.me, isuba, err.me)
    if err.isErr:
        printErrMsg(err, "Error smoothing SN table")
コード例 #19
0
def PDivUV(err, input=UVDivInput):
    """ Fourier transform Sky model and divide into uv data

    A SkyModel is Fourier transformed and divided into
    InData and written to outData.
    If doCalSelect, selection by channel/IF will specify the output
    err     = Python Obit Error/message stack
    input   = input parameter dictionary
    
    Input dictionary entries:
    InData      = Input UV data,
    SkyModel    = Input SkyModel,
    OutData     = Output uv data,
    doCalSelect = Select/calibrate/edit data?),
    REPLACE     = Replace data with model?
    Stokes      = Stokes parameter, blank-> unchanged from input),
    CCVer       = CC table versions to use [def all 0 => highest]
    BComp       = Start CC to use per table, 1-rel [def 1 ]
    EComp       = Highest CC to use per table, 1-rel [def to end]
    BChan       = First spectral channel selected. [def all]),
    EChan       = Highest spectral channel selected. [def all]),
    BIF         = First IF selected. [def all]),
    EIF         = Highest IF selected. [def all]),
    doPol       = >0 -> calibrate polarization.),
    doCalib     = >0 -> calibrate, 2=> also calibrate Weights),
    gainUse     = SN/CL table version number, 0-> use highest),
    flagVer     = Flag table version, 0-> use highest, <0-> none),
    BLVer       = BL table version, 0> use highest, <0-> none),
    BPVer       = Band pass (BP) table version, 0-> use highest),
    Subarray    = Selected subarray, <=0->all [default all]),
    freqID      = Selected Frequency ID, <=0->all [default all]),
    timeRange   = Selected timerange in days. [8 floats] 0s -> all),
    UVRange     = Selected UV range in wavelengths. 0s -> all),
    Sources     = Source names selected unless any starts with),
    Antennas    = A list of selected antenna numbers, if any is negative),
    corrType    = Correlation type, 0=cross corr only, 1=both, 2=auto only.),
    doBand      = Band pass application type <0-> none),
    Smooth      = Specifies the type of spectral smoothing [three floats]
    do3D        = If 3D imaging wanted. [def false]
    Factor      = Model multiplication factor (-1=>add) [def 1]
    PBCor       = If TRUE make relative primary beam corrections. [def false]
    antSize     = Diameter of antennas for PBCor,.[def 25.0]
    minFlux     = Minimum flux density model or pixel [def -1.0e20]
    Type        = Model type (ObitSkyModelType) [def OBIT_SkyModel_Comps]
                  0=CC Comps, 1=Image, 2=Model
    Mode        = Model mode (ObitSkyModelMode) [def OBIT_SkyModel_Fastest]
                  0=fastest, 1=DFT, 2=Grid
    MODPTFLX    = Point model flux in Jy, [def 0.0]')
    MODPTXOF    = Point model x offset in deg  [def 0.0]
    MODPTYOF    = Point model y offset in deg  [def 0.0]
    MODPTYPM    = Point other parameters  [def all 0.0]
              Parm[3] = 0; Point - no other parameters
              Parm[3] = 1; Gaussian on sky:
                  [0:2] = major_axis (asec),  minor_axis (asec),  
                   Rotation of major axis (deg) from east towards north
              Parm[3] = 3; Uniform sphere:
                  [0] =  radius (asec)
    """
    ################################################################
    # Get input parameters
    inData = input["InData"]
    inSkyModel = input["SkyModel"]
    outData = input["OutData"]
    # Checks
    if not PIsA(inSkyModel):
        raise TypeError, "inSkyModel MUST be a Python Obit SkyModel"
    if not UV.PIsA(inData):
        raise TypeError, "inData MUST be a Python Obit UV"
    if not UV.PIsA(outData):
        raise TypeError, "outData MUST be a Python Obit UV"
    #
    #
    dim = [1, 1, 1, 1, 1]
    #
    # Set control values on SkyModel/inData
    dim[0] = 1
    inInfo = PGetList(inSkyModel)  #
    uvInfo = inData.List  #
    InfoList.PPutBoolean(uvInfo, "doCalSelect", dim, [input["doCalSelect"]],
                         err)
    InfoList.PPutBoolean(inInfo, "REPLACE", dim, [input["REPLACE"]], err)
    # Put channel selection on uvdata or skymodel depending on doCalSelect
    if input["doCalSelect"]:
        InfoList.PPutInt(uvInfo, "BChan", dim, [input["BChan"]], err)
        InfoList.PPutInt(uvInfo, "EChan", dim, [input["EChan"]], err)
        InfoList.PPutInt(uvInfo, "BIF", dim, [input["BIF"]], err)
        InfoList.PPutInt(uvInfo, "EIF", dim, [input["EIF"]], err)
    else:
        InfoList.PPutInt(inInfo, "BChan", dim, [input["BChan"]], err)
        InfoList.PPutInt(inInfo, "EChan", dim, [input["EChan"]], err)
        InfoList.PPutInt(inInfo, "BIF", dim, [input["BIF"]], err)
        InfoList.PPutInt(inInfo, "EIF", dim, [input["EIF"]], err)
    itemp = int(input["doPol"])
    InfoList.PPutInt(uvInfo, "doPol", dim, [itemp], err)
    InfoList.PPutInt(uvInfo, "doCalib", dim, [input["doCalib"]], err)
    InfoList.PPutInt(uvInfo, "doBand", dim, [input["doBand"]], err)
    InfoList.PPutInt(uvInfo, "gainUse", dim, [input["gainUse"]], err)
    InfoList.PPutInt(uvInfo, "flagVer", dim, [input["flagVer"]], err)
    InfoList.PPutInt(uvInfo, "BLVer", dim, [input["BLVer"]], err)
    InfoList.PPutInt(uvInfo, "BPVer", dim, [input["BPVer"]], err)
    InfoList.PPutInt(uvInfo, "Subarray", dim, [input["Subarray"]], err)
    InfoList.PPutInt(uvInfo, "freqID", dim, [input["freqID"]], err)
    InfoList.PPutInt(uvInfo, "corrType", dim, [input["corrType"]], err)
    dim[0] = 4
    InfoList.PAlwaysPutString(uvInfo, "Stokes", dim, [input["Stokes"]])
    dim[0] = 16
    dim[1] = len(input["Sources"])
    InfoList.PAlwaysPutString(uvInfo, "Sources", dim, input["Sources"])
    dim[0] = 2
    InfoList.PPutFloat(uvInfo, "UVRange", dim, input["UVRange"], err)
    dim[0] = 3
    InfoList.PPutFloat(uvInfo, "Smooth", dim, input["Smooth"], err)
    dim[0] = 2
    InfoList.PPutFloat(uvInfo, "timeRange", dim, input["timeRange"], err)
    dim[0] = len(input["Antennas"])
    InfoList.PAlwaysPutInt(uvInfo, "Antennas", dim, input["Antennas"])
    dim[0] = 16
    dim[1] = len(input["Sources"])
    InfoList.PAlwaysPutString(uvInfo, "Sources", dim, input["Sources"])
    dim[0] = 1
    dim[1] = 1
    InfoList.PPutBoolean(inInfo, "do3D", dim, [input["do3D"]], err)
    InfoList.PPutInt(inInfo, "ModelType", dim, [input["Type"]], err)
    InfoList.PPutInt(inInfo, "Mode", dim, [input["Mode"]], err)
    InfoList.PPutFloat(inInfo, "Factor", dim, [input["Factor"]], err)
    InfoList.PPutBoolean(inInfo, "PBCor", dim, [input["PBCor"]], err)
    InfoList.PPutFloat(inInfo, "antSize", dim, [input["antSize"]], err)
    InfoList.PPutFloat(inInfo, "minFlux", dim, [input["minFlux"]], err)
    InfoList.PPutFloat(inInfo, "MODPTFLX", dim, [input["MODPTFLX"]], err)
    InfoList.PPutFloat(inInfo, "MODPTXOF", dim, [input["MODPTXOF"]], err)
    InfoList.PPutFloat(inInfo, "MODPTYOF", dim, [input["MODPTYOF"]], err)
    dim[0] = len(input["MODPTYPM"])
    InfoList.PAlwaysPutFloat(inInfo, "MODPTYPM", dim, input["MODPTYPM"])
    if input["CCVer"] != None:
        dim[0] = len(input["CCVer"])
        InfoList.PAlwaysPutInt(inInfo, "CCVer", dim, input["CCVer"])
    if input["BComp"] != None:
        dim[0] = len(input["BComp"])
        InfoList.PAlwaysPutInt(inInfo, "BComp", dim, input["BComp"])
    if input["EComp"] != None:
        dim[0] = len(input["EComp"])
        InfoList.PAlwaysPutInt(inInfo, "EComp", dim, input["EComp"])
    #
    # show any errors
    #OErr.printErrMsg(err, "UVDiv: Error setting parameters")
    #
    # Do operation
    sm = inSkyModel.cast(myClass)  # cast pointer
    Obit.SkyModelDivUV(sm, inData.me, outData.me, err.me)
    if err.isErr:
        OErr.printErrMsg(err, "Error dividing SkyModel into UV data")
コード例 #20
0
def PCreate (name, uvdata, err, input=CleanInput):
    """
    Create the parameters and underlying structures of a CleanVis.
    
    Returns CleanVis created.

    * name      = Name to be given to object. Most control parameters are in 
      InfoList member
    * uvdata    = Python uv data from which image is to be made
    * err       = Python Obit Error/message stack
    * input     = control parameters:

      ===========  ============================================================
      Niter        Maximum number of CLEAN iterations
      minPatch     Minimum beam patch in pixels [def 100]
      maxPixel     Maximum number of residuals [def 20000]
      BMAJ         Restoring beam major axis (deg)
      BMIN         Restoring beam minor axis (deg)
      BPA          Restoring beam position angle (deg)
      Gain         CLEAN loop gain
      minFlux      Minimun flux density (Jy)
      Factor       CLEAN depth factor
      Plane        Plane being processed, 1-rel indices of axes 3-?
      autoWindow   True if autoWindow feature wanted.
      CCVer        CC table version number
      Mode         Model mode, 0=fastest, 1=DFT, 2=Grid
      doCalSelect  Select/calibrate/edit data?),
      Stokes       Stokes parameter, blank-> unchanged from input),
      BChan        First spectral channel selected. [def all]),
      EChan        Highest spectral channel selected. [def all]),
      BIF          First IF selected. [def all]),
      EIF          Highest IF selected. [def all]),
      doPol        >0 -> calibrate polarization.),
      doCalib      >0 -> calibrate, 2=> also calibrate Weights),
      gainUse      SN/CL table version number, 0-> use highest),
      flagVer      Flag table version, 0-> use highest, <0-> none),
      BLVer        BL table version, 0> use highest, <0-> none),
      BPVer        Band pass (BP) table version, 0-> use highest),
      Subarray     Selected subarray, <=0->all [default all]),
      freqID       Selected Frequency ID, <=0->all [default all]),
      timeRange    Selected timerange in days. [2 floats] 0s -> all),
      UVRange      Selected UV range in wavelengths. 0s -> all),
      Sources      Source names selected unless any starts with),
      Antennas     A list of selected antenna numbers, if any is negative),
      corrType     Correlation type, 0=cross corr only, 1=both, 2=auto only.),
      doBand       Band pass application type <0-> none),
      Smooth       Specifies the type of spectral smoothing [three floats]
      DoWeight     True if Weighting to be applied
      PBCor        If True make freq. dependent rel. pri. beam corr.
      Robust       Briggs robust parameter. (AIPS definition)
      UVTaper      UV plane taper, sigma in klambda,deg as [maj, min, pa]
      WtSize       Size of weighting grid in cells [same as image nx]
      WtBox        Size of weighting box in cells [def 1]
      WtFunc       Weighting convolution function [def. 1]
                   1=Pill box, 2=linear, 3=exponential, 4=Gaussian
                   if positive, function is of radius, negative in u and v.
      WtPower      Power to raise weights to.  [def = 1.0]
                   Note: a power of 0.0 sets all the output weights to 1 as modified
                   by uniform/Tapering weighting.
                   Applied in determinng weights as well as after.
      DoBeam       True if beams are to be made
      Type         Underlying file type, 0=FITS, 1=AIPS
      Name         Name of image, used as AIPS name or to derive FITS filename
      Class        Root of class, used as AIPS class or to derive FITS filename
      Seq          Sequence number
      Disk         Disk number for underlying files
      FOV          Field of view (deg) for Mosaic
      doFull       If True, create full field (FOV) image
      NField       Number of fields defined in input,
                   if unspecified derive from data and FOV
      xCells       Cell spacing in X (asec) for all images,
                   if unspecified derive from data
      yCells       Cell spacing in Y (asec) for all images,
                   if unspecified derive from data
      nx           Minimum number of cells in X for NField images
                   if unspecified derive from data
      ny           Minimum number of cells in Y for NField images
                   if unspecified derive from data
      RAShift      Right ascension shift (AIPS convention) for each field
                   if unspecified derive from FOV and data
      DecShift     Declination for each field
                   if unspecified derive from FOV and data
      Catalog      AIPSVZ format catalog for defining outliers, None=do not use
      OutlierFlux  Minimum estimated outlyer flux density (Jy)
      OutlierDist  Maximum distance to add outlyers (deg)
      OutlierSI    Spectral index to estimate flux density
      OutlierSize  Size of outlyer field (pixels)
      dispURL      URL of display server
      doRestore    Restore image when done? [def True]
      doFlatten    Flatten image when done? [def True]
      ===========  ============================================================
    """
    ################################################################
    # Checks
    if not UV.PIsA(uvdata):
        raise TypeError,"uvData MUST be a Python Obit UV"
    if not OErr.OErrIsA(err):
        raise TypeError,"err MUST be an OErr"
    #
    dim = [1,1,1,1,1]
    # Set imaging control values on uvdata
    dim[0] = 1;
    inInfo = UV.PGetList(uvdata)    # 
    InfoList.PPutBoolean (inInfo, "doCalSelect",  dim, [input["doCalSelect"]], err)
    dim[0] = 4
    InfoList.PAlwaysPutString (inInfo, "Stokes",   dim, [input["Stokes"]])
    dim[0] = 1;
    InfoList.PPutInt  (inInfo, "BChan",      dim, [input["BChan"]],    err)
    InfoList.PPutInt  (inInfo, "EChan",      dim, [input["EChan"]],    err)
    InfoList.PPutInt  (inInfo, "BIF",        dim, [input["BIF"]],      err)
    InfoList.PPutInt  (inInfo, "EIF",        dim, [input["EIF"]],      err)
    itemp = int(input["doPol"])
    InfoList.PPutInt  (inInfo, "doPol",      dim, [itemp],             err)
    InfoList.PPutInt  (inInfo, "doCalib",    dim, [input["doCalib"]],  err)
    InfoList.PPutInt  (inInfo, "doBand",     dim, [input["doBand"]],   err)
    InfoList.PPutInt  (inInfo, "gainUse",    dim, [input["gainUse"]],  err)
    InfoList.PPutInt  (inInfo, "flagVer",    dim, [input["flagVer"]],  err)
    InfoList.PPutInt  (inInfo, "BLVer",      dim, [input["BLVer"]],    err)
    InfoList.PPutInt  (inInfo, "BPVer",      dim, [input["BPVer"]],    err)
    InfoList.PPutInt  (inInfo, "Subarray",   dim, [input["Subarray"]], err)
    InfoList.PPutInt  (inInfo, "freqID",     dim, [input["freqID"]],   err)
    InfoList.PPutInt  (inInfo, "corrType",   dim, [input["corrType"]], err)
    dim[0] = 2
    InfoList.PPutFloat (inInfo, "UVRange",   dim, input["UVRange"],    err)
    dim[0] = 3
    InfoList.PPutFloat (inInfo, "Smooth",    dim, input["Smooth"],     err)
    dim[0] = 2
    InfoList.PPutFloat (inInfo, "timeRange", dim, input["timeRange"],  err)
    dim[0] = len(input["Antennas"])
    InfoList.PPutInt  (inInfo, "Antennas",   dim, input["Antennas"],   err)
    dim[0] = 16; dim[1] = len(input["Sources"])
    InfoList.PAlwaysPutString  (inInfo, "Sources", dim, input["Sources"])
    # Weighting parameters
    dim[0] = 1; dim[1] = 1;
    InfoList.PPutBoolean (inInfo,"DoWeight",dim,[input["DoWeight"]],err)
    InfoList.PPutBoolean (inInfo,"PBCor",  dim, [input["PBCor"]],   err)
    InfoList.PPutFloat  (inInfo, "Robust", dim, [input["Robust"]],  err)
    InfoList.PPutInt    (inInfo, "WtBox",  dim, [input["WtBox"]],   err)
    InfoList.PPutInt    (inInfo, "WtFunc", dim, [input["WtFunc"]],  err)
    InfoList.PPutFloat  (inInfo, "WtPower",dim, [input["WtPower"]], err)
    dim[1] = len(input["UVTaper"])
    InfoList.PPutFloat  (inInfo, "Taper",  dim, input["UVTaper"],   err)
    WtSize   = input["WtSize"]
    if (WtSize>0):
        print "WtSize", WtSize
        # Change name for C routine.
        dim[0] = 1;
        InfoList.PPutInt  (inInfo, "nuGrid",  dim, [WtSize], err)
        InfoList.PPutInt  (inInfo, "nvGrid",  dim, [WtSize], err)
    # Define image
    dim[0] = 1; dim[1] = 1;
    InfoList.PPutInt    (inInfo, "imFileType", dim, [input["Type"]],   err)
    InfoList.PPutInt    (inInfo, "imSeq",      dim, [input["Seq"]],    err)
    InfoList.PPutInt    (inInfo, "imDisk",     dim, [input["Disk"]],   err)
    InfoList.PPutFloat  (inInfo, "FOV",      dim, [input["FOV"]],    err)
    InfoList.PPutBoolean (inInfo, "doFull",  dim, [input["doFull"]], err)
    InfoList.PPutInt    (inInfo, "NField",   dim, [input["NField"]], err)
    InfoList.PPutFloat  (inInfo, "xCells",   dim, [input["xCells"]], err)
    InfoList.PPutFloat  (inInfo, "yCells",   dim, [input["yCells"]], err)
    InfoList.PPutFloat  (inInfo, "OutlierFlux", dim, [input["OutlierFlux"]], err)
    InfoList.PPutFloat  (inInfo, "OutlierDist", dim, [input["OutlierDist"]], err)
    InfoList.PPutFloat  (inInfo, "OutlierSI",   dim, [input["OutlierSI"]],   err)
    InfoList.PPutInt    (inInfo, "OutlierSize", dim, [input["OutlierSize"]], err)
    InfoList.PPutFloat  (inInfo, "BMAJ",     dim, [input["BMAJ"]],     err)
    InfoList.PPutFloat  (inInfo, "BMIN",     dim, [input["BMIN"]],     err)
    InfoList.PPutFloat  (inInfo, "BPA",      dim, [input["BPA"]],      err)
    dim[0] = len(input["Name"])
    InfoList.PAlwaysPutString (inInfo, "imName",     dim, [input["Name"]])
    dim[0] = len(input["Class"])
    InfoList.PAlwaysPutString (inInfo, "imClass",    dim, [input["Class"]])
    dim[0] = len(input["Catalog"])
    InfoList.PAlwaysPutString (inInfo, "Catalog",  dim, [input["Catalog"]])
    dim[0] = len(input["nx"])
    InfoList.PAlwaysPutInt    (inInfo, "nx",       dim, input["nx"])
    dim[0] = len(input["ny"])
    InfoList.PAlwaysPutInt    (inInfo, "ny",       dim, input["ny"])
    dim[0] = len(input["RAShift"])
    InfoList.PAlwaysPutFloat  (inInfo, "RAShift",  dim, input["RAShift"])
    dim[0] = len(input["DecShift"])
    InfoList.PAlwaysPutFloat  (inInfo, "DecShift", dim, input["DecShift"])
    #OErr.printErrMsg(err, "CleanVisCreate: Error setting parameters")
    #
    # Create
    out = CleanVis(name);
    out.me = Obit.CleanVisCreate(name, uvdata.me,  err.me)
    if err.isErr:
        OErr.printErrMsg(err, "Error creating CleanVis")
    # Set Clean control values on out
    dim[0] = 1;
    inInfo = PGetList(out)    # 
    InfoList.PPutInt   (inInfo, "Niter",    dim, [input["Niter"]],    err)
    InfoList.PPutInt   (inInfo, "minPatch", dim, [input["minPatch"]], err)
    InfoList.PPutInt   (inInfo, "maxPixel", dim, [input["maxPixel"]], err)
    InfoList.PPutInt   (inInfo, "CCVer",    dim, [input["CCVer"]],    err)
    InfoList.PPutInt   (inInfo, "Mode",     dim, [input["Mode"]],    err)
    InfoList.PPutFloat (inInfo, "BMAJ",     dim, [input["BMAJ"]],     err)
    InfoList.PPutFloat (inInfo, "BMIN",     dim, [input["BMIN"]],     err)
    InfoList.PPutFloat (inInfo, "BPA",      dim, [input["BPA"]],      err)
    InfoList.PPutFloat (inInfo, "Gain",     dim, [input["Gain"]],     err)
    InfoList.PPutFloat (inInfo, "minFlux",  dim, [input["minFlux"]],  err)
    InfoList.PPutFloat (inInfo, "Factor",   dim, [input["Factor"]],   err)
    InfoList.PPutBoolean (inInfo, "doRestore",  dim, [input["doRestore"]], err)
    InfoList.PPutBoolean (inInfo, "doFlatten",  dim, [input["doFlatten"]], err)
    InfoList.PPutBoolean (inInfo, "autoWindow", dim, [input["autoWindow"]],err)
    dim[0] = len(input["Plane"])
    InfoList.PAlwaysPutInt   (inInfo, "Plane",    dim, input["Plane"])
    dim[0] = len(input["dispURL"])
    InfoList.PAlwaysPutString (inInfo, "dispURL",   dim, [input["dispURL"]])
    # show any errors 
    #OErr.printErrMsg(err, "CleanVisCreate: Error setting parameters")
    #
    return out;
コード例 #21
0
ファイル: SkyModelVMIon.py プロジェクト: mauch/Obit-1
def PDivUV(err, input=UVSubInput):
    """ Fourier transform Sky model and divide into uv data

    A SkyModelVMIon is Fourier transformed and divided into
    InData and written to outData.
    err     = Python Obit Error/message stack
    input   = input parameter dictionary
    
    Input dictionary entries:
    InData      = Input UV data,
    SkyModelVMIon    = Input SkyModelVMIon,
    OutData     = Output uv data,
    doCalSelect = Select/calibrate/edit data?),
    REPLACE     = Replace data with model?
    Stokes      = Stokes parameter, blank-> unchanged from input),
    CCVer       = CC table versions to use [def all 0 => highest]
    BComp       = Start CC to use per table, 1-rel [def 1 ]
    EComp       = Highest CC to use per table, 1-rel [def to end]
    BChan       = First spectral channel selected. [def all]),
    EChan       = Highest spectral channel selected. [def all]),
    BIF         = First IF selected. [def all]),
    EIF         = Highest IF selected. [def all]),
    doPol       = >0 -> calibrate polarization.),
    doCalib     = >0 -> calibrate, 2=> also calibrate Weights),
    ionVer      = NI table version number, 0-> use highest, def=1
    flagVer     = Flag table version, 0-> use highest, <0-> none),
    BLVer       = BL table version, 0> use highest, <0-> none),
    BPVer       = Band pass (BP) table version, 0-> use highest),
    Subarray    = Selected subarray, <=0->all [default all]),
    freqID      = Selected Frequency ID, <=0->all [default all]),
    timeRange   = Selected timerange in days. [8 floats] 0s -> all),
    UVRange     = Selected UV range in wavelengths. 0s -> all),
    Sources     = Source names selected unless any starts with),
    Antennas    = A list of selected antenna numbers, if any is negative),
    corrType    = Correlation type, 0=cross corr only, 1=both, 2=auto only.),
    doBand      = Band pass application type <0-> none),
    Smooth      = Specifies the type of spectral smoothing [three floats]
    do3D        = If 3D imaging wanted. [def false]
    Factor      = Model multiplication factor (-1=>add) [def 1]
    PBCor       = If TRUE make relative primary beam corrections. [def false]
    antSize     = Diameter of antennas for PBCor,.[def 25.0]
    minFlux     = Minimum flux density model or pixel [def -1.0e20]
    Type        = Model type (ObitSkyModelVMIonType) [def OBIT_SkyModelVMIon_Comps]
                  0=CC Comps, 1=Image, 2=Model
    Mode        = Model mode (ObitSkyModelVMIonMode) [def OBIT_SkyModelVMIon_Fastest]
                  0=fastest, 1=DFT, 2=Grid
    MODPTFLX    = Point model flux in Jy, [def 0.0]')
    MODPTXOF    = Point model x offset in deg  [def 0.0]
    MODPTYOF    = Point model y offset in deg  [def 0.0]
    MODPTYP     = Point other parameters  [def all 0.0]
    """
    ################################################################
    # Get input parameters
    inData = input["InData"]
    inSkyModelVMIon = input["SkyModelVMIon"]
    outData = input["OutData"]
    # Checks
    if not PIsA(inSkyModelVMIon):
        raise TypeError("inSkyModelVMIon MUST be a Python Obit SkyModelVMIon")
    if not UV.PIsA(inData):
        raise TypeError("inData MUST be a Python Obit UV")
    if not UV.PIsA(outData):
        raise TypeError("outData MUST be a Python Obit UV")
    #
    #
    dim = [1, 1, 1, 1, 1]
    #
    # Set Ion control values on SkyModelVMIon/inData
    dim[0] = 1
    inInfo = inSkyModelVMIon.List
    uvInfo = inData.List  #
    InfoList.PPutInt(uvInfo, "ionVer", dim, [input["ionVer"]], err)
    input["SkyModel"] = inSkyModelVMIon
    #
    # Do operation
    SkyModel.PDivUV(err, input=input)
    if err.isErr:
        OErr.printErrMsg(err, "Error dividing SkyModelVMIon into UV data")
コード例 #22
0
ファイル: UVSoln2Cal.py プロジェクト: mauch/Obit
def PSoln2Cal(inUV, outUV, err, input=Soln2CalInput):
    """ Apply a gain solution to a calibration table

    inUV     = UV data with solution and input calibration
    outUV    = UV data for output calibration table
    err      = Python Obit Error/message stack
    input    = input parameter dictionary
    
    Input dictionary entries:
    solnVer = Input Solution (SN) table version 
    calIn   = Input Cal (CL) table version, 0=high, -1=none
    calOut  = Output Calibration table version, 0=>create new
    subA    = Selected subarray (default 1)
    interMode =  Interpolation mode 2PT, SELF POLY SIMP AMBG CUBE MWF '),
        "2PT " = linear vector interpolation with no SN smoothing.
        "SELF" = Use only SN solution from same source which is closest in time.
        "POLY" = Fit a polynomial to the SN rates and delays.
                  Use the integral of the rate polynomial for the phases. (NYI)
        "SIMP" = Simple linear phase connection between SN phase
                 entries, assumes phase difference less than 180 degrees.
        "AMBG" = Linear phase connection using rates to resolve phase ambiguities.
        "CUBE" = As AMBG but fit third order polynomial to phases and rates.
        "MWF " = Median window filter of SN table before 2PT interpolation
        "GAUS" = Gaussian smoothing of SN table before 2PT interpolation,
        "BOX " = Boxcar smoothing of SN table before 2PT interpolation,
    interParm =  interpolation parameters, smoothing time (hr)
                 amplitude, phase, delay/rate
    interNPoly = number of terms in polynomial'),
    allPass = If true copy unmodified entries as well (default False)
    refAnt  = Ref ant to use. (default 1)
    """
    ################################################################
    # Get input parameters
    InData = input["InData"]
    InTable = input["InTable"]
    isuba = input["isuba"]
    #
    # Checks
    if not UV.PIsA(inUV):
        raise TypeError, 'PSoln2Cal: Bad input UV data'
    if not UV.PIsA(outUV):
        raise TypeError, 'PSoln2Cal: Bad output UV data'

    # Set control values on UV
    dim[0] = 1
    inInfo = UV.PGetList(InData)  # Add control to UV data
    dim[0] = 4
    InfoList.PAlwaysPutString(inInfo, "interMode", dim, [input["interMode"]])
    dim[0] = 1
    InfoList.PAlwaysPutInt(inInfo, "solnVer", dim, [input["solnVer"]])
    InfoList.PAlwaysPutInt(inInfo, "calIn", dim, [input["calIn"]])
    InfoList.PAlwaysPutInt(inInfo, "calOut", dim, [input["calOut"]])
    InfoList.PAlwaysPutInt(inInfo, "subA", dim, [input["subA"]])
    InfoList.PAlwaysPutInt(inInfo, "interNPoly", dim, [input["interNPoly"]])
    InfoList.PAlwaysPutInt(inInfo, "refAnt", dim, [input["refAnt"]])
    InfoList.PAlwaysPutBool(inInfo, "allPass", dim, [input["allPass"]])
    dim[0] = len(input["interParm"])
    InfoList.PAlwaysPutFloat(inInfo, "allPass", dim, input["interParm"])
    # Calibrate
    Obit.UVSoln2Cal(inUV, outUV, err)
    if err.isErr:
        printErrMsg(err, "Error applying SN table to CL table")
コード例 #23
0
ファイル: VLBAContPipe.py プロジェクト: mauch/Obit-1
def pipeline(aipsSetup, parmFile):
    """
    VLBA Continuum pipeline.
    
    * *aipsSetup* = AIPS setup file
    * *parmFile* = pipeline input parameters file
    """
    ############################# Initialize OBIT ##########################################
    noScrat = []
    exec(open(aipsSetup).read())
    VLBAAddOutFile(aipsSetup, 'project', "Obit's AIPS setup file")

    ############################# Default parameters ##########################################
    # Define data
    project = "Unspecified"  # Project name (12 char or less, used as AIPS Name)
    session = "?"  # Project session code
    band = "?"  # Observing band
    logFile = project + "_" + session + "_" + band + ".log"  # Processing log file
    seq = 1  # AIPS sequence number
    gain = 0.10  # CLEAN loop gain
    doLoadIDI = True  # Load data from IDI FITS?
    doLoadUVF = False  # Load the "AIPS Friendly" (uvfits) FITS  version
    dataInUVF = None  # Input uvfits data file name
    dataInIDI = None  # Input FITS-IDI file or list
    dataClass = "Raw"  # AIPS class of raw uv data
    Compress = False  # Use compressed UV data?
    calInt = 0.15  # Calibration table interval in min.
    wtThresh = 0.8  # Data weight  threshold
    check = False  # Only check script, don't execute tasks
    debug = False  # run tasks debug
    prtLv = 2  # Print level

    # Initialize parameters
    parms = VLBAInitContParms()

    ############################# Set Project Processing parameters ##################
    exec(open(parmFile).read())
    VLBAAddOutFile(parmFile, 'project', 'Pipeline input parameters')

    ################################## Process #####################################
    # Init cal pickle jars
    goodCalPicklefile = project + "_" + session + "_" + band + "_GoodCal.pickle"  # Where results saved
    # Default "best" calibration
    goodCal = {
        "Source": "  ",
        "souID": 0,
        "timeRange": (0.0, 100.0),
        "Fract": 0.0,
        "SNR": 0.0,
        "bestRef": 0
    }
    # Save initial default if it doesn't already exist
    SaveObject(goodCal, goodCalPicklefile, False)
    VLBAAddOutFile(goodCalPicklefile, 'project', 'Best calibrator information')

    OKCalPicklefile = project + "_" + session + "_" + band + "_OKCal.pickle"  # Where results saved
    SaveObject(parms["contCals"], OKCalPicklefile, False)
    VLBAAddOutFile(OKCalPicklefile, 'project', 'List of calibrators')

    targetsPicklefile = project + "_" + session + "_" + band + "_targets.pickle"  # Where results saved
    if (not parms["targets"]) and os.path.exists(targetsPicklefile):
        parms["targets"] = FetchObject(targetsPicklefile)
    else:
        SaveObject(parms["targets"], targetsPicklefile, False)
    VLBAAddOutFile(targetsPicklefile, 'project', 'List of targets')

    # Load the outputs pickle jar
    VLBAFetchOutFiles()

    # Logging directly to logFile
    OErr.PInit(err, prtLv, logFile)
    retCode = 0
    VLBAAddOutFile(logFile, 'project', 'Pipeline log file')

    mess = "Start project " + project + " session " + session + " " + band + " Band" + " AIPS user no. " + str(
        AIPS.userno)
    printMess(mess, logFile)
    logger.info(mess)
    if debug:
        pydoc.ttypager = pydoc.plainpager  # don't page task input displays
        mess = "Using Debug mode "
        printMess(mess, logFile)
    if check:
        mess = "Only checking script"
        printMess(mess, logFile)

    # Load Data from FITS
    uv = None  # Raw data
    uvc = None  # Cal/averaged data
    if doLoadIDI:
        logger.info("--> Load IDI data file (doLoadIDI)")
        if type(dataInIDI) == list:
            logger.info(
                "--> Loading a list of IDI files (dataInIDI is a list)\n" +
                "    This data appears to be from the old correlator.\n" +
                "    IDI corrections will be applied when loading is\n" +
                "    complete.")
            # Read list
            for dataIn in dataInIDI:
                uv = VLBAIDILoad(dataIn, project, session, band, dataClass, disk, seq, err, logfile=logFile, \
                                     wtThresh=wtThresh, calInt=calInt, Compress=Compress, \
                                     check=check, debug=debug)
                if not UV.PIsA(uv):
                    raise RuntimeError("Cannot load " + dataIn)
            # Fix IDI files:
            uv = IDIFix.IDIFix(uv, err)
            seq = uv.Aseq
        else:
            logger.info(
                "--> Loading a single IDI file (dataInIDI is not a list)\n" +
                "    This data appears to be from the DiFX correlator.\n" +
                "    No IDI corrections will be applied.")
            # Single IDI file
            uv = VLBAIDILoad(dataInIDI, project, session, band, dataClass, disk, seq, err, logfile=logFile, \
                                 wtThresh=wtThresh, calInt=calInt, Compress=Compress, \
                                 check=check, debug=debug)
            if not UV.PIsA(uv):
                raise RuntimeError("Cannot load " + dataInIDI)
    if doLoadUVF:
        logger.info("--> Load UVFITS data file (doLoadUVF)")
        uv = VLBAIDILoad(dataInUVF, project, session, band, dataClass, disk, seq, err, logfile=logFile, \
                             wtThresh=wtThresh, calInt=calInt, Compress=Compress, \
                             check=check, debug=debug)
        # Adding check condition to avoid error when checking
        if not UV.PIsA(uv) and not check:
            raise RuntimeError("Cannot load " + dataInUVF)
    # Otherwise set uv
    if uv == None and not check:
        Aname = VLBAAIPSName(project, session)
        uvname = project + "_" + session + "_" + band
        uv = UV.newPAUV(uvname, Aname, dataClass, disk, seq, True, err)
        if err.isErr:
            OErr.printErrMsg(err, "Error creating AIPS data")

    # frequency dependent default parameters
    VLBAInitContFQParms(uv, parms, err, \
                            logfile=logFile, check=check, debug=debug)

    # Setup target source list
    if os.path.exists(targetsPicklefile):
        parms["targets"] = \
            setupSourceList( parms["targets"],  uv, err, logFile, check, debug )
        logger.debug("parms['targets'] = " + str(parms["targets"]))

    # Clear any old calibration/editing
    if parms["doClearTab"]:
        logger.info("--> Clear old calibration/editing (doClearTab)")
        VLBAClearCal(uv, err, doGain=parms["doGain"], doFlag=parms["doFlag"], doBP=parms["doBP"], \
                         check=check, logfile=logFile)
        OErr.printErrMsg(err, "Error resetting calibration")

    # Copy FG 1 to FG 2
    if parms["doCopyFG"]:
        logger.info("--> Copy flag (FG) table 1 to flag table 2 (doCopyFG)")
        retCode = VLBACopyFG(uv,
                             err,
                             logfile=logFile,
                             check=check,
                             debug=debug)
        if retCode != 0:
            raise RuntimeError("Error Copying FG table")

    # Special editing
    if parms["doEditList"] and not check:
        logger.info("--> Special editing (doEditList)")
        for edt in parms["editList"]:
            UV.PFlag(uv,err,timeRange=[dhms2day(edt["timer"][0]),dhms2day(edt["timer"][1])], \
                         flagVer=editFG, Ants=edt["Ant"], Chans=edt["Chans"], IFs=edt["IFs"], \
                         Stokes=edt["Stokes"], Reason=edt["Reason"])
            OErr.printErrMsg(err, "Error Flagging")

    # Quack to remove data from start and end of each scan
    if parms["doQuack"]:
        logger.info("--> Remove data from start and end of scans (doQuack)")
        retCode = VLBAQuack (uv, err, \
                                 begDrop=parms["quackBegDrop"], endDrop=parms["quackEndDrop"], \
                                 Reason=parms["quackReason"], \
                                 logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error Quacking data")

    # Median window time editing, for RFI impulsive in time or dropouts
    if parms["doMedn"]:
        logger.info("--> Median window time editing (doMedn)")
        retCode = VLBAMedianFlag (uv, "    ", err, noScrat=noScrat, nThreads=nThreads, \
                                  avgTime=parms["mednAvgTime"], avgFreq=parms["mednAvgFreq"], \
                                  chAvg=parms["mednChAvg"], timeWind=parms["mednTimeWind"], \
                                  flagSig=parms["mednSigma"], flagVer=2, \
                                  logfile=logFile, check=check, debug=False)
        if retCode != 0:
            raise RuntimeError("Error in MednFlag")

# Quantization correction?
    if parms["doQuantCor"]:
        logger.info("--> Quantization correction (doQuantCor)")
        plotFile = project + "_" + session + "_" + band + ".Quant.ps"
        retCode = VLBAQuantCor(uv, parms["QuantSmo"], parms["QuantFlag"], err, \
                                   doSNPlot=parms["doSNPlot"], plotFile=plotFile, \
                                   logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in quantization correcting/flagging")

    # Parallactic angle correction?
    if parms["doPACor"]:
        logger.info("--> Parallactic angle correction (doPACor)")
        retCode = VLBAPACor(uv, err, noScrat=noScrat, \
                                logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in quantization correcting/flagging")

    # Opacity/Tsys/gain correction
    if parms["doOpacCor"]:
        logger.info("--> Opacity/Tsys/Gain correction (doOpacCor)")
        plotFile = project + "_" + session + "_" + band + ".Opacity.ps"
        retCode = VLBAOpacCor(uv, parms["OpacSmoo"], err,  \
                                  doSNPlot=parms["doSNPlot"], plotFile=plotFile, \
                                  logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in opacity/gain.Tsys correction")

        VLBASaveOutFiles()  # Save plot file in Outfiles

    # Need to determine a list of calibrators?
    if (parms["contCals"] == None) or (len(parms["contCals"]) <= 0):
        logger.info("--> Get list of calibrators (contCals = None or [])")
        if parms["doFindOK"]:
            slist = VLBAAllSource(uv,
                                  err,
                                  logfile=logFile,
                                  check=check,
                                  debug=debug)
            parms["contCals"] = VLBAOKCal(uv, parms["minOKFract"], err, \
                                              solInt=parms["findSolInt"],  \
                                              calSou=slist, minSNR=parms["minOKSNR"], \
                                              doCalib=-1, flagVer=2, refAnts=parms["refAnts"], \
                                              noScrat=noScrat, nThreads=nThreads, \
                                              logfile=logFile, check=check, debug=debug)
            if not parms["contCals"] and not check:
                raise RuntimeError("Error in finding acceptable calibrators")
            logger.info("Calibrators = " + str(parms["contCals"]))
        else:
            # Snatch from pickle jar
            parms["contCals"] = FetchObject(OKCalPicklefile)

    # Save contCals to a pickle jar
    SaveObject(parms["contCals"], OKCalPicklefile, True)

    # Find best calibration source
    if parms["doFindCal"]:
        logger.info("--> Find best calibration source (doFindCal)")
        goodCal = VLBAGoodCal(uv,  err, \
                                  solInt=parms["findSolInt"], timeInt=parms["findTimeInt"], \
                                  calSou=parms["contCals"], \
                                  #CalModel=parms["contCalModel"], \
                                  doCalib=-1, flagVer=2, refAnts=parms["refAnts"], \
                                  noScrat=noScrat, nThreads=nThreads, \
                                  logfile=logFile, check=check, debug=debug)
        if not goodCal and not check:
            raise RuntimeError("Error in finding best calibration data")
        # Save it to a pickle jar
        SaveObject(goodCal, goodCalPicklefile, True)
    else:
        # Fetch from pickle
        goodCal = FetchObject(goodCalPicklefile)

    # Apply Phase cals from PC table?
    if parms["doPCcor"] and not check:
        logger.info("--> Apply phase cals (doPCcor)")
        plotFile = project + "_" + session + "_" + band + ".PC.ps"
        retCode = VLBAPCcor(uv, err, calSou=goodCal["Source"], \
                            timeRange=goodCal["timeRange"], \
                            doCalib=-1, flagVer=2, solInt=parms["manPCsolInt"], \
                            PCin=1, SNout=0, refAnt=goodCal["bestRef"], \
                            doPCPlot=parms["doPCPlot"], plotFile=plotFile, \
                            noScrat=noScrat, logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in PC calibration")
        VLBASaveOutFiles()  # Save plot file in Outfiles

    # manual phase cal
    if parms["doManPCal"] and not check:
        logger.info("--> Manual phase cal (doManPCal)")
        plotFile = project + session + band + ".ManPCal.ps"
        retCode = VLBAManPCal(uv, err, calSou=goodCal["Source"], \
                                  #CalModel=parms["contCalModel"], \
                                  timeRange=goodCal["timeRange"], \
                                  solInt=parms["manPCsolInt"], smoTime=parms["manPCSmoo"],  \
                                  refAnts=[goodCal["bestRef"]], doCalib=2, flagVer=2, \
                                  doManPCalPlot=parms["doManPCalPlot"], \
                                  plotFile=plotFile, noScrat=noScrat, \
                                  nThreads=nThreads, logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in manual phase calibration")

    # image cals
    if parms["doImgCal"] and not check:
        logger.info("--> Image calibrators (doImgCal)")
        VLBAImageCals(uv,
                      err,
                      Sources=parms["contCals"],
                      seq=seq,
                      sclass=parms["outCclass"],
                      doCalib=2,
                      flagVer=2,
                      doBand=0,
                      FOV=parms["FOV"],
                      Robust=parms["Robust"],
                      maxPSCLoop=parms["maxPSCLoop"],
                      minFluxPSC=parms["minFluxPSC"],
                      solPInt=parms["solPInt"],
                      solMode=parms["solMode"],
                      maxASCLoop=parms["maxASCLoop"],
                      minFluxASC=parms["minFluxASC"],
                      solAInt=parms["solAInt"],
                      avgPol=parms["avgPol"],
                      avgIF=parms["avgIF"],
                      minSNR=parms["minSNR"],
                      refAnt=goodCal["bestRef"],
                      nThreads=nThreads,
                      noScrat=noScrat,
                      logfile=logFile,
                      check=check,
                      debug=debug)
        # Rewrite OKCal pickle file because calibrators may have been updated
        SaveObject(parms["contCals"], OKCalPicklefile, True)
        if len(parms["contCals"]) <= 0:
            logger.error(
                "No calibration sources have been detected! Stopping pipeline."
            )
            raise RuntimeError("No calibration sources have been detected!")

    # Check if calibrator models now available
    parms["contCalModel"] = VLBAImageModel(parms["contCals"],
                                           parms["outCclass"], disk, seq, err)

    # delay calibration
    if parms["doDelayCal"] and not check:
        logger.info("--> Delay calibration (doDelayCal)")
        plotFile = project + "_" + session + "_" + band + ".DelayCal.ps"
        retCode = VLBADelayCal(uv, err, calSou=parms["contCals"], CalModel=parms["contCalModel"], \
                                   doCalib=2, flagVer=2, doBand=0, \
                                   solInt=parms["manPCsolInt"], smoTime=parms["delaySmoo"],  \
                                   refAnts=[goodCal["bestRef"]], \
                                   doSNPlot=parms["doSNPlot"], plotFile=plotFile, \
                                   nThreads=nThreads, noScrat=noScrat, logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in delay calibration")
        VLBASaveOutFiles()  # Save plot file in Outfiles

    # Bandpass calibration if needed
    if parms["doBPCal"] and not check:
        logger.info("--> Bandpass calibration (doBPCal)")
        retCode = VLBABPass(uv, goodCal["Source"], err, CalModel=parms["contCalModel"], \
                                timeRange=goodCal["timeRange"], doCalib=2, flagVer=2, \
                                noScrat=noScrat, solInt1=parms["bpsolint1"], \
                                solInt2=parms["bpsolint2"], solMode=parms["bpsolMode"], \
                                BChan1=parms["bpBChan1"], EChan1=parms["bpEChan1"], BChan2=parms["bpBChan2"], \
                                EChan2=parms["bpEChan2"], ChWid2=parms["bpChWid2"], \
                                doCenter1=parms["bpDoCenter1"], refAnt=goodCal["bestRef"], specIndex=parms["specIndex"], \
                                doAuto = parms["bpdoAuto"], \
                                nThreads=nThreads, logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in Bandpass calibration")

    # Plot amplitude and phase vs. frequency
    if parms["doSpecPlot"]:
        logger.info("--> Spectral plotting (doSpecPlot)")
        plotFile = project + '_' + session + '_' + band + ".spec.ps"
        VLBASpecPlot(uv,
                     goodCal,
                     err,
                     doband=1,
                     check=check,
                     plotFile=plotFile,
                     logfile=logFile,
                     debug=debug)
        VLBASaveOutFiles()  # Save plot file in Outfiles

    # Phase calibration using calibrator models
    if parms["doPhaseCal"]:
        logger.info(
            "--> Phase calibration using calibrator models (doPhaseCal)")
        plotFile = project + "_" + session + "_" + band + ".PhaseCal0.ps"
        retCode = VLBAPhaseCal(uv, err, calSou=parms["contCals"], CalModel=parms["contCalModel"], \
                             doCalib=-1, flagVer=0, doBand=-1, \
                             refAnt=goodCal["bestRef"], solInt=parms["solPInt"], \
                             doSNPlot=parms["doSNPlot"], plotFile=plotFile, \
                             nThreads=nThreads, noScrat=noScrat, logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in phase calibration")
        VLBASaveOutFiles()  # Save plot file in Outfiles
        # Rewrite contCals pickle file because contCals may have been updated
        SaveObject(parms["contCals"], OKCalPicklefile, True)
        if len(parms["contCals"]) <= 0:
            logger.error(
                "No calibrator sources have been detected! Stopping pipeline.")
            raise RuntimeError("No calibrator sources have been detected!")

    # Amplitude calibration
    if parms["doAmpCal"] and not check:
        logger.info("--> Amplitude calibration (doAmpCal)")
        plotFile = project + "_" + session + "_" + band + ".AmpCal.ps"
        retCode = VLBAAmpCal(uv,
                             err,
                             calSou=parms["contCals"],
                             CalModel=parms["contCalModel"],
                             doCalib=2,
                             flagVer=2,
                             doBand=1,
                             minSumCC=parms["minFluxASC"],
                             refAnt=goodCal["bestRef"],
                             solInt=parms["solAInt"],
                             smoTimeA=2.0,
                             smoTimeP=1. / 60.,
                             doSNPlot=parms["doSNPlot"],
                             plotFile=plotFile,
                             nThreads=nThreads,
                             noScrat=noScrat,
                             logfile=logFile,
                             check=check,
                             debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in amplitude calibration")
        VLBASaveOutFiles()  # Save plot file in Outfiles
        # Rewrite contCals pickle file because contCals may have been updated
        SaveObject(parms["contCals"], OKCalPicklefile, True)
        if len(parms["contCals"]) <= 0:
            logger.error(
                "No calibrator sources have been detected! Stopping pipeline.")
            raise RuntimeError("No calibrator sources have been detected!")

    # Calibrate and average  data
    if parms["doCalAvg"]:
        logger.info("--> Calibration and average data (doCalAvg)")
        retCode = VLBACalAvg (uv, parms["avgClass"], seq, parms["CalAvgTime"], err, \
                                  flagVer=2, doCalib=2, gainUse=0, doBand=1, BPVer=1,  \
                                  BIF=parms["CABIF"], EIF=parms["CAEIF"], \
                                  BChan=parms["CABChan"], EChan=parms["CAEChan"], \
                                  chAvg=parms["chAvg"], avgFreq=parms["avgFreq"], Compress=Compress, \
                                  logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in CalAvg")

    # image targets phase only self-cal - NOTE: actually A&P
    if parms["doImgTarget"] and not check:
        logger.info("--> Image targets (doImgTargets)")
        if not uvc:
            # Get calibrated/averaged data
            Aname = VLBAAIPSName(project, session)
            uvname = project + "_" + session + "_" + band + "_Cal"
            uvc = UV.newPAUV(uvname, Aname, parms["avgClass"], disk, seq, True,
                             err)
            if err.isErr:
                OErr.printErrMsg(err, "Error creating cal/avg AIPS data")
        logger.debug("parms['targets'] = " + str(parms["targets"]))
        VLBAImageCals(uv,
                      err,
                      Sources=parms["targets"],
                      seq=seq,
                      sclass=parms["outTclass"],
                      doCalib=2,
                      flagVer=2,
                      doBand=1,
                      FOV=parms["FOV"],
                      Robust=parms["Robust"],
                      maxPSCLoop=parms["maxPSCLoop"],
                      minFluxPSC=parms["minFluxPSC"],
                      solPInt=parms["solPInt"],
                      solMode=parms["solMode"],
                      maxASCLoop=parms["maxASCLoop"],
                      minFluxASC=parms["minFluxASC"],
                      solAInt=parms["solAInt"],
                      avgPol=parms["avgPol"],
                      avgIF=parms["avgIF"],
                      minSNR=parms["minSNR"],
                      refAnt=goodCal["bestRef"],
                      nThreads=nThreads,
                      noScrat=noScrat,
                      logfile=logFile,
                      check=check,
                      debug=debug)
        # Rewrite targets pickle file because targets may have been updated
        SaveObject(parms["targets"], targetsPicklefile, True)
        if len(parms["targets"]) <= 0:
            logger.error(
                "No target sources have been detected! Stopping pipeline.")
            raise RuntimeError("No target sources have been detected!")

    # Phase calibration using target models
    if parms["doPhaseCal"]:
        logger.info("--> Phase calibration using target models (doPhaseCal)")
        if not uvc:
            # Get calibrated/averaged data
            Aname = VLBAAIPSName(project, session)
            uvname = project + "_" + session + "_" + band + "_Cal"
            uvc = UV.newPAUV(uvname, Aname, parms["avgClass"], disk, seq, True,
                             err)
            if err.isErr:
                OErr.printErrMsg(err, "Error creating cal/avg AIPS data")
        parms["targetModel"] = VLBAImageModel(parms["targets"],
                                              parms["outTclass"], disk, seq,
                                              err)
        plotFile = project + "_" + session + "_" + band + ".PhaseCal.ps"
        retCode = VLBAPhaseCal(uvc, err, calSou=parms["targets"], CalModel=parms["targetModel"], \
                             doCalib=-1, flagVer=0, doBand=-1, \
                             refAnt=goodCal["bestRef"], solInt=parms["manPCsolInt"], \
                             doSNPlot=parms["doSNPlot"], plotFile=plotFile, \
                             nThreads=nThreads, noScrat=noScrat, logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in phase calibration")
        VLBASaveOutFiles()  # Save plot file in Outfiles
        # Rewrite targets pickle file because targets may have been updated
        SaveObject(parms["targets"], targetsPicklefile, True)
        if len(parms["targets"]) <= 0:
            logger.error(
                "No target sources have been detected! Stopping pipeline.")
            raise RuntimeError("No target sources have been detected!")

    # Instrumental polarization calibration
    if parms["doInstPol"]:
        logger.info("--> Instrumental polarization calibration (doInstPol)")
        # calibrators defaults to strong calibrator list
        if not parms["instPolCal"]:
            instPolCal = contCals
        else:
            instPolCal = parms["instPolCal"]
        if not uvc:
            # Get calibrated/averaged data
            Aname = VLBAAIPSName(project, session)
            uvname = project + "_" + session + "_" + band + "_Cal"
            uvc = UV.newPAUV(uvname, Aname, parms["avgClass"], disk, seq, True,
                             err)
            if err.isErr:
                OErr.printErrMsg(err, "Error creating cal/avg AIPS data")
        retCode = VLBAPolCal(uvc, instPolCal, err, \
                                 doCalib=2, flagVer=0, doBand=-1, doSetJy=True, \
                                 refAnt=goodCal["bestRef"], solInt=2.0, \
                                 noScrat=noScrat, logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in instrumental poln calibration")

    # RL Phase (EVPA) calibration as BP table
    if parms["doRLCal"] and parms["RLCal"]:
        logger.info("--> RL phase calibration (doRLCal)")
        if not uvc:
            # Get calibrated/averaged data
            Aname = VLBAAIPSName(project, session)
            uvname = project + "_" + session + "_" + band + "_Cal"
            uvc = UV.newPAUV(uvname, Aname, parms["avgClass"], disk, seq, True,
                             err)
            if err.isErr:
                OErr.printErrMsg(err, "Error creating cal/avg AIPS data")
        retCode = VLBARLCal2(uvc, err, RLPCal=parms["RLCal"], \
                                doCalib=2, gainUse=2, flagVer=0, doBand=-1, doPol=True,  \
                                refAnt=goodCal["bestRef"], niter=300, FOV=0.02/3600.0, \
                                nThreads=nThreads, noScrat=noScrat, logfile=logFile, check=check, debug=debug)
        if retCode != 0:
            raise RuntimeError("Error in RL phase calibration")

    # image targets possible with Stokes I(QU)
    if parms["doImgFullTarget"]:
        logger.info("--> Image targets (doImgFullTargets)")
        if not uvc:
            # Get calibrated/averaged data
            Aname = VLBAAIPSName(project, session)
            uvname = project + "_" + session + "_" + band + "_Cal"
            uvc = UV.newPAUV(uvname, Aname, parms["avgClass"], disk, seq, True,
                             err)
            if err.isErr:
                OErr.printErrMsg(err, "Error creating cal/avg AIPS data")
        VLBAImageTargets(uvc,
                         err,
                         Sources=parms["targets"],
                         seq=seq,
                         sclass=parms["outIclass"],
                         doCalib=2,
                         flagVer=0,
                         doBand=-1,
                         Stokes=parms["Stokes"],
                         FOV=parms["FOV"],
                         Robust=parms["Robust"],
                         maxPSCLoop=2,
                         minFluxPSC=parms["minFluxPSC"],
                         solPInt=parms["solPInt"],
                         solMode="P",
                         maxASCLoop=parms["maxASCLoop"],
                         minFluxASC=parms["minFluxASC"],
                         solAInt=parms["solAInt"],
                         avgPol=parms["avgPol"],
                         avgIF=parms["avgIF"],
                         minSNR=parms["minSNR"],
                         refAnt=goodCal["bestRef"],
                         nTaper=parms["nTaper"],
                         Tapers=parms["Tapers"],
                         do3D=parms["do3D"],
                         nThreads=nThreads,
                         noScrat=noScrat,
                         logfile=logFile,
                         check=check,
                         debug=debug)

    # Save UV data?
    if parms["doSaveUV"] and (not check):
        logger.info("--> Save UV data (doSaveUV)")
        mess = "Write calibrated and averaged UV data to disk"
        printMess(mess, logFile)
        # Get calibrated/averaged data
        if not uvc:
            Aname = VLBAAIPSName(project, session)
            uvname = project + "_" + session + "_" + band + "_Cal"
            uvc = UV.newPAUV(uvname, Aname, parms["avgClass"], disk, seq, True,
                             err)
            if err.isErr:
                OErr.printErrMsg(err, "Error creating cal/avg AIPS data")
        # Write
        filename = project + session + band + "CalAvg.uvtab"
        fuv = VLBAUVFITS(uvc, filename, 0, err, compress=Compress)
        VLBAAddOutFile(filename, 'project', "Calibrated Averaged UV data")
        # Save list of output files
        VLBASaveOutFiles()

    # Save UV data tables?
    if parms["doSaveTab"] and (not check):
        logger.info("--> Save UV data tables (doSaveTab)")
        mess = "Write UV data tables to disk."
        printMess(mess, logFile)
        filename = project + session + band + "CalTab.uvtab"
        fuv = VLBAUVFITSTab(uv, filename, 0, err)
        VLBAAddOutFile(filename, 'project', "Calibrated AIPS tables")
        # Save list of output files
        VLBASaveOutFiles()
    # Imaging results
    outDisk = 0
    if parms["doSaveImg"]:
        logger.info("--> Save images (doSaveImg)")
        mess = "Write images to disk."
        printMess(mess, logFile)
        # How many Stokes images
        nstok = len(parms["Stokes"])
        # Targets
        logger.debug("parms['targets'] = " + str(parms['targets']))
        for target in parms["targets"]:
            if not check:
                # intermediate images
                oclass = parms["outTclass"]
                x = Image.newPAImage("out", target, oclass, disk, seq, True,
                                     err)
                if (not x.exist):
                    print(target, "image not found. Skipping.")
                    continue
                outfile = project + session + band + target + "." + oclass + ".fits"
                mess = "Write Intermediate target " + outfile + " on disk " + str(
                    outDisk)
                VLBAAddOutFile(outfile, target, 'Intermediate target image')
                printMess(mess, logFile)
                xf = VLBAImFITS(x, outfile, outDisk, err, fract=0.1)
                # Save list of output files
                VLBASaveOutFiles()
                # Statistics
                zz = imstat(x, err, logfile=logFile)
                del x, xf
                # Final images
                for istok in range(0, nstok):
                    oclass = parms["Stokes"][istok:istok +
                                             1] + parms["outIclass"][1:]
                    x = Image.newPAImage("out", target, oclass, disk, seq,
                                         True, err)
                    outfile = project + session + band + target + "." + oclass + ".fits"
                    logger.info("Write " + outfile + " on disk " +
                                str(outDisk))
                    xf = VLBAImFITS(x, outfile, outDisk, err, fract=0.1)
                    VLBAAddOutFile(outfile, target, 'Image')
                    logger.info("Writing file " + outfile)
                    # Statistics
                    zz = imstat(x, err, logfile=logFile)
                    del x, xf
                    # Save list of output files
                    VLBASaveOutFiles()
        # Calibrators
        for target in parms["contCals"]:
            if not check:
                oclass = parms["outCclass"]
                x = Image.newPAImage("out", target, oclass, disk, seq, True,
                                     err)
                if (not x.exist):
                    print(target, "image not found. Skipping.")
                    continue
                outfile = project + session + band + target + "." + oclass + ".fits"
                mess = "Write Calibrator " + outfile + " on disk " + str(
                    outDisk)
                printMess(mess, logFile)
                xf = VLBAImFITS(x, outfile, outDisk, err, fract=0.1)
                VLBAAddOutFile(outfile, target, 'Calibrator Image')
                # Statistics
                zz = imstat(x, err, logfile=logFile)
                del x, xf
                # Save list of output files
                VLBASaveOutFiles()
        # end writing images loop

    # Contour plots
    if parms["doKntrPlots"]:
        logger.info("--> Contour plots (doKntrPlots)")
        VLBAKntrPlots(err,
                      imName=parms["targets"],
                      project=project,
                      session=session,
                      band=band,
                      disk=disk,
                      debug=debug)
        # Save list of output files
        VLBASaveOutFiles()
    elif debug:
        print("Not creating contour plots ( doKntrPlots = ",
              parms["doKntrPlots"], " )")

    # Source uv plane diagnostic plots
    if parms["doDiagPlots"]:
        logger.info("--> Diagnostic plots (doDiagPlots)")
        # Get the highest number avgClass catalog file
        Aname = VLBAAIPSName(project, session)
        uvc = None
        if not check:
            uvname = project + "_" + session + "_" + band + "_Cal"
            uvc = UV.newPAUV(uvname, Aname, parms["avgClass"], disk, seq, True,
                             err)
        VLBADiagPlots( uvc, err, cleanUp=parms["doCleanup"], \
                           project=project, session=session, band=band, \
                           logfile=logFile, check=check, debug=debug )
        # Save list of output files
        VLBASaveOutFiles()
    elif debug:
        print("Not creating diagnostic plots ( doDiagPlots = ",
              parms["doDiagPlots"], " )")

    # Save metadata
    srcMetadata = None
    projMetadata = None
    if parms["doMetadata"]:
        logger.info("--> Save metadata (doMetadata)")
        if not uvc:
            # Get calibrated/averaged data
            Aname = VLBAAIPSName(project, session)
            uvname = project + "_" + session + "_" + band + "_Cal"
            uvc = UV.newPAUV(uvname, Aname, parms["avgClass"], disk, seq, True,
                             err)
            if err.isErr:
                OErr.printErrMsg(err, "Error creating cal/avg AIPS data")

        # Get source metadata; save to pickle file
        srcMetadata = VLBASrcMetadata(uvc,
                                      err,
                                      Sources=parms["targets"],
                                      seq=seq,
                                      sclass=parms["outIclass"],
                                      Stokes=parms["Stokes"],
                                      logfile=logFile,
                                      check=check,
                                      debug=debug)
        picklefile = project + "_" + session + "_" + band + "SrcReport.pickle"
        SaveObject(srcMetadata, picklefile, True)
        VLBAAddOutFile(picklefile, 'project', 'All source metadata')

        # Get project metadata; save to pickle file
        projMetadata = VLBAProjMetadata(uvc,
                                        AIPS_VERSION,
                                        err,
                                        contCals=parms["contCals"],
                                        goodCal=goodCal,
                                        project=project,
                                        session=session,
                                        band=band,
                                        dataInUVF=dataInUVF,
                                        archFileID=archFileID)
        picklefile = project + "_" + session + "_" + band + "ProjReport.pickle"
        SaveObject(projMetadata, picklefile, True)
        VLBAAddOutFile(picklefile, 'project', 'Project metadata')

    # Write report
    if parms["doHTML"]:
        logger.info("--> Write HTML report (doHTML)")
        VLBAHTMLReport( projMetadata, srcMetadata, \
                            outfile=project+"_"+session+"_"+band+"report.html", \
                            logFile=logFile )

    # Write VOTable
    if parms["doVOTable"]:
        logger.info("--> Write VOTable (doVOTable)")
        VLBAAddOutFile('VOTable.xml', 'project', 'VOTable report')
        VLBAWriteVOTable(projMetadata, srcMetadata, filename='VOTable.xml')

    # Save list of output files
    VLBASaveOutFiles()

    # Cleanup - delete AIPS files
    if parms["doCleanup"] and (not check):
        logger.info("--> Clean up (doCleanup)")
        # Delete target images
        # How many Stokes images
        nstok = len(parms["Stokes"])
        for istok in range(0, nstok):
            oclass = parms["Stokes"][istok:istok + 1] + parms["outIclass"][1:]
            AllDest(err, disk=disk, Aseq=seq, Aclass=oclass)

        # delete Calibrator images
        AllDest(err, disk=disk, Aseq=seq, Aclass=parms["outCclass"])

        # Delete intermediate target images
        AllDest(err, disk=disk, Aseq=seq, Aclass=parms["outTclass"])
        OErr.printErrMsg(err, "Deleting AIPS images")

        # Delete UV data
        uv.Zap(err)
        # Zap calibrated/averaged data
        if not uvc:
            Aname = VLBAAIPSName(project, session)
            uvc = UV.newPAUV("AIPS UV DATA", Aname, parms["avgClass"], disk,
                             seq, True, err)
            if err.isErr:
                OErr.printErrMsg(err, "Error creating cal/avg AIPS data")
        uvc.Zap(err)
        OErr.printErrMsg(err, "Writing output/cleanup")

    # Shutdown
    mess = "Finished project " + project
    printMess(mess, logFile)
    OErr.printErr(err)
    OSystem.Shutdown(ObitSys)
コード例 #24
0
ファイル: UVImager.py プロジェクト: mauch/Obit
def PUVCreateImager(err, name='myUVImager', input=UVCreateImagerInput):
    """ Create an imager to generate a set of images needed to cover a region.

    Create and return a Python Obit UVImager based on input parameters and
    uv data to be imaged.  Images should be fully defined when returned.
    err     = Python Obit Error/message stack
    name    = Name for output object
    input   = input parameter dictionary
    
    Input dictionary entries:
    InData   = Input Python UV data to image
    doCalSelect = Select/calibrate/edit data?),
    Stokes   = Stokes parameter, blank-> unchanged from input),
    BChan    = First spectral channel selected. [def all]),
    EChan    = Highest spectral channel selected. [def all]),
    BIF      = First IF selected. [def all]),
    EIF      = Highest IF selected. [def all]),
    doPol    = >0 -> calibrate polarization.),
    doCalib  = >0 -> calibrate, 2=> also calibrate Weights),
    gainUse  = SN/CL table version number, 0-> use highest),
    flagVer  = Flag table version, 0-> use highest, <0-> none),
    BLVer    = BL table version, 0> use highest, <0-> none),
    BPVer    = Band pass (BP) table version, 0-> use highest),
    Subarray = Selected subarray, <=0->all [default all]),
    freqID   = Selected Frequency ID, <=0->all [default all]),
    timeRange= Selected timerange in days. [2 floats] 0s -> all),
    UVRange  = Selected UV range in wavelengths. 0s -> all),
    Sources  = Source names selected unless any starts with),
    Antennas = A list of selected antenna numbers, if any is negative),
    corrType = Correlation type, 0=cross corr only, 1=both, 2=auto only.),
    doBand   = Band pass application type <0-> none),
    Smooth   = Specifies the type of spectral smoothing [three floats]
    DoWeight = True if Weighting to be applied
    Robust   = Briggs robust parameter. (AIPS definition)
    UVTaper  = UV plane taper, sigma in klambda,deg as [maj, min, pa]
    WtSize   = Size of weighting grid in cells [same as image nx]
    WtBox    = Size of weighting box in cells [def 1]
    WtFunc   = Weighting convolution function [def. 1]
               1=Pill box, 2=linear, 3=exponential, 4=Gaussian
               if positive, function is of radius, negative in u and v.
    WtPower  = Power to raise weights to.  [def = 1.0]
               Note: a power of 0.0 sets all the output weights to 1 as modified
               by uniform/Tapering weighting.
               Applied in determinng weights as well as after.
    DoBeam   = True if beams are to be made
    Type     = Underlying file type, 0=FITS, 1=AIPS
    Name     = Name of image, used as AIPS name or to derive FITS filename
    Class    = Root of class, used as AIPS class or to derive FITS filename
    Seq      = Sequence number
    Disk     = Disk number for underlying files
    FOV      = Field of view (deg) for Mosaic
    doFull   = If True, create full field (FOV) image
    NField   = Number of fields defined in input,
               if unspecified derive from data and FOV
    xCells   = Cell spacing in X (asec) for all images,
               if unspecified derive from data
    yCells   = Cell spacing in Y (asec) for all images,
               if unspecified derive from data
    nx       = Minimum number of cells in X for NField images
               if unspecified derive from data
    ny       = Minimum number of cells in Y for NField images
               if unspecified derive from data
    RAShift  = Right ascension shift (AIPS convention) for each field
               if unspecified derive from FOV and data
    DecShift = Declination for each field
               if unspecified derive from FOV and data
    Catalog  = AIPSVZ format catalog for defining outliers, None=do not use
    OutlierFlux = Minimum estimated outlyer flux density (Jy)
    OutlierDist = Maximum distance to add outlyers (deg)
    OutlierSI   = Spectral index to estimate flux density
    OutlierSize = Size of outlyer field (pixels)

    returns = Output UVImager with defined ImageMosaic
    """
    ################################################################
    # Get input parameters
    InData = input["InData"]
    #
    # Checks
    if not UV.PIsA(InData):
        raise TypeError, 'UVCreateImage: Bad input UV data'
    # Set control values on UV
    dim[0] = 1
    dim[1] = 1
    dim[2] = 1
    dim[3] = 1
    dim[4] = 1
    inInfo = UV.PGetList(InData)  # Add control to UV data
    # Calibration/editing/selection
    InfoList.PAlwaysPutBoolean(inInfo, "doCalSelect", dim,
                               [input["doCalSelect"]])
    dim[0] = 4
    InfoList.PAlwaysPutString(inInfo, "Stokes", dim, [input["Stokes"]])
    dim[0] = 1
    InfoList.PAlwaysPutInt(inInfo, "BChan", dim, [input["BChan"]])
    InfoList.PAlwaysPutInt(inInfo, "EChan", dim, [input["EChan"]])
    InfoList.PAlwaysPutInt(inInfo, "BIF", dim, [input["BIF"]])
    InfoList.PAlwaysPutInt(inInfo, "EIF", dim, [input["EIF"]])
    itemp = int(input["doPol"])
    InfoList.PAlwaysPutInt(inInfo, "doPol", dim, [itemp])
    InfoList.PAlwaysPutInt(inInfo, "doCalib", dim, [input["doCalib"]])
    InfoList.PAlwaysPutInt(inInfo, "doBand", dim, [input["doBand"]])
    InfoList.PAlwaysPutInt(inInfo, "gainUse", dim, [input["gainUse"]])
    InfoList.PAlwaysPutInt(inInfo, "flagVer", dim, [input["flagVer"]])
    InfoList.PAlwaysPutInt(inInfo, "BLVer", dim, [input["BLVer"]])
    InfoList.PAlwaysPutInt(inInfo, "BPVer", dim, [input["BPVer"]])
    InfoList.PAlwaysPutInt(inInfo, "Subarray", dim, [input["Subarray"]])
    InfoList.PAlwaysPutInt(inInfo, "freqID", dim, [input["freqID"]])
    InfoList.PAlwaysPutInt(inInfo, "corrType", dim, [input["corrType"]])
    dim[0] = 2
    InfoList.PAlwaysPutFloat(inInfo, "UVRange", dim, input["UVRange"])
    dim[0] = 3
    InfoList.PAlwaysPutFloat(inInfo, "Smooth", dim, input["Smooth"])
    dim[0] = 2
    InfoList.PAlwaysPutFloat(inInfo, "timeRange", dim, input["timeRange"])
    dim[0] = len(input["Antennas"])
    InfoList.PAlwaysPutInt(inInfo, "Antennas", dim, input["Antennas"])
    dim[0] = 16
    dim[1] = len(input["Sources"])
    InfoList.PAlwaysPutString(inInfo, "Sources", dim, input["Sources"])
    # Weighting parameters
    dim[0] = 1
    dim[1] = 1
    InfoList.PAlwaysPutFloat(inInfo, "Robust", dim, [input["Robust"]])
    InfoList.PAlwaysPutInt(inInfo, "WtBox", dim, [input["WtBox"]])
    InfoList.PAlwaysPutInt(inInfo, "WtFunc", dim, [input["WtFunc"]])
    InfoList.PAlwaysPutFloat(inInfo, "WtPower", dim, [input["WtPower"]])
    dim[0] = len(input["UVTaper"])
    InfoList.PAlwaysPutFloat(inInfo, "UVTaper", dim, input["UVTaper"])
    WtSize = input["WtSize"]
    if (WtSize > 0):
        print "WtSize", WtSize
        # Change name for C routine.
        dim[0] = 1
        InfoList.PAlwaysPutInt(inInfo, "nuGrid", dim, [WtSize])
        InfoList.PAlwaysPutInt(inInfo, "nvGrid", dim, [WtSize])
    # Define image
    dim[0] = 1
    dim[1] = 1
    InfoList.PAlwaysPutInt(inInfo, "imFileType", dim, [input["Type"]])
    InfoList.PAlwaysPutInt(inInfo, "imSeq", dim, [input["Seq"]])
    InfoList.PAlwaysPutInt(inInfo, "imDisk", dim, [input["Disk"]])
    InfoList.PAlwaysPutFloat(inInfo, "FOV", dim, [input["FOV"]])
    InfoList.PAlwaysPutBoolean(inInfo, "doFull", dim, [input["doFull"]])
    InfoList.PAlwaysPutInt(inInfo, "NField", dim, [input["NField"]])
    InfoList.PAlwaysPutFloat(inInfo, "xCells", dim, [input["xCells"]])
    InfoList.PAlwaysPutFloat(inInfo, "yCells", dim, [input["yCells"]])
    InfoList.PAlwaysPutFloat(inInfo, "OutlierFlux", dim,
                             [input["OutlierFlux"]])
    InfoList.PAlwaysPutFloat(inInfo, "OutlierDist", dim,
                             [input["OutlierDist"]])
    InfoList.PAlwaysPutFloat(inInfo, "OutlierSI", dim, [input["OutlierSI"]])
    InfoList.PAlwaysPutInt(inInfo, "OutlierSize", dim, [input["OutlierSize"]])
    dim[0] = len(input["Name"])
    InfoList.PAlwaysPutString(inInfo, "imName", dim, [input["Name"]])
    dim[0] = len(input["Class"])
    InfoList.PAlwaysPutString(inInfo, "imClass", dim, [input["Class"]])
    dim[0] = len(input["Catalog"])
    InfoList.PAlwaysPutString(inInfo, "Catalog", dim, [input["Catalog"]])
    dim[0] = len(input["nx"])
    InfoList.PAlwaysPutInt(inInfo, "nx", dim, input["nx"])
    dim[0] = len(input["ny"])
    InfoList.PAlwaysPutInt(inInfo, "ny", dim, input["ny"])
    dim[0] = len(input["RAShift"])
    InfoList.PAlwaysPutFloat(inInfo, "RAShift", dim, input["RAShift"])
    dim[0] = len(input["DecShift"])
    InfoList.PAlwaysPutFloat(inInfo, "DecShift", dim, input["DecShift"])
    #
    # Create
    out = UVImager(name, InData.me, err.me)
    # show any errors
    #OErr.printErrMsg(err, "UVImage: Error creating UVImager object")
    #
    return out
コード例 #25
0
ファイル: VLBALinePipe.py プロジェクト: mauch/Obit
mess = "Start project " + project + " session " + session + " " + band + " Band"
printMess(mess, logFile)
if debug:
    mess = "Using Debug mode "
    printMess(mess, logFile)
if check:
    mess = "Only checking script"
    printMess(mess, logFile)

# Load Data from FITS
uv = None
if doLoadIDI:
    uv = VLBAIDILoad(dataIn, project, session, band, dataClass, disk, seq, err, logfile=logFile, \
                         wtThresh=wtThresh, calInt=calInt, Compress=Compress, \
                         check=check, debug=debug)
    if not UV.PIsA(uv):
        raise RuntimeError, "Cannot load " + dataIn
# Otherwise set uv
if uv == None and not check:
    Aname = VLBAAIPSName(project, session)
    uv = UV.newPAUV("AIPS UV DATA", Aname, dataClass, disk, seq, True, err)
    if err.isErr:
        OErr.printErrMsg(err, "Error creating AIPS data")

# Clear any old calibration/editing
if doClearTab:
    VLBAClearCal(uv,
                 err,
                 doGain=doGain,
                 doFlag=doFlag,
                 doBP=doBP,
コード例 #26
0
ファイル: UVPolnUtil.py プロジェクト: mauch/Obit-1
def ExtractPD (inUV, ant, err, PDVer=1, inc=1):
    """ Extract data from PD table

    return dict:
     'Elip1' array of elipticities poln 1 in deg
     'Ori1'  array of orientations poln 1 in deg
     'Elip2' array of elipticities poln 2 in deg
     'Ori2'  array of orientations poln 2 in deg
     'Freqs' array of frequencies corresponding to data
     'refant' reference antenna
     'ant'    antenna
    * inUV  = Obit UV data with tables
    * ant   = antenna number
    * err   = Obit error/message stack
    * PDVer = PD table version
    * inc   = increment in spectrum
    """
      ################################################################
    # Checks
    if not UV.PIsA(inUV):
        print("Actually ",inUV.__class__)
        raise TypeError("inUV MUST be a Python Obit UV")
    
    e1 = []; e2 = []; o1 = []; o2 = []
    # Get table
    PDTab = inUV.NewTable(Table.READONLY,"AIPS PD",PDVer,err)
    # Open table, find antenna
    PDTab.Open(Table.READONLY, err)
    nrow = PDTab.Desc.Dict['nrow']
    for irow in range (1,nrow+1):
        row = PDTab.ReadRow(irow, err)
        if row['ANTENNA'][0]==ant:
            break
    for i in range(0,len(row['REAL 1']),inc):
        e = row['REAL 1'][i]
        # Bad soln?
        if e==fblank:
            e1.append(fblank); e2.append(fblank); 
            o1.append(fblank); o2.append(fblank); 
        else:
            # Fold elipticities to range [-45, 45]
            e = math.degrees(e)
            o = math.degrees(row['IMAG 1'][i])
            if e>45.0:
                e = 90.0 - e
                o = -o
            if o>180.0:
                o -= 360.
            if o<-180.0:
                o += 360
            # Default values probably bad
            if e>=44.999 and o==0.0:
                e = fblank; o = fblank
            e1.append(e)
            o1.append(o)
            e = math.degrees(row['REAL 2'][i])
            o = math.degrees(row['IMAG 2'][i])
            if e<-45.0:
                e = -(90.0 + e)
                o = -o
            if o>180.0:
                o -= 360.
            if o<-180.0:
                o += 360
            if e<=-44.999 and o==0.0:
                e = fblank; o = fblank
            e2.append(e)
            o2.append(o)
    refant = row['REFANT'][0]
    ant    = row['ANTENNA'][0]
    del row
    PDTab.Close(err)
    # Get frequencies
    f = GetFreqArr(inUV, err)
    # select by inc in GHz
    frqs = []
    for i in range(0,len(f),inc):
        frqs.append(f[i]*1.0e-9)
    return {'Elip1':e1, 'Ori1':o1, 'Elip2':e2, 'Ori2':o2, 'refant':refant, 'ant':ant, 'Freqs':frqs}
コード例 #27
0
ファイル: UVPolnUtil.py プロジェクト: mauch/Obit-1
def FitSource(inUV, souID, err, CPVer=1, inc=1):
    """
    Fit the RM of a source in a CP table
    
    Return a dict with:
        "RM"       = fitted RM (rad/m**2)
        "RMErr"    = fitted RM error
        "EVPA0"    = EVPA at "RefLamb2 (rad)
        "EVPAErr"  = error in EVPA
        "RefLamb2" = reference Lambda^2
        "Lamb2"    = array of lamb2 (m**2)
        "FPol"  = array of fractional poln
        "EVPA   = array of EVPA (rad) of poln
    * inUV     = Obit UV data with tables
    * souID    = source ID
    * err      = Python Obit Error/message stack
    * CPVer    = CP table version
    * inc      = incremant between channels to use
    """
    ################################################################
    # Checks
    if not UV.PIsA(inUV):
        print("Actually ",inUV.__class__)
        raise TypeError("inUV MUST be a Python Obit UV")

    # Get table
    cptab = inUV.NewTable(Table.READONLY,"AIPS CP",CPVer,err)
    cptab.Open(Table.READONLY,err)
    nrow = cptab.Desc.Dict["nrow"]
    # Find souID
    IPol = None
    for irow in range (1,nrow+1):
        cprow=cptab.ReadRow(irow,err)
        if souID == cprow["SOURCE ID"][0]:
            IPol  = cprow["I"]
            QPol  = cprow["Q"]
            UPol  = cprow["U"]
            break
    # end loop looking for souID
    # Find it?
    if IPol==None:
        raise  RuntimeError("No CP entry for source ID "+str(souID))
    # Get lambda^2 array
    lamb2 = GetLamb2(inUV, err)
    # Check consistency
    if len(IPol)!=len(lamb2):
        raise  RuntimeError("Size of CP entries ("+str(len(IPol))+") NOT number of channels ("+str(len(lamb2))+")")
    # Get fitting parameters with descimation by inc
    l2 = [];  QObs = []; Qsig = []; UObs = []; Usig = [];
    FPol = []; EVPA = []
    for i in range (0, len(lamb2), inc):
        if IPol[i]>0.0:
            l2.append(lamb2[i])
            QObs.append(QPol[i]); Qsig.append(0.001)
            UObs.append(UPol[i]); Usig.append(0.001)
            EVPA.append(0.5*math.atan2(UPol[i], QPol[i]))
            FPol.append(((QPol[i]**2+UPol[i]**2)**0.5)/IPol[i])
    # end loop getting data arrays
    # Fit RM
    refLamb2 = l2[len(l2)/2]
    RMParms = RMFit.PSingle(refLamb2, l2, QObs, Qsig, UObs, Usig, err)
    print("debug RMParms",RMParms)
    print("Fitted RM=%f (%f), EVPA=%f(%f)"\
        %(RMParms[0],RMParms[2],math.degrees(RMParms[1]),math.degrees(RMParms[3])))
    return{"RM":RMParms[0], "RMErr":RMParms[2], "EVPA0":RMParms[1], "EVPAErr":RMParms[3], \
               "RefLamb2":refLamb2 ,"Lamb2":l2, "FPol":FPol, "EVPA":EVPA}
コード例 #28
0
ファイル: PeelScripts.py プロジェクト: bill-cotton/Obit
def UVSub4Peel(uv, source, im, inCC, err, \
                   nfield=1, doGPU=False, gainUse=1, flagVer=-1, \
                   nThreads=1, noScrat=[0,0,0], taskLog='', debug=False):
    """
    Sets up for subtraction of non peel sources from data
    
    UV data should be have calibration tables from self calibration
    Output data will be on the same disk as the input, seq=1, class='4Peel' and
    with the name of the source (up to 12 char)
    Returns UVSub task object
    * uv        Dataset to be subtracted from
    * source    source name
    * im        Python Image with CC Tables
    * inCC      input CC version, should have had the peel source CCs removed
                using SelectCC
    * err       Python Obit Error/message stack
    * doGPU     Use GPU if available?
    * nfield    Number of facet images
    * gainUse   CL (SN) table to apply, -1=> no cal
    * flagVer   FG table to apply, -1=> no flag
    * noThreads number of threads to use
    * noScrat   AIPS disks not to use for scratch
    * taskLog   Log file
    * debug     If True leave debug Input file in /tmp
    """
    ################################################################
    # Checks
    if not UV.PIsA(uv):
        raise TypeError("uv MUST be a Python Obit UV data")
    if not Image.PIsA(im):
        raise TypeError("im MUST be a Python Obit Image")
    if not OErr.OErrIsA(err):
        raise TypeError("err MUST be an OErr")
    uvsub = ObitTask('UVSub')
    setname(uv, uvsub)
    set2name(im, uvsub)
    uvsub.CCVer = inCC
    uvsub.nfield = nfield
    if uv.FileType == 'AIPS':
        uvsub.DataType = 'AIPS'
    else:
        uvsub.DataType = 'FITS'
    if im.FileType == 'AIPS':
        uvsub.DataType2 = 'AIPS'
    else:
        uvsub.DataType2 = 'FITS'
    uvsub.outDisk = uvsub.inDisk
    uvsub.outSeq = 1
    uvsub.outClass = '4Peel'
    uvsub.outName = source[0:12]
    uvsub.nThreads = nThreads
    uvsub.noScrat = noScrat
    uvsub.Cmethod = 'DFT'
    uvsub.noNeg = False
    uvsub.doGPU = doGPU
    uvsub.PBCor = False
    uvsub.taskLog = taskLog
    uvsub.debug = debug
    uvsub.flagVer = flagVer
    uvsub.Sources[0] = source
    if gainUse >= 0:
        uvsub.doCalib = 2
        uvsub.gainUse = gainUse
    return uvsub
コード例 #29
0
ファイル: PeelScripts.py プロジェクト: bill-cotton/Obit
def SubPeel(uv, source, imp, uvp, err, addBack=False, seq=999, \
                flagVer=0, nThreads=1, doGPU=False, noScrat=[0,0,0], taskLog='', debug=False):
    """
    Subtract Peel model w/ solutions, then optionally add back w/o corruptions
    
    UV data should have calibration tables from self calibration
    Output data will be on the same disk as the input, seq=seq, class='PelSub' and
    with name = source (up to 12 char).
    Returns Peel source subtracted/replaced data
    * uv        Dataset with cal tables
                Needs at least the self cal gain table
    * source    source name
    * imp       Peel source model (CC table from ImagePeel)
    * uvp       UV data the result of peel (ImagePeel)
    * err       Python Obit Error/message stack
    * seq       Sequence number for output
    * addBack   Add model back to data w/o corruptions? Not recommended.
    * flagVer   FG table to apply, -1=> no flag
    * nThreads  number of threads to use
    * doGPU     Use GPU if available?
    * noScrat   AIPS disks not to use for scratch
    * taskLog   Log file
    * debug     If True leave debug Input file in /tmp
    """
    ################################################################
    # Checks
    if not UV.PIsA(uv):
        raise TypeError("uv MUST be a Python Obit UV data")
    if not Image.PIsA(imp):
        raise TypeError("imp MUST be a Python Obit Image")
    if not OErr.OErrIsA(err):
        raise TypeError("err MUST be an OErr")
    # Split main data set
    OErr.PLog(err, OErr.Info, "Copy data")
    OErr.printErr(err)
    split = ObitTask('Split')
    setname(uv, split)
    split.outDisk = split.inDisk
    split.outSeq = seq
    split.outClass = 'UPeel'
    split.Sources[0] = source
    split.flagVer = flagVer
    if uv.GetHighVer('AIPS SN') > 0:
        split.doCalib = 2
        split.gainUse = 0
        split.doCalWt = True
    else:
        split.doCalib = -1
    split.taskLog = taskLog
    split.debug = debug
    split.g
    outClass = split.outClass
    outDisk = split.outDisk
    outSeq = split.outSeq

    # Get data
    OErr.PLog(err, OErr.Info, "Make Peel model with corruptions")
    OErr.printErr(err)
    if UV.AExist(source[0:12], outClass, outDisk, outSeq, err):
        datauv = UV.newPAUV('data', source[0:12], outClass, outDisk, outSeq,
                            True, err)
    else:
        datauv = UV.newPAUV('data', source[0:8], outClass, outDisk, outSeq,
                            True, err)
    # Make data set with the model peel source with peel cal applied
    uvsub = ObitTask('UVSub')
    setname(uv, uvsub)
    uvsub.outName = source[0:12]
    uvsub.outDisk = uvsub.inDisk
    uvsub.outSeq = 1
    uvsub.outClass = 'Model'
    uvsub.Sources[0] = source
    uvsub.flagVer = flagVer
    uvsub.doCalib = -1
    uvsub.gainUse = 0
    set2name(imp, uvsub)
    uvsub.CCVer = 1
    uvsub.nfield = 1
    uvsub.Cmethod = 'DFT'
    uvsub.Opcode = 'MODL'
    uvsub.PBCor = False
    uvsub.noScrat = noScrat
    uvsub.noNeg = False
    uvsub.taskLog = taskLog
    uvsub.nThreads = nThreads
    uvsub.doGPU = doGPU
    uvsub.debug = debug
    uvsub.g

    # Get model data
    modeluv = UV.newPAUV('model', uvsub.outName, uvsub.outClass, uvsub.outDisk,
                         uvsub.outSeq, True, err)
    # Copy/invert/unblank SN table from peeluv
    hiPeelSN = uvp.GetHighVer('AIPS SN')
    inTab = max(1, hiPeelSN)
    sntab = uvp.NewTable(Table.READONLY, 'AIPS SN', inTab, err)
    z = UVSelfCal.PInvertSN(sntab, modeluv, 1, True, err)
    # Apply calibration table in subtract
    modeluv.List.set('doCalSelect', True)
    modeluv.List.set('doCalib', 2)
    modeluv.List.set('gainUse', 1)
    modeluv.List.set('passAll', True)

    # Subtract model from main data
    OErr.PLog(err, OErr.Info, "Subtract Corrupted Peel model from uv data")
    UV.PUtilVisSub(datauv, modeluv, datauv, err)
    OErr.printErr(err)

    # Add model without corrupting calibration
    if addBack:
        OErr.PLog(err, OErr.Info, "Add Peel model without corruptions")
        uvsub = ObitTask('UVSub')
        setname(datauv, uvsub)
        setoname(datauv, uvsub)
        uvsub.outSeq = uvsub.inSeq + 1
        uvsub.Sources[0] = source
        uvsub.flagVer = flagVer
        uvsub.doCalib = -1
        uvsub.gainUse = 0
        set2name(imp, uvsub)
        uvsub.CCVer = 1
        uvsub.nfield = 1
        uvsub.Cmethod = 'DFT'
        uvsub.Factor = -1.
        uvsub.PBCor = False
        uvsub.noScrat = noScrat
        uvsub.noNeg = False
        uvsub.taskLog = taskLog
        uvsub.nThreads = nThreads
        uvsub.doGPU = doGPU
        uvsub.debug = debug
        uvsub.g
        outClass = uvsub.outClass
        outDisk = uvsub.outDisk
        outSeq = uvsub.outSeq
        # end add back
    OErr.printErr(err)
    # Delete model dataset
    if not debug:
        modeluv.Zap(err)

# final data
    if UV.AExist(source[0:12], outClass, outDisk, outSeq, err):
        datauv2 = UV.newPAUV('data', source[0:12], outClass, outDisk, outSeq,
                             True, err)
    else:
        datauv2 = UV.newPAUV('data', source[0:8], outClass, outDisk, outSeq,
                             True, err)
    return datauv2
コード例 #30
0
def PCal (inSC, err, input=UVSelfCalCalInput):
    """ Self calibrate data

    Determine a gain table from a set of data assumed divided by model.
    Solution table attached to  OutData
    inSC    = Selfcal object
    err     = Python Obit Error/message stack
    input   = input parameter dictionary
    
    Input dictionary entries:
    InData   = Input Python UV data from which to determine calibration
               Should have been divided by model if not a point source.
    OutData  = UV data to which output SN table will be attached.
    subA     = Selected subarray (default 1)
    solInt   = Solution interval (min). (default 1 sec)
    refAnt   = Ref ant to use. (default 1)
    avgPol   = True if RR and LL to be averaged (false)
    avgIF    = True if all IFs to be averaged (false)
    minSNR   = Minimum acceptable SNR (5)
    doMGM    = True then find the mean gain modulus (true)
    solType  = Solution type '  ', 'L1',  (' ')
    solMode  = Solution mode: 'A&P', 'P', 'P!A', 'GCON' ('P')
    minNo    = Min. no. antennas. (default 4)
    WtUV     = Weight outside of UV_Full. (default 1.0)
    antWt    = Weight per antenna, def all 1
    prtLv    = Print level (default no print)
    returns  = Output SN Table with solution
    """
    ################################################################
    # Get input parameters
    InData    = input["InData"]
    OutData   = input["OutData"]
    #
    # Checks
    if not PIsA(inSC):
        raise TypeError('Bad input selfcalibrator')
    if not UV.PIsA(InData):
        raise TypeError('Bad input UV data')
    if not UV.PIsA(OutData):
        raise TypeError('Bad output UV data')
    dim = [1,1,1,1,1]
    # Create solver
    solver = UVGSolve.newObit("Selfcal Solver", err)
    # Set control values on solver
    dim[0] = 1;
    inInfo = PGetList(solver)    # 
    InfoList.PPutInt     (inInfo, "subA",   dim, [input["subA"]],  err)
    InfoList.PPutInt     (inInfo, "refAnt", dim, [input["refAnt"]],err)
    InfoList.PPutInt     (inInfo, "minNo",  dim, [input["minNo"]], err)
    InfoList.PPutInt     (inInfo, "prtLv",  dim, [input["prtLv"]], err)
    InfoList.PPutBoolean (inInfo, "avgPol", dim, [input["avgPol"]],err)
    InfoList.PPutBoolean (inInfo, "avgIF",  dim, [input["avgIF"]], err) 
    InfoList.PPutBoolean (inInfo, "doMGM",  dim, [input["doMGM"]], err)
    InfoList.PPutFloat   (inInfo, "solInt", dim, [input["solInt"]],  err)
    InfoList.PPutFloat   (inInfo, "minSNR", dim, [input["minSNR"]],  err)
    InfoList.PPutFloat   (inInfo, "WtUV",   dim, [input["WtUV"]],    err)
    dim[0] = len(input["solType"])
    InfoList.PAlwaysPutString  (inInfo, "solType",dim, [input["solType"]])
    dim[0] = len(input["solMode"])
    InfoList.PAlwaysPutString  (inInfo, "solMode",dim, [input["solMode"]])
    # antWt if given 
    if input["antWt"].__class__!=None.__class__:
        dim[0] = len(input["antWt"])
        InfoList.PAlwaysPutFloat (inInfo, "antWt",   dim, input["antWt"])
    # show any errors 
    OErr.printErrMsg(err, "UVSelfCalCreate: Error setting parameters")
    #
    # Create output
    outTable    = Table.Table("None")
    # Solve
    outTable.me = UVGSolveCal(solver.me, InData.me, OutData.me, err)
    #outTable.me = UVSelfCalCal(inSC.me, InData.me, OutData.me, err)
    # show any errors 
    OErr.printErrMsg(err, "UVSelfCalCal: Error Self-calibrating")
    #
    return outTable