Showing with 355 additions and 392 deletions.
  1. +42 −79 src/libkst/datavector.cpp
  2. +0 −2 src/libkst/datavector.h
  3. +8 −8 src/libkst/editablevector.cpp
  4. +4 −4 src/libkst/generatedvector.cpp
  5. +74 −86 src/libkst/vector.cpp
  6. +20 −6 src/libkst/vector.h
  7. +2 −2 src/libkstmath/csd.cpp
  8. +4 −4 src/libkstmath/equation.cpp
  9. +2 −2 src/libkstmath/eventmonitorentry.cpp
  10. +2 −2 src/libkstmath/histogram.cpp
  11. +2 −2 src/libkstmath/psd.cpp
  12. +1 −1 src/libkstmath/psdcalculator.cpp
  13. +1 −1 src/libkstmath/psdcalculator.h
  14. +35 −35 src/plugins/dataobject/activitylevel/activitylevel.cpp
  15. +3 −3 src/plugins/dataobject/bin/bin.cpp
  16. +4 −4 src/plugins/dataobject/chop/chop.cpp
  17. +2 −2 src/plugins/dataobject/convolution/convolve/convolve.cpp
  18. +2 −2 src/plugins/dataobject/convolution/deconvolve/deconvolve.cpp
  19. +7 −7 src/plugins/dataobject/correlation/autocorrelation/autocorrelation.cpp
  20. +7 −7 src/plugins/dataobject/correlation/crosscorrelation/crosscorrelation.cpp
  21. +9 −9 src/plugins/dataobject/crossspectrum/crossspectrum.cpp
  22. +2 −2 src/plugins/dataobject/genericfilter/genericfilter.cpp
  23. +5 −5 src/plugins/dataobject/interpolations/interpolations.h
  24. +4 −4 src/plugins/dataobject/linefit/linefit.cpp
  25. +4 −4 src/plugins/dataobject/lockin/lockin.cpp
  26. +2 −2 src/plugins/dataobject/noiseaddition/noiseaddition.cpp
  27. +8 −8 src/plugins/dataobject/periodogram/periodogram.cpp
  28. +8 −8 src/plugins/dataobject/phase/phase.cpp
  29. +4 −4 src/plugins/dataobject/shift/shift.cpp
  30. +4 −4 src/plugins/dataobject/syncbin/syncbin.cpp
  31. +2 −2 src/plugins/filters/cumulativeaverage/cumulativeaverage.cpp
  32. +2 −2 src/plugins/filters/cumulativesum/cumulativesum.cpp
  33. +7 −7 src/plugins/filters/despike/filterdespike.cpp
  34. +2 −2 src/plugins/filters/differentiation/differentiation.cpp
  35. +2 −2 src/plugins/filters/filters.h
  36. +2 −2 src/plugins/filters/unwind/filterunwind.cpp
  37. +2 −2 src/plugins/filters/window/filterwindow.cpp
  38. +3 −3 src/plugins/fits/common.h
  39. +6 −6 src/plugins/fits/gradient_unweighted/fitgradient_unweighted.cpp
  40. +6 −6 src/plugins/fits/gradient_weighted/fitgradient_weighted.cpp
  41. +11 −11 src/plugins/fits/kneefrequency/fitkneefrequency.cpp
  42. +4 −4 src/plugins/fits/linear.h
  43. +9 −9 src/plugins/fits/linear_unweighted/fitlinear_unweighted.cpp
  44. +4 −4 src/plugins/fits/linear_weighted.h
  45. +9 −9 src/plugins/fits/linear_weighted/fitlinear_weighted.cpp
  46. +6 −6 src/plugins/fits/non_linear.h
  47. +6 −6 src/plugins/fits/non_linear_weighted.h
121 changes: 42 additions & 79 deletions src/libkst/datavector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
a datasource.
-------------------
begin : Fri Sep 22 2000
copyright : (C) 2000-2010 by C. Barth Netterfield
copyright : (C) 2000-2015 by C. Barth Netterfield
email : netterfield@astro.utoronto.ca
***************************************************************************/

Expand Down Expand Up @@ -68,7 +68,6 @@ DataVector::DataVector(ObjectStore *store)
: Vector(store), DataPrimitive(this) {

_saveable = true;
//_dontUseSkipAccel = false;
_numSamples = 0;
_scalars["sum"]->setValue(0.0);
_scalars["sumsquared"]->setValue(0.0);
Expand Down Expand Up @@ -131,7 +130,6 @@ void DataVector::change(DataSourcePtr in_file, const QString &in_field,
Skip = 1;
}

//_dontUseSkipAccel = false;
setDataSource(in_file);
ReqF0 = in_f0;
ReqNF = in_n;
Expand Down Expand Up @@ -348,7 +346,6 @@ LabelInfo DataVector::labelInfo() const {
void DataVector::reset() { // must be called with a lock
Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);

//_dontUseSkipAccel = false;
if (dataSource()) {
SPF = dataInfo(_field).samplesPerFrame;
}
Expand Down Expand Up @@ -501,7 +498,7 @@ void DataVector::internalUpdate() {
}
}

memmove(_v, _v+shift, _numSamples*sizeof(double));
memmove(_v_raw, _v_raw+shift, _numSamples*sizeof(double));
}

if (DoSkip) {
Expand All @@ -513,37 +510,9 @@ void DataVector::internalUpdate() {
return;
}
}
// FIXME maybe.
// -skip acceleration is not supported by any current data sources.
// -there is no API implemented to report if a data source implements skip accel
// so: for now, just say it isn't supported here. Fix if we ever implement a data source
// where skip accel is important (eg, planck HFI...)
#if 0
_dontUseSkipAccel = true;
if (!_dontUseSkipAccel) { // ie, use skip accel. Not used.
int rc;
int lastRead = -1;
if (DoAve) {
// We don't support boxcar inside data sources yet.
_dontUseSkipAccel = true;
} else {
rc = readField(_v + _numSamples, _field, new_f0, (new_nf - NF)/Skip, Skip, &lastRead);
if (rc != -9999) {
if (rc >= 0) {
n_read = rc;
} else {
n_read = 0;
}
} else {
_dontUseSkipAccel = true;
}
}
}
#endif
// if (_dontUseSkipAccel) {
n_read = 0;
/** read each sample from the File */
double *t = _v + _numSamples;
double *t = _v_raw + _numSamples;
int new_nf_Skip = new_nf - Skip;
if (DoAve) {
for (i = NF; new_nf_Skip >= i; i += Skip) {
Expand Down Expand Up @@ -572,7 +541,6 @@ void DataVector::internalUpdate() {
n_read += readField(t++, _field, new_f0 + i, -1);
}
}
// } // end if _dontUseSkipAccel
} else {
// reallocate V if necessary
if ((new_nf - 1)*SPF + 1 != _size) {
Expand All @@ -583,13 +551,9 @@ void DataVector::internalUpdate() {
}
}

//if (NF > 0) {
// NF--; /* last frame read was only partially read... */
//}

// read the new data from file
if (start_past_eof) {
_v[0] = NOPOINT;
_v_raw[0] = NOPOINT;
n_read = 1;
} else if (info.samplesPerFrame > 1) {
if (NF>0) {
Expand All @@ -600,13 +564,13 @@ void DataVector::internalUpdate() {
assert(new_f0 + NF >= 0);
//assert(new_f0 + safe_nf - 1 >= 0);
if ((new_f0 + safe_nf - 1 >= 0) && (safe_nf - NF > 1)) {
n_read = readField(_v+NF*SPF, _field, new_f0 + NF, safe_nf - NF - 1);
n_read += readField(_v+(safe_nf-1)*SPF, _field, new_f0 + safe_nf - 1, -1);
n_read = readField(_v_raw+NF*SPF, _field, new_f0 + NF, safe_nf - NF - 1);
n_read += readField(_v_raw+(safe_nf-1)*SPF, _field, new_f0 + safe_nf - 1, -1);
}
} else {
assert(new_f0 + NF >= 0);
if (new_nf - NF > 0 || new_nf - NF == -1) {
n_read = readField(_v+NF*SPF, _field, new_f0 + NF, new_nf - NF);
n_read = readField(_v_raw+NF*SPF, _field, new_f0 + NF, new_nf - NF);
}
}
}
Expand All @@ -626,7 +590,7 @@ void DataVector::internalUpdate() {
if (_numSamples != _size && !(_numSamples == 0 && _size == 1)) {
_dirty = true;
for (i = _numSamples; i < _size; ++i) {
_v[i] = _v[0];
_v_raw[i] = _v_raw[0];
}
}

Expand All @@ -648,42 +612,41 @@ void DataVector::internalUpdate() {

QByteArray DataVector::scriptInterface(QList<QByteArray> &c)
{
Q_ASSERT(c.size());
if(c[0]=="changeFrames") {
// int f0, int n, int skip, bool in_doSkip, bool in_doAve;
if(c.size()!=6) {
return QByteArray("Bad parameter count (!=5).");
}
changeFrames(c[1].toInt(),c[2].toInt(),c[3].toInt(),(c[4]=="true")?1:0,(c[5]=="true")?1:0);
return QByteArray("Done.");
} else if(c[0]=="numFrames") {
return QByteArray::number(numFrames());
} else if(c[0]=="startFrame") {
return QByteArray::number(startFrame());
} else if(c[0]=="doSkip") {
return QByteArray(doSkip()?"true":"false");
} else if(c[0]=="doAve") {
return QByteArray(doAve()?"true":"false");
} else if(c[0]=="skip") {
return QByteArray::number(skip());
} else if(c[0]=="reload") {
reload();
return QByteArray("Done");
} else if(c[0]=="samplesPerFrame") {
return QByteArray::number(samplesPerFrame());
} else if(c[0]=="fileLength") {
return QByteArray::number(fileLength());
} else if(c[0]=="readToEOF") {
return QByteArray(readToEOF()?"true":"false");
} else if(c[0]=="countFromEOF") {
return QByteArray(countFromEOF()?"true":"false");
} else if(c[0]=="descriptionTip") {
return QByteArray(descriptionTip().toLatin1());
} else if(c[0]=="isValid") {
return isValid()?"true":"false";
Q_ASSERT(c.size());
if(c[0]=="changeFrames") {
if(c.size()!=6) {
return QByteArray("Bad parameter count (!=5).");
}

return "No such command...";
changeFrames(c[1].toInt(),c[2].toInt(),c[3].toInt(),(c[4]=="true")?1:0,(c[5]=="true")?1:0);
return QByteArray("Done.");
} else if(c[0]=="numFrames") {
return QByteArray::number(numFrames());
} else if(c[0]=="startFrame") {
return QByteArray::number(startFrame());
} else if(c[0]=="doSkip") {
return QByteArray(doSkip()?"true":"false");
} else if(c[0]=="doAve") {
return QByteArray(doAve()?"true":"false");
} else if(c[0]=="skip") {
return QByteArray::number(skip());
} else if(c[0]=="reload") {
reload();
return QByteArray("Done");
} else if(c[0]=="samplesPerFrame") {
return QByteArray::number(samplesPerFrame());
} else if(c[0]=="fileLength") {
return QByteArray::number(fileLength());
} else if(c[0]=="readToEOF") {
return QByteArray(readToEOF()?"true":"false");
} else if(c[0]=="countFromEOF") {
return QByteArray(countFromEOF()?"true":"false");
} else if(c[0]=="descriptionTip") {
return QByteArray(descriptionTip().toLatin1());
} else if(c[0]=="isValid") {
return isValid()?"true":"false";
}

return "No such command...";
}


Expand Down
2 changes: 0 additions & 2 deletions src/libkst/datavector.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ class KSTCORE_EXPORT DataVector : public Vector, public DataPrimitive

bool checkIntegrity(); // must be called with a lock

//bool _dontUseSkipAccel;

// wrappers around DataSource interface functions
int readField(double *v, const QString& field, int s, int n, int skip = -1);
const DataInfo dataInfo(const QString& field) const;
Expand Down
16 changes: 8 additions & 8 deletions src/libkst/editablevector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ void EditableVector::setValue(const int &i, const double &val) { //sa Vector::ch
if(i>_size) {
resize(i,1);
}
_scalars["sum"]->setValue(_sum+val-_v[i]);
_scalars["sum"]->setValue(_sum+val-_v_out[i]);
_scalars["sumsquared"]->setValue(_sum*_sum);
_scalars["max"]->setValue(qMax(_max,val));
_scalars["min"]->setValue(qMin(_min,val));
if (val>=0.0) {
_scalars["minpos"]->setValue(qMin(_minPos,val));
}
_scalars["last"]->setValue(_v[_size-1]);
_scalars["first"]->setValue(_v[0]);
_v[i]=val;
_scalars["last"]->setValue(_v_out[_size-1]);
_scalars["first"]->setValue(_v_out[0]);
_v_raw[i]=val;
unlock();
}

Expand All @@ -78,7 +78,7 @@ void EditableVector::save(QXmlStreamWriter &s) {
QDataStream qds(&qba, QIODevice::WriteOnly);

for (int i = 0; i < length(); i++) {
qds << _v[i];
qds << _v_raw[i];
}

s.writeTextElement("data", qCompress(qba).toBase64());
Expand All @@ -94,7 +94,7 @@ void EditableVector::loadFromTmpFile(QFile &fp) {

resize(fp.size()/sizeof(double));

n_read = fp.read((char *)_v, fp.size());
n_read = fp.read((char *)_v_raw, fp.size());

if (n_read != fp.size()) {
resize(n_read/sizeof(double));
Expand All @@ -107,10 +107,10 @@ QString EditableVector::_automaticDescriptiveName() const {

QString name("(");
if (length()>=1) {
name += QString::number(_v[0]);
name += QString::number(_v_out[0]);
}
if (length()>=2) {
name += " " + QString::number(_v[1]);
name += " " + QString::number(_v_out[1]);
}

if (length()>=3) {
Expand Down
8 changes: 4 additions & 4 deletions src/libkst/generatedvector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void GeneratedVector::changeRange(double x0, double x1, int n) {
}

for (int i = 0; i < n; i++) {
_v[i] = x0 + double(i) * (x1 - x0) / double(n - 1);
_v_raw[i] = x0 + double(i) * (x1 - x0) / double(n - 1);
}

_min = x0;
Expand All @@ -88,16 +88,16 @@ void GeneratedVector::setSaveData(bool save) {
}

QString GeneratedVector::_automaticDescriptiveName() const {
return QString::number(_v[0])+".."+QString::number(_v[length()-1]);
return QString::number(_v_raw[0])+".."+QString::number(_v_raw[length()-1]);
}

QString GeneratedVector::descriptionTip() const {
return tr("Generated Vector: %1\n"
" %2 values from %3 to %4").arg(Name()).arg(length()).arg(_v[0]).arg(_v[length()-1]);
" %2 values from %3 to %4").arg(Name()).arg(length()).arg(_v_raw[0]).arg(_v_raw[length()-1]);
}

QString GeneratedVector::propertyString() const {
return tr("%3 points from %1 to %2").arg(_v[0]).arg(_v[length()-1]).arg(length());
return tr("%3 points from %1 to %2").arg(_v_raw[0]).arg(_v_raw[length()-1]).arg(length());
}

}
Expand Down
Loading