instrument_model¶
Instrument Model from NeXus files
Makes use of NeXus classes and NXtransformations to build a structure of the instrument from a scan file.
NXBeam
¶
NXbeam object
Source code in mmg_toolbox/nexus/instrument_model.py
energy_wavelength()
¶
Return beam energy in keV and wavelength in A
Returns:
| Type | Description |
|---|---|
|
incident_energy, incident_wavelength |
Source code in mmg_toolbox/nexus/instrument_model.py
NXDetector
¶
NXdetector object
Source code in mmg_toolbox/nexus/instrument_model.py
NXDetectorModule
¶
NXdetector_module object
Source code in mmg_toolbox/nexus/instrument_model.py
117 118 119 120 121 122 123 124 125 126 127 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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
corners(frame)
¶
return corners of the detector module at this frame in scan
Source code in mmg_toolbox/nexus/instrument_model.py
pixel_direction(point)
¶
Return direction of pixel in lab frame
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Pixel
|
(n, i, j) == (frame, slow_axis_pixel, fast_axis_pixel) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
[dx, dy, dz] unit vector |
Source code in mmg_toolbox/nexus/instrument_model.py
pixel_position(point)
¶
Return position of pixel (n, i, j) in lab frame n = frame in scan i = pixel along slow axis j = pixel along fast axis
Source code in mmg_toolbox/nexus/instrument_model.py
pixel_wavevector(point, wavelength_a)
¶
Return wavevector of pixel in lab frame
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Pixel
|
(n, i, j) == (frame, slow_axis_pixel, fast_axis_pixel) |
required |
wavelength_a
|
wavelength in Angstrom |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
[x, y, z] in inverse Angstrom |
Source code in mmg_toolbox/nexus/instrument_model.py
shape()
¶
Return scan shape of module (n, i, j) Where: n = frames in scan i = pixels along slow axis j = pixels along fast axis
NXInstrumentModel
¶
NXInstrumentModel object
Source code in mmg_toolbox/nexus/instrument_model.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
all_pixels_hkl()
¶
Convert all pixel coordinates for the detector to hkl
Returns an array of hkl coordinates with length n * i * j, where n is the number of detector frames, i and j are the number of detector pixels along the slow and fast axis, respectively.
Warning - this function is quite slow due to the large array it creates.
Returns:
| Type | Description |
|---|---|
ndarray
|
array([[h, k, l]]) |
Source code in mmg_toolbox/nexus/instrument_model.py
detector_border_hkl(frame=None)
¶
Return list of coordinates in hkl for the boundary of the detector
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
int | None
|
int frame number, of None to use the middle frame. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
array([[h, k, l]]) |
Source code in mmg_toolbox/nexus/instrument_model.py
detector_q(point=(0, 0, 0))
¶
return wavevector transfer, kf-ki, of first detector module, in lab frame
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Pixel
|
(n, i, j) == (frame, slow_axis_pixel, fast_axis_pixel) |
(0, 0, 0)
|
Returns:
| Type | Description |
|---|---|
ndarray
|
[x, y, z] in inverse Angstrom |
Source code in mmg_toolbox/nexus/instrument_model.py
frame_pixels_hkl(frame=None)
¶
Convert all pixel coordinates for a detector frame to hkl coordinates
Returns an array of hkl coordinates with length i * j, where i and j are the number of detector pixels along the slow and fast axis, respectively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
int | None
|
int frame number, of None to use the middle frame. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
array([[h, k, l]]) |
Source code in mmg_toolbox/nexus/instrument_model.py
hkl(point=(0, 0, 0))
¶
return hkl coordinate of pixel coordinate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Pixel
|
(n, i, j) == (frame, slow_axis_pixel, fast_axis_pixel) |
(0, 0, 0)
|
Returns:
| Type | Description |
|---|---|
tuple[float, float, float]
|
[h, k, l] |
Source code in mmg_toolbox/nexus/instrument_model.py
hkl2q(hkl)
¶
Returns wavecector direction for given hkl
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hkl
|
tuple[float, float, float] | ndarray
|
Miller indices, in units of reciprocal lattice vectors |
required |
Returns:
| Type | Description |
|---|---|
|
Q position in inverse Angstroms |
Source code in mmg_toolbox/nexus/instrument_model.py
pixel2hkl(frame, pixel_i, pixel_j)
¶
Convert pixel coordinates to hkl
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
int
|
integer detector frame number |
required |
pixel_i
|
int | float
|
slow axis pixel index |
required |
pixel_j
|
int | float
|
fast axis pixel index |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float, float]
|
(h, k, l) |
Source code in mmg_toolbox/nexus/instrument_model.py
shape()
¶
Return scan shape from the first detector module (n, i, j) Where: n = frames in scan i = pixels along slow axis j = pixels along fast axis
Source code in mmg_toolbox/nexus/instrument_model.py
NXSsample
¶
NXsample object
Source code in mmg_toolbox/nexus/instrument_model.py
compare_diffcalc_ub()
¶
Compare difference between UB from sample/ub_matrix and from DifCalc
hkl2q(hkl, index=0)
¶
Returns wavevector direction for given hkl in lab space
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hkl
|
tuple[float, float, float] | ndarray
|
Miller indices (h, k, l), in units of reciprocal lattice vectors |
required |
index
|
int
|
index of scan |
0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Q position in inverse Angstroms |