Class NexusScanMetadataWriter

java.lang.Object
org.eclipse.dawnsci.nexus.scan.NexusScanMetadataWriter
All Implemented Interfaces:
INexusDevice<NXcollection>
Direct Known Subclasses:
SolsticeScanMetadataWriter

public class NexusScanMetadataWriter extends Object implements INexusDevice<NXcollection>
  • Field Details

    • SCALAR_SHAPE

      public static final int[] SCALAR_SHAPE
    • SINGLE_SHAPE

      public static final int[] SINGLE_SHAPE
    • ONE_D_UNLIMITED_SHAPE

      public static final int[] ONE_D_UNLIMITED_SHAPE
    • SINGLE_CHUNKING

      public static final int[] SINGLE_CHUNKING
      The chunk size for single values needs to be 2, as 1 doesn't work, instead defaulting to 4096, which is 32k for double-type datasets.
    • uniqueKeysDataset

      protected org.eclipse.january.dataset.ILazyWriteableDataset uniqueKeysDataset
    • scanFinishedDataset

      protected org.eclipse.january.dataset.ILazyWriteableDataset scanFinishedDataset
    • scanDurationDataset

      protected org.eclipse.january.dataset.ILazyWriteableDataset scanDurationDataset
    • scanDeadTimeDataset

      protected org.eclipse.january.dataset.ILazyWriteableDataset scanDeadTimeDataset
    • scanDeadTimePercentDataset

      protected org.eclipse.january.dataset.ILazyWriteableDataset scanDeadTimePercentDataset
    • scanEndTimeDataset

      protected org.eclipse.january.dataset.ILazyWriteableDataset scanEndTimeDataset
    • pointStartTimeStamps

      protected org.eclipse.january.dataset.ILazyWriteableDataset pointStartTimeStamps
    • pointEndTimeStamps

      protected org.eclipse.january.dataset.ILazyWriteableDataset pointEndTimeStamps
    • scanInfo

      protected NexusScanInfo scanInfo
    • scanStartTime

      protected ZonedDateTime scanStartTime
  • Constructor Details

    • NexusScanMetadataWriter

      public NexusScanMetadataWriter()
    • NexusScanMetadataWriter

      public NexusScanMetadataWriter(String name)
  • Method Details

    • getName

      public String getName()
      Description copied from interface: INexusDevice
      Returns the name of this nexus device.
      Specified by:
      getName in interface INexusDevice<NXcollection>
      Returns:
      name of nexus device
    • setHardwareScan

      public void setHardwareScan(boolean hardwareScan)
    • isHardwareScan

      public boolean isHardwareScan()
    • setNexusObjectProviders

      public void setNexusObjectProviders(Map<NexusScanInfo.ScanRole,List<NexusObjectProvider<?>>> nexusObjectProviderMap)
    • setNexusObjectProviders

      public void setNexusObjectProviders(List<NexusObjectProvider<?>> nexusObjectProviders)
    • getNexusProvider

      public NexusObjectProvider<NXcollection> getNexusProvider(NexusScanInfo info) throws NexusException
      Description copied from interface: INexusDevice
      Returns the object provider required for writing correct NeXus files.

      In this method you should prepare the LazyDatasets the device will fill during the scan. You can also write out static device metadata, which will not change during the scan.

      Use the methods on NexusNodeFactory to create a NeXus object which matches the device e.g. a NXdetector. final NXdetector detector = NexusNodeFactory.createNXdetector();

      On the detector object you can create LazyDatasets and keep references which you can later use during the scan to write data. e.g. imageData = detector.initializeLazyDataset(NXdetector.NX_DATA, info.getRank() + 2, Double.class); You should also set chunking on the LazyDatasets you create e.g. imageData.setChunking(info.createChunk(detectorXSize, detectorYSize));.

      In this method you can also write static metadata such as the detector exposure e.g. detector.setField("exposure_time", model.getExposure());. Or static datasets such as the image axis data detector.setDataset("image_x_axis", DatasetFactory.createLinearSpace(DoubleDataset.class, minX, maxX, xPoints)); For fields that are defined in the NXDL base class definition for the returned nexus object, a setXXX or setXXXScalar method may be used as appropriate, e.g. detector.setLocalName(DatasetFactory.createFromObject("my detector")); or detector.setLocalNameScalar("my detector");

      If this device is a 'metadata scannable', then the device should write its data at this point directly into the returned nexus object. This can be done with the NXobject.setField(String, Object) method, or the setXXXScalar methods for fields defined in the appropriate NXDL base class definition.

      The default implementation of this method throws UnsupportedOperationException. One of either this method or INexusDevice.getNexusProviders(NexusScanInfo) must be overridden to create and return the nexus object(s) for this INexusDevice.

      Specified by:
      getNexusProvider in interface INexusDevice<NXcollection>
      Parameters:
      info - information about the scan which can be useful when creating datasets e.g. info.getRank()
      Returns:
      The NXobject created using the nodeFactory to represent this device
      Throws:
      NexusException - if the nexus object could not be created for any reason
    • createNexusObject

      protected NXcollection createNexusObject(NexusScanInfo scanInfo)
    • writePosition

      public void writePosition(org.eclipse.january.dataset.SliceND scanSlice, int scanPointNum)
    • pointStarted

      public void pointStarted(org.eclipse.january.dataset.SliceND scanSlice)
    • pointFinished

      public void pointFinished(org.eclipse.january.dataset.SliceND scanSlice)
    • createDataset

      public org.eclipse.january.dataset.Dataset createDataset(Object data, String datasetName)
    • scanFinished

      public void scanFinished() throws NexusException
      Throws:
      NexusException
    • writeScalarData

      protected void writeScalarData(String datasetName, org.eclipse.january.dataset.ILazyWriteableDataset dataset, Object data) throws NexusException
      Throws:
      NexusException
    • getCustomNexusModification

      public CustomNexusEntryModification getCustomNexusModification()
      Description copied from interface: INexusDevice
      Returns an object that performs a custom modification to an NXentry.

      NOTE: Use this method with caution as it can be used to break the central design concept of the new Nexus writing framework, namely that the nexus framework itself knows where to put the nexus groups for devices and build any required NXdata groups. It is currently used by the new Nexus framework to partially support legacy GDA8 spring configurations, in particular the 'locationmap'.

      The nexus framework will call this method after

      invalid reference
      #createNexusObject(NexusNodeFactory, NexusScanInfo)
      , so this method create links to nodes created in that method if appropriate.

      The easiest way to implement this method is to make this object itself also implement CustomNexusEntryModification. This method can then be overridden to simply return this.

      Specified by:
      getCustomNexusModification in interface INexusDevice<NXcollection>
      Returns:
      a CustomNexusEntryModification that makes a custom modification, or null if this device should not make custom modifications
    • modifyEntry

      public void modifyEntry(NXentry entry)
    • setStartTime

      public void setStartTime(ZonedDateTime startTime)