Ejemplo n.º 1
0
    def createCube_forTestDataInOpdImages(self):
        tt = '20191210_143625'
        fold = os.path.join(Configuration.OPD_DATA_FOLDER,
                            'OPDImages', tt, 'hdf5')

        hduList = pyfits.open(os.path.join(fold, 'ampVect.fits'))
        self._cmdAmplitude = hduList[0].data
        hduList = pyfits.open(os.path.join(fold, 'modeRange.fits'))
        self._actsVector = hduList[0].data
        hduList = pyfits.open(os.path.join(fold, 'template.fits'))
        vector_of_push_pull = hduList[0].data

        cube = None
        tip_til_det = TipTiltDetrend()
        r = ROI()
#         for i in range(self._actsVector.shape[0]):
        for i in range(7):
            k = i * vector_of_push_pull.shape[0]
            imaList = []
            for j in range(vector_of_push_pull.shape[0]):
                l = k + j
                file_name = os.path.join(fold, 'img_%04d.h5') %l
                img = self._ic.from4D(file_name)
                roi = r.roiGenerator(img)
                ima_tt = tip_til_det.tipTiltRemover(img, roi, 3)
                imaList.append(ima_tt)

            image = imaList[0] + imaList[1] - imaList[2]

            if cube is None:
                cube = image
            else:
                cube = np.ma.dstack((cube, image))

        return cube
Ejemplo n.º 2
0
    def createCubeFromImageFolder(self, data_file_path, tiptilt_detrend=None, phase_ambiguity=None):
        cube_all_act = None
        where = self._indexReorganization()
        ampl_reorg = self._amplitudeReorganization(self._actsVector,
                                                   self._indexingList,
                                                   self._cmdAmplitude,
                                                   self._nPushPull)
        for i in range(self._actsVector.shape[0]):
            for k in range(self._nPushPull):
                p = self._nPushPull * i + k
                n = where[p][0][0]
                mis_amp = k* self._indexingList.shape[1] + n
                mis = k * self._indexingList.shape[1] * self._template.shape[0] \
                        + n * self._template.shape[0]

                name = 'img_%04d.h5' %mis
                file_name = os.path.join(data_file_path, name)
                image_for_dim = self._ic.from4D(file_name)

                image_sum = np.zeros((image_for_dim.shape[0],
                                     image_for_dim.shape[1]))
                for l in range(1, self._template.shape[0]):
                    name = 'img_%04d.h5' %(mis+l)
                    file_name = os.path.join(data_file_path, name)
                    ima = self._ic.from4D(file_name)
                    image = image_sum + ima * self._template[l]
                img_if = image / (2 * ampl_reorg[mis_amp] * (self._template.shape[0] - 1))
                if tiptilt_detrend is None:
                    img_if = img_if
                else:
                    r = ROI()
                    roi = r.roiGenerator(img_if)
                    tt = TipTiltDetrend()
                    img_if = tt.tipTiltRemover(img_if, roi, 3)

                if_push_pull_kth = img_if-np.ma.median(img_if)

                if k == 0:
                    all_push_pull_act_jth = if_push_pull_kth
                else:
                    all_push_pull_act_jth = np.ma.dstack((all_push_pull_act_jth,
                                                          if_push_pull_kth))

            if self._nPushPull == 1:
                if_act_jth = all_push_pull_act_jth
            else:
                if_act_jth = np.ma.mean(all_push_pull_act_jth, axis=2)

            if cube_all_act is None:
                cube_all_act = if_act_jth
            else:
                cube_all_act = np.ma.dstack((cube_all_act, if_act_jth))
        self._cube = cube_all_act

        return self._cube
Ejemplo n.º 3
0
    def createCube(self, tiptilt_detrend=None, phase_ambiguity=None):
        '''
            Args:
                ttDetrend = in the creation of the cube the images are reduced
                            removing tip tilt on the central segment

                phaseSolve=

            Returns:
                self._cube = cube
        '''
        cube_all_act = None
        self._ttData()
        self._logCubeCreation(tiptilt_detrend, phase_ambiguity)   #modRB here add the Zernike removal or best decide how to manage the Zernike shapes, if to remove them in flattening only
        where = self._indexReorganization()                       #modRB here add the image immersion in the full frame
        #misure_pos, misure_neg = self._splitMeasureFromFits(self._cubeMeasure)
        ampl_reorg = self._amplitudeReorganization(self._actsVector,
                                                   self._indexingList,
                                                   self._cmdAmplitude,
                                                   self._nPushPull)


        for i in range(self._actsVector.shape[0]):
            for k in range(self._nPushPull):
                p = self._nPushPull * i + k
                n = where[p][0][0]
                mis_amp = k* self._indexingList.shape[1] + n
                mis = k * self._indexingList.shape[1] * self._template.shape[0] \
                        + n * self._template.shape[0]

                #img_pos = misure_pos[:,:,mis]
                #img_neg = misure_neg[:,:,mis]
                image_sum = np.zeros((self._cubeMeasure.shape[0],
                                     self._cubeMeasure.shape[1]))
                for l in range(1, self._template.shape[0]):
                    image = image_sum + self._cubeMeasure[:,:, mis+l] * self._template[l]
                img_if = image / (2 * ampl_reorg[mis_amp] * (self._template.shape[0] - 1))
                if tiptilt_detrend is None:
                    img_if = img_if
                else:
                    r = ROI()
                    roi = r.roiGenerator(img_if)
                    tt = TipTiltDetrend()
                    img_if = tt.tipTiltRemover(img_if, roi, 3)

                if_push_pull_kth = img_if-np.ma.median(img_if)

                if k == 0:
                    all_push_pull_act_jth = if_push_pull_kth
                else:
                    all_push_pull_act_jth = np.ma.dstack((all_push_pull_act_jth,
                                                          if_push_pull_kth))

            if self._nPushPull == 1:
                if_act_jth = all_push_pull_act_jth
            else:
                if_act_jth = np.ma.mean(all_push_pull_act_jth, axis=2)

            if cube_all_act is None:
                cube_all_act = if_act_jth
            else:
                cube_all_act = np.ma.dstack((cube_all_act, if_act_jth))
        self._cube = cube_all_act

        return self._cube