McStasMcXtrace / iFit

a simple library to analyze data (with McCode and Phonons/DFT hooks). :warning: this project has been moved to https://gitlab.com/soleil-data-treatment/soleil-software-projects/remote-desktop
http://ifit.mccode.org
Other
5 stars 5 forks source link

Single_crystal_inelastic / Saving 4D Sqw fails using default example #170

Closed willend closed 5 years ago

willend commented 5 years ago

The default example taken from http://ifit.mccode.org/McStas.html#mozTocId36233 fails on the save step:

s = sqw_spinw('defaults')
d = iData(s); % use default grid for axes
saveas(d, 'sx_coh.sqw4', 'mcstas');
sqw_spinw: Model  atom1 built using SpinW.
Ground state energy: -4 [mev/spin]
 * S. Toth and B. Lake, J. Phys.: Condens. Matter 27, 166002 (2015).
s =  iFunc_Sqw4D (methods,doc,plot,more...) 4D model:

    [Tag] [Dim]                                [Model] [Parameters 'p']
  iF24178   4  Sqw_spinw spin-wav. A HKL spi. ax = ... Gamma Temperature Amplitude J1 
max: maximum phonon energy 8 [meV] in Sqw_spinw spin-wave dispersion(HKL) [sqw_spinw]
Opening sx_coh.sqw4
Index exceeds matrix dimensions.

Error in Sqw_McStas (line 118)
        if     iscell(val) && ischar(val{1}), val = sprintf('%s ', val{:});

Error in iData_Sqw4D/saveas (line 111)
          f = Sqw_McStas(self, varargin{1});
 
willend commented 5 years ago

I had a look myself, but the logic looks a bit too involved :-)

willend commented 5 years ago

Same output with current GitHub code as well as 2.0 release

willend commented 5 years ago

Hmm, it seems I can save once I do

        if     iscell(val) && ~isempty(val) && ischar(val{1}), val = sprintf('%s ', val{:});
        elseif iscell(val) && ~isempty(val) && isnumeric(val{1}), val = sprintf('%f ', val{:});
        end
        if ~isempty(val)
            t=val; t(~isstrprop(t,'print')) = ' '; val=t;
            fprintf(fid, '# %-13s %-s %s\n', name, val, comment);
            parameters.(name)=NaN;
        end

...

Attaching txt file with edits here Sqw_McStas.m.txt

willend commented 5 years ago

It seems the output only includes the positive combination of [h k l]

willend commented 5 years ago