Skip to content

Commit b2cb4ab

Browse files
authored
Merge branch 'main' into random_stlalg_ccpchecks
2 parents 9b21de9 + 2ea8ecf commit b2cb4ab

File tree

16 files changed

+2258
-362
lines changed

16 files changed

+2258
-362
lines changed

Framework/DataHandling/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ set(SRC_FILES
3838
src/LoadAscii2.cpp
3939
src/LoadAsciiStl.cpp
4040
src/LoadBBY.cpp
41+
src/LoadBBY2.cpp
4142
src/LoadBankFromDiskTask.cpp
4243
src/LoadBinaryStl.cpp
4344
src/LoadCSNSNexus.cpp
@@ -258,6 +259,7 @@ set(INC_FILES
258259
inc/MantidDataHandling/LoadAscii2.h
259260
inc/MantidDataHandling/LoadAsciiStl.h
260261
inc/MantidDataHandling/LoadBBY.h
262+
inc/MantidDataHandling/LoadBBY2.h
261263
inc/MantidDataHandling/LoadBankFromDiskTask.h
262264
inc/MantidDataHandling/LoadBinaryStl.h
263265
inc/MantidDataHandling/LoadCSNSNexus.h
@@ -475,6 +477,7 @@ set(TEST_FILES
475477
LoadAsciiStlTest.h
476478
LoadAsciiTest.h
477479
LoadBBYTest.h
480+
LoadBBY2Test.h
478481
LoadBinaryStlTest.h
479482
LoadCSNSNexusTest.h
480483
LoadCalFileTest.h

Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
//---------------------------------------------------
1212

1313
#include "MantidAPI/IFileLoader.h"
14+
#include "MantidAPI/LogManager.h"
1415
#include "MantidDataObjects/EventWorkspace.h"
1516
#include "MantidGeometry/Instrument.h"
1617
#include "MantidNexus/NexusClasses_fwd.h"
18+
#include <algorithm>
1719
#include <regex>
1820

1921
#define TarTypeFlag_NormalFile '0'
@@ -55,6 +57,7 @@ class ProgressTracker {
5557
// methods
5658
void update(int64_t position);
5759
void complete();
60+
void setTarget(int64_t target);
5861
};
5962

6063
class EventProcessor {
@@ -219,12 +222,12 @@ class File {
219222
size_t m_bufferAvailable;
220223

221224
// not supported
222-
File(const File &);
223-
File &operator=(const File &);
225+
File(const File &) = delete;
226+
File &operator=(const File &) = delete;
224227

225228
public:
226229
// construction
227-
File(const std::string &path);
230+
explicit File(const std::string &path);
228231
void close();
229232

230233
// properties
@@ -246,6 +249,34 @@ class File {
246249
};
247250

248251
} // namespace Tar
252+
253+
namespace Anxs {
254+
// options to capture timeseries data
255+
enum class ScanLog { Start, End, Mean };
256+
257+
std::string extractWorkspaceTitle(const std::string &nxsFile);
258+
259+
int64_t epochRelDateTimeBase(int64_t epochInNanoSeconds);
260+
261+
template <typename T> bool loadNXDataSet(const Nexus::NXEntry &entry, const std::string &path, T &value, int index);
262+
bool loadNXString(const Nexus::NXEntry &entry, const std::string &path, std::string &value);
263+
264+
bool isTimedDataSet(const Nexus::NXEntry &entry, const std::string &path);
265+
std::pair<uint64_t, uint64_t> getTimeScanLimits(const Nexus::NXEntry &entry, int datasetIx);
266+
std::pair<uint64_t, uint64_t> getHMScanLimits(const Nexus::NXEntry &entry, int datasetIx);
267+
268+
template <typename T>
269+
uint64_t extractTimedDataSet(const Nexus::NXEntry &entry, const std::string &path, uint64_t startTime, uint64_t endTime,
270+
std::vector<uint64_t> &times, std::vector<T> &events, std::string &units);
271+
template <typename T>
272+
bool extractTimedDataSet(const Nexus::NXEntry &entry, const std::string &path, uint64_t startTime, uint64_t endTime,
273+
ScanLog valueOption, uint64_t &eventTime, T &eventValue, std::string &units);
274+
275+
void ReadEventData(ProgressTracker &prog, const Nexus::NXEntry &entry, EventProcessor *handler, uint64_t start_nsec,
276+
uint64_t end_nsec, const std::string &neutron_path, int tube_resolution = 1024);
277+
278+
} // namespace Anxs
279+
249280
} // namespace ANSTO
250281
} // namespace DataHandling
251282
} // namespace Mantid
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Mantid Repository : https://github.com/mantidproject/mantid
2+
//
3+
// Copyright &copy; 2010 ISIS Rutherford Appleton Laboratory UKRI,
4+
// NScD Oak Ridge National Laboratory, European Spallation Source,
5+
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6+
// SPDX - License - Identifier: GPL - 3.0 +
7+
#pragma once
8+
9+
//---------------------------------------------------
10+
// Includes
11+
//---------------------------------------------------
12+
13+
// #include "MantidAPI/IFileLoader.h"
14+
#include "MantidAPI/NexusFileLoader.h"
15+
#include "MantidDataHandling/DllConfig.h"
16+
#include "MantidDataHandling/LoadANSTOHelper.h"
17+
#include "MantidDataObjects/EventWorkspace.h"
18+
#include "MantidGeometry/Instrument.h"
19+
#include "MantidNexus/NexusClasses_fwd.h"
20+
#include "MantidNexus/NexusDescriptor.h"
21+
22+
namespace Mantid {
23+
namespace DataHandling {
24+
/*
25+
Loads a Bilby data file. Implements API::IFileLoader and its file check methods
26+
to recognise a file as the one containing Bilby data.
27+
28+
@author David Mannicke (ANSTO), Anders Markvardsen (ISIS), Roman Tolchenov
29+
(Tessella plc)
30+
@date 11/07/2014
31+
*/
32+
33+
class MANTID_DATAHANDLING_DLL LoadBBY2 : public API::NexusFileLoader {
34+
35+
struct InstrumentInfo {
36+
// core values or non standard conversion
37+
std::string sample_name;
38+
std::string sample_description;
39+
std::string start_time;
40+
int64_t bm_counts;
41+
int32_t att_pos;
42+
int64_t master1_chopper_id;
43+
int64_t master2_chopper_id;
44+
bool is_tof; // tof or wavelength data
45+
double wavelength; // -> /nvs067/lambda
46+
double period_master;
47+
double period_slave;
48+
double phase_slave;
49+
};
50+
51+
public:
52+
// description
53+
LoadBBY2();
54+
int version() const override { return 1; }
55+
const std::vector<std::string> seeAlso() const override { return {"Load", "LoadBBY"}; }
56+
const std::string name() const override { return "LoadBBY2"; }
57+
const std::string category() const override { return "DataHandling\\ANSTO"; }
58+
const std::string summary() const override { return "Loads a Bilby data file into a workspace."; }
59+
60+
// returns a confidence value that this algorithm can load a specified file
61+
int confidence(Nexus::NexusDescriptor &descriptor) const override;
62+
63+
protected:
64+
// initialisation
65+
void init() override;
66+
// execution
67+
void execLoader() override;
68+
69+
private:
70+
// region of interest
71+
static std::vector<bool> createRoiVector(const std::string &maskfile);
72+
73+
// instrument creation
74+
void createInstrument(const Nexus::NXEntry &entry, uint64_t startTime, uint64_t endTime,
75+
InstrumentInfo &instrumentInfo, std::map<std::string, double> &logParams,
76+
std::map<std::string, std::string> &logStrings, std::map<std::string, std::string> &allParams);
77+
void loadInstrumentParameters(const Nexus::NXEntry &entry, uint64_t startTime, uint64_t endTime,
78+
std::map<std::string, double> &logParams,
79+
std::map<std::string, std::string> &logStrings,
80+
std::map<std::string, std::string> &allParams);
81+
82+
bool useHMScanTime{false};
83+
};
84+
85+
} // namespace DataHandling
86+
} // namespace Mantid

0 commit comments

Comments
 (0)