Exemple #1
0
        def do_work(i, item_list):
            processor = Processor(copy.deepcopy(self.params), composite_tag="%04d" % i)
            for item in item_list:
                tag, filename = item

                experiments = do_import(filename)
                imagesets = experiments.imagesets()
                if len(imagesets) == 0 or len(imagesets[0]) == 0:
                    logger.info("Zero length imageset in file: %s" % filename)
                    return
                if len(imagesets) > 1:
                    raise Abort("Found more than one imageset in file: %s" % filename)
                if len(imagesets[0]) > 1:
                    raise Abort(
                        "Found a multi-image file. Run again with pre_import=True"
                    )

                if self.reference_detector is not None:
                    imagesets[0].set_detector(
                        Detector.from_dict(self.reference_detector.to_dict())
                    )

                update_geometry(imagesets[0])

                processor.process_experiments(tag, experiments)
            processor.finalize()
def test_cspad_cbf_in_memory(dials_regression, run_in_tmpdir,
                             composite_output):
    # Check the data files for this test exist
    image_path = os.path.join(
        dials_regression,
        "image_examples",
        "LCLS_cspad_nexus",
        "idx-20130301060858801.cbf",
    )
    assert os.path.isfile(image_path)

    with open("process_lcls.phil", "w") as f:
        f.write(cspad_cbf_in_memory_phil)

    params = phil_scope.fetch(parse(file_name="process_lcls.phil")).extract()
    params.output.experiments_filename = None
    params.output.composite_output = composite_output
    if composite_output:
        processor = Processor(params, composite_tag="memtest")
    else:
        processor = Processor(params)
    mem_img = dxtbx.load(image_path)
    raw_data = mem_img.get_raw_data(
    )  # cache the raw data to prevent swig errors
    mem_img = FormatCBFCspadInMemory(mem_img._cbf_handle)
    mem_img._raw_data = raw_data
    mem_img._cbf_handle = None  # drop the file handle to prevent swig errors
    imgset = ImageSet(ImageSetData(MemReader([mem_img]), None))
    imgset.set_beam(mem_img.get_beam())
    imgset.set_detector(mem_img.get_detector())
    experiments = ExperimentListFactory.from_imageset_and_crystal(imgset, None)
    processor.process_experiments("20130301060858801",
                                  experiments)  # index/integrate the image
    if composite_output:
        processor.finalize()
        result = "idx-memtest_integrated.refl"
    else:
        result = "idx-20130301060858801_integrated.refl"
    n_refls = list(range(
        140, 152))  # large ranges to handle platform-specific differences
    table = flex.reflection_table.from_file(result)
    assert len(table) in n_refls, len(table)
    assert "id" in table
    assert (table["id"] == 0).count(False) == 0