Dear Guilherme,
On Wed, Sep 25, 2019 at 2:41 PM Guilherme Calligaris via
xrayutilities-users <xra...@li...> wrote:
> Hi all,
>
> I'm having difficulties in progressing to make pseudo-angles like
> constraints for the Q2AngFit, under q2ang_fit module. I'm hoping that this
> mailing list is the right way to discuss matters like this.
>
You asked at the right place.
> It might be straightforward, but I am not an expert in python (I'm trying
> my best to reach a reasonable programming level). I did notice that inside
> the q2ang_fit.py, it has an exitAngleConst function that is supposed to
> guide users like me. However, I didn't quite get it how to use such
> constraints yet.
>
I added this functionality once very quickly because I needed it but its
not very well documented. I am afraid at the moment you have to read a bit
the code to understand how it works. The "contraints" argument to Q2AngFit
is in principle passed unchecked to scipy.optimize.minimize. Therefore the
documentation of this function (
https://docs.scipy.org/doc/scipy-1.3.0/reference/generated/scipy.optimize.minimize.html#scipy.optimize.minimize)
is your best reference. Note that the SLSQP algorithm is used.
I added an issue on Github to remind me that the documentation of this
needs improvement (https://github.com/dkriegner/xrayutilities/issues/85)
If you find issues when using this please report them also there!
> The plan is to make pseudo-angles constraints in a 4S+2D diffractometer
> such as the ones implemented in SPEC (Certified Scientific Software) and H.
> You (J. Appl. Cryst. (1999), 32, 614).
>
This should be possible. But be aware that a numerical procedure is used in
Q2AngFit which not always (depending on the starting values ->
"startvalues" agrument) find the correct solution. So this approach is
unfortunately not as stable as the implementation in SPEC. the advantage is
it works for any given goniometer as long as enough degrees of freedom are
fixed of course!
> I'm not sure, for instance, if the constraints need to be inserted like a
> function inside the q2ang_fit.py (somehow similar to the exitAngleConst
> function) or would I define the constraints in the same program that calls
> the Q2AngFit function, using its constraints parameter.
> Hope I made my self understandable.
>
I think you should find what you need at
https://docs.scipy.org/doc/scipy-1.3.0/reference/generated/scipy.optimize.minimize.html#scipy.optimize.minimize
But yes you have to define functions like the exitAngleConst function which
return 0 when your constraint is fulfilled and pass them to Q2AngFit as
explained in the scipy.optimize.minimize documentation.
kind regards
Dominik
> Any thoughts or examples regarding such an approach are welcome and much
> appreciated.
>
> Thanks in advance for your time,
>
> Guilherme
>
> _______________________________________________
> xrayutilities-users mailing list
> xra...@li...
> https://lists.sourceforge.net/lists/listinfo/xrayutilities-users
>
|