GeopsyCore/SubSignalPool.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of GeopsyCore.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2003-11-10
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef SUBSIGNALPOOL_H
00030 #define SUBSIGNALPOOL_H
00031 
00032 #include <QGpCoreTools.h>
00033 
00034 #include "GeopsyCoreDLLExport.h"
00035 #include "Signal.h"
00036 #include "SortKey.h"
00037 #include "TimeRangeParameters.h"
00038 
00039 namespace GeopsyCore {
00040 
00041   class AbstractSignalGroup;
00042   class MetaDataFieldList;
00043 
00044   extern const char * SignalKeyName [];
00045 
00046   class GEOPSYCORE_EXPORT SubSignalPool: protected QList<Signal *>
00047   {
00048     TRANSLATIONS( "SubPoolWindow" )
00049   public:
00050     SubSignalPool() {}
00051     SubSignalPool(const SubSignalPool& subPool);
00052     ~SubSignalPool() {removeAll();}
00053 
00054     // Useful members from QList with public access
00055     typedef QList<Signal *>::iterator iterator;
00056     typedef QList<Signal *>::const_iterator const_iterator;
00057     iterator begin() {return QList<Signal *>::begin();}
00058     iterator end() {return QList<Signal *>::end();}
00059     const_iterator begin() const {return QList<Signal *>::begin();}
00060     const_iterator end() const {return QList<Signal *>::end();}
00061     SubSignalPool& operator=(const SubSignalPool& o);
00062     bool operator==(const SubSignalPool& o) const;
00063     bool operator!=(const SubSignalPool& o) const {return !operator==(o);}
00064     SubSignalPool copy() const;
00065     int count() const {return QList<Signal *>::count();}
00066     int samplesCount();
00067     bool empty() {return QList<Signal *>::empty();}
00068     bool isEmpty() const {return QList<Signal *>::isEmpty();}
00069     Signal * at(int index) const {return QList<Signal *>::at(index);}
00070     Signal * first() const {return QList<Signal *>::first();}
00071     Signal * last() const {return QList<Signal *>::last();}
00072     int indexOf(const Signal * sig) const {return QList<Signal *>::indexOf(const_cast<Signal *>(sig));}
00073     bool contains(const Signal * sig) const {return QList<Signal *>::contains(const_cast<Signal *>(sig));}
00074 
00075     void sort() {qSort(begin(), end(), SortKey::lessThan);}
00076 
00077     const QString& name() const {return _name;}
00078     void setName(const QString& n) {_name=n;}
00079 
00080     void setHeaderModified(bool b) const;
00081     bool isHeaderModified() const;
00082     bool isReadOnlySamples() const;
00083 
00084     TimeRange timeRange() const;
00085     QStringList availableTimePicks() const;
00086 
00087     // Signal selection
00088     void addAll();
00089     void addSubPool(const SubSignalPool& subPool);
00090     void addSource(Point point);
00091     void addReceiver(Point point);
00092     void addSignal(Signal * sig) {append(sig);}
00093     void addSignal(int id);
00094     void addFile(int fileN);
00095     void addFile(const SignalFile * sf);
00096     void addGroup(AbstractSignalGroup * g);
00097     void addList(QString signalList);
00098     void insertSignal(Signal * sig, Signal * refSig=0, bool before=true);
00099     void remove(Signal * sig);
00100     void removeAt(int i);
00101     void remove(Signal::Components comp);
00102     void removeAll();
00103     void debugSignalSharing();
00104 
00105     // Saving to file
00106     static bool isExportFormat(const SignalFileFormat& f);
00107     bool save(QString filePath, bool useOriginalBaseName, SignalFileFormat format,
00108               int maximumSignalsPerFile=0 , const QString& pickName=QString::null) const;
00109     bool saveGeopsySignal (QString filePath) const;
00110 
00111     // Signal processing
00112     void pickCoppens(const QString& pickName, double delta, double tend, double tstart=0., bool relative=false, double mute=0.0);
00113     void pickMinMax(const QString& pickNameb, double from, double to, Signal::PickWhat what);
00114     void subtractValue(double val=0.0);
00115     void subtractSignal(Signal * bysig);
00116     void subtractSignals(SubSignalPool * bySubPool);
00117     void filter(const FilterParameters& param);
00118     void waveletTransform(const MorletParameters& param);
00119     void shift(double dt);
00120     void overSample(double factor);
00121     void whiten();
00122     void agc(double width);
00123     void stddevClip(double factor);
00124     void multiply(double value);
00125     bool mergeStations();
00126     bool merge();
00127     void stalta(double tsta, double tlta);
00128     void taper(const TimeRangeParameters& range, const TaperParameters& param);
00129     void cut(const TimeRangeParameters& param);
00130     void correlations(double maxDelay, const Signal * referenceSig=0);
00131     void normalizedCorrelations(double maxDelay, const Signal * referenceSig=0);
00132     void convolution(const Signal * referenceSig);
00133     void decimateAmplitude(int maxCount, double maxRef);
00134     void decimateTime(int factor);
00135     void fastFourierTransform(DoubleSignal::SignalType st);
00136     void discreteFourierTransform();
00137     void importTable(QString fileName);
00138     void exportTable(QString fileName, const MetaDataFieldList& param);
00139     int linearSearch(const Point& source, const Point& receiver);
00140     void unglitch(double threshold);
00141     int checkDuplicateRays();
00142     void rotateComponents(Matrix3x3 rotMatrix);
00143     bool associate3Components();
00144     Curve<Point> sources() const;
00145     Curve<Point> receivers() const;
00146     double azimuth() const;
00147     int maximumTimePickCount() const;
00148   protected:
00149     QString _name;
00150   private:
00151     bool exportFilePath(QString& filePath, bool useOriginalBaseName, const SignalFileFormat& f) const;
00152     bool check3ComponentTriplet(SubSignalPool& triplet);
00153     inline void prepend(Signal * sig);
00154     inline void append(Signal * sig);
00155 
00156     bool saveSeg2(QString filePath) const;
00157     bool saveSeg2Return(bool ret, int * offset) const;
00158     bool writeSeg2Header(QFile& f, int nSignals) const;
00159     bool writeSeg2Offsets(QFile& f, int nSignals, int *offset) const;
00160     bool saveArrivalTimes(QString filePath, const QString& pickName) const;
00161     bool saveAsciiOneColumn(QString filePath) const;
00162     bool saveAsciiMultiColumns(QString filePath) const;
00163     bool saveSaf(QString filePath) const;
00164     bool saveOneSaf(QString filePath) const;
00165     bool saveSac(QString filePath, bool useOriginalBaseName, QDataStream::ByteOrder bo) const;
00166     bool saveSu(QString filePath, QDataStream::ByteOrder bo) const;
00167     bool saveSegY(QString filePath, QDataStream::ByteOrder bo) const;
00168     bool saveWav(QString filePath) const;
00169     bool saveGse2(QString filePath) const;
00170     bool saveMiniSeed(QString filePath) const;
00171   };
00172 
00173   inline void SubSignalPool::append(Signal * sig)
00174   {
00175     TRACE;
00176     if(sig) {
00177       sig->addReference();
00178       QList<Signal *>::append(sig);
00179     }
00180   }
00181 
00182   inline void SubSignalPool::prepend(Signal * sig)
00183   {
00184     TRACE;
00185     if(sig) {
00186       sig->addReference();
00187       QList<Signal *>::prepend(sig);
00188     }
00189   }
00190 
00191 } // namespace GeopsyCore
00192 
00193 #endif // SUBSIGNALPOOL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines