Exemple #1
0
def POTFGetInstCal(inOTF, outOTF, err):
    """ Determine instrumental calibration for an OTF multibeam OTF dataset.

    Calculates average gain from cal measurements
    calculates median ofset
    Calibration parameters are on the inOTF info member.
    "solInt"   float scalar Solution interval in days [def 1 sec].
    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF from which the solution is to be determined
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFGetInstCal(inOTF.me, outOTF.me, err.me)
    return out
Exemple #2
0
def PMBBase(inOTF, outOTF, err):
    """ Fits polynomial additive term on median averages of a residual data set.

    Each solution interval in a scan is median averaged
    (average of 9 points around the median) and then a polynomial fitted.
    Calibration parameters are on the inOTF info member.
    "SolInt"    float scalar Solution interval in days [def 10 sec].
                This should not exceed 5000 samples.  Solutions will be truncated
                at this limit.
    "minEl"     float scalar Minimum elevation allowed (deg)
    "Order"     Polynomial order [def 1]
    "clipSig"   data outside of range +/- CLIP sigma are blanked [def large]
    "plotDet"   Detector number to plot per scan [def =-1 = none]
    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF (residual) from which the solution is to be determined
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFGetSolnMBBase(inOTF.me, outOTF.me, err.me)
    return out
Exemple #3
0
def PAtmEm(inOTF, outOTF, err):
    """ Set atmospheric emission corrections for an OTF dataset.

    Set atmospheric emission corrections into the detector offsets for an OTF dataset
    Results are placed in a newly created OTFSoln table.
    Calibration parameters are on the inOTF info member.
    "solInt"   float (1,1,1) Solution interval in days [def 10 sec].
    "AtmEm"    float (*,1,1) Equivalent zenith atmospheric brightness in Jy [0]
    "Tau0"     float (1,1,1) Zenith opacity in nepers [def 0].

    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF from which the solution is to be determined
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError,"inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError,"outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError,"err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr: # existing error?
        return out
    out.me = Obit.OTFGetAtmEm (inOTF.me, outOTF.me, err.me)
    return out
Exemple #4
0
def POTFSoln2Cal(inOTF, outOTF, err):
    """ Apply a Soln table to a Cal table and write a new Cal table

    Calibration parameters are on the inOTF info member.
    If an input Cal table is specified then apply Solutions in this routine,
    if no input Cal table, then copy the Soln table to a new Cal table
    in ObitOTFSolnCopyCal.
    "SOLNUSE"   int scalar Input Solution table version 
    "CALIN"     int scalar Input Cal table version 
                iff <0 then no input Cal table, copy Soln records to output.
    "CALOUT"    int scalar) Output Calibration table version
    returns updated OTFCal table
    inOTF   = Python Obit OTF from which the solution table is appended
    outOTF  = Python Obit OTF on which the calibration tables reside
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFSoln2Cal(inOTF.me, outOTF.me, err.me)
    return out
Exemple #5
0
def GetTargetPos(OTF, Target, err):
    """ Get target position from OTFTarget table

    return [raepo, decepo] in deg
    Loop through target table on OTF looking for Target and return position
    
    OTF      = OTF data file to check
    Target   = Name of target e.g. "MARS"
    """
    ################################################################
    # Checks
    if not OTF.OTFIsA():
        raise TypeError, "OTF MUST be a Python Obit OTF"
    if type(Target) != str:
        raise TypeError, "Target MUST be a string"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be an OErr"

    tarTab = OTF.NewTable(Table.READONLY, "OTFTarget", 1, err)
    tarTab.Open(Table.READONLY, err)
    OErr.printErrMsg(err, "Error with OTFTarget table")
    norow = tarTab.Desc.Dict["nrow"]
    for irow in range(1, norow + 1):
        row = tarTab.ReadRow(irow, err)
        if row["TARGET"][0].strip() == Target.strip():
            out = [row["RAEPO"][0], row["DECEPO"][0]]
            tarTab.Close(err)
            return out

    tarTab.Close(err)
    # Didn't find it if it gets here
    OErr.printErrMsg(err, "Error getting Target")
    raise RuntimeError, "Failed to find target " + Target + " in OTFTarget on " + OTF.GetName(
    )
    return [None, None]
Exemple #6
0
def PModelImage(inOTF, outOTF, image, desc, err):
    """ Replace OTF data with the model in a 2D ObitFArray

    inOTF   = input Python Obit OTF
    outOTF  = output Python Obit OTF, must be previously defined
    image   = Python Obit Image model to use, as FArray
    desc    = Python Obit ImageDesc for image
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not FArray.PIsA(image):
        raise TypeError, "image MUST be a Python Obit FArray"
    if not ImageDesc.PIsA(desc):
        raise TypeError, "desc MUST be a Python Obit ImageDesc"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilModelImage(inOTF.me, outOTF.me, image.me, desc.me, err.me)
Exemple #7
0
def PFilter(inOTF, outOTF, err):
    """ Determine offset calibration for an OTF by time filtering a residual data set.

    The time series of each detector is filtered to remove structure on time 
    scales shorter than solInt. 
    Scans in excess of 5000 samples will be broken into several.
    Calibration parameters are on the inOTF info member.
    "solInt"    float scalar Solution interval in days [def 10 sec].
                This should not exceed 1000 samples.  Solutions will be truncated
                at this limit.
    "minEl"     float scalar Minimum elevation allowed (deg)
    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF (residual) from which the solution is to be determined
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFGetSolnFilter(inOTF.me, outOTF.me, err.me)
    return out
Exemple #8
0
def PCal(inOTF, outOTF, err):
    """ Determine offset calibration for an OTF residual for multibeam systems


    Uses an Atmospheric model across the array of detectors.
    Calibration parameters are on the inOTF info member.
    "solInt"   float scalar Solution interval in days [def 1 sec].
    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF from which the solution is to be determined
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFGetSolnCal(inOTF.me, outOTF.me, err.me)
    return out
Exemple #9
0
def PSubImage(inOTF, outOTF, image, desc, err):
    """ Subtract a 2D ObitFArray from an OTF

    inOTF   = input Python Obit OTF
    outOTF  = output Python Obit OTF, must be previously defined
    image   = Python Obit Image data to subtract, as FArray
    desc    = Python Obit ImageDesc for image
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not FArray.PIsA(image):
        raise TypeError, "image MUST be a Python Obit FArray"
    if not ImageDesc.PIsA(desc):
        raise TypeError, "desc MUST be a Python Obit ImageDesc"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilSubImage(inOTF.me, outOTF.me, image.me, desc.me, err.me)
Exemple #10
0
def POTFGetDummyCal(inOTF, outOTF, inter, ver, ncoef, err):
    """ Create dummy OTFCal table table (applying will not modify data)

    returns OTFCal table with solutions
    inOTF   = input Python Obit OTF 
    outOTF  = Python Obit OTF onto which the cal table is to be appended.
    inter   = time interval (sec) between entries
    ver     = OTFCal table version
    ncoef   = Number of coefficients (across array feeds) in table
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    #
    # Set interval on table
    dim[0] = 1
    dim[1] = 1
    inInfo = Obit.OTFGetList(inOTF.me)  # return Obit object
    Obit.InfoListPutFloat(inInfo, "solInt", dim, [inter / 86400.0], err.me)
    out.me = Obit.OTFGetDummyCal(inOTF.me, outOTF.me, ver, ncoef, err.me)
    # Cleanup Obit objects
    inInfo = Obit.InfoListUnref(inInfo)
    #
    return out
Exemple #11
0
def POTFGetSolnPointTab(inOTF, outOTF, err):
    """ Write pointing corrections into a OTFSoln table

    Given a set of pointing correction, write to OTFSoln table
    Calibration parameters are on the inOTF info member.
        "POffset"   OBIT_float (3,?,1) Table of pointing offsets
                    Triplets (time(day), Azoff(asec), Decoff(asec))
                    MUST be in ascending time order
    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF from which the solution is to be determined
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFGetSolnPointTab(inOTF.me, outOTF.me, err.me)
    return out
Exemple #12
0
def PFlag(inOTF,
          err,
          timeRange=[0.0, 1.0e20],
          Target="Any",
          flagVer=1,
          Chans=[1, 0],
          Stokes="1111",
          Feed=0,
          Reason=" "):
    """ Adds entry to flag table

    Adds flagging table entry.
    Note: there is currently no sorting so the flagging entries must be
    added in time order
    inOTF     = Python Obit OTF
    err       = Python Obit Error/message stack
    timeRange = pair of floats giving the beginning and end time in days,
                inclusive, of the data to be flagged
    Target    = target name list, "Any" => all sources.
    flagVer   = flagging table version number
    Chans     = pair of ints giving first and last spectral channel numbers
                (1-rel) to be flagged; 0s => all
    Stokes    = String giving stokes to be flagged, 
                "FFF"  where F is '1' to flag corresponding stokes, '0' not.
                Stokes order 'R', 'L', 'RL' or 'X', 'Y', 'XY'
    Feed      = feed number (1-rel) to flag, 0 => all
    Reason    = reason string for flagging (max 24 char)
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    # Set flagging parameters
    inInfo = OTF.PGetList(inOTF)
    dim = OTF.dim
    dim[0] = 1
    dim[1] = 1
    dim[2] = 1
    InfoList.PAlwaysPutInt(inInfo, "flagVer", dim, [flagVer])
    InfoList.PAlwaysPutInt(inInfo, "Feed", dim, [Feed])
    dim[0] = 2
    InfoList.PAlwaysPutInt(inInfo, "Chans", dim, Chans)
    dim[0] = 2
    InfoList.PAlwaysPutFloat(inInfo, "timeRange", dim, timeRange)
    dim[0] = len(Target)
    InfoList.PAlwaysPutString(inInfo, "Target", dim, [Target])
    dim[0] = len(Stokes)
    InfoList.PAlwaysPutString(inInfo, "Stokes", dim, [Stokes])
    dim[0] = len(Reason)
    InfoList.PAlwaysPutString(inInfo, "Reason", dim, [Reason])
    #
    Obit.OTFCalUtilFlag(inOTF.me, err.me)
Exemple #13
0
def POTFGetSolnPARGain(inOTF, outOTF, err):
    """ Determine Penn Array type gain calibration from data

    Determine instrumental gain from Penn Array-like cal measurements
    Penn Array-like = slow switching, many samples between state changes
    Average On and Off for each detector and difference.
    Mult factor = calJy/(cal_on-cal_off) per detector, may be negative.
    Data scan averaged and repeated for any subsequent scans without cal On data
    Write Soln entries at beginning and end of each scan.
    Note: Any scans prior to a scan with calibration data will be flagged.
    Calibration parameters are on the inOTF info member.
    "calJy"     OBIT_float (*,1,1) Calibrator value in Jy per detector [def 1.0] .
                Duplicates if only one given.

    "doWate"    OBIT_boolean (1,1,1) If true determine Weights from RMS [def False]
     "minSNR"    OBIT_float (1,1,1) Minimum SNR for acceptable cal (ratio cal/RMS)
    If doWate is True then for each scan:
       Remove variations in data, calculate cal delta and weight
       from inverse variance of data.
     Per detector:
       1) Determined cal from averaging each segment and differencing transitions;
       2) Corrects data for cal value
       3) Fit polynomial (5th order) to data
       4) Determine rms deviation
       5) Clip points > 5 sigma from 0
       6) Refit polynomial
       7) redetermine rms deviation
       8) Flag scans with weights with entries further than 10X low or
          5X high from the median weight
  
    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF from which the solution is to be determined
              prior calibration/selection applied if requested
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFGetSolnPARGain(inOTF.me, outOTF.me, err.me)
    return out
Exemple #14
0
def PFitNod(inOTF, err):
    """ Fits nodding scans

    Gets cal values in units of Jy
    Input values on inOTF
    "Scan"     OBIT_Int   (1,1,1) Scan number to process, should be a nodding scan
    "calFlux"  OBIT_float (1,1,1) If given, the calibrator flux density, otherwise
                                  get from OTFTarget table
    Output values on inOTF
    "TRx"      OBIT_float (*,1,1) Receiver temperature per detector in units of the cal
    "calJy"    OBIT_float (*,1,1) Equivalent Jy per detector of the cal.
    
    inOTF   = Python Obit OTF
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFCalUtilFitNod(inOTF.me, -1, err.me)
Exemple #15
0
def PCreateImage(inOTF, err):
    """ Create basic ObitImage structure and fill out descriptor.

    Imaging parameters are on the inOTF info member.
    "nx"     int scalar Dimension of image in RA [no default].
    "ny"     int scalar Dimension of image in declination[no default]
    "RA"     float scalar Right Ascension of center of image
             Default is observed position center in inOTF 
    "Dec"    float scalar Declination of center of image
             Default is observed position center in inOTF 
    "xCells" float scalar X (=RA) cell spacing in degrees [no default]
    "yCells" float scalar Y (=dec) cell spacing in degrees [no default]
    "Proj"   string (4,1,1) Projection string "-SIN", "-ARC", "-TAN"
             [Default "-SIN"]
    returns Image
    inOTF   = Python Obit OTF from which the solution is to be determined
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Image.Image("None")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFUtilCreateImage(inOTF.me, err.me)
    return out
Exemple #16
0
def PFitTip(inOTF, err):
    """ Fits tipping scans

    Gets reciever/sky brightness/tau0 from tipping scan
    Input values on inOTF
    "Scan"     OBIT_Int (1,1,1) Scan number to process, should be a tipping scan
    "TCal"     OBIT_float (*,1,1) Noise cal value in K, per detector
    "TSky"     OBIT_float (1,1,1) Physical temperature of the sky (K) [def 300]
    "minEl"    OBIT_float (1,1,1) Min. elevation (deg).
                                  This may be needed to cut off low elevations where the
                                  mountains are in the beam.
    "doPlot"   OBIT_Bool (1,1,1) If present and True, plot data and models [def FALSE]
    Output values on inOTF
    "Tau0"     OBIT_float (1,1,1) Zenith opacity in nepers 
    "ATemp"    OBIT_float (*,1,1) Effective atmospheric temperature in data units.
               i.e. the additional offset per airmass due to the atmosphere.
               per detector in units of the cal.
    "TRx"      OBIT_float (*,1,1) Receiver temperature per detector in units of the cal
    "TipRMS"   OBIT_float (*,1,1) RMS residual (K) per detector
    
    inOTF   = Python Obit OTF
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFCalUtilFitTip(inOTF.me, err.me)
Exemple #17
0
def PFitCal(inOTF, detect, err):
    """ Fits calibrator scans

    Gets calibrator information from the Target table (position, flux density)
    Input values on inOTF
    "Scans"    OBIT_Int (1,1,1) Scan numbers to process, should be 4 scans
    "Tau0"     OBIT_float (1,1,1) Zenith opacity in nepers [def 0].
    "ATemp"    OBIT_float (*,1,1) Effective atmospheric temperature in data units.
        i.e. the additional offset per airmass due to the atmosphere.
        per detector in units of the cal. [def 300]
    "doPlot"   OBIT_Bool (1,1,1) If present and True, plot data and models [def FALSE]
    Output values on inOTF
    "TRx"      OBIT_float (*,1,1) Receiver temperature per detector in units of the cal
    "calJy"    OBIT_float (*,1,1) Noise cal value in Jy, per detector
    "RAoff"    OBIT_float (*,1,1) Offset in deg to add to RA
    "Decoff"   OBIT_float (*,1,1) Offset in deg to add to Dec
    "Timeoff"  OBIT_float (*,1,1) Offset in time (day) (actual-expected peak)
    
    inOTF   = Python Obit OTF
    detect  = detector number (0-rel), -1 => all
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilFitCal(inOTF.me, detect, err.me)
Exemple #18
0
def PAverage(inOTF, outOTF, chAvg, err):
    """ Frequency average an OTF

    inOTF   = input Python Obit OTF
    outOTF  = output Python Obit OTF, must be previously defined
    chAvg   = Number of channels to average, -1 => all
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.VEGASAverage(inOTF.me, outOTF.me, chAvg, err.me)
Exemple #19
0
def PFlag(inOTF, model, outOTF, FGVer, err):
    """ Flag data on basis of comparison of statistics of model, residuals

    Determine flagging from the statistics of time stream data.
    If a model is supplied, this is determined from the residuals to the model.
    The residual data will be derived from inOTF minus the model.
    Detector/intervals in excess of the larger of maxRMS or maxRatio times the 
    equivalent model RMS are flagged in OTFFlag table FGVer on outOTF.
    An evaluation is made independently in each flagInt and detector.
    Control parameters are on the inOTF info member.
    "flagInt"   float Flaffing interval in days [def 10 sec].
                This should not exceed 1000 samples.  Intervals will be truncated
                at this limit.
    "maxRMS"    float  Maximum allowable  RMS in Jy[ def 1.0].
    "maxRatio"  float  Max. allowable ratio to equivalent model RMS [2]
    "minEl"     float  Minimum elevation allowed (deg)
    inOTF   =  Python Obit OTF from which the solution is to be determined 
    model   =  Input CLEAN model, if not provided (None) then the model RMS
               is assumed 0.0
               The pixels values in the image array should be the estimated
               antenna response to the source in that direction.
    outOTF  =  Python Obit OTF onto which the solution table is to be appended.
    FGVer   =  Flag version for output, if 0 create new
    err     =  Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    if err.isErr:  # existing error?
        return
    if model == None:
        Obit.OTFGetSolnFlagNoModel(inOTF.me, outOTF.me, FGVer, err.me)
    else:
        Obit.OTFGetSolnFlag(inOTF.me, model.me, outOTF.me, FGVer, err.me)
Exemple #20
0
def PGain(inOTF, outOTF, err):
    """ Determine gain calibration for an OTF from a residual data set.

    Gain Calibration is based on the "Cal" values in the data.
    Average value of the noise Cal is computed and entered in the data. (Gain only)
    Additive values are determined from the median values of the residual data.
    Solution type controlled by calType 
    Calibration parameters are on the inOTF info member.
    "solInt"    float scalar Solution interval in days [def 10 sec].
                This should not exceed 1000 samples.  Solutions will be truncated
                at this limit.
    "minRMS"    float scalar minimum allowable fractional solution RMS [def 0.1].
                bad solutions are replaced with pervious good value. [Gain soln]
    "calJy"     float array Calibrator value in Jy per detector [Gain soln] [def 1.0] .
    "minEl"     float scalar Minimum elevation allowed (deg)
    "calType"   string  Calibration type desired
                "Gain" => Gain (multiplicative, cal) solution only
                "Offset" => Offset (additive) solution only
                "GainOffset" both gain and offset calibration (probably bad idea).
                anything else or absent => Gain only.
    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF (residual) from which the solution is to be determined 
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr:  # existing error?
        return out
    out.me = Obit.OTFGetSolnGain(inOTF.me, outOTF.me, err.me)
    return out
Exemple #21
0
def PScale(inOTF, outOTF, scale, offset, err):
    """ Scale and offset data in an OTF

    out = in*scale + offset
    inOTF   = input Python Obit OTF
    outOTF  = output Python Obit OTF, must be previously defined
    scale   = multiplicative term
    offset  = additive term
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilScale(inOTF.me, outOTF.me, scale, offset, err.me)
Exemple #22
0
def P(inOTF, outOTF, err):
    """ Determine gain offset calibration for an OTF dataset.

    The offset is determined from an atmospheric model.
    The gain calibration is determined from the average noise cal values
    and the atmospheric opacity.
    Results are placed in a newly created OTFSoln table.
    Calibration parameters are on the inOTF info member.
    "solInt"   float (1,1,1) Solution interval in days [def 10 sec].
    "Tau0"     float (1,1,1) Zenith opacity in nepers [def 0].
    "aTemp"    float (*,1,1) Effective atmospheric temperature in data units.
                i.e. the additional offset per airmass due to the atmosphere.
                per detector in units of the cal.
    "minEl"    float (1,1,1) Minimum elevation (deg)
    "tRx"      float (*,1,1) Receiver temperature per detector in units of the cal
    "calJy"    float (*,1,1) Noise cal value in Jy, per detector [def 1.0] .
    "Azoff"    float (*,1,1) Offset in deg to add to (cross El) [def 0] .
    "Eloff"    float (*,1,1) Offset in deg to add to El  [def 0.0] .

    returns OTFSoln table with solutions
    inOTF   = Python Obit OTF from which the solution is to be determined
    outOTF  = Python Obit OTF onto which the solution table is to be appended.
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError,"inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError,"outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError,"err MUST be a Python ObitErr"
    #
    out = Table.Table(" ")
    if err.isErr: # existing error?
        return out
    out.me = Obit.ObitOTFGetAtmCor (inOTF.me, outOTF.me, err.me)
    return out
Exemple #23
0
def PEditFD(inOTF, outOTF, err):
    """ Frequency domain editing of an OTF

    Compares data with a running median in frequency and makes flag table
    entries for channels with discrepant values or excessive RMSes.
    Data in channels which are mostly, but not completely flagged may also
    be flagged.
    Generates an OTFFlag flagging table on outOTF.
    Multiple threads may be used, up to one per spectrum.
    Control parameters on inOTF List member:
      flagTab  int   FG table version number [ def. 1]
      timeAvg  float Time interval over which to average (min) [def. 1]
      FDwidMW  int   The width of the median window in channels. 
                     An odd number (5) is recommended, [def nchan-1]
      FDmaxRMS float[2] Flag all channels having RMS values > FDmaxRMS[0] 
                        of the channel median sigma.[def 6.]
                        plus FDmaxRMS[1] (def 0.1) of the channel 
                        average in quadrature.
      FDmaxRes float Max. residual flux in sigma allowed [def 6.]
      minGood  float Minimum fraction of time samples at and below 
               which a channel/interval will be flagged.  
               [def 0.25, -1 ->no flagging by fraction of samples.]
    inOTF   = input Python Obit OTF, prior editing and calibration honored
    outOTF  = output Python Obit OTF for flag table
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFFlagEditFD(inOTF.me, outOTF.me, err.me)
Exemple #24
0
def PNoise(inOTF, outOTF, scale, offset, sigma, err):
    """ Scale and offset and add Gaussian noise to data in an OTF

    out = in*scale + offset + noise(sigma)
    inOTF   = input Python Obit OTF
    outOTF  = output Python Obit OTF, must be previously defined
    scale   = multiplicative term
    offset  = additive term
    sigma   = Std. deviation of noise to be added
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OTF.PIsA(outOTF):
        raise TypeError, "outOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilNoise(inOTF.me, outOTF.me, scale, offset, sigma, err.me)
Exemple #25
0
def PMakeImage(inOTF, outImage, err, doBeam=True, Beam=None, Wt=None):
    """ Makes an image from an OTF

    Convolves data onto a grid, accumulated and normalizes.
    Imaging parameters are on the inOTF info member.
    "minWt"  float scalar Minimum summed gridding convolution weight [def 0.1]
    "beamNx" int scalar "X" size of Beam (pixels)
    "beamNy" int scalar "Y" size of Beam (pixels)
    "doScale" bool scalar If true, convolve/scale beam [def True]
              Only use False if providing a dirty beam which already
              includes the effects of gridding.
    "deMode"  bool scalar Subtract image mode from image? [def False]
    "deBias"  bool scalar Subtract calibration bias from image? [def False]
             Note, this doesn't really work the way you would like
    "ConvType" Convolving function Type 0=pillbox,3=Gaussian,4=exp*sinc,5=Sph wave
              def [3]
    "ConvParm"float[10] = Convolving function parameters
    inOTF   = Python Obit input OTF 
    outImage= Python Obit Image
    err     = Python Obit Error/message stack
    doBeam  = if True make "Beam" (PSF) image and use to normalize
    Beam    = Actual instrumental Beam to use, else Gaussian [def None]
    Wt      = Image to save gridding weight array [def None]'),
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not Image.PIsA(outImage):
        raise TypeError, "outImage MUST be a Python Obit Image"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    # Dummy image arguments if needed
    if Beam:
        lbeam = Beam  # Actual beam given
    else:
        lbeam = Image.Image("NoBeam")  # Not given
    if Wt:
        lWt = Wt  # Actual weight image given
    else:
        lWt = Image.Image("NoWt")  # Not given
    Obit.OTFUtilMakeImage(inOTF.me, outImage.me, doBeam, lbeam.me, lWt.me,
                          err.me)
Exemple #26
0
def PIndex(inOTF, err):
    """ Index an OTF

    inOTF   = Python Obit OTF 
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        print "Really is", inOTF.__class__
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilIndex(inOTF.me, err.me)
Exemple #27
0
def PFitBPOnOff(inOTF, scans, err, BPVer=1):
    """ Fits bandpass from On/Off scan pair

    Gets calibrator information from the Target table (flux density)
    Writes results in OTFBP table
    Input values on inOTF
    inOTF   = Python Obit OTF
    scans   = pair of scans [off,on]
    err     = Python Obit Error/message stack
    BPVer   = output BP table,  0=>new
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilFitBPOnOff(inOTF.me, scans[0], scans[1], BPVer, err.me)
Exemple #28
0
def PFitOnOff(inOTF, detect, err):
    """ Fits calibrator On/Off scan pair

   Gets calibrator information from the Target table (flux density)
    Input values on inOTF
    "Scan"     OBIT_Int (2,1,1) Scan numbers to process, should be 4 scans
    Output values on inOTF
    "TRx"      OBIT_float (*,1,1) Receiver temperature per detector in units of the cal
    "calJy"    OBIT_float (*,1,1) Noise cal value in Jy, per detector
    
    inOTF   = Python Obit OTF
    detect  = detector number (0-rel), -1 => all
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilFitOnOff(inOTF.me, detect, err.me)
Exemple #29
0
def PDiffNod(inOTF, scan, err):
    """ Differences nodding scans

    Differences ons and offs in an nodding scan
    Output values on inOTF
    "OnOff"   OBIT_float (*,1,1) Differences of On-Off for each detector
              in the same order as defined in the data.  For beamswitched
              data this will be twice the source strength.
     
    inOTF   = Python Obit OTF, target position must be in OTFTarget table
              Calibration specified is applied.
    Scan    = scan number to process
    err     = Python Obit Error/message stack
    """
    ################################################################
    # Checks
    if not OTF.PIsA(inOTF):
        raise TypeError, "inOTF MUST be a Python Obit OTF"
    if not OErr.OErrIsA(err):
        raise TypeError, "err MUST be a Python ObitErr"
    if err.isErr:  # existing error?
        return
    #
    Obit.OTFUtilDiffNod(inOTF.me, scan, err.me)
Exemple #30
0
import OTF, OTFUtil, OSystem, OErr, InfoList
from Obit import Bomb

# Init Obit
err = OErr.OErr()
ObitSys = OSystem.OSystem("FitOnOff", 1, 100, 1, ["None"], 1, ["FITSdata/"], 1,
                          0, err)
OErr.printErrMsg(err, "Error with Obit startup")

# Files
disk = 1
inFile = "ComaPbandAvg2OTF.fits"  # Part 2
#inFile   = "ComaPbandAvg1OTF.fits"     # Part 1

# Set data
inData = OTF.newPOTF("Input data", inFile, disk, 1, err)
OErr.printErrMsg(err, "Error initializing")

# Set scans
scan = [126, 128]  # Part 2
#scan = [40,42] # Part 1, first
#scan = [77,75] # Part 1, second

dim = OTF.dim
dim[0] = 1
dim[1] = 1
inInfo = OTF.PGetList(inData)
dim[0] = 2
InfoList.PAlwaysPutInt(inInfo, "Scan", dim, scan)
#Bomb()
# Do fitting