def PBackFFT(FFTrev, inArray, outArray, err): """ Back transform half plane complex to real inArray is FFTed (half plane complex - real) to outArray * FFTref = FFT object to FT inArray * inArray = CArray with image to be FFTed must be a size compatable with FFTrev * outArray = FArray for output must be a size compatable with FT of inArray * err = Python Obit Error/message stack """ ################################################################ # Checks if not FFT.PIsA(FFTrev): print("Actually ",FFTrev.__class__) raise TypeError("FFTrev MUST be a Python Obit FFT") if not CArray.PIsA(inArray ): print("Actually ",inArray.__class__) raise TypeError("inArray MUST be a Python Obit CArray") if not FArray.PIsA(outArray ): print("Actually ",outArray.__class__) raise TypeError("outArray MUST be a Python Obit FArray") if not OErr.OErrIsA(err): raise TypeError("err MUST be an OErr") # # FFT PFFTC2R (FFTrev, inArray, outArray) FArray.PCenter2D (outArray)
def PBigger (naxis, inImage, outImage, err): """ Increases the size of an image and zero pads Any blanked values are replaced with zeroes * naxis = dimension array of desired output * inImage = Python Obit Image to be padded. * outImage = Python Obit Image for output Must previously exist * err = Python Obit Error/message stack """ ################################################################ # Checks if not Image.PIsA(inImage): print("Actually ",inImage.__class__) raise TypeError("inImage MUST be a Python Obit Image") if not Image.PIsA(outImage): print("Actually ",outImage.__class__) raise TypeError("outImage MUST be a Python Obit Image") if not OErr.OErrIsA(err): raise TypeError("err MUST be an OErr") # # Read input, Copy Descriptor inImage.Open(Image.READONLY, err) inImage.Read(err) desc = inImage.Desc inImage.Close(err) #OErr.printErrMsg(err, "Error reading input image "+Image.PGetName(inImage)) # Get data arrays inArray = inImage.FArray outArray = FArray.FArray("Padded array", naxis) # Copy/pad/deblank array FArray.PPad(inArray, outArray, 1.0) # Reset output image size of first two axes naxis = outArray.Naxis # output size descDict = desc.Dict # Input Python dict object dim = descDict["inaxes"] # input size crpix = descDict["crpix"] # Update reference pixel, pixel shift an integral number pixOff = [naxis[0]//2-dim[0]//2, naxis[1]//2-dim[1]//2] crpix[0] = crpix[0] + pixOff[0] crpix[1] = crpix[1] + pixOff[1] # Update size dim[0] = naxis[0]; dim[1] = naxis[1] descDict["inaxes"] = dim descDict["bitpix"] = -32 # output floating desc = outImage.Desc # Replace descriptor on output desc.Dict = descDict # Write output image outImage.Open(Image.WRITEONLY, err) outImage.WriteFA(outArray, err) outImage.Close(err) outImage.FArray = outArray # Now attach array to image to
def PSubImage(inImage, inArray, outImage, err): """ Extract the subimage in inAray corresponding to outImage This assumes that both input and output images have pixels on the same locations (i.e. one the padded version of the other) outImage is updated in permanent storage (disk) * inImage = Image describing inArray * inArray = Image to be extracted * outImage = accepts values from inImage, must exist and be fully defined * err = Python Obit Error/message stack """ ################################################################ # Checks if not Image.PIsA(inImage ): print("Actually ",inImage.__class__) raise TypeError("inImage MUST be a Python Obit Image") if not FArray.PIsA(inArray ): print("Actually ",inArray.__class__) raise TypeError("inArray MUST be a Python Obit FArray") if not Image.PIsA(outImage ): print("Actually ",outImage.__class__) raise TypeError("outImage MUST be a Python Obit Image") if not OErr.OErrIsA(err): raise TypeError("err MUST be an OErr") # # get selected input header info descDict = inImage.Desc.Dict inCrpix = descDict["crpix"] inInaxes = descDict["inaxes"] # get selected output header info descDict = outImage.Desc.Dict outCrpix = descDict["crpix"] outInaxes = descDict["inaxes"] # determine window in image blc = [1,1,1,1,1,1,1] blc[0] = (int(inCrpix[0]) - int(outCrpix[0])) blc[1] = (int(inCrpix[1]) - int(outCrpix[1])) trc = inInaxes trc[0] = blc[0] + outInaxes[0] - 1 trc[1] = blc[1] + outInaxes[1] - 1 # Extract array outArray = FArray.PSubArr(inArray, blc, trc, err) #OErr.printErrMsg(err, "Error extracting sub-image") # rewrite image outImage.Open(Image.READWRITE, err) outImage.WriteFA(outArray, err) outImage.Close(err)
def PCreateModel(image, outArray): """ Fill an FArray with a model the size and shape of the resolution in an image A model image is inserted in outArray derived from the restoring beam in image. The size and geometry of OutArray must be those described by image * image = Python Obit Image with info * outArray = Python FArray to receive model Must previously exist """ ################################################################ # Checks if not Image.PIsA(image): raise TypeError("image MUST be a Python Obit Image") if not FArray.PIsA(outArray): print("Actually ",outArray.__class__) raise TypeError("outArray MUST be a Python Obit FArray") # # Check compatability array = Image.PGetFArray(image) if not FArray.PIsCompatable (array, outArray): array = Obit.FArrayUnref(array) # Cleanup raise TypeError("image and array incompatible") del array # Cleanup # Get image info from descriptor desc = image.Desc descDict = desc.Dict beamMaj = descDict["beamMaj"] beamMin = descDict["beamMin"] beamPA = descDict["beamPA"] cdelt = descDict["cdelt"] crpix = descDict["crpix"] crota = descDict["crota"] inaxes = descDict["inaxes"] # Check that beam OK if beamMaj < 0.0001/3600.0: raise TypeError("No beam provided for "+image) print("Beam",beamMaj*3600.0,beamMin*3600.0,beamPA) # Zero array FArray.PFill (outArray, 0.0) amp = 1.0 Cen = [crpix[0]-1.0, crpix[1]-1.0] # zero ref Cen = [float(inaxes[0]/2), float(inaxes[1]/2)] # zero ref GauMod = [beamMaj/abs(cdelt[0]), beamMin/abs(cdelt[0]), beamPA-90.0] FArray.PEGauss2D(outArray, amp, Cen, GauMod)
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)
def PConvBeam(CCTab, Beam, Template, err): """ Convolve a set of Clean components with a beam image CCTab CC Table, following parameters on infoList member "BComp" OBIT_int (1,1,1) Start CC to use, 1-rel [def 1 ] "EComp" OBIT_int (1,1,1) Highest CC to use, 1-rel [def to end ] Beam Beam Image to convolve with CCs Template Template FArray for output array err Obit Error stack Returns an ObitFArray whose size is that of Template, spacing is that of Beam with the CCs in CCTab convolved with Beam and the (0,0) position is (nx/2,ny/2) (0-rel) """ ################################################################ # Checks if not Table.PIsA(CCTab): raise TypeError, "CCTab MUST be a Python Obit Table" if not OErr.OErrIsA(err): raise TypeError, "err MUST be a Python ObitErr" # out = FArray.FArray("Convolved CCs") if err.isErr: # existing error? return out out.me = Obit.OTFUtilConvBeam(CCTab.me, Beam.me, Template.me, err.me) return out
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)
def PFit1DGauss(inFA, err): """ Fit 1-D Gaussian plus a linear baseline in FArray returns list: [0]= Full width Half Max (pixels) of fitted Gaussian [1]= peak value in fitted Gaussian [2]= x pixel (0-rel) coordinates of peak in pixels [3]= 0th order baseline term [4]= 1st order baseline term [5]= RMS residual * inFA = Array to be fitted * err = Python Obit Error/message stack """ ################################################################ # Checks if not FArray.PIsA(inFA): raise TypeError, "inFA MUST be a Python Obit FArray" FWHM = 0.0 cen = 0.0 peak = 0.0 center = 0.0 # Not really used # results in retVal retVal = Obit.FArrayUtilFit1DGauss(inFA.me, FWHM, center, peak, err.me) return retVal
def PFitCGauss(inFA, FWHM, center, peak, err): """ Fit Circular Gaussian around peak in FArray returns RMS residual to fit * inFA = Array to be fitted * FWHM = [in] as list, half width of box around peak to use in fitting * 0 = all. [out] as list, Full width Half Max (pixels) of fitted Gaussian * center = [out] [x,y] pixel (0-rel) coordinates of peak * peak = [out] as list, peak value in fitted Gaussian * err = Python Obit Error/message stack """ ################################################################ # Checks if not FArray.PIsA(inFA): raise TypeError, "inFA MUST be a Python Obit FArray" # results in retVal retVal = Obit.FArrayUtilFitCGauss(inFA.me, FWHM[0], center, peak[0], err.me) FWHM[0] = retVal[0] peak[0] = retVal[1] center[0] = retVal[2] center[1] = retVal[3] return retVal[4]
def PConv(inImage, convFn, doDivide, rescale, outImage, err): """ (de)Convolve an Image with an FArray and write outImage This routine convolves all selected planes in inImage with convFn if doDivide is FALSE, else it does a linear deconvolution Operations are performed using FFTs * inImage = Obit Image to be convolved * convFn = Obit/FArray Convolving Function * doDovide = If true divide FT of convFn into FT of inImage, else multiply. * rescale = Multiplication factor to scale output to correct units * outImage = Output ObitImage must be a clone of inImage Actual convolution size must be set externally * err = Python Obit Error/message stack """ ################################################################ # Checks if not Image.PIsA(inImage): print "Actually ", inImage.__class__ raise TypeError, "inImage MUST be a Python Obit Image" if not FArray.PIsA(convFn): print "Actually ", convFn.__class__ raise TypeError, "convFn MUST be a Python Obit FArray" if not Image.PIsA(outImage): print "Actually ", outImage.__class__ raise TypeError, "outImage MUST be a Python Obit Image" if not OErr.OErrIsA(err): raise TypeError, "err MUST be an OErr" # Obit.ConvUtilConv(inImage.me, convFn.me, doDivide, rescale, outImage.me, err.me)
def PExtract (inFFT, inArray, outArray, err): """ Extract a Real array from one padded for FFTs Any blanked values are replaces with zeroes returns outArray * inFFT = Gives size of FFT used * inArray = Python FArray with FFT results. * outArray = Python FArray describing results * err = Python Obit Error/message stack """ ################################################################ # Checks if not FFT.PIsA(inFFT): raise TypeError("inFFT MUST be a Python Obit FFT") if not FArray.PIsA(inArray): print("Actually ",inArray.__class__) raise TypeError("inArray MUST be a Python Obit FArray") if not FArray.PIsA(outArray): print("Actually ",outArray.__class__) raise TypeError("outArray MUST be a Python Obit FArray") if not OErr.OErrIsA(err): raise TypeError("err MUST be an OErr") # # FFT info FFTrank = FFT.PGetRank(inFFT) FFTdim = FFT.PGetDim(inFFT) # Target Array info ArrayNdim = outArray.Ndim ArrayNaxis = outArray.Naxis # Get window to extract cen = [FFTdim[0]//2, FFTdim[1]//2]; blc = [0,0]; trc=[0,0] blc[0] = cen[0] - ArrayNaxis[0] // 2; trc[0] = cen[0] - 1 + ArrayNaxis[0] // 2 blc[1] = cen[1] - ArrayNaxis[1] // 2; trc[1] = cen[1] - 1 + ArrayNaxis[1] // 2 # Make sure to fill output array if ((trc[0]-blc[0]+1)<ArrayNaxis[0]): trc[0] = blc[0] + ArrayNaxis[0] - 1 if ((trc[1]-blc[1]+1)<ArrayNaxis[1]): trc[1] = blc[1] + ArrayNaxis[1] - 1 # Extract out = FArray.PSubArr(inArray, blc, trc, err) return out
def MFPBCor(inIm, err, antSize=24.5, minGain=0.05): """ Apply primary beam corrections to an ImageMF WARNING: This routine modifies the input image; ONLY RUN IT ONCE. * inIm = Image to be modified * err = Python Obit Error/message stack * antSize = Antenna diameter in m. * minGain = Minimum antenna gain """ # Check if not inIm.ImageIsA(): raise TypeError("input MUST be a Python Obit Image") # Image info nterm = inIm.Desc.List.Dict['NTERM'][2][0] nspec = inIm.Desc.List.Dict['NSPEC'][2][0] freqs = [] for i in range(1, nspec + 1): key = 'FREQ%4.4d' % i freqs.append(inIm.Desc.List.Dict[key][2][0]) # end loop # Make scratch image for beam beam = Image.Image("PBeam") Image.PCloneMem(inIm, beam, err) OErr.printErrMsg(err, "Error with scratch beam image") # Loop over planes for i in range(1, nspec + 1): # Read plane plane = [i + nterm, 1, 1, 1, 1] Image.PGetPlane(inIm, None, plane, err) OErr.printErrMsg(err, "Error reading image") # Set frequency for PBCor d = inIm.Desc.Dict d['crval'][2] = freqs[i - 1] inIm.Desc.Dict = d # Make PB Image ImageUtil.PPBImage(beam, beam, err, minGain=minGain, antSize=antSize, outPlane=plane) OErr.printErrMsg(err, "Error making PB image") # Divide FArray.PDivClip(inIm.FArray, beam.FArray, minGain, inIm.FArray) # Rewrite plane Image.PPutPlane(inIm, None, plane, err) OErr.printErrMsg(err, "Error writing image") # end loop # Add history outHistory = History.History("history", inIm.List, err) outHistory.Open(History.READWRITE, err) outHistory.TimeStamp(" Start Obit MFPBCor", err) outHistory.WriteRec(-1, "MFPBCor" + " antSize = " + str(antSize), err) outHistory.WriteRec(-1, "MFPBCor" + " minGain = " + str(minGain), err) outHistory.Close(err)
def SumImageCube (inCube, outImage, err): """ Average the planes in an image Ignores all blank or zero images * inCube = cube to sum * outImage = output average plane, defined but not instantiated * err = Python Obit Error/message stack """ # Checks if not Image.PIsA(inCube): raise TypeError,"inCube MUST be a Python Obit Image" if not Image.PIsA(outImage): raise TypeError,"outImage MUST be a Python Obit Image" if not OErr.OErrIsA(err): raise TypeError,"err MUST be an OErr" # Clone output image inCube.List.set("BLC",[1,1,1]) inCube.List.set("TRC",[0,0,1]) inCube.Clone(outImage,err) inCube.List.set("TRC",[0,0,0]) OErr.printErrMsg(err, "Error initializing images") # Open files inCube.Open(Image.READONLY,err) outImage.Open(Image.WRITEONLY,err) OErr.printErrMsg(err, "Error opening images") nplane = inCube.Desc.Dict["inaxes"][2] count = 0 for i in range (1,nplane+1): plane = [i,1,1,1,1] inCube.GetPlane(None, plane, err) OErr.printErrMsg(err, "Error reading image") # Anything here rms = inCube.FArray.RawRMS if (not math.isnan(rms)) and (rms>0.0): count += 1 FArray.PAdd(inCube.FArray, outImage.FArray, outImage.FArray) # end loop norm = 1.0 / float(count) FArray.PSMul(outImage.FArray, norm) plane = [1,1,1,1,1] outImage.PutPlane(None, plane, err) OErr.printErrMsg(err, "Error writing image") inCube.Close(err) outImage.Close(err) OErr.printErrMsg(err, "Error closing images")
def np_farray(self): try: buf = FArray.PGetBuf(self.img.FArray) except Exception: raise Exception("Exception getting float array buffer " "on image '%s'" % self.name) return np.frombuffer(buf, count=-1, dtype=np.float32).reshape(self.FArray.Naxis)
def PMakeBeamMask(inImage, inFFT, err): """ Make uv plane weighting array Creates an FArray the size of a plane in inImage, FFT, takes real part and normalizes the central value to one Resulting array is returned. * inImage = Python Image whose FArray is to be converted to a weight mask * inFFT = Python Obit fortward FFT object * err = Python Obit Error/message stack """ ################################################################ # Checks if not Image.PIsA(inImage): print "Actually ", inImage.__class__ raise TypeError, "inImage MUST be a Python Obit Image" if not FFT.PIsA(inFFT): print "Actually ", inFFT.__class__ raise TypeError, "inFFT MUST be a Python Obit FFT" # # Make copy of data array inArray = inImage.FArray outArray = FArray.PClone(inArray, err) #OErr.printErrMsg(err, "Error duplicating FArray for "+Image.PGetName(inImage)) # Add model PCreateModel(inImage, outArray) # Pad for FFT FFTdim = FFT.PGetDim(inFFT) FFTArray = FArray.PClone(inArray, err) naxis = FFTdim[0:2] # Make output big enough for FFT FFTArray = FArray.FArray("FFT array", naxis) PPadArray(inFFT, outArray, FFTArray) del outArray # Cleanup # Swaparoonie FArray.PCenter2D(FFTArray) # FFT uvArray = PCreateFFTArray(inFFT) PFFTR2C(inFFT, FFTArray, uvArray) del FFTArray # Cleanup # Extract Real part naxis = CArray.PGetNaxis(uvArray)[0:2] maskArray = FArray.FArray("Mask array for " + Image.PGetName(inImage), naxis) CArray.PReal(uvArray, maskArray) del uvArray # Cleanup # Normalize pos = [0, 1 + naxis[1] / 2] peak = FArray.PMax(maskArray, pos) norm = 1.0 / peak FArray.PSMul(maskArray, norm) return maskArray
def PMFPBCor(inIm, err, antSize=25, minGain=0.05): """ Apply primary beam corrections to an ImageMF WARNING: This routine modifies the input image; ONLY RUN IT ONCE. * inIm = Image to be modified * err = Python Obit Error/message stack * antSize = Antenna diameter in m. * minGain = Minimum antenna gain """ # Image info nterm = inIm.Desc.List.Dict['NTERM'][2][0] nspec = inIm.Desc.List.Dict['NSPEC'][2][0] freqs = [] for i in range(1, nspec + 1): key = 'FREQ%4.4d' % i freqs.append(inIm.Desc.List.Dict[key][2][0]) # end loop # Make scratch image for beam beam = Image.Image("PBeam") Image.PCloneMem(inIm, beam, err) OErr.printErrMsg(err, "Error with scratch beam image") # Debug xf = Image.PFArray2FITS(beam.FArray, "Beam.fits", err, 0, oDesc=beam.Desc) # Loop over planes for i in range(1, nspec + 1): # Read plane plane = [i + nterm, 1, 1, 1, 1] Image.PGetPlane(inIm, None, plane, err) OErr.printErrMsg(err, "Error reading image") # Set frequency for PBCor d = inIm.Desc.Dict d['crval'][2] = freqs[i - 1] inIm.Desc.Dict = d # Make PB Image ImageUtil.PPBImage(beam, beam, err, minGain=minGain, antSize=antSize, outPlane=plane) OErr.printErrMsg(err, "Error making PB image") # Debug oldVal = inIm.FArray.get(5046, 1533) gain = beam.FArray.get(5046, 1533) # Divide FArray.PDivClip(inIm.FArray, beam.FArray, minGain, inIm.FArray) newVal = inIm.FArray.get(5046, 1533) # Rewrite plane Image.PPutPlane(inIm, None, plane, err) # Debug print(i, plane[0], "nu=", freqs[i - 1], 'g=', gain, oldVal, newVal) Image.PPutPlane(xf, beam.FArray, plane, err) OErr.printErrMsg(err, "Error writing image")
def PConvolve(inFA1, inFA2, err): """ Return the convolution of two 2-D arrays inFA1 and inFA2 must be compatible size and should not contain magic value blanks. Convolved array returned. * inFA1 = First array * inFA2 = Second array * err = Python Obit Error/message stack """ ################################################################ # Checks if not FArray.PIsA(inFA1): raise TypeError, "inFA1 MUST be a Python Obit FArray" if not FArray.PIsA(inFA2): raise TypeError, "inFA2 MUST be a Python Obit FArray" # outFA = FArray.FArray("None") outFA.me = Obit.FArrayUtilConvolve(inFA1.me, inFA2.me, err.me) return outFA
def PPadArray (inFFT, inArray, outArray): """ Zero Pads an array as needed for an FFT Any blanked values are replaced with zeroes * inFFT = Gives size of FFT needed * inArray = Python FArray to be padded. * outArray = Python FArray containing inArray but zero filled. Must previously exist. """ ################################################################ # Checks if not FFT.PIsA(inFFT): raise TypeError("inFFT MUST be a Python Obit FFT") if not FArray.PIsA(inArray): print("Actually ",inArray.__class__) raise TypeError("inArray MUST be a Python Obit FArray") if not FArray.PIsA(outArray): print("Actually ",outArray.__class__) raise TypeError("outArray MUST be a Python Obit FArray") # # FFT info FFTrank = FFT.PGetRank(inFFT) FFTdim = FFT.PGetDim(inFFT) # Array info ArrayNdim = inArray.Ndim ArrayNaxis = inArray.Naxis # Zero fill output FArray.PFill(outArray, 0.0) # Insert inArray into outArray - center as well as possible pos1 = [FFTdim[0]//2, FFTdim[1]//2] pos2 = [ArrayNaxis[0]//2, ArrayNaxis[1]//2] FArray.PShiftAdd (outArray, pos1, inArray, pos2, 1.0, outArray) # Replace any blanks with zeroes FArray.PDeblank(outArray, 0.0)
def PIntHist(inPixHistFDR): """ Return the integrated pixel histogram returns integrated pixel histogram inPixHistFDR = Python PixHistFDR object """ ################################################################ # Checks if not PIsA(inPixHistFDR): raise TypeError("inPixHistFDR MUST be a Python Obit PixHistFDR") # out = FArray.FArray("IntHist") out.me = Obit.FArrayUnref(out.me) out.me = Obit.PixHistFDRGetIntHisto(inPixHistFDR.me) return out
def PReplace(inFI, newArray): """ Replace the ObitFArray member to be interpolated. * inFI = Python Obit input FInterpolate * newArray= Python Obit FArray """ ################################################################ # Checks if not PIsA(inFI): raise TypeError("inFI MUST be a Python Obit FInterpolate") if not FArray.PIsA(newArray): raise TypeError("newArray MUST be a Python Obit FArray") # Obit.FInterpolateReplace(inFI.me, newArray.me)
def PGetFArray(inFI): """ Get Associated FArray reference return FArray (data being interpolated) reference * inFI = Python Obit input FInterpolate """ ################################################################ # Checks if not PIsA(inFI): raise TypeError("inFI MUST be a Python Obit FInterpolate") # out = FArray.FArray("None") out.me = Obit.FInterpolateGetFArray(inFI.me) return out
def PImPix(inPixHistFDR): """ Return the Image Pixel FArray returns Image Pixel FArray inPixHistFDR = Python PixHistFDR object """ ################################################################ # Checks if not PIsA(inPixHistFDR): raise TypeError("inPixHistFDR MUST be a Python Obit PixHistFDR") # out = FArray.FArray("ImPix") out.me = Obit.FArrayUnref(out.me) out.me = Obit.PixHistFDRGetImPix(inPixHistFDR.me) return out
def PDifHist(inPixHistFDR): """ Return the differential pixel histogram returns differential pixel histogram inPixHistFDR = Python PixHistFDR object """ ################################################################ # Checks if not PIsA(inPixHistFDR): raise TypeError("inPixHistFDR MUST be a Python Obit PixHistFDR") # out = FArray.FArray("DifHist") out.me = Obit.FArrayUnref(out.me) out.me = Obit.PixHistFDRGetHisto(inPixHistFDR.me) return out
def PMakeC(Fin): """ Make a CArray with the same geometry as a FArray return CArray size of Fin * Fin = input Python FArray """ ################################################################ # Checks if not FArray.PIsA(Fin): print("Actually ", Fin.__class__) raise TypeError("Fin MUST be a Python Obit FArray") outCA = CArray("None") outCA.me = Obit.CArrayMakeC(Fin.me) return outCA
def PImPix(inPixHistFDR): """ Return the Image Pixel FArray returns Image Pixel FArray inPixHistFDR = Python PixHistFDR object """ ################################################################ # Checks if not PIsA(inPixHistFDR): raise TypeError, "inPixHistFDR MUST be a Python Obit PixHistFDR" # sm = inPixHistFDR.cast(myClass) # cast pointer out = FArray.FArray("ImPix") out.me = Obit.FArrayUnref(out.me) out.me = Obit.PixHistFDRGetImPix(sm) return out
def PDifHist(inPixHistFDR): """ Return the differential pixel histogram returns differential pixel histogram inPixHistFDR = Python PixHistFDR object """ ################################################################ # Checks if not PIsA(inPixHistFDR): raise TypeError, "inPixHistFDR MUST be a Python Obit PixHistFDR" # sm = inPixHistFDR.cast(myClass) # cast pointer out = FArray.FArray("DifHist") out.me = Obit.FArrayUnref(out.me) out.me = Obit.PixHistFDRGetHisto(sm) return out
def PMakeF(Cin): """ Make an FArray with the same geometry as a CArray return FArray size of CArray * Cin = input Python CArray """ ################################################################ # Checks if not PIsA(Cin): print("Actually ", iCn.__class__) raise TypeError("Cin MUST be a Python Obit CArray") outFA = FArray.FArray("None") outFA.me = Obit.CArrayMakeF(Cin.me) return outFA
def PComplex(Fin1, Fin2, out): """ Combine two FArrays into a CArray Fill A complex CArray from two FArrays * Fin1 = input Python FArray for Real part * Fin2 = input Python FArray for Imaginary part * out = output Python CArray """ ################################################################ # Checks if not FArray.PIsCompatable(Fin1, Fin2): raise RuntimeError("Fin1 and Fin2 have incompatable geometry") if not PIsFCompatable(out, Fin1): raise RuntimeError("Fin1 and out have incompatable geometry") Obit.CArrayComplex(Fin1.me, Fin2.me, out.me)
def PGetFArray(inImageMF): """ Return FArray used to buffer Image data returns FArray with image pixel data * inImageMF = Python Image object """ ################################################################ if inImageMF.myClass == 'AIPSImage': raise TypeError("Function unavailable for " + inImage.myClass) # Checks if not inImageMF.ImageMFIsA(): raise TypeError("inImageMF MUST be a Python Obit Image") # out = FArray.FArray("None") out.me = Obit.ImageMFGetFArray(inImageMF.me) return out
def PUVGaus(naxis, cells, maprot, maj, min, pa): """ Create a Gaussian UV tapering image corresponding to an image plane Gaussian Returns an FArray with a Gaussian taper, as [u,v] * naxis = dimension as [nx,ny] * cells = cell spacing in x and y in units of maj,min (asec) * maprot = Map rotation (deg) * maj = Major axis of Gaussian in image plane (same units as cells) * min = Minor axis of Gaussian in image plane (same units as cells) * pa = Position angle of Gaussian in image plane, from N thru E, (deg) """ ################################################################ # Create output outFA = FArray.FArray("UVpix", naxis) outFA.me = Obit.FArrayUtilUVGaus(naxis, cells, maprot, maj, min, pa) return outFA