In [1]:
import numpy as np
from databroker import DataBroker, get_table
from csxtools.utils import get_fastccd_images, get_images_to_4D, get_images_to_3D
from csxtools.ipynb import image_stack_to_movie, show_image_stack
%matplotlib inline
from matplotlib import pyplot as plt
import timeit
import psutil
Set the logger level to info to see logging output, if required!
In [ ]:
#import logging
#logging.getLogger().setLevel(logging.INFO)
In [ ]:
bgnd = DataBroker['ce5042b7-00ae-49ca-9b11-b10c5661aaaa'] #[52440]
In [ ]:
data = DataBroker['b2596f8e-d220-4aea-8a55-8ccb17cbdacc'] #[52436]
In [ ]:
images = get_fastccd_images(data, (bgnd, None, None), tag='fccd_image_lightfield')
The returned images object is a 4D stack of images of shape (N, M, y, x) where N is the number of events. This is - for example - the number of data points in a scan. M is the number of images collected at each point, while y and x are the size of the CCD chip.
As the data was collected as a single ct(), there is only one event. Lets select that.
In [ ]:
stack = images[0]
In [ ]:
stack[0]
We can use this as a PIMS object, or we could convert it to a image stack using the get_images_to_4D() function
In [ ]:
arr = get_images_to_4D(images)
arr.shape
In [ ]:
arr_3d = get_images_to_3D(images)
arr_3d.shape
In [ ]:
arr[0][0] # The first image, corrected
In [ ]:
show_image_stack(stack, (-100, 100))
In [ ]:
image_stack_to_movie(stack[20:120], figsize=(12, 10), vmin=-20, vmax=20)
In [ ]:
images = get_fastccd_images(data, (bgnd, None, None), tag='fccd_image_lightfield', roi = [200,100,150,175])
In [ ]:
stack = images[0]
stack.shape
In [ ]:
show_image_stack(stack, (-100, 100))
In [ ]:
n_runs = 5
In [ ]:
t = timeit.timeit('get_fastccd_images(data, (bgnd, None, None), tag=\'fccd_image_lightfield\')',
globals=globals(), number=n_runs)
print("Image conversion took {:.3f} seconds".format(t / n_runs))
In [ ]:
t = timeit.timeit('get_fastccd_images(data, (bgnd, None, None), tag=\'fccd_image_lightfield\', roi = (200,100,400,100))',
globals=globals(), number=n_runs)
print("Image conversion took {:.3f} seconds".format(t / n_runs))
In [ ]:
import csxtools
csxtools.__version__
In [ ]:
import databroker
databroker.__version__
In [16]:
mem = psutil.virtual_memory()
mem
Out[16]:
In [19]:
mem.precent
In [ ]: