instamatic.tools
Functions
find_beam_center(img, sigma=30, m=100, kind=3)
Find the center of the primary beam in the image img
The position is
determined by summing along X/Y directions and finding the position along
the two directions independently.
Uses interpolation by factor m
to find the coordinates of the
pimary beam with subpixel accuracy.
Source code in src/instamatic/tools.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
find_beam_center_with_beamstop(img, z=None, method='thresh', plot=False)
Find the beam center when a beam stop is present.
methods: gauss, thresh
thresh
uses a threshold to segment the image. The largest blob then corresponds to the
primary beam. The center of the bounding box of the blob defines the beam center.
gauss
applies a gaussian filter with a very large standard deviation in an attempt
to smooth out the beam stop. The position of the largest pixel corresponds to the
beam center.
z = thresh: percentile to segment the image at (99) gauss: standard deviation for the gaussian blurring (50)
Source code in src/instamatic/tools.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
find_defocused_image_center(image, treshold=1)
Find the center of a defocused diffraction pattern.
Source code in src/instamatic/tools.py
192 193 194 195 196 197 198 199 200 201 202 203 |
|
find_peak_max(arr, sigma, m=50, w=10, kind=3)
Find the index of the pixel corresponding to peak maximum in 1D pattern
arr
.
First, the pattern is smoothed using a gaussian filter with standard
deviation sigma
The initial guess takes the position corresponding
to the largest value in the resulting pattern A window of size 2*w+1
around this guess is taken and expanded by factor m
to to
interpolate the pattern to get the peak maximum position with
subpixel precision.
Source code in src/instamatic/tools.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
find_subranges(lst)
Takes a range of sequential numbers (possibly with gaps) and splits them in sequential sub-ranges defined by the minimum and maximum value.
Source code in src/instamatic/tools.py
71 72 73 74 75 76 77 78 79 |
|
get_acquisition_time(timestamps, exp_time, savefig=True, drc=None)
Take a list of timestamps and return the acquisition time and overhead.
Parameters:
-
timestamps
(tuple
) –List of timestamps
-
exp_time
(float
) –Exposure time in s
-
savefig
(bool
, default:True
) –Save the resulting fit under the name
acquisition_time.png
-
drc
(str
, default:None
) –Location where to store the image
Returns:
-
Namespace with acquisition/exposure/overhead time in s
–
Source code in src/instamatic/tools.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
prepare_grid_coordinates(nx, ny, stepsize=1.0)
Prepare a list of grid coordinates nx by ny in size. The grid is centered at the center of the grid.
nx, ny: int, Defines the grid in x and y direction. The number of steps is defined by nx * ny stepsize: Distance between each grid point in x/y
returns: list of coordinates
Source code in src/instamatic/tools.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
printer(data)
Print things to stdout on one line dynamically.
Source code in src/instamatic/tools.py
186 187 188 189 |
|
relativistic_wavelength(voltage=200000)
Calculate the relativistic wavelength of electrons from the accelarating voltage.
Input: Voltage in V Output: Wavelength in Angstrom
Source code in src/instamatic/tools.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
|
to_xds_untrusted_area(kind, coords)
Takes coordinate list and turns it into an XDS untrusted area kind: rectangle, ellipse, quadrilateral coords: coordinates corresponding to the untrusted area
For definitions, see: http://xds.mpimf-heidelberg.mpg.de/html_doc/xds_parameters.html#UNTRUSTED_ELLIPSE=
coords
corresponds to a list of (x, y) coordinates of the corners of the quadrilateral / rectangle
Source code in src/instamatic/tools.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|