Class NexusDataWriter

java.lang.Object
gda.data.scan.datawriter.DataWriterBase
gda.data.scan.datawriter.NexusDataWriter
All Implemented Interfaces:
DataWriter, IDataWriterExtender, INexusDataWriter
Direct Known Subclasses:
NexusExtraMetadataDataWriter, XasNexusDataWriter

public class NexusDataWriter extends DataWriterBase implements INexusDataWriter
DataWriter that outputs NeXus files and optionally a SRS/Text file as well.
  • Field Details

    • GROUP_NAME_INSTRUMENT

      public static final String GROUP_NAME_INSTRUMENT
      See Also:
    • GROUP_NAME_MEASUREMENT

      public static final String GROUP_NAME_MEASUREMENT
      See Also:
    • GDA_NEXUS_INSTRUMENT_API

      public static final String GDA_NEXUS_INSTRUMENT_API
      Property to control the level of instrumentation of the nexus api
      See Also:
    • GDA_NEXUS_METADATAPROVIDER_NAME

      public static final String GDA_NEXUS_METADATAPROVIDER_NAME
      See Also:
    • GDA_NEXUS_CREATE_SRS

      public static final String GDA_NEXUS_CREATE_SRS
      Property specifying whether SRS data files should be written in addition to NeXus files. Default is true.
      See Also:
    • GDA_NEXUS_BEAMLINE_PREFIX

      public static final String GDA_NEXUS_BEAMLINE_PREFIX
      Boolean property specifying whether nxs/dat filenames should be prefixed with the beamline name; if true, files will be named (e.g.) "i23-999.nxs" instead of just "999.nxs"
      See Also:
    • GDA_NEXUS_SWMR

      public static final String GDA_NEXUS_SWMR
      Property to enable swmr writing for the nexus scan file. SWMR mode will be enabled before the first scan point is written into the file, after the initial structure is set up The structure of the file cannot change after we enter SWMR mode.
      See Also:
    • CREATE_SRS_FILE_BY_DEFAULT

      public static final boolean CREATE_SRS_FILE_BY_DEFAULT
      Default SRS writing
      See Also:
    • GDA_NEXUS_CREATE_MEASUREMENT_GROUP

      public static final String GDA_NEXUS_CREATE_MEASUREMENT_GROUP
      Property that if enabled writes a measurement group that contains the data printed to the console during the scan
      See Also:
    • beamline

      protected String beamline
    • dataDir

      protected String dataDir
      Directory to write data to
    • fileBaseName

      protected String fileBaseName
      file name with no extension
    • fileBaseUrl

      protected String fileBaseUrl
    • nexusRelativeUrl

      protected String nexusRelativeUrl
    • entryName

      protected String entryName
    • file

      protected NexusFile file
    • srsFile

      protected SrsDataFile srsFile
    • scanNumber

      protected int scanNumber
      The current run number.
  • Constructor Details

    • NexusDataWriter

      public NexusDataWriter()
      Constructor. This attempts to read the java.property which defines the beamline name.
    • NexusDataWriter

      public NexusDataWriter(int fileNumber)
  • Method Details

    • setBeforeScanMetaData

      public void setBeforeScanMetaData(INexusTree beforeScanMetaData)
      Description copied from interface: INexusDataWriter
      Add an INexusTree to be written as before scan metadata. TODO: do we need this method. It doesn't seem to be used, but may potentially be useful?
      Specified by:
      setBeforeScanMetaData in interface INexusDataWriter
      Parameters:
      beforeScanMetaData -
    • configureScanNumber

      public void configureScanNumber(int scanNumber)
      Description copied from class: DataWriterBase
      If filenumber not set then read from scandatapoint or from num tracker
      Specified by:
      configureScanNumber in interface DataWriter
      Overrides:
      configureScanNumber in class DataWriterBase
      Parameters:
      scanNumber -
    • generateStartPosPrefix

      protected static final int[] generateStartPosPrefix(int currentPoint, int[] scanDimensions)
    • generateDataStartPos

      protected static final int[] generateDataStartPos(int[] dataStartPosPrefix, int[] dataDimensions)
    • generateDataStop

      protected static int[] generateDataStop(int[] dataStartPos, int[] dataDimensions)
    • generateDataDim

      protected static int[] generateDataDim(boolean make, int[] dataDimPrefix, int[] dataDimensions)
      calculate dimensionality of data to be written
      Parameters:
      make - if true calculate for pre-allocation (first Dim UNLIMITED)
      dataDimPrefix - set to null if not point dependent
      dataDimensions -
      Returns:
      dimensions
    • addData

      public void addData(IScanDataPoint dataPoint) throws Exception
      Description copied from interface: DataWriter
      for incremental addition of data
      Specified by:
      addData in interface DataWriter
      Overrides:
      addData in class DataWriterBase
      Parameters:
      dataPoint - Object
      Throws:
      Exception
    • completeCollection

      public void completeCollection() throws Exception
      Perform any tasks that should be done at the end of a scan and close the file.
      Specified by:
      completeCollection in interface DataWriter
      Overrides:
      completeCollection in class DataWriterBase
      Throws:
      Exception
    • releaseFile

      protected void releaseFile()
      Releases the file handle.
    • getCurrentFileName

      public String getCurrentFileName()
      Description copied from interface: DataWriter
      Get the absFilePath for this scan
      Specified by:
      getCurrentFileName in interface DataWriter
      Returns:
      String
    • createCustomMetaData

      protected void createCustomMetaData(GroupNode g) throws NexusException
      Override to provide additional meta data, if required. Does nothing otherwise.
      Parameters:
      g -
      Throws:
      NexusException
    • getGroupClassFor

      protected String getGroupClassFor(Scannable s)
    • makeAxesLinks

      protected void makeAxesLinks(GroupNode group)
    • createFile

      protected NexusFile createFile() throws Exception
      wrap the dreaded static so behaviour can be customised
      Returns:
      reference to file
      Throws:
      Exception
    • createNextFile

      protected void createNextFile() throws Exception
      Create the next file. First increment the file number and then try and get a NeXus file handle from NexusFileFactory.
      Throws:
      Exception
    • getDataDir

      public String getDataDir()
      Description copied from interface: INexusDataWriter
      Returns the full path of the folder which data files are written to.
      Specified by:
      getDataDir in interface INexusDataWriter
      Returns:
      the full path of the folder which data files are written
    • setHeader

      public void setHeader(String header)
      Not used in this implementation.
      Specified by:
      setHeader in interface DataWriter
      Parameters:
      header - String
    • writeScannable

      protected void writeScannable(Scannable scannable) throws NexusException
      Throws:
      NexusException
    • writeDefaultScannable

      protected void writeDefaultScannable(Scannable scannable) throws NexusException
      Writes the data for a given scannable to an existing NXpositioner.
      Throws:
      NexusException
    • getCurrentScanIdentifier

      public int getCurrentScanIdentifier()
      Description copied from interface: DataWriter
      Get the current scan identifier (ie scan number)
      Specified by:
      getCurrentScanIdentifier in interface DataWriter
      Returns:
      String
    • setNexusFileNameTemplate

      public void setNexusFileNameTemplate(String nexusFileNameTemplate)
      Description copied from interface: INexusDataWriter
      Sets the template to use for the filename. This should use the string String.format(String, Object...) pattern, with a single format specifier %s, e.g. ixx-%d.nxs.
      Specified by:
      setNexusFileNameTemplate in interface INexusDataWriter
      Parameters:
      nexusFileNameTemplate -
    • getNexusFileNameTemplate

      protected String getNexusFileNameTemplate()
    • clearConfiguration

      @Deprecated(since="GDA 9.33", forRemoval=true) public static void clearConfiguration()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Clears the NexusDataWriterConfiguration. This method should be called in the @After or AfterClass method of tests that set the configuration.
    • getNexusFileName

      public String getNexusFileName()
      Description copied from interface: INexusDataWriter
      The file name of the nexus file being written by this writer.
      Specified by:
      getNexusFileName in interface INexusDataWriter
      Returns:
      file name of nexus file
    • getSwmrStatus

      public SwmrStatus getSwmrStatus()
      Description copied from interface: INexusDataWriter
      Returns a SwmrStatus object specifying the state of SWMR mode (single-write multiple-read) for the nexus file written by this writer. See the javadoc for SwmrStatus for details.
      Specified by:
      getSwmrStatus in interface INexusDataWriter
      Returns:
      the SwmrStatus