Skip to content

Commit

Permalink
make dark field optional
Browse files Browse the repository at this point in the history
  • Loading branch information
KedoKudo committed Sep 16, 2024
1 parent 7b511ae commit 79460ca
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/imars3d/backend/preparation/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class normalization(param.ParameterizedFunction):
flats = param.Array(
doc="3D array of flat field images (aka flat field, open beam), axis=0 is the image number axis.", default=None
)
darks = param.Array(doc="3D array of dark field images, axis=0 is the image number axis.", default=None)
darks = param.Array(doc="3D array of optional dark field images, axis=0 is the image number axis.", default=None)
max_workers = param.Integer(
default=0,
bounds=(0, None),
Expand All @@ -59,10 +59,15 @@ def __call__(self, **params):
self.max_workers = clamp_max_workers(params.max_workers)
logger.debug(f"max_worker={self.max_workers}")

# use median filter to remove outliers from flats and darks
# NOTE: this will remove the random noises coming from the environment.
# process flats (formerly known as open beam, white field)
self.flats = np.median(params.flats, axis=0)
self.darks = np.median(params.darks, axis=0)

# process darks (formerly known as black field)
if params.darks is None:
self.darks = np.zeros_like(self.flats)

Check warning on line 67 in src/imars3d/backend/preparation/normalization.py

View check run for this annotation

Codecov / codecov/patch

src/imars3d/backend/preparation/normalization.py#L67

Added line #L67 was not covered by tests
else:
self.darks = np.median(params.darks, axis=0)

# apply normalization
_bg = self.flats - self.darks
_bg[_bg <= 0] = 1e-6
Expand Down

0 comments on commit 79460ca

Please sign in to comment.