Skip to content

Commit

Permalink
Re #1790 trying to fix jenkins tests. Fixed sqw with detector_array i…
Browse files Browse the repository at this point in the history
…ssue
  • Loading branch information
abuts committed Dec 25, 2024
1 parent 716fe4f commit 504597a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 18 deletions.
23 changes: 15 additions & 8 deletions _test/test_multifit/test_multifit_horace_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,29 @@
end

methods
function this = test_multifit_horace_1(name)
function obj = test_multifit_horace_1(name)
if nargin == 0
name = 'test_multifit_horace_1';
end
% Construct object
output_file = 'test_multifit_horace_1_output.mat';
this = this@TestCaseWithSave(name, output_file);
obj = obj@TestCaseWithSave(name, output_file);

% Read in data
data_dir = fileparts(mfilename('fullpath'));

this.w1data = read_sqw(fullfile(data_dir,'w1data.sqw'));
this.w2data = read_sqw(fullfile(data_dir,'w2data.sqw'));
obj.w1data = read_sqw(fullfile(data_dir,'w1data.sqw'));
obj.w2data = read_sqw(fullfile(data_dir,'w2data.sqw'));
hp = horace_paths;
this.w4ddata = read_sqw(fullfile(hp.test_common,'sqw_4d.sqw'));
this.win=[this.w1data,this.w2data]; % combine the two cuts into an array of sqw objects and fit
obj.w4ddata = read_sqw(fullfile(hp.test_common,'sqw_4d.sqw'));
disp("*********************************************************")
disp('Re #1790 identifying issues present on Jenkins only')
disp(obj.w4ddata.experiment_info.detector_arrays)
disp("*********************************************************")
obj.win=[obj.w1data,obj.w2data]; % combine the two cuts into an array of sqw objects and fit

% Save reference results, if '-save' option is requested
this.save();
obj.save();
end

% ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -105,9 +109,12 @@
% ------------------------------------------------------------------------------------------------
function obj = test_fit_multidimensional_dataset(obj)
% Example of simultaneously fitting more than one sqw object
%
%
disp("*********************************************************")
disp('Re #1790 identifying issues present on Jenkins only')
disp(obj.w4ddata.experiment_info.detector_arrays)
disp(obj.w4ddata.detpar.unique_objects.unique_objects)
disp("*********************************************************")
mss = multifit_sqw_sqw(obj.w4ddata);
mss = mss.set_fun(@sqw_bcc_hfm, [75,5,2.7,10,-75]); % set foreground function(s)
mss = mss.set_free([1,1,1,1,0]); % set which parameters are floating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
% instruments and samples

unique_objects; % returns unique_objects_container. Hidden not to
% expose expensive operation to view
% expose expensive operation to view but widely used in access/save/load operations
end

methods % property (and method) set/get
Expand Down
2 changes: 1 addition & 1 deletion horace_core/Tobyfit/detector_array.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if isempty(det) || det.n_runs == 0
% no detector info was available when the sqw was populated; as detpar
% is no longer available this is an error
error('HORACE:tobyfit-detector_array:invalid_argument', ...
error('HORACE:detector_array:invalid_argument', ...
'trying to make detectors from a detpar but it doesnt exist any more');
else
% make a new detector object based on value of use_tubes and insert
Expand Down
7 changes: 2 additions & 5 deletions horace_core/algorithms/resolution_plot.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@
sample.alatt = lat.alatt;
sample.angdeg = lat.angdeg;
end
exper = Experiment([],instrument,sample,expdata);

wres.experiment_info = exper;


% Check detector
Expand All @@ -231,8 +228,8 @@
if ~isfield(detpar,'filepath'), detpar.filepath = ''; end
if ~isfield(detpar,'group'), detpar.group = 1; end

wres.detpar = detpar;

detpar = IX_detector_array(detpar);
wres.experiment_info = Experiment(detpar,instrument,sample,expdata);

% Make data structure
ax = line_axes('nbins_all_dims',[3,3,1,1],'img_range',range_add_border(zeros(2,4)));
Expand Down
11 changes: 11 additions & 0 deletions horace_core/sqw/@sqw/private/set_from_old_struct_.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
if isfield(ss,'experiment_info') && isstruct(ss.experiment_info)
ss.experiment_info = Experiment.loadobj(ss.experiment_info);
end
if isfield(ss,'detpar')
detpar = IX_detector_array(ss.detpar);
ss.experiment_info.detector_arrays = detpar;
end
% the detpar value will be put in further down in from_bare_struct.
% NB reminder that this will require experiment_info having an empty
% detector_arrays rather than being preconstructed
Expand Down Expand Up @@ -119,3 +123,10 @@
obj.pix.alignment_matr = al_info.rotmat;
end
end
if S.version == 5
% may contain detpar stored in their own field and not present within
% the experiment_info
if obj.experiment_info.detector_arrays.n_objects == 0
obj.detpar = S.detpar; % use setter for old array format
end
end
6 changes: 3 additions & 3 deletions horace_core/sqw/@sqw/sqw.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@

experiment_info_ = []; %Experiment(); now at start of constructor;
% detectors array
detpar_ = struct([]);

% holder for image data, e.g. appropriate dnd object
data_;
Expand Down Expand Up @@ -529,7 +528,7 @@ function save_xye(obj,varargin)
%======================================================================
% SERIALIZABLE INTERFACE
properties(Constant,Access=protected)
fields_to_save_ = {'main_header','experiment_info','detpar','data','pix'};
fields_to_save_ = {'main_header','experiment_info','data','pix'};
end
%
methods
Expand All @@ -538,7 +537,8 @@ function save_xye(obj,varargin)
% and nxsqw data format. Each new version would presumably read
% the older version, so version substitution is based on this
% number
ver = 5;
ver = 6;
% version 6 detpar is saved/lodaded through experiment_info
% version 5 -- support for loading previous version
% data in case if the data were realigned
end
Expand Down

0 comments on commit 504597a

Please sign in to comment.