Commit 8ff9040b authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Add methods to data_obs class

- set_msec to set milliseconds
- add_time to add a time difference in sec/nsec
- bugfix when assigning data
- initiialize with zero time and missing data value
parent 950ca345
......@@ -78,6 +78,8 @@ double get_MD();
/** Set msec to zero if below given scatter. */
public: int smooth_msec(int prec);
/** Set msec */
public: int set_msec(long msec);
/** Set the time of the data */
public: int set_time(int year, int mon, int day, int hour, int min, int sec,
long msec);
......@@ -88,6 +90,9 @@ public: int set_timing_err(double error);
/** Set the time of the data */
public: int set_time(data_obs* data);
/** Add specified time **/
public: int add_time(time_t sec, long nsec);
/** Get the time of the data */
public: int get_time(int* year, int* mon, int* day, int* hour, int* min, int* sec,
long* msec);
......
......@@ -32,7 +32,8 @@
// Standard Constructor
data_obs::data_obs() {
year=0;
set_time(0,0,0,0,0,0,(long) 0);
set_values_MD();
// TODO: Assign MD, move MD variable to data_obs class
estimated_timing_error=-99999;
}
......@@ -87,6 +88,18 @@ int data_obs::smooth_msec(int prec){
}
/****************************************************************************
* *
* Set msec
* *
***************************************************************************/
int data_obs::set_msec(long msec){
this->msec=msec;
return(0);
}
/********************************************************************************
* *
......@@ -155,6 +168,24 @@ int data_obs::set_time(struct timespec* time) {
}
/********************************************************************************
* *
* Add timeshift *
* *
********************************************************************************/
int data_obs::add_time(time_t sec, long nsec){
struct timespec time;
get_time(&time);
time.tv_sec+=sec;
time.tv_nsec+=nsec;
set_time(&time);
return(0);
}
/********************************************************************************
* *
* Set the time from timespec. *
......@@ -373,8 +404,8 @@ int data_obs::set_data(double* values){
}
int data_obs::set_data(std::vector<double>& values){
if (values.size() != N_data); return(-1);
data = values;
if (values.size() != N_data) return(-1);
data.assign(values.begin(),values.end());
return(0);
}
......@@ -422,7 +453,7 @@ int data_obs::set_supp(double* values){
}
int data_obs::set_supp(std::vector<double>& values){
if (values.size() != N_supp); return(-1);
if (values.size() != N_supp) return(-1);
supp = values;
return(0);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment