Skip to content

equivalence azimuth and radial units#2395

Merged
kif merged 10 commits intosilx-kit:mainfrom
EdgarGF93:azimuthunits_fix
Jan 30, 2025
Merged

equivalence azimuth and radial units#2395
kif merged 10 commits intosilx-kit:mainfrom
EdgarGF93:azimuthunits_fix

Conversation

@EdgarGF93
Copy link
Copy Markdown
Collaborator

From #2389

@kif
Copy link
Copy Markdown
Member

kif commented Jan 24, 2025

Overall, it looks good. Can you implement a non-regression test, just on the radial & azimuthal range values...

@EdgarGF93 EdgarGF93 added the work in progress Don't review label Jan 26, 2025
@EdgarGF93 EdgarGF93 added ready to merge Please review work in progress Don't review and removed work in progress Don't review ready to merge Please review labels Jan 29, 2025
@EdgarGF93 EdgarGF93 added ready to merge Please review and removed work in progress Don't review labels Jan 29, 2025
@EdgarGF93
Copy link
Copy Markdown
Collaborator Author

EdgarGF93 commented Jan 29, 2025

Now, the integrations with/without chi_discontinuity_at_zero, with degrees/radians:
is consistent between units and radian conversion is correct

image

With the main branch:
image

Script:

from pyFAI import detector_factory
from pyFAI.calibrant import get_calibrant
from pyFAI.integrator.azimuthal import AzimuthalIntegrator
from pyFAI.gui.jupyter import plot1d, plot2d, subplots
import matplotlib.pyplot as plt
from pyFAI.units import to_unit
from pyFAI.units import get_unit_fiber
import numpy

if __name__ == "__main__":
    cal = get_calibrant("LaB6")
    det = detector_factory("Eiger_4M")
    ai = AzimuthalIntegrator(detector=det, wavelength=1e-10, dist=0.1,
                             poni1=0.1, poni2=0.1,
                             )
    data = cal.fake_calibration_image(ai=ai)
    
    ai.chiDiscAtPi = False

    CONFIGS = [
    {
        "data" : data,
        "npt_rad" : 1000,
        "npt_azim" : 360,
        "unit" : (to_unit("q_nm^-1"), to_unit("chi_deg")),
        "radial_range" : [5,20],
        "azimuth_range" : [-20,20],
    },
    {
        "data" : data,
        "npt_rad" : 1000,
        "npt_azim" : 360,
        "unit" : (to_unit("q_nm^-1"), to_unit("chi_deg")),
        "radial_range" : [5,20],
        "azimuth_range" : [160,200],
    },
    {
        "data" : data,
        "npt_rad" : 1000,
        "npt_azim" : 360,
        "unit" : (to_unit("q_nm^-1"), to_unit("chi_rad")),
        "radial_range" : [5,20],
        "azimuth_range" : [-0.35, 0.35],
    },
     {
        "data" : data,
        "npt_rad" : 1000,
        "npt_azim" : 360,
        "unit" : (to_unit("q_nm^-1"), to_unit("chi_rad")),
        "radial_range" : [5,20],
        "azimuth_range" : [1.8, 3.5],
    },
    ]
    ai.reset()
    fig, ax = subplots(ncols=4, nrows=2, figsize=(15,5))
    for ind_r, chidisc in enumerate([True, False]):
        ai.reset()
        ai.chiDiscAtPi = chidisc
        for ind_c, config in enumerate(CONFIGS):
            res = ai.integrate2d(**config)
            plot2d(result=res, ax=ax[ind_r, ind_c], label=f"chidisc={chidisc}, az_range={config['azimuth_range']}")
            ax[ind_r, ind_c].set_xlabel("")
    plt.show()

@EdgarGF93 EdgarGF93 added work in progress Don't review ready to merge Please review and removed ready to merge Please review work in progress Don't review labels Jan 29, 2025
@kif kif merged commit 04e2c43 into silx-kit:main Jan 30, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Please review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants