コード例 #1
0
 def testIsLoadable(self):
     buffer = BytesIO()
     verbose.VerboseFFR._CrossKernelReconstructor(
         engine._LinearKernelSolver([[0.1, 0], [0, 10]]),
         [[1, 30], [2, 20], [3, 10]]).save(buffer)
     buffer.seek(0)
     reconstructor = verbose.VerboseFFR._CrossKernelReconstructor.load(
         buffer)
     self.checkArrayLikeAlmostEqual([23, 42, 61], reconstructor([2, 1]))
コード例 #2
0
def cross_kernel_estimation(loadable_reconstructor,
                            measurement_manager_basis,
                            potential,
                            regularization_parameter=0):
    kernel = loadable_reconstructor.kernel
    cross_kernel = loadable_reconstructor.get_kernel_matrix(
        measurement_manager_basis)
    cross_reconstructor = _CrossKernelReconstructor(
        _LinearKernelSolver(kernel), cross_kernel)
    est_csd = cross_reconstructor(potential, regularization_parameter)
    return est_csd
コード例 #3
0
 def createSolver(self, kernel):
     buffer = BytesIO()
     _LinearKernelSolver(np.array(kernel)).save(buffer)
     buffer.seek(0)
     with np.load(buffer) as fh:
         return _LinearKernelSolver.load_from_npzfile(fh)
コード例 #4
0
 def createSolver(self, kernel):
     buffer = BytesIO()
     _LinearKernelSolver(np.array(kernel)).save(buffer)
     buffer.seek(0)
     return _LinearKernelSolver.load(buffer)
コード例 #5
0
 def createSolver(self, kernel):
     return _LinearKernelSolver(np.array(kernel))
コード例 #6
0
 def setUp(self):
     if hasattr(self, 'KERNEL'):
         self.solver = _LinearKernelSolver(np.array(self.KERNEL))
     else:
         self.skipTest('test in abstract class called')
コード例 #7
0
reconstructor_filename = '../SavedReconstructor_four_spheres_1000_deg_1.npz'
#reconstructor = VerboseFFR(sources, measurement_manager)
#reconstructor.save(reconstructor_filename)
#print("Reconstructor --- %s seconds ---" % (time.time() - start_time))

factoryCSD = SomeSphereGaussianSourceFactoryOnlyCSD(MESHFILE)
dst = factoryCSD.R[1] - factoryCSD.R[0]
sourcesCSD = [factoryCSD(r, altitude, azimuth)
              for altitude, azimuth in altitude_azimuth_mesh(-np.pi/2,
                                                          dst/factory.scalp_radius)
              for r in factoryCSD.R]
# Load saved reconstructor
loadable_reconstructor = LoadableVerboseFFR(reconstructor_filename, sourcesCSD, measurement_manager)
kernel = loadable_reconstructor.kernel
cross_kernel = loadable_reconstructor.get_kernel_matrix(measurement_manager_basis)
cross_reconstructor = _CrossKernelReconstructor(_LinearKernelSolver(kernel), cross_kernel)

potential = [measurement_manager.probe(source) for source in sources]
filename = 'four_spheres_1000_deg_1_rp_cv.npz'



rps = np.logspace(-1, -15, 7, base=10.)

error_time = time.time()
if PARALLEL_AVAILABLE:
    source_scanning_error, true_csd, est_csd, error, rp = source_scanning_parallel(potential, sourcesCSD, cross_reconstructor, measurement_manager, measurement_manager_basis, regularization_parameter=rps, filename=filename)
else:
    source_scanning_error = source_scanning(sources, reconstructor, measurement_manager,
                                            measurement_manager_basis, EST_X, EST_Y, EST_Z,
                                            filename=filename)