version  0.0.1
Defines the C++ API for MsPASS
Public Member Functions | List of all members
mspass::seismic::TimeSeriesWGaps Class Reference
Inheritance diagram for mspass::seismic::TimeSeriesWGaps:
mspass::seismic::TimeSeries mspass::seismic::DataGap mspass::seismic::CoreTimeSeries mspass::utility::ProcessingHistory mspass::seismic::BasicTimeSeries mspass::utility::Metadata mspass::utility::BasicProcessingHistory mspass::utility::BasicMetadata

Public Member Functions

 TimeSeriesWGaps ()
 Constructor. More...
 
 TimeSeriesWGaps (const TimeSeries &parent)
 
 TimeSeriesWGaps (const TimeSeriesWGaps &parent)
 
 TimeSeriesWGaps (const TimeSeries &tsp, const DataGap &dgp)
 
TimeSeriesWGapsoperator= (const TimeSeriesWGaps &parent)
 
void ator (const double tshift)
 
void rtoa (const double tshift)
 
void rtoa ()
 
void shift (const double dt)
 
void zero_gaps ()
 
size_t memory_use () const
 
- Public Member Functions inherited from mspass::seismic::TimeSeries
 TimeSeries ()
 
 TimeSeries (const size_t nsamples)
 
 TimeSeries (const BasicTimeSeries &bts, const Metadata &md)
 
 TimeSeries (const Metadata &md)
 
 TimeSeries (const mspass::seismic::CoreTimeSeries &d)
 Construct from lower level CoreTimeSeries. More...
 
 TimeSeries (const mspass::seismic::CoreTimeSeries &d, const std::string alg)
 
 TimeSeries (const mspass::seismic::BasicTimeSeries &b, const mspass::utility::Metadata &m, const mspass::utility::ProcessingHistory &mcts, const std::vector< double > &d)
 
 TimeSeries (const TimeSeries &parent)
 
TimeSeriesoperator= (const TimeSeries &parent)
 
TimeSeriesoperator+= (const TimeSeries &d)
 
TimeSeriesoperator*= (const double scale)
 
TimeSeriesoperator-= (const TimeSeries &d)
 
void load_history (const mspass::utility::ProcessingHistory &h)
 
size_t memory_use () const
 
- Public Member Functions inherited from mspass::seismic::CoreTimeSeries
 CoreTimeSeries ()
 
 CoreTimeSeries (const size_t nsin)
 
 CoreTimeSeries (const BasicTimeSeries &bts, const Metadata &md)
 
 CoreTimeSeries (const CoreTimeSeries &)
 
void set_dt (const double sample_interval)
 Set the sample interval. More...
 
void set_npts (const size_t npts)
 Set the number of samples attribute for data. More...
 
void sync_npts ()
 Sync the number of samples attribute with actual data size. More...
 
void set_t0 (const double t0in)
 Set the data start time. More...
 
CoreTimeSeriesoperator= (const CoreTimeSeries &parent)
 
CoreTimeSeriesoperator+= (const CoreTimeSeries &d)
 Summation operator. More...
 
const CoreTimeSeries operator+ (const CoreTimeSeries &other) const
 
CoreTimeSeriesoperator*= (const double)
 
CoreTimeSeriesoperator-= (const CoreTimeSeries &d)
 Subtraction operator. More...
 
const CoreTimeSeries operator- (const CoreTimeSeries &other) const
 
double operator[] (size_t const sample) const
 
- Public Member Functions inherited from mspass::seismic::BasicTimeSeries
 BasicTimeSeries ()
 
 BasicTimeSeries (const BasicTimeSeries &)
 
virtual ~BasicTimeSeries ()
 Virtual destructor. More...
 
double time (const int i) const
 
int sample_number (double t) const
 
double endtime () const noexcept
 
bool shifted () const
 
double time_reference () const
 
void force_t0_shift (const double t)
 Force a t0 shift value on data. More...
 
bool live () const
 
bool dead () const
 
void kill ()
 
void set_live ()
 
double dt () const
 
bool time_is_UTC () const
 
bool time_is_relative () const
 
TimeReferenceType timetype () const
 
double samprate () const
 
size_t npts () const
 
double t0 () const
 
void set_tref (const TimeReferenceType newtref)
 Force the time standard. More...
 
BasicTimeSeriesoperator= (const BasicTimeSeries &parent)
 
- Public Member Functions inherited from mspass::utility::ProcessingHistory
 ProcessingHistory ()
 
 ProcessingHistory (const std::string jobnm, const std::string jid)
 
 ProcessingHistory (const ProcessingHistory &parent)
 
bool is_empty () const
 
bool is_raw () const
 
bool is_origin () const
 
bool is_volatile () const
 
bool is_saved () const
 
size_t number_of_stages () override
 Return number of processing stages that have been applied to this object. More...
 
void set_as_origin (const std::string alg, const std::string algid, const std::string uuid, const AtomicType typ, bool define_as_raw=false)
 
std::string new_ensemble_process (const std::string alg, const std::string algid, const AtomicType typ, const std::vector< ProcessingHistory * > parents, const bool create_newid=true)
 
void add_one_input (const ProcessingHistory &data_to_add)
 Add one datum as an input for current data. More...
 
void add_many_inputs (const std::vector< ProcessingHistory * > &d)
 Define several data objects as inputs. More...
 
void merge (const ProcessingHistory &data_to_add)
 Merge the history nodes from another. More...
 
void accumulate (const std::string alg, const std::string algid, const AtomicType typ, const ProcessingHistory &newinput)
 Method to use with a spark reduce algorithm. More...
 
std::string clean_accumulate_uuids ()
 Clean up inconsistent uuids that can be produced by reduce. More...
 
std::string new_map (const std::string alg, const std::string algid, const AtomicType typ, const ProcessingStatus newstatus=ProcessingStatus::VOLATILE)
 Define this algorithm as a one-to-one map of same type data. More...
 
std::string new_map (const std::string alg, const std::string algid, const AtomicType typ, const ProcessingHistory &data_to_clone, const ProcessingStatus newstatus=ProcessingStatus::VOLATILE)
 Define this algorithm as a one-to-one map. More...
 
std::string map_as_saved (const std::string alg, const std::string algid, const AtomicType typ)
 Prepare the current data for saving. More...
 
void clear ()
 
std::multimap< std::string, mspass::utility::NodeDataget_nodes () const
 
int stage () const
 
ProcessingStatus status () const
 
std::string id () const
 
std::pair< std::string, std::string > created_by () const
 
NodeData current_nodedata () const
 
std::string newid ()
 
int number_inputs () const
 
int number_inputs (const std::string uuidstr) const
 
void set_id (const std::string newid)
 
std::list< mspass::utility::NodeDatainputs (const std::string id_to_find) const
 Return a list of data that define the inputs to a give uuids. More...
 
ProcessingHistoryoperator= (const ProcessingHistory &parent)
 
- Public Member Functions inherited from mspass::utility::BasicProcessingHistory
 BasicProcessingHistory (const std::string jobname, const std::string jobid)
 
 BasicProcessingHistory (const BasicProcessingHistory &parent)
 
std::string jobid () const
 
void set_jobid (const std::string &newjid)
 
std::string jobname () const
 
void set_jobname (const std::string jobname)
 
BasicProcessingHistoryoperator= (const BasicProcessingHistory &parent)
 
- Public Member Functions inherited from mspass::seismic::DataGap
 DataGap ()
 
 DataGap (const std::list< mspass::algorithms::TimeWindow > &twlist)
 
 DataGap (const DataGap &parent)
 
bool is_gap (const double ttest)
 
bool has_gap (const mspass::algorithms::TimeWindow twin)
 
bool has_gap ()
 
void add_gap (const mspass::algorithms::TimeWindow tw)
 
std::list< mspass::algorithms::TimeWindowget_gaps () const
 
void clear_gaps ()
 Clear gaps. More...
 
int number_gaps () const
 
DataGap subset (const mspass::algorithms::TimeWindow tw) const
 
void translate_origin (double time_of_new_origin)
 
DataGapoperator= (const DataGap &parent)
 
DataGapoperator+= (const DataGap &other)
 

Additional Inherited Members

- Public Attributes inherited from mspass::seismic::CoreTimeSeries
std::vector< double > s
 
- Public Attributes inherited from mspass::utility::ProcessingHistory
ErrorLogger elog
 
- Protected Attributes inherited from mspass::seismic::BasicTimeSeries
bool mlive
 
double mdt
 
double mt0
 
size_t nsamp
 
TimeReferenceType tref
 
bool t0shift_is_valid
 
double t0shift
 
- Protected Attributes inherited from mspass::utility::ProcessingHistory
std::multimap< std::string, mspass::utility::NodeDatanodes
 
- Protected Attributes inherited from mspass::utility::BasicProcessingHistory
std::string jid
 
std::string jnm
 
- Protected Attributes inherited from mspass::seismic::DataGap
std::set< mspass::algorithms::TimeWindow, mspass::algorithms::TimeWindowCmpgaps
 Holds data gap definitions. We use an STL set object to define data gaps for any time series object derived from this base class. The set is keyed by a TimeWindow which allows a simple, fast way to define a time range with invalid data.
 

Constructor & Destructor Documentation

◆ TimeSeriesWGaps() [1/3]

mspass::seismic::TimeSeriesWGaps::TimeSeriesWGaps ( )
inline

Constructor.

Will need a set of conastructors. Requires some thought as how to set gap is an issue.

13 :TimeSeries(),DataGap(){};
DataGap()
Definition: DataGap.h:28
TimeSeries()
Definition: TimeSeries.h:18

◆ TimeSeriesWGaps() [2/3]

mspass::seismic::TimeSeriesWGaps::TimeSeriesWGaps ( const TimeSeries parent)
inline

Partial copy constructor from a plain TimeSeries.

Sometimes we need to build the skeleton of a gappy TimeSeries from a regular TimeSeries. This does that and builds makes a copy of the TimeSeries and creates an empty container that defines the gaps.

19 : TimeSeries(parent),DataGap(){};

◆ TimeSeriesWGaps() [3/3]

mspass::seismic::TimeSeriesWGaps::TimeSeriesWGaps ( const TimeSeriesWGaps parent)
inline

Copy constructor.

22  : TimeSeries(dynamic_cast<const TimeSeries&>(parent)),
23  DataGap(dynamic_cast<const DataGap&>(parent)){};;

Member Function Documentation

◆ ator()

void mspass::seismic::TimeSeriesWGaps::ator ( const double  tshift)
virtual

Absolute to relative time conversion. Sometimes we want to convert data from absolute time (epoch times) to a relative time standard. Examples are conversions to travel time using an event origin time or shifting to an arrival time reference frame. This operation simply switches the tref variable and alters t0 by tshift.

This method overrides the one in BasicTimeSeries to correctly reference gaps.

Parameters
tshift- time shift applied to data before switching data to relative time mode.

Reimplemented from mspass::seismic::BasicTimeSeries.

17 {
18  /* dead traces should to totally ignored */
19  if(this->dead()) return;
21  this->t0shift=tshift;
22  this->mt0 -= tshift;
23  // We have to shift all the gap windows definitions
24  TimeWindow tw;
25  std::set <TimeWindow,TimeWindowCmp> shifted_gaps;
26  std::set <TimeWindow,TimeWindowCmp>::iterator this_gap;
27  for(this_gap=gaps.begin();this_gap!=gaps.end();++this_gap)
28  {
29  tw.start = this_gap->start - tshift;
30  tw.end = this_gap->end - tshift;
31  shifted_gaps.insert(tw);
32  }
33  /* the section below is a replacement for the following simple
34  construct that worked in the old seispp library that used a
35  similar construct for gaps:
36  this->gaps = shifted_gaps;
37  Had to use the clear and loop below because g++ complained about operator=
38  not being defined for the set container. This loop is likely actually
39  faster than having to call operator= anyway but why this fails is unknown. */
40  this->gaps.clear();
41  for(this_gap=shifted_gaps.begin();this_gap!=shifted_gaps.end();++this_gap)
42  {
43  this->gaps.insert(*this_gap);
44  }
46  this->t0shift_is_valid=true;
47 
48 }
Defines a time window.
Definition: TimeWindow.h:14
double start
Definition: TimeWindow.h:19
double end
Definition: TimeWindow.h:23
bool dead() const
Definition: BasicTimeSeries.h:149
TimeReferenceType tref
Definition: BasicTimeSeries.h:278
double mt0
Definition: BasicTimeSeries.h:264
std::set< mspass::algorithms::TimeWindow, mspass::algorithms::TimeWindowCmp > gaps
Holds data gap definitions. We use an STL set object to define data gaps for any time series object d...
Definition: DataGap.h:106

References mspass::algorithms::TimeWindow::end, mspass::seismic::Relative, and mspass::algorithms::TimeWindow::start.

◆ memory_use()

size_t mspass::seismic::TimeSeriesWGaps::memory_use ( ) const

Return an estimate of the memmory use by the data in this object.

Memory consumed by a TimeSeriesWGaps object is needed to implement the sizeof method in python that dask/spark use to manage memory. Without that feature we had memory fault issues. Note the estimate this method returns should not be expected to be exact. The MsPASS implementation or any alternative implementation avoids an exact calculation because it requries an (expensive) traversal of multiple map containers.

164 {
165  size_t memory_estimate;
166  memory_estimate = TimeSeries::memory_use();
167  memory_estimate += DATA_GAP_AVERAGE_SIZE*gaps.size();
168  return memory_estimate;
169 }
size_t memory_use() const
Definition: TimeSeries.cc:96

References mspass::seismic::TimeSeries::memory_use().

◆ rtoa() [1/2]

void mspass::seismic::TimeSeriesWGaps::rtoa ( )
virtual

Relative to absolute time conversion. Sometimes we want to convert data from relative time to to an absolute time standard. An example would be converting segy shot data to something that could be processed like earthquake data in a css3.0 database.

This method returns data previously converted to relative back to absolute using the internally stored time shift attribute.

This method overrides the one in BasicTimeSeries to correctly reference gaps.

Reimplemented from mspass::seismic::BasicTimeSeries.

75 {
76  /* dead traces should to totally ignored */
77  if(this->dead()) return;
78  const std::string errormess("TimeSeriesWGaps::rtoa() t0shift for conversion is not defined.");
79  /* This perhaps should create a complaint message */
80  if(tref==TimeReferenceType::UTC) return;
81  /* A rather odd test for a nonzero. We use 100 s assuming no active
82  * source data would use a shift longer than that unless it really did
83  * have an absolute time standard. Also assumes we'll never use data from
84  * the first 2 minutes of 1960.*/
85  if(t0shift_is_valid || (t0shift>100.0) )
86  {
87  this->mt0 += this->t0shift;
88  TimeWindow tw;
89  std::set <TimeWindow,TimeWindowCmp> shifted_gaps;
90  std::set <TimeWindow,TimeWindowCmp>::iterator this_gap;
91  for(this_gap=gaps.begin();this_gap!=gaps.end();++this_gap)
92  {
93  tw.start = this_gap->start + t0shift;
94  tw.end = this_gap->end + t0shift;
95  shifted_gaps.insert(tw);
96  }
97  /* See related comment on why the line below will not compile */
98  //this->gaps = shifted_gaps;
99  this->gaps.clear();
100  for(this_gap=shifted_gaps.begin();this_gap!=shifted_gaps.end();++this_gap)
101  {
102  this->gaps.insert(*this_gap);
103  }
105  t0shift_is_valid=false;
106  }
107  else
108  {
109  this->kill();
110  throw MsPASSError(errormess,ErrorSeverity::Invalid);
111  }
112 }
void kill()
Definition: BasicTimeSeries.h:151
Base class for error object thrown by MsPASS library routines.
Definition: MsPASSError.h:40

References mspass::algorithms::TimeWindow::end, mspass::algorithms::TimeWindow::start, and mspass::seismic::UTC.

◆ rtoa() [2/2]

void mspass::seismic::TimeSeriesWGaps::rtoa ( const double  tshift)

Relative to absolute time conversion. Sometimes we want to convert data from relative time to to an absolute time standard. An example would be converting segy shot data to something that could be processed like earthquake data in a css3.0 database. This operation simply switches the tref variable and alters t0 by tshift.

This method overrides the one in BasicTimeSeries to correctly reference gaps.

Parameters
tshift- time shift applied to data before switching data to absolute time mode.

NOTE: This method is maintained only for backward compatibility. May be depricated in favor of method that uses internally stored private shift variable.

50 {
51  /* dead traces should to totally ignored */
52  if(this->dead()) return;
53  if(tref==TimeReferenceType::UTC) return;
54  this->mt0 += tshift;
55  TimeWindow tw;
56  std::set <TimeWindow,TimeWindowCmp> shifted_gaps;
57  std::set <TimeWindow,TimeWindowCmp>::iterator this_gap;
58  for(this_gap=gaps.begin();this_gap!=gaps.end();++this_gap)
59  {
60  tw.start = this_gap->start + tshift;
61  tw.end = this_gap->end + tshift;
62  shifted_gaps.insert(tw);
63  }
64  /* See related comment on why the line below will not compile */
65  //this->gaps = shifted_gaps;
66  this->gaps.clear();
67  for(this_gap=shifted_gaps.begin();this_gap!=shifted_gaps.end();++this_gap)
68  {
69  this->gaps.insert(*this_gap);
70  }
72  this->t0shift_is_valid=true;
73 }

References mspass::algorithms::TimeWindow::end, mspass::algorithms::TimeWindow::start, and mspass::seismic::UTC.

◆ shift()

void mspass::seismic::TimeSeriesWGaps::shift ( const double  dt)
virtual

Shift the reference time.

Sometimes we need to shift the reference time t0. An example is a moveout correction. This method shifts the reference time by dt. Note a positive dt means data aligned to zero will be shifted left because relative time is t-t0.

Reimplemented from mspass::seismic::BasicTimeSeries.

114 {
115  /* This is the same test for valid t0shift used in BasicTimeSeries*/
116  if(this->t0shift_is_valid || (this->t0shift>100.0) )
117  {
118  double oldt0shift=this->t0shift;
119  this->rtoa();
120  this->ator(oldt0shift+dt);
121  }
122  else
123  {
124  this->kill();
125  std::stringstream ss;
126  ss<<"TimeSeriesWGaps::shift: internal shift attributes is marked invalid"
127  <<std::endl
128  <<"shift method should only be used on data originating with a UTC time standard"
129  <<std::endl;
130  throw MsPASSError(ss.str(),ErrorSeverity::Invalid);
131  }
132 }
double dt() const
Definition: BasicTimeSeries.h:157
void rtoa()
Definition: TimeSeriesWGaps.cc:74
void ator(const double tshift)
Definition: TimeSeriesWGaps.cc:16

◆ zero_gaps()

void mspass::seismic::TimeSeriesWGaps::zero_gaps ( )

Force all data inside data gaps to zero.

134 {
135  int i,istart,iend;
136  std::set<TimeWindow,TimeWindowCmp>::iterator this_gap;
137 
138  for(this_gap=gaps.begin();this_gap!=gaps.end();++this_gap)
139  {
140  if(this_gap->end < this->mt0) continue;
141  if(this_gap->start > this->endtime()) continue;
142  if(this_gap->start<this->mt0)
143  istart = 0;
144  else
145  istart = round((this_gap->start-this->mt0)/this->mdt);
146  if((this_gap->end) > this->endtime())
147  iend = this->nsamp - 1;
148  else
149  iend = round((this_gap->end-mt0)/this->mdt);
150  for(i=istart;i<=iend;++i) this->s[i]=0.0;
151  }
152 }
size_t nsamp
Definition: BasicTimeSeries.h:268
std::vector< double > s
Definition: CoreTimeSeries.h:28

The documentation for this class was generated from the following files: