def __init__(self): """Construct a sensor wavefront data object.""" super().__init__() self.sensorId = 999 self.listOfDonut = [] self.masterDonut = DonutImage(0, 0, 0, 0, 0) self.effWfErr = np.zeros(self.NUM_OF_ZER)
def _genMasterImgOnSglCcd(self, donutList, zcCol): """Generate the master donut image on single CCD. CCD: Charge-coupled device. Parameters ---------- sensorName : str Canonical sensor name (e.g. "R:2,2 S:1,1"). donutList : list List of donut object (type: DonutImage). zcCol : numpy.ndarray Coefficients of wavefront (z1-z22) in nm. Returns ------- DonutImage Master donut. """ intraProjImgList = [] extraProjImgList = [] for donut in donutList: # Get the field x, y fieldXY = donut.getFieldPos() # Set the image intraImg = donut.getIntraImg() if intraImg is not None: # Get the projected image projImg = self._getProjImg(fieldXY, DefocalType.Intra, intraImg, zcCol) # Collect the projected donut intraProjImgList.append(projImg) extraImg = donut.getExtraImg() if extraImg is not None: # Get the projected image projImg = self._getProjImg(fieldXY, DefocalType.Extra, extraImg, zcCol) # Collect the projected donut extraProjImgList.append(projImg) # Generate the master donut stackIntraImg = self._stackImg(intraProjImgList) stackExtraImg = self._stackImg(extraProjImgList) # Put the master donut to donut map pixelX, pixelY = searchDonutPos(stackIntraImg) masterDonut = DonutImage( 0, pixelX, pixelY, 0, 0, intraImg=stackIntraImg, extraImg=stackExtraImg ) return masterDonut
def setUp(self): self.starId = 0 self.pixelX = 1 self.pixelY = 2 self.fieldX = 3 self.fieldY = 4 self.donutImg = DonutImage(self.starId, self.pixelX, self.pixelY, self.fieldX, self.fieldY)
def _getDonut(self): starId = 1 pixelX = 2.0 pixelY = 3.0 fieldX = 1.5 fieldY = 1.6 donut = DonutImage(starId, pixelX, pixelY, fieldX, fieldY) return donut
def __init__(self, numOfZk=19): """Construct a sensor wavefront data object. Parameters ---------- numOfZk : int, optional Number of annular Zernike polynomials. (the default is 19.) """ super(SensorWavefrontData, self).__init__(numOfZk=numOfZk) self.listOfDonut = [] self.masterDonut = DonutImage(0, 0, 0, 0, 0)
def getDonutMap(self, neighborStarMap, wfsImgMap, filterType, doDeblending=False): """Get the donut map on each wavefront sensor (WFS). Parameters ---------- neighborStarMap : dict Information of neighboring stars and candidate stars with the name of sensor as a dictionary. wfsImgMap : dict Post-ISR image map. The dictionary key is the sensor name. The dictionary item is the defocal image on the camera coordinate. (type: DefocalImage). filterType : FilterType Filter type. doDeblending : bool, optional Do the deblending or not. If False, only consider the single donut based on the bright star catalog.(the default is False.) Returns ------- dict Donut image map. The dictionary key is the sensor name. The dictionary item is the list of donut image (type: list[DonutImage]). """ donutMap = dict() for sensorName, nbrStar in neighborStarMap.items(): # Configure the source processor self.sourProc.config(sensorName=sensorName) # Get the defocal images: [intra, extra] defocalImgList = [ wfsImgMap[sensorName].getIntraImg(), wfsImgMap[sensorName].getExtraImg(), ] # Get the bright star id list on specific sensor brightStarIdList = list(nbrStar.getId()) for starIdIdx in range(len(brightStarIdList)): # Get the single star map for jj in range(len(defocalImgList)): ccdImg = defocalImgList[jj] # Get the segment of image if ccdImg is not None: ( singleSciNeiImg, allStarPosX, allStarPosY, magRatio, offsetX, offsetY, ) = self.sourProc.getSingleTargetImage( ccdImg, nbrStar, starIdIdx, filterType ) # Only consider the single donut if no deblending if (not doDeblending) and (len(magRatio) != 1): continue # Get the single donut/ deblended image if (len(magRatio) == 1) or (not doDeblending): imgDeblend = singleSciNeiImg if len(magRatio) == 1: realcx, realcy = searchDonutPos(imgDeblend) else: realcx = allStarPosX[-1] realcy = allStarPosY[-1] # Do the deblending or not elif len(magRatio) == 2 and doDeblending: imgDeblend, realcx, realcy = self.sourProc.doDeblending( singleSciNeiImg, allStarPosX, allStarPosY, magRatio ) # Update the magnitude ratio magRatio = [1] else: continue # Extract the image if len(magRatio) == 1: sizeInPix = self.wfEsti.getSizeInPix() x0 = np.floor(realcx - sizeInPix / 2).astype("int") y0 = np.floor(realcy - sizeInPix / 2).astype("int") imgDeblend = imgDeblend[ y0 : y0 + sizeInPix, x0 : x0 + sizeInPix ] # Rotate the image if the sensor is the corner # wavefront sensor if sensorName in self.CORNER_WFS_LIST: # Get the Euler angle eulerZangle = round( self.sourProc.getEulerZinDeg(sensorName) ) # Change the sign if the angle < 0 while eulerZangle < 0: eulerZangle += 360 # Do the rotation of matrix numOfRot90 = eulerZangle // 90 imgDeblend = np.flipud( np.rot90(np.flipud(imgDeblend), numOfRot90) ) # Put the deblended image into the donut map if sensorName not in donutMap.keys(): donutMap[sensorName] = [] # Check the donut exists in the list or not starId = brightStarIdList[starIdIdx] donutIndex = self._searchDonutListId( donutMap[sensorName], starId ) # Create the donut object and put into the list if it # is needed if donutIndex < 0: # Calculate the field X, Y pixelX = realcx + offsetX pixelY = realcy + offsetY fieldX, fieldY = self.sourProc.camXYtoFieldXY( pixelX, pixelY ) # Instantiate the DonutImage class donutImg = DonutImage( starId, pixelX, pixelY, fieldX, fieldY ) donutMap[sensorName].append(donutImg) # Search for the donut index again donutIndex = self._searchDonutListId( donutMap[sensorName], starId ) # Get the donut image list donutList = donutMap[sensorName] # Take the absolute value for images, which might # contain the negative value after the ISR correction. # This happens for the amplifier images. imgDeblend = np.abs(imgDeblend) # Set the intra focal image if jj == 0: donutList[donutIndex].setImg(intraImg=imgDeblend) # Set the extra focal image elif jj == 1: donutList[donutIndex].setImg(extraImg=imgDeblend) return donutMap