Пример #1
0
        # configure with random scatterers
        data = np.empty((num_scatterers, 4), dtype="float32")
        data[:, 0] = np.random.uniform(low=args.x0,
                                       high=args.x1,
                                       size=(num_scatterers, ))
        data[:, 1] = np.random.uniform(low=args.x0,
                                       high=args.x1,
                                       size=(num_scatterers, ))
        data[:, 2] = np.random.uniform(low=0.0,
                                       high=args.line_length + 1e-2,
                                       size=(num_scatterers, ))
        data[:, 3] = np.random.uniform(low=-1.0,
                                       high=1.0,
                                       size=(num_scatterers, ))
        sim.clear_fixed_scatterers()
        sim.add_fixed_scatterers(data)

        # do the simulation
        start_time = time()
        iq_lines = sim.simulate_lines()
        end_time = time()
        elapsed_time = end_time - start_time
        print "Simulation took %f sec @ %d scatterers." % (elapsed_time,
                                                           num_scatterers)

        # store time per IQ-line
        sim_times.append(elapsed_time / args.num_lines)
        sim_nums.append(num_scatterers)

        plt.clf()
plt.plot(t, envelope, 'g--', t, excitation)
plt.title('Excitation', fontsize=16, y=-.15)
plt.gca().set_facecolor('white')
plt.xticks([])
plt.yticks([])

# Record range of scatterer data

x_range = scatterers[:, 0].min(), scatterers[:, 0].max()
y_range = scatterers[:, 1].min(), scatterers[:, 1].max()
z_range = scatterers[:, 2].min(), scatterers[:, 2].max()
a_range = scatterers[:, 3].min(), scatterers[:, 3].max()

# Set scatterers

sim.clear_fixed_scatterers()  # Make this cell idempotent

data = scatterers

sim.add_fixed_scatterers(data)

# Set the beam profile

sigma_lateral = 1e-3
sigma_elevational = 1e-3
sim.set_analytical_beam_profile(sigma_lateral, sigma_elevational)

# Simulate all scanlines

decimation = 1
sim.set_parameter('radial_decimation', str(decimation))
Пример #3
0
 
 plt.figure()
 plt.ion()
 plt.show()
 
 sim_times = []
 sim_nums  = []
 for num_scatterers in all_nums:
     
     # configure with random scatterers
     data = np.empty((num_scatterers, 4), dtype="float32")
     data[:, 0] = np.random.uniform(low=args.x0, high=args.x1, size=(num_scatterers,))
     data[:, 1] = np.random.uniform(low=args.x0, high=args.x1, size=(num_scatterers,))
     data[:, 2] = np.random.uniform(low=0.0, high=args.line_length+1e-2, size=(num_scatterers,))
     data[:, 3] = np.random.uniform(low=-1.0, high=1.0, size=(num_scatterers,))
     sim.clear_fixed_scatterers()
     sim.add_fixed_scatterers(data)
     
     # do the simulation
     start_time = time()
     iq_lines = sim.simulate_lines()
     end_time = time()
     elapsed_time = end_time-start_time
     print "Simulation took %f sec @ %d scatterers." % (elapsed_time, num_scatterers)
     
     # store time per IQ-line
     sim_times.append(elapsed_time/args.num_lines)
     sim_nums.append(num_scatterers)
     
     plt.clf()
     plt.plot(sim_nums, sim_times)