Hi Graeme,<div><br></div><div>You can make it work like this:</div><div><br></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">def symop_to_mat(symop):</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  return matrix.sqr(sgtbx.rt_mx(</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    sgtbx.parse_string(symop)<font class="Apple-style-span" color="#ff0000">, r_den=12, t_den=144</font>).as_double_array()[:9]).transpose().elems</font></div>
<div><br></div><div>But I suggest using the change_of_basis_op type instead. See the complete script below.</div><div><br></div><div>Ralf</div><div><br></div><div><br></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from cctbx import sgtbx</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from cctbx.array_family import flex</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from scitbx import matrix</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">def symop_to_mat(symop):</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  return matrix.sqr(sgtbx.rt_mx(</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    sgtbx.parse_string(symop), r_den=12, t_den=144).as_double_array()[:9]).transpose().elems</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br>
</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">def run(args):</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  assert len(args) == 0</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  print symop_to_mat(&quot;1/2*z,-y+1/2*z,x&quot;)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  cb_op = sgtbx.change_of_basis_op(&quot;1/2*z,-y+1/2*z,x&quot;).inverse()</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  print cb_op.as_hkl()</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  miller_indices = flex.miller_index([(2,4,1)])</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  print list(cb_op.apply(miller_indices))</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">if (__name__ == &quot;__main__&quot;):</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  import sys</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  run(args=sys.argv[1:])</font></div></div><div><br></div><br><div class="gmail_quote">On Tue, Jul 12, 2011 at 7:06 AM,  <span dir="ltr">&lt;<a href="mailto:Graeme.Winter@diamond.ac.uk">Graeme.Winter@diamond.ac.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">





<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Dear All,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">For a little while now I have been using some cctbx jiffy code to convert from symmetry operations to matrices to help with testing reindexing data. This works as<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">def symop_to_mat(symop):<u></u><u></u></p>
<p class="MsoNormal">    return matrix.sqr(sgtbx.rt_mx(<u></u><u></u></p>
<p class="MsoNormal">        sgtbx.parse_string(symop)).as_double_array()[:9]).transpose().elems<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Which is plenty simple. However it just exploded when given “1/2*z,-y+1/2*z,x”  - reasonably really as this is not a rotation. It is however a valid reindexing operation to go from C2 to P1.<u></u><u></u></p>

<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Does anyone have code which will handle this general transformation from a reindexing operation to a matrix, which will cope with the fact that the resulting matrix is not RT? I had a little jiffy I wrote using ccp4f lib (symop2mat – you
 can probably see it!) but I am trying to do away with things like that and do everything properly…<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Many thanks in advance,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Graeme<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Dr. Graeme Winter<u></u><u></u></p>
<p class="MsoNormal">Senior Software Scientist<u></u><u></u></p>
<p class="MsoNormal">Diamond Light Source<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><a href="tel:%2B44%201235%20778091" value="+441235778091" target="_blank">+44 1235 778091</a> (work)<u></u><u></u></p>
<p class="MsoNormal"><a href="tel:%2B44%207786%20662784" value="+447786662784" target="_blank">+44 7786 662784</a> (work mobile)<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>

<br><p align="justify"> </p>

<p align="justify">--  </p>

<p align="justify">This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.<br>
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. <br>Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.<br>
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom<br> </p>

<br></div>

<br>_______________________________________________<br>
cctbxbb mailing list<br>
<a href="mailto:cctbxbb@phenix-online.org">cctbxbb@phenix-online.org</a><br>
<a href="http://phenix-online.org/mailman/listinfo/cctbxbb" target="_blank">http://phenix-online.org/mailman/listinfo/cctbxbb</a><br>
<br></blockquote></div><br></div>