SAXS Module API

class SAXS.calibration(config, mask=None, attachment=None)

This class represents a calibration for SAXS diffraction. After initialization, the integrate() method can compute the radial intensity very fast.

Parameters:
  • config (dict) – the calibration json object as dictionary Calibration file Reference:
  • mask (dict) – The mask of the list to use for this instance
  • attachment (dict) – If mask is not to be read from filesystem it must be provided as attachment
integParameters(Intensity)

function to calculate the integral parameters between qStart and qStop returns I0, I1, I2

integrate(image)

Integrate a picture.

Parameters:image (numpy.array(dim=2)) – Sensor image to integrate as 2d NumPy array
Returns:Returns Angle and intensity vector as a tuple (angle,intensity)
integratechi(image, path, picture)

Integrate and save to file in “chi” format.

Parameters:
  • image (np.array()) – Image to integrate as numpy array
  • path (string) – Path to save the file to
Returns:

Scattering curve data as numpy array

integrateerror(image)

Integrates an image and computes error estimates.

Parameters:image (np.array()) – Image to integrate as numpy array
Returns:The intensity the standard deviation and the Poisson statistics error in a numpy array.
plot(image, outputfile='', startplotat=0, fig=None)

Plot integrated function for image in argument.

Parameters:
  • image (numpy.array(dim=2)) – Sensor image to integrate as 2d NumPy array
  • outputfile (string) – File to write plot to. Might be any image format supported by matplotlib.
  • startplotat (integer) – radial point from which to start the plot
polcorr(Pfrac, rot)

Polarization Correction

class SAXS.slice(conf, sliceconf, attachments=[])

Initializes slice integration

Parameters:
  • conf (dictionary) – Detector calibration
  • sliceconf (dictionary) – The part of detector calibration which deals with this slice.
  • attachments (dictionary) – Mask data.
integratechi(image, path, picture)

Integrate and save to file in “chi” format.

Parameters:
  • image (np.array()) – Image to integrate as numpy array
  • path (string) – Path to save the file to
Returns:

Scattering curve data as json structure

plot(image, outputfile='', startplotat=0, fig=None)

dummy function in order to not trip up image queue

SAXS.calc_theta(r, phi, d, tilt, tiltdir)

Calculates the difraction angle from pixel coordinates. It does work when called with arrays. See Geometry

Parameters:
  • r (float) – Distance to beamcenter.
  • phi (float) – Angle[rad] from polar sensor plane coordinates.
  • d (float) – distance to difraction center.
  • tilt (float) – Angle[rad] of sensor plane tilt.
  • tiltdir (float) – Angle[rad] of direction of tilt.
Returns:

theta

SAXS.scalemat(Xsize, Ysize, ov)

Computes a scaling projection for use in computing the pixel weights for integration

Parameters:
  • Xsize (int) – Picture size in X direction.
  • Ysize (int) – Picture size in Ydirection.
  • ov (int) – Number of oversampling ticks in x ynd y direction
  • corr (array) – Polarizationn an other correction factors
Returns:

sparce matrix toing the scaling

SAXS.openmask(mfile, attachment=None)

Open the mask file especialy the *.msk file. Unfortunately there is no library module for msk files available also no documentation. So, for the msk file, we have a very brittle hack it works for our sensor. Nevermind any other resolution or size.

Parameters:config (object) – Calibration config object.
Returns:Mask as logical numpy array.
SAXS.convert()

This implements the functionality oft The Converter. It parses the commandline options and converts the Fit2d info file to the JSON data used by the SAXS.callibration class.

SAXS.saxsdog()

This implements the functionality of The Saxsdog

class SAXS.imagequeue(Cals, options, directory, conf)

This class keeps a queue of images which may be worked on in threads.

Parameters:
  • Cal (SAXS.calibration) – The SAXS Calibration to use for the processing
  • options (optparser) – The object with the comandline options of the saxsdog
  • args (list) – List of command line options
fillqueuewithexistingfiles()

Fill the queue with the list of images that is already there.

start()

Start threads and directory observer.

class SAXS.Server(conf, serverid, stopflag=None, serverdir=None)

class to manage a saxsdog server

authenticate(data)

check signature of request

commandhandler(object, attachment)
start()

start server loop

start_image_queue(object, attachment)

prepare new image queue start processing threads

SAXS.initcommand(options, arg, conf)

Interface for issuing leash commands

SAXS.validateResponse(message)

Validate response from saxsdog server against the schema.