Ejemplo n.º 1
0
def makefft(img,pad=0):
    d=darc.Control("SH")
    return correlation.transformPSF(img,3,[256,256,128],[128]*3,[98,98,49],d.Get("subapLocation"),d.Get("subapFlag"),pad)
Ejemplo n.º 2
0
dmflag = tel.Pupil(8, 4, 0).fn.ravel()
numpy.put(tmp, dmflag.nonzero()[0], numpy.arange(52))

corrClip = 1
corrNStore = 20
corrThresh = 0.0
corrThreshType = 2  #CORR_FRAC_SUB
corrUpdateGain = 0.
centroidMode = "CorrelationCoG"

psf = FITS.Read(fname.strip("\0"))[1].mean(0).ravel() - bgImage
psf = numpy.where(psf < 0, 0, psf)

import correlation
corrdata = correlation.transformPSF(
    psf, ncam, npxlx, npxly, nsub, subapLocation, subapFlag, pad=8
)  #Note - to get identical slope estimates when doing auto correlation update and using the correlation result for shift and add (corrUpdateToCoG=0), probably need pad to be larger, to avoid wrapping.  But in practice, the difference in results is small.
corrFFTPattern = corrdata["corrFFTPattern"]
corrSubapLoc = corrdata["corrSubapLoc"]
corrNpxlx = corrdata["corrNpxlx"]
corrNpxlCum = corrdata["corrNpxlCum"]

#Now populate the control structure - this is what gets used.

control = {
    "switchRequested":
    0,  #this is the only item in a currently active buffer that can be changed...
    "pause": 0,
    "go": 1,
    "maxClipped": nacts,
    "refCentroids": None,
Ejemplo n.º 3
0
    "mirrorName":
    "dmcSocket",
    "mirrorOpen":
    0,
    "frameno":
    0,
    "switchTime":
    numpy.zeros((1, ), "d")[0],
    "adaptiveWinGain":
    0.5,
    "corrThreshType":
    0,
    "corrThresh":
    0.,
    "corrFFTPattern":
    correlation.transformPSF(correlationPSF, ncam, npxlx, npxly, nsub,
                             subapLocation, subapFlag),
    #    "correlationPSF":correlationPSF,
    "nsubapsTogether":
    1,
    "nsteps":
    0,
}
#set the gain array
control["gain"][:2] = 0.5
# Note, gain is NOT used by the reconstructor - here, we assume that rows of the reconstructor have already been multiplied by the appropriate gain.  Similarly, the rows of E have been multiplied by 1-gain.  This multiplication is handled transparently by the GUI.

# set up the pxlCnt array - number of pixels to wait until each subap is ready.  Here assume identical for each camera.
for k in range(ncam):
    # tot=0#reset for each camera
    for i in range(nsuby[k]):
        for j in range(nsubx[k]):
Ejemplo n.º 4
0
    #plt.show()
    nacts = 140 #The total number of actuators for the system.
    ncam = 1    #This is the number of camera objects in the system
    npxly = numpy.zeros((ncam,), numpy.int32)#An array of length ncam, specifying the number of pixels in a vertical direction with an entry for each frame grabber.
    npxly[:] = 1080#An array of length ncam, specifying the number of pixels in a vertical direction with an entry for each frame grabber.
    npxlx = npxly.copy()#An array of length ncam, specifying the number of pixels in a horizontal direction with an entry for each frame grabber.
    npxlx[:] = 1920#An array of length ncam, specifying the number of pixels in a horizontal direction with an entry for each frame grabber.
    nsuby = npxly.copy()
    nsuby[:] = 1#this is science, so only one subap required... 
    nsubx = nsuby.copy()
    nsub = nsubx*nsuby #An array with ncam entries, specifying the number of sub-apertures for each frame grabber.
    nsubaps = (nsuby*nsubx).sum() #nsubaps is the total number of sub-apertures
    subapFlag = numpy.ones((nsubaps,), "i") #An array of size equal to the total number of sub-apertures, with a flag value for each, specifying whether this sub-aperture should be used.
    
#    correlation.transformPSF(img,ncam,npxlx,npxly,nsub, subapLocation,d.Get("subapFlag"),pad)
    correlation.transformPSF(img,ncam,npxlx,npxly,nsub, d.Get("subapLocation"),d.Get("subapFlag"),pad,savespace=1)
    #def transformPSF(psf,ncam,npxlx,npxly,nsub,subapLocation,subflag,pad=None,savespace=0):
    #    """Function to transform psf into a form that will be usable by the RTC.
    #    psf is eg the LGS spot elongation pattern.  ncam is number of cameras
    #    npxlx/y is array of size ncam with number of pixels for each camera nsubx/y
    #    is array size ncam with number of subaps for each camera subapLocation is
    #    array containing subap location details, one set of entries per
    #    subaperture.  If pad is set, it will pad the fft pattern, and also return
    #    lots of other things required by darc.  If savespace is also set (as per
    #    default), the returned fft pattern subaperture locations will bear no
    #    resemblance to the wavefront sensors.
    (slopes, usenow) = getSlopes(img)
    print slopes
    print usenow
    print slopes.size