#include <CompatDispersionData.h>
Public Member Functions | |
double | closestModeMisfit (bool strictModeJumping, FILE *flog) |
CompatDispersionData () | |
default constructor | |
CompatDispersionData (int modesCount, int omegasCount) | |
Allocates an empty structure. | |
CompatDispersionData (const CompatDispersionData *o, int modesCount) | |
Allocates an empty structure based on an existing one with another number of modes. | |
CompatDispersionData (const CompatMultiModalCurves *o) | |
Set the values o as the measurements. | |
void | convertStddev () |
Export in a file readable by Herrmann SURF. | |
ModalCurve | curve (int iMode) |
QVector< double > * | groupSlowness (int iMode) |
double | maxDataFrequency () |
double | minDataFrequency () |
double | misfit (int iMin, int iMax, FILE *flog) |
double | misfit (FILE *flog) |
Calculate the Root Mean Square for the current calculated dispersion curve. | |
void | valuesToData () |
void | valuesToData (CompatMultiModalCurves *o) |
default constructor
: CompatDispersion(), CompatMultiModalData() {}
QGpCompatibility::CompatDispersionData::CompatDispersionData | ( | int | modesCount, |
int | omegasCount | ||
) | [inline] |
Allocates an empty structure.
QGpCompatibility::CompatDispersionData::CompatDispersionData | ( | const CompatDispersionData * | o, |
int | modesCount | ||
) | [inline] |
Allocates an empty structure based on an existing one with another number of modes.
: CompatDispersion(o, modesCount), CompatMultiModalData(o, modesCount,0) {}
QGpCompatibility::CompatDispersionData::CompatDispersionData | ( | const CompatMultiModalCurves * | o | ) | [inline] |
Set the values o as the measurements.
: CompatDispersion(o), CompatMultiModalData(o) {}
double QGpCompatibility::CompatDispersionData::closestModeMisfit | ( | bool | strictModeJumping, |
FILE * | flog | ||
) |
Calculate the Root Mean Square for the current calculated dispersion curve using the mode that matches best the the data fundamental curve (taken as the effictive apparent velocity)
References QGpCompatibility::CompatMultiModalData::_measurements, QGpCompatibility::CompatMultiModalFrequency::_modesCount, QGpCompatibility::CompatMultiModalFrequency::_omegasCount, QGpCompatibility::CompatMultiModalData::_omegasCount, QGpCompatibility::CompatMultiModalData::_stddev, QGpCompatibility::CompatMultiModalCurves::_values, QGpCompatibility::CompatMultiModalData::measurements(), mode, QGpCoreTools::sqrt(), QGpCompatibility::CompatMultiModalData::stddev(), and TRACE.
{ TRACE; // RMS is the calculated with the closest mode double rms_val=0; int omegaCountReal=CompatMultiModalFrequency::_omegasCount; int omegaCountData=omegaCountReal; // Effective apparent velocity is always in mode 0 (fundamental) double * measurements=_measurements[0]; double * stddev=_stddev[0]; int maxMode=CompatMultiModalFrequency::_modesCount-1; for(int i=CompatMultiModalFrequency::_omegasCount-1;i>=0;i--) { if(measurements[i]!=0) { double diff,minDiff=1e99; int nextSampleMaxMode=maxMode; for(int mode=0;mode<=maxMode;mode++) { if(_values[mode][i]!=0) { #ifdef SLOWNESS_MISFIT if(stddev[i]) diff=(measurements[i]-_values[mode][i]) /stddev[i]; else diff=(measurements[i]-_values[mode][i]) /measurements[i]; #else if(stddev[i]) diff=(1/measurements[i]-1/_values[mode][i])*stddev[i]; else diff=(1/measurements[i]-1/_values[mode][i])*measurements[i]; #endif if(diff<0) diff=-diff; if(diff<minDiff) { minDiff=diff; nextSampleMaxMode=mode; } } } if(strictModeJumping) maxMode=nextSampleMaxMode; if(minDiff!=1e99) rms_val+=minDiff*minDiff; else omegaCountReal--; } else {omegaCountData--;omegaCountReal--;} } if(omegaCountReal>0) rms_val=sqrt(rms_val/omegaCountReal)*(1+omegaCountData-omegaCountReal); else { fprintf(flog," *** ERROR *** : no common value between calculated and data, this should never happen!\n"); rms_val=10000; } return rms_val; }
Export in a file readable by Herrmann SURF.
the measurements are read from a file of the Herrmann disp.d format: 1st line : IUNIT (not used here) IFRPER (0 if period, 1 if frequency) Other lines: ILVRY (1=Love,2=Rayleigh) IPORG(unused) IMODE FRPER VAL DVAL(unused)
The way the stddev is stored has changed from the inverse of velocity stddev to the stddev of the slowness. new_stddev=old_stddev*slowness*slowness All reports with version 0 have the old format for stddev This routine is called be CompatInversionReport to change the stddev in case of version 0
References QGpCompatibility::CompatMultiModalData::_measurements, QGpCompatibility::CompatMultiModalData::_modesCount, QGpCompatibility::CompatMultiModalData::_omegasCount, QGpCompatibility::CompatMultiModalData::_stddev, QGpCompatibility::CompatMultiModalData::measurements(), mode, QGpCompatibility::CompatMultiModalData::stddev(), and TRACE.
Referenced by QGpCompatibility::CompatInversionReport::loadDispersionGoal().
{ TRACE; for(int mode=0;mode<CompatMultiModalFrequency::_modesCount;mode++) { double * measurements=_measurements[mode]; double * stddev=_stddev[mode]; for(int i=0;i<CompatMultiModalFrequency::_omegasCount;i++) stddev[i]=measurements[i]*measurements[i]/stddev[i]; } }
ModalCurve QGpCompatibility::CompatDispersionData::curve | ( | int | iMode | ) |
Reimplemented from QGpCompatibility::CompatMultiModalData.
References QGpCompatibility::CompatMultiModalFrequency::_omegas, QGpCompatibility::CompatMultiModalData::_omegasCount, and TRACE.
{ TRACE; ModalCurve c=CompatMultiModalData::curve(iMode); int n=CompatMultiModalFrequency::_omegasCount; for(int i=0;i<n;i++) { c[i].setX(_omegas[i]); } return c; }
QVector< double > * QGpCompatibility::CompatDispersionData::groupSlowness | ( | int | iMode | ) |
References QGpCompatibility::CompatMultiModalData::_measurements, and QGpCompatibility::CompatMultiModalFrequency::_omegas.
{ ASSERT(iMode<CompatMultiModalFrequency::_modesCount); QVector<double> * list=new QVector<double>; double * values=_measurements[iMode]; int n=CompatMultiModalFrequency::_omegasCount-1; for(int i=1;i<n;i++) { double derslow=0.5*((values[i]-values[i-1])/(_omegas[i]-_omegas[i-1])+ (values[i+1]-values[i])/(_omegas[i+1]-_omegas[i])); derslow*=_omegas[i]; list->push_back(values[i]+derslow); } return list; }
References QGpCompatibility::CompatMultiModalData::_measurements, QGpCompatibility::CompatMultiModalData::_modesCount, QGpCompatibility::CompatMultiModalFrequency::_omegas, mode, TRACE, and twopi.
{ TRACE; double maxFreq=0; for(int mode=0; mode<CompatMultiModalFrequency::_modesCount;mode++) { double * measurements=_measurements[mode]; for(int i=CompatMultiModalFrequency::_omegasCount-1;i>=0;i--) { if(measurements[i]!=0) { if(_omegas[i]>maxFreq) maxFreq=_omegas[i]; break; } } } return maxFreq/twopi; }
References QGpCompatibility::CompatMultiModalData::_measurements, QGpCompatibility::CompatMultiModalData::_modesCount, QGpCompatibility::CompatMultiModalFrequency::_omegas, QGpCompatibility::CompatMultiModalData::_omegasCount, mode, TRACE, and twopi.
{ TRACE; double minFreq=1e99; for(int mode=0; mode<CompatMultiModalFrequency::_modesCount;mode++) { double * measurements=_measurements[mode]; for(int i=0;i<CompatMultiModalFrequency::_omegasCount;i++) { if(measurements[i]!=0) { if(_omegas[i]<minFreq) minFreq=_omegas[i]; break; } } } return minFreq/twopi; }
double QGpCompatibility::CompatDispersionData::misfit | ( | int | iMin, |
int | iMax, | ||
FILE * | flog | ||
) |
Calculate the Root Mean Square for the current calculated dispersion curve between indexes iMin and iMax
References QGpCompatibility::CompatMultiModalData::_measurements, QGpCompatibility::CompatMultiModalFrequency::_modesCount, QGpCompatibility::CompatMultiModalData::_modesCount, QGpCompatibility::CompatMultiModalData::_stddev, QGpCompatibility::CompatMultiModalCurves::_values, QGpCompatibility::CompatMultiModalData::measurements(), mode, QGpCoreTools::sqrt(), QGpCompatibility::CompatMultiModalData::stddev(), and TRACE.
{ TRACE; // Global RMS is the sum of the RMS of all modes double rms_val=0; int omegaCountReal=(iMax-iMin+1)*CompatMultiModalFrequency::_modesCount; int omegaCountData=omegaCountReal; for(int mode=0;mode<CompatMultiModalFrequency::_modesCount;mode++) { double * measurements=_measurements[mode]; double * stddev=_stddev[mode]; double * calculated=_values[mode]; for(int i=iMin;i<=iMax;i++) { if(measurements[i]!=0) { if(calculated[i]!=0) { double diff; #ifdef SLOWNESS_MISFIT if(stddev[i]) diff=(measurements[i]-calculated[i]) /stddev[i]; else diff=(measurements[i]-calculated[i]) /measurements[i]; #else if(stddev[i]) diff=(1/measurements[i]-1/calculated[i])*stddev[i]; else diff=(1/measurements[i]-1/calculated[i])*measurements[i]; #endif rms_val+=diff*diff; } else omegaCountReal--; } else {omegaCountData--;omegaCountReal--;} } } if(omegaCountReal>0) rms_val=sqrt(rms_val/omegaCountReal)*(1+omegaCountData-omegaCountReal); else if(omegaCountData==0) rms_val=0; else { fprintf(flog," *** ERROR *** : no common value between calculated and data, this should never happen!\n"); rms_val=10000; } return rms_val; }
double QGpCompatibility::CompatDispersionData::misfit | ( | FILE * | flog | ) | [inline] |
Calculate the Root Mean Square for the current calculated dispersion curve.
References QGpCompatibility::CompatMultiModalFrequency::_omegasCount, and misfit().
{ return misfit(0,CompatMultiModalFrequency::_omegasCount-1,flog); }
void QGpCompatibility::CompatDispersionData::valuesToData | ( | ) | [inline] |
References QGpCompatibility::CompatMultiModalData::valuesToData().
{CompatMultiModalData::valuesToData(this);}
void QGpCompatibility::CompatDispersionData::valuesToData | ( | CompatMultiModalCurves * | o | ) | [inline] |
Reimplemented from QGpCompatibility::CompatMultiModalData.
References QGpCompatibility::CompatMultiModalData::valuesToData().