Ticket #4963 (closed: fixed)
ExperimentInfo::saveExperimentInfoNexus: Much of the method belongs in the Instrument class
Reported by: | Russell Taylor | Owned by: | Karl Palmen |
---|---|---|---|
Priority: | major | Milestone: | Release 2.6 |
Component: | Framework | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Tester: | Michael Reuter |
Description
Comments placed in ticket #4781 that weren't addressed before it was closed:
I'm thinking that most of the code added here is in the wrong place - that it belongs in Instrument rather than ExperimentInfo. It may be that you want positions etc. after any parameters have been applied to the base instrument (and if not, I think that's what you're getting), but that should work fine if a parameterized instrument is created using getInstrument and acted upon.
At minimum multiple calls to getInstrument() should be avoided as they construct a whole new instrument every time.
Change History
comment:2 Changed 8 years ago by Nick Draper
- Status changed from new to assigned
- Owner set to Karl Palmen
comment:4 Changed 7 years ago by Karl Palmen
It looks like all the code that writes the instrument group into the Nexus file could be transferred to a new function of instrument. This function would need to take the parameter map got by constInstrumentParameters() as an argument.
comment:6 Changed 7 years ago by Karl Palmen
- Status changed from assigned to accepted
ExperimentInfo::saveExperimentInfoNexus currently calls getInstrument once and saves it to a pointer for later use. So the minimum requirement is already met.
comment:7 Changed 7 years ago by Karl Palmen
- Status changed from accepted to verify
- Resolution set to fixed
To test, check that there is only one call of getInstrument in ExperimentInfo::saveExperimentInfoNexus.
There is no need to call the git macros for this test.
comment:8 Changed 7 years ago by Michael Reuter
- Status changed from verify to verifying
- Tester set to Michael Reuter
comment:9 Changed 7 years ago by Michael Reuter
- Status changed from verifying to reopened
- Resolution fixed deleted
The second point wasn't completely addressed as the function saveDetectorSetInfoToNexus called from within saveExperimentInfoNexus has a call to getInstrument.
The first and most major point was not addressed at all. The point was that the saveExperimentInfoNexus function should look something like this:
Instrument_const_sptr instrument = getInstrument(); instrument->saveNexus(file, "instrument"); m_sample->saveNexus(file, "sample"); m_run->saveNexus(file, "logs");
where all the saving is off-loaded to the respective objects. There is the beginnings of a Instrument::saveNexus and ParameterMap::saveNexus already exists. Just beware that calling ParameterMap::saveNexus from within Instrument::saveNexus can only be done when Instrument::isParameterized is true.
comment:11 Changed 7 years ago by Karl Palmen
Use parameterMap::saveNexus re #4963
Signed-off-by: Karl Palmen <karl.palmen@…>
Changeset: d9980051c0f349ce461a339e2d8845dfd758bfc0
comment:12 Changed 7 years ago by Karl Palmen
saveDetectorSetInfoToNexus can be moved from ExperimentInfo to Instrument to enable SaveExperimentInfoNexus to be so moved.
comment:13 Changed 7 years ago by Karl Palmen
Move code from ExperimentInfo to Instrument re #4963
Signed-off-by: Karl Palmen <karl.palmen@…>
Changeset: 981cce74a16ce5efa42bbc1e7cb5f670a381997d
comment:14 Changed 7 years ago by Karl Palmen
To test look at the code for ExperimentInfo and check that SetExperimentInfoNexus is now very short and saveDetectorSetInfoToNexus no longer exists in this class.
Then load a raw file file save the workspace to nexus, load the nexus file. Look at the instrument in both workspaces and check that both instruments look the same.
comment:15 Changed 7 years ago by Karl Palmen
- Status changed from accepted to verify
- Resolution set to fixed
comment:17 Changed 7 years ago by Michael Reuter
- Status changed from verifying to closed
Merge remote-tracking branch 'origin/feature/4963_instrument_save_nexus'
comment:18 Changed 7 years ago by Michael Reuter
This looks to be working just fine.
comment:20 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 5809
Commit 663bd7edac0f2ae56b81e1bb0e21a437d2a1c988 was mistakenly filed under #4962.