GeopsyCore/SEGYTraceHeader.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 : 2009-08-26
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef SEGYTRACEHEADER_H
00029 #define SEGYTRACEHEADER_H
00030 
00031 #include <QGpCoreTools.h>
00032 
00033 #include "SignalFileFormat.h"
00034 #include "GeopsyCoreDLLExport.h"
00035 
00036 namespace GeopsyCore {
00037 
00038 #pragma pack(1)     /* set alignment to 1 byte boundary */
00039 
00040 class GEOPSYCORE_EXPORT SEGYTraceHeader
00041 {
00042   TRANSLATIONS("SEGYTraceHeader")
00043 public:
00044   SEGYTraceHeader();
00045 
00046   static SignalFileFormat::Format determineByteOrderSEGY(QString fileName);
00047   static SignalFileFormat::Format determineByteOrderSU(QString fileName);
00048   static bool isSampleCodingValid(qint16 sampleCoding);
00049 
00050   static double IBMFloat2ieee(qint32 val);
00051 
00052   void read(QDataStream& s);
00053   void write(QDataStream& s);
00054 
00055   double t0() const;
00056   bool setT0(double t);
00057   double SUt0() const;
00058   bool setSUT0(double t);
00059   bool setNSamples(int n);
00060   QDateTime dateTime() const;
00061 
00062   Point source() const;
00063   Point receiver() const;
00064 
00065   bool setCoordinateFactor(const Point& rec, const Point& src);
00066   bool setElevationFactor(const Point& rec, const Point& src);
00067   void setReceiver(const Point& rec);
00068   void setSource(const Point& src);
00069 
00070   union {
00071     struct {
00072       qint32 raw0[7];
00073       qint16 raw1[4];
00074       qint32 raw2[8];
00075       qint16 raw3[2];
00076       qint32 raw4[4];
00077       qint16 raw5[46];
00078       qint32 raw6[5];
00079       qint16 raw7[20];
00080     } raw;
00081     struct {
00082       qint32 traceNumberInLine;              // 1-4
00083       qint32 traceNumberInFile;              // 5-8
00084       qint32 originalRecordNumber;           // 9-12
00085       qint32 traceNumberInRecord;            // 13-16
00086       qint32 sourceNumber;                   // 17-20
00087       qint32 ensembleNumber;                 // 21-24
00088       qint32 traceNumberInEnsemble;          // 25-28
00089       qint16 traceIndentificationCode;       // 29-30
00090       qint16 numberSumVertical;              // 31-32
00091       qint16 numberStackHorizontal;          // 33-34
00092       qint16 dataUse;                        // 35-36
00093       qint32 sourceReceiverDistance;         // 37-40
00094       qint32 receiverElevation;              // 41-44
00095       qint32 sourceSurfaceElevation;         // 45-48
00096       qint32 sourceDepth;                    // 49-52
00097       qint32 receiverDatumElevation;         // 53-56
00098       qint32 sourceDatumElevation;           // 57-60
00099       qint32 sourceWaterDepth;               // 61-64
00100       qint32 receiverWaterDepth;             // 65-68
00101       qint16 elevationFactor;                // 69-70
00102       qint16 coordinateFactor;               // 71-72
00103       qint32 sourceXCoordinate;              // 73-76
00104       qint32 sourceYCoordinate;              // 77-80
00105       qint32 receiverXCoordinate;            // 81-84
00106       qint32 receiverYCoordinate;            // 85-88
00107       qint16 coordinateUnit;                 // 89-90
00108       qint16 weatheringVelocity;             // 91-92
00109       qint16 subWeatheringVelocity;          // 93-94
00110       qint16 sourceUpholeTime;               // 95-96
00111       qint16 receiverUpholeTime;             // 97-98
00112       qint16 sourceStaticCorrection;         // 99-100
00113       qint16 receiverStaticCorrection;       // 101-102
00114       qint16 totalStaticCorrection;          // 103-104
00115       qint16 lagTimeA;                       // 105-106
00116       qint16 lagTimeB;                       // 107-108
00117       qint16 delayRecordingTime;             // 109-110 (milliseconds)
00118       qint16 startMuteTime;                  // 111-112
00119       qint16 endMuteTime;                    // 113-114
00120       quint16 sampleNumber;                  // 115-116
00121       quint16 sampleInterval;                // 117-118
00122       qint16 gainType;                       // 119-120
00123       qint16 gainConstant;                   // 121-122
00124       qint16 initialGain;                    // 123-124
00125       qint16 correlated;                     // 125-126
00126       qint16 startSweepFrequency;            // 127-128
00127       qint16 endSweepFrequency;              // 129-130
00128       qint16 lengthSweepFrequency;           // 131-132
00129       qint16 sweepType;                      // 133-134
00130       qint16 startSweepTaper;                // 135-136
00131       qint16 endSweepTaper;                  // 137-138
00132       qint16 taperType;                      // 139-140
00133       qint16 aliasFilterFrequency;           // 141-142
00134       qint16 aliasFilterSlope;               // 143-144
00135       qint16 notchFilterFrequency;           // 145-146
00136       qint16 notchFilterSlope;               // 147-148
00137       qint16 lowCutFrequency;                // 149-150
00138       qint16 highCutFrequency;               // 151-152
00139       qint16 lowCutSlope;                    // 153-154
00140       qint16 highCutSlope;                   // 155-156
00141       qint16 year;                           // 157-158
00142       qint16 day;                            // 159-160
00143       qint16 hour;                           // 161-162
00144       qint16 minute;                         // 163-164
00145       qint16 second;                         // 165-166
00146       qint16 timeBase;                       // 167-168
00147       qint16 weightFactor;                   // 169-170
00148       qint16 ignored01;                      // 171-172
00149       qint16 ignored02;                      // 173-174
00150       qint16 ignored03;                      // 175-176
00151       qint16 ignored04;                      // 177-178
00152       qint16 ignored05;                      // 179-180
00153       qint32 ignored06;                      // 181-184
00154       qint32 ignored07;                      // 185-188
00155       qint32 ignored08;                      // 189-192
00156       qint32 ignored09;                      // 193-196
00157       qint32 ignored10;                      // 197-200
00158       qint16 ignored11;                      // 201-202
00159       qint16 amplitudeUnit;                  // 203-204
00160       qint32 ignored12; qint16 ignored13;    // 205-210
00161       qint16 ignored14;                      // 211-212
00162       qint16 ignored15;                      // 213-214
00163       qint16 timeFactor;                     // 215-216
00164       qint16 ignored16;                      // 217-218
00165       qint16 ignored17; qint32 ignored18;    // 219-224
00166       qint32 ignored19; qint16 ignored20;    // 225-230
00167       qint16 ignored21;                      // 231-232
00168       qint32 ignored22, ignored23;           // 233-240
00169     } field;
00170   };
00171 private:
00172   static bool suCanReadAll(QDataStream& s, qint64 fileSize);
00173   double decodeCoordinateFactor() const;
00174   double decodeElevationFactor() const;
00175   double decodeTimeFactor() const;
00176   double encodeCoordinateFactor() const;
00177   double encodeElevationFactor() const;
00178   double encodeTimeFactor() const;
00179   static qint16 factor(double min, double max, double theoreticalMaximum);
00180 };
00181 
00182 #pragma pack()   // restore original alignment
00183 
00184 } // namespace GeopsyCore
00185 
00186 #endif // SEGYTRACEHEADER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines