◆ DataGap() [1/2]
mspass::seismic::DataGap::DataGap |
( |
| ) |
|
|
inline |
Default construtor. Does nothing but create empty gap container.
◆ DataGap() [2/2]
Construct with an initial list of TimeWindows defining gaps.
◆ add_gap()
Adds a gap to the gap definitions for this data object. Sometimes an algorithm detects or needs to create a gap (e.g. a mute, or a constructor). This function provides a common mechanism to define such a gap in the data.
16 auto insert_result = this->
gaps.insert(tw);
17 if(!insert_result.second)
24 if(tw.
start<old_tw.start)
27 new_tw.
start=old_tw.start;
31 new_tw.
end=old_tw.end;
32 gaps.erase(insert_result.first);
Defines a time window.
Definition: TimeWindow.h:14
double start
Definition: TimeWindow.h:19
double end
Definition: TimeWindow.h:23
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, and mspass::algorithms::TimeWindow::start.
◆ clear_gaps()
void mspass::seismic::DataGap::clear_gaps |
( |
| ) |
|
|
inline |
Clear gaps.
It is sometimes necessary to clear gap definitions. This is particularly important when a descendent of this class is cloned and then morphed into something else. This method clears the entire content. This class assumes gaps are an immutable property of recorded data. A subclass could be used to add that functionality.
References gaps.
◆ get_gaps()
std::list< TimeWindow > mspass::seismic::DataGap::get_gaps |
( |
| ) |
const |
Getter returns a list of TimeWindows defining a set of gaps.
59 std::list<TimeWindow> result;
60 for(
auto sptr=this->
gaps.begin(); sptr!=this->gaps.end(); ++sptr)
61 result.push_back(*sptr);
◆ has_gap() [1/2]
bool mspass::seismic::DataGap::has_gap |
( |
| ) |
|
|
inline |
Global test to see if data has any gaps defined. Gap processing is expensive and we need this simple method to test to see if the associated object has any gaps defined.
- Returns
- true if the associated object has any gaps defined.
56 {
return(!
gaps.empty());};
References gaps.
◆ has_gap() [2/2]
Checks if a given data segment has a gap. For efficiency it is often useful to ask if a whole segment of data is free of gaps. Most time series algorithms cannot process through data gaps so normal practice would be to drop data with any gaps in a requested time segment.
- Returns
- true if time segment has any data gaps
- Parameters
-
twin | time window of data to test defined by a TimeWindow object |
51 if(
gaps.empty())
return false;
◆ is_gap()
bool mspass::seismic::DataGap::is_gap |
( |
const double |
ttest | ) |
|
Checks if data at time ttest is a gap or valid data. This function is like the overloaded version with an int argument except it uses a time instead of sample number for the query.
- Parameters
-
ttest | - time to be tested. |
38 const double dt(0.001);
39 if(
gaps.empty())
return false;
41 twin.
start = ttest - dt*0.5;
42 twin.
end = ttest + dt*0.5;
References mspass::algorithms::TimeWindow::end, and mspass::algorithms::TimeWindow::start.
◆ number_gaps()
int mspass::seismic::DataGap::number_gaps |
( |
| ) |
const |
|
inline |
Return number of defined gaps.
77 {
return gaps.size();};
References gaps.
◆ operator+=()
DataGap & mspass::seismic::DataGap::operator+= |
( |
const DataGap & |
other | ) |
|
Add contents of another DataGap container to this one.
115 for(
auto ptr=parent.gaps.begin();ptr!=parent.gaps.end();++ptr) this->
add_gap(*ptr);
void add_gap(const mspass::algorithms::TimeWindow tw)
Definition: DataGap.cc:14
References gaps.
◆ operator=()
DataGap & mspass::seismic::DataGap::operator= |
( |
const DataGap & |
parent | ) |
|
Standard assignment operator.
References gaps.
◆ subset()
Return the subset of gaps within a specified time interval.
- Parameters
-
tw | TimeWindow defining range to be returned. Note overlaps with the edge will be returned with range outside the range defined by tw. If the tw is larger than the range of the current content returns a copy of itself. |
71 std::list<TimeWindow> gaplist = this->
get_gaps();
72 for(
auto twptr= gaplist.begin();twptr!=gaplist.end();++twptr)
74 if( ((twptr->end)>tw.
start) && ((twptr->start)<tw.
end))
std::list< mspass::algorithms::TimeWindow > get_gaps() const
Definition: DataGap.cc:57
References add_gap(), mspass::algorithms::TimeWindow::end, and mspass::algorithms::TimeWindow::start.
◆ translate_origin()
void mspass::seismic::DataGap::translate_origin |
( |
double |
time_of_new_origin | ) |
|
Shift the times of all gaps by a value.
When used with a TimeSeries or Seismogram the concept of UTC versus relative time requires shifting the time origin.
This method should be used in that context or any other context where the data origin is shifted. The number passed as shift is subtracted from all the window start and end times that define data gaps.
93 std::set<TimeWindow,TimeWindowCmp> translated_gaps;
94 for(
auto ptr=this->
gaps.begin();ptr!=this->gaps.end();++ptr)
97 tw.start -= origin_time;
98 tw.end -= origin_time;
99 translated_gaps.insert(tw);
102 for(
auto ptr=translated_gaps.begin();ptr!=translated_gaps.end();++ptr)
void clear_gaps()
Clear gaps.
Definition: DataGap.h:75
References mspass::algorithms::TimeWindow::end, and mspass::algorithms::TimeWindow::start.
The documentation for this class was generated from the following files:
- /home/runner/work/mspass/mspass/cxx/include/mspass/seismic/DataGap.h
- /home/runner/work/mspass/mspass/cxx/src/lib/seismic/DataGap.cc