-
Notifications
You must be signed in to change notification settings - Fork 3
AB's proposal for refactoring the sqw and dnd classes
Go back: Horace framework redesign ideas
AB also presented a proposal to rewrite (refactor) parts of the core Matlab Horace code:
This section will deal proposed changes to the sqw
and dnd
classes.
Another section deals a new base class iSQW
for better file handling.
In the other section, the proposal was to have a base iSQW
class from which both sqw
and dnd
classes will be derived.
iSQW
will have concrete load
and save
methods but other methods, including binary and unary operations will be virtual and be implemented in the sqw
and dnd
subclasses.
As currently, dnd
will contain only binned data, whilst sqw
will contain both binned data as well as the original pixel data (counts per energy per detector element).
Since sqw
will also have binned data, to have better code reuse, AB proposes that each sqw
object includes an instance of dnd
as one of its data member.
As such, methods such as plot
which never require pixel information will be a reference to the equivalent dnd
call.
(An alternative idea is have sqw
be a subclass of dnd
rather than iSQW
directly.)
In addition to dnd
, sqw
will also have a member which is of a new PixBlock
class, which will contain the pixel information and may be file-backed.
PixBlock
's main method is get_pixels
which returns a list of counts within some specified boundaries.
(Alternatively, sqw
could have multiple inheritance and derive from both dnd
and PixBlock
.)
One of the new features for Horace to be implemented in the PACE project is to support "generic projections".
At present, Horace can only rebin along the coordinate axes of the data, either along the actual crystallographic axes (nonorthogonal
projections) or along the orthogonalised crystal coordinates used when the data was converted by gen_sqw
.
In future, it is desirable that the data could also be rebinned in spherical or cylindrical or mixed q-E coordinates.
This will be encapsulated in a new projection
class.
The main functionality of projection
is in the methods get_pixels_rlu
and get_contributing_bins
which is equivalent to the get_pixels
method of PixBlock
but in the user's desired coordinate system rather than in the orthogonal crystal coordinates used when the data was generated (e.g. by gen_sqw
).
How projection
works is unclear from the documents - it seems that it should be a member of dnd
but will also need to access the internal data of PixBlock
.
It might be better if projection
is an abstract base class from which both dnd
and PixBlock
(and hence sqw
) inherits and provide concrete implementations of get_pixels_rlu
.
Go back: Horace framework redesign ideas