getting indices of selected grid elements of a map

Hi, I am wondering if there is an efficient way to retrieve the 3D indices of a selection from a map. In the example on https://cci.lbl.gov/docs/cctbx/doc_low_flex_advanced/#getting-indices-of-sel... it is shown how to list the indices of a subset of grid elements of the map as in print(list(isel)) But isel is a 1D representation of 3d map indices. What if I want to get hold of the list of 3D indices corresponding to the indices in the isel array? Is there a fast boost-python way of doing this or would I have to do a 3D loop over the unit cell grid numbers to see if enumerated grid elements matches any of the elements in the isel array? Many thanks, Rob

Hi Rob, have a look at cctbx_project/mmtbx/maps/correlation.py line #240: sel = maptbx.grid_indices_around_sites Is this what you are looking for or perhaps something close that you use to achieve your goal? Pavel On 1/20/25 09:25, [email protected] wrote:
Hi,
I am wondering if there is an efficient way to retrieve the 3D indices of a selection from a map. In the example on https://cci.lbl.gov/docs/cctbx/doc_low_flex_advanced/#getting-indices-of-sel... it is shown how to list the indices of a subset of grid elements of the map as in
print(list(isel))
But isel is a 1D representation of 3d map indices. What if I want to get hold of the list of 3D indices corresponding to the indices in the isel array? Is there a fast boost-python way of doing this or would I have to do a 3D loop over the unit cell grid numbers to see if enumerated grid elements matches any of the elements in the isel array?
Many thanks,
Rob _______________________________________________ cctbxbb mailing list -- [email protected] To unsubscribe send an email to [email protected]

It's close but as far as I can tell from having tried using this function sel = maptbx.grid_indices_around_sites( unit_cell = unit_cell, fft_n_real = map_1.focus(), fft_m_real = map_1.all(), sites_cart = flex.vec3_double([site_cart]), site_radii = flex.double(1, radius)) the sel array is still a 1d array corresponding to 3d grid indices. Or am I wrong? Rob

I think so, yes, this is likely 1d.. Perhaps you can use relationships between 1d and 3d, something along these lines: 1d index=i×m×p+j×p+k and back to 3d i=index/(m×p) j=(index mod(m×p))/p k=index mod p where n, m, p are your 3d map dimensions. This is how we'd work with 3d maps in Fortran/C++ as if was 1d, for efficiency. Pavel On 1/20/25 09:39, [email protected] wrote:
It's close but as far as I can tell from having tried using this function
sel = maptbx.grid_indices_around_sites( unit_cell = unit_cell, fft_n_real = map_1.focus(), fft_m_real = map_1.all(), sites_cart = flex.vec3_double([site_cart]), site_radii = flex.double(1, radius))
the sel array is still a 1d array corresponding to 3d grid indices. Or am I wrong?
Rob _______________________________________________ cctbxbb mailing list -- [email protected] To unsubscribe send an email to [email protected]
participants (2)
-
Pavel Afonine
-
robert@oeffner.net