Improve plotting
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#include "GitInfo.h"
|
||||
#include "DiffractionExperiment.h"
|
||||
#include "JFJochException.h"
|
||||
#include "RawToConvertedGeometry.h"
|
||||
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
#define check_max(param, val, max) if ((val) > (max)) throw JFJochException(JFJochExceptionCategory::InputParameterAboveMax, param)
|
||||
#define check_min(param, val, min) if ((val) < (min)) throw JFJochException(JFJochExceptionCategory::InputParameterBelowMin, param)
|
||||
@@ -15,7 +18,8 @@
|
||||
|
||||
DiffractionExperiment::DiffractionExperiment() : DiffractionExperiment(DetectorGeometry(8, 2)) {}
|
||||
|
||||
DiffractionExperiment::DiffractionExperiment(const DetectorSetup& det_setup) : detector(det_setup) {
|
||||
DiffractionExperiment::DiffractionExperiment(const DetectorSetup& det_setup)
|
||||
: detector(det_setup), roi_mask(det_setup) {
|
||||
default_omega_axis = {1, 0, 0};
|
||||
|
||||
rad_int_polarization_corr = false;
|
||||
@@ -63,11 +67,14 @@ DiffractionExperiment::DiffractionExperiment(const DetectorSetup& det_setup) : d
|
||||
pulsed_source = false;
|
||||
|
||||
mode = DetectorMode::Conversion;
|
||||
|
||||
max_spot_count = MAX_SPOT_COUNT;
|
||||
}
|
||||
|
||||
// setter functions
|
||||
DiffractionExperiment &DiffractionExperiment::Detector(const DetectorSetup &input) {
|
||||
detector = input;
|
||||
roi_mask = ROIMask(input);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -230,7 +237,7 @@ DiffractionExperiment& DiffractionExperiment::QSpacingForAzimInt_recipA(float in
|
||||
}
|
||||
|
||||
DiffractionExperiment &DiffractionExperiment::SetUnitCell(const std::optional<UnitCell> &cell) {
|
||||
dataset.SetUnitCell(cell);
|
||||
dataset.SetUnitCell(cell);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -556,11 +563,12 @@ std::chrono::microseconds DiffractionExperiment::GetPreviewPeriod() const {
|
||||
return std::chrono::microseconds(0);
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetSpotFindingBin() const {
|
||||
if (GetImageTime().count() >= 200*1000)
|
||||
return 1;
|
||||
int64_t DiffractionExperiment::GetDefaultPlotBinning() const {
|
||||
auto tmp = 500ms / GetImageTime();
|
||||
if (GetImageNum() / tmp >= 10)
|
||||
return tmp; // 1 bin == 500 ms
|
||||
else
|
||||
return 200*1000 / GetImageTime().count(); // 1 bin = 1 second
|
||||
return 1; // no binning if less than 10 bins with 200 ms
|
||||
}
|
||||
|
||||
bool DiffractionExperiment::IsUsingInternalPacketGen() const {
|
||||
@@ -642,8 +650,15 @@ float DiffractionExperiment::GetQSpacingForAzimInt_recipA() const {
|
||||
return q_spacing;
|
||||
}
|
||||
|
||||
DiffractionExperiment &DiffractionExperiment::MaxSpotCount(int64_t input) {
|
||||
check_min("Max spot count", input, 10);
|
||||
check_max("Max spot count", input, 500);
|
||||
max_spot_count = input;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetMaxSpotCount() const {
|
||||
return MAX_SPOT_COUNT;
|
||||
return max_spot_count;
|
||||
}
|
||||
|
||||
std::string DiffractionExperiment::GetSampleName() const {
|
||||
@@ -722,7 +737,6 @@ void DiffractionExperiment::FillMessage(StartMessage &message) const {
|
||||
message.instrument_name_short = GetInstrumentNameShort();
|
||||
message.summation = GetSummation();
|
||||
message.user_data = GetHeaderAppendix();
|
||||
message.roi_summation_area = GetROISummation();
|
||||
|
||||
message.countrate_correction_enabled = false;
|
||||
message.flatfield_enabled = false;
|
||||
@@ -737,6 +751,9 @@ void DiffractionExperiment::FillMessage(StartMessage &message) const {
|
||||
message.series_unique_id = GetSeriesIDString();
|
||||
|
||||
message.gain_file_names = detector.GetGainFileNames();
|
||||
|
||||
for (const auto &[x, y]: roi_mask.GetROINameMap())
|
||||
message.roi_names.emplace_back(x);
|
||||
}
|
||||
|
||||
DiffractionExperiment &DiffractionExperiment::ApplyPixelMaskInFPGA(bool input) {
|
||||
@@ -1052,15 +1069,6 @@ Coord DiffractionExperiment::GetModuleSlowDirection(uint16_t module_number) cons
|
||||
return detector.GetGeometry().GetSlowDirection(module_number);
|
||||
}
|
||||
|
||||
DiffractionExperiment &DiffractionExperiment::ROISummation(const std::optional<ROIRectangle> &input) {
|
||||
dataset.ROISummation(input);
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::optional<ROIRectangle> DiffractionExperiment::GetROISummation() const {
|
||||
return dataset.GetROISummation();
|
||||
}
|
||||
|
||||
DiffractionExperiment &DiffractionExperiment::ConversionOnFPGA(bool input) {
|
||||
conversion_on_fpga = input;
|
||||
return *this;
|
||||
@@ -1151,3 +1159,20 @@ DiffractionExperiment &DiffractionExperiment::ImportDatasetSettings(const Datase
|
||||
DatasetSettings DiffractionExperiment::GetDatasetSettings() const {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
ROIMask &DiffractionExperiment::ROI() {
|
||||
return roi_mask;
|
||||
}
|
||||
|
||||
const ROIMask &DiffractionExperiment::ROI() const {
|
||||
return roi_mask;
|
||||
}
|
||||
|
||||
void DiffractionExperiment::ExportROIMask(uint16_t *dest, size_t module_number) const {
|
||||
if (GetDetectorMode() == DetectorMode::Conversion)
|
||||
ConvertedToRawGeometry(*this, module_number, dest, roi_mask.GetMask().data());
|
||||
else {
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
dest[i] = UINT16_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user