SpinW / spinw

SpinW Matlab library for spin wave calculation
http://www.spinw.org
GNU General Public License v3.0
35 stars 15 forks source link

Convert output struct from spinw.spinwave() to a class #184

Open mducle opened 4 months ago

mducle commented 4 months ago

At the moment, the spinwave calculations outputs the spectra as a plain Matlab struct which can then be used with the functions sw_neutron, sw_egrid, sw_plotspec etc. to rebin and calculate different cross-sections or to plot.

However, the fields of the output struct are not uniform - for example if the fitmode option is given to spinwave, then the original spinw object is not included as a field in the struct. This causes sw_plotspec (it uses unit labels in the spinw object to plot) and sw_egrid (which needs information on the twins) to fail.

A more robust approach would be to convert the current plain struct to a class and to make the various sw_* functions methods of the class. These are: sw_egrid, sw_instrument, sw_magdomain, sw_neutron, sw_omegasum, sw_plotspec, sw_spec2MDHisto, sw_xray. The sw_ prefix could be retained for backwards compatibility or removed (or aliased).

RichardWaiteSTFC commented 1 month ago

Maybe can wait till we migrate to python