nabu.app.create_distortion_map_from_poly module

nabu.app.create_distortion_map_from_poly.create_distortion_maps_entry_point(user_args=None)[source]

This application builds two arrays. Let us call them map_x and map_z. Both are 2D arrays with shape given by (nz, nx). These maps are meant to be used to generate a corrected detector image, using them to obtain the pixel (i,j) of the corrected image by interpolating the raw data at position ( map_z(i,j), map_x(i,j) ).

This map is determined by a user given polynomial P(rs) in the radial variable rs = sqrt( (z-center_z)**2 + (x-center_x)**2 ) / (nx/2) where center_z and center_x give the center around which the deformation is centered.

The perfect position (zp,xp) , that would be observed on a perfect detector, of a photon observed at pixel (z,x) of the distorted detector is:

(zp, xp) = (center_z, center_x) + P(rs) * ( z - center_z , x - center_x )

The polynomial is given by P(rs) = rs *(1 + c2 * rs**2 + c4 * rs**4)

The map is rescaled and reshifted so that a perfect match is realised at the borders of a horizontal line passing by the center. This ensures coerence with the procedure of pixel size calibration which is performed moving a needle horizontally and reading the motor positions at the extreme positions.

The maps are written in the target file, creating it as hdf5 file, in the datasets

“/coords_source_x” “/coords_source_z”

The URLs of these two maps can be used for the detector correction of type “map_xz” in the nabu configuration file as in this example

[dataset] … detector_distortion_correction = map_xz detector_distortion_correction_options = map_x=”silx:./map_coordinates.h5?path=/coords_source_x” ; map_z=”silx:./map_coordinates.h5?path=/coords_source_z”

nabu.app.create_distortion_map_from_poly.create_maps_x_and_z(args_dict)[source]

This method is meant for those applications which wants to use the functionalities of the poly2map entry point through a standar python API. The argument arg_dict must contain the keys that you can find in cli_configs.py:

CreateDistortionMapHorizontallyMatchedFromPolyConfig

Look at this files for variables and their meaning and defaults Parameters:

args_dict : dict
      a dictionary containing keys : center_x, center_z, nz, nx,  c2, c4, axis_pos
Returns:

max_x, map_z, new_rot_pos