Brief description of class still missing. More...
#include <StackWeights.h>
Public Member Functions | |
| virtual StackWeights * | clone () const |
| virtual double | misfit (bool &ok) |
| void | setGlobalTimeLimits (const TimeRangeParameters &timeLimits) |
| void | setReceiverIndex (int recIndex) |
| void | setSignalTimeLimits (const TimeRangeParameters &timeLimits) |
| void | setUniformWeights () |
| void | setWeights (const int *gridWeights) |
| void | stack (SubSignalPool &results) |
| StackWeights (QList< ShotRecord * > shots) | |
Brief description of class still missing.
There n-1 parameters if there are n shots. There values are from 0 to 1 with a condition that values must increase. There in fact represent the cumulative weights. Effective weights are calculated by subtracting two adjacent parameters.
| StackWeights::StackWeights | ( | QList< ShotRecord * > | shots | ) |
| StackWeights * StackWeights::clone | ( | ) | const [virtual] |
Implements DinverCore::AbstractForward.
References StackWeights().
{
StackWeights * c=new StackWeights(_shots);
c->setParameters();
return c;
}
| double StackWeights::misfit | ( | bool & | ok | ) | [virtual] |
Provided for convenience, it calls misfit(double *, bool) to compute misfit from a vector of parameter values. Reimplement this function if you do not need values under this format (direct access to parameter space).
Reimplemented from DinverCore::AbstractForward.
References GeopsyCore::TimeRangeParameters::absoluteRange(), CONST_LOCK_SAMPLES, GeopsyCore::TimeRange::end(), stack(), GeopsyCore::TimeRange::start(), TRACE, UNLOCK_SAMPLES, and w.
Referenced by ToolNR::uniformStack().
{
TRACE;
int nShots=_shots.count();
double weights[nShots];
param2weights(weights);
double sum=0.0;
TimeRange globalTw=_globalTimeLimits.absoluteRange(_shots.first()->at(_receiverIndex));
TimeRange signalTw=_signalTimeLimits.absoluteRange(_shots.first()->at(_receiverIndex));
int nSamples=_shots.at(0)->nSamples();
double t0=_shots.at(0)->t0();
double invdt=1.0/_shots.at(0)->deltaT();
int iGlobalStart=(int) floor(( globalTw.start() - t0) * invdt + 0.5);
int iGlobalEnd=(int) floor(( globalTw.end() - t0) * invdt + 0.5);
if(iGlobalStart<0) iGlobalStart=0;
if(iGlobalStart>nSamples) iGlobalStart=nSamples;
if(iGlobalEnd<0) iGlobalEnd=0;
if(iGlobalEnd>nSamples) iGlobalEnd=nSamples;
int iStart=(int) floor(( signalTw.start() - t0) * invdt + 0.5);
int iEnd=(int) floor(( signalTw.end() - t0) * invdt + 0.5);
if(iStart<iGlobalStart) iStart=iGlobalStart;
if(iStart>iGlobalEnd) iStart=iGlobalEnd;
if(iEnd<iGlobalStart) iEnd=iGlobalStart;
if(iEnd>iGlobalEnd) iEnd=iGlobalEnd;
double stack[nSamples];
// Reset stack vector
for(int i=iGlobalStart; i < iStart; i++ ) {
stack[i]=0.0;
}
for(int i=iEnd; i < iGlobalEnd; i++ ) {
stack[i]=0.0;
}
// Stack
for(int iShot=0; iShot < nShots; iShot++ ) {
const Signal * sig=_shots.at(iShot)->at(_receiverIndex);
CONST_LOCK_SAMPLES(double, samp, sig)
double w=weights[iShot];
for(int i=iGlobalStart; i < iStart; i++ ) {
stack[i] += w * samp[i];
}
for(int i=iEnd; i < iGlobalEnd; i++ ) {
stack[i] += w * samp[i];
}
UNLOCK_SAMPLES(sig)
}
// compute stack total energy
for(int i=iGlobalStart; i < iStart; i++ ) {
sum += stack[i]*stack[i];
}
for(int i=iEnd; i < iGlobalEnd; i++ ) {
sum += stack[i]*stack[i];
}
return sum;
}
| void StackWeights::setGlobalTimeLimits | ( | const TimeRangeParameters & | timeLimits | ) | [inline] |
Referenced by ToolNR::optimizeStack(), and ToolNR::uniformStack().
{_globalTimeLimits=timeLimits;}
| void StackWeights::setReceiverIndex | ( | int | recIndex | ) | [inline] |
Referenced by ToolNR::optimizeStack(), and ToolNR::uniformStack().
{_receiverIndex=recIndex;}
| void StackWeights::setSignalTimeLimits | ( | const TimeRangeParameters & | timeLimits | ) | [inline] |
Referenced by ToolNR::optimizeStack(), and ToolNR::uniformStack().
{_signalTimeLimits=timeLimits;}
| void StackWeights::setUniformWeights | ( | ) |
Set current parameter values to uniform weights. Use stack() right after to get signal stacked.
References DinverCore::RealSpace::parameter(), DinverCore::AbstractForward::parameterSpace(), DinverCore::Parameter::setRealValue(), and TRACE.
Referenced by ToolNR::uniformStack().
{
TRACE;
int nShots=_shots.count();
double v=1.0/nShots;
for(int i=1;i < nShots;i++ ) {
parameterSpace().parameter(i-1)->setRealValue(i*v);
}
}
| void StackWeights::setWeights | ( | const int * | gridWeights | ) |
Set current parameter values to arbitrary weights. Use stack() right after to get signal stacked. gridWeights is usually obtained after an inversion (best model).
References DinverCore::RealSpace::parameter(), DinverCore::AbstractForward::parameterSpace(), DinverCore::Parameter::setGridValue(), and TRACE.
Referenced by ToolNR::optimizeStack().
{
TRACE;
int nShots=_shots.count();
for(int i=0; i < nShots-1; i++ ) {
parameterSpace().parameter(i)->setGridValue(gridWeights[i] );
}
}
| void StackWeights::stack | ( | SubSignalPool & | results | ) |
Stacks shots into results using the current weights.
References GeopsyCore::SubSignalPool::addSignal(), GeopsyCore::SubSignalPool::at(), CONST_LOCK_SAMPLES, GeopsyCore::SubSignalPool::count(), QGpCoreTools::endl(), GeopsyCore::SignalTemplate< sampleType >::initValues(), LOCK_SAMPLES, QGpCoreTools::tr(), TRACE, UNLOCK_SAMPLES, and w.
Referenced by misfit(), ToolNR::optimizeStack(), and ToolNR::uniformStack().
{
TRACE;
int nShots=_shots.count();
int nSamples=_shots.at(0)->nSamples();
double weights[nShots];
param2weights(weights);
for(int i=0; i < nShots; i++ ) {
App::stream() << tr("Best stack weight for shot %1=%2").arg(_shots.at(i)->name()).arg(weights[i]) << endl;
}
Signal * resSig=0;
ASSERT(_receiverIndex<=results.count());
if(_receiverIndex==results.count()) {
resSig=new Signal( *_shots.at(0)->at(_receiverIndex));
results.addSignal(resSig);
} else {
resSig=results.at(_receiverIndex);
}
resSig->initValues(0.0, 0, nSamples);
LOCK_SAMPLES(double, resSamp, resSig)
for(int iShot=0; iShot < nShots; iShot++ ) {
const Signal * sig=_shots.at(iShot)->at(_receiverIndex);
CONST_LOCK_SAMPLES(double, samp, sig)
double w=weights[iShot];
for(int i=0; i < nSamples; i++ ) {
resSamp[i] += w * samp[i];
}
UNLOCK_SAMPLES(sig)
}
UNLOCK_SAMPLES(resSig)
}