44#include < dx2/crystal.hpp>
55#include < dx2/detector.hpp>
66#include < dx2/goniometer.hpp>
7+ #include < dx2/imagesequence.hpp>
78#include < dx2/scan.hpp>
9+ #include < dx2/utils.hpp>
810#include < nlohmann/json.hpp>
911
1012using Eigen::Vector3d;
@@ -22,15 +24,21 @@ template <class BeamType> class Experiment {
2224 Detector &detector ();
2325 const Crystal &crystal () const ;
2426 void set_crystal (Crystal crystal);
27+ void set_beam (BeamType beam);
28+ void set_scan (Scan scan);
29+ void set_detector (Detector detector);
30+ void set_goniometer (Goniometer goniometer);
31+ void set_imagesequence (ImageSequence imagesequence);
2532 void set_identifier (std::string identifier);
33+ void generate_identifier ();
2634
2735protected:
2836 BeamType _beam{};
2937 Scan _scan{};
3038 Goniometer _goniometer{};
3139 Detector _detector{};
3240 Crystal _crystal{};
33- json _imageset_json {};
41+ ImageSequence _imagesequence {};
3442 std::string _identifier{};
3543};
3644
@@ -51,8 +59,9 @@ Experiment<BeamType>::Experiment(json experiment_data) {
5159 this ->_goniometer = gonio;
5260 this ->_detector = detector;
5361 // Save the imageset json to propagate when saving to file.
54- json imageset_data = experiment_data[" imageset" ][0 ];
55- this ->_imageset_json = imageset_data;
62+ json imagesequence_data = experiment_data[" imageset" ][0 ];
63+ ImageSequence imagesequence (imagesequence_data);
64+ this ->_imagesequence = imagesequence;
5665 try { // We don't always have a crystal model e.g. before indexing.
5766 json crystal_data = experiment_data[" crystal" ][0 ];
5867 Crystal crystal (crystal_data);
@@ -67,7 +76,6 @@ template <class BeamType> json Experiment<BeamType>::to_json() const {
6776 json elist_out; // a list of potentially multiple experiments
6877 elist_out[" __id__" ] = " ExperimentList" ;
6978 json expt_out; // our single experiment
70- // no imageset (for now?).
7179 expt_out[" __id__" ] = " Experiment" ;
7280 expt_out[" identifier" ] = _identifier;
7381 expt_out[" beam" ] =
@@ -82,7 +90,7 @@ template <class BeamType> json Experiment<BeamType>::to_json() const {
8290 elist_out[" goniometer" ] = std::array<json, 1 >{_goniometer.to_json ()};
8391 elist_out[" beam" ] = std::array<json, 1 >{_beam.to_json ()};
8492 elist_out[" detector" ] = std::array<json, 1 >{_detector.to_json ()};
85- elist_out[" imageset" ] = std::array<json, 1 >{_imageset_json };
93+ elist_out[" imageset" ] = std::array<json, 1 >{_imagesequence. to_json () };
8694
8795 if (_crystal.get_U_matrix ().determinant ()) {
8896 expt_out[" crystal" ] = 0 ;
@@ -115,15 +123,42 @@ void Experiment<BeamType>::set_crystal(Crystal crystal) {
115123 _crystal = crystal;
116124}
117125
126+ template <class BeamType > void Experiment<BeamType>::set_beam(BeamType beam) {
127+ _beam = beam;
128+ }
129+
118130template <class BeamType > BeamType &Experiment<BeamType>::beam() {
119131 return _beam;
120132}
121133
134+ template <class BeamType > void Experiment<BeamType>::set_scan(Scan scan) {
135+ _scan = scan;
136+ }
137+
138+ template <class BeamType >
139+ void Experiment<BeamType>::set_detector(Detector detector) {
140+ _detector = detector;
141+ }
142+
143+ template <class BeamType >
144+ void Experiment<BeamType>::set_goniometer(Goniometer goniometer) {
145+ _goniometer = goniometer;
146+ }
147+
148+ template <class BeamType >
149+ void Experiment<BeamType>::set_imagesequence(ImageSequence imagesequence) {
150+ _imagesequence = imagesequence;
151+ }
152+
122153template <class BeamType >
123154const std::string &Experiment<BeamType>::identifier() const {
124155 return _identifier;
125156}
126157template <class BeamType >
127158void Experiment<BeamType>::set_identifier(std::string identifier) {
128159 _identifier = identifier;
160+ }
161+
162+ template <class BeamType > void Experiment<BeamType>::generate_identifier() {
163+ _identifier = ersatz_uuid4 ();
129164}
0 commit comments