Skip to content

get indices at coords #47

@shimwell

Description

@shimwell

I think this is the pure numpy solution but it doesn't pass the 2nd test :-(

    def get_indices_at_coords(self, x: float, y: float, z: float) -> Tuple[int]:
        """Finds the index of the mesh voxel at the specified x,y,z coordinates.

        Parameters
        ----------
        x : float
            The x axis value
        y : float
            The y axis value
        z : float
            The z axis value

        Returns
        -------
        Tuple[int]
            The r, phi, z indices

        """
        
        distances = np.sum((self.centroids-(x,y,z))**2, axis=3)
        min_distance = np.min(distances)
        r_index, phi_index, z_index = np.argwhere(distances == min_distance).flatten()

        return (r_index, phi_index, z_index)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions