Ejemplo n.º 1
0
def makePattern(pattern, oversample=2, col=None):
    if pattern == "cross":
        pattern = numpy.zeros((oversample, oversample, 4), numpy.float32)
        pattern[oversample / 2:oversample / 2 + 1, :, 3] = 1
        pattern[:, oversample / 2:oversample / 2 + 1, 3] = 1
        if col == None:
            col = (0, 1, 0)
        pattern[oversample / 2:oversample / 2 + 1, :, :3] = col
        pattern[:, oversample / 2:oversample / 2 + 1, :3] = col
    elif pattern == "egg":
        import tel
        pattern = numpy.zeros((oversample, oversample, 4), numpy.float32)
        pattern[:, :, 0] = tel.Pupil(oversample, oversample / 2, 0).fn
        pattern[:, :, 1] = pattern[:, :, 0]
        pattern[:, :, 2] = tel.Pupil(oversample, oversample / 4, 0).fn
        #pattern[oversample*.25:oversample*.75,oversample*.25:oversample*.75,:3]=1
        pattern[:, :, 3] = 0.4

    elif pattern == "target":
        import tel
        pattern = numpy.zeros((oversample, oversample, 4), numpy.float32)
        pattern[:, :, 1] = 1
        pattern[:, :, 3] = tel.Pupil(oversample, oversample / 2,
                                     oversample / 2 - 1).fn
    else:
        pattern = numpy.zeros((oversample, oversample, 4), numpy.float32)
        pattern[:, :, 1::2] = 1
    return pattern
Ejemplo n.º 2
0
def createZernikeOverlay(actmap, pupfn=None, nmodes=None):
    #pupfn is same size as actmap
    import zernike
    if pupfn == None:
        import tel
        pupfn = tel.Pupil(actmap.shape[0], actmap.shape[0] / 2,
                          0).fn  #(actmap!=0).astype(numpy.int32)
    if nmodes == None:
        nmodes = int((actmap.shape[0] + 1) * (actmap.shape[0] + 2) / 2.)
    z = zernike.Zernike(pupfn, nmodes)
    coeff = z.calcZernikeCoeff(actmap)
    data = z.zernikeReconstruct(coeff, size=64)
    return data
Ejemplo n.º 3
0
 def zernikeReconstruct(self, coeff, out=None, size=None):
     if out == None:
         if size == None:
             size = self.npup
         out = numpy.zeros((size, size), numpy.float32)
     if out.shape[0] != self.npup:
         if self.zernExpand == None or self.zernExpand.shape[
                 1] != out.shape[0]:
             import tel
             print "Computing zernikes"
             z = Zernike(
                 tel.Pupil(out.shape[0], out.shape[0] / 2, 0).fn,
                 coeff.shape[0])
             self.zernExpand = z.zern
         zern = self.zernExpand
     else:
         zern = self.zern
     for i in range(1, coeff.shape[0]):
         out += coeff[i] * zern[i]
     return out
Ejemplo n.º 4
0
import numpy
ncam=6#1, 2, 3, 4.  This is the number of physical cameras

nacts=220#97#54#+256
#ncam=(int(NCAMERAS)+1)/2
camPerGrab=numpy.ones((ncam,),"i")
ncamThreads=numpy.ones((ncam,),numpy.int32)*1
npxly=numpy.zeros((ncam,),numpy.int32)
npxly[:]=128
npxlx=npxly.copy()*camPerGrab
nsuby=npxlx.copy()
nsuby[:]=10#for config purposes only... not sent to rtc
nsubx=nsuby.copy()*camPerGrab#for config purposes - not sent to rtc
nsub=nsubx*nsuby#This is used by rtc.
nsubaps=nsub.sum()#(nsuby*nsubx).sum()
individualSubapFlag=tel.Pupil(10,10/2.,0.5,10,0.5).subflag.astype("i")
subapFlag=numpy.zeros((nsubaps,),"i")
for i in range(ncam):
    tmp=subapFlag[nsub[:i].sum():nsub[:i+1].sum()]
    tmp.shape=nsuby[i],nsubx[i]
    for j in range(camPerGrab[i]):
        tmp[:,j::camPerGrab[i]]=individualSubapFlag
#ncents=nsubaps*2
ncents=subapFlag.sum()*2
npxls=(npxly*npxlx).sum()
print "ncents %d"%ncents
fakeCCDImage=None#(numpy.random.random((npxls,))*20).astype("i")
#camimg=(numpy.random.random((10,npxls))*20).astype(numpy.int16)

bgImage=None#FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise=None#FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
Ejemplo n.º 5
0
#along with this program.  If not, see <http://www.gnu.org/licenses/>.
import FITS
import tel
import numpy
import os
#Set up some basic parameters
nacts = 1024
ncam = 1  # Number of WFSs
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 8  #Number of threads to use
npxly = numpy.ones((ncam, ), numpy.int32) * 128  #detector size
npxlx = npxly.copy()
nsuby = numpy.ones((ncam, ), numpy.int32) * 7  #number of sub-apertures
nsubx = nsuby.copy()
nsub = nsuby * nsubx
nsubtot = nsub.sum()
subapFlag = numpy.array([tel.Pupil(7 * 16, 7 * 8, 8, 7).subflag.astype("i")] *
                        ncam).ravel()  #Generate an map of used sub-apertures

ncents = subapFlag.sum() * 2  #number of slope measurements (x and y)
npxls = (npxly * npxlx).sum()

#Calibration data
bgImage = numpy.ones(
    128 * 128 * ncam) * 12  #None#FITS.Read("shimgb1stripped_bg.fits")[1]
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField = None  #FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

nsubaps = nsuby * nsubx  #cumulative subap
nsubapsCum = numpy.zeros((ncam + 1, ), numpy.int32)
ncentsCum = numpy.zeros((ncam + 1, ), numpy.int32)
for i in range(ncam):
Ejemplo n.º 6
0
import correlation,FITS
import tel
import numpy
nacts=52#97#54#+256
ncam=1
ncamThreads=numpy.ones((ncam,),numpy.int32)*8
npxly=numpy.zeros((ncam,),numpy.int32)
npxly[:]=128
npxlx=npxly.copy()
nsuby=npxly.copy()
nsuby[:]=7
#nsuby[4:]=16
nsubx=nsuby.copy()
nsub=nsubx*nsuby
nsubaps=(nsuby*nsubx).sum()
subapFlag=tel.Pupil(7*16,7*8,8,7).subflag.astype("i").ravel()#numpy.ones((nsubaps,),"i")

#ncents=nsubaps*2
ncents=subapFlag.sum()*2
npxls=(npxly*npxlx).sum()

fakeCCDImage=None#(numpy.random.random((npxls,))*20).astype("i")
#camimg=(numpy.random.random((10,npxls))*20).astype(numpy.int16)

bgImage=None#FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise=None#FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField=None#FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

#FITS.Write(camimg,"camImage.fits")#file used when reading from file,
subapLocation=numpy.zeros((nsubaps,6),"i")
nsubaps=nsuby*nsubx#cumulative subap
Ejemplo n.º 7
0
nacts = 54  #97#54#+256
ncam = (int(NCAMERAS) + 1) / 2
camPerGrab = numpy.ones((ncam, ), "i") * 2
if NCAMERAS % 2 == 1:
    camPerGrab[-1] = 1
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 128
npxlx = npxly.copy() * camPerGrab
nsuby = npxlx.copy()
nsuby[:] = 7  #for config purposes only... not sent to rtc
nsubx = nsuby.copy() * camPerGrab  #for config purposes - not sent to rtc
nsub = nsubx * nsuby  #This is used by rtc.
nsubaps = nsub.sum()  #(nsuby*nsubx).sum()
individualSubapFlag = tel.Pupil(7, 3.5, 1, 7).subflag.astype("i")
subapFlag = numpy.zeros((nsubaps, ), "i")
for i in range(ncam):
    tmp = subapFlag[nsub[:i].sum():nsub[:i + 1].sum()]
    tmp.shape = nsuby[i], nsubx[i]
    for j in range(camPerGrab[i]):
        tmp[:, j::camPerGrab[i]] = individualSubapFlag
#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")
#camimg=(numpy.random.random((10,npxls))*20).astype(numpy.int16)

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
Ejemplo n.º 8
0
ncamThreads=numpy.ones((ncam,),numpy.int32)*8
nlots=[4]*ncam#number of blocks in which to do processing

noPrePostThread=0
threadPriority=numpy.ones((ncamThreads.sum()+1,),numpy.int32)*40
#threadPriority=numpy.arange(ncamThreads.sum()+1)+40
threadPriority[0]=39
threadAffinity=None#1<<(numpy.arange(1+ncamThreads.sum()))



nsub=84#should be 40 for sphere...
npxl=8
nact=nsub+1
nacts=tel.Pupil(nact,nact/2.,2).fn.astype("i").sum()
#if NCAMERAS%2==1:
#    camPerGrab[-1]=1
npxly=numpy.zeros((ncam,),numpy.int32)
npxly[:]=nsub*npxl
npxlx=npxly.copy()*camPerGrab
nsuby=npxly.copy()
nsuby[:]=nsub
nsubx=nsuby.copy()*camPerGrab
nsubaps=(nsuby*nsubx).sum()
individualSubapFlag=tel.Pupil(nsub,nsub/2.,84/2./7.,nsub).subflag.astype("i")#42m, with 6m secondary
subapFlag=numpy.zeros(((nsuby*nsubx).sum(),),"i")
for i in range(ncam):
    tmp=subapFlag[(nsuby[:i]*nsubx[:i]).sum():(nsuby[:i+1]*nsubx[:i+1]).sum()]
    tmp.shape=nsuby[i],nsubx[i]
    for j in range(camPerGrab[i]):
Ejemplo n.º 9
0
    try:
        ncam = int(prefix)
    except:
        ncam = 4
print "Using %d cameras" % ncam
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 488
npxlx = npxly.copy()
npxlx[:] = 488
nsuby = npxlx.copy()
nsuby[:] = 30  #for config purposes only... not sent to rtc
nsubx = nsuby.copy()  #for config purposes - not sent to rtc
nsub = nsubx * nsuby  #This is used by rtc.
nsubaps = nsub.sum()  #(nsuby*nsubx).sum()
individualSubapFlag = tel.Pupil(30, 15, 2, 30).subflag.astype("i")
subapFlag = numpy.zeros((nsubaps, ), "i")
for i in range(ncam):
    tmp = subapFlag[nsub[:i].sum():nsub[:i + 1].sum()]
    tmp.shape = nsuby[i], nsubx[i]
    tmp[:] = individualSubapFlag
#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField = None  #FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")
Ejemplo n.º 10
0
mirrorParams[0] = 1000  #timeout/ms
mirrorParams[1] = 1  #port
mirrorParams[2] = 1  #thread affinity el size
mirrorParams[3] = 1  #thread prioirty
mirrorParams[4] = -1  #thread affinity

#Now describe the DM - this is for the GUI only, not the RTC.
#The format is: ndms, N for each DM, actuator numbers...
#Where ndms is the number of DMs, N is the number of linear actuators for each, and the actuator numbers are then an array of size NxN with entries -1 for unused actuators, or the actuator number that will set this actuator in the DMC array.
dmDescription = numpy.zeros((8 * 8 + 1 + 1, ), numpy.int16)
dmDescription[0] = 1  #1 DM
dmDescription[1] = 8  #1st DM has nacts linear actuators
tmp = dmDescription[2:]
tmp[:] = -1
tmp.shape = 8, 8
dmflag = tel.Pupil(8, 4, 0).fn.ravel()
numpy.put(tmp, dmflag.nonzero()[0], numpy.arange(52))

control = {
    "switchRequested":
    0,  #this is the only item in a currently active buffer that can be changed...
    "pause": 0,
    "go": 1,
    #"DMgain":0.25,
    #"staticTerm":None,
    "maxClipped": nacts,
    "refCentroids": None,
    #"dmControlState":0,
    #"gainReconmxT":None,#numpy.random.random((ncents,nacts)).astype("f"),#reconstructor with each row i multiplied by gain[i].
    #"dmPause":0,
    #"reconMode":"closedLoop",
Ejemplo n.º 11
0
import FITS
import tel
import numpy

nacts = 52  #97#54#+256
ncam = 1
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 128
npxlx = npxly.copy()
nsuby = npxlx.copy()
nsuby[:] = 7  #for config purposes only... not sent to rtc
nsubx = nsuby.copy()
nsub = nsubx * nsuby  #This is used by rtc.
nsubaps = nsub.sum()  #(nsuby*nsubx).sum()
subapFlag = tel.Pupil(7, 3.5, 1, 7).subflag.astype("i").ravel()
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField = None  #FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

subapLocation = numpy.zeros((nsubaps, 6), "i")
nsubapsCum = numpy.zeros((ncam + 1, ), numpy.int32)
ncentsCum = numpy.zeros((ncam + 1, ), numpy.int32)
nsubapsCum[1] = nsub[0]
ncentsCum[1] = subapFlag.sum() * 2
Ejemplo n.º 12
0
npxly[ncamSL:ncamSL+NLGSOCAM]=242
npxly[ncamSL+NLGSOCAM:ncamSL+NBOBCAT+NLGSOCAM]=140
npxlx=npxly.copy()#*camPerGrab
npxlx[ncamSL:ncamSL+NLGSOCAM]=264
nsuby=npxlx.copy()
nsuby[:]=7#for config purposes only... not sent to rtc
if ncamSL!=0:
    nsuby[ncamSL-1]=14#truth
nsuby[ncamSL:ncamSL+NLGSOCAM]=7#The LGS 
nsuby[ncamSL+NLGSOCAM:ncamSL+NLGSOCAM+NBOBCAT]=[7,14][:NBOBCAT]
nsubx=nsuby.copy()#*camPerGrab#for config purposes - not sent to rtc
#nsubx[1]=35#ngs3 + truth (14x14)
#nsubx[ncamSL:ncamSL+NLGSOCAM]=14*4#The LGS (4 WFS on 1 detector - in a row.)
nsub=nsubx*nsuby#This is used by rtc.
nsubaps=nsub.sum()#(nsuby*nsubx).sum()
individualSubapFlag=tel.Pupil(7,3.5,1,7).subflag.astype("i")
sf14=tel.Pupil(14,7.,2,14).subflag.astype("i")
sfNoObs=tel.Pupil(7,3.5,0,7).subflag.astype("i")
sf14NoObs=tel.Pupil(14,7.,0,14).subflag.astype("i")
#lgsSubapFlag=numpy.zeros((14,56),"i")

#For the ocam, I think we can simply interleave the top and bottom subap by subap.
#To be sure of ordering, have pxlCnt set to the end of the row, rather than subap.

nsublist=[]
print "nsub:",nsub
#for i in range(4):
#    lgsSubapFlag[:,i::4]=sf14
subapFlag=numpy.zeros((nsubaps,),"i")

for i in range(NNGSCAM+NLGSOCAM+NBOBCAT):#ngs 1-3, truth, lgs, lofs, hofs
Ejemplo n.º 13
0
#You should have received a copy of the GNU Affero General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.
#This is a configuration file for SPHERE.
#Aim to fill up the control dictionary with values to be used in the RTCS.

#import correlation
import FITS
import tel
import numpy
NCAMERAS = 1  #1, 2, 3, 4.  This is the number of physical cameras

nsub = 48
npxl = 6
nact = nsub + 1
nacts = tel.Pupil(nact, nact / 2., 2).fn.astype("i").sum()
ncam = NCAMERAS  #(int(NCAMERAS)+1)/2
camPerGrab = numpy.ones((ncam, ), "i")
#if NCAMERAS%2==1:
#    camPerGrab[-1]=1
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 4
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = nsub * npxl
npxlx = npxly.copy()
nsuby = npxly.copy()
nsuby[:] = nsub
nsubx = nsuby.copy()
nsubaps = (nsuby * nsubx).sum()
individualSubapFlag = tel.Pupil(nsub, nsub / 2., 2, nsub).subflag.astype("i")
subapFlag = numpy.zeros(((nsuby * nsubx).sum(), ), "i")
for i in range(ncam):
Ejemplo n.º 14
0
import tel
import numpy
import os
import time
#Set up some basic parameters
ndm=2
nacts=241*ndm
ncam=1 # Number of WFSs
ncamThreads=numpy.ones((ncam,),numpy.int32)*8 #Number of threads to use
npxly=numpy.ones((ncam,),numpy.int32)*128#detector size
npxlx=npxly.copy()
nsuby=numpy.ones((ncam,),numpy.int32)*7#number of sub-apertures
nsubx=nsuby.copy()
nsub=nsuby*nsubx
nsubtot=nsub.sum()
subapFlag=numpy.array([tel.Pupil(7*16,7*8,8,7).subflag.astype("i")]*ncam).ravel()#Generate an map of used sub-apertures

ncents=subapFlag.sum()*2#number of slope measurements (x and y)
npxls=(npxly*npxlx).sum()

#Calibration data
bgImage=numpy.ones(128*128*ncam)*12#None#FITS.Read("shimgb1stripped_bg.fits")[1]
darkNoise=None#FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField=None#FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

nsubaps=nsuby*nsubx#cumulative subap
nsubapsCum=numpy.zeros((ncam+1,),numpy.int32)
ncentsCum=numpy.zeros((ncam+1,),numpy.int32)
for i in range(ncam):
    nsubapsCum[i+1]=nsubapsCum[i]+nsubaps[i]
    ncentsCum[i+1]=ncentsCum[i]+subapFlag[nsubapsCum[i]:nsubapsCum[i+1]].sum()*2
Ejemplo n.º 15
0
nacts = 54  #97#54#+256
ncam = 1
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 2
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 144  #300#480
npxlx = npxly.copy()
npxlx[:] = 144  #400#640
nsuby = npxly.copy()
nsuby[:] = 14  #15
#nsuby[4:]=16
nsubx = nsuby.copy()
nsubaps = (nsuby * nsubx).sum()
#subapFlag=tel.Pupil(15*16,15*8,8,15).subflag.astype("i").ravel()#numpy.ones((nsubaps,),"i")
subapFlag = tel.Pupil(
    14 * 14, 14 * 7, 4 * 7,
    14).subflag.astype("i").ravel()  #numpy.ones((nsubaps,),"i")

#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")
#camimg=(numpy.random.random((10,npxls))*20).astype(numpy.int16)

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField = None  #FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

subapLocation = numpy.zeros((nsubaps, 6), "i")
nsubaps = nsuby * nsubx  #cumulative subap
Ejemplo n.º 16
0
except:
    port = 8800
print port
import time
time.sleep(1)
#Set up some basic parameters
nacts = 52  #97#54#+256
ncam = 1  # Number of WFSs
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 8  #Number of threads to use
npxly = numpy.ones((ncam, ), numpy.int32) * 128  #detector size
npxlx = npxly.copy()
nsuby = numpy.ones((ncam, ), numpy.int32) * 7  #number of sub-apertures
nsubx = nsuby.copy()
nsub = nsuby * nsubx
nsubtot = nsub.sum()
subapFlag = numpy.array([tel.Pupil(7 * 16, 7 * 8, 8, 7).subflag.astype("i")] *
                        ncam).ravel()  #Generate an map of used sub-apertures

ncents = subapFlag.sum() * 2  #number of slope measurements (x and y)
npxls = (npxly * npxlx).sum()

#Calibration data
bgImage = numpy.ones(
    128 * 128 * ncam) * 12  #None#FITS.Read("shimgb1stripped_bg.fits")[1]
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField = None  #FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

nsubaps = nsuby * nsubx  #cumulative subap
nsubapsCum = numpy.zeros((ncam + 1, ), numpy.int32)
ncentsCum = numpy.zeros((ncam + 1, ), numpy.int32)
for i in range(ncam):
Ejemplo n.º 17
0
#You should have received a copy of the GNU Affero General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.
#This is a configuration file for CANARY.
#Aim to fill up the control dictionary with values to be used in the RTCS.

#import correlation
import FITS
import tel
import numpy

NCAMERAS = 7  #1, 2, 3, 4.  This is the number of physical cameras

nsub = 16
npxl = 12
nact = nsub + 1
nacts = tel.Pupil(17, 8.5, 1).fn.astype("i").sum()
ncam = NCAMERAS  #(int(NCAMERAS)+1)/2
camPerGrab = numpy.ones((ncam, ), "i")
#if NCAMERAS%2==1:
#    camPerGrab[-1]=1
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = nsub * npxl
npxlx = npxly.copy()
nsuby = npxly.copy()
nsuby[:] = 16
nsubx = nsuby.copy()
nsub = nsubx * nsuby
nsubaps = (nsuby * nsubx).sum()
individualSubapFlag = tel.Pupil(nsubx[0], nsubx[0] / 2., 1,
                                nsubx[0]).subflag.astype("i")
Ejemplo n.º 18
0
#along with this program.  If not, see <http://www.gnu.org/licenses/>.
import FITS
import tel
import numpy
import os
#Set up some basic parameters
nacts=52#97#54#+256
ncam=1 # Number of WFSs
ncamThreads=numpy.ones((ncam,),numpy.int32)*8 #Number of threads to use
npxly=numpy.ones((ncam,),numpy.int32)*20#detector size
npxlx=npxly.copy()
nsuby=numpy.ones((ncam,),numpy.int32)*10#number of sub-apertures
nsubx=nsuby.copy()
nsub=nsuby*nsubx
nsubtot=nsub.sum()
subapFlag=tel.Pupil(10,5,0).fn.astype("i")

ncents=subapFlag.sum()*2#number of slope measurements (x and y)
npxls=(npxly*npxlx).sum()

#Calibration data
bgImage=None
darkNoise=None
flatField=None

nsubaps=nsuby*nsubx#cumulative subap
nsubapsCum=numpy.zeros((ncam+1,),numpy.int32)
ncentsCum=numpy.zeros((ncam+1,),numpy.int32)
for i in range(ncam):
    nsubapsCum[i+1]=nsubapsCum[i]+nsubaps[i]
    ncentsCum[i+1]=ncentsCum[i]+subapFlag[nsubapsCum[i]:nsubapsCum[i+1]].sum()*2
Ejemplo n.º 19
0
camAffin[1 - (mcpu - nthreads - 1) / 32] = 0
print "cam affinity", [bin(i) for i in camAffin]

# print out threadAfinity in binary form for verification
for i in range(nthreads + 1):
    print i, [
        bin(j)
        for j in threadAffinity[i * threadAffElSize:(i + 1) * threadAffElSize]
    ]

npxl = 6  # for square subaps
xnpxl = 12  # width for rectangular subaps
ynpxl = 3  #height for rectangular subaps
nact = (nsub + 1)
#print "nact = ", nact
nacts = tel.Pupil(nact, nact / 2., 2).fn.astype("i").sum()
print "nacts1", nacts
nacts = 16 * ((nacts + 15) / 16)
#nacts=10000
print "nacts2", nacts
camPerGrab = numpy.ones((ncam, ), "i")
#if NCAMERAS%2==1:
#    camPerGrab[-1]=1
npxly = numpy.zeros((ncam, ), numpy.int32)

npxly[:] = nsub * npxl  #square subaps
npxly[:] = nsub * ynpxl  #rectangular subaps
npxly[:] = 260  #manually set for 10G camera

npxlx = npxly.copy()  #square subaps
npxlx[:] = nsub * xnpxl  #rectangular subaps
Ejemplo n.º 20
0
import numpy
NCAMERAS=1#1, 2, 3, 4.  This is the number of physical cameras
ncam=NCAMERAS#(int(NCAMERAS)+1)/2
nn=8
nlots=[nn*3]*ncam#number of chunks to divide up into.
ncamThreads=numpy.ones((ncam,),numpy.int32)*nn
noPrePostThread=0
threadPriority=numpy.ones((ncamThreads.sum()+1,),numpy.int32)*40
#threadPriority=numpy.arange(ncamThreads.sum()+1)+40
threadPriority[0]=39
threadAffinity=1<<(numpy.arange(1+ncamThreads.sum()))
#threadAffinity=None
nsub=31
npxl=4
nact=nsub+1
nacts=tel.Pupil(nact,nact/2.,2).fn.astype("i").sum()
camPerGrab=numpy.ones((ncam,),"i")
#if NCAMERAS%2==1:
#    camPerGrab[-1]=1
npxly=numpy.zeros((ncam,),numpy.int32)
npxly[:]=128#nsub*npxl
npxlx=npxly.copy()
nsuby=npxly.copy()
nsuby[:]=nsub
nsubx=nsuby.copy()
nsubaps=(nsuby*nsubx).sum()
individualSubapFlag=tel.Pupil(nsub,nsub/2.,2.7,nsub).subflag.astype("i")#gives 1240 used subaps
subapFlag=numpy.zeros(((nsuby*nsubx).sum(),),"i")
for i in range(ncam):
    tmp=subapFlag[(nsuby[:i]*nsubx[:i]).sum():(nsuby[:i+1]*nsubx[:i+1]).sum()]
    tmp.shape=nsuby[i],nsubx[i]
Ejemplo n.º 21
0
nacts = 140  #97#54#+256
ncam = 1
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 480
npxlx = npxly.copy()
npxlx[:] = 640
nsuby = npxly.copy()
nsuby[:] = 11
#nsuby[4:]=16
nsubx = nsuby.copy()
nsub = nsubx * nsuby
nsubaps = (nsuby * nsubx).sum()
#subapFlag=numpy.ones((nsubaps,),"i")
subapFlag = tel.Pupil(
    11, 11 / 2., 1,
    11).subflag.astype("i").ravel()  #numpy.ones((nsubaps,),"i")

#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")
#camimg=(numpy.random.random((10,npxls))*20).astype(numpy.int16)

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField = None  #FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")
#indx=0
#nx=npxlx/nsubx
#ny=npxly/nsuby
Ejemplo n.º 22
0
    try:
        ncam = int(prefix)
    except:
        ncam = 4
print "Using %d cameras" % ncam
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 140  #488
npxlx = npxly.copy()
npxlx[:] = 140  #648
nsuby = npxlx.copy()
nsuby[:] = 15  #for config purposes only... not sent to rtc
nsubx = nsuby.copy()  #for config purposes - not sent to rtc
nsub = nsubx * nsuby  #This is used by rtc.
nsubaps = nsub.sum()  #(nsuby*nsubx).sum()
individualSubapFlag = tel.Pupil(15, 7.5, 1, 15).subflag.astype("i")
subapFlag = numpy.zeros((nsubaps, ), "i")
for i in range(ncam):
    tmp = subapFlag[nsub[:i].sum():nsub[:i + 1].sum()]
    tmp.shape = nsuby[i], nsubx[i]
    tmp[:] = individualSubapFlag
#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField = None  #FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")
Ejemplo n.º 23
0
import FITS
import tel
import numpy
import os
#Set up some basic parameters
nacts=5318#97#54#+256
ncam=1 # Number of WFSs
ncamThreads=numpy.ones((ncam,),numpy.int32)*2 #Number of threads to use
npxly=numpy.ones((ncam,),numpy.int32)*800#detector size
npxlx=npxly.copy()
nsuby=numpy.ones((ncam,),numpy.int32)*74#number of sub-apertures
nsubx=nsuby.copy()
nsub=nsuby*nsubx
nsubtot=nsub.sum()
subapFlag=numpy.array([tel.Pupil(74,40,7).fn.astype("i")]*ncam).ravel()

ncents=subapFlag.sum()*2#number of slope measurements (x and y)
npxls=(npxly*npxlx).sum()

#Calibration data
bgImage=numpy.random.normal(0,0.1,(npxlx*npxly).sum()).astype("f")#None#FITS.Read("shimgb1stripped_bg.fits")[1]
darkNoise=None#FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField=numpy.random.normal(1,0.1,(npxlx*npxly).sum()).astype("f")#FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

nsubaps=nsuby*nsubx#cumulative subap
nsubapsCum=numpy.zeros((ncam+1,),numpy.int32)
ncentsCum=numpy.zeros((ncam+1,),numpy.int32)
for i in range(ncam):
    nsubapsCum[i+1]=nsubapsCum[i]+nsubaps[i]
    ncentsCum[i+1]=ncentsCum[i]+subapFlag[nsubapsCum[i]:nsubapsCum[i+1]].sum()*2
Ejemplo n.º 24
0
npxly = numpy.zeros((ncam, ), numpy.int32)

npxly[:] = nsub * npxl  #square subaps
npxly[:] = nsub * ynpxl  #rectangular subaps
#npxly[:]=320 #manually set for 10G camera

npxlx = npxly.copy()  #square subaps
npxlx[:] = nsub * xnpxl  #rectangular subaps
#npxlx[:]=320 #manually set for 10G camera

nsuby = npxly.copy()
nsuby[:] = nsub
nsubx = nsuby.copy()
nsubaps = (nsuby * nsubx).sum()
individualSubapFlag = tel.Pupil(nsub, nsub / 2., 2.8 * nsub / 20.,
                                nsub).subflag.astype(
                                    "i")  #gives 1240 used subaps
subapFlag = numpy.zeros(((nsuby * nsubx).sum(), ), "i")
for i in range(ncam):
    tmp = subapFlag[(nsuby[:i] * nsubx[:i]).sum():(nsuby[:i + 1] *
                                                   nsubx[:i + 1]).sum()]
    tmp.shape = nsuby[i], nsubx[i]
    tmp[:] = individualSubapFlag
#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

nvSubaps = subapFlag.sum()  # number of valid subaps

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")
#camimg=(numpy.random.random((10,npxls))*20).astype(numpy.int16)
Ejemplo n.º 25
0
ncam += 1  #Add the EVT.
print "Using %d cameras" % ncam
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 488
npxly[-1] = 1088  #EVT
npxlx = npxly.copy()
npxlx[:] = 648
npxlx[-1] = 2048  #EVT
nsuby = npxlx.copy()
nsuby[:] = 31  #for config purposes only... not sent to rtc
nsuby[-1] = 62  #the EVT
nsubx = nsuby.copy()  #for config purposes - not sent to rtc
nsub = nsubx * nsuby  #This is used by rtc.
nsubaps = nsub.sum()  #(nsuby*nsubx).sum()
individualSubapFlag = tel.Pupil(31, 15.5, 2, 31).subflag.astype("i")
subapFlag = numpy.zeros((nsubaps, ), "i")
for i in range(ncam - 1):
    tmp = subapFlag[nsub[:i].sum():nsub[:i + 1].sum()]
    tmp.shape = nsuby[i], nsubx[i]
    tmp[:] = individualSubapFlag
#now the EVT
tmp = subapFlag[nsub[:-1].sum():nsub.sum()]
tmp.shape = nsuby[-1], nsubx[-1]
tmp[:31, :31] = individualSubapFlag
tmp[31:, :31] = individualSubapFlag
tmp[:31, 31:] = individualSubapFlag
tmp[31:, 31:] = individualSubapFlag
#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()
Ejemplo n.º 26
0
nacts = 54  #97#54#+256
ncam = 1
ncamSL240 = 0

print "Using %d cameras" % ncam
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 242  #121
npxlx = npxly.copy()
npxlx[:] = 264  #1056
nsuby = npxlx.copy()
nsuby[:] = 14  #for config purposes only... not sent to rtc
nsubx = nsuby.copy()  #for config purposes - not sent to rtc
nsub = nsubx * nsuby  #This is used by rtc.
nsubaps = nsub.sum()  #(nsuby*nsubx).sum()
individualSubapFlag = tel.Pupil(7, 3.5, 1).fn.astype("i")
subapFlag = numpy.zeros((nsubaps, ), "i")
for i in range(ncam):
    tmp = subapFlag[nsub[:i].sum():nsub[:i + 1].sum()]
    tmp.shape = nsuby[i], nsubx[i]
    for j in range(4):
        tmp[(j // 2) * 7:(j // 2) * 7 + 7,
            (j % 2) * 7:(j % 2) * 7 + 7] = individualSubapFlag
#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
Ejemplo n.º 27
0
ncamThreads[2:] = 1

npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 128
npxlx = npxly.copy()
npxlx[:] = 256
nsuby = npxly.copy()
nsuby[:2] = 15
nsuby[2:] = 7
#nsuby[4:]=16
nsubx = nsuby.copy()
nsubx[:2] = 30
nsubx[2:] = 14
nsub = nsubx * nsuby
nsubaps = (nsuby * nsubx).sum()
subapFlagNGS = tel.Pupil(7 * 16, 7 * 8, 8, 7).subflag.astype(
    "i")  #.ravel()#numpy.ones((nsubaps,),"i")
subapFlagLGS = tel.Pupil(15 * 8, 15 * 4, 8, 15).subflag.astype(
    "i")  #.ravel()#numpy.ones((nsubaps,),"i")
subapFlag = numpy.zeros((7 * 7 * 4 + 15 * 15 * 4, ), "i")
tmp = subapFlag[:15 * 30]
tmp.shape = 15, 30
tmp[:, ::2] = subapFlagLGS
tmp[:, 1::2] = subapFlagLGS
tmp = subapFlag[15 * 30:2 * 15 * 30]
tmp.shape = 15, 30
tmp[:, ::2] = subapFlagLGS
tmp[:, 1::2] = subapFlagLGS
tmp = subapFlag[2 * 15 * 30:2 * 15 * 30 + 7 * 14]
tmp.shape = 7, 14
tmp[:, ::2] = subapFlagNGS
tmp[:, 1::2] = subapFlagNGS
Ejemplo n.º 28
0
#along with this program.  If not, see <http://www.gnu.org/licenses/>.
import FITS
import tel
import numpy
import os
#Set up some basic parameters
nacts=52#97#54#+256
ncam=1 # Number of WFSs
ncamThreads=numpy.ones((ncam,),numpy.int32)*8 #Number of threads to use
npxly=numpy.ones((ncam,),numpy.int32)*128#detector size
npxlx=npxly.copy()
nsuby=numpy.ones((ncam,),numpy.int32)*7#number of sub-apertures
nsubx=nsuby.copy()
nsub=nsuby*nsubx
nsubtot=nsub.sum()
subapFlag=numpy.array([tel.Pupil(7*16,7*8,8,7).subflag.astype("i")]*ncam).ravel()#Generate an map of used sub-apertures

ncents=subapFlag.sum()*2#number of slope measurements (x and y)
npxls=(npxly*npxlx).sum()

#Calibration data
bgImage=None#numpy.ones(128*128*ncam)*12#None#FITS.Read("shimgb1stripped_bg.fits")[1]
darkNoise=None#FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField=None#FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

nsubaps=nsuby*nsubx#cumulative subap
nsubapsCum=numpy.zeros((ncam+1,),numpy.int32)
ncentsCum=numpy.zeros((ncam+1,),numpy.int32)
for i in range(ncam):
    nsubapsCum[i+1]=nsubapsCum[i]+nsubaps[i]
    ncentsCum[i+1]=ncentsCum[i]+subapFlag[nsubapsCum[i]:nsubapsCum[i+1]].sum()*2
Ejemplo n.º 29
0
nacts = 54  #97#54#+256
ncam = (int(NCAMERAS) + 1) / 2
camPerGrab = numpy.ones((ncam, ), "i") * 2
if NCAMERAS % 2 == 1:
    camPerGrab[-1] = 1
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 1
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 128
npxlx = npxly.copy() * camPerGrab
nsuby = npxlx.copy()
nsuby[:] = 7  #for config purposes only... not sent to rtc
nsubx = nsuby.copy() * camPerGrab  #for config purposes - not sent to rtc
nsub = nsubx * nsuby  #This is used by rtc.
nsubaps = nsub.sum()  #(nsuby*nsubx).sum()
individualSubapFlag = tel.Pupil(7, 3.5, 1, 7).subflag.astype("i")
subapFlag = numpy.zeros((nsubaps, ), "i")
for i in range(ncam):
    tmp = subapFlag[nsub[:i].sum():nsub[:i + 1].sum()]
    tmp.shape = nsuby[i], nsubx[i]
    for j in range(camPerGrab[i]):
        tmp[:, j::camPerGrab[i]] = individualSubapFlag
#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")
#camimg=(numpy.random.random((10,npxls))*20).astype(numpy.int16)

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
Ejemplo n.º 30
0
nacts = 54  #97#54#+256
ncam = 1
ncamThreads = numpy.ones((ncam, ), numpy.int32) * 2
npxly = numpy.zeros((ncam, ), numpy.int32)
npxly[:] = 144  #300#480
npxlx = npxly.copy()
npxlx[:] = 144  #400#640
nsuby = npxly.copy()
nsuby[:] = 12  #15
#nsuby[4:]=16
nsubx = nsuby.copy()
nsub = nsubx * nsuby
nsubaps = (nsuby * nsubx).sum()
#subapFlag=tel.Pupil(15*16,15*8,8,15).subflag.astype("i").ravel()#numpy.ones((nsubaps,),"i")
subapFlag = tel.Pupil(
    12 * 12, 12 * 6, 6,
    12).subflag.astype("i").ravel()  #numpy.ones((nsubaps,),"i")

#ncents=nsubaps*2
ncents = subapFlag.sum() * 2
npxls = (npxly * npxlx).sum()

fakeCCDImage = None  #(numpy.random.random((npxls,))*20).astype("i")
#camimg=(numpy.random.random((10,npxls))*20).astype(numpy.int16)

bgImage = None  #FITS.Read("shimgb1stripped_bg.fits")[1].astype("f")#numpy.zeros((npxls,),"f")
darkNoise = None  #FITS.Read("shimgb1stripped_dm.fits")[1].astype("f")
flatField = None  #FITS.Read("shimgb1stripped_ff.fits")[1].astype("f")

subapLocation = numpy.zeros((nsubaps, 6), "i")
nsubaps = nsuby * nsubx  #cumulative subap