Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
62e08998
Commit
62e08998
authored
Oct 22, 2020
by
Mathieu Tillet
Browse files
Check date format in ILL loaders
parent
bb9c5e51
Changes
6
Hide whitespace changes
Inline
Side-by-side
Framework/DataHandling/test/LoadILLDiffractionTest.h
View file @
62e08998
...
...
@@ -19,6 +19,7 @@
#include
"MantidKernel/FacilityInfo.h"
#include
"MantidKernel/Unit.h"
#include
"MantidKernel/V3D.h"
#include
"MantidTypes/Core/DateAndTimeHelpers.h"
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Kernel
;
...
...
@@ -82,6 +83,7 @@ public:
TS_ASSERT
(
!
outputWS
->
isHistogramData
())
TS_ASSERT
(
!
outputWS
->
isDistribution
())
TS_ASSERT_EQUALS
(
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
(),
"Degrees"
)
checkTimeFormat
(
outputWS
);
}
void
test_D20_no_scan
()
{
...
...
@@ -169,6 +171,7 @@ public:
TS_ASSERT_EQUALS
(
outputWS
->
run
().
getProperty
(
"Detector.calibration_file"
)
->
value
(),
"none"
)
checkTimeFormat
(
outputWS
);
}
void
test_D20_no_scan_requesting_calibrated_throws
()
{
...
...
@@ -255,6 +258,7 @@ public:
"4.8
\n
2017-Feb-15 08:59:02.423509996 5
\n
"
;
TS_ASSERT_EQUALS
(
omega
->
value
(),
omegaTimeSeriesValue
)
checkTimeFormat
(
outputWS
);
}
void
test_D20_detector_scan_offset
()
{
...
...
@@ -278,6 +282,7 @@ public:
position
.
getSpherical
(
r
,
theta
,
phi
);
TS_ASSERT_DELTA
(
theta
,
5.825
,
0.001
);
TS_ASSERT_LESS_THAN
(
position
.
X
(),
0.
);
checkTimeFormat
(
outputWS
);
}
void
test_D20_multifile
()
{
...
...
@@ -301,6 +306,7 @@ public:
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
0
))
TS_ASSERT
(
!
outputWS
->
isHistogramData
())
TS_ASSERT
(
!
outputWS
->
isDistribution
())
checkTimeFormat
(
outputWS
);
}
void
test_D2B_alignment
()
{
...
...
@@ -349,6 +355,7 @@ public:
TS_ASSERT_DELTA
(
tube128CentreTime2
.
Y
(),
0.
,
0.001
)
tube128CentreTime2
.
getSpherical
(
r
,
theta
,
phi
);
TS_ASSERT_DELTA
(
theta
,
147.55
,
0.001
)
checkTimeFormat
(
outputWS
);
}
void
do_test_D2B_single_file
(
const
std
::
string
&
dataType
)
{
...
...
@@ -439,6 +446,7 @@ public:
ANGULAR_DETECTOR_SPACING
*
double
(
i
)),
1e-2
)
}
checkTimeFormat
(
outputWS
);
}
TS_ASSERT
(
outputWS
->
run
().
hasProperty
(
"Multi.TotalCount"
))
...
...
@@ -478,6 +486,13 @@ public:
TS_ASSERT
(
run
.
hasProperty
(
"ScanType"
));
const
auto
type
=
run
.
getLogData
(
"ScanType"
);
TS_ASSERT_EQUALS
(
type
->
value
(),
"DetectorScan"
);
checkTimeFormat
(
outputWS
);
}
void
checkTimeFormat
(
MatrixWorkspace_const_sptr
outputWS
)
{
TS_ASSERT
(
outputWS
->
run
().
hasProperty
(
"start_time"
));
TS_ASSERT
(
Mantid
::
Types
::
Core
::
DateAndTimeHelpers
::
stringIsISO8601
(
outputWS
->
run
().
getProperty
(
"start_time"
)
->
value
()));
}
private:
...
...
Framework/DataHandling/test/LoadILLIndirect2Test.h
View file @
62e08998
...
...
@@ -13,6 +13,7 @@
#include
"MantidDataHandling/LoadILLIndirect2.h"
#include
"MantidGeometry/Instrument.h"
#include
"MantidGeometry/Instrument/DetectorInfo.h"
#include
"MantidTypes/Core/DateAndTimeHelpers.h"
#include
<boost/algorithm/string/predicate.hpp>
...
...
@@ -85,6 +86,7 @@ public:
const
auto
&
detInfo
=
output2D
->
detectorInfo
();
constexpr
double
degToRad
=
M_PI
/
180.
;
TS_ASSERT_DELTA
(
detInfo
.
twoTheta
(
65
),
33.1
*
degToRad
,
0.01
)
checkTimeFormat
(
output2D
);
}
void
test_first_tube_251
()
{
...
...
@@ -108,6 +110,7 @@ public:
const
std
::
string
idf
=
output2D
->
getInstrument
()
->
getFilename
();
TS_ASSERT_EQUALS
(
output2D
->
getInstrument
()
->
getName
(),
"IN16BF"
);
TS_ASSERT
(
boost
::
ends_with
(
idf
,
"IN16BF_Definition.xml"
));
checkTimeFormat
(
output2D
);
}
void
test_diffraction_bats
()
{
...
...
@@ -134,6 +137,7 @@ public:
TS_ASSERT_EQUALS
(
output2D
->
dataY
(
1050
)[
1156
],
16
)
TS_ASSERT_EQUALS
(
output2D
->
dataY
(
871
)[
1157
],
17
)
TS_ASSERT_EQUALS
(
output2D
->
dataY
(
746
)[
1157
],
18
)
checkTimeFormat
(
output2D
);
AnalysisDataService
::
Instance
().
clear
();
}
...
...
@@ -161,6 +165,7 @@ public:
TS_ASSERT_EQUALS
(
output2D
->
dataY
(
1050
)[
558
],
2
)
TS_ASSERT_EQUALS
(
output2D
->
dataY
(
873
)[
557
],
2
)
TS_ASSERT_EQUALS
(
output2D
->
dataY
(
724
)[
561
],
3
)
checkTimeFormat
(
output2D
);
AnalysisDataService
::
Instance
().
clear
();
}
...
...
@@ -191,11 +196,18 @@ public:
const
Mantid
::
API
::
Run
&
runlogs
=
output
->
run
();
TS_ASSERT
(
runlogs
.
hasProperty
(
"Facility"
));
TS_ASSERT_EQUALS
(
runlogs
.
getProperty
(
"Facility"
)
->
value
(),
"ILL"
);
checkTimeFormat
(
output
);
// Remove workspace from the data service.
AnalysisDataService
::
Instance
().
clear
();
}
void
checkTimeFormat
(
MatrixWorkspace_const_sptr
outputWS
)
{
TS_ASSERT
(
outputWS
->
run
().
hasProperty
(
"start_time"
));
TS_ASSERT
(
Mantid
::
Types
::
Core
::
DateAndTimeHelpers
::
stringIsISO8601
(
outputWS
->
run
().
getProperty
(
"start_time"
)
->
value
()));
}
private:
std
::
string
m_dataFile2013
{
"ILL/IN16B/034745.nxs"
};
std
::
string
m_dataFile2015
{
"ILL/IN16B/127500.nxs"
};
...
...
Framework/DataHandling/test/LoadILLPolarizedDiffractionTest.h
View file @
62e08998
...
...
@@ -22,6 +22,8 @@
#include
"MantidKernel/FacilityInfo.h"
#include
"MantidKernel/Unit.h"
#include
"MantidKernel/V3D.h"
#include
"MantidTypes/Core/DateAndTimeHelpers.h"
#include
<tuple>
using
namespace
Mantid
::
API
;
...
...
@@ -129,6 +131,7 @@ public:
TS_ASSERT_DELTA
(
workspaceEntry1
->
x
(
133
)[
1
],
3.19
,
0.01
)
TS_ASSERT_EQUALS
(
workspaceEntry1
->
y
(
133
)[
0
],
2042
)
TS_ASSERT_DELTA
(
workspaceEntry1
->
e
(
133
)[
0
],
45.18
,
0.01
)
checkTimeFormat
(
workspaceEntry1
);
}
void
test_D7_timeOfFlight
()
{
...
...
@@ -214,6 +217,7 @@ public:
TS_ASSERT_DELTA
(
workspaceEntry1
->
x
(
133
)[
512
],
3579.68
,
0.01
)
TS_ASSERT_EQUALS
(
workspaceEntry1
->
y
(
133
)[
511
],
0
)
TS_ASSERT_DELTA
(
workspaceEntry1
->
e
(
133
)[
511
],
0.00
,
0.01
)
checkTimeFormat
(
workspaceEntry1
);
}
void
test_D7_multifile_sum
()
{
...
...
@@ -272,6 +276,7 @@ public:
TS_ASSERT_DELTA
(
workspaceEntry1
->
x
(
133
)[
1
],
3.19
,
0.01
)
TS_ASSERT_EQUALS
(
workspaceEntry1
->
y
(
133
)[
0
],
4109
)
TS_ASSERT_DELTA
(
workspaceEntry1
->
e
(
133
)[
0
],
64.10
,
0.01
)
checkTimeFormat
(
workspaceEntry1
);
}
void
test_D7_multifile_list
()
{
...
...
@@ -361,6 +366,7 @@ public:
TS_ASSERT_DELTA
(
workspaceEntry12
->
x
(
133
)[
1
],
3.19
,
0.01
)
TS_ASSERT_EQUALS
(
workspaceEntry12
->
y
(
133
)[
0
],
108504
)
TS_ASSERT_DELTA
(
workspaceEntry12
->
e
(
133
)[
0
],
329.39
,
0.01
)
checkTimeFormat
(
workspaceEntry1
);
}
void
test_D7_default_alignment
()
{
...
...
@@ -497,6 +503,7 @@ public:
double
wavelength
=
stod
(
ws
->
mutableRun
().
getLogData
(
"monochromator.wavelength"
)
->
value
());
TS_ASSERT_DELTA
(
wavelength
,
3.09
,
0.01
)
checkTimeFormat
(
ws
);
}
void
test_D7_transpose
()
{
...
...
@@ -628,6 +635,7 @@ public:
TS_ASSERT
(
workspaceEntry
->
isHistogramData
())
TS_ASSERT
(
!
workspaceEntry
->
isDistribution
())
TS_ASSERT_EQUALS
(
workspaceEntry
->
YUnitLabel
(),
"Counts"
)
checkTimeFormat
(
workspaceEntry
);
if
(
measurementMode
==
"monochromatic"
)
{
TS_ASSERT_EQUALS
(
workspaceEntry
->
blocksize
(),
1
)
TS_ASSERT_EQUALS
(
workspaceEntry
->
getAxis
(
0
)
->
unit
()
->
caption
(),
...
...
@@ -642,6 +650,12 @@ public:
}
}
void
checkTimeFormat
(
MatrixWorkspace_const_sptr
outputWS
)
{
TS_ASSERT
(
outputWS
->
run
().
hasProperty
(
"run_start"
));
TS_ASSERT
(
Mantid
::
Types
::
Core
::
DateAndTimeHelpers
::
stringIsISO8601
(
outputWS
->
run
().
getProperty
(
"run_start"
)
->
value
()));
}
private:
const
double
RAD_2_DEG
=
180.0
/
M_PI
;
std
::
string
m_oldFacility
;
...
...
Framework/DataHandling/test/LoadILLReflectometryTest.h
View file @
62e08998
...
...
@@ -19,6 +19,7 @@
#include
"MantidGeometry/Instrument.h"
#include
"MantidGeometry/Instrument/RectangularDetector.h"
#include
"MantidKernel/Unit.h"
#include
"MantidTypes/Core/DateAndTimeHelpers.h"
using
namespace
Mantid
::
API
;
using
Mantid
::
DataHandling
::
LoadILLReflectometry
;
...
...
@@ -55,6 +56,10 @@ private:
std
::
set
<
Mantid
::
detid_t
>
{
0
})
// sample log entry must exist
TS_ASSERT
(
output
->
run
().
hasProperty
(
"reduction.line_position"
))
TS_ASSERT
(
output
->
run
().
hasProperty
(
"run_start"
));
TS_ASSERT
(
Mantid
::
Types
::
Core
::
DateAndTimeHelpers
::
stringIsISO8601
(
output
->
run
().
getProperty
(
"run_start"
)
->
value
()));
}
static
double
detCounts
(
const
MatrixWorkspace_sptr
&
output
)
{
...
...
Framework/DataHandling/test/LoadILLSANSTest.h
View file @
62e08998
...
...
@@ -17,6 +17,7 @@
#include
"MantidGeometry/Instrument/DetectorInfo.h"
#include
"MantidKernel/ConfigService.h"
#include
"MantidKernel/Unit.h"
#include
"MantidTypes/Core/DateAndTimeHelpers.h"
using
Mantid
::
API
::
AnalysisDataService
;
using
Mantid
::
API
::
Axis
;
...
...
@@ -95,6 +96,7 @@ public:
TS_ASSERT_DELTA
(
err6
[
0
],
sqrt
(
20
),
1E-5
)
const
auto
unit
=
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
();
TS_ASSERT_EQUALS
(
unit
,
"Wavelength"
);
checkTimeFormat
(
outputWS
);
}
void
test_D22
()
{
...
...
@@ -130,6 +132,7 @@ public:
TS_ASSERT_DELTA
(
err6
[
0
],
sqrt
(
45
),
1E-5
)
const
auto
unit
=
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
();
TS_ASSERT_EQUALS
(
unit
,
"Wavelength"
);
checkTimeFormat
(
outputWS
);
}
void
test_D16
()
{
...
...
@@ -185,6 +188,7 @@ public:
TS_ASSERT_DELTA
(
xAxis
[
1
],
7.035
,
1E-3
)
TS_ASSERT_EQUALS
(
spec
[
0
],
17
)
TS_ASSERT_DELTA
(
err
[
0
],
sqrt
(
17
),
1E-5
)
checkTimeFormat
(
outputWS
);
}
void
test_D33
()
{
...
...
@@ -230,6 +234,7 @@ public:
TS_ASSERT_EQUALS
(
bottom
->
getPos
(),
V3D
(
0
,
-
0.41
,
1.3118
));
const
auto
unit
=
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
();
TS_ASSERT_EQUALS
(
unit
,
"Wavelength"
);
checkTimeFormat
(
outputWS
);
}
void
test_D33_TOF
()
{
...
...
@@ -259,6 +264,13 @@ public:
TS_ASSERT_EQUALS
(
tof
->
value
(),
"TOF"
);
const
auto
unit
=
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
();
TS_ASSERT_EQUALS
(
unit
,
"Wavelength"
);
checkTimeFormat
(
outputWS
);
}
void
checkTimeFormat
(
MatrixWorkspace_const_sptr
outputWS
)
{
TS_ASSERT
(
outputWS
->
run
().
hasProperty
(
"run_start"
));
TS_ASSERT
(
Mantid
::
Types
::
Core
::
DateAndTimeHelpers
::
stringIsISO8601
(
outputWS
->
run
().
getProperty
(
"run_start"
)
->
value
()));
}
};
...
...
Framework/DataHandling/test/LoadILLTOF2Test.h
View file @
62e08998
...
...
@@ -10,6 +10,8 @@
#include
"MantidAPI/MatrixWorkspace.h"
#include
"MantidAPI/SpectrumInfo.h"
#include
"MantidDataHandling/LoadILLTOF2.h"
#include
"MantidTypes/Core/DateAndTimeHelpers.h"
#include
<cxxtest/TestSuite.h>
using
namespace
Mantid
::
API
;
...
...
@@ -65,6 +67,10 @@ public:
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
outputSpace
);
TS_ASSERT
(
output
->
run
().
hasProperty
(
"start_time"
));
TS_ASSERT
(
Mantid
::
Types
::
Core
::
DateAndTimeHelpers
::
stringIsISO8601
(
output
->
run
().
getProperty
(
"start_time"
)
->
value
()));
TS_ASSERT_EQUALS
(
output
->
getNumberHistograms
(),
numberOfHistograms
)
const
auto
&
spectrumInfo
=
output
->
spectrumInfo
();
for
(
size_t
wsIndex
=
0
;
wsIndex
!=
output
->
getNumberHistograms
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment