def remakedonut(self):
        """Remake make_donut

        Notes
        -----
        No input or return.

        """
        self.make_donut = makedonut(**self.makedonut_dict)
        return
 def __init__(self, **kwargs):
     y_keys = ['stamp']
     x_keys = ['x', 'y', 'rzero',
               'z1', 'z2', 'z3',
               'z4', 'z5', 'z6',
               'z7', 'z8',
               'z9', 'z10',
               'z11']
     super(Zernike_to_Pixel_Interpolator, self).__init__(
             y_keys=y_keys, x_keys=x_keys, **kwargs)
     # set up makedonut
     self.makedonut_dict = {'nbin': 256,
                            'nPixels': 32,
                            'pixelOverSample': 8,
                            'scaleFactor': 1,
                            'randomFlag': 0}
     for kwarg in kwargs:
         if kwarg in self.makedonut_dict:
             self.makedonut_dict[kwarg] = kwargs[kwarg]
     self.make_donut = makedonut(**self.makedonut_dict)
示例#3
0
    'nbin': 512,
    'nPixels': 64,
    'pixelOverSample': 8,
    'scaleFactor': 1.,
    'rzero': 0.125,
    'nEle': 1.0e6,
    'background': 4000.,
    'randomFlag': True,
    'randomSeed': 2314809,
    'ZernikeArray': zarray,
    'gain': 4.5,
    'xDECam': xdecam,
    'yDECam': ydecam
}

m = makedonut(**inputDict)
donut1 = m.make()

## fit them

fitinitDict = {
    "nZernikeTerms":
    37,
    "fixedParamArray1": [
        0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
    ],
    "fixedParamArray2": [
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1,
        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
    ],
示例#4
0
def makeTheDonuts(donut1Name, donut2Name, z4, z5, z6, z7, z8, z9, z10, z11,
                  z12, z13, z14, z15, z16, z17, z18, z19, z20, z21, z22, iNr):

    # Define Zernike coefficients of the donuts.
    # The first 3 terms are set to 0.
    z1 = 0.0
    z2 = 0.0
    z3 = 0.0

    # In order to create defocussed images, we add 40 micrometer to z4 for donut image 1 and
    # subtract 40 micrometer for donut image 2.
    #z4 = z4 + 40.

    # Define the background.
    bkgr = 0.0

    # Define the x,y position of the camera.
    xCam = 0.00
    yCam = 0.00

    # Set the random number used in the simulation
    # rndSeed = 2314809
    rndSeed = np.random.randint(1, np.iinfo(np.int32).max)

    # Create the input dictionary for donut production (donut 1
    inputDict = {'writeToFits':True,'outputPrefix':donut1Name,'iTelescope':3,'nZernikeTerms':37,\
                 'nbin':1792,'nPixels':224,'pixelOverSample':8,'scaleFactor':1.,'rzero':0.125,\
                 'nEle':1.0e8, 'background':bkgr, 'randomFlag':False, 'randomSeed':rndSeed,\
                 'ZernikeArray':[z1,z2,z3,z4,z5,z6,z7,z8,z9,z10,z11,z12,z13,z14,z15,z16,z17,z18,z19,z20,z21,z22],\
                 'xDECam':xCam,'yDECam':yCam,'printLevel':5}
    #,'xDECam':xCam,'yDECam':yCam}

    # Create the image of donut 1
    m = makedonut(**inputDict)
    donut1 = m.make()

    # Update the disctionary for donut 2 and create the image of donut 2.
    # Note: we also change the value of z4 by -80 micrometer to reflect that we want to look at the second
    # out-of-focus sensor.  The out-of-focus sensors are assumed to be defocussed by +40 micrometer and
    # -40 micrometer.  We added 40 micrometer to z4 when we generated donut 1; we now have to subtract
    # 80 micrometer in order to create donut 2.
    #z4 = z4 - 80.
    newDict = {'outputPrefix':donut2Name,\
               'ZernikeArray':[z1,z2,z3,z4,z5,z6,z7,z8,z9,z10,z11,z12,z13,z14,z15,z16,z17,z18,z19,z20,z21,z22]}
    donut2 = m.make(**newDict)

    # Print current file names.
    print donut1Name
    print donut2Name

    # Done making donuts.

    # We now create the images we need for learning:
    # donut 1
    # donut 2
    # donut difference = donut 1 - donut 2
    # These images are written in png and hdf5 format.
    # Open the data files.
    #hdu1 = pyfits.open(donut1Name+'.stamp.fits')
    #hdu2 = pyfits.open(donut2Name+'.stamp.fits')

    # Get the image data.
    #donut1Data = hdu1[0].data
    #donut2Data = hdu2[0].data

    # Calculate the difference between donut 1 and donut 2
    #donutDiffData = donut1Data - donut2Data

    # Calculate the name of the image file for the donut difference.
    #diffName = donut1Name[0:22]+'12'+donut1Name[24:]

    # Write images in png format.
    #imageio.imwrite(donut1Name+'.png', donut1Data)
    #imageio.imwrite(donut2Name+'.png', donut2Data)
    #imageio.imwrite(diffName+'.png', donutDiffData)

    # Write image in hdf5 format.
    #h5f = h5py.File(donut1Name+'.h5', 'w')
    #h5f.create_dataset('Donut 1', data=donut1Data)
    #h5f.close()

    #h5f = h5py.File(donut2Name+'.h5', 'w')
    #h5f.create_dataset('Donut 2', data=donut2Data)
    #h5f.close()

    #h5f = h5py.File(diffName+'.h5', 'w')
    #h5f.create_dataset('Donut 1 - Donut 2', data=donutDiffData)
    #h5f.close()

    return
示例#5
0
from donutlib.makedonut import makedonut
from donutlib.donutfit import donutfit


# make donuts
z4 = 10.
z5 = 0.2
z6 = 0.2
z7 = -0.15
z8 = .05
z9 = 0.3
z10 = -.05
z11 = .2
inputDict = {'writeToFits':True,'outputPrefix':'unittest.0001','iTelescope':0,'nZernikeTerms':37,'nbin':512,'nPixels':64,'pixelOverSample':8,'scaleFactor':1.,'rzero':0.125, 'nEle':1.0e6, 'background':4000., 'randomFlag':True, 'randomSeed':2314809, 'ZernikeArray':[0.,0.,0.,z4,z5,z6,z7,z8,z9,z10,z11]}

m = makedonut(**inputDict)
donut1 = m.make()

z4 = 10.5
z9 = -0.05
z10 = 0.3
newDict = {'outputPrefix':'unittest.0002','ZernikeArray':[0.,0.,0.,z4,z5,z6,z7,z8,z9,z10,z11]}
donut2 = m.make(**newDict)

## fit them
fitinitDict = {"nZernikeTerms":15,"fixedParamArray1":[0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1],"fixedParamArray2":[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0],"nFits":2,"nPixels":64,"nbin":512,"scaleFactor":1.0,"pixelOverSample":8,"iTelescope":0,"inputrzero":0.15,"debugFlag":False}
df = donutfit(**fitinitDict)

# fit first donut
fitDict  = {}
fitDict["inputFile"] = 'unittest.0001.stamp.fits'