Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
049e6ad
Re 896 (b) typo in test names
abuts Jul 8, 2025
921c91b
Re #896 (b) IO tests for mode 6 (nosort)
abuts Jul 8, 2025
9058373
Re #896 (b) implemented nosort mode. More tests are needed
abuts Jul 9, 2025
ce3a5ee
Re #896 (b) finished mode 6 (bin pixels non-sorted, return cell idx)
abuts Jul 9, 2025
627d9f8
Re #896 (b) change mode-6 indices output to int64
abuts Jul 9, 2025
a19be10
Re #896 fixed issue with zero pixels returned by mex bin
abuts Jul 9, 2025
500cd73
Re #896 (b) modify input analysis code to retrieve all parameters fro…
abuts Jul 10, 2025
b361d73
Re #896 (c) finished mode 7 (return logical array of selected pixels)
abuts Jul 10, 2025
189ec8e
Re #896 (c) formally implemented mode 8 (needs tests)
abuts Jul 9, 2025
907c714
Re #896 (c) modified pixel indices type to mxInt64
abuts Jul 9, 2025
c5d72c1
Re #896 (c) fixed merge conflicts and invalid generic code replacement
abuts Jul 10, 2025
e859b42
Re #896c enabled mode 8 and first unit tests for it.
abuts Jul 10, 2025
2d71da8
Re #896 (b) Merge branch 'master' into 896b_all_mex4Axes_bin
abuts Jul 10, 2025
b7e4451
Re #896 (b) fixed test_line_axes (different input types from mex code)
abuts Jul 11, 2025
6cfc2da
Merge branch '896b_all_mex4Axes_bin' into 896c_all_mex4Axes_bin
abuts Jul 11, 2025
2c9b86a
Re #896 (c) fixed horace_mex
abuts Jul 11, 2025
3966739
Re #896 (c) attempt to fix horace_mex_mpi. Incomplete
abuts Jul 11, 2025
eaa280f
Re #896 (c) fixed horace_mex_mpi and minor changes to C++ code
abuts Jul 14, 2025
294c33a
Re #896 (c) more reliable treatment of input cell data
abuts Jul 16, 2025
2a6ceca
Re #896 (c) Merge branch 'master' into 896c_all_mex4Axes_bin
abuts Jul 29, 2025
4ba8836
Re #896 (c) fixing merge error
abuts Jul 29, 2025
54359ec
Re #896 (c) minor change in output pix_idx format which supports pixe…
abuts Jul 31, 2025
d173b2c
Re #896 (c) Merge remote-tracking branch 'remotes/origin/896a_mex_in_…
abuts Oct 6, 2025
9eab60f
Re #896 (c) fixing merge errors
abuts Oct 7, 2025
16079c5
Re #896 (c) Merge remote-tracking branch 'remotes/origin/1902_integra…
abuts Nov 20, 2025
a8b307e
Re #896 (c) some CR/CL changes
abuts Nov 20, 2025
b2f48d5
Re #896 (c) Merge branch '896a_mex_in_cut' into 896c_all_mex4Axes_bin
abuts Nov 20, 2025
7da32aa
Merge remote-tracking branch 'remotes/origin/1902_integration_ranges'…
abuts Nov 21, 2025
49126bb
Re #896 (c) fixing merge errors
abuts Nov 21, 2025
ead72ca
Re #896c Merge branch 'master' into 896c_all_mex4Axes_bin
abuts Dec 16, 2025
55885b5
Re #896 (c) update cmake packages to support recent MATLAB version (s)
abuts Dec 16, 2025
a8844e4
Re #896 (c) attempt to modify cmake and Jenkins file to support polic…
abuts Dec 16, 2025
d4d2524
Merge branch '1909_matlab2025_graphics' into 896c_all_mex4Axes_bin
abuts Dec 16, 2025
7bed952
Re #896 (c) disable default doc builds as it does not supported any m…
abuts Dec 16, 2025
0583776
Merge branch '1909_matlab2025_graphics' into 896c_all_mex4Axes_bin
abuts Dec 16, 2025
6e1ad76
Merge branch '1909_matlab2025_graphics' into 896c_all_mex4Axes_bin
abuts Dec 17, 2025
17f8793
Re #896 (c) should fix python package search error. Disabled run doci…
abuts Dec 17, 2025
3719512
Re #896 (c) recovered inverse Windows jobs execution, disabled after …
abuts Dec 17, 2025
c1f2139
Merge branch 'master' into 896c_all_mex4Axes_bin
abuts Dec 18, 2025
d92d680
Re #896 (c) attempt to fix Jenkins builds using latest cmake version
abuts Dec 18, 2025
ad811fb
Re #896 (c) remove unsupported binning option description in sqw_op_b…
abuts Dec 22, 2025
533ea08
Re #896 (b) Merge branch 'master' into 896b_all_mex4Axes_bin
abuts Dec 22, 2025
c2abc35
Re #896 (b) merge errors (omissions)
abuts Dec 22, 2025
a3aebf8
Re #896 (b) changes from review (typo in var name)
abuts Dec 22, 2025
5eae9fe
Re #896 (b) other merge error
abuts Dec 22, 2025
bb41d90
Re #896 (b) formal change to push up the build. Seems Jenkins worker …
abuts Dec 23, 2025
97b1364
Re #896 (c) Merge branch '896b_all_mex4Axes_bin' into 896c_all_mex4Ax…
abuts Dec 23, 2025
65ab781
Re 896 (c) fresh mex code, build with VS 2022 for MATLAB 2025b
abuts Dec 23, 2025
a35fa3e
Re #896 (c) release notes for work done in branches 896 a-c
abuts Dec 23, 2025
597e711
Re #896 (c) cosmetic changes to MagneticIons to start the build
abuts Jan 6, 2026
b4cc291
Re #896 (c) disable hdf5 plug-in for unsupported MATLAB + minor typo …
abuts Jan 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.29)

set(Horace_ROOT ${CMAKE_CURRENT_LIST_DIR})
file(READ "${Horace_ROOT}/VERSION" _version)
Expand Down Expand Up @@ -66,7 +66,7 @@ include(PACE_FindMatlab)
#
message(" MATLAB CURRENT VERSION: ${MATLAB_CURRENT_VERSION}")
set(BUILD_HDF_MEX_PLUGIN TRUE)
if ((${MATLAB_CURRENT_VERSION} VERSION_LESS "7.11") OR (${MATLAB_CURRENT_VERSION} VERSION_GREATER "9.4"))
if ((${MATLAB_CURRENT_VERSION} VERSION_LESS_EQUAL "7.11") OR (${MATLAB_CURRENT_VERSION} VERSION_GREATER "9.4"))
set(BUILD_HDF_MEX_PLUGIN FALSE)
endif()

Expand All @@ -75,7 +75,7 @@ include(PACE_AddMex)
include(PACE_CodeAnalysis)
include(PACE_Docs)
if (${BUILD_HDF_MEX_PLUGIN})
include(horace_FindHDF5)
include(horace_FindHDF5)
endif()

include(herbert_FindMPI)
Expand Down
8 changes: 4 additions & 4 deletions _LowLevelCode/cpp/accumulate_cut_c/accumulate_cut_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mwSize accumulate_cut(double* s, double* e, double* npix,

T Inf(0);
double ebin_inv = (1 / ebin);
bool ignore_something, ignote_all;
bool ignore_something, ignore_all;

//if we want to ignore nan and inf in the data
bool ignore_nan(false);
Expand All @@ -50,7 +50,7 @@ mwSize accumulate_cut(double* s, double* e, double* npix,
ignore_inf = true;
}
ignore_something = ignore_nan || ignore_inf;
ignote_all = ignore_nan && ignore_inf;
ignore_all = ignore_nan && ignore_inf;
if (ignore_inf)
{
Inf = static_cast<T>(mxGetInf());
Expand Down Expand Up @@ -143,7 +143,7 @@ mwSize accumulate_cut(double* s, double* e, double* npix,
pStor) \
firstprivate(data_size, distribution_size, \
trans_elo, ebin_inv, Inf, PIXEL_data_width, \
ignote_all, ignore_nan, ignore_inf, ignore_something, transform_energy, \
ignore_all, ignore_nan, ignore_inf, ignore_something, transform_energy, \
nDimX, nDimY, nDimZ, nDimE, \
s, e, npix,pixel_data) \
reduction(+: nPixel_retained)
Expand All @@ -158,7 +158,7 @@ mwSize accumulate_cut(double* s, double* e, double* npix,
ok[i] = false;
if (ignore_something)
{
if (ignote_all)
if (ignore_all)
{
if (pixel_data[j0 + 7] == Inf || isNaN(pixel_data[j0 + 7]) ||
pixel_data[j0 + 8] == Inf || isNaN(pixel_data[j0 + 8]))
Expand Down
76 changes: 63 additions & 13 deletions _LowLevelCode/cpp/bin_pixels_c/BinningArg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ void BinningArg::set_all_pix(mxArray const* const pField)
auto data_type = mxGetClassID(a_cell_ptr);
if (data_type != mxDOUBLE_CLASS) {
std::stringstream buf;
buf << "Binning the dataype N " << data_type << " have not been implemented yet";
buf << " Setting input pixel data to bin\n";
buf << " Binning for input datatype N: " << data_type << " have not been implemented yet\n";
buf << " You can bin datatype N " << mxDOUBLE_CLASS << " only";
mexErrMsgIdAndTxt("HORACE:bin_pixels_c:not_implemented",
buf.str().c_str());
}
Expand Down Expand Up @@ -389,8 +391,9 @@ void BinningArg::return_pix_range(mxArray* pFieldName, mxArray* pFieldValue, int
pix_range = this->pix_data_range_ptr;
}
mxSetCell(pFieldValue, fld_idx, pix_range);
this->pix_data_range_ptr = nullptr;
};
// return pixel obtained after binning and may be sorting.Sets up empty matrix if algorithm have not been using pixels
// return pixel obtained after binning and may be sorting. Sets up empty matrix if algorithm have not been using pixels
void BinningArg::return_pix_ok_data(mxArray* pFieldName, mxArray* pFieldValue, int fld_idx, const std::string& field_name)
{
mxSetCell(pFieldName, fld_idx, mxCreateString(field_name.c_str()));
Expand All @@ -401,7 +404,36 @@ void BinningArg::return_pix_ok_data(mxArray* pFieldName, mxArray* pFieldValue, i
pix_ok = mxCreateDoubleMatrix(0, 0, mxREAL);
}
mxSetCell(pFieldValue, fld_idx, pix_ok);
this->pix_ok_ptr = nullptr;
};
// return array of pixels indices, which specify position of pixels within image cell
void BinningArg::return_pix_img_idx(mxArray* pFieldName, mxArray* pFieldValue, int fld_idx, const std::string& field_name)
{
mxSetCell(pFieldName, fld_idx, mxCreateString(field_name.c_str()));
mxArray* pix_img_idx(nullptr);
if (this->pix_img_idx_ptr) {
pix_img_idx = this->pix_img_idx_ptr;
} else {
pix_img_idx = mxCreateNumericMatrix(0, 0, mxINT64_CLASS, mxREAL);
}
mxSetCell(pFieldValue, fld_idx, pix_img_idx);
this->pix_img_idx_ptr = nullptr;
};
// return array of pixels indices, which specify position of pixels within image cell
void BinningArg::return_is_pix_selected(mxArray* pFieldName, mxArray* pFieldValue, int fld_idx, const std::string& field_name)
{
mxSetCell(pFieldName, fld_idx, mxCreateString(field_name.c_str()));
mxArray* is_pix_selected(nullptr);
if (this->is_pix_selected_ptr) {
is_pix_selected = this->is_pix_selected_ptr;
} else {
is_pix_selected = mxCreateLogicalMatrix(0, 0);
}
mxSetCell(pFieldValue, fld_idx, is_pix_selected);
this->is_pix_selected_ptr = nullptr;
};


//===================================================================================
// calculate steps used in binning over non-unit directions and numbers of these dimensions
void BinningArg::calc_step_sizes_pax_and_strides()
Expand Down Expand Up @@ -458,11 +490,24 @@ void BinningArg::register_output_methods()
this->Mode5ParList = this->Mode4ParList;
this->Mode5ParList["unique_runid"] = [this](mxArray* p1, mxArray* p2, int idx, const std::string& name) { this->return_unique_runid(p1, p2, idx, name); };

this->Mode6ParList = this->Mode5ParList;
this->Mode6ParList["pix_img_idx"] = [this](mxArray* p1, mxArray* p2, int idx, const std::string& name) { this->return_pix_img_idx(p1, p2, idx, name); };

this->Mode7ParList = this->Mode6ParList;
this->Mode7ParList["is_pix_selected"] = [this](mxArray* p1, mxArray* p2, int idx, const std::string& name) { this->return_is_pix_selected(p1, p2, idx, name); };

this->Mode8ParList = this->Mode0ParList;
this->Mode8ParList["is_pix_selected"] = [this](mxArray* p1, mxArray* p2, int idx, const std::string& name) { this->return_is_pix_selected(p1, p2, idx, name); };


this->out_handlers[opModes::npix_only] = &Mode0ParList;
this->out_handlers[opModes::sig_err] = &Mode0ParList;
this->out_handlers[opModes::sigerr_cell] = &Mode0ParList;
this->out_handlers[opModes::sort_pix] = &Mode4ParList;
this->out_handlers[opModes::sort_and_uid] = &Mode5ParList;
this->out_handlers[opModes::nosort] = &Mode6ParList;
this->out_handlers[opModes::nosort_sel] = &Mode7ParList;
this->out_handlers[opModes::siger_selected] = &Mode8ParList;
};
/** Parse input binning arguments and set new BinningArg from MATLAB input arguments
* structure.
Expand Down Expand Up @@ -694,6 +739,8 @@ void BinningArg::return_test_inputs(mxArray* plhs[], int nlhs)
this->pix_ok_ptr = mxDuplicateArray(this->all_pix_ptr);
this->OutParList["pix_ok_data"] = [this](mxArray* p1, mxArray* p2, int idx, const std::string& name) { this->return_pix_ok_data(p1, p2, idx, name); };
this->OutParList["unique_runid"] = [this](mxArray* p1, mxArray* p2, int idx, const std::string& name) { this->return_unique_runid(p1, p2, idx, name); };
this->OutParList["pix_img_idx"] = [this](mxArray* p1, mxArray* p2, int idx, const std::string& name) { this->return_pix_img_idx(p1, p2, idx, name); };
this->OutParList["is_pix_selected"] = [this](mxArray* p1, mxArray* p2, int idx, const std::string& name) { this->return_is_pix_selected(p1, p2, idx, name); };

/* ********************************************************************************
* retrieve binning parameters form BinningArg class and copy them into output array
Expand Down Expand Up @@ -813,28 +860,29 @@ void BinningArg::check_and_init_accumulators(mxArray* plhs[], mxArray const* prh
plhs[out_arg::Signal] = this->signal_ptr;
plhs[out_arg::Error] = this->error_ptr;
}
if (this->binMode >= opModes::sort_pix) {
// pixels modes
if (this->binMode >= opModes::sort_pix && this->binMode<opModes::siger_selected) {
if (this->n_data_points > this->pix_ok_bin_idx.size()) {
this->pix_ok_bin_idx.resize(this->n_data_points);
}
// fill all positions of the pix_ok vector with certainly invalid value. Index can not be negative
// this will indicate invalid elements
std::fill(this->pix_ok_bin_idx.begin(), this->pix_ok_bin_idx.end(), -1);
if (this->npix_bin_start.size() != this->distr_size) {
this->npix_bin_start.resize(this->distr_size);
this->npix1.resize(this->distr_size);
}
std::fill(this->npix1.begin(), this->npix1.end(), 0); // nullify accumulators for npix1
// ranges calculated per each pixels block, i.e. calculations per call to bin_pixels_c
// allocate space for pixel data range, which is always calculated for
// any pixel mode
this->pix_data_range_ptr = mxCreateDoubleMatrix(2, pix_flds::PIX_WIDTH, mxREAL);
if (init_new_accumulators) {
// just in case, clear unique run-id-s set (should be empty anyway at this stage)
this->unique_runID.clear();
}
} else {
// clear ranges left from previous call to binning functions
// as they are not needed for this call but may confuse output routines
this->pix_data_range_ptr = nullptr;
if (this->binMode < opModes::nosort) {
// accumulators needed for sorting pixels according to bins
if (this->npix_bin_start.size() != this->distr_size) {
this->npix_bin_start.resize(this->distr_size);
this->npix1.resize(this->distr_size);
}
std::fill(this->npix1.begin(), this->npix1.end(), 0); // nullify accumulators for npix1
}
}
}

Expand Down Expand Up @@ -905,6 +953,8 @@ BinningArg::BinningArg()
, n_pix_retained(0)
, pix_data_range_ptr(nullptr)
, pix_ok_ptr(nullptr)
, pix_img_idx_ptr(nullptr)
, is_pix_selected_ptr(nullptr)
{
/* initialize input Matlab parameters map with methods which associate
* Matlab field names with the methods, which set appropriate property value */
Expand Down
19 changes: 14 additions & 5 deletions _LowLevelCode/cpp/bin_pixels_c/BinningArg.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum opModes {
sort_and_uid = 5, // in additional to binning and sorting, return unique pixels id
nosort = 6, // do binning but do not sort pixels but return array which defines pixels position
// within the image grid
nosort_sel = 7, // like 6, but return ?logical? array which specifies what pixels have been selected
nosort_sel = 7, // like 6, but return logical array which specifies what pixels have been selected
// and what were rejected by binning operations
siger_selected = 8, // the same as sig_err but return logical array of selected piels instead of pix_ok array
test_inputs = 9, // do not do calculations but just return parsed inputs for
Expand Down Expand Up @@ -111,6 +111,9 @@ class BinningArg {
mxArray* pix_data_range_ptr;
mxArray* pix_ok_ptr; // pointer to array of all pixels retained after binning
std::unordered_set<uint32_t> unique_runID; // set containing unique run_id-s of the
mxArray* pix_img_idx_ptr; // pointer to array of pixel indices within the image cell
mxArray* is_pix_selected_ptr; // pointer to logical array containing true where pixel
// was selected for binning and false otherwise
// processed pixels
//********************************************************************************
// helper values
Expand All @@ -119,7 +122,7 @@ class BinningArg {
std::vector<size_t> stride; // vector, which describes binning steps reflecting multidimensional array strides
std::vector<size_t> bin_cell_idx_range; // vector containing allowed maximal indixes of the binning (with nbins_all_dims>1) cells in binning directions
// auxiliary array containing pixel indices over bins
std::vector<long> pix_ok_bin_idx;
std::vector<mxInt64> pix_ok_bin_idx;
// auxiliary array defining ranges of the bins to sort pixels over
std::vector<size_t> npix_bin_start;
std::vector<size_t> npix1; // pixel distribution over bins calculated in single call to bin_pixels routine;
Expand Down Expand Up @@ -149,13 +152,12 @@ class BinningArg {
void set_nbins_all_dims(mxArray const* const pField); //
void set_unique_runid(mxArray const* const pField); // holder for the information about unique run_id-s present in the data. Set procedure is non-standard
void set_force_double(mxArray const* const pField); // boolean parameters which would request output transformed pixels always been double regardless of input pixels
void set_return_selected(mxArray const* const pField);
void set_test_input_mode(mxArray const* const pField); // intialize testing mode (or not)
void set_all_pix(mxArray const* const pField); // pointer to all pixels to sort or use as binning arguments
void set_alignment_matrix(mxArray const* const pField); // matrix which have to be applied to raw pixels to bring them into Crystal Cartesian coordinate system
void set_check_pix_selection(mxArray const* const pField); // if true, check if detector_id are negative which may suggest that pixels have been alreary used in previous binning operation

// register with parameters map all methods which
// register with parameters map all methods which return variable results to MATLAB
void register_output_methods();
// setters for binning results returned to MATLAB in output structure
void return_npix_retained(mxArray* p1, mxArray* p2, int idx, const std::string& name);
Expand All @@ -165,7 +167,11 @@ class BinningArg {
void return_pix_ok_data(mxArray* p1, mxArray* p2, int idx, const std::string& name);
// setter to return unique run_id,.calculated in the call
void return_unique_runid(mxArray* p1, mxArray* p2, int idx, const std::string& name);

// setter to return pixels indices within the image cell
void return_pix_img_idx(mxArray* p1, mxArray* p2, int fld_idx, const std::string& name);
// setter to return array containing true for selected pixels and false if they have not been selected
void return_is_pix_selected(mxArray* p1, mxArray* p2, int fld_idx, const std::string& name);
//
public:
BinningArg(); // construction
// process binning arguments input values for new binning arguments cycle
Expand Down Expand Up @@ -198,6 +204,9 @@ class BinningArg {
OutHandlerMap Mode0ParList;
OutHandlerMap Mode4ParList;
OutHandlerMap Mode5ParList;
OutHandlerMap Mode6ParList;
OutHandlerMap Mode7ParList;
OutHandlerMap Mode8ParList;

std::unordered_map<opModes, OutHandlerMap*> out_handlers;
};
Loading