DATRW++ library: seismic data I/O with multiple formats
mseedread_mseedrecord_other.cc
Go to the documentation of this file.
1 /*! \file mseedread_mseedrecord_other.cc
2  * \brief various collected member functions of mseed::MiniSEEDRecord (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 23/06/2016
8  *
9  * various collected member functions of mseed::MiniSEEDRecord (implementation)
10  *
11  * Copyright (c) 2016 by Thomas Forbriger (BFO Schiltach)
12  *
13  *
14  * ----
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 
28  * ----
29  *
30  * REVISIONS and CHANGES
31  * - 23/06/2016 V1.0 Thomas Forbriger
32  * - 12/07/2016 V1.1 thof: uniquely specify sign of correction
33  *
34  * ============================================================================
35  */
36 #define DATRW_MSEEDREAD_MSEEDRECORD_OTHER_CC_VERSION \
37  "DATRW_MSEEDREAD_MSEEDRECORD_OTHER_CC V1.1"
38 
39 #include <datrwxx/mseedread.h>
40 #include<aff/subarray.h>
41 
42 namespace datrw {
43 
44  namespace mseed {
45 
46  /*----------------------------------------------------------------------*/
47 
48  /*! \brief Return actual data samples stored in object.
49  *
50  * The container MiniSEEDRecord::Mdata can be larger than the actual
51  * samples stored therein.
52  * Extract as many samples as being indicated by to be read from file.
53  *
54  * \note
55  * The function returns an aff::Series object, which has reference
56  * semantics.
57  * As a consequence sample values in the returned object will be altered
58  * upon reading more samples with the same MiniSEEDRecord object.
59  */
61  {
62  Tseries retval;
63  if (this->valid())
64  {
65  retval=aff::subarray(Mdata)(Mrecordheader.nsamp-1);
66  }
67  return(retval);
68  } // MiniSEEDRecord::Tseries MiniSEEDRecord::data() const
69 
70  /*----------------------------------------------------------------------*/
71 
72  libtime::TAbsoluteTime MiniSEEDRecord::date() const
73  {
74  libtime::TAbsoluteTime retval=convert(this->recordheader().stime);
75  datrw::mseed::SEED::ActivityFlags aflags(this->recordheader().aflags);
76  if (! (aflags.tcorrapp || (this->recordheader().tcorr == 0) ) )
77  {
78  libtime::TRelativeTime corr(0,0,0,0,0,100);
79  //long int tcorr=this->recordheader().tcorr;
80  int tcorr=this->recordheader().tcorr;
81  if (tcorr >= 0)
82  {
83  retval += (corr * tcorr);
84  }
85  else
86  {
87  // result of multiplication of libtime::TAbsoluteTime with
88  // any value (also negative) provides a positive result;
89  // swap sign just to make things clear
90  tcorr *= -1;
91  retval -= (corr * tcorr);
92  }
93  }
94  if (this->hasblockette1001())
95  {
96  int tcorr=this->blockette1001().iusec();
97  if (tcorr != 0)
98  {
99  libtime::TRelativeTime corr(0,0,0,0,0,1);
100  if (tcorr >= 0)
101  {
102  retval += (corr * tcorr);
103  }
104  else
105  {
106  // result of multiplication of libtime::TAbsoluteTime with
107  // any value (also negative) provides a positive result;
108  // swap sign just to make things clear
109  tcorr *= -1;
110  retval -= (corr * tcorr);
111  }
112  }
113  }
114  return(retval);
115  } // libtime::TAbsoluteTime MiniSEEDRecord::date() const
116 
117  /*----------------------------------------------------------------------*/
118 
119  double MiniSEEDRecord::dt() const
120  {
121  return(samplinginterval(this->recordheader().srate,
122  this->recordheader().srmult));
123  } // double MiniSEEDRecord::dt() const
124 
125  } // namespace mseed
126 
127 } // namespace datrw
128 
129 /* ----- END OF mseedread_mseedrecord_other.cc ----- */
const SEED::FixedDataRecordHeader & recordheader() const
returns Fixed Data Record Header
Definition: mseedread.h:177
unsigned short int nsamp
number of samples
Definition: seedstructs.h:311
double samplinginterval(const short int &srate, const short int &srmult)
calculate sampling interval from srate and smult
Definition: mseedread.cc:180
double dt() const
return sampling interval
const SEED::DataExtensionBlockette & blockette1001() const
returns Data Extension Blockette
Definition: mseedread.h:183
bool hasblockette1001() const
true if Data Extension Blockette is present
Definition: mseedread.h:174
aff::Series< Tvalue > Tseries
type of container for sample data
Definition: mseedread.h:159
Root namespace of library.
Definition: aalibdatrwxx.cc:16
libtime::TAbsoluteTime convert(const SEED::BTIME &t)
convert BTIME structure to libtime structure
Definition: mseedread.cc:166
bool valid() const
true if record was successfully read
Definition: mseedread.h:187
SEED::FixedDataRecordHeader Mrecordheader
Fixed Data Record Header.
Definition: mseedread.h:237
libtime::TAbsoluteTime date() const
return time of first sample
Tseries Mdata
Container for sample data.
Definition: mseedread.h:245
bool tcorrapp
time correction applied
Definition: seedstructs.h:239
Tseries data() const
Return actual data samples stored in object.