Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to multidimensional histo writer #166

Merged
merged 4 commits into from
Feb 29, 2024
Merged

Conversation

granrothge
Copy link

This updates the writing of spec to MDH file writer. So now the output along the x axis is scaled to the proj vector along it's direction rather than the norm of that vector this means a cut 0,0,0 to 1,1,0 would read 0 to 1 along the x axis rather than 0 1.41.
also a bug was fixed so it no properly writes things when q0 is something other than 0,0,0.

The tests were updated accordingly to ensure this bug is captured.

@granrothge
Copy link
Author

@mducle @RichardWaiteSTFC Hi guys I caught a bug in my MDH writer that did not handle the case where the cut started from something other than 0,0,0. also I improved the axis scaling. let me know if you have any comments.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (950ad3b) 40.51% compared to head (ec22175) 40.52%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #166      +/-   ##
==========================================
+ Coverage   40.51%   40.52%   +0.01%     
==========================================
  Files         240      240              
  Lines       15981    15985       +4     
==========================================
+ Hits         6474     6478       +4     
  Misses       9507     9507              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@mducle mducle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks ok, except for a comment...

Tested with this script:

spec = sw_egrid(spinwave(sw_model('triAF', 1), {[-3 -3 0], [1 1 0], 2000}));
spec = sw_instrument(spec, 'dE', 0.2);
proj = [[1 1 0]' [1 -1 0]' [0 0 1]'];
dproj = [1, 1e-6, 1e-6];
sw_spec2MDHisto(spec, proj, dproj, 'test.nxs');

And loaded the resulting test.nxs in Mantid 6.8 and it plots fine - the q-direction scale goes from -3 to +1 as expected (rather than -4.24 to +1.41 as it would before this PR).

for idx=1:3
procjv = proj(:,idx)/norm(proj(:,idx));

qidx = idx;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is needed since qidx is always the same as idx...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the fix was so it would go from -3 to 1 as expected. I updated to remove the redundancy in the variable. I chose to keep qidx and remove idx as it is a more descriptive.

@granrothge
Copy link
Author

This should be good to go now.

@mducle mducle merged commit ce8dd43 into SpinW:master Feb 29, 2024
8 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants