This documentation page refers to a previous release of DIALS (2.2).
Click here to go to the corresponding page for the latest version of DIALS

dxtbx.datablock

class dxtbx.datablock.AutoEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class dxtbx.datablock.BeamComparison(wavelength_tolerance=1e-06, direction_tolerance=1e-06, polarization_normal_tolerance=1e-06, polarization_fraction_tolerance=1e-06)[source]

Bases: object

A class to provide simple beam comparison

class dxtbx.datablock.BeamDiff(wavelength_tolerance=1e-06, direction_tolerance=1e-06, polarization_normal_tolerance=1e-06, polarization_fraction_tolerance=1e-06)[source]

Bases: object

A class to provide simple beam comparison

class dxtbx.datablock.DataBlock(imagesets=None)[source]

Bases: object

High level container for blocks of sequences and imagesets.

append(imageset)[source]

Add an imageset to the block.

extend(datablock)[source]

Add two datablocks.

extract_imagesets()[source]

Extract all imagesets.

extract_sequences()[source]

Extract all the sequences from the block.

extract_stills()[source]

Extract all the still imagesets

format_class()[source]

Return the format class.

iter_sequences()[source]

Iterate over sequence groups.

iter_stills()[source]

Iterate over still groups.

num_images()[source]

Get the number of images.

to_dict()[source]

Convert the datablock to a dictionary

unique_beams()[source]
unique_detectors()[source]
unique_goniometers()[source]
unique_scans()[source]
class dxtbx.datablock.DataBlockDictImporter(obj, check_format=True, directory=None)[source]

Bases: object

A class to import a datablock from dictionary.

class dxtbx.datablock.DataBlockDumper(datablocks)[source]

Bases: object

Class to help in dumping datablock objects.

as_file(filename, **kwargs)[source]

Dump datablocks as file.

as_json(filename=None, compact=False)[source]

Dump datablock as json.

as_pickle(filename=None, **kwargs)[source]

Dump datablock as pickle.

class dxtbx.datablock.DataBlockFactory[source]

Bases: object

Class for creating DataBlock instances

static from_args(args, verbose=None, unhandled=None, compare_beam=None, compare_detector=None, compare_goniometer=None, scan_tolerance=None, format_kwargs=None)[source]

Try to load datablocks from any recognized format.

static from_dict(obj, check_format=True, directory=None)[source]

Create a datablock from a dictionary.

static from_filenames(filenames, verbose=None, unhandled=None, compare_beam=None, compare_detector=None, compare_goniometer=None, scan_tolerance=None, format_kwargs=None)[source]

Create a list of data blocks from a list of directory or file names.

static from_imageset(imagesets)[source]

Load a datablock from a list of imagesets.

static from_imageset_json_file(filename)[source]

Load a datablock from a sequence file.

static from_in_memory(images, indices=None)[source]

Function to instantiate data block from in memory imageset.

static from_json(string, check_format=True, directory=None)[source]

Decode a datablock from JSON string.

static from_json_file(filename, check_format=True)[source]

Decode a datablock from a JSON file.

static from_pickle_file(filename)[source]

Decode a datablock from a pickle file.

static from_serialized_format(filename, check_format=True)[source]

Load a datablock from serialized formats.

class dxtbx.datablock.DataBlockFilenameImporter(filenames, compare_beam=None, compare_detector=None, compare_goniometer=None, scan_tolerance=None, format_kwargs=None)[source]

Bases: object

A class to import a datablock from image files.

class dxtbx.datablock.DataBlockImageSetImporter(imagesets)[source]

Bases: object

A class to import a datablock from imagesets.

class dxtbx.datablock.DataBlockTemplateImporter(templates, **kwargs)[source]

Bases: object

A class to import a datablock from a template.

class dxtbx.datablock.DetectorComparison(fast_axis_tolerance=1e-06, slow_axis_tolerance=1e-06, origin_tolerance=1e-06)[source]

Bases: object

A class to provide simple detector comparison

class dxtbx.datablock.DetectorDiff(fast_axis_tolerance=1e-06, slow_axis_tolerance=1e-06, origin_tolerance=1e-06)[source]

Bases: object

A class to provide simple detector comparison

class dxtbx.datablock.FormatChecker[source]

Bases: object

A helper class to speed up identifying the correct image format by first trying the last format that was used.

find_format(filename)[source]

Search the registry for the image format class. Where possible use the last seen format class as a prioritisation hint.

iter_groups(filenames)[source]
class dxtbx.datablock.GoniometerComparison(rotation_axis_tolerance=1e-06, fixed_rotation_tolerance=1e-06, setting_rotation_tolerance=1e-06)[source]

Bases: object

A class to provide simple goniometer comparison

class dxtbx.datablock.GoniometerDiff(rotation_axis_tolerance=1e-06, fixed_rotation_tolerance=1e-06, setting_rotation_tolerance=1e-06)[source]

Bases: object

A class to provide simple goniometer comparison

class dxtbx.datablock.ImageMetadataRecord(beam=None, detector=None, goniometer=None, scan=None, template=None, filename=None, index=None)[source]

Bases: object

Object to store metadata information.

This is used whilst building the datablocks. The metadata for each image can be read once, and then any grouping/deduplication can happen later, without re-opening the original file.

classmethod from_format(fmt)[source]

Read metadata information from a Format instance.

This will only pull information out of a single format instance while it is open - combining metadata records must be done separately.

Parameters:format – The instance of the format class to read data from
Returns:A new ImageMetadataRecord with the pre-read information
merge_metadata_from(other_record, compare_beam=<built-in function eq>, compare_detector=<built-in function eq>, compare_goniometer=<built-in function eq>)[source]

Compare two record objects and merge equivalent data.

This method will compare (with optional functions) instance data for beam, detector and goniometer. If any of the metadata for this record is equivalent to (but a different instance from) the other record, then this instance will be altered to match the other. The function used to compare beams, detectors and goniometers can be customised - but by default the normal equality operator is used.

Parameters:
  • other_record – Another metadata instance
  • compare_beam – A function to compare beams
  • compare_detector – A function to compare detectors
  • compare_goniometer – A function to compare goniometers

Returns: True if any action was taken

exception dxtbx.datablock.InvalidDataBlockError[source]

Bases: RuntimeError

Indicates an error whilst validating the experiment list.

This means that there is some structural problem that prevents the given data from representing a well-formed experiment list. This doesn’t indicate e.g. some problem with the data or model consistency.

class dxtbx.datablock.OpeningPathIterator(pathnames)[source]

Bases: object

Utility class to efficiently open all paths.

A path is a potential file or directory. Each path will be opened with dxtbx.format.Format.open_file(), but in order to do so each file will only be opened once, and extraneous use of os.stat() will be avoided. Any path entries that are a directory will be recursed into, once - any further directories found will be ignored. Any path that is not a file or directory, or on which IO fails for any reason, will be added to the unhandled list. The current expected length of the iterator can be found with len(iterator) - this can change while iterating, because until a directory is encountered it cannot be detected without extra IO operations. The number of items processed can be accessed through the index attribute.

unhandled

List of paths that could not be handled

index

Index of the next path item (alternatively, number of processed path items)

index

Get the number of processed items

next()

Get the next path to process

class dxtbx.datablock.ScanDiff(scan_tolerance=1e-06)[source]

Bases: object

A class to provide scan comparison

class dxtbx.datablock.SequenceDiff(tolerance)[source]

Bases: object