Comments (5)
From @patryk-w
def get_half_fastccd_flatfield(light, darks, flat=None, limits=(0.6, 1.4),
module_width=480, right_side=0):
"""Calculate flat field for the working module of the fCCD
This function calculates the flat field correction array for the fCCD
detector with only one of the modules working (right module), setting the
other half to NaNs.
Parameters:
-----------
light (int): transient scan id for the flat field,
darks (array of ints): transient scan id for the dark images,
flat (ndarray): flatfield image (optional)
Returns
-------
flat_corrected (ndarray): corrected flat field array for the whole fccd
detector including only the working module
"""
light = db[int(light)]
dark = []
if darks is not None:
for d in darks:
if d is not None:
dark.append(db[(int(d))])
else:
dark.append(None)
else:
dark = None
flat_images = get_images_to_3D(get_fastccd_images(light, dark))
flat_image = stackmean(flat_images)
flat = flat_image[:, flat_image.shape[-1] - module_width : flat_image.shape[-1] - right_side]
limits = np.array(limits)
limits = np.nanmedian(flat) * limits
flat[flat < np.min(limits)] = np.nan
flat[flat > np.max(limits)] = np.nan
flat = np.nanmean(flat) / flat
flat_corrected = np.empty_like(flat_image)
flat_corrected[:, :] = np.nan
flat_corrected[:, flat_image.shape[-1] - module_width:flat_image.shape[-1] - right_side] = flat
flat_corrected = np.rot90(flat_corrected)
removed = np.sum(np.isnan(flat))
if removed != 0:
msg = 'Flat field correction removed {} pixels'.format(removed)
msg += ' ({:.2f}%) out of the working part of the detector'.format(removed * 100 / flat.size)
print(msg)
return flat_corrected
from csxtools.
Thanks for posting the modified function.
I think what we actually want, however, is an additional argument to get_half_fastccd_flatfield
that specifies a minimum_ADUs
, below which we consider the fCCD to have not detected any phonons. This can be a variable number, which is set to a default that we consider sensible. If pixels are below this they are set to np.NaN
from the outset.
from csxtools.
@mpmdean I think using a threshold makes for the most generic solution. However, we should either edit the original function or make a new function that isn't specified for half of the ccd.
In this way, the new function can be generically applied no matter the mode the ccd is running (framestore, non-framestore, with or without overscan) and is more robust than the original function created many years ago.
from csxtools.
we've noticed that the levels on the broken side change. This makes it a little hard to use a general threshold in an automated way. Lets just get something that works now.
For future threshold, we can now build some historical data for generalized testing of whatever this new function will be. There is a new function that labels the flatfield data appropriately at csx ct_flatfield()
from csxtools.
sophisticated fix is a global issue (half or not, FCCD or not). Making new issue for enhancement request.
from csxtools.
Related Issues (20)
- make csx tools load multiple scan_ids HOT 6
- image_stack_to_movie is broken HOT 1
- get_fastccd_images cannot process all instances of recorded data HOT 2
- roi argument for get_fastccd_images() is broken ... plus some flatfield dependency discussion HOT 23
- KeyError: 'AD_HDF5' for 1.14 for get_fastccd_flatfield() and get_fastccd_images() HOT 7
- Should we change default behavior get_fastccd_images to use a flatfield of (almost) all ones? HOT 3
- get_fastccd_images() does not work with roi given as input HOT 3
- swmr says it is enabled but it doesn't seem to work HOT 1
- Strange error related to dark image scan with x2 gain HOT 3
- Logging module no longer works
- Remove hard-coded rows and columns because this changes HOT 1
- Potential place for controlling dark image searching HOT 1
- flat field issue HOT 3
- conda packaging for Python 3.10 HOT 2
- Fix deprecation warnings on tests. HOT 6
- ENH more automation of flatfield correction HOT 1
- homework for new helpers modules HOT 1
- helpers.overscan copy-paste error for right-side of detector
- flake8 style needed for new modules
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csxtools.