def main(self, params, options, args):
    """Execute the script."""
    from dials.algorithms.refinement import RefinerFactory
    from dials.model.serialize import load
    import cPickle as pickle
    from time import time
    import sys

    # Check the number of arguments is correct
    if len(args) != 3:
      self.config().print_help()
      return

    # Hack the phil parameters to control the number of reflections
    params.refinement.reflections.use_all_reflections = False
    params.refinement.reflections.random_seed = None

    # and also to make the target achieved criterion more stringent
    params.refinement.target.bin_size_fraction = 0.1

    # print header for output table
    print "Nref RMSDx RMSDy RMSDphi Steps Target_acheived Time"

    #for n in range(1,170,2):
    for n in [e * 0.1 for e in range(1,100)]:

      # Set nref to use
      params.refinement.reflections.reflections_per_degree = n

      # Get the refiner from the input parameters
      refine = RefinerFactory.from_parameters(params, options.verbosity)

      # Try to load the models
      sweep = load.sweep(args[0])
      crystal = load.crystal(args[1])
      reflections = pickle.load(open(args[2], 'rb'))

      # Refine the geometry
      start_time = time()
      try:
        refined = refine(sweep, crystal, reflections)
      except Exception as e:
        print "ERROR occurred"
        continue
      time_taken = time() - start_time

      print refined.history.num_reflections[-1],
      print "%.6f %.6f %.8f" % refine.rmsds(),
      print "%d" % refined.get_num_steps(),
      print refined.test_for_termination(),
      print "%.3f" % time_taken

      # flush the buffer so we can see some output
      sys.stdout.flush()

    return
Exemplo n.º 2
0
    def main(self, params, options, args):
        """Execute the script."""
        from dials.algorithms.refinement import RefinerFactory
        from dials.model.serialize import load
        import cPickle as pickle
        from time import time
        import sys

        # Check the number of arguments is correct
        if len(args) != 3:
            self.config().print_help()
            return

        # Hack the phil parameters to control the number of reflections
        params.refinement.reflections.use_all_reflections = False
        params.refinement.reflections.random_seed = None

        # and also to make the target achieved criterion more stringent
        params.refinement.target.bin_size_fraction = 0.1

        # print header for output table
        print("Nref RMSDx RMSDy RMSDphi Steps Target_acheived Time")

        # for n in range(1,170,2):
        for n in [e * 0.1 for e in range(1, 100)]:

            # Set nref to use
            params.refinement.reflections.reflections_per_degree = n

            # Get the refiner from the input parameters
            refine = RefinerFactory.from_parameters(params, options.verbosity)

            # Try to load the models
            sweep = load.sweep(args[0])
            crystal = load.crystal(args[1])
            reflections = pickle.load(open(args[2], "rb"))

            # Refine the geometry
            start_time = time()
            try:
                refined = refine(sweep, crystal, reflections)
            except Exception as e:
                print("ERROR occurred")
                continue
            time_taken = time() - start_time

            print(refined.history.num_reflections[-1], end=" ")
            print("%.6f %.6f %.8f" % refine.rmsds(), end=" ")
            print("%d" % refined.get_num_steps(), end=" ")
            print(refined.test_for_termination(), end=" ")
            print("%.3f" % time_taken)

            # flush the buffer so we can see some output
            sys.stdout.flush()

        return
Exemplo n.º 3
0
# In [16]: refl[index[10000]].miller_index
# Out[16]: (17, 23, 23)

# In [17]: refl[index[10000]].image_coord_px
# Out[17]: (788.1612634483189, 1969.9381446581392)

# In [18]: refl[index[10000]].frame_number
# Out[18]: 352.1425769902628

# In [19]: 2.688E+03
# Out[19]: 2688.0

from dials.model.serialize import load

sweep = load.sweep("/home/upc86896/Data/TRP_M1S3_2_/sweep.json")
crystal = load.crystal("/home/upc86896/Data/TRP_M1S3_2_/crystal.json")
reference = load.reference("/home/upc86896/Data/TRP_M1S3_2_/reference.pickle")
# from dials.algorithms.integration import ReflectionExtractor

# extract = ReflectionExtractor(3)
# refl = extract(sweep, crystal)
# index = 104786
# print refl[index].miller_index

import pickle

# pickle.dump(refl[index], open('test_reflection', 'w'))
refl = pickle.load(open("test_reflection", "r"))

from dials.model.data import ReflectionList
Exemplo n.º 4
0
def get_dials_matrix(crystal_json):
    from dials.model.serialize import load
    crystal = load.crystal(crystal_json)
    return crystal.get_A()
Exemplo n.º 5
0
#In [16]: refl[index[10000]].miller_index
#Out[16]: (17, 23, 23)

#In [17]: refl[index[10000]].image_coord_px
#Out[17]: (788.1612634483189, 1969.9381446581392)

#In [18]: refl[index[10000]].frame_number
#Out[18]: 352.1425769902628

#In [19]: 2.688E+03
#Out[19]: 2688.0

from dials.model.serialize import load
sweep = load.sweep('/home/upc86896/Data/TRP_M1S3_2_/sweep.json')
crystal = load.crystal('/home/upc86896/Data/TRP_M1S3_2_/crystal.json')
reference= load.reference('/home/upc86896/Data/TRP_M1S3_2_/reference.pickle')
#from dials.algorithms.integration import ReflectionExtractor

#extract = ReflectionExtractor(3)
#refl = extract(sweep, crystal)
#index = 104786
#print refl[index].miller_index

import pickle
#pickle.dump(refl[index], open('test_reflection', 'w'))
refl = pickle.load(open('test_reflection', 'r'))

from dials.model.data import ReflectionList
ref_list = ReflectionList(1)
ref_list[0] = refl
Exemplo n.º 6
0
from dials.algorithms.integration import ReflectionExtractor
from dials.model.serialize import load
import os

path = "/home/upc86896/Projects/cctbx/sources/dials_regression/centroid_test_data"

sweep = load.sweep(os.path.join(path, "sweep.json"))
crystal = load.crystal(os.path.join(path, "crystal.json"))

extract = ReflectionExtractor(3)
refl = extract(sweep, crystal)


import copy

refl2 = copy.deepcopy(refl)


from dials.algorithms.reflection_basis import transform
from dials.util.command_line import Command

Command.start("Init transform")
trans = transform.Forward(sweep, crystal, 3, 4)
Command.end("Init transform")

Command.start("Transform")
for i in range(1):
    trans(refl)
Command.end("Transform")

Command.start("Init Transform")
Exemplo n.º 7
0
def get_dials_matrix(crystal_json):
    from dials.model.serialize import load

    crystal = load.crystal(crystal_json)
    return crystal.get_A()
Exemplo n.º 8
0


from dials.algorithms.integration import ReflectionExtractor
from dials.model.serialize import load
import os
path = '/home/upc86896/Projects/cctbx/sources/dials_regression/centroid_test_data'

sweep = load.sweep(os.path.join(path, 'sweep.json'))
crystal = load.crystal(os.path.join(path, 'crystal.json'))

extract = ReflectionExtractor(3)
refl = extract(sweep, crystal)


import copy

refl2 = copy.deepcopy(refl)


from dials.algorithms.reflection_basis import transform
from dials.util.command_line import Command

Command.start('Init transform')
trans = transform.Forward(sweep, crystal, 3, 4)
Command.end('Init transform')

Command.start('Transform')
for i in range(1):
  trans(refl)
Command.end('Transform')