Esempio n. 1
0
def process(job):

    job_id, (file, field_pos, rotation_rule) = job

    rotation_rule = rotation_rule[0] # remove enclosing list

    arrays = arrays_base.copy()  # make copy of array so following manipulations do not persist

    # rotate arrays based on rotation rule
    for array_id, dir, angle in rotation_rule:
        for array in arrays:
            if array['id'] == array_id:
                abstract.rotate_array(array, dir, np.deg2rad(angle))

    # create and run simulation

    kwargs, meta = Solver.connector(simulation, *arrays)
    solver = Solver(**kwargs)
    solver.solve(field_pos)

    # extract results and save
    rf_data = solver.result['rf_data']
    p = np.max(util.envelope(rf_data, axis=1), axis=1)
    angle = rotation_rule[0][2]

    with write_lock:
        with closing(sql.connect(file)) as con:
            update_image_table(con, angle, field_pos, p)
            util.update_progress(con, job_id)
Esempio n. 2
0
def process(args):

    file, field_pos, rotation_rule, sim, arrays = args

    sim = abstract.loads(sim)
    arrays = abstract.loads(arrays)

    # set focus delays while arrays are flat
    tx_focus = sim['transmit_focus']
    rx_focus = sim['receive_focus']
    c = sim['sound_speed']
    quant = sim['delay_quantization']

    for array in arrays:
        abstract.focus_array(array,
                             tx_focus,
                             sound_speed=c,
                             quantization=quant,
                             kind='tx')
        abstract.focus_array(array,
                             rx_focus,
                             sound_speed=c,
                             quantization=quant,
                             kind='rx')

    # rotate arrays based on rotation rule
    for array_id, dir, angle in rotation_rule:

        if dir.lower() == 'x':
            vec = [1, 0, 0]
        elif dir.lower() == 'y':
            vec = [0, 1, 0]
        elif dir.lower() == 'z':
            vec = [0, 0, 1]

        for array in arrays:
            if array['id'] == array_id:
                abstract.rotate_array(array, vec, np.deg2rad(angle))

    # create and run simulation
    kwargs, meta = MultiArrayTransmitReceiveBeamplot.connector(sim, *arrays)
    simulation = MultiArrayTransmitReceiveBeamplot(**kwargs)
    simulation.solve(field_pos)

    # extract results and save
    rf_data = simulation.result['rf_data']
    times = simulation.result['times']

    with write_lock:
        with closing(sql.connect(file)) as con:

            if sim['save_image_data_only']:
                pass
            else:
                for rf, t in zip(rf_data, times):
                    update_pressures_table(con, field_pos, t, rf)
            update_progress(con, field_pos)
Esempio n. 3
0
def process(job):

    job_id, (file, field_pos, rotation_rule) = job

    rotation_rule = rotation_rule[0]  # remove enclosing list
    arrays = arrays_base.copy()
    simulation = simulation_base.copy()

    # rotate arrays based on rotation rule
    for array_id, dir, angle in rotation_rule:
        for array in arrays:
            if array['id'] == array_id:
                abstract.rotate_array(array, dir, np.deg2rad(angle))

    # set focus delays while array is in rotated state
    focus = simulation['focus']
    if focus is not None:
        c = simulation['sound_speed']
        delay_quant = simulation['delay_quantization']
        for array in arrays:
            abstract.focus_array(array, focus, c, delay_quant, kind='both')

    arrays_plus = arrays.copy()
    arrays_minus = arrays.copy()

    # rotate arrays again based on plus and minus tolerance
    angle_tol = simulation['angle_tolerance']
    for array_id, dir, _ in rotation_rule:
        for array in arrays_plus:
            if array['id'] == array_id:
                abstract.rotate_array(array, dir, np.deg2rad(angle_tol))

        for array in arrays_minus:
            if array['id'] == array_id:
                abstract.rotate_array(array, dir, np.deg2rad(-angle_tol))

    # create and run simulation
    kwargs, meta = Solver.connector(simulation, *arrays_plus)
    solver_plus = Solver(**kwargs)
    solver_plus.solve(field_pos)

    # create and run simulation
    kwargs, meta = Solver.connector(simulation, *arrays_minus)
    solver_minus = Solver(**kwargs)
    solver_minus.solve(field_pos)

    # extract results and save
    angle = rotation_rule[0][2]

    with write_lock:
        with closing(sql.connect(file)) as con:

            rf_data = solver_plus.result['rf_data']
            b = np.max(util.envelope(rf_data, axis=1), axis=1)
            update_image_table(con, angle, angle_tol, 'plus', field_pos, b)

            rf_data = solver_minus.result['rf_data']
            b = np.max(util.envelope(rf_data, axis=1), axis=1)
            update_image_table(con, angle, angle_tol, 'minus', field_pos, b)

            util.update_progress(con, job_id)