QGpCompatibility/CompatAutocorrCurves.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCompatibility.
00004 **
00005 **  This file may be distributed and/or modified under the terms of the
00006 **  GNU General Public License version 2 or 3 as published by the Free
00007 **  Software Foundation and appearing in the file LICENSE.GPL included
00008 **  in the packaging of this file.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00013 **  more details.
00014 **
00015 **  You should have received a copy of the GNU General Public License
00016 **  along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 **
00018 **  See http://www.geopsy.org for more information.
00019 **
00020 **  Created : 2003-02-11
00021 **  Authors:
00022 **    Marc Wathelet
00023 **    Marc Wathelet (ULg, Liège, Belgium)
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef COMPATAUTOCORRCURVES_H
00029 #define COMPATAUTOCORRCURVES_H
00030 
00031 #define CompatAUTOCORR_INVALID_VALUE -99
00032 
00033 #include "QGpCompatibilityDLLExport.h"
00034 #include "CompatDispersion.h"
00035 
00036 namespace QGpCompatibility {
00037 
00038 class QGPCOMPATIBILITY_EXPORT CompatAutocorrCurves: public CompatMultiModalFrequency
00039 {
00040 public:
00041   enum FrequencyRange {Complete,NoInitialFlat,FirstSlope};
00042   // Constructor: default constructor
00043   CompatAutocorrCurves();
00044   // Constructor
00045   CompatAutocorrCurves(int modesCount, int radiusCount, int omegasCount);
00046   // Copy constructor
00047   CompatAutocorrCurves(const CompatAutocorrCurves * o);
00048   // Copy constructor changing the number of modes
00049   CompatAutocorrCurves(const CompatAutocorrCurves * o,int modesCount);
00050   // Destructor: get rid of all unused memory
00051   virtual ~CompatAutocorrCurves();
00052   
00053   /* Calculate the autocorrelation curves from a dispersion curve for all possible modes
00054   Min(modesCount(),disp.modesCount())*/
00055   void calculate(CompatDispersion& disp);
00056   
00057   // Export curves to stream
00058   void toStream(FILE * f);
00059   // Prints the _radiusMin and _radiusMax to the binary stream (usually the autocorrreport)
00060   void radiusToReport(QDataStream& s) const;
00061   // Loads the _radiusMin and _radiusMax from the binary stream (usually the autocorrreport)
00062   void reportToRadius(QDataStream& s);
00063   // Prints the _autocorr to the binary stream (usually the autocorrreport)
00064   void valuesToReport(QDataStream& s) const;
00065   // Loads the _omega from the binary stream (usually the autocorrreport)
00066   void reportToOmega(QDataStream& s);
00067   // Loads the _autocorr from the binary stream (usually the autocorrreport)
00068   void reportToValues(QDataStream& s);
00069   // Copy all point of imode into a point vector and return the number of valid points
00070   int toPointVector(int imode,int iRadius,Point2D * pointList);
00071   // Copy all point of imode into a point vector and return the number of valid points
00072   int toDistancePointVector(int imode,int iomega,Point2D * pointList);
00073   // Set all autocorrelation curves to zero
00074   void resetAutocorr();
00075   
00076   // Returns the omega count for radius r and mode imode where autocorrelation is defined
00077   int omegasCount (int imode, int r) const;
00078   // Returns the omega count
00079   int omegasCount () const {return _omegasCount;}
00080   // Returns the radius count
00081   int radiusCount () const {return _radiusCount;}
00082   // Returns the radius min
00083   double radiusMin (int i) const {return _radiusMin[i];}
00084   // Returns the radius max
00085   double radiusMax (int i) const {return _radiusMax[i];}
00086   // Returns the radius average
00087   double radiusAverage (int i) const {return (_radiusMax[i]+_radiusMin[i])/2;}
00088   // Returns the radius average
00089   QVector<double> * radiusAverage () const;
00090   // Set Radius min and max
00091   void setRadius(QVector<double>& rmin,QVector<double>& rmax);
00092   void setRadius(CompatAutocorrCurves * o);
00093   void setRadius(QString radiusFile);
00094   void setRadius(int r, double rmin, double rmax)
00095   {_radiusMin[r]=rmin;_radiusMax[r]=rmax;}
00096   static int getRadiusCount(QString radiusFile);
00097   // Returns the ith autocorr of radius r and mode m
00098   double value(int i, int r,int m) const {return _values[m][r][i];}
00099   // Set autocorr of mode m, radius r and point i
00100   void setValue(int i, int r,int m, double value) {_values[m][r][i]=value;}
00101   // Set the range type for computations in calculate (by default it is complete)
00102   void setRangeType(FrequencyRange fr) {_rangeType=fr;}
00103   // Set all autocorr curves to invalid value
00104   void resetValues();
00105   void setRayleighModesCount(int rm) {
00106     if(rm<=_modesCount) _rayleighModesCount=rm;
00107   }
00108   uint rayleighModesCount() {return _rayleighModesCount;}
00109 protected:
00110   friend class CompatAutocorrData;
00111   uint _rayleighModesCount;
00112   // Number of radius
00113   int _radiusCount;
00114   // Storage for radii min for each omega
00115   double * _radiusMin;
00116   // Storage for radii max for each omega
00117   double * _radiusMax;
00118   // Storage for calculated autocorrelations curves
00119   double *** _values;
00120   // Type of frequency range for computations in calculate()
00121   FrequencyRange _rangeType;
00122   // Allocates the storage for radius lists
00123   void allocatesRadius();
00124   // Delete _values (called by destructor)
00125   void deleteValues();
00126   // Allocates the storage for calculated slownesses
00127   void allocatesValues();
00128 };
00129 
00130 } // namespace QGpCompatibility
00131 
00132 #endif // COMPATAUTOCORRCURVES_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines