示例#1
0
  def tst_cspad_hierarchy(self):
    from dxtbx.serialize import dump, load
    from dxtbx.imageset import ImageSetFactory
    import libtbx.load_env
    import os
    from glob import glob
    try:
      path = libtbx.env.dist_path('dials_regression')
    except Exception:
      print "No dials_regression directory found"
      return

    # Get the imageset
    filename = os.path.join(path, "spotfinding_test_data", "idx*.cbf")
    imageset = ImageSetFactory.new(glob(filename))
    assert(len(imageset) == 1)
    imageset = imageset[0]

    # Dump and reload
    from uuid import uuid4
    filename = '%s.json' % uuid4().hex
    dump.imageset(imageset, filename)
    imageset2 = load.imageset(filename)

    # Check they're are the same
    assert(imageset2.get_beam() == imageset.get_beam())
    d1 = imageset.get_detector()
    d2 = imageset2.get_detector()
    assert(len(d1) == len(d2))
    for i, (p1, p2) in enumerate(zip(d1, d2)):
      assert(p1 == p2)
    assert(imageset2.get_detector() == imageset.get_detector())
    assert(imageset2 == imageset)

    # Test passed
    print 'OK'
示例#2
0
def exercise_to_xds():
  if not libtbx.env.has_module("dials_regression"):
    print "Skipping exercise_to_xds(): dials_regression not present"
    return

  data_dir = libtbx.env.find_in_repositories(
    relative_path="dials_regression/centroid_test_data",
    test=os.path.isdir)
  template = os.path.join(data_dir, "centroid_*.cbf")
  file_names = glob.glob(template)

  expected_output = """\
DETECTOR=PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD=495976
SENSOR_THICKNESS= 0.320
DIRECTION_OF_DETECTOR_X-AXIS= 1.00000 0.00000 0.00000
DIRECTION_OF_DETECTOR_Y-AXIS= 0.00000 1.00000 0.00000
NX=2463 NY=2527 QX=0.1720 QY=0.1720
DETECTOR_DISTANCE= 190.180
ORGX= 1235.84 ORGY= 1279.58
ROTATION_AXIS= 1.00000 0.00000 0.00000
STARTING_ANGLE= 0.000
OSCILLATION_RANGE= 0.200
X-RAY_WAVELENGTH= 0.97950
INCIDENT_BEAM_DIRECTION= -0.000 -0.000 1.021
FRACTION_OF_POLARIZATION= 0.999
POLARIZATION_PLANE_NORMAL= 0.000 1.000 0.000
NAME_TEMPLATE_OF_DATA_FRAMES= %s
TRUSTED_REGION= 0.0 1.41
UNTRUSTED_RECTANGLE= 487 495 0 2528
UNTRUSTED_RECTANGLE= 981 989 0 2528
UNTRUSTED_RECTANGLE= 1475 1483 0 2528
UNTRUSTED_RECTANGLE= 1969 1977 0 2528
UNTRUSTED_RECTANGLE= 0 2464 195 213
UNTRUSTED_RECTANGLE= 0 2464 407 425
UNTRUSTED_RECTANGLE= 0 2464 619 637
UNTRUSTED_RECTANGLE= 0 2464 831 849
UNTRUSTED_RECTANGLE= 0 2464 1043 1061
UNTRUSTED_RECTANGLE= 0 2464 1255 1273
UNTRUSTED_RECTANGLE= 0 2464 1467 1485
UNTRUSTED_RECTANGLE= 0 2464 1679 1697
UNTRUSTED_RECTANGLE= 0 2464 1891 1909
UNTRUSTED_RECTANGLE= 0 2464 2103 2121
UNTRUSTED_RECTANGLE= 0 2464 2315 2333
DATA_RANGE= 1 9
JOB=XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT\
""" %(template.replace("*", "????"))

  cmd = " ".join(["dxtbx.to_xds"] + file_names)
  result = easy_run.fully_buffered(cmd)
  # allow extra lines to have been added (these may be comments)
  for record in expected_output.split('\n'):
    assert record.strip() in "\n".join(result.stdout_lines), record

  # now test reading from a json file
  sweep = ImageSetFactory.new(file_names)[0]
  f = open_tmp_file(suffix="sweep.json", mode="wb")
  dump.imageset(sweep, f)
  f.close()
  cmd = " ".join(["dxtbx.to_xds", f.name])
  result = easy_run.fully_buffered(cmd)

  # allow extra lines to have been added (these may be comments)
  for record in expected_output.split('\n'):
    assert record.strip() in "\n".join(result.stdout_lines), record
示例#3
0
    from dxtbx.imageset import ImageSetFactory

    # Specify the command line options
    usage = "usage: %prog [options] /path/to/image/files.ext"
    parser = OptionParser(usage)

    # Add a verbose option (False by default)
    parser.add_option('-o',
                      '--output-file',
                      dest='output_file',
                      type="string",
                      default="imageset.json",
                      help='Enter a destination filename for serialization')

    # Parse the arguments
    (options, args) = parser.parse_args()

    # Print help if no arguments specified, otherwise call spot prediction
    if len(args) == 0:
        print parser.print_help()

    else:
        imagesets = ImageSetFactory.new(args)
        if len(imagesets) == 0:
            print "Error: no imagesets to serialize."
        elif len(imagesets) > 1:
            print "Error: more than 1 imageset has been specified"
        else:
            dump.imageset(imagesets[0], options.output_file)
            print "Serialized imageset to {0}".format(options.output_file)
示例#4
0
  from optparse import OptionParser
  from dxtbx.serialize import dump
  from dxtbx.imageset import ImageSetFactory

  # Specify the command line options
  usage  = "usage: %prog [options] /path/to/image/files.ext"
  parser = OptionParser(usage)

  # Add a verbose option (False by default)
  parser.add_option('-o', '--output-file',
                    dest='output_file', type="string",
                    default="imageset.json",
                    help='Enter a destination filename for serialization')

  # Parse the arguments
  (options, args) = parser.parse_args()

  # Print help if no arguments specified, otherwise call spot prediction
  if len(args) == 0:
    print parser.print_help()

  else:
    imagesets = ImageSetFactory.new(args)
    if len(imagesets) == 0:
      print "Error: no imagesets to serialize."
    elif len(imagesets) > 1:
      print "Error: more than 1 imageset has been specified"
    else:
      dump.imageset(imagesets[0], options.output_file)
      print "Serialized imageset to {0}".format(options.output_file)
示例#5
0
def exercise_to_xds():
    if not libtbx.env.has_module("dials"):
        print "Skipping test: dials not present"
        return
    if not libtbx.env.has_module("dials_regression"):
        print "Skipping exercise_to_xds(): dials_regression not present"
        return

    data_dir = libtbx.env.find_in_repositories(
        relative_path="dials_regression/centroid_test_data",
        test=os.path.isdir)
    template = os.path.join(data_dir, "centroid_*.cbf")
    file_names = glob.glob(template)

    expected_output = """\
DETECTOR=PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD=495976
SENSOR_THICKNESS= 0.320
DIRECTION_OF_DETECTOR_X-AXIS= 1.00000 0.00000 0.00000
DIRECTION_OF_DETECTOR_Y-AXIS= 0.00000 1.00000 0.00000
NX=2463 NY=2527 QX=0.1720 QY=0.1720
DETECTOR_DISTANCE= 190.180
ORGX= 1235.84 ORGY= 1279.58
ROTATION_AXIS= 1.00000 0.00000 0.00000
STARTING_ANGLE= 0.000
OSCILLATION_RANGE= 0.200
X-RAY_WAVELENGTH= 0.97950
INCIDENT_BEAM_DIRECTION= -0.000 -0.000 1.021
FRACTION_OF_POLARIZATION= 0.999
POLARIZATION_PLANE_NORMAL= 0.000 1.000 0.000
NAME_TEMPLATE_OF_DATA_FRAMES= %s
TRUSTED_REGION= 0.0 1.41
UNTRUSTED_RECTANGLE= 487 495 0 2528
UNTRUSTED_RECTANGLE= 981 989 0 2528
UNTRUSTED_RECTANGLE= 1475 1483 0 2528
UNTRUSTED_RECTANGLE= 1969 1977 0 2528
UNTRUSTED_RECTANGLE= 0 2464 195 213
UNTRUSTED_RECTANGLE= 0 2464 407 425
UNTRUSTED_RECTANGLE= 0 2464 619 637
UNTRUSTED_RECTANGLE= 0 2464 831 849
UNTRUSTED_RECTANGLE= 0 2464 1043 1061
UNTRUSTED_RECTANGLE= 0 2464 1255 1273
UNTRUSTED_RECTANGLE= 0 2464 1467 1485
UNTRUSTED_RECTANGLE= 0 2464 1679 1697
UNTRUSTED_RECTANGLE= 0 2464 1891 1909
UNTRUSTED_RECTANGLE= 0 2464 2103 2121
UNTRUSTED_RECTANGLE= 0 2464 2315 2333
DATA_RANGE= 1 9
JOB=XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT\
""" % (template.replace("*", "????"))

    cmd = " ".join(["dxtbx.to_xds"] + file_names)
    result = easy_run.fully_buffered(cmd)
    # allow extra lines to have been added (these may be comments)
    for record in expected_output.split('\n'):
        assert record.strip() in "\n".join(result.stdout_lines), record

    # now test reading from a json file
    sweep = ImageSetFactory.new(file_names)[0]
    f = open_tmp_file(suffix="sweep.json", mode="wb")
    dump.imageset(sweep, f)
    f.close()
    cmd = " ".join(["dxtbx.to_xds", f.name])
    result = easy_run.fully_buffered(cmd)

    # allow extra lines to have been added (these may be comments)
    for record in expected_output.split('\n'):
        assert record.strip() in "\n".join(result.stdout_lines), record