nexusformat / definitions

Definitions of the NeXus Standard File Structure and Contents
https://manual.nexusformat.org/
Other
26 stars 55 forks source link

Introduce new class `NXspacially_located_object` #1364

Open paulmillar opened 4 months ago

paulmillar commented 4 months ago

There is a large number of classes that describe physical objects that have some location in space, and that currently extend the base class NXobject.

These classes all have elements in common: they all contain both a group of type NXtransformations and a field with name depends_on.

Here is a list of these classes:

paul@celebrimbor:~/git/NeXus-related/definitions (main)$ git grep -l 'group type="NXtransformations"' |xargs grep -l 'field name="depends_on"' | xargs grep -l 'extends="NXobject"'
applications/NXmx.nxdl.xml
base_classes/NXaperture.nxdl.xml
base_classes/NXattenuator.nxdl.xml
base_classes/NXbeam.nxdl.xml
base_classes/NXbeam_stop.nxdl.xml
base_classes/NXbending_magnet.nxdl.xml
base_classes/NXcapillary.nxdl.xml
base_classes/NXcollimator.nxdl.xml
base_classes/NXcrystal.nxdl.xml
base_classes/NXdetector.nxdl.xml
base_classes/NXdisk_chopper.nxdl.xml
base_classes/NXenvironment.nxdl.xml
base_classes/NXfermi_chopper.nxdl.xml
base_classes/NXfilter.nxdl.xml
base_classes/NXflipper.nxdl.xml
base_classes/NXfresnel_zone_plate.nxdl.xml
base_classes/NXgrating.nxdl.xml
base_classes/NXguide.nxdl.xml
base_classes/NXinsertion_device.nxdl.xml
base_classes/NXmirror.nxdl.xml
base_classes/NXmoderator.nxdl.xml
base_classes/NXmonitor.nxdl.xml
base_classes/NXmonochromator.nxdl.xml
base_classes/NXpinhole.nxdl.xml
base_classes/NXpolarizer.nxdl.xml
base_classes/NXpositioner.nxdl.xml
base_classes/NXsample.nxdl.xml
base_classes/NXsensor.nxdl.xml
base_classes/NXslit.nxdl.xml
base_classes/NXsource.nxdl.xml
base_classes/NXvelocity_selector.nxdl.xml
base_classes/NXxraylens.nxdl.xml
contributed_definitions/NXcollectioncolumn.nxdl.xml
contributed_definitions/NXdeflector.nxdl.xml
contributed_definitions/NXelectronanalyser.nxdl.xml
contributed_definitions/NXlens_em.nxdl.xml
contributed_definitions/NXmanipulator.nxdl.xml
contributed_definitions/NXregistration.nxdl.xml
contributed_definitions/NXspindispersion.nxdl.xml
paul@celebrimbor:~/git/NeXus-related/definitions (main)$ 

This list has 31 (of 57) base classes and 7 (of 62) contributed classes.

Repeating the same information in each of these classes makes maintenance harder and (arguable) makes it harder to understand the classes.

One option might be to introduce a new class (called NXspacially_located_object for example) that extends NXobject and contains the NXtransformations group and depends_on field. Subclasses of this new class would describe any object with a well-defined location in space.

This new class could also contain definitions of the legacy elements (groups of type NXgeometry), if that were possible and desirable.

The definitions of the above list of classes could then be updated to extend this new class, removing the elements that would then be redundant.