[cctbxbb] modulo operation on flex.double

Robert Oeffner rdo20 at cam.ac.uk
Thu Apr 11 10:51:33 PDT 2019


Thanks Richard,

That does the trick for me.

Rob

On 11/04/2019 18:25, richard.gildea at diamond.ac.uk wrote:
> Will flex.fmod_positive help here, e.g.:
>
>
>          """Modify the calculated phi values so that they match the full rotation
>          from zero taken from the the observations, rather than being modulo 2*pi."""
>
>          x_obs, y_obs, phi_obs = reflections["xyzobs.mm.value"].parts()
>          x_calc, y_calc, phi_calc = reflections["xyzcal.mm"].parts()
>          resid = phi_calc - (flex.fmod_positive(phi_obs, TWO_PI))
>          # ensure this is the smaller of two possibilities
>          resid = flex.fmod_positive((resid + pi), TWO_PI) - pi
>          phi_calc = phi_obs + resid
>
>
> https://github.com/dials/dials/blob/c8692c36577ac3e8b1410e78b6ede7f4e8300392/algorithms/refinement/prediction/managed_predictors.py#L143
>
>
> Dr Richard Gildea
> Data Analysis Scientist
> Tel: +441235 77 8078
>
> Diamond Light Source Ltd.
> Diamond House
> Harwell Science & Innovation Campus
> Didcot
> Oxfordshire
> OX11 0DE
> ________________________________
> From: cctbxbb-bounces at phenix-online.org <cctbxbb-bounces at phenix-online.org> on behalf of Robert Oeffner <rdo20 at cam.ac.uk>
> Sent: 11 April 2019 17:46:29
> To: cctbxbb at phenix-online.org
> Subject: [cctbxbb] modulo operation on flex.double
>
> Hi,
>
> I have a flex.double array of phase values between -360 and 360 degrees
> I would like to cast them all in one go to lie within 0 to 360. Does
> anybody know if there is a nice way of doing this with flex arrays? The
> modulo operator doesn't seem to be supported for flex arrays unlike the
> +, -, * and the / operators. This would otherwise be handy as I could
> then convert the array in one line of code like
>
> phases = phases % 360.0
>
> If not I guess I'll have to numpy the problem :-)
>
> Many thanks,
>
> Rob
>
>
> _______________________________________________
> cctbxbb mailing list
> cctbxbb at phenix-online.org
> http://phenix-online.org/mailman/listinfo/cctbxbb
>
-- 
Robert Oeffner, Ph.D.
Research Associate, The Read Group
Department of Haematology,
Cambridge Institute for Medical Research
University of Cambridge
Cambridge Biomedical Campus
The Keith Peters Building
Hills Road
Cambridge CB2 0XY

www.cimr.cam.ac.uk/investigators/read/index.html
tel: +44(0)1223 763234



More information about the cctbxbb mailing list