On second thought, the simplest solution is to use the direct_space_asu object. This is available for all space groups:

>>> from cctbx import sgtbx
>>> sgi = sgtbx.space_group_info( "P2" )
>>> asu = sgi.direct_space_asu()
>>> asu.is_inside( ( 0, 0, 0 ) )
True
>>> asu.is_inside( (0, 0, 0.51 ) )
False

BW, Gabor

On Mon, Nov 21, 2016 at 1:22 PM, Gabor Bunkoczi <gabor.bunkoczi@googlemail.com> wrote:
Dear Engelbert,

you can use the asu_mappings objects to compute this (there may be something more suitable for regular grids). Here is a link to a tutorial written by Ralf Grosse-Kunstleve, where this is explained:

http://cci.lbl.gov/publications/download/iucrcompcomm_aug2004.pdf

BW, Gabor


On Mon, Nov 21, 2016 at 12:47 PM, Tijskens Engelbert <Engelbert.Tijskens@uantwerpen.be> wrote:
Hi,

I am an experienced C++ and Python programmer, but new to cctbx.

Can any tell me if there is an algorithm in cctbx available  to convert an arbritrary point in direct space to the corresponding point in the asymmetric unit of a given space group? i can figure out how to convert it to the corresponding point in the unit cell at the origin, but from there to the asymmetric unit is unclear to me. 

I found the brick class which gives me the assymmetric unit
from cctbx import crystal,sgtbx

if __name__=='__main__':
    crystal_symmetry = crystal.symmetry( unit_cell=(3.5093,3.5093,3.5093,90,90,90)
                                       , space_group_symbol="229" # = "I m -3 m"
                                       )
    sg = crystal_symmetry.space_group()
    brick = sgtbx.brick( sg.type() )
    print brick

I also found cctbx::sgtbx::asu and the classes therein, but they are largely undocumented. 

For the interested, this is the problem i want to solve:
I have a (scalar) physical property P(r), depending on spatial position, presented as a 3D array on a regular grid over the unit cell (space group is known). I need to integrate P(r)*f(r), f(r) being an arbitrary function over a region of direct space, which typically comprises several unit cells. In order to reduce the memory footprint of the P array, i would like to restrict it to the space group’s asymmetric unit.

All help is greatly appreciated.
kindest regards, 

Dr [Engel]bert Tijskens
HPC Analyst/Consultant

Flemish Supercomputer Center vscentrum.be 
HPC core facility CalcUA uantwerp.be/calcua
Computational mathematics www.uantwerpen.be/en/rg/cma

University of Antwerp 
Middelheimlaan1 G.309, B-2020 Antwerp, Belgium

engelbert.tijskens@uantwerpen.be
++32 3 265 3879

_______________________________________________
cctbxbb mailing list
cctbxbb@phenix-online.org
http://phenix-online.org/mailman/listinfo/cctbxbb