All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Member Functions | Public Attributes
GeopsyCore::SACHeader Class Reference

Brief description of class still missing. More...

#include <SACHeader.h>

List of all members.

Public Member Functions

void read (QDataStream &s)
 SACHeader ()
QDateTime startTime () const
bool write (QDataStream &s)

Static Public Member Functions

static SignalFileFormat determineByteOrder (QString fileName)

Public Attributes

union {
   struct {
      quint32   LCALDA
      quint32   LEVEN
      quint32   LOVROK
      quint32   LPSPOL
      quint32   UNUSED
   }   field
   quint32   raw [5]
bools
union {
   struct {
      char   KA [8]
      char   KCMPNM [8]
      char   KDATRD [8]
      char   KEVNM [16]
      char   KF [8]
      char   KHOLE [8]
      char   KINST [8]
      char   KNETWK [8]
      char   KO [8]
      char   KSTNM [8]
      char   KT0 [8]
      char   KT1 [8]
      char   KT2 [8]
      char   KT3 [8]
      char   KT4 [8]
      char   KT5 [8]
      char   KT6 [8]
      char   KT7 [8]
      char   KT8 [8]
      char   KT9 [8]
      char   KUSER0 [8]
      char   KUSER1 [8]
      char   KUSER2 [8]
   }   field
   char   raw [192]
chars
union {
   struct {
      float   A
      float   AZ
      float   B
      float   BAZ
      float   CMPAZ
      float   CMPINC
      float   DELTA
      float   DEPMAX
      float   DEPMEN
      float   DEPMIN
      float   DIST
      float   E
      float   EVDP
      float   EVEL
      float   EVLA
      float   EVLO
      float   F
      float   GCARC
      float   INTERNAL0
      float   INTERNAL1
      float   INTERNAL2
      float   MAG
      float   O
      float   ODELTA
      float   RESP0
      float   RESP1
      float   RESP2
      float   RESP3
      float   RESP4
      float   RESP5
      float   RESP6
      float   RESP7
      float   RESP8
      float   RESP9
      float   SCALE
      float   STDP
      float   STEL
      float   STLA
      float   STLO
      float   T [10]
      float   UNUSED0
      float   UNUSED1
      float   UNUSED2
      float   UNUSED3
      float   UNUSED4
      float   UNUSED5
      float   UNUSED6
      float   USER0
      float   USER1
      float   USER2
      float   USER3
      float   USER4
      float   USER5
      float   USER6
      float   USER7
      float   USER8
      float   USER9
      float   XMAXIMUM
      float   XMINIMUM
      float   YMAXIMUM
      float   YMINIMUM
   }   field
   float   raw [70]
floats
union {
   struct {
      qint32   IDEP
      qint32   IEVREG
      qint32   IEVTYP
      qint32   IFTYPE
      qint32   IINST
      qint32   IMAGSRC
      qint32   IMAGTYP
      qint32   INTERNAL
      qint32   IQUAL
      qint32   ISTREG
      qint32   ISYNTH
      qint32   IZTYPE
      qint32   NEVID
      qint32   NORID
      qint32   NPTS
      qint32   NVHDR
      qint32   NWFID
      qint32   NXSIZE
      qint32   NYSIZE
      qint32   NZHOUR
      qint32   NZJDAY
      qint32   NZMIN
      qint32   NZMSEC
      qint32   NZSEC
      qint32   NZYEAR
      qint32   UNUSED0
      qint32   UNUSED1
      qint32   UNUSED2
      qint32   UNUSED3
      qint32   UNUSED4
      qint32   UNUSED5
      qint32   UNUSED6
      qint32   UNUSED7
      qint32   UNUSED8
      qint32   UNUSED9
   }   field
   qint32   raw [35]
ints

Detailed Description

Brief description of class still missing.

SAC binary format is very simple: 632 bytes of header followed by the data. For more informations see SAC online manual at http://www.iris.edu/manuals/sac/manual.html


Constructor & Destructor Documentation

References bools, chars, floats, ints, and TRACE.

{
  TRACE;
  ASSERT(sizeof( float)==4);
  ASSERT(sizeof( SACHeader)==632);
  for(int i=0;i < 70;i++ ) floats.raw[ i ]=-12345.0;
  for(int i=0;i < 35;i++ ) ints.raw[ i ]=-12345;
  for(int i=0;i < 5;i++ ) bools.raw[ i ]=0;
  for(int i=0;i < 192;i++ ) chars.raw[ i ]=' ';
}

Member Function Documentation

References GeopsyCore::SignalFileFormat::SacBigEndian, GeopsyCore::SignalFileFormat::SacLittleEndian, and GeopsyCore::SignalFileFormat::Unknown.

Referenced by GeopsyCore::SignalFileFormat::fromContent(), and GeopsyCore::SignalFileFormat::fromSuffix().

{
  QFile f(fileName);
  if( !f.open(QIODevice::ReadOnly) ) {
    return SignalFileFormat::Unknown;
  }
  QDataStream s(&f);
  s.setByteOrder(QDataStream::LittleEndian);
  int version, iftype, leven;
  f.seek(76 * 4);
  s >> version;
  f.seek(85 * 4);
  s >> iftype;
  f.seek(105 * 4);
  s >> leven;
  if(version==6 && iftype==1 && leven)
    return SignalFileFormat::SacLittleEndian;
  f.seek(0); // reset to begin of file
  s.setByteOrder(QDataStream::BigEndian);
  f.seek(76 * 4);
  s >> version;
  f.seek(85 * 4);
  s >> iftype;
  f.seek(105 * 4);
  s >> leven;
  if(version==6 && iftype==1 && leven)
    return SignalFileFormat::SacBigEndian;
  return SignalFileFormat::Unknown;
}
void GeopsyCore::SACHeader::read ( QDataStream &  s)

References bools, chars, floats, ints, and TRACE.

{
  TRACE;
  for(int i=0;i<70;i++) s >> floats.raw[i];
  for(int i=0;i<35;i++) s >> ints.raw[i];
  for(int i=0;i<5;i++) s >> bools.raw[i];
  s.readRawData(chars.raw, 192);
}
QDateTime GeopsyCore::SACHeader::startTime ( ) const

References ints, and TRACE.

{
  TRACE;
  QDateTime t(
    QDate(ints.field.NZYEAR>0 ? ints.field.NZYEAR : 0 , 1, 1),
    QTime(ints.field.NZHOUR>0 ? ints.field.NZHOUR : 0,
          ints.field.NZMIN>0 ? ints.field.NZMIN : 0,
          ints.field.NZSEC>0 ? ints.field.NZSEC : 0));
  t=t.addDays(ints.field.NZJDAY>0 ? (ints.field.NZJDAY-1) : 0);
  return t;
}
bool GeopsyCore::SACHeader::write ( QDataStream &  s)

References bools, chars, floats, ints, and TRACE.

Referenced by GeopsyCore::Signal::writeSac().

{
  TRACE;
  qint64 offset=s.device()->pos();
  for(int i=0;i<70;i++) s << floats.raw[i];
  for(int i=0;i<35;i++) s << ints.raw[i];
  for(int i=0;i<5;i++) s << bools.raw[i];
  s.writeRawData(chars.raw, 192);
  return s.device()->pos()-offset==sizeof(float)*70+sizeof(qint32)*35+sizeof(quint32)*5+192;
}

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines