-
Notifications
You must be signed in to change notification settings - Fork 13
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
flat field issue #80
Labels
Comments
Thanks @mpmdean . We are working on code for one big PR for various issues. For others that run into this prroblem, you may use the work around below by setting import logging
logger = logging.getLogger(__name__)
import numpy as np
from csxtools.image import rotate90, stackmean
from csxtools.utils import calculate_flatfield, get_images_to_3D, get_fastccd_images
def get_fastccd_flatfield(light, dark, flat=None, limits=(0.6, 1.4), half=False, half_args = (7, 486)):
"""MODIFIED from csxtools original: Calculate a flatfield
This routine calculates the flatfield using the
:func:calculate_flatfield() function after obtaining the images from
the headers.
Parameters
----------
light : databroker header
The header containing the light images
dark : databroker header
The header from the run containin the dark images
flat : flatfield image (optional)
The array to be used for the initial flatfield
half : calculate for just the "good" half - hard coded
Default is False
half_args : Tuple for exluding entire sides of detector (left versus right)
Left side is refers the the left side of the image after raw data is
processed with get_fastccd_images(). Default arguments are for the left side
using the FrameStore mode.
Returns
-------
array_like
Flatfield correction
"""
images = get_images_to_3D(get_fastccd_images(light, dark, flat))
images = stackmean(images)
if half == True:
#rows because "super columns" are the large 10 pixel bins, but camera is on side.
row_start, row_stop = half_args
images[:,row_start:row_stop] = np.nan
#plt.figure()
#im = plt.imshow(images, vmin =0, vmax = 500)
#cbar = plt.colorbar(im)
#cbar.set_label('ADU gain corrected')
flat = calculate_flatfield(images, limits)
removed = np.sum(np.isnan(flat))
if removed != 0:
logger.warning("Flatfield correction removed %d pixels (%.2f %%)" %
(removed, removed * 100 / flat.size))
return flat |
Issue #77 covers this |
I didn't spot that prior version of the same issue. I think this can be closed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The calculate_flatfield function has an issue when it is used with the current state of the CSX detector.
The problem is that more than 1/2 the detector is insensitive to light, so the median is not representative of the true data. The line below then means that the data and limits get re-scaled to unreal values.
csxtools/csxtools/utils.py
Line 268 in 52ff964
The text was updated successfully, but these errors were encountered: