Commit 0bb7dc9c authored by Erik von Reis's avatar Erik von Reis
Browse files

Diaggui now has option to select double or single precision frequency buckets for swept sine.

xmlconv is fixed so that it displays double/complex32 arrays correctly.
parent 0a14d396
cds-crtools (3.0.0~rc1+deb10u2) UNRELEASED; urgency=medium
* Conflicting gds packages now constrained by version number
-- Erik von Reis <evonreis@caltech.edu> Wed, 11 Aug 2021 16:45:23 -0700
cds-crtools (3.0.0~rc1+deb10u1) testing; urgency=medium
* Version changed to 3.0.0 to make it superior to all previous gds
......
......@@ -737,6 +737,8 @@ namespace diag {
const int ssAChannelsDef = 0;
const char* const ssAverages = stAverages;
const int ssAveragesDef = 1;
const char ssDoublePrecFreq[] = "DoublePrecFreq";
const int ssDoublePrecFreqDef = 1;
const char ssMeasurementTime[] = "MeasurementTime";
const double ssMeasurementTimeDef[] = {0.1, 10};
const char ssSettlingTime[] = "SettlingTime";
......
......@@ -181,7 +181,13 @@ namespace diag {
semlock lockit (mux);
bool err = false;
// read double precision
if (!test->getParam (*storage->Test, ssDoublePrecFreq, doublePrecFreq)) {
errmsg << "Unable to load values from Test." <<
ssDoublePrecFreq << endl;
err = true;
}
// read measurement time
if (!test->getParam (*storage->Test,
ssMeasurementTime, *measTime, 2)) {
......@@ -1074,11 +1080,17 @@ namespace diag {
resT = aRes->newObject (0, N * (M + 1), 0,
rindex + resultnum, -1, gds_complex32);
resC = aRes->newObject (0, N * (M + 1), 0,
rindex + numA + resultnum, -1, gds_float64);
rindex + numA + resultnum, -1,
doublePrecFreq ? gds_float64 : gds_float32);
// cerr << "N = " << N << ", M = " << M << endl;
if (resT != 0) {
// set parameters of transfer function
aRes->setParam (*resT, stTransferFunctionSubtype, 6);
if(doublePrecFreq) {
aRes->setParam(*resT, stTransferFunctionSubtype, 6);
}
else {
aRes->setParam(*resT, stTransferFunctionSubtype, 3);
}
aRes->setParam (*resT, stTransferFunctionf0, (double) 0.0);
aRes->setParam (*resT, stTransferFunctiondf, (double) 0.0);
aRes->setParam (*resT, stTransferFunctiont0, id.ival.first);
......@@ -1103,7 +1115,12 @@ namespace diag {
}
if (resC != 0) {
// set parameters of coherence
aRes->setParam (*resC, stTransferFunctionSubtype, 7);
if(doublePrecFreq) {
aRes->setParam(*resC, stTransferFunctionSubtype, 7);
}
else {
aRes->setParam(*resC, stTransferFunctionSubtype, 5);
}
aRes->setParam (*resC, stTransferFunctionf0, (double) 0.0);
aRes->setParam (*resC, stTransferFunctiondf, (double) 0.0);
aRes->setParam (*resC, stTransferFunctiont0, id.ival.first);
......@@ -1142,8 +1159,13 @@ namespace diag {
// fill in transfer function coefficients
cerr << "DO SSINE 12 " << M << endl;
((double*) resT->value)[ndx] =
sstmps[resultnum].coeff[0].real();
if(doublePrecFreq) {
((double *)resT->value)[ndx] = sstmps[resultnum].coeff[0].real();
}
else {
((complex<float>*) resT->value)[ndx] =
- complex<float>(sstmps[resultnum].coeff[0]);
}
for (int b = 0; b < M; b++) {
complex<float>& x =
((complex<float>*) resT->value)[(b + 1) * N + ndx];
......@@ -1165,18 +1187,35 @@ namespace diag {
}
// fill in coherence coefficients
((double*) resC->value)[ndx] = sstmps[resultnum].coeff[0].real();
for (int b = 0; b < M; b++) {
double& x =
((double*) resC->value)[(b + 1) * N + ndx];
if (b != resultnum) {
if(doublePrecFreq) {
((double *)resC->value)[ndx] = sstmps[resultnum].coeff[0].real();
for (int b = 0; b < M; b++) {
double& x =
((double*) resC->value)[(b + 1) * N + ndx];
if (b != resultnum) {
x = ssCoherence ((dCmplx*) sstmps[resultnum].coeff + 2,
(dCmplx*) sstmps[b].coeff + 2, pAverages);
}
else {
(dCmplx*) sstmps[b].coeff + 2, pAverages);
}
else {
x = 1.0;
}
}
}
}
else {
((float*) resC->value)[ndx] = sstmps[resultnum].coeff[0].real();
for (int b = 0; b < M; b++) {
float& x =
((float*) resC->value)[(b + 1) * N + ndx];
if (b != resultnum) {
x = ssCoherence ((dCmplx*) sstmps[resultnum].coeff + 2,
(dCmplx*) sstmps[b].coeff + 2, pAverages);
}
else {
x = 1.0;
}
}
}
return true;
}
......
......@@ -220,7 +220,9 @@ namespace diag {
std::complex<double>* coeff;
};
// whether to use double precision for frequencies
int doublePrecFreq;
/// measurement time
double measTime[2];
/// settling time
......
......@@ -176,6 +176,7 @@ namespace diag {
p.fMeas.fBurstNoiseQuietTime_s = 0;
p.fMeas.fAverageType = 0;
p.fMeas.fPoints = 61;
p.fMeas.fDoublePrecFreq = 1;
p.fMeas.fTimeMeas[0] = (id == 3) ? 1 : 0.1;
p.fMeas.fTimeMeas[1] = 10;
p.fMeas.fHarmonicOrder = 1;
......@@ -944,6 +945,11 @@ namespace diag {
kSSAChannels, kNESInteger, kNEANonNegative);
fSSAChannels->Associate (this);
fSSFrame[2]->AddFrame (fSSAChannels, fSSLayout[1]);
TGLabel *double_label = new TGLabel(fSSFrame[2], " Double prec. Freqs:");
fSSFrame[2]->AddFrame( double_label, fSSLayout[1]);
fSSDoublePrecFreq = new TGCheckButton( fSSFrame[2], "", kSSDoublePrecFreqs);
fSSDoublePrecFreq->Associate(this);
fSSFrame[2]->AddFrame( fSSDoublePrecFreq, fSSLayout[1]);
// 4th line
fSSLabel[10] = new TGLabel (fSSFrame[3], "Measurement Time:");
fSSFrame[3]->AddFrame (fSSLabel[10], fSSLayout[1]);
......@@ -1751,6 +1757,7 @@ namespace diag {
delete fSSSweepFormat;
delete fSSSweepEdit;
delete fSSSweepEditText;
delete fSSDoublePrecFreq;
delete fSSMeasTimeSel[0];
delete fSSMeasTimeSel[1];
delete fSSMeasTime[0];
......@@ -2261,6 +2268,7 @@ namespace diag {
}
}
}
fParam->fMeas.fDoublePrecFreq = (fSSDoublePrecFreq->GetState() == kButtonDown);
for (int i = 0; i < 2; i++) {
if (fSSMeasTimeSel[i]->GetState() == kButtonDown) {
fParam->fMeas.fTimeMeas[i] =
......@@ -2425,6 +2433,7 @@ namespace diag {
fSSSweepType[i]->SetState
((sweeptype == i) ? kButtonDown : kButtonUp);
}
fSSDoublePrecFreq->SetState( fParam->fMeas.fDoublePrecFreq ? kButtonDown : kButtonUp);
Swap (fParam->fMeas.fTimeMeas[0], fParam->fMeas.fTimeMeas[1]);
for (int i = 0; i < 2; i++) {
if (fParam->fMeas.fTimeMeas[i] < 0) {
......
......@@ -198,8 +198,10 @@ namespace diag {
const Int_t kSSPowerSpec = kSSWindow + 1;
/// Swept sine Number of A channels widget id
const Int_t kSSAChannels = kSSPowerSpec + 1;
/// Swept sine use double precision frequency buckets
const Int_t kSSDoublePrecFreqs = kSSAChannels + 1;
/// Swept sine measurement time selection widget ids
const Int_t kSSMeasTimeSel = kSSAChannels + 1;
const Int_t kSSMeasTimeSel = kSSDoublePrecFreqs + 1;
/// Swept sine measurement time widget id
const Int_t kSSMeasTime = kSSMeasTimeSel + 2;
/// Swept sine averages widget id
......@@ -474,6 +476,8 @@ namespace diag {
Double_t fBurstNoiseQuietTime_s;
/// Number of points
Int_t fPoints;
// whether to store double precision frequency values
Int_t fDoublePrecFreq;
/// Measurement time
Double_t fTimeMeas[2];
/// Harmonic order
......@@ -784,6 +788,8 @@ namespace diag {
TGButton* fSSSweepDir[2];
/// Swept sine sweep type
TGButton* fSSSweepType[3];
// Swept sine frequency bucket precision
TGButton* fSSDoublePrecFreq;
/// Swept sine measurement time selection
TGButton* fSSMeasTimeSel[2];
/// Swept sine measurement time selection
......
......@@ -1478,6 +1478,7 @@ namespace diag {
fCmdLine->getVar (testvar (ssNumberOfPoints), fParam->fMeas.fPoints);
fCmdLine->getVar (testvar (ssAChannels), fParam->fMeas.fAChannels);
fCmdLine->getVar (testvar (ssAverages), fParam->fMeas.fAverages);
fCmdLine->getVar (testvar (ssDoublePrecFreq), fParam->fMeas.fDoublePrecFreq);
fCmdLine->getVar (testvar (ssMeasurementTime), fParam->fMeas.fTimeMeas[0], 2);
fCmdLine->getVar (testvar (ssSettlingTime), fParam->fMeas.fTimeSettling);
fCmdLine->getVar (testvar (ssRampDown), fParam->fMeas.fRampDownTime) ;
......@@ -1819,6 +1820,7 @@ namespace diag {
fCmdLine->putVar (testvar (ssNumberOfPoints), fParam->fMeas.fPoints);
fCmdLine->putVar (testvar (ssAChannels), fParam->fMeas.fAChannels);
fCmdLine->putVar (testvar (ssAverages), fParam->fMeas.fAverages);
fCmdLine->putVar (testvar (ssDoublePrecFreq), fParam->fMeas.fDoublePrecFreq);
fCmdLine->putVar (testvar (ssMeasurementTime), fParam->fMeas.fTimeMeas, 2);
fCmdLine->putVar (testvar (ssSettlingTime), fParam->fMeas.fTimeSettling);
fCmdLine->putVar (testvar (ssRampDown), fParam->fMeas.fRampDownTime) ;
......
......@@ -384,6 +384,7 @@
double dx = 1.0; // x coordinat spacing
bool xIncluded = false; // x coordinate included?
bool dataStride = false; // data stored in stride format?
bool xDouble = false; // true if x is a double precision real, not a complex32
// determine parameters names for x0, dx and xLen
xLen = dat->dimension[0];
......@@ -410,6 +411,7 @@
deltaname = stTransferFunctiondf;
Nname = stTransferFunctionN;
xIncluded = (stype >= 3);
xDouble = (stype == 6);
dataStride = true;
}
else if (otype == stObjectTypeCoefficients) {
......@@ -554,8 +556,13 @@
else {
ndx = i * xStride * dat->elSize();
}
complex<double> y =
get_val ((char*) dat->value + ndx, dat->datatype);
complex<double> y;
if(xDouble){
y = get_val((char*) dat->value + ndx, gds_float64);
}
else {
y = get_val((char *)dat->value + ndx, dat->datatype);
}
write_val (out, y, (dtype == gds_channel) ? gds_string : dtype);
if ((dtype == gds_string) || (dtype == gds_channel)) {
out << " " << setw (12) << setprecision (8) << showpos;
......
......@@ -2022,6 +2022,8 @@ namespace diag {
&ssAChannelsDef, 1));
dParams.push_back (diagParam (ssAverages, 0, 0, gds_int32,
&ssAveragesDef, 1));
dParams.push_back (diagParam (ssDoublePrecFreq, 0, 0, gds_int32,
&ssDoublePrecFreq, 1));
dParams.push_back (diagParam (ssMeasurementTime, 0, 0, gds_float64,
ssMeasurementTimeDef, 2, "s"));
dParams.push_back (diagParam (ssSettlingTime, 0, 0, gds_float64,
......
Supports Markdown
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