GeopsyCore/PasscalSegYHeader.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 : 2010-03-20
00022 **  Authors :
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef PASSCALSEGYHEADER_H
00028 #define PASSCALSEGYHEADER_H
00029 
00030 #include <QGpCoreTools.h>
00031 
00032 #include "SignalFileFormat.h"
00033 #include "Signal.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 PasscalSegYHeader
00041 {
00042   TRANSLATIONS("PasscalSegYHeader")
00043 public:
00044   PasscalSegYHeader();
00045 
00046   void read(QDataStream& s);
00047   void write(QDataStream& s) const;
00048 
00049   static SignalFileFormat determineByteOrder(QString fileName);
00050 
00051   int sampleSize() const {return field.dataFormat==0 ? 2 : 4;}
00052   double deltaT() const {return field.sampleInterval16==1 ? 1e-6*field.sampleInterval32 : 1e-6*field.sampleInterval16;}
00053   int nSamples() const {return field.sampleNumber16==32767 ? field.sampleNumber32 : field.sampleNumber16;}
00054   DateTime t0() const;
00055   DateTime timePick() const;
00056   Signal::Components component() const;
00057 
00058   union {
00059     struct {
00060       qint32 raw0[7];     // 1-28
00061       qint16 raw1[4];     // 29-36
00062       qint32 raw2[8];     // 37-68
00063       qint16 raw3[2];     // 69-72
00064       qint32 raw4[4];     // 73-88
00065       qint16 raw5[46];    // 89-180
00066       char raw6[18];      // 181-198
00067       qint16 raw7;        // 199-200
00068       qint32 raw8;        // 201-204
00069       qint16 raw9[8];     // 205-220
00070       float raw10;        // 221-224
00071       qint16 raw11[2];    // 225-228
00072       qint32 raw12[3];    // 229-240
00073     } raw;
00074     struct {
00075       qint32 traceNumberInFile;              // 1-4
00076       qint32 traceNumberInReel;              // 5-8 same as above
00077       qint32 eventNumber;                    // 9-12 event number
00078       qint32 channelNumber;                  // 13-16 1 or 4 for Vertical, 2 or 5 North, 3 or 6 for East
00079       qint32 ignored0[3];                    // 17-28
00080       qint16 traceIndentificationCode;       // 29-30 seismic data=1
00081       qint16 ignored1[3];                    // 31-36
00082       qint32 ignored2[8];                    // 37-68
00083       qint16 elevationScale;                 // 69-70 scale=1
00084       qint16 coordinateScale;                // 71-72 scale=1
00085       qint32 ignored3[4];                    // 73-88
00086       qint16 coordinateUnit;                 // 89-90 =2 (Lat/Long)
00087       qint16 ignored4[6];                    // 91-102
00088       qint16 totalStaticCorrectionLow;       // 103-104 in milliseconds added to start time (lower 2 bytes) ???
00089       qint16 ignored5[5];                    // 105-114
00090       quint16 sampleNumber16;                // 115-116 Number of samples in this trace (if 32767, see sampleNumber32)
00091       quint16 sampleInterval16;              // 117-118 Sampling interval in microseconds (if 1, see sampleInterval32)
00092       qint16 gainType;                       // 119-120 Gain Type: 1=Fixed Gain
00093       qint16 gainConstant;                   // 121-122 Gain of amplifier
00094       qint16 ignored6[17];                   // 123-156
00095       qint16 year;                           // 157-158 year of trace
00096       qint16 day;                            // 159-160 day of year at Start of trace
00097       qint16 hour;                           // 161-162 hour at Start of trace
00098       qint16 minute;                         // 163-164 minute at Start of trace
00099       qint16 second;                         // 165-166 second at Start of trace
00100       qint16 timeBase;                       // 167-168 Time basis code: 2=GMT
00101       qint16 ignored7[6];                    // 169-180
00102       char stationName[6];                   // 181-186
00103       char sensorSerial[8];                  // 187-194
00104       char channelName[4];                   // 195-198
00105       qint16 totalStaticCorrectionHigh;      // 199-200 in milliseconds added to start time (higher 2 bytes) ???
00106       qint32 sampleInterval32;               // 201-204 Sample interval in MICROSECS as a 32 bit
00107       qint16 dataFormat;                     // 205-206 Data Format flag: 0=16 bit, 1=32 bit integer
00108       qint16 milliseconds;                   // 207-208 milliseconds of Start of trace
00109       qint16 triggerYear;                    // 209-210 year of Trigger time
00110       qint16 triggerDay;                     // 211-212 day of year at Trigger time
00111       qint16 triggerHour;                    // 213-214 hour at Trigger time
00112       qint16 triggerMinute;                  // 215-216 minute at Trigger time
00113       qint16 triggerSecond;                  // 217-218 second at Trigger time
00114       qint16 triggerMilliseconds;            // 219-220 milliseconds at Trigger time
00115       float scaleFactor;                     // 221-224 Scale factor: true amplitude=value*scaleFactor/gainConstant
00116       quint16 instrumentSerialNumber;        // 225-226 Instrument serial number
00117       qint16 ignored8;                       // 227-228
00118       qint32 sampleNumber32;                 // 229-232 Number of Samples as a 32 bit integer (when sampleLength==32767)
00119       qint32 maximumAmplitude;               // 233-236 Maximum value in Counts
00120       qint32 minimumAmplitude;               // 237-240 Minimum value in Counts
00121     } field;
00122   };
00123 private:
00124   static bool canReadAll(QDataStream& s, qint64 fileSize);
00125 };
00126 
00127 #pragma pack()   // restore original alignment
00128 
00129 } // namespace GeopsyCore
00130 
00131 #endif // PASSCALSEGYHEADER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines