else: P.init.Nabc = SIM.crystal.Ncells_abc if "detz_shift" in args.perturb: P.init.detz_shift = 1 else: P.init.detz_shift = 0 if "eta" in args.perturb: P.init.eta_abc = [0.12, 0.13, 0.14] P.simulator.crystal.num_mosaicity_samples = 250 # in practive, the number of mosaic domains we model should be smaller than whats in the crystal .. . P.simulator.crystal.has_isotropic_mosaicity = False P.fix.eta_abc = False E.detector = SIM.detector E.beam = SIM.D.beam E.imageset = make_imageset([img], E.beam, E.detector) #refls = utils.refls_from_sims([img], E.detector, E.beam, thresh=18) refls = utils.refls_from_sims([spots], E.detector, E.beam, thresh=18) print("%d REFLS" % len(refls)) utils.refls_to_q(refls, E.detector, E.beam, update_table=True) utils.refls_to_hkl(refls, E.detector, E.beam, E.crystal, update_table=True) P.roi.shoebox_size = 20 P.relative_tilt = False P.roi.fit_tilt = False P.roi.pad_shoebox_for_background_estimation = 10 P.roi.reject_edge_reflections = False P.refiner.sigma_r = SIM.D.readout_noise_adu P.refiner.adu_per_photon = SIM.D.quantum_gain P.simulator.init_scale = 1 #SIM.D.spot_scale
from __future__ import division from simtbx.diffBragg import utils from simtbx.nanoBragg.tst_nanoBragg_basic import pdb_lines from simtbx.diffBragg.phil import hopper_phil, philz from libtbx.phil import parse from simtbx.nanoBragg import tst_nanoBragg_multipanel from dxtbx.model import Experiment import numpy as np # make a dummie experiment expt = Experiment() expt.detector = tst_nanoBragg_multipanel.whole_det expt.beam = tst_nanoBragg_multipanel.beam expt.crystal = tst_nanoBragg_multipanel.cryst # write a dummie PDB file PDB = "1234.pdb" o = open(PDB, "w") o.write(pdb_lines) o.close() # Create a miller array from on-disk PDB file F = utils.get_complex_fcalc_from_pdb(PDB, wavelength=expt.beam.get_wavelength(), dmin=2, dmax=20, k_sol=0.2, b_sol=20) F = F.as_amplitude_array() Fmap = {h: amp for h,amp in zip(F.indices(), F.data())} # Create a sim_data class instance as would be done for hopper_utils.refine for example phil_scope = parse(hopper_phil+philz)
iset = isets[i] path = iset.get_path(0) d = df2_filt0.query("imgpaths=='%s'" % path) if has_master: master_index = iset.indices()[0] d = d.query("master_indices==%d" % master_index) if len(d) != 1: continue A = d.Amats.values[0] #break C = deepcopy(crystals[i]) #C.set_A(A) Ex = Experiment() Ex.crystal = C Ex.imageset = iset Ex.beam = beams[i] Ex.detector = D El2.append(Ex) Rsel = R.select(R['id']==i) nref = len(Rsel) Rsel['id'] = flex.int(nref, new_id) R2.extend(Rsel) new_id += 1 print (new_id) el_file = "%s.expt" % args.tag R_file = "%s.refl" % args.tag El2.as_file(el_file) print("Saved experiment %s" % el_file ) R2.as_file(R_file)