def correct(self, orientation): if self.flag == None: raise # no correction necessary from scitbx import matrix M1 = matrix.sqr(self.flag['trans']) corrected = orientation.change_basis(M1.transpose().elems) unit_cell_too_small(corrected.unit_cell(), cutoff=100.) return corrected
def correct(self, orientation): if self.flag is None: raise RuntimeError("no correction necessary") M1 = scitbx.matrix.sqr(self.flag['trans']) corrected = orientation.change_basis(M1.transpose().elems) unit_cell_too_small(corrected.unit_cell(), cutoff=100.) return corrected
def correct(experiments, reflections, assign_indices, threshold=0.9): assert len(experiments.crystals()) == 1 while True: sel = reflections["miller_index"] != (0, 0, 0) if sel.count(True) == 0: break T = detect(reflections["miller_index"].select(sel), threshold=threshold) if T is None: break crystal_model = experiments.crystals()[0] direct_matrix = scitbx.matrix.sqr(crystal_model.get_A()).inverse() M = T.inverse().transpose() new_direct_matrix = M * direct_matrix crystal_model.set_A(new_direct_matrix.inverse()) unit_cell_too_small(crystal_model.get_unit_cell()) cb_op = crystal_model.get_unit_cell( ).change_of_basis_op_to_niggli_cell() crystal_model.update(crystal_model.change_basis(cb_op)) reflections["id"] = flex.int(len(reflections), -1) reflections.unset_flags(flex.bool(len(reflections), True), reflections.flags.indexed) assign_indices(reflections, experiments)
def correct(self,orientation): if self.flag==None: raise # no correction necessary from scitbx import matrix M1 = matrix.sqr(self.flag['trans']) corrected = orientation.change_basis(M1.transpose().elems) unit_cell_too_small(corrected.unit_cell(),cutoff = 100.) return corrected
def correct(self,orientation): print "before", orientation.unit_cell(),orientation.unit_cell().volume() print [float(i) for i in self.cb_op.elems] corrected = orientation.change_basis([float(i) for i in self.cb_op.elems]) print "after", corrected.unit_cell(),orientation.unit_cell().volume() unit_cell_too_small(corrected.unit_cell(),cutoff=25.) return corrected
def __init__(self,ai,combo,cutoff=unphysical_cell_cutoff_small_molecule_regime): self.ai = ai self.combo = combo self.cutoff = cutoff solns=[ai[combo[i]] for i in [0,1,2]] self.setA(solns) unit_cell_too_small(ai.getOrientation().unit_cell(),cutoff=self.cutoff) ai.niggli() # reduce cell
def __init__(self,ai,combo,cutoff=unphysical_cell_cutoff_small_molecule_regime): self.ai = ai self.combo = combo self.cutoff = cutoff solns=[ai[combo[i]] for i in [0,1,2]] self.setA(solns) unit_cell_too_small(ai.getOrientation().unit_cell(),cutoff=self.cutoff) ai.niggli() # reduce cell
def rwgk_niggli(UC,epsilon=None,cutoff=100.): '''Reference: R.W. Grosse-Kunstleve, N.K. Sauter and P.D. Adams. Numerically stable algorithms for the computation of reduced unit cells. Acta Cryst. A60, 1-6 (2004) ''' if isinstance(UC,unit_cell): #return UC.niggli_cell(epsilon) return fast_minimum_reduction(UC).as_unit_cell() elif isinstance(UC,crystal_orientation.crystal_orientation): uc = UC.unit_cell() unit_cell_too_small(uc,cutoff=cutoff) #R = uc.niggli_reduction(epsilon) R = fast_minimum_reduction(uc) #minimum reduction gets r_inv as a tuple instead of scitbx.matrix rinverse = matrix.sqr( R.r_inv() ) #NIG = R.as_unit_cell().parameters() #MIN = fast_minimum_reduction(uc).as_unit_cell().parameters() return UC.change_basis(rinverse.transpose().inverse().elems)
#print "transformation",invS.transpose().elems,{True:"is",False:"not"}[idx_possible],"possible" if idx_possible: print "There are systematic absences. Applying transformation",invS.transpose().elems self.cb_op = invS.transpose().inverse() # not sure if transpose.inverse or just inverse self.flag = True return 1 return 0 def correct(self,orientation): print "before", orientation.unit_cell(),orientation.unit_cell().volume() print [float(i) for i in self.cb_op.elems] corrected = orientation.change_basis([float(i) for i in self.cb_op.elems]) print "after", corrected.unit_cell(),orientation.unit_cell().volume() unit_cell_too_small(corrected.unit_cell(),cutoff=25.) return corrected class FewSpots(exceptions.Exception): pass class SolutionTracker: def __init__(self): self.all_solutions=[] self.volume_filtered=[] def append(self,item): item['serial']=len(self.all_solutions) self.all_solutions.append(item) self.update_analysis() def update_analysis(self): self.best_likelihood = max([i['model_likelihood'] for i in self.all_solutions]) self.close_solutions = [