def PDeblank (inImage, value): """ Replace blanks in the FArray for image inImage Any blanked values are replaced with value * inImage = Python Image whose FArray is to be deblanked * value = value to replace blanks, e.g. 0.0 """ ################################################################ # Checks if not Image.PIsA(inImage): print("Actually ",inImage.__class__) raise TypeError("inImage MUST be a Python Obit Image") # # Get data array inArray = Image.PGetFArray(inImage) # Replace any blanks with value FArray.PDeblank(inArray, value)
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)
ypix = YPixIm.FArray # Set interpolator to input image FInterpolate.PSetDesc(fi, x.Desc) FInterpolate.PReplace(fi, inArr) # Interpolate for ix in range(0, ncell): for iy in range(0, ncell): pos = [space * (ix - half), space * (iy - half)] pix = ImageDesc.PGetPixel(x.Desc, pos, err) val = FInterpolate.PPixel(fi, pix, err) work.set(val, ix, iy) # end interpolation loops # Accumulate weight image, zero where image blanked FArray.PFill(work2, weight[ires]) FArray.PBlank(work2, work, work2) FArray.PDeblank(work2, 0.0) # Replace any blanking with 0.0 FArray.PAdd(accW, work2, accW) # Image * wt FArray.PDeblank(work, 0.0) # Replace any blanking with 0.0 FArray.PSMul(work, weight[ires]) # Accumulate image*wt FArray.PAdd(accWI, work, accWI) ires += 1 # Next resolution # end resolution loop FArray.PDiv(accWI, accW, accWI) # Normalize to accWI # Write output outIm.PutPlane(accWI, oplane, err) iplane[0] += 1 # Next input plane if iplane[0] > nChan: