API

Connecting to ISPyB

exception ispyb.ConnectionError[source]

Bases: ispyb.ISPyBException

Unable to connect or connection has been closed.

exception ispyb.ISPyBException[source]

Bases: exceptions.Exception

Base class for all exceptions

exception ispyb.NoResult[source]

Bases: ispyb.ISPyBException

Query returned no result.

exception ispyb.ReadWriteError[source]

Bases: ispyb.ISPyBException

Record could not be read, inserted, updated or deleted. This could be due to illegal values, the wrong number of parameters, a violation of table or index constraints, or a database failure.

ispyb.open(configuration_file)[source]

Create an ISPyB connection using settings from a configuration file. This can be used either as a function call or as a context manager.

Parameters:configuration_file – Full path to a file containing database credentials
Returns:ISPyB connection object

Accessing records using the object model

The connection object offers the following accessor functions to get object-like representations of database entries:

class ispyb.model.interface.ObjectModelMixIn[source]

Object model accessor functions for Connector classes.

get_data_collection(dcid)[source]

Return a DataCollection object representing the information about the selected data collection.

get_data_collection_group(dcgid)[source]

Return a DataCollectionGroup object representing the information about the selected data collection group.

get_detector(detectorid)[source]

Return a Detector object representing a Detector database entry.

get_processing_job(jobid)[source]

Return a ProcessingJob object representing the information about the selected processing job.

get_processing_program(appid)[source]

Return a ProcessingProgram object representing the information about a processing program invocation.

get_screening(screening_id)[source]

Return a Screening object representing the information about a Screening result.

get_screening_output(screening_output_id)[source]

Return a ScreeningOutput object representing the information about a ScreeningOutput result.

get_screening_output_lattice(screening_output_lattice_id)[source]

Return a ScreeningOutputLattice object representing the information about a ScreeningOutputLattice result.

get_screening_strategy(screening_strategy_id)[source]

Return a ScreeningStrategy object representing the information about a ScreeningStrategy result.

get_screening_strategy_sub_wedge(screening_strategy_sub_wedge_id)[source]

Return a ScreeningStrategySubWedge object representing the information about a ScreeningStrategySubWedge result.

get_screening_strategy_wedge(screening_strategy_wedge_id)[source]

Return a ScreeningStrategyWedge object representing the information about a ScreeningStrategyWedge result.

DataCollection and DataCollectionGroup

class ispyb.model.datacollection.DataCollection(dcid, db_area, preload=None)[source]

An object representing a DataCollection database entry. The object lazily accesses the underlying database when necessary and exposes record data as python attributes.

comment

A free comment field for the data collection.

dcgid

Returns the Data Collection Group ID associated with this data collection. You can use .group to get the data collection group model object instead

dcid

Returns the DataCollectionID.

detector

Returns the Detector object associated with this DC.

detector_2theta

2Theta angle between the main beam and the detector normal in degrees

detector_distance

Distance from the sample to the detector in mm

detector_id

A unique identifier for the detector used in this acquisition. You can access the detector model object via .detector directly.

file_directory

Fully qualified path to the image files

file_template

Template for file names with the character ‘#’ standing in for image number digits.

file_template_full

Template for file names with full directory path. As with file_template ‘#’ characters stand in for image number digits.

file_template_full_python

Template for file names that can be used in python string templates (for use with the % operator), with %0xd standing in for the x image number digits.

group

Returns a DataCollectionGroup object.

image_quality

Returns the list of ImageQualityIndicators objects associated with this DC.

integrations

Returns the list of IntegrationResult objects associated with this DC.

pdb

Returns a PDB object for the sample of this datacollection.

reload()[source]

Load/update information from the database.

resolution

Inscribed resolution circle in Angstrom. Currently only well-defined for data collections with 2theta=0

sample_groups

Returns the list of SampleGroups associated with this DC.

screenings

Returns the list of Screening objects associated with this DC.

snapshot1

One of four possible fields to store file paths to image files relating to the data collection

snapshot2

One of four possible fields to store file paths to image files relating to the data collection

snapshot3

One of four possible fields to store file paths to image files relating to the data collection

snapshot4

One of four possible fields to store file paths to image files relating to the data collection

status

Returns a string representing the current data collection status.

time_exposure

Exposure time per frame in seconds

transmission

Beam transmission, in per cent

wavelength

Beam wavelength in Angstrom

class ispyb.model.datacollection.DataCollectionGroup(dcgid, db_conn, preload=None)[source]

An object representing a DataCollectionGroup database entry. The object lazily accesses the underlying database when necessary and exposes record data as python attributes.

container

Returns the container information for the DataCollectionGroup sample.

dcgid

Returns the DataCollectionGroupID.

experiment_type

The type of the underlying experiment,for example ‘Mesh’ describes what is also known as a grid scan

gridinfo

Returns a GridInfo object.

reload()[source]

Load/update information from the database.

Detector

class ispyb.model.detector.Detector(detectorid, db_conn, preload=None)[source]

An object representing a Detector database entry. The object lazily accesses the underlying database when necessary and exposes record data as python attributes.

distance_max

The maximum sample-detector distance (mm)

distance_min

The minimum sample-detector distance (mm)

id

Returns the detectorId

manufacturer

The detector manufacturer

model

The detector model

pixel_size_horizontal

The pixel size in the horizonal direction (µm)

pixel_size_vertical

The pixel size in the vertical direction (µm)

pixels_x

Detector number of pixels in x

pixels_y

Detector number of pixels in y

reload()[source]

Load/update information from the database.

sensor_thickness

The detector sensor thickness (µm)

serial_number

The detector serial number

type

The detector type, e.g. ‘Photon Counting’ or ‘CCD’

ProcessingJob

class ispyb.model.processingjob.ProcessingJob(jobid, db_area)[source]

An object representing a ProcessingJob database entry. The object lazily accesses the underlying database when necessary and exposes record data as python attributes.

DCID

Returns the main data collection id.

automatic

Returns whether this processing job was initiated as part of automatic data processing.

data_collection

Returns the DataCollection model object for the main data collection of the ProcessingJob.

jobid

Returns the ProcessingJob ID.

reload()[source]

Load/update information from the database.

sweeps

Returns a list of ProcessingJobImageSweeps involved in this processing job.

class ispyb.model.processingjob.ProcessingJobImageSweep(dcid, start, end, sweep_id, db_area)[source]

An object representing an image sweep for a processing job. Each image sweep has a data collection id, a start and an end image, and an image sweep id.

DCID

Returns the data collection id.

data_collection

Returns the DataCollection model object for the data collection of this sweep.

end

Returns the end image number of the sweep

start

Returns the start image number of the sweep

sweep_id

Returns the processingJobImageSweepId

class ispyb.model.processingjob.ProcessingJobImageSweeps(jobid, db_area)[source]

An object representing the list of image sweeps for a ProcessingJob database entry. The object lazily accesses the underlying database when necessary and exposes the sweeps as a list.

reload()[source]

Load/update information from the database.

class ispyb.model.processingjob.ProcessingJobParameterValue(key, value, parameter_id)[source]

An object representing a key/value parameter pair. The object behaves like the value string, but also contains a .key and .parameter_id attribute.

key

Returns the parameterKey

parameter_id

Returns the processingJobParameterId

class ispyb.model.processingjob.ProcessingJobParameters(jobid, db_area)[source]

An object representing the parameters for a ProcessingJob database entry. The object lazily accesses the underlying database when necessary and exposes the parameters both as a list and in a dictionary-like fashion.

reload()[source]

Load/update information from the database.

class ispyb.model.processingjob.ProcessingJobPrograms(jobid, db_area)[source]

An object representing the programs working on a ProcessingJob. The object lazily accesses the underlying database when necessary and exposes the programs as a list of AutoProcProgam objects.

reload()[source]

Load/update information from the database.

ProcessingProgram

These objects correspond to entries in the ISPyB table AutoProcProgram.

class ispyb.model.processingprogram.ProcessingProgram(app_id, db_area, preload=None)[source]

An object representing an AutoProcProgram database entry. The object lazily accesses the underlying database when necessary and exposes record data as python attributes.

app_id

Returns the AutoProcProgramID.

job_id

Returns the associated ProcessingJob ID (if any).

reload()[source]

Load/update information from the database.

status_text

Returns a human-readable status.