Exemple #1
0
def rectilinear(parent=None,
                element_count_x=16,
                element_count_y=16,
                element_pitch_x=7e-3,
                element_pitch_y=7e-3):
    '''
    ---------------------------------------------
    rectilinear(parent,element_count_x,element_count_y,element_pitch_x, element_pitch_y)
    ---------------------------------------------
        
    DESCRIPTION HERE

    Parameters
    ----------

    parent : handybeam world
            DESCRIPTION HERE
    element_count_x : int
            DESCRIPTION HERE
    element_count_y : int
            DESCRIPTION HERE
    element_pitch_x : float
            DESCRIPTION HERE
    element_pitch_y : float
            DESCRIPTION HERE
        
    '''
    this = TxArray(parent)

    total_element_count = element_count_x * element_count_y

    this.tx_array_element_descriptor = np.zeros((total_element_count, 16),
                                                dtype=np.float32)

    for array_element_iy in range(element_count_y):
        for array_element_ix in range(element_count_x):
            # add an element at that indexed location
            element_idx = array_element_iy * element_count_x + array_element_ix

            loc_x = (array_element_ix -
                     (element_count_x / 2) + 0.5) * element_pitch_x
            loc_y = (array_element_iy -
                     (element_count_y / 2) + 0.5) * element_pitch_y

            this.tx_array_element_descriptor[element_idx, :] = \
                this.generate_tx_array_element(x=loc_x, y=loc_y, amplitude_ratio_setting=1.0)

            # print('at B,{},{},{}'.format(array_element_iy,array_element_ix,this.tx_array_element_descriptor_a.dtype))

    this.name = 'fully sampled rectilinear, parametrized with element_count={}; '.format(
        element_count_x * element_count_y)

    return this
Exemple #2
0
def from_system_xml(parent=None, file=None):
    """
    attempt to load a description of the array from an "Acoustic Renderer" xml file.
    :param parent: set to local world.
    :param file: file name to load. Must be an "Acoustic Renderer" compatible xml file.
    :return:
    """
    import xml.etree.ElementTree as et

    this = TxArray(parent)

    try:
        tree = et.parse(file)

    except:
        print("XML parsing error")

    root = tree.getroot()

    no_transducers = 0

    for transducer in root.findall("./System/Transducers/Transducer"):
        no_transducers += 1

    this.tx_array_element_descriptor = np.zeros((no_transducers, 16),
                                                dtype=np.float32)

    for transducer in root.findall("./System/Transducers/Transducer"):
        element_id = int(transducer.get('Index'))
        x_pos = float(transducer.get('Xmm')) * 1e-3
        y_pos = float(transducer.get('Ymm')) * 1e-3
        z_pos = float(transducer.get('Zmm')) * 1e-3
        pol = transducer.get('ABX')

        if (pol == 'X'):
            # TODO: Check this works
            amp_ratio = 0.0

        else:
            amp_ratio = 1.0

        this.tx_array_element_descriptor[element_id, :] = \
            this.generate_tx_array_element(x=x_pos, y=y_pos, amplitude_ratio_setting=amp_ratio)

    return this
Exemple #3
0
def single_element(parent=None):
    '''DESCRIPTION HERE

    Parameters
    ----------

    parent : handybeam world
            DESCRIPTION HERE
        
    '''

    this = TxArray(parent)
    this.name = 'most basic single point'
    this.is_frequency_enabled = True
    this.tx_array_element_descriptor = this.generate_tx_array_element(
        amplitude_ratio_setting=1.0)

    return this
Exemple #4
0
def simple_linear(parent=None, element_count=16, element_pitch=7e-3):
    '''
    ---------------------------------------------
    simple_linear(parent, element_count, element_pitch)
    ---------------------------------------------
        
    DESCRIPTION HERE

    Parameters
    ----------

    parent : handybeam world
            DESCRIPTION HERE
    element_count : int 
            DESCRIPTION HERE
    element_pitch : float 
            DESCRIPTION HERE
        
    '''

    this = TxArray(parent)
    this.name = 'a line of elements, starting at xyz=0, along y, spaced by {:0.1f}mm'.format(
        element_pitch * 1e3)

    this.tx_array_element_descriptor = np.zeros((element_count, 16),
                                                dtype=np.float32)

    half_length = (element_count * element_pitch) / 2

    for array_element_iy in range(element_count):

        # add an element at that indexed location
        element_idx = array_element_iy

        loc_x = 0
        loc_y = (array_element_iy -
                 (element_pitch / 2) + 0.5) * element_pitch - half_length

        this.tx_array_element_descriptor[element_idx, :] = \
        this.generate_tx_array_element(x=loc_x, y=loc_y, amplitude_ratio_setting=1.0)

    return this
Exemple #5
0
def simple_linear(parent=None, element_count=16, element_pitch=7e-3):
    """1D line of elements, starting at xyz=0, along y, with given element_pitch

    Parameters
    ----------

    parent : handybeam.world.World
            the world to give to this array as parent
    element_count : int 
            count of elements.
    element_pitch : float 
            distance between elements
        
    """

    this = TxArray(parent)
    this.name = 'a line of elements, starting at xyz=0, along y, spaced by {:0.1f}mm'.format(
        element_pitch * 1e3)

    this.tx_array_element_descriptor = np.zeros((element_count, 16),
                                                dtype=np.float32)

    half_length = (element_count * element_pitch) / 2

    for array_element_iy in range(element_count):

        # add an element at that indexed location
        element_idx = array_element_iy

        loc_x = 0
        loc_y = (array_element_iy -
                 (element_pitch / 2) + 0.5) * element_pitch - half_length

        this.tx_array_element_descriptor[element_idx, :] = \
        this.generate_tx_array_element(x=loc_x, y=loc_y, amplitude_ratio_setting=1.0)

    return this