Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fiberunit numexpr #2349

Merged
merged 8 commits into from
Dec 6, 2024
Merged

fiberunit numexpr #2349

merged 8 commits into from
Dec 6, 2024

Conversation

EdgarGF93
Copy link
Collaborator

No description provided.

@EdgarGF93 EdgarGF93 self-assigned this Dec 5, 2024
@EdgarGF93 EdgarGF93 added the work in progress Don't review label Dec 5, 2024
@EdgarGF93
Copy link
Collaborator Author

EdgarGF93 commented Dec 5, 2024

Got a x2 in speed for FiberIntegrator.integrate2d:

from pyFAI.units import Unit, get_unit_fiber, to_unit
from pyFAI.integrator.azimuthal import AzimuthalIntegrator
from pyFAI.calibrant import get_calibrant
from pyFAI.integrator.fiber import FiberIntegrator
from pyFAI import detector_factory
import time
from pyFAI.gui.jupyter import subplots, display, plot2d
import matplotlib.pyplot as plt
import numpy

if __name__ == "__main__":
    fi = FiberIntegrator(dist=0.1, poni1=0.1, poni2=0.1, detector=detector_factory("Eiger_4M"), wavelength=1e-10)
    cal = get_calibrant("LaB6")
    data = cal.fake_calibration_image(ai=fi)
    qip = get_unit_fiber(name="qip_nm^-1")
    qoop = get_unit_fiber(name="qoop_nm^-1")

    t=time.perf_counter()
    res2d_fast = fi.integrate2d_grazing_incidence(data=data, unit_ip=qip, unit_oop=qoop)
    print(f"Fast path: {time.perf_counter()-t} s")
    fi.reset()

    qip.formula = None
    qip.equation = qip._equation
    qoop.formula = None
    qoop.equation = qoop._equation

    t=time.perf_counter()
    res2d_slow = fi.integrate2d_grazing_incidence(data=data, unit_ip=qip, unit_oop=qoop)
    print(f"Slow path: {time.perf_counter()-t} s")
    
    print(f"Max. diff intensity: {(res2d_slow.intensity-res2d_fast.intensity).max()}")
    print(f"Max. diff radial: {(res2d_slow.radial-res2d_fast.radial).max()}")
    print(f"Max. diff azimuthal: {(res2d_slow.azimuthal-res2d_fast.azimuthal).max()}")

Fast path: 0.6643166319990996 s
Slow path: 1.4383158040000126 s
Max. diff intensity: 0.0
Max. diff radial: 7.105427357601002e-15
Max. diff azimuthal: 0.0

@EdgarGF93
Copy link
Collaborator Author

can I add a script in sandbox?, it's useful for me to check that the grazing incidence results make sense

@EdgarGF93 EdgarGF93 added ready to merge Please review and removed work in progress Don't review labels Dec 5, 2024
@kif
Copy link
Member

kif commented Dec 6, 2024

Sandboxing scripts is OK. I would suggest to make it a notebook part of the documentation since we review the documentation for every release and ensure it keeps up to date.

@kif kif self-requested a review December 6, 2024 15:07
@kif
Copy link
Member

kif commented Dec 6, 2024

BTW, thanks for suggesting the usage of f-string for formatting formula, very clean and readable !

Copy link
Member

@kif kif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kif kif merged commit 3825037 into silx-kit:main Dec 6, 2024
8 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