Brief description of class still missing. More...
#include <EllipticityReader.h>
Public Member Functions | |
| EllipticityReader () | |
| bool | setOptions (int &argc, char **argv) |
Protected Member Functions | |
| virtual bool | parse (QTextStream &s) |
Brief description of class still missing.
Full description of class still missing
Description of constructor still missing
References QGpCoreTools::LogScale, and TRACE.
: ArgumentStdinReader() { TRACE; _nRayleigh=1; _samplingType=LogScale; _nSamples=100; _minRange=0.2; _maxRange=20.0; _outputCurves=true; _calculatePeaks=false; _signed=false; _oneMode=false; }
| bool EllipticityReader::parse | ( | QTextStream & | s | ) | [protected, virtual] |
Implements QGpCoreTools::ArgumentStdinReader.
References QGpCoreWave::ModalStorage::abs(), QGpCoreWave::Dispersion::calculate(), QGpCoreWave::Seismic1DModel::fromStream(), QGpCoreWave::Seismic1DModel::layerCount(), QGpCoreWave::Ellipticity::peaks(), QGpCoreWave::Dispersion::setPrecision(), sOut(), QGpCoreWave::ModalStorage::toStream(), and TRACE.
{
TRACE;
QTextStream sOut(stdout);
Seismic1DModel m;
QString comments;
if(!m.fromStream(s, &comments)) {
return false;
}
if(m.layerCount()>0) {
if(_nRayleigh>0) {
Rayleigh rayleigh(&m);
Dispersion dispersion (_nRayleigh, &_x);
dispersion.setPrecision(1e-12); // Highest precision with double
Ellipticity ell(_nRayleigh, &_x);
// TODO: take errors into consideration
dispersion.calculate(&rayleigh, &ell);
QList<double> peaks[_nRayleigh];
if(_calculatePeaks) {
for(int im=0; im<_nRayleigh; im++) {
peaks[im]=ell.peaks (im, dispersion, &rayleigh);
}
}
if(!_signed) {
ell.abs();
}
sOut << comments;
if(_outputCurves) {
sOut << QString("# %1 Rayleigh ellipticity mode(s)\n").arg(_nRayleigh);
ell.toStream(sOut, _oneMode ? _nRayleigh-1 : -1);
} else {
for(int im=0; im < _nRayleigh; im++ ) {
sOut << "# Mode " << im << "\n";
for(int ip=0; ip < peaks[im].count(); ip++ ) {
sOut << peaks[im][ip] << "\n";
}
}
}
}
}
return true;
}
| bool EllipticityReader::setOptions | ( | int & | argc, |
| char ** | argv | ||
| ) |
References QGpCoreTools::endl(), QGpCoreTools::Function, QGpCoreTools::InversedScale, QGpCoreTools::Curve< pointType >::line(), QGpCoreTools::LinearScale, QGpCoreTools::LogScale, QGpCoreTools::Curve< pointType >::resample(), QGpCoreTools::tr(), TRACE, QGpCoreTools::Curve< pointType >::xMultiply(), and QGpCoreTools::Curve< pointType >::xVector().
Referenced by main().
{
TRACE;
// Check arguments
int i, j=1;
for(i=1; i<argc; i++) {
QByteArray arg=argv[i];
if(arg[0]=='-') {
if(arg=="-R") {
CoreApplication::checkOptionArg(i, argc, argv);
_nRayleigh=atoi(argv[i]);
} else if (arg=="-one-mode") {
_oneMode=true;
} else if(arg=="-signed") {
_signed=true;
} else if(arg=="-s") {
CoreApplication::checkOptionArg(i, argc, argv);
if(strcmp(argv[i],"period")==0) {
_samplingType=InversedScale;
} else if(strcmp(argv[i],"frequency")==0) {
_samplingType=LinearScale;
} else {
_samplingType=LogScale;
}
} else if(arg=="-min") {
CoreApplication::checkOptionArg(i, argc, argv);
_minRange=atof(argv[i]);
} else if(arg=="-max") {
CoreApplication::checkOptionArg(i, argc, argv);
_maxRange=atof(argv[i]);
} else if(arg=="-n") {
CoreApplication::checkOptionArg(i, argc, argv);
_nSamples=atoi(argv[i]);
if(_nSamples<=0) {
App::stream() << tr("gpell: negative or null number of samples (option -n)") << endl;
return false;
}
} else if(arg=="-p") {
_calculatePeaks=true;
_outputCurves=false;
} else if(arg=="-c") {
_calculatePeaks=false;
_outputCurves=true;
} else if(arg=="-pc") {
_calculatePeaks=true;
_outputCurves=true;
} else {
App::stream() << tr("gpell: bad option %1, see -help").arg(argv[i]) << endl;
return false;
}
} else {
argv[j++]=argv[i];
}
}
if(j < argc) {
argv[j]=0;
argc=j;
}
// Compute common sampling scale
Curve<Point1D> c;
c.line(_minRange, _maxRange);
c.resample(_nSamples, _minRange, _maxRange, _samplingType | Function);
c.xMultiply(2*M_PI); // convert to angular frequency
_x=c.xVector();
return true;
}