Commit ab8c770d authored by d22's avatar d22
Browse files

spectrum is now saved in absoption when using D22SampleSequencer

parent b99b8251
......@@ -57,6 +57,7 @@ CountWithSpectro::CountWithSpectro(const std::string & name) :
inSequencerMode.init(this, NOSAVE, "in_sequencer_mode");
yDataArray.init(this, NOSAVE, "yData_array");
yDataArrayInAbsorbance.init(this, NOSAVE, "yData_array_absorbance");
initialTime.init(this, NOSAVE, "initial_time");
measureDuration.init(this, NOSAVE, "measure_duration");
......@@ -324,12 +325,21 @@ void CountWithSpectro::initArrays() {
m_yDataArray = new float64[totalSize];
memset(m_yDataArray, 0, totalSize * sizeof(float64)); //set to zero
yDataArray.update(m_yDataArray);
yDataArray.setSize(totalSize+2);
yDataArray.setSize(totalSize+2); // +2 ??
m_yDataArraySecondChannel = new float64[totalSize];
memset(m_yDataArraySecondChannel, 0, totalSize * sizeof(float64)); //set to zero
yDataArraySecondChannel.update(m_yDataArraySecondChannel);
yDataArraySecondChannel.setSize(totalSize);
// Initialize too the property used to store absorption data
float64* yDataAbs = new float64[totalSize];
memset(yDataAbs, 0, totalSize * sizeof(float64)); //set to zero
yDataArrayInAbsorbance.update(yDataAbs);
yDataArrayInAbsorbance.setSize(totalSize);
delete[] yDataAbs;
yDataAbs = nullptr;
}
......@@ -378,6 +388,22 @@ void CountWithSpectro::saveSpectroDataInShiftedMode() {
int32 totalSize = YSIZE * numSpectroMeasures();
yDataArray.update(m_yDataArrayToSave); // Change local array used to store propertyArray values
yDataArray.setSize(totalSize);
// New! Store data in absorbance units (in nexus file) ONLY WHEN WE TAKE A SINGLE SPECTRUM measure
if (spectro->y0Data.getSize() == YSIZE && numSpectroMeasures() == 1) { // Check we have a y0 measured already
float64* absorptionData = new float64[totalSize];
memset(absorptionData, 0, totalSize * sizeof(float64)); //set to zero
float64* intensity0 = spectro->y0Data();
for (int32 j = 0; j < totalSize; j++) {
absorptionData[j] = ::log(((intensity0[j]) / m_yDataArrayToSave[j]));
}
yDataArrayInAbsorbance.update(absorptionData);
yDataArrayInAbsorbance.setSize(totalSize);
delete[] absorptionData;
absorptionData = nullptr;
}
}
float64 CountWithSpectro::getCountTimeInSec() {
......
......@@ -67,6 +67,7 @@ public:
ArrayProperty<float64> yDataArray;
ArrayProperty<float64> yDataArraySecondChannel;
ArrayProperty<float64> yDataArrayInAbsorbance;
DynamicProperty<int32> measureDuration;
Property<std::string> initialTime;
......
......@@ -274,6 +274,7 @@ void D22SpectroSampleSequencer::start() {
m_CountStarted = true;
countWithSpectro->useSwitcher = false; //always in NO switcher mode
countWithSpectro->inSequencerMode = true;
countWithSpectro->numSpectroMeasures = 1;
countWithSpectro->startCommand();
m_CountStarted = false;
} else {
......
......@@ -7,6 +7,6 @@
<label role="d22spectroSampleSequencer1" property="time_type" spaceBefore="false" />
<newLine />
<text role="d22spectroSampleSequencer1" prefix="sample_sequencer.integration_time" property="integration_time" suffix="sample_sequencer.integration_timeSuffix" />
<text role="d22spectroSampleSequencer1" property="num_spectro" prefix="sample_sequencer.numSpectro"/>
<!-- <text role="d22spectroSampleSequencer1" property="num_spectro" prefix="sample_sequencer.numSpectro"/> -->
<text role="d22spectroSampleSequencer1" prefix="sample_sequencer.scan_average" property="scans_average" />
</plugin>
\ No newline at end of file
......@@ -5,7 +5,7 @@
</group>
<group title="sample_sequencer.spectroGroup">
<text role="d22spectroSampleSequencer1" prefix="sample_sequencer.integration_time" property="integration_time" suffix="sample_sequencer.integration_timeSuffix" />
<text role="d22spectroSampleSequencer1" property="num_spectro" prefix="sample_sequencer.numSpectro" key="numSpectroMeasuresText" />
<!-- <text role="d22spectroSampleSequencer1" property="num_spectro" prefix="sample_sequencer.numSpectro" key="numSpectroMeasuresText" /> -->
<text role="d22spectroSampleSequencer1" prefix="sample_sequencer.scan_average" property="scans_average" />
</group>
<newLine />
......
......@@ -32,7 +32,7 @@ const std::string QE65000Controller::COUNT_SINGLE = "count_single";
const std::string QE65000Controller::COUNT_SWITCHER = "count_switcher";
QE65000Controller::QE65000Controller(const std::string& name) :
ExperimentController(TYPE, name), controller::Stoppable(this) {
ExperimentController(TYPE, name), controller::Stoppable(this),Autozero(this) {
setFamily(family::SAMPLE_ENVIRONMENT);
......@@ -42,10 +42,8 @@ QE65000Controller::QE65000Controller(const std::string& name) :
integrationTime.init(this, SAVE, "integration_time");
xData.init(this, NOSAVE, "x_data");
yData.init(this, NOSAVE, "y_data");
// yDataBlock.init(this, NOSAVE, "y_data_block");
y0Data.init(this, NOSAVE, "y0_data");
size.init(this, SAVE, "size");
// blockSize.init(this, SAVE, "block_size");
// zSize.init(this, SAVE, "z_size");
spectroStatus.init(this, SAVE, "spectro_status");
spectroStatusMessage.init(this, SAVE, "spectro_status_message");
spectroOpenErrorMessage.init(this, SAVE, "spectro_open_error_message");
......@@ -86,7 +84,6 @@ void QE65000Controller::postConfiguration() {
//Get size from driver
size = spectroDriver->size();
// zSize = 1;
}
void QE65000Controller::refreshIntegrationTime(int32 time) {
......@@ -139,12 +136,18 @@ void QE65000Controller::start() {
spectroDriver.execute("start", false);
commandProgression = 75;
float64* tempYData = new float64[size()];
memset(tempYData, 0, size() * sizeof(float64));
for (int32 j = 0; j < size(); j++) {
tempYData[j] = tempYData[j] / integrationTime();
}
//x data
xData.update(spectroDriver->xData());
xData.setSize(size());
//y data
yData.update(spectroDriver->yData());
yData.update(tempYData);
yData.setSize(size());
//To take those changes into account do the following:
......@@ -154,6 +157,9 @@ void QE65000Controller::start() {
commandProgression = 99;
spectroDriver.execute("stop", false);
delete[] tempYData;
tempYData = nullptr;
} else {
//REVISE THE USAGE OF THE ARRAYS HERE
float64* tempYData;
......@@ -181,6 +187,7 @@ void QE65000Controller::start() {
//y data
tempYData = spectroDriver->yData();
for (int32 j = 0; j < size(); j++) {
tempYData[j] = tempYData[j] / integrationTime();
finalYData[j] = finalYData[j] + tempYData[j];
if (i == scansToAverage() - 1) {
finalYData[j] = finalYData[j] / scansToAverage();
......@@ -227,76 +234,54 @@ void QE65000Controller::setPlotName(int32 plotId) {
numor.update(plotId);
}
/*
* This method is called from HPLC system. Delete after tests
*/
/*
void QE65000Controller::doContinuousMeasurement() {
m_StopActivated = false;
// Move the init to another place
spectroDriver.execute("init", false);
// Initialize arrays of data and vectors
float64* tempYData = new float64[size()];
memset(tempYData, 0, size() * sizeof(float64));
yDataVector.clear();
// We assume to average measures
scansToAverage = 1;
// Measure until time is reached
common::Date startTime = common::Date();
common::Date actualTime = startTime;
common::Duration duration = actualTime - startTime;
while ((duration.getSeconds() < timeOfMeasure()) && (!m_StopActivated)) {
void QE65000Controller::makeAutozero() {
spectroDriver.execute("start", true);
// We do not do a measure... we just copy the last spectrum done as our intensity0
if (!spectroDriver->commandStatus.isRunning()) {
y0Data.update(yData());
y0Data.setSize(size());
// Last size of data measured
int32 yDataSize = spectroDriver->size();
tempYData = spectroDriver->yData();
for (int32 j = 0; j < yDataSize; j++) {
yDataVector.push_back(tempYData[j]);
}
// Update time
actualTime = common::Date();
duration = (actualTime - startTime);
// Update data used for graphical purposes
xData.update(spectroDriver->xData());
xData.update(spectroDriver->xData()); // do not forget the x axis
xData.setSize(size());
yData.update(spectroDriver->yData());
yData.setSize(size());
xData.sendEvent();
yData.sendEvent();
// Update the content of the vector after each measure
int32 vectorSize = yDataVector.size();
float64* tempYBlockData = new float64[vectorSize];
memset(tempYBlockData, 0, vectorSize * sizeof(float64));
std::copy(yDataVector.begin(), yDataVector.end(), tempYBlockData);
yDataBlock.update(tempYBlockData);
yDataBlock.setSize(vectorSize);
blockSize = vectorSize / size();
y0Data.sendEvent();
}
// Stop measurement
spectroDriver.execute("stop", false);
// Do a single measure and store it locally as I0
// if(!spectroDriver->commandStatus.isRunning()) {
//
// float64* tempYData = new float64[size()];
// float64* finalYData = new float64[size()];
// memset(tempYData, 0, size() * sizeof(float64));
// memset(finalYData, 0, size() * sizeof(float64));
//
// for (int32 i = 0; i < scansToAverage(); i++) {
// spectroDriver.execute("start", false);
//
// tempYData = spectroDriver->yData();
// for (int32 j = 0; j < size(); j++) {
// tempYData[j] = tempYData[j] / integrationTime();
// finalYData[j] = finalYData[j] + tempYData[j];
// if (i == scansToAverage() - 1) {
// finalYData[j] = finalYData[j] / scansToAverage();
// }
// }
//
// }
// y0Data.update(finalYData);
// y0Data.setSize(size());
//
// xData.update(spectroDriver->xData()); // do not forget the x axis
// xData.setSize(size());
//
// xData.sendEvent();
// y0Data.sendEvent();
//
// spectroDriver.execute("stop", false); // is it necessary?
// }
}
*/
}
......@@ -26,7 +26,21 @@ using namespace oceanoptics;
namespace spectrometer {
class QE65000Controller : public ExperimentController , public controller::Stoppable {
class Autozero: private controller::Command {
public:
Autozero(ExperimentController * c) :
controller::Command(c, "makeAutozero", &Autozero::makeAutozero, this) {
}
virtual void makeAutozero() = 0;
void makeAutozeroCommand(bool logging = false) {
command(logging, true);
}
};
class QE65000Controller : public ExperimentController , public controller::Stoppable, public Autozero {
public:
......@@ -46,12 +60,10 @@ public:
Property<std::string> spectroOpenErrorMessage;
Property<int32> scansToAverage;
Property<int32> size;
// Property<int32> blockSize;
// Property<int32> zSize;
ArrayProperty<float64> xData;
ArrayProperty<float64> yData;
// ArrayProperty<float64> yDataBlock; // This property is used in continuous measurement
ArrayProperty<float64> y0Data;
Property<std::string> mode; // This property is used for nexus files to indicate how was used the spectro when saving the data (when being used with a count)
// possible values are: SEQUENCE, COUNT_SINGLE, COUNT_SWITCHER and idle.
......@@ -79,13 +91,12 @@ public:
void setPlotName(int32 plotId);
// Delete after tests
// void doContinuousMeasurement();
private:
bool m_StopActivated;
std::vector<float64> yDataVector;
virtual void makeAutozero();
};
......
spectro1.integration_timePrefix=Integration Time:
spectro1.integration_timeSuffix=~mus
spectro1.plotTitle=Spectrum
spectro1.plotIntensity0Title=Intensity 0 Spectrum
spectro1.plotXAxisLegend=Wavelength
spectro1.plotYAxisLegend=
spectro1.spectrumPlotPrefix=Intensity
spectro1.intensity0PlotPrefix=Intensity 0
spectro1.dataLegend=Data
spectro1.intensity0Legend=Intensity 0
spectro1.scansToAverage=Scans to average
spectro1.commandAutozero=Save as I0
......@@ -3,4 +3,8 @@
<dataX p_role="spectro1" p_name="x_data"/>
<dataY p_role="spectro1" p_name="y_data"/>
</plotdata>
<plotdata key="intensity0" legend_key="spectro1.intensity0Legend" color="1F96C0" plugins="COMMAND|SETUP">
<dataX p_role="spectro1" p_name="x_data"/>
<dataY p_role="spectro1" p_name="y0_data"/>
</plotdata>
</plotdatas>
<plugin>
<controller type="spectro" role="spectro1"/>
<text role="spectro1" property="integration_time" prefix="spectro1.integration_timePrefix" suffix="spectro1.integration_timeSuffix"/>
<newline/>
<plot_launcher role="spectro1" data="data" title="spectro1.plotTitle" x_axis_title="spectro1.plotXAxisLegend" y_axis_title="spectro1.plotYAxisLegend" height="20"/>
<newline/>
<text role="spectro1" property="scans_average" prefix="spectro1.scansToAverage"/>
<plot_launcher role="spectro1" data="data" title="spectro1.plotTitle" x_axis_title="spectro1.plotXAxisLegend" y_axis_title="spectro1.plotYAxisLegend" height="20"/>
<simple_label prefix="spectro1.spectrumPlotPrefix"/>
<newLine/>
<button role="spectro1" command="makeAutozero" prefix="spectro1.commandAutozero"/>
<plot_launcher role="spectro1" data="intensity0" title="spectro1.plotIntensity0Title" x_axis_title="spectro1.plotXAxisLegend" y_axis_title="spectro1.plotYAxisLegend" height="20"/>
<simple_label prefix="spectro1.intensity0PlotPrefix"/>
<summary>
<summary_content>
<label role="spectro1" property="spectro_status_message"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment