silx-kit / pyFAI

Fast Azimuthal Integration in Python
Other
106 stars 95 forks source link

In script calibration #212

Closed CJ-Wright closed 9 months ago

CJ-Wright commented 9 years ago

Would it be possible to have a function which we could call to produce the calibration configuration dictionary (the key word arguments for pyFAI.geometry.Geometry)? My hope is that the signature would look like this:

geometry_keywords = magic_calibration_function(
img, ring_positions, d_spacings, detector, mask, initial_guess_dictionary)

Parameters
----------------
img: NxN ndarray
    The diffraction image of the calibrant, as a NxN numpy array
ring_positions: NxM ndarray
    The positions of all the rings to calibrate against
d_spacings: ndarray
    The d spacings of the calibrant as a numpy array
detector: str or detector object
    The detector name or object itself
mask: NxN ndarray
    The mask for the detector as a boolean NxN array
initial_guess_dictionary: dict
    A dictionary containing the initial guesses for the refinement

Returns
----------
dict:
   The dictionary of keywords arguments needed to init a geometry object

My hope is that this would eliminate as much user involvement and file IO as possible, as the peaks will have already been found, and all the file IO will be accomplished before or after calling this function. Thank you very much!

kif commented 9 years ago

On Tue, 23 Jun 2015 15:13:06 -0700 "Christopher J. Wright" notifications@github.com wrote:

Would it be possible to have a function which we could call to produce the calibration configuration dictionary (the key word arguments for pyFAI.geometry.Geometry)? My hope is that the signature would look like this:

geometry_keywords = magic_calibration_function(
img, ring_positions, d_spacings, detector, mask, initial_guess_dictionary)

There is a calibration function which almost does what you are looking for:

Procedural version of calibration

def calib(img, calibrant, detector, basename="from_ipython", reconstruct=False, dist=0.1, gaussian=None, interactive=True): """ Procedural interfact for calibration

@param img: 2d array representing the calibration image
@param calibrant: Instance of Calibrant, set-up with wavelength
@param detector: Detector instance containing the mask
@param basename: output file base
@param recontruct: perform image reconstruction of masked pixel ?
@param dist: initial distance
@param gaussian: width of the gaussian used for difference of gaussian in the "massif" peak-picking algorithm
@param interactive: set to False for testing
@retrun: azimuthal integrator object
"""

You would like to inject in addition the control points ? it looks like the biggest difference. And it should not be too complicated (actually the signature of this function is not yet fixed).

Cheers,

CJ-Wright commented 9 years ago

Yes, @tacaswell has a nice way for finding/tracking the diffraction rings automatically.

kif commented 9 years ago

First of all, I would like to appologise, I confused you with Jon (also Wright)

Yes, @tacaswell has a nice way for finding/tracking the diffraction rings automatically.

Are you refering to the correlation of a debye-scherrer ring diffraction image with itself flipped H-V and R-L to get the vertical and horizontal center position ?

tacaswell commented 9 years ago

That is the first naive approach. I have some quasi-vaporware ideas based on extending my graduate work for finding interference fringes, but have not done anything with that yet.

kif commented 9 years ago

On Wed, 24 Jun 2015 14:33:25 -0700 Thomas A Caswell notifications@github.com wrote:

That is the first naive approach. I have some quasi-vaporware ideas based on extending my graduate work for finding interference fringes, but have not done anything with that yet.

Hi Thomas,

I don't know where you are now, but we are able to calibrate really obfuscated setups like this one: http://journals.iucr.org/j/issues/2015/02/00/fv5028/fv5028fig2thm.gif

But me neither, I am not yet happy with have. I am thinking on a Ridge&Valley reconstruction based on a watershed like technique ... Cheers,

Jerome.

PS: we have 3 positions opened on data-analysis, if you wish to visit the French alps :)

CJ-Wright commented 8 years ago

Out of curiosity, did the above function ever get written? It would be very helpful for doing in python data processing. Would it be possible to have the option of providing the control points? If not given run though the full GUI?

kif commented 9 months ago

A bit late ... but I guess this class does what you are looking for: http://www.silx.org/doc/pyFAI/dev/api/pyFAI.html#pyFAI.goniometer.SingleGeometry

It is intensively used in goniometer calibration, there are several tutorials available on them.