P2866 updates
We will add some quick fixes:
- Allow loading a list of dark images
- Allow centroid to return the raw hits (instead of spectrum)
Merge request reports
Activity
added 1 commit
- bd45362a - Centroiding algorithm can return individual hits
You can now get x- and y-arrays of the individual hits sorted by train number by specifying
return_hits=True
when calling the centroiding function. A known bug is that this now crashes anyprint
call referring to your data (because that assumes the values can be flattened to scalars).h = hRIXS() h.PROPOSAL = 2866 pixel0 = 1080 h.FIELDS = ['hRIXS_det','hRIXS_index','hRIXS_norm','hRIXS_delay'] h.Y_RANGE = slice(pixel0,2000) h.STD_THRESHOLD = 3.5 # default 3.5 h.CURVE_B = -3.695346575286939e-07 h.CURVE_A = 0.024084479232443695 # Ranges for centroiding h.RANGE = 0,1100 h.BINS = 968 data = h.from_run(467,2866) tot = h.centroid(data, return_hits=True) x, y = np.concatenate([tot.xhits.values[i] for i in range(len(tot))]),\ np.concatenate([tot.yhits.values[i] for i in range(len(tot))]) plt.plot(x, y, alpha = 0.1, marker = '.', linestyle='none') plt.xlim([0,1000]) plt.ylim([0,2048])
Edited by Hampus Wikmark KreugerI found that adding
sys.path.insert(0, '/home/hwikmark/2866test/ToolBox/src')
(i.e. the absolute path to where the code has been cloned) seems to enable the jupyter notebook to load the development code. The insert 0 will put this path as the first place Python looks for thetoolbox_scs
module.I stumble on this by chance, but following: https://rtd.xfel.eu/docs/scs-toolbox/en/latest/#alternative-manual-toolbox-installation
you can clone the toolbox in your home directory, install it under the exfel_anaconda3 environment. Then if you run your notebook with the xfel kernel it will use that one. To check which toolbox is used you can:
import toolbox_scs as tb print(tb.__file__)
added 1 commit
- 92cb6a1f - Allow load_dark to load an array of dark images
I think the part
x, y = np.concatenate([tot.xhits.values[i] for i in range(len(tot))]),
np.concatenate([tot.yhits.values[i] for i in range(len(tot))])is unnecessarily complicated. Could one simply have an attribute tot.hits for as a 2D array or is there some other stuff with xhits and yhits?
Edited by Johannes NiskanenI agree that we could have a "hits" 2D array instead. The concatenation, however, is bringing together the xhits/yhits for all the different trains in the run. I think if we had a "hits" array we would still be left with something like:
x, y = np.concatenate([tot.hits.values[i, 0] for i in range(len(tot))]), np.concatenate([tot.hits.values[i, 1] for i in range(len(tot))])
or saving everything as a hit-array and plotting
hit_array[:,0]
for x, etc.This is of course only in the context of plotting. If you have a use-case where a 2D array would be more useful, by all means we can change it, this is how I started doing it until I started trying to plot them. It would be a (tiny) bit of data overhead but we could also add both separate x- and y-arrays and a 2D one
Edit: Sorry @niskanen I thought I posted this comment last week but it was apparently "in review" the whole time...
Edited by Hampus Wikmark Kreuger
added 4 commits
- f68b7f75 - Load_dark optionally generates a mask to filter bad pixels
- 8e8e7e9f - Return_hits returns a "hits" array with both x and y of hits
- a2ffa1b9 - Merge branch 'p2866_updates' of https://git.xfel.eu/gitlab/SCS/ToolBox into...
- bd425898 - Merge branch 'p2866_updates_darksubtraction' into 'p2866_updates'
Toggle commit listI have added dark subtraction and also the mask for hot pixels (that we also find using the dark images).
The way the hot pixel detection works at the moment is that each pixel is compared to an "average" (of a region we set using ´MASK_AVG_X´ and ´MASK_AVG_Y´). If the difference is higher than ´DARK_MASK_THRESHOLD´ we will replace it by the average. This applies to both the dark image and the sample image.
The above image shows a few different thresholds. I have set the default to 100 now but this can of course be changed. Above 150 this seems more or less useless (corrected and uncorrected are the same), however as seen below higher thresholds may still remove some hot pixels in other places. I think another takeaway is that subtracting by the dark image (especially with hot pixel correction) mostly adds noise to the spectrum.
In the above "vertical squashes" of dark images, with and without hot pixel correction, we see that thresholds of 50 and below cause some artifacts. This is because we (as of now) the average is taken at the far "right" of the detector screen (close to our data) and the average is slightly different on the other side of the bright line in the middle.
Edited by Hampus Wikmark KreugerI think this is a good idea. I forgot about the
abs
but added this to avoid some strange effects of (what later turned out to be) an incorrect calculation of the average.Edited by Hampus Wikmark Kreuger
added 7 commits
- 71e16cc5 - Initial commit with alignment function draft
- 35e26f66 - A few comments clarified
- e5d7a675 - Alignment routine runs, but needs a careful validation & debugging.
- 36ac54ed - align_readouts() now runs, but has some bugs still. It can group
- a5388fee - Some nasty bugs fixed.
- 8f178956 - Align_readouts() should work now.
- 1898f7ac - Merge branch 'p2866_updates_jhns_alignment' into 'p2866_updates'
Toggle commit listmentioned in commit 563fcc83