Skip to content

Commit

Permalink
Fix issue with cut_sym not transforming pixels (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Apr 5, 2024
1 parent f0eb934 commit 1f593e1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
1 change: 0 additions & 1 deletion _test/test_sym_op/test_cut_sqw_sym.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ function test_cut_sym_reflect_half_to_whole_cut(obj)

function test_cut_sym_with_pix(obj)
% Test symmetrisation, keeping pixels
skipTest('Cut with pix disabled')
clOb = set_temporary_config_options(hor_config, 'log_level', -1);
w2sym = cut(obj.data, obj.proj, obj.bin,...
obj.width, obj.width, obj.ebins, obj.sym);
Expand Down
4 changes: 2 additions & 2 deletions horace_core/sqw/@sqw/cut.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@
[targ_ax_block, targ_proj] = obj.define_target_axes_block(targ_proj, pbin_tmp, sym);

if return_cut
wout{cut_num} = cut_single_(obj, targ_proj, targ_ax_block, opt, log_level);
wout{cut_num} = cut_single_(obj, targ_proj, targ_ax_block, opt, log_level, sym);
else
cut_single_(obj, targ_proj, targ_ax_block, opt, log_level);
cut_single_(obj, targ_proj, targ_ax_block, opt, log_level, sym);
end
end

Expand Down
11 changes: 4 additions & 7 deletions horace_core/sqw/@sqw/private/cut_accumulate_data_.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function [s, e, npix, pix_out, unique_runid] = ...
cut_accumulate_data_(obj, targ_proj, targ_axes, keep_pixels, log_level)
cut_accumulate_data_(obj, targ_proj, targ_axes, keep_pixels, log_level, sym)
%%CUT_ACCUMULATE_DATA Accumulate image and pixel data for a cut
%
% Input:
Expand Down Expand Up @@ -74,7 +74,7 @@

if keep_pixels
[npix, s, e, pix_out, unique_runid] = cut_with_pixels(obj.pix, block_starts, block_sizes, targ_proj, ...
targ_axes, npix, s, e, log_level,keep_precision, pixel_contrib_name);
targ_axes, npix, s, e, log_level,keep_precision, pixel_contrib_name, sym);
else
[npix, s, e, pix_out, unique_runid] = cut_no_pixels(obj.pix, block_starts, block_sizes, targ_proj, ...
targ_axes, npix, s, e, log_level, pixel_contrib_name);
Expand Down Expand Up @@ -166,11 +166,7 @@

function [npix, s, e, pix_out, unique_runid] = cut_with_pixels(pix, block_starts, block_sizes, ...
targ_proj, targ_axes, npix, s, e, ll, ...
keep_precision, pixel_contrib_name)

if numel(targ_proj) > 1
error('HORACE:cut:not_implemented', 'Cannot cut sym and return pixels')
end
keep_precision, pixel_contrib_name, sym)

hc = hor_config;
chunk_size = hc.mem_chunk_size;
Expand Down Expand Up @@ -225,6 +221,7 @@
[npix, s, e, pix_ok, unique_runid_l, pix_indx, selected] = ...
targ_proj(i).bin_pixels(targ_axes(i), candidate_pix, npix, s, e);

candidate_pix = sym{i}.transform_pix(candidate_pix, {}, selected);
candidate_pix = candidate_pix.tag(selected);

npix_step_retained = pix_ok.num_pixels; % just for logging the progress
Expand Down
6 changes: 3 additions & 3 deletions horace_core/sqw/@sqw/private/cut_single_.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function wout = cut_single_(w, targ_proj, targ_axes, opt, log_level)
function wout = cut_single_(w, targ_proj, targ_axes, opt, log_level, sym)
%%CUT_SINGLE Perform a cut on a single sqw object
%
% Input:
Expand Down Expand Up @@ -27,7 +27,7 @@

% Accumulate image and pixel data for cut
[s, e, npix, pix_out,runid_contributed] = cut_accumulate_data_( ...
w, targ_proj, targ_axes, opt.keep_pix, log_level);
w, targ_proj, targ_axes, opt.keep_pix, log_level, sym);


if isa(pix_out, 'MultipixBase')
Expand All @@ -51,7 +51,7 @@
if opt.keep_pix
wout = sqw();
wout.main_header = w.main_header;
% NB detpar is no longer copied as detpar just exposes the detector_arrays
% NB detpar is no longer copied as detpar just exposes the detector_arrays
% already in experiment_info
wout.data = data_out.data;
wout.pix = data_out.pix;
Expand Down
7 changes: 6 additions & 1 deletion horace_core/symop/@Symop/Symop.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function disp(obj)
end
end

function pix = transform_pix(obj, pix, proj)
function pix = transform_pix(obj, pix, proj, selected)
% Transform pixel coordinates into symmetry related coordinates
%
% The transformation converts the components of a vector which is
Expand All @@ -138,13 +138,17 @@ function disp(obj)
%
% pix PixelData object
%
% selected Pixels to transform
% Output:
% -------
% pix Transformed PixelData object

if ~exist('proj', 'var')
proj = {};
end
if ~exist('selected', 'var')
selected = 1:pix.num_pixels;
end

% Check input
if ~isa(pix, 'PixelDataBase')
Expand All @@ -156,6 +160,7 @@ function disp(obj)
if isa(pix, 'PixelDataMemory')
for i = numel(obj):-1:1
sel = obj(i).in_irreducible(pix.q_coordinates, proj{:});
sel(~selected) = false;
pix.q_coordinates(:, ~sel) = obj(i).transform_vec(pix.q_coordinates(:, ~sel));
end
else
Expand Down

0 comments on commit 1f593e1

Please sign in to comment.