mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-06-04 21:38:41 +02:00
added timer and file processing
This commit is contained in:
@@ -33,7 +33,7 @@ from .CtbRawFile import CtbRawFile
|
||||
from .RawFile import RawFile
|
||||
from .ScanParameters import ScanParameters
|
||||
|
||||
from .utils import random_pixels, random_pixel, flat_list, add_colorbar
|
||||
from .utils import random_pixels, random_pixel, flat_list, add_colorbar, Timer
|
||||
|
||||
|
||||
#make functions available in the top level API
|
||||
|
||||
+16
-1
@@ -2,6 +2,7 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from mpl_toolkits.axes_grid1 import make_axes_locatable
|
||||
import time
|
||||
|
||||
def random_pixels(n_pixels, xmin=0, xmax=512, ymin=0, ymax=1024):
|
||||
"""Return a list of random pixels.
|
||||
@@ -34,4 +35,18 @@ def add_colorbar(ax, im, size="5%", pad=0.05):
|
||||
divider = make_axes_locatable(ax)
|
||||
cax = divider.append_axes("right", size=size, pad=pad)
|
||||
plt.colorbar(im, cax=cax)
|
||||
return ax, im, cax
|
||||
return ax, im, cax
|
||||
|
||||
|
||||
class Timer:
|
||||
def __init__(self, label="Elapsed time:", verbose=True):
|
||||
self.label = label
|
||||
self.verbose = verbose
|
||||
def __enter__(self):
|
||||
self.start = time.perf_counter()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc, tb):
|
||||
self.elapsed = time.perf_counter() - self.start
|
||||
if self.verbose:
|
||||
print(f"{self.label} {self.elapsed:.3f}s")
|
||||
@@ -142,6 +142,25 @@ void define_pedestal_tracking_pixel_histogram_bindings(py::module &m) {
|
||||
)",
|
||||
py::arg("image").noconvert())
|
||||
|
||||
|
||||
.def("fill_from_file", &PedestalTrackingPixelHistogram::fill_from_file,
|
||||
R"(
|
||||
Fill the histogram from a file.
|
||||
|
||||
Args:
|
||||
file_path: Path to the file to fill from
|
||||
max_frames: Maximum number of frames to fill from the file (default: -1)
|
||||
)",py::call_guard<py::gil_scoped_release>(),
|
||||
py::arg("fname"), py::arg("max_frames") = -1, py::arg("verbose") = false)
|
||||
.def("process_pedestal_file", &PedestalTrackingPixelHistogram::process_pedestal_file,
|
||||
R"(
|
||||
Process a pedestal file.
|
||||
|
||||
Args:
|
||||
file_path: Path to the file to process
|
||||
max_frames: Maximum number of frames to process from the file (default: -1)
|
||||
)",py::call_guard<py::gil_scoped_release>(),
|
||||
py::arg("fname"), py::arg("max_frames") = -1, py::arg("verbose") = false)
|
||||
.def_property("n_sigma", &PedestalTrackingPixelHistogram::n_sigma,
|
||||
&PedestalTrackingPixelHistogram::set_n_sigma,
|
||||
R"(
|
||||
|
||||
Reference in New Issue
Block a user