Package gda.data.scan.datawriter
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
DataWriter that outputs NeXus files and optionally a SRS/Text file as well.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringstatic final booleanDefault SRS writingprotected StringDirectory to write data toprotected Stringprotected NexusFileprotected Stringfile name with no extensionprotected Stringstatic final StringBoolean property specifying whether nxs/dat filenames should be prefixed with the beamline name; iftrue, files will be named (e.g.)"i23-999.nxs"instead of just"999.nxs"static final StringProperty that if enabled writes a measurement group that contains the data printed to the console during the scanstatic final StringProperty specifying whether SRS data files should be written in addition to NeXus files.static final StringProperty to control the level of instrumentation of the nexus apistatic final Stringstatic final StringProperty to enable swmr writing for the nexus scan file.static final Stringstatic final Stringprotected Stringprotected intThe current run number.protected SrsDataFileFields inherited from class gda.data.scan.datawriter.DataWriterBase
delimiter, header, terminalPrinter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddData(IScanDataPoint dataPoint) for incremental addition of datastatic voidDeprecated, for removal: This API element is subject to removal in a future version.voidPerform any tasks that should be done at the end of a scan and close the file.voidconfigureScanNumber(int scanNumber) If filenumber not set then read from scandatapoint or from num trackerprotected voidOverride to provide additional meta data, if required.protected NexusFilewrap the dreaded static so behaviour can be customisedprotected voidCreate the next file.protected static int[]generateDataDim(boolean make, int[] dataDimPrefix, int[] dataDimensions) calculate dimensionality of data to be writtenprotected static final int[]generateDataStartPos(int[] dataStartPosPrefix, int[] dataDimensions) protected static int[]generateDataStop(int[] dataStartPos, int[] dataDimensions) protected static final int[]generateStartPosPrefix(int currentPoint, int[] scanDimensions) Get the absFilePath for this scanintGet the current scan identifier (ie scan number)Returns the full path of the folder which data files are written to.protected StringThe file name of the nexus file being written by this writer.protected StringReturns aSwmrStatusobject specifying the state of SWMR mode (single-write multiple-read) for the nexus file written by this writer.protected voidmakeAxesLinks(GroupNode group) protected voidReleases the file handle.voidsetBeforeScanMetaData(INexusTree beforeScanMetaData) Add anINexusTreeto be written as before scan metadata.voidNot used in this implementation.voidsetNexusFileNameTemplate(String nexusFileNameTemplate) Sets the template to use for the filename.protected voidwriteDefaultScannable(Scannable scannable) Writes the data for a given scannable to an existing NXpositioner.protected voidwriteScannable(Scannable scannable) Methods inherited from class gda.data.scan.datawriter.DataWriterBase
addData, addDataWriterExtender, completeCollection, getDetectorData, getDetectorData, getHeader, removeDataWriterExtender, setHeaderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gda.data.scan.datawriter.DataWriter
addDataWriterExtender, getHeader, removeDataWriterExtender, scanStart, setHeader
-
Field Details
-
GROUP_NAME_INSTRUMENT
- See Also:
-
GROUP_NAME_MEASUREMENT
- See Also:
-
GDA_NEXUS_INSTRUMENT_API
Property to control the level of instrumentation of the nexus api- See Also:
-
GDA_NEXUS_METADATAPROVIDER_NAME
- See Also:
-
GDA_NEXUS_CREATE_SRS
Property specifying whether SRS data files should be written in addition to NeXus files. Default istrue.- See Also:
-
GDA_NEXUS_BEAMLINE_PREFIX
Boolean property specifying whether nxs/dat filenames should be prefixed with the beamline name; iftrue, files will be named (e.g.)"i23-999.nxs"instead of just"999.nxs"- See Also:
-
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_DEFAULTDefault SRS writing- See Also:
-
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
-
dataDir
Directory to write data to -
fileBaseName
file name with no extension -
fileBaseUrl
-
nexusRelativeUrl
-
entryName
-
file
-
srsFile
-
scanNumber
protected int scanNumberThe 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
Description copied from interface:INexusDataWriterAdd anINexusTreeto 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:
setBeforeScanMetaDatain interfaceINexusDataWriter- Parameters:
beforeScanMetaData-
-
configureScanNumber
public void configureScanNumber(int scanNumber) Description copied from class:DataWriterBaseIf filenumber not set then read from scandatapoint or from num tracker- Specified by:
configureScanNumberin interfaceDataWriter- Overrides:
configureScanNumberin classDataWriterBase- 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 dependentdataDimensions-- Returns:
- dimensions
-
addData
Description copied from interface:DataWriterfor incremental addition of data- Specified by:
addDatain interfaceDataWriter- Overrides:
addDatain classDataWriterBase- Parameters:
dataPoint- Object- Throws:
Exception
-
completeCollection
Perform any tasks that should be done at the end of a scan and close the file.- Specified by:
completeCollectionin interfaceDataWriter- Overrides:
completeCollectionin classDataWriterBase- Throws:
Exception
-
releaseFile
protected void releaseFile()Releases the file handle. -
getCurrentFileName
Description copied from interface:DataWriterGet the absFilePath for this scan- Specified by:
getCurrentFileNamein interfaceDataWriter- Returns:
- String
-
createCustomMetaData
Override to provide additional meta data, if required. Does nothing otherwise.- Parameters:
g-- Throws:
NexusException
-
getGroupClassFor
-
makeAxesLinks
-
createFile
wrap the dreaded static so behaviour can be customised- Returns:
- reference to file
- Throws:
Exception
-
createNextFile
Create the next file. First increment the file number and then try and get a NeXus file handle fromNexusFileFactory.- Throws:
Exception
-
getDataDir
Description copied from interface:INexusDataWriterReturns the full path of the folder which data files are written to.- Specified by:
getDataDirin interfaceINexusDataWriter- Returns:
- the full path of the folder which data files are written
-
setHeader
Not used in this implementation.- Specified by:
setHeaderin interfaceDataWriter- Parameters:
header- String
-
writeScannable
- Throws:
NexusException
-
writeDefaultScannable
Writes the data for a given scannable to an existing NXpositioner.- Throws:
NexusException
-
getCurrentScanIdentifier
public int getCurrentScanIdentifier()Description copied from interface:DataWriterGet the current scan identifier (ie scan number)- Specified by:
getCurrentScanIdentifierin interfaceDataWriter- Returns:
- String
-
setNexusFileNameTemplate
Description copied from interface:INexusDataWriterSets the template to use for the filename. This should use the stringString.format(String, Object...)pattern, with a single format specifier%s, e.g.ixx-%d.nxs.- Specified by:
setNexusFileNameTemplatein interfaceINexusDataWriter- Parameters:
nexusFileNameTemplate-
-
getNexusFileNameTemplate
-
clearConfiguration
Deprecated, for removal: This API element is subject to removal in a future version.Clears theNexusDataWriterConfiguration. This method should be called in the@AfterorAfterClassmethod of tests that set the configuration. -
getNexusFileName
Description copied from interface:INexusDataWriterThe file name of the nexus file being written by this writer.- Specified by:
getNexusFileNamein interfaceINexusDataWriter- Returns:
- file name of nexus file
-
getSwmrStatus
Description copied from interface:INexusDataWriterReturns aSwmrStatusobject specifying the state of SWMR mode (single-write multiple-read) for the nexus file written by this writer. See the javadoc forSwmrStatusfor details.- Specified by:
getSwmrStatusin interfaceINexusDataWriter- Returns:
- the
SwmrStatus
-