def display(self, desc, url): data = self._verify(desc) try: # Display server object disp = ODisplay.ODisplay("ObitView", url, self.err) # Send to display ODisplay.PImage(disp, data, self.err) del disp except OErr.OErr, self.err: OErr.printErrMsg(err, "FITSImage Display") msg = "Cannot display image" raise RuntimeError, msg
def display(self, desc, url): data = self._verify(desc) try: # Display server object disp = ODisplay.ODisplay("ObitView", url, self.err) # Send to display ODisplay.PImage(disp, data, self.err) del disp except OErr.OErr, self.err: OErr.printErrMsg(err, "AIPSImage Display") if self.doInit: # Initialized Obit? OSystem.Shutdown(self.ObitSys) msg = "Cannot display image" raise RuntimeError, msg
def display(self, desc, url): data = self._verify(desc) try: # Display server object disp = ODisplay.ODisplay("ObitView", url, self.err) # Send to display ODisplay.PImage(disp, data, self.err) del disp except OErr.OErr as xxx_todo_changeme: self.err = xxx_todo_changeme OErr.printErrMsg(err, "FITSImage Display") msg = "Cannot display image" raise RuntimeError(msg) OErr.printErrMsg(self.err, "Error with Obit Image display") return True # Return something other than None.
def display(self, desc, url): data = self._verify(desc) try: # Display server object disp = ODisplay.ODisplay("ObitView", url, self.err) # Send to display ODisplay.PImage(disp, data, self.err) del disp except OErr.OErr as xxx_todo_changeme: self.err = xxx_todo_changeme OErr.printErrMsg(err, "AIPSImage Display") if self.doInit: # Initialized Obit? OSystem.Shutdown(self.ObitSys) msg = "Cannot display image" raise RuntimeError(msg) if self.doInit: # Initialized Obit? OSystem.Shutdown(self.ObitSys) self.doInit = False OErr.printErrMsg(self.err, "Error with Obit Image display") return True # Return something other than None.
def tvlod(image, window=None): """ display image * image = Obit Image, created with getname, getFITS * window = Optional window for image to edit """ ################################################################ if Image.PIsA(image): # Obit/Image ODisplay.PImage(disp, image, err, window=window) elif image.__class__==AIPSData.AIPSImage: # AIPS Image tmp = Image.newPAImage("AIPS Image",image.name, image.klass, image.disk, \ image.seq, True, err) ODisplay.PImage(disp, tmp, err, window=window) del tmp elif image.__class__==FITSData.FITSImage: # FITS Image tmp = Image.newPFImage("FITS Image",image.filename, image.disk, True, err) ODisplay.PImage(disp, tmp, err, window=window) del tmp
def PClean(err, input=CleanInput): """ Performs image based CLEAN The peak in the image is iteratively found and then the beam times a fraction of the peak is subtracted and the process is iterated. err = Python Obit Error/message stack input = input parameter dictionary Input dictionary entries: CleanOTF = Input CleanOTF, disp = Image display to edit window Niter = Maximum number of CLEAN iterations Patch = Beam patch in pixels [def 100] maxPixel = Maximum number of residuals [def 20000] BeamSize = Restoring beam (deg) Gain = CLEAN loop gain minFlux = Minimun flux density (Jy) noResid = If True do not include residuals in restored image doRestore = If True restore components doScale = If True scale residuals in restored image by beam areas 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 scale = If True, scale CCs to units of restored CLEAN image """ ################################################################ # Get input parameters inCleanOTF = input["CleanOTF"] # Checks if not PIsA(inCleanOTF): print "Really is", inCleanOTF.__class__ raise TypeError, "inCleanOTF MUST be a Python Obit CleanOTF" if err.isErr: # existing error? return # dim = [1, 1, 1, 1, 1] # # Set control values on CleanOTF dim[0] = 1 inInfo = PGetList(inCleanOTF) # InfoList.PAlwaysPutInt(inInfo, "Niter", dim, [input["Niter"]]) InfoList.PAlwaysPutInt(inInfo, "Patch", dim, [input["Patch"]]) InfoList.PAlwaysPutInt(inInfo, "CCVer", dim, [input["CCVer"]]) InfoList.PAlwaysPutFloat(inInfo, "BeamSize", dim, [input["BeamSize"]]) InfoList.PAlwaysPutFloat(inInfo, "Gain", dim, [input["Gain"]]) InfoList.PAlwaysPutFloat(inInfo, "minFlux", dim, [input["minFlux"]]) InfoList.PAlwaysPutFloat(inInfo, "Factor", dim, [input["Factor"]]) InfoList.PAlwaysPutBoolean(inInfo, "noResid", dim, [input["noResid"]]) InfoList.PAlwaysPutBoolean(inInfo, "doRestore", dim, [input["doRestore"]]) InfoList.PAlwaysPutBoolean(inInfo, "doScale", dim, [input["doScale"]]) InfoList.PAlwaysPutBoolean(inInfo, "doScaleCC", dim, [input["scale"]]) InfoList.PAlwaysPutBoolean(inInfo, "autoWindow", dim, [input["autoWindow"]]) dim[0] = len(input["Plane"]) InfoList.PAlwaysPutInt(inInfo, "Plane", dim, input["Plane"]) # # show any errors OErr.printErrMsg(err, "Clean: Error setting parameters") # Edit CLEAN window? disp = input["disp"] if disp != None: window = PGetWindow(inCleanOTF) print "Display Dirty image for editing" ODisplay.PImage(disp, inCleanOTF.Dirty, err, window=window) OErr.printErrMsg(err, "Error editing CLEAN boxes") # # if Beam Given set on dirty image if inCleanOTF.Beam: dirty = inCleanOTF.Dirty dirty.Beam = inCleanOTF.Beam # Do operation Obit.CleanOTFClean(inCleanOTF.me, err.me)
inOTF =OTF.newPOTF("Input data", inFile, inDisk, 1, err) OErr.printErrMsg(err, "Error creating input data object") inInfo = inOTF.List ################################## Set parameters ##################################### # Get position from OTF pos = GBTUtil.GetTargetPos(inOTF, target[0], err) ra = pos[0] # ra of center dec = pos[1] # dec of center # dirty beam dirtyBeam = Image.newPFImage("dirty beam", BeamFile, inDisk, True, err) OErr.printErrMsg(err, "Error initializing dirty beam") # Image display disp = ODisplay.ODisplay("ObitView", "ObitView", err) # Imaging parameters OTF.ImageInput["InData"] = inOTF OTF.ImageInput["disk"] = inDisk OTF.ImageInput["OutName"] = dirtFile OTF.ImageInput["Beam"] = dirtyBeam OTF.ImageInput["ra"] = ra # Center RA OTF.ImageInput["dec"] = dec # Center Dec OTF.ImageInput["xCells"] = cells # "X" cell spacing OTF.ImageInput["yCells"] = cells # "Y" cell spacing OTF.ImageInput["nx"] = nx # number of cells in X OTF.ImageInput["ny"] = ny # number of cells in Y OTF.ImageInput["gainUse"] = 0 # Which cal table to apply, -1 = none OTF.ImageInput["flagVer"] = flagver # Which flag table to apply, -1 = none OTF.ImageInput["minWt"] = 1.0e-2 # Minimum weight in imaging - includes data weight
Aclass = 'Blank' disk = 1 seq = 1 offs = [-139, -169] plane = [1, 1, 1, 1, 1] image = Image.newPAImage("Im", Aname, Aclass, disk, seq, True, err) OErr.printErr(err) # Read image image.GetPlane(None, plane, err) OErr.printErr(err) # Define blanking interactively defining a OWindow naxis = image.Desc.Dict['inaxes'][0:2] win = OWindow.PCreate1('wind', naxis, err) ODisplay.PImage(disp, image, err, window=win) OErr.printErr(err) wlist = OWindow.PGetList(win, 1, err) OErr.printErr(err) # Apply BlankImage(image, OWindow.PGetList(win, 1, err), off=offs) OErr.printErr(err) # Update image image.PutPlane(None, plane, err) OErr.printErr(err) # Blank Image function del BlankImage
def PSetup(inImage, disp, err): """ Interactive initial definition of fitting region Interactively allows the user to set the region of the image to be fitted and the initial model. The fitting region is first specified with a rectangular window and then the initial models to be fitted with circular windows. Returns FitRegion, leaves image pixel array on inImage * image = image to be fitted * disp = image display to use * err = Obit Error/message stack """ ################################################################ # Checks if not Image.PIsA(inImage): raise TypeError, "inImage MUST be a Python Obit Image" if not ODisplay.PIsA(disp): print "Actually ", disp.__class__ raise TypeError, "disp MUST be a Python Obit Display" if not OErr.OErrIsA(err): raise TypeError, "err MUST be an OErr" # id = inImage.Desc.Dict naxis = id["inaxes"][0:2] window = OWindow.PCreate1("window", naxis, err) # Give user instructions print "Specify the region to fit with a rectangular box." print "Followed by circular boxes to mark Gaussian component" print "initial locations and initial sizes." boxes = [] while len(boxes) < 2: ODisplay.PImage(disp, inImage, err, window) if err.isErr: printErrMsg(err, "Error with interactive display") boxes = OWindow.PGetList(window, 1, err) if err.isErr: printErrMsg(err, "Error getting boxes") print "DEBUG BOXES", boxes # Checks if len(boxes) < 2: print "You MUST specity fitting region and at least one Gaussian" # End loop 'til user gets it right # Fitting window box = boxes[0] if box[1] != OWindow.RectangleType: raise RuntimeError, "Fitting region NOT rectangular" corner = [min(box[2], box[4]), min(box[3], box[5])] dim = [abs(box[4] - box[2]) + 1, abs(box[5] - box[3]) + 1] # Image interpolator inImage.Open(Image.READONLY, err) inImage.Read(err) fi = FInterpolate.FInterpolate("inter", inImage.FArray, inImage.Desc, 2) inImage.Close(err) if err.isErr: printErrMsg(err, "Error reading image for interpolator") # Models models = [] for box in boxes[1:]: if box[1] != OWindow.RoundType: raise RuntimeError, "Indicate Gaussians with Round boxes" type = FitModel.GaussMod x = box[3] - corner[0] y = box[4] - corner[1] pixel = [float(box[3]), float(box[4])] parms = [float(box[2]), float(box[2]), 0.0] s = FInterpolate.PPixel(fi, pixel, err) models.append( FitModel.FitModel(type=type, Peak=s, DeltaX=x, DeltaY=y, parms=parms)) # create output out = FitRegion(name=id["object"], corner=corner, dim=dim, models=models) return out
# Test AIPS directory listing import Obit, OSystem, OErr, AIPSDir, Image, ODisplay # Init Obit err=OErr.OErr() ObitSys=OSystem.OSystem ("Imager", 1, 100, 1, ["/DATA/LUSUS_1/"], 1, ["../PythonData/"], 1, 0, err) OErr.printErrMsg(err, "Error with Obit startup") from Obit import Bomb disk=1 # list directory AIPSDir.PListDir(disk, err) a=Image.newPACNO(1,4,True,err) d=ODisplay.ODisplay("ObitView","ObitView",err) ODisplay.PImage(d,a,err) # Shutdown Obit OErr.printErr(err) del ObitSys
OTF.ResidCalInput["gainUse"] = baseCal # Prior calibration, 0-> highest OTF.ResidCalInput["minEl"] = -90.0 # minimum elevation OTF.ResidCalInput["flagVer"] = flagver # Which flag table to apply, -1 = none ############################## Create initial image ################################### print "Make Dirty Image" OTF.ImageInput["gainUse"] = 0 # Which cal table to if len(feeds) > 0: inInfo.set("Feeds", feeds) # Which feeds DirtyImg = OTF.makeImage(err, OTF.ImageInput) OErr.printErrMsg(err, "Error making initial image") ################################# CLEAN parameters #################################### # Image display disp = ODisplay.ODisplay("ObitView", "ObitView", err) # Image for cleaning CleanImg = Image.newPFImage("Clean Image", cleanFile, outDisk, False, err) # Create CleanOTF CleanObj = CleanOTF.PCreate("Clean", DirtyImg, dirtyBeam, CleanImg, err) OErr.printErrMsg(err, "Error creating CLEAN object") # CLEAN parameters CleanOTF.CleanInput["CleanOTF"] = CleanObj # Clean object CleanOTF.CleanInput["disp"] = disp # Image display object CleanOTF.CleanInput["Patch"] = 40 # Beam patch CleanOTF.CleanInput["Niter"] = niter # Number of iterations CleanOTF.CleanInput["Gain"] = gain # CLEAN loop gain CleanOTF.CleanInput[
def FitCal(err, input=FitCalInput): """ Image and fit a sequence of calibrator scans Does imaging and iterative calibration of a sequence of scans on a calibrator (Target). Calibration is by imaging and performing a CLEAN to derive a sky model and then subtracting the sky model from the data. An estimate of the residual background is derived from filtering the residuals. The number of calibration cycles is determined by the number of entries in soln and each cycle may consist of a "Common" calibration, or a "Detector" calibration or both. Data are imaged as grouped in scanList, scans in each list in scanList are imaged together Returns an array of dict's, one per list in scanList with "Time" Center time in Days "Target" Source Name "Peak" Peak flux density "Gauss" Gaussian parameters (major, minor axis size (asec), PA (deg)) "elOff" Offset in elevation in asec "azOff" Offset in azimuth ( actually Xel) err = Python Obit Error/message stack input = input parameter dictionary, for interactive use, the function input will display the contents in human readable format. Input dictionary entries: InData = Python input OTF to calibrate scrDisk = Disk number for scratch files PSF = Image with telescope psf scanList= list of lists of target/scans to be imaged together list of forn [target, scan_1...] disp = Image display to show final "dirty" maps save = if True, save derived images, else delete These will be in scrDisk with names of the form target.+scan+.CalImage.fits nx = number of pixels in "x" = RA ny = number of pixels in 'Y' = dec xCells = Cell spacing in x (asec) yCells = Cell spacing in y (asec) ConvType= Convolving function Type 0=pillbox,3=Gaussian,4=exp*sinc,5=Sph wave ConvParm= Convolving function parameters depends on ConvType Type 2 = Sinc, (poor function - don't use) Parm[0] = halfwidth in cells, Parm[1] = Expansion factor Type 3 = Gaussian, Parm[0] = halfwidth in cells,[def 3.0] Parm[1] = Gaussian with as fraction or raw beam [def 1.0] Type 4 = Exp*Sinc Parm[0] = halfwidth in cells, [def 2.0] Parm[1] = 1/sinc factor (cells) [def 1.55] Parm[2] = 1/exp factor (cells) [def 2.52] Parm[3] = exp power [def 2.0] Type 5 = Spherodial wave Parm[0] = halfwidth in cells [def 3.0] Parm[1] = Alpha [def 5.0] Parm[2] = Expansion factor [not used] gainUse = version number of prior table (Soln or Cal) to apply, -1 is none flagVer = version number of flagging table to apply, -1 is none Niter = Maximum number of CLEAN iterations Patch = Beam patch in pixels [def 100] BeamSize = Restoring beam (deg) Gain = CLEAN loop gain autoWindow = True if autoWindow feature desired doFilter = Filter out of band noise? solInt = solution interval (sec) solType = solution type: "Common" solve for common mode.additive effects on timescales longer than solInt "Detector" Solve for detector additive terms on timescales longer than 3 * solInt "Both" Both Common and Detector solutions each calibration cycle soln = list of solution intervals, one cycle per interval NO value should be less than solInt """ ################################################################ # Get input parameters dim = [1, 1, 1, 1, 1] inData = input["InData"] inInfo = inData.List # Checks if not OTF.PIsA(inData): raise TypeError, 'Image: Bad input OTF' if err.isErr: # existing error? return None # Set calibration gainUse = input["gainUse"] flagVer = input["flagVer"] # Default table versions (the Obit routines will do this as well) if gainUse == 0: # Get highest numbered OTFCal table gainUse = Obit.OTFGetHighVer(inData.me, "OTFCal") if gainUse == 0: # Doesn't seem to be one, try OTFSoln gainUse = Obit.OTFGetHighVer(inData.me, "OTFSoln") if gainUse == 0: # Must not be one gainUse = -1 inInfo.set("doCalSelect", True) inInfo.set("flagVer", flagVer) if gainUse > 0: inInfo.set("doCalib", 1) inInfo.set("gainUse", gainUse) # Set imaging/calibration parameters scrDisk = input["scrDisk"] # Imaging parameters OTF.ImageInput["disk"] = scrDisk OTF.ImageInput["Beam"] = input["PSF"] OTF.ImageInput["xCells"] = input["xCells"] OTF.ImageInput["yCells"] = input["yCells"] OTF.ImageInput["nx"] = input["nx"] OTF.ImageInput["ny"] = input["ny"] OTF.ImageInput["gainUse"] = 0 OTF.ImageInput["flagVer"] = flagVer OTF.ImageInput["minWt"] = input["minWt"] OTF.ImageInput["ConvType"] = input["ConvType"] OTF.ImageInput["ConvParm"] = input["ConvParm"] OTF.ImageInput["doFilter"] = input["doFilter"] # Calibration parameters (some reset in loop) OTF.ResidCalInput["solType"] = "MultiBeam" OTF.ResidCalInput["solInt"] = input["solInt"] OTF.ResidCalInput["gainUse"] = 0 OTF.ResidCalInput["minEl"] = -90.0 OTF.ResidCalInput["flagVer"] = flagVer OTF.ResidCalInput["minFlux"] = 0.0 # CLEAN parameters CleanOTF.CleanInput["autoWindow"] = input["autoWindow"] CleanOTF.CleanInput["Patch"] = input["Patch"] CleanOTF.CleanInput["Niter"] = input["Niter"] CleanOTF.CleanInput["Gain"] = input["Gain"] CleanOTF.CleanInput["BeamSize"] = input["BeamSize"] #DEBUG CleanOTF.CleanInput["disp"] = input["disp"] CleanOTF.CleanInput["minFlux"] = 0.0 # Reset Soln2Cal parameters for self cal OTF.Soln2CalInput["oldCal"] = 1 OTF.Soln2CalInput["newCal"] = 2 disp = input["disp"] # Image display # Initialize output results = [] # Loop over images scount = 0 for scans in input["scanList"]: # Make scratch OTF data scrData = inData.Scratch(err) scrInfo = scrData.List target = scans[0] pos = GBTUtil.GetTargetPos(inData, target, err) ra = pos[0] # ra of center dec = pos[1] # dec of center OTF.ImageInput["ra"] = ra OTF.ImageInput["dec"] = dec OTF.ImageInput["OutName"] = target + "." + str( scans[1]) + ".CalImage.fits" # copy first scan inInfo.set("Scans", [scans[1], scans[1]]) inInfo.set("Targets", target) inData.Copy(scrData, err) # Concatenate rest OTF.ConcatInput["InData"] = inData OTF.ConcatInput["OutData"] = scrData for scan in scans[2:]: inInfo.set("Targets", target) inInfo.set("Scans", [scan, scan]) OTF.Concat(err, OTF.ConcatInput) if err.isErr: OErr.printErrMsg(err, "Error creating scratch OTF data") # delete any prior calibration tables OTF.ClearCal(scrData, err) # Dummy cal table inter = input["solInt"] / 4 OTFGetSoln.POTFGetDummyCal(scrData, scrData, inter, 1, 1, err) if err.isErr: OErr.printErrMsg(err, "Error creating dummy cal table") scrInfo.set("gainUse", 0) scrInfo.set("doCalSelect", True) OTF.ImageInput["InData"] = scrData OTF.ResidCalInput["InData"] = scrData OTF.Soln2CalInput["InData"] = scrData OTF.ImageInput["gainUse"] = 0 # Create dirty image OTF.ImageInput["InData"] = scrData DirtyImg = OTF.makeImage(err, OTF.ImageInput) OErr.printErrMsg(err, "Error making initial image") # Image for cleaning CleanImg = DirtyImg.Scratch(err) # Create CleanOTF dirtyBeam = input["PSF"] CleanObj = CleanOTF.PCreate("Clean", DirtyImg, dirtyBeam, CleanImg, err) OErr.printErrMsg(err, "Error creating CLEAN object") CleanOTF.CleanInput["CleanOTF"] = CleanObj # Clean object # CLEAN window win = [-1, 20, input["nx"] / 2 + 1, input["ny"] / 2 + 1] CleanOTF.PAddWindow(CleanObj, win, err) # Calibration loop count = 0 soln = input["soln"] OTF.ImageInput["gainUse"] = 1 # Which cal table to apply OTF.ResidCalInput["gainUse"] = 0 # Prior calibration, scrInfo.set("deMode", False) # Don't remove mode first cycle if input["solType"] == "Both": for si in soln: count = count + 1 # First calibration of pair OTF.ResidCalInput["solInt"] = 3 * si OTF.ResidCalInput["solType"] = "Offset" OTF.Soln2CalInput["oldCal"] = 1 OTF.Soln2CalInput["newCal"] = 2 # (Re)Use 2 OTF.SelfCal(err, OTF.ImageInput, CleanOTF.CleanInput, OTF.ResidCalInput, OTF.Soln2CalInput) OErr.printErrMsg(err, "Error in self cal") OTF.ImageInput["gainUse"] = OTF.Soln2CalInput[ "newCal"] # Which cal table to apply OTF.ResidCalInput["gainUse"] = OTF.Soln2CalInput[ "newCal"] # Prior calibration # Second OTF.ResidCalInput["solInt"] = si OTF.ResidCalInput["solType"] = "MultiBeam" OTF.Soln2CalInput["oldCal"] = 2 OTF.Soln2CalInput["newCal"] = 3 # (Re)Use 3 OTF.SelfCal(err, OTF.ImageInput, CleanOTF.CleanInput, OTF.ResidCalInput, OTF.Soln2CalInput) OTF.ImageInput["gainUse"] = OTF.Soln2CalInput[ "newCal"] # Which cal table to apply OTF.ResidCalInput[ "gainUse"] = 1 # Prior calibration for next cycle # Cleanup Soln tables scrData.ZapTable("OTFSoln", 1, err) scrData.ZapTable("OTFSoln", 2, err) scrInfo.set("deMode", True) # remove mode else: # Only one type if input["solType"] == "Common": stype = "MultiBeam" else: stype = "Offset" for si in soln: count = count + 1 OTF.ResidCalInput["solInt"] = si OTF.ResidCalInput["solType"] = stype OTF.Soln2CalInput["oldCal"] = 1 OTF.Soln2CalInput["newCal"] = 2 OTF.SelfCal(err, OTF.ImageInput, CleanOTF.CleanInput, OTF.ResidCalInput, OTF.Soln2CalInput) OTF.ImageInput["gainUse"] = OTF.Soln2CalInput[ "newCal"] # Which cal table to apply OTF.ResidCalInput[ "gainUse"] = 1 # Prior calibration for next cycle # Cleanup Soln tables scrData.ZapTable("OTFSoln", 1, err) scrInfo.set("deMode", True) # remove mode # Final image DirtyImg = OTF.makeImage(err, OTF.ImageInput) OErr.printErrMsg(err, "Error in final dirty image") print "Display final image" ODisplay.PImage(disp, DirtyImg, err) OErr.printErrMsg(err, "Error displaying final image") # Do fitting # Model fitting import ImageFit, FitRegion, FitModel # Set up model fm = FitModel.FitModel(type=FitModel.GaussMod, Peak=1.0, parms=[3.,3.,0.], \ DeltaX=8., DeltaY=8.) cen = [8, 8] DirtyImg.Open(Image.READONLY, err) DirtyImg.ReadPlane(err) fm.Peak = FArray.PMax(DirtyImg.FArray, cen) DirtyImg.Close(err) corner = [cen[0] - 8, cen[1] - 8] cen = [8, 8] d = DirtyImg.Desc.Dict fr = FitRegion.FitRegion(corner=corner, dim=[17, 17], models=[fm]) imf = ImageFit.ImageFit("ImageFit") fitinput = ImageFit.FitInput fitinput["fitImage"] = DirtyImg fitinput["fitRegion"] = fr fitinput["MaxIter"] = 100 fitinput["prtLv"] = 0 fitinput["PosGuard"] = 1. print "Initial guess Corner=", corner, "Peak=", fm.Peak # Fit imf.Fit(err, fitinput) # Offsets raOff = (fm.DeltaX + corner[0] - d["crpix"][0]) * d["cdelt"][0] decOff = (fm.DeltaY + corner[1] - d["crpix"][1]) * d["cdelt"][1] print "Processing target/scans", scans print "Results Peak=", fm.Peak, "dx=", raOff * 3600.0, "dy=", decOff * 3600.0 print "Results Center=[", fm.DeltaX + corner[ 0], ",", fm.DeltaY + corner[1], "]" print "Results Gauss=", fm.parms # Get time, pa of data scrInfo.set("doCalSelect", False) scrInfo.set("doCalib", -1) scrData.Open(OTF.READONLY, err) nrow = scrData.Desc.Dict["nrecord"] row = scrData.ReadRec(err) ttime = row.time pa = row.rot scrData.Close(err) del row print "target", target, "time", ttime * 24.0, "par ang", pa pa /= 57.296 # Offsets raOff = (fm.DeltaX + corner[0] - d["crpix"][0]) * d["cdelt"][0] decOff = (fm.DeltaY + corner[1] - d["crpix"][1]) * d["cdelt"][1] # Gaussian parameters to asec gparm = [fm.parms[0]*abs(d["cdelt"][0])*3600.0, \ fm.parms[1]*abs(d["cdelt"][1])*3600.0, fm.parms[2]*57.296] # Rotate to az, el azOff = raOff * math.cos(pa) - decOff * math.sin(pa) elOff = decOff * math.cos(pa) + raOff * math.sin(pa) # to asec azOff *= 3600.0 elOff *= 3600.0 # Set output fitdata = {"Time":ttime, "Peak":fm.Peak, "Gauss":gparm, \ "elOff":elOff, "azOff":azOff,"Target":target} results.append(fitdata) # Cleanup scrData.Zap(err) if not input["save"]: DirtyImg.Zap(err) else: del DirtyImg CleanImg.Zap(err) del CleanObj scount += 1 # end loop over images return results
import Obit, Table, FArray, OErr, InfoList, History, AIPSDir, OSystem import Image, ImageDesc, TableList, ODisplay, UV, OWindow import os, AIPS # ParselTongue classes import AIPSData, FITSData # from PTObit import * # ObitStart() #global Adisk err = OErr.OErr() ObitSys = None Adisk = 1 # Display connection disp = ODisplay.ODisplay("ObitView", "ObitView", err) #Initialize Obit system # Get list of FITS disks FITSdisks = [] for dsk in [ "FITS", "FITS01", "FITS02", "FITS03", "FITS04", "FITS05", "FITS06" ]: dir = os.getenv(dsk) if dir: FITSdisks.append(dir) nFITS = len(FITSdisks) # Get list of AIPS disks AIPSdisks = [] for dsk in [