Class AbstractNexusObjectProvider<N extends NXobject>
- Type Parameters:
N- nexus base class type, a subinterface ofNXobject
- All Implemented Interfaces:
NexusEntryModification,NexusObjectProvider<N>
- Direct Known Subclasses:
NexusObjectWrapper,NexusUser
NexusObjectProvider.
Use this class to help implementing NexusObjectProvider, for example:
class Detector implements IRunnableDevice, INexusDevice {
private NexusObjectProvider prov;
public Detector() {
prov = new AbstractNexusObjectProvider(NexusBaseClass.NX_DETECTOR) {
protected NXdetector doCreateNexusObject(NexusNodeFactory nodeFactory) {
final NXdetectorImpl detector = nodeFactory.createNXdetector();
final int rank = 4;
detector.initializeLazyDataset(NXdetectorImpl.NX_DATA, rank, Double.class);
return detector;
}
};
}
public NexusObjectProvider getNexusProvider() {
return prov;
}
public void write(...) {
// Use prov to help write the required datasets.
}
}
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNexusObjectProvider(String name, NexusBaseClass nexusBaseClass) Creates a newAbstractNexusObjectProviderfor given name, base class type and data node name.AbstractNexusObjectProvider(String name, NexusBaseClass nexusBaseClass, String defaultDataFieldName, String... additionalDataFieldNames) Creates a newAbstractNexusObjectProviderfor given name, base class type and data node name. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdditionalPrimaryDataFieldName(String dataFieldName) Add an additional primary data field.voidaddAuxilaryDataGroup(String dataGroupName, List<String> dataFieldNames) voidaddAuxiliaryDataField(String dataGroupName, String dataFieldName) voidaddAxisDataField(String dataFieldName, Integer defaultAxisDimension, int... dimensionMappings) Adds the given axis data field for the primary data field of this device.voidaddAxisDataFieldForPrimaryDataField(String dataFieldName, String primaryDataFieldName, Integer defaultAxisDimension, int... dimensionMappings) Adds a data field as an axis to a given primary data field.voidaddAxisDataFieldName(String dataFieldName) Adds the given name to the names of the axis data fields for this device.voidaddAxisDataFieldNames(String... axisDataFieldNames) Adds the given names to the names of the data fields for this device.voidaddExternalFileName(String externalFileName) Adds an external filename to thisAbstractNexusObjectProvider.voidaddExternalLink(NXobject groupNode, String fieldName, String pathToNode, int rank) A convenience method to add an external link to the given group node with the given name, while also setting the rank of the external dataset within thisAbstractNexusObjectProvider.voidaddExternalLink(NXobject groupNode, String fieldName, String externalFileName, String pathToNode, int rank) protected abstract NReturns the names of any additional primary data fields for this device.getAuxiliaryDataFieldNames(String primaryFieldName) Returns the names of the data fields for the given auxiliary data group as aList.Returns the names of any auxiliary data groups to create.Returns the axis data field names for this object.getAxisDataFieldsForPrimaryDataField(String primaryDataFieldName) Returns the names of the data fields that are axes for the given primary data field within this device.Returns the category for thisNexusObjectProvider.Returns the name of the collection for thisNexusObjectProvider.Returns the name of the default axis field for this nexus object, if any.getDefaultAxisDimension(String primaryDataFieldName, String axisDataFieldName) Returns the dimension of the given primary data field for which the data field with the given name is a default axis, ornullif this field does not provide a default axis to the default data field.static StringgetDefaultName(NexusBaseClass nexusBaseClass) int[]getDimensionMappings(String primaryDataFieldName, String axisDataFieldName) Returns the dimension mappings between the data field and the primary data field with the given names.intgetExternalDatasetRank(String fieldName) Returns the rank of the external dataset with the given field name.Returns the names of the external HDF5 file(s) that this device writes its data to, ornullif none.getName()Get the name of the provider.Return the NeXus base class enum value for the type NeXus object this provider creates.final NReturns the NeXus object for this provider, creating it if necessary The same NeXus object must be returned each time this method is invokedReturns the name of the default data field to write to within the nexus object.getPropertyValue(String propertyName) Returns the value of the application defined property of this object with the given name.Returns aNexusScanInfo.ScanRoledefining the role of the device for this nexus object provider performs in the scan.org.eclipse.january.dataset.ILazyWriteableDatasetgetWriteableDataset(String fieldName) Returns whether the name of this device name (as returned byNexusObjectProvider.getName()should be used in the names of the links created withinNXdatagroups to the fields within the nexus object for this instance.voidsetAuxiliaryDataGroups(Map<String, List<String>> auxiliaryDataFieldNames) voidsetAxisDataFieldNames(String... axisDataFieldNames) Sets the names of the data fields for this device.voidsetCategory(NexusBaseClass category) voidsetCollectionName(String collectionName) voidsetDefaultAxisDataFieldName(String defaultAxisDataFieldName) Sets the name of the data field for this device that acts as an axis.voidsetDefaultExternalFileName(String externalFileName) Set the name of the external file that this device writes its data to.voidsetExternalDatasetRank(String fieldName, int rank) Set the rank of an external dataset within the nexus object returned bygetNexusObject().voidvoidsetPrimaryDataFieldName(String primaryDataFieldName) Sets the name of the field to use as the primary data field.voidsetPropertyValue(String propertyName, Object value) voidsetScanRole(NexusScanInfo.ScanRole scanRole) voidsetUseDeviceNameInNXdata(boolean useDeviceNameInNXdata)
-
Field Details
-
DEFAULT_DATA_NODE_NAME
- See Also:
-
-
Constructor Details
-
AbstractNexusObjectProvider
Creates a newAbstractNexusObjectProviderfor given name, base class type and data node name.- Parameters:
name- namenexusBaseClass- base class type
-
AbstractNexusObjectProvider
public AbstractNexusObjectProvider(String name, NexusBaseClass nexusBaseClass, String defaultDataFieldName, String... additionalDataFieldNames) Creates a newAbstractNexusObjectProviderfor given name, base class type and data node name. The default data field will be used as the@signalfor anNexusBaseClass.NX_DETECTORwhen building anNXdatafor this object, otherwise if this device is the default axis for a particular dimension of the@signalfield of the device, this is the field that will be added to the@axesattribute of theNXdatagroup for that dimension.- Parameters:
name- namenexusBaseClass- base class typedefaultDataFieldName- default data field, the default signal field for a detector, the default axis field for any other type of nexus objectadditionalDataFieldNames- the names of any additional data fields
-
-
Method Details
-
getDefaultName
-
getNexusObject
Description copied from interface:NexusObjectProviderReturns the NeXus object for this provider, creating it if necessary The same NeXus object must be returned each time this method is invoked- Specified by:
getNexusObjectin interfaceNexusObjectProvider<N extends NXobject>- Returns:
- NeXus object or
null
-
createNexusObject
-
getName
Description copied from interface:NexusObjectProviderGet the name of the provider. This is used as the name of the NeXus object (i.e. group) in the parent group to which it is added.- Specified by:
getNamein interfaceNexusObjectProvider<N extends NXobject>- Returns:
- name of base
-
setName
-
getNexusBaseClass
Description copied from interface:NexusObjectProviderReturn the NeXus base class enum value for the type NeXus object this provider creates.- Specified by:
getNexusBaseClassin interfaceNexusObjectProvider<N extends NXobject>- Returns:
- the
NexusBaseClassfor this object provider
-
getScanRole
Description copied from interface:NexusObjectProviderReturns aNexusScanInfo.ScanRoledefining the role of the device for this nexus object provider performs in the scan. This affects how the fields within the nexus object returned byNexusObjectProvider.getNexusObject()are added to theNXdatagroup, if any. For example andNXdatagroup will be created for each primary field of each detector, and axis fields The nexus writing framework already knows theNexusScanInfo.ScanRoleof theINexusDevicewhoseinvalid input: 'method returned this NexusObjectProvider, as the INexusDevices are grouped by ScanRole in the NexusScanModel. However, some INexusDevices may correspond to multiple devices with different roles in the scan - a malcolm device is an example of this. Where this is the case, this method can returns a non-null value to override the scan ro @return the role of this device in the scan, where <code>null</code> tells the nexus writing framework to use the scan role of the {@link INexusDevice} in the NexusScanModel which produced this provider'- Specified by:
getScanRolein interfaceNexusObjectProvider<N extends NXobject>
-
setScanRole
-
getExternalFileNames
Description copied from interface:NexusObjectProviderReturns the names of the external HDF5 file(s) that this device writes its data to, ornullif none.- Specified by:
getExternalFileNamesin interfaceNexusObjectProvider<N extends NXobject>- Returns:
- name of external file, or
null
-
setDefaultExternalFileName
Set the name of the external file that this device writes its data to.- Parameters:
externalFileName- external file name
-
addExternalFileName
Adds an external filename to thisAbstractNexusObjectProvider.- Parameters:
externalFileName-
-
addExternalLink
A convenience method to add an external link to the given group node with the given name, while also setting the rank of the external dataset within thisAbstractNexusObjectProvider. This is required to be set when adding aNexusObjectProviderwith external links to aNexusDataBuilderin order for theaxesand<axisname>_indicesto be created.An external file must have been set by calling
setDefaultExternalFileName(String)prior to calling this method.- Parameters:
groupNode- group node to add external link tofieldName- name of external dataset within the grouppathToNode- path of node to link to within the external filerank- the rank of the
-
addExternalLink
-
getExternalDatasetRank
Description copied from interface:NexusObjectProviderReturns the rank of the external dataset with the given field name.- Specified by:
getExternalDatasetRankin interfaceNexusObjectProvider<N extends NXobject>- Parameters:
fieldName- field name- Returns:
- rank of external dataset with given field name
-
setExternalDatasetRank
Set the rank of an external dataset within the nexus object returned bygetNexusObject(). The methodsetDefaultExternalFileName(String)must have been invoked before calling this method.- Parameters:
fieldName- the name of the external dataset within the nexus objectrank- the rank of the external dataset
-
getPrimaryDataFieldName
Description copied from interface:NexusObjectProviderReturns the name of the default data field to write to within the nexus object. If this object is added as the primary device to anNXdatagroup, then this is the field name of the default field, i.e. the field referred to by the@signalattribute.If additional
NXdatagroups should be created for other fields in this scan, then the names of these fields should be returned byNexusObjectProvider.getAdditionalPrimaryDataFieldNames().- Specified by:
getPrimaryDataFieldNamein interfaceNexusObjectProvider<N extends NXobject>- Returns:
- default data field name, this cannot be
null
-
setPrimaryDataFieldName
Sets the name of the field to use as the primary data field. If this device is the primary device for a scan then this field is used as the@signalfield for theNXdatagroup.- Parameters:
primaryDataFieldName- name of the primary data field
-
getDefaultAxisDataFieldName
Description copied from interface:NexusObjectProviderReturns the name of the default axis field for this nexus object, if any. If this object is added as a device to anNXdatathen this is the field that will be added as a default axis of the@signalfield, for example for a positioner this may be the demand field.- Specified by:
getDefaultAxisDataFieldNamein interfaceNexusObjectProvider<N extends NXobject>- Returns:
- name of demand field, or
nullif none.
-
setDefaultAxisDataFieldName
Sets the name of the data field for this device that acts as an axis. This field should only be set if this device is a scannable, i.e. a device that is set to a position at a particular point in the scan.- Parameters:
defaultAxisDataFieldName-
-
getAxisDataFieldNames
Description copied from interface:NexusObjectProviderReturns the axis data field names for this object. These are the fields that will be linked to when this this object is added to anNexusDataBuilderto construct anNXdatagroup. This method should not return the names of primary data fields, nor should it return the names of data fields which should only be added to theNXdatagroups for a particular primary data field (anNXdatagroup is added to the scan for each primary data field, as returned byNexusObjectProvider.getPrimaryDataFieldName()andNexusObjectProvider.getAdditionalPrimaryDataFieldNames()). The primary data field will also be linked to in anNXdatagroup, except where this device is the primary device for the scan where it is not linked to in theNXdatagroups for additional primary data fields.- Specified by:
getAxisDataFieldNamesin interfaceNexusObjectProvider<N extends NXobject>- Returns:
- name of data fields for this object
-
setAxisDataFieldNames
Sets the names of the data fields for this device. Each data field will be added to anyNXdatagroup created for this scan.- Parameters:
axisDataFieldNames- names of data fields
-
addAxisDataFieldName
Adds the given name to the names of the axis data fields for this device. Each data field will be added to anyNXdatagroup created for this scan (anNXdatagroup is created for each primary data field). In order to add a data field that should only be added to theNXdatagroup for a specific primary data field useaddAxisDataFieldForPrimaryDataField(String, String, Integer, int...)- Parameters:
dataFieldName- names of data fields
-
addAxisDataFieldNames
Adds the given names to the names of the data fields for this device. Each data field will be added to anyNXdatagroup created for this scan (anNXdatagroup is created for each primary data field). In order to add a data field that should only be added to theNXdatagroup for a specific primary data field useaddAxisDataFieldForPrimaryDataField(String, String, Integer, int...)- Parameters:
axisDataFieldNames- names of data fields
-
addAxisDataField
public void addAxisDataField(String dataFieldName, Integer defaultAxisDimension, int... dimensionMappings) Adds the given axis data field for the primary data field of this device. It will be added as an axis field to theNXdatagroup where the primary data field of this device is the@signalfield.- Parameters:
dataFieldName- name of data fielddefaultAxisDimension- the dimension of the primary data field for which this field is a default axisdimensionMappings- mappings between the dimensions of the axis data field and the primary data field for this device, can be omitted if the mapping is one-to-one as is usually the case
-
getAxisDataFieldsForPrimaryDataField
Returns the names of the data fields that are axes for the given primary data field within this device.- Specified by:
getAxisDataFieldsForPrimaryDataFieldin interfaceNexusObjectProvider<N extends NXobject>- Parameters:
primaryDataFieldName- primary data field name- Returns:
- names of data fields
-
addAxisDataFieldForPrimaryDataField
public void addAxisDataFieldForPrimaryDataField(String dataFieldName, String primaryDataFieldName, Integer defaultAxisDimension, int... dimensionMappings) Adds a data field as an axis to a given primary data field. This field is only added to theNXdatagroup for the given primary data field (i.e. where it is the@signalfield).- Parameters:
dataFieldName- name of data field to addprimaryDataFieldName- name of primary data field that the new data field is an axis fordefaultAxisDimension-dimensionMappings- (optional) dimension mappings between the new data field and the primary data. If this argument is not specified then the dimension mappings will be assumed to be {0, 1, 2, etc} if the data field is multidimensional, or { defaultAxisDimension } if the data field has a single dimension
-
addAdditionalPrimaryDataFieldName
Add an additional primary data field. This is a data field for which, when this device is the primary device in a scan, an additionalNXdatagroup should be created with this field as the@signalfield.- Parameters:
dataFieldName- the name of the additional primary data field
-
getAdditionalPrimaryDataFieldNames
Description copied from interface:NexusObjectProviderReturns the names of any additional primary data fields for this device. This method indicates that if this device is to be used to create anNXdatawith the fieldNexusObjectProvider.getPrimaryDataFieldName()as the default (signal field), then additionalNXdatagroups should be created for each of these fields.- Specified by:
getAdditionalPrimaryDataFieldNamesin interfaceNexusObjectProvider<N extends NXobject>- Returns:
- additional primary data field names
-
getCategory
Description copied from interface:NexusObjectProviderReturns the category for thisNexusObjectProvider. When adding a nexus object to aNexusEntryBuilder, the nexus object will be added to a group of this type, if one exists in the skeleton tree. For example aNexusObjectProviderthat provides anNXpositionerwould normally be added to theNXinstrumentgroup, but if this method returnsNexusBaseClass.NX_SAMPLE, then it will instead be added to theNXsamplegroup.- Specified by:
getCategoryin interfaceNexusObjectProvider<N extends NXobject>- Returns:
- category for this object
-
setCategory
-
getCollectionName
Description copied from interface:NexusObjectProviderReturns the name of the collection for thisNexusObjectProvider. When adding a nexus object to aNexusEntryBuilder, if this method does not returnnull, then the nexus object will be added to theNXcollectionwith this name within the group that it would have been added to otherwise. The collection will be created if it does not already exist.- Specified by:
getCollectionNamein interfaceNexusObjectProvider<N extends NXobject>- Returns:
- collection name or
null
-
setCollectionName
-
getDefaultAxisDimension
Description copied from interface:NexusObjectProviderReturns the dimension of the given primary data field for which the data field with the given name is a default axis, ornullif this field does not provide a default axis to the default data field. This method is required only when this device provides the default data field of anNXdatagroup (i.e. that referred to by the@signalattribute), and additional data fields within this device provide default axis for that data field- Specified by:
getDefaultAxisDimensionin interfaceNexusObjectProvider<N extends NXobject>- Parameters:
primaryDataFieldName- name of primary data fieldaxisDataFieldName- axis data field name- Returns:
- dimension of the default data field for which the field with the
given name provides a default axis, or
nullif none
-
getDimensionMappings
Description copied from interface:NexusObjectProviderReturns the dimension mappings between the data field and the primary data field with the given names. This method is required only when this device provides the default data field of anNXdatagroup (i.e. that referred to by thesignalattribute), and additional data fields within that and the default data field of this device.- Specified by:
getDimensionMappingsin interfaceNexusObjectProvider<N extends NXobject>- Parameters:
primaryDataFieldName- field nameaxisDataFieldName- axis data field name- Returns:
- dimension mappings between the field with the given name and the default data field
-
getWriteableDataset
-
addAuxilaryDataGroup
-
setAuxiliaryDataGroups
-
addAuxiliaryDataField
-
getAuxiliaryDataGroupNames
Description copied from interface:NexusObjectProviderReturns the names of any auxiliary data groups to create. An auxiliary data group is one that groups a number of data group with the same rank together. A typical use case would be for statistics about the main data field for the device, such as min, max, mean, sum, etc.- Specified by:
getAuxiliaryDataGroupNamesin interfaceNexusObjectProvider<N extends NXobject>- Returns:
- names of auxiliary data groups
-
getAuxiliaryDataFieldNames
Description copied from interface:NexusObjectProviderReturns the names of the data fields for the given auxiliary data group as aList. These are the plottable fields for that data group. In the typical use case of an auxiliary data group for statistics.- Specified by:
getAuxiliaryDataFieldNamesin interfaceNexusObjectProvider<N extends NXobject>- Parameters:
primaryFieldName- name of the auxiliary data group- Returns:
- list of names of data fields for the auxiliary data group with the given name,
or
nullif there is no such auxiliary data group
-
isUseDeviceNameInNXdata
Description copied from interface:NexusObjectProviderReturns whether the name of this device name (as returned byNexusObjectProvider.getName()should be used in the names of the links created withinNXdatagroups to the fields within the nexus object for this instance. If this is not the case, the links to the fields created in theNXdatagroup will have the same name as they do in the nexus object for this instance (i.e. that returned byNexusObjectProvider.getNexusObject().If this method returns an empty
Optionalthen the default behaviour is to use the device name in the names of the links in theNXdatafor this device for the axes device for theNXdatagroup (often these are the devices being scanned, whose nexus object is anNXpositioner), but not for the primary data deviceIf the device name is to be used in the name of the links created then:
- If a single field from this device is added to the
NXdatagroup then that link will simply have the same name as this device. - If multiple fields from this devices are added to an
NXdatagroup then name of the link created within theNXdatagroup will be the name of the device, followed by an underscore, followed by the name of the field within the nexus object for this instance.
- Specified by:
isUseDeviceNameInNXdatain interfaceNexusObjectProvider<N extends NXobject>- Returns:
- an
OptionalcontainingBoolean.TRUEto use the device name when linking fields in anNXdatagroup,Boolean.FALSEto not use the device name, and an empty optional to use the default behaviour, i.e. use the device name for axis devices only
- If a single field from this device is added to the
-
setUseDeviceNameInNXdata
public void setUseDeviceNameInNXdata(boolean useDeviceNameInNXdata) -
getPropertyValue
Description copied from interface:NexusObjectProviderReturns the value of the application defined property of this object with the given name. This allows arbitrary application or implementation specific information to be associated with this object.Note that these properties should not be confused with the fields of the NeXus object returned by
NexusObjectProvider.getNexusObject().- Specified by:
getPropertyValuein interfaceNexusObjectProvider<N extends NXobject>- Parameters:
propertyName- name of property- Returns:
- the value of the property with the given name, or
nullif no property with the given name is set
-
setPropertyValue
-