コード例 #1
0
    def fire_gaus_optimize(self, ):
        xs, ys = self.fire_shift_optimize()
        if self.costs.min() < 0.1:
            min_val = [4, 4, -15, xs - 2, ys - 2]
            max_val = [40, 40, 15, xs + 2, ys + 2]
            self.bounds = [4, 40], [4, 40], [-15,
                                             15], [xs - 2,
                                                   xs + 2], [ys - 2, ys + 2]

            ps, distributions = create_training_set(self.parameters,
                                                    min_val,
                                                    max_val,
                                                    n_train=50)
            print('Start solving...')
            self.gaus_solved = parmap(self.gaus_optimize, ps, nprocs=5)
            result = np.array(
                [np.hstack((i[0], i[1])) for i in self.gaus_solved])
            print(
                'solved psf',
                dict(
                    zip(self.parameters + [
                        'cost',
                    ], result[np.argmin(result[:, -1])])))
            return result[np.argmin(result[:, -1]), :]
        else:
            print('Cost is too large, plese check!')
            return []
コード例 #2
0
    def fire_shift_optimize(self, ):
        #self.S2_PSF_optimization()
        self._preprocess()
        if self.lh_mask.sum() == 0:
            self.costs = np.array([
                100000000000.,
            ])
            return 0, 0
        min_val = [-50, -50]
        max_val = [50, 50]
        ps, distributions = create_training_set(['xs', 'ys'],
                                                min_val,
                                                max_val,
                                                n_train=50)
        self.shift_solved = parmap(self.shift_optimize, ps)
        self.paras, self.costs = np.array([i[0] for i in self.shift_solved]), \
                                           np.array([i[1] for i in self.shift_solved])

        if (1 - self.costs.min()) >= 0.6:
            xs, ys = self.paras[self.costs == np.nanmin(self.costs)][0].astype(
                int)
        else:
            xs, ys = 0, 0
        #print 'Best shift is ', xs, ys, 'with the correlation of', 1-self.costs.min()
        return xs, ys