Build Packages / Unit tests (push) Successful in 1h22m15s
Build Packages / build:windows:nocuda (push) Successful in 18m0s
Build Packages / build:windows:cuda (push) Successful in 20m30s
Build Packages / build:viewer-tgz:cpu (push) Successful in 10m32s
Build Packages / build:viewer-tgz:cuda (push) Successful in 11m39s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 8m55s
Build Packages / build:rugnux:windows (push) Successful in 11m25s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 20m6s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 16m27s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 20m19s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 15m34s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 20m25s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m36s
Build Packages / build:rpm (rocky8) (push) Successful in 17m43s
Build Packages / build:rpm (rocky9) (push) Successful in 13m34s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 21m28s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 18m19s
Build Packages / DIALS test (push) Successful in 12m36s
Build Packages / XDS test (durin plugin) (push) Successful in 6m56s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 6m48s
Build Packages / XDS test (neggia plugin) (push) Successful in 6m7s
Build Packages / Generate python client (push) Successful in 11s
Build Packages / Build documentation (push) Successful in 36s
Build Packages / Create release (push) Skipped
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 5m11s
* `rugnux --mode calibration` writes `<prefix>.json` beside the `.poni`, whose `dataset_settings` member is a `jfjoch_broker` `dataset_settings` body as it stands. * `rugnux` and `jfjoch_viewer` read PILATUS miniCBF sweeps natively, without conversion. * Masters written by other facilities open, including Eiger 1.x and third-party NXmx variants. * `rugnux` measures the beam centre on every run, and indexes with it when the file's value indexes nothing. * A detector swung out on a 2theta arm is placed where the file says it stands, and the calibration can hold the tilt fixed. * `rugnux` writes the unmerged MTZ by default, and a P1 merge beside it, so a wrong space group can be re-merged without reprocessing. * Significant improvements to symmetry handling in `rugnux`: the lattice, the point group, the setting and the systematic absences. * The `rugnux` report gives the resolution the CC1/2 fit reached, beside the range the reflections were written to. * The `rugnux` report gives the twinning statistics measured before the space group was decided, beside the ones measured after. * The `rugnux` report gives the strong-direction diffraction limit, and warns when CC1/2 is not monotone with resolution. * `rugnux` ranks screw axes on the evidence their absences carry, rather than on how many control reflections a candidate happens to have. * Twinning is no longer reported when the L-test contradicts it. * The `rugnux` report gives the detector tilt, the measured tilt and the direct beam beside the beam centre, and a post-refined beam centre is judged against the run's own measurement rather than the file's. * `--no-refine-tilt` holds the detector tilt at the value in the file, instead of zeroing it, when the calibration starts from the spots. * The `jfjoch_viewer` grid scan view draws the cells in the proportion of the scan steps, so the map has the shape of the scanned area. Reviewed-on: #76 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
178 lines
5.9 KiB
C++
178 lines
5.9 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <cmath>
|
|
#include "GridScanSettings.h"
|
|
#include "JFJochException.h"
|
|
|
|
GridScanSettings::GridScanSettings(int64_t in_n_fast,
|
|
float in_grid_step_x_um,
|
|
float in_grid_step_y_um,
|
|
bool in_snake_raster_scan,
|
|
bool in_vertical_scan)
|
|
: n_fast(in_n_fast),
|
|
n_slow(1),
|
|
n_elem(in_n_fast),
|
|
grid_elem_x_um(in_grid_step_x_um),
|
|
grid_elem_y_um(in_grid_step_y_um),
|
|
snake_scan(in_snake_raster_scan),
|
|
vertical_scan(in_vertical_scan) {
|
|
if (n_fast <= 0)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Number of elements in fast direction must be positive");
|
|
if (grid_elem_x_um == 0.0f || grid_elem_y_um == 0.0f)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Grid elements must be non-zero");
|
|
}
|
|
|
|
GridScanSettings &GridScanSettings::ImageNum(int64_t input) {
|
|
if (input < 0)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Number of elements in slow direction must be positive");
|
|
|
|
n_slow = (input + n_fast - 1) / n_fast;
|
|
n_elem = n_slow * n_fast;
|
|
return *this;
|
|
}
|
|
|
|
int64_t GridScanSettings::GetGridSizeX_step() const {
|
|
return vertical_scan ? n_slow : n_fast;
|
|
}
|
|
|
|
int64_t GridScanSettings::GetGridSizeY_step() const {
|
|
return vertical_scan ? n_fast : n_slow;
|
|
}
|
|
|
|
float GridScanSettings::GetGridSizeX_um() const {
|
|
return fabsf(GetGridStepX_um()) * static_cast<float>(GetGridSizeX_step());
|
|
}
|
|
|
|
float GridScanSettings::GetGridSizeY_um() const {
|
|
return fabsf(GetGridStepY_um()) * static_cast<float>(GetGridSizeY_step());
|
|
}
|
|
|
|
int64_t GridScanSettings::GetElementPosX_step(int64_t elem_number) const {
|
|
if (vertical_scan)
|
|
return GetElementPosSlow_step(elem_number);
|
|
else
|
|
return GetElementPosFast_step(elem_number);
|
|
}
|
|
|
|
int64_t GridScanSettings::GetElementPosY_step(int64_t elem_number) const {
|
|
if (vertical_scan)
|
|
return GetElementPosFast_step(elem_number);
|
|
else
|
|
return GetElementPosSlow_step(elem_number);
|
|
}
|
|
|
|
float GridScanSettings::GetElementPosX_um(int64_t elem_number) const {
|
|
return static_cast<float>(GetElementPosX_step(elem_number)) * fabs(GetGridStepX_um());
|
|
}
|
|
|
|
float GridScanSettings::GetElementPosY_um(int64_t elem_number) const {
|
|
return static_cast<float>(GetElementPosY_step(elem_number)) * fabs(GetGridStepY_um());
|
|
}
|
|
|
|
float GridScanSettings::GetGridStepX_um() const {
|
|
return grid_elem_x_um;
|
|
}
|
|
|
|
float GridScanSettings::GetGridStepY_um() const {
|
|
return grid_elem_y_um;
|
|
}
|
|
|
|
int64_t GridScanSettings::GetElementPosFast_step(int64_t image_number) const {
|
|
if ((image_number < 0) || (image_number >= n_elem))
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Image out of bounds");
|
|
|
|
// Snake reverses the stage direction on alternate rows in ACQUISITION order, so the parity has
|
|
// to come from the acquisition row, not from the display row GetElementPosSlow_step returns
|
|
// (the two differ by (n_slow-1) - row when the slow step is negative).
|
|
int64_t row = image_number / n_fast;
|
|
int64_t fast = image_number % n_fast;
|
|
if (GetGridElemFast_um() < 0)
|
|
fast = (n_fast - 1) - fast;
|
|
if (snake_scan && (row % 2 == 1))
|
|
fast = (n_fast - 1) - fast;
|
|
return fast;
|
|
}
|
|
|
|
int64_t GridScanSettings::GetElementPosSlow_step(int64_t image_number) const {
|
|
if ((image_number < 0) || (image_number >= n_elem))
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Image out of bounds");
|
|
|
|
int64_t slow = image_number / n_fast;
|
|
if (GetGridElemSlow_um() < 0)
|
|
slow = (n_slow - 1) - slow;
|
|
return slow;
|
|
}
|
|
|
|
std::vector<double> GridScanSettings::GetXContainer_m(int64_t max_image_number) const {
|
|
std::vector<double> pos_container(max_image_number);
|
|
for (int32_t i = 0; i < max_image_number; i++)
|
|
pos_container[i] = GetElementPosX_um(i) * 1e-6;
|
|
return pos_container;
|
|
}
|
|
|
|
std::vector<double> GridScanSettings::GetYContainer_m(int64_t max_image_number) const {
|
|
std::vector<double> pos_container(max_image_number);
|
|
for (int32_t i = 0; i < max_image_number; i++)
|
|
pos_container[i] = GetElementPosY_um(i) * 1e-6;
|
|
return pos_container;
|
|
}
|
|
|
|
int64_t GridScanSettings::GetNFast() const {
|
|
return n_fast;
|
|
}
|
|
|
|
int64_t GridScanSettings::GetNSlow() const {
|
|
return n_slow;
|
|
}
|
|
|
|
int64_t GridScanSettings::GetNElem() const {
|
|
return n_elem;
|
|
}
|
|
|
|
float GridScanSettings::GetGridElemFast_um() const {
|
|
if (vertical_scan)
|
|
return grid_elem_y_um;
|
|
else
|
|
return grid_elem_x_um;
|
|
}
|
|
|
|
float GridScanSettings::GetGridElemSlow_um() const {
|
|
if (vertical_scan)
|
|
return grid_elem_x_um;
|
|
return grid_elem_y_um;
|
|
}
|
|
|
|
bool GridScanSettings::IsSnakeScan() const {
|
|
return snake_scan;
|
|
}
|
|
|
|
bool GridScanSettings::IsVerticalScan() const {
|
|
return vertical_scan;
|
|
}
|
|
|
|
std::vector<float> GridScanSettings::Rearrange(const std::vector<float> &input, float fill_value) const {
|
|
std::vector<float> output(n_elem, fill_value);
|
|
for (int64_t i = 0; i < std::min<int64_t>(input.size(), n_elem); i++)
|
|
output.at(Rearrange(i)) = input[i];
|
|
|
|
return output;
|
|
}
|
|
|
|
std::vector<int64_t> GridScanSettings::Rearrange(const std::vector<int64_t> &input, uint64_t fill_value) const {
|
|
std::vector<int64_t> output(n_elem, fill_value);
|
|
for (int64_t i = 0; i < std::min<int64_t>(input.size(), n_elem); i++)
|
|
output.at(Rearrange(i)) = input[i];
|
|
return output;
|
|
}
|
|
|
|
int64_t GridScanSettings::Rearrange(int64_t image_number) const {
|
|
return GetElementPosY_step(image_number) * GetGridSizeX_step()
|
|
+ GetElementPosX_step(image_number);
|
|
}
|