Commit bf88f3d6 authored by Thomas Edwards's avatar Thomas Edwards
Browse files

Merge branch 'dtu_develop' into rasp3_DTU

parents 302ddf4b 55f517e7
......@@ -12,6 +12,7 @@ PRIVATE/
CHANGELOG
DataLogger
parameters*
RSYNC
DATA
DATA/*
......
......@@ -26,13 +26,13 @@ public:
int median(buffer_obs* buffer_in, buffer_obs* buffer_out,
data_obs* data, data_obs* data0, double freq_out);
int median_odd_vec(buffer_obs* buffer_in,
int median_odd(buffer_obs* buffer_in,
buffer_obs* buffer_out, int points, int downsample);
int gaussian_odd_vec(buffer_obs* buffer_in,
buffer_obs* buffer_out, double cutoff, int points);
int fir_window_vec(buffer_obs* buffer_in,
int fir_window(buffer_obs* buffer_in,
buffer_obs* buffer_out, std::vector <double>* win,
int downsample=1);
......
......@@ -4,9 +4,7 @@
#include <vector>
#include <string> // String
#include <data_obs_vector.hpp>
#include <data_obs_scalar.hpp>
#include <Obs_Calibration.hpp>
#include <data_obs.hpp>
#include <unordered_map>
class Obs_Calibration_Vector {
......@@ -21,13 +19,15 @@ private:
std::string file_ADC="";
/** The offset */
double offset[5];
std::vector<double> offset;
/** The scale value */
double scale[5];
std::vector<double> scale;
int N=0;
/** Non-zero calibration constants */
char do_cal;
char do_cal=0;
/** ADC calibration constant */
struct adc_cal {
......@@ -59,15 +59,11 @@ private:
public:
/** Constructor with single values */
Obs_Calibration_Vector(double offset=0, double scale=1);
Obs_Calibration_Vector(int N, double offset=0, double scale=1);
/** Constructor with vector values */
Obs_Calibration_Vector(double* offset, double* scale);
/** Constructor with individual values */
Obs_Calibration_Vector(double scale_X, double scale_Y, double scale_Z, double scale_T1, double scale_T2,
double offset_X=0, double offset_Y=0, double offset_Z=0, double offset_T1=0, double offset_T2=0);
Obs_Calibration_Vector(std::vector<double>& offset,
std::vector<double>& scale);
//
// Public Methods
......@@ -75,11 +71,8 @@ public:
public:
/** Calibrate the vector data */
int calibrate(data_obs_vector* vdata);
/** Calibrate the scalar data */
int calibrate(data_obs_scalar* sdata);
/** Calibrate data */
int calibrate(data_obs* sdata);
/** Get the calibration constants for the ADC */
int get_adc_calibrate(std::string config, std::string &offset,
......
......@@ -52,7 +52,7 @@ int read(std::string filename);
/** Search for value from key */
std::string get_str(std::string key);
int get_int(std::string key);
double get_dbl(std::string key);
double get_dbl(std::string key,double my_default=-1);
/** Add a key-value pair */
int add(std::string key, std::string val);
......
/*
* File: String_Parser.hpp
* Author: mors
*
* Created on October 20, 2020, 11:52 AM
*/
#ifndef STRING_PARSER_HPP
#define STRING_PARSER_HPP
// C++ headers
#include <string>
// Custom C++ Headers
#include <data_obs.hpp> // Basic observatory data class
#include <data_obs_vector.hpp> // Basic observatory data class
#include <data_obs_scalar.hpp> // Basic observatory data class
/****************************************************************************
****************************************************************************
*
* This class provides a generator and parser of strings to data objects
*
****************************************************************************
***************************************************************************/
class String_Parser {
//
// Private class variables
//
private:
/** Format String */
std::string formatstr;
//
// Constructors
//
/** Standard constructor */
public: String_Parser();
public: String_Parser(std::string formatstr);
//
// Public Methods
//
public:
/** Set the format */
int set_format(const std::string& format);
/** Get the string representation */
int string(std::string& string, data_obs* data);
/** Parse the string representation */
int parse(data_obs* data, std::string* string);
};
#endif /* STRING_PARSER_HPP */
......@@ -8,14 +8,18 @@
* This class implements the abstract class buffer_obs. *
* *
********************************************************************************/
#ifndef _BUFFER_OBS_file_H
#define _BUFFER_OBS_file_H
#ifndef _BUFFER_OBS_FILE_H
#define _BUFFER_OBS_FILE_H
#include <buffer_obs.hpp>
#include <data_obs.hpp>
#include <data_obs_vector.hpp>
#include <data_obs_scalar.hpp>
#include <fstream>
#include <String_Parser.hpp>
class buffer_obs_file : public buffer_obs
{
......@@ -23,10 +27,8 @@ class buffer_obs_file : public buffer_obs
// Private class variables
//
private:
protected:
// Precision
int precision;
// Path to output files
std::string path;
// Format of output file (strftime)
......@@ -37,37 +39,39 @@ std::string filename="";
std::fstream file;
//
// Constructors
//
public:
//buffer_obs_file(int precision=2);
//buffer_obs_file(int precision,std::string path);
buffer_obs_file(int precision=2,std::string path="", std::string format="TEST_%Y%m%d.txt");
//buffer_obs_file_ascii(int precision=2);
//buffer_obs_file_ascii(int precision,std::string path);
buffer_obs_file(std::string path="",
std::string file="TEST_%Y%m%d.txt");
//
// Public Methods
//
/** Add to buffer */
public: int put(data_obs* data);
public: virtual int put(data_obs* data)=0;
/** Get last element and delete */
public: int pop(data_obs* data);
public: virtual int pop(data_obs* data)=0;
/** Get last element and delete */
public: data_obs pop();
public: virtual data_obs pop()=0;
//
// Private Methods
//
/** Initialize the buffer */
private: int init();
protected: int init();
/** Open file and create folder */
private: int open(std::string filename);
protected: int open(std::string filename);
/** Write string to file buffer */
protected: int check(data_obs* data);
};
#endif /* _BUFFER_OBS_file_H */
#endif /* _BUFFER_OBS_FILE_H */
/********************************************************************************
* WRITTEN BY ACHIM MORSCHHAUSER, GFZ POTSDAM, July 2019 *
* mors//gfz-potsdam.de *
* *
* This class provides a buffer of observatory data that uses file input and *
* output. It can be used in combination with the SHELL file operator (|). *
* *
* This class implements the abstract class buffer_obs. *
* *
********************************************************************************/
#ifndef _BUFFER_OBS_FILE_ASCII_H
#define _BUFFER_OBS_FILE_ASCII_H
#include <buffer_obs_file.hpp>
#include <data_obs.hpp>
#include <data_obs_vector.hpp>
#include <data_obs_scalar.hpp>
#include <fstream>
#include <String_Parser.hpp>
class buffer_obs_file_ascii : public buffer_obs_file
{
//
// Private class variables
//
private:
// String Parser for data format in file
String_Parser parser;
//
// Constructors
//
public:
//buffer_obs_file(int precision=2);
//buffer_obs_file(int precision,std::string path);
buffer_obs_file_ascii(std::string path="",
std::string file="TEST_%Y%m%d.txt");
buffer_obs_file_ascii(int precision,
std::string path="",
std::string file="TEST_%Y%m%d.txt");
buffer_obs_file_ascii(std::string& formatstr,
std::string path="",
std::string file="TEST_%Y%m%d.txt");
buffer_obs_file_ascii(const String_Parser& parser,
std::string path="",
std::string file="TEST_%Y%m%d.txt");
//
// Public Methods
//
/** Add to buffer */
public: int put(data_obs* data);
/** Get last element and delete */
public: int pop(data_obs* data);
/** Get last element and delete */
public: data_obs pop();
//
// Private Methods
//
};
#endif /* _BUFFER_OBS_FILE_ASCII_H */
/********************************************************************************
* WRITTEN BY ACHIM MORSCHHAUSER, GFZ POTSDAM, July 2019 *
* mors//gfz-potsdam.de *
* *
* This class provides a buffer of observatory data that uses file input and *
* output. It can be used in combination with the SHELL file operator (|). *
* *
* This class implements the abstract class buffer_obs. *
* *
********************************************************************************/
#ifndef _BUFFER_OBS_FILE_BINARY_H
#define _BUFFER_OBS_FILE_BINARY_H
#include <buffer_obs_file.hpp>
#include <data_obs.hpp>
#include <data_obs_vector.hpp>
#include <data_obs_scalar.hpp>
#include <fstream>
class buffer_obs_file_binary : public buffer_obs_file
{
//
// Private class variables
//
private:
bool info_written=false;
//
// Constructors
//
public:
//buffer_obs_file_binary(int precision=2);
//buffer_obs_file_binary(int precision,std::string path);
buffer_obs_file_binary(std::string path="",
std::string file="TEST_%Y%m%d.bin");
//
// Public Methods
//
/** Add to buffer */
public: int put(data_obs* data);
/** Get last element and delete */
public: int pop(data_obs* data);
/** Get last element and delete */
public: data_obs pop();
//
// Private Methods
//
private:
int info(data_obs* data);
};
#endif /* _BUFFER_OBS_FILE_BINARY_H */
......@@ -13,6 +13,7 @@
// C++ Headers
#include <string>
#include <vector>
#include <map>
class data_obs
......@@ -32,6 +33,21 @@ protected: int sec;
protected: long msec;
protected: double estimated_timing_error;
protected: int N_data=0;
protected: int N_supp=0;
//TODO Must be the same for all instances
protected: double MD=99999; // Missing data value
// Data
protected: std::vector<double> data;
protected: std::vector<double> supp;
//protected: std::unique_ptr<double[]> supp;
// Data to channel mapping
protected: std::map<std::string, int> datatype;
protected: std::map<std::string, int> supptype;
//
// Constructors
//
......@@ -56,6 +72,9 @@ bool operator < (const data_obs data1) const {
// Public Methods
//
/** Get the missing data value */
double get_MD();
/** Set msec to zero if below given scatter. */
public: int smooth_msec(int prec);
......@@ -72,11 +91,17 @@ public: int set_time(data_obs* data);
/** Get the time of the data */
public: int get_time(int* year, int* mon, int* day, int* hour, int* min, int* sec,
long* msec);
/** Get the time as std::vector */
public: int get_time(std::vector<int> &time);
/** Get time as tm */
public: int get_time(struct tm* time) const;
/** Get time as timespec */
public: int get_time(struct timespec* time) const;
/** Get time as str representation */
public: std::string get_time(std::string formatstr) const;
public: std::string get_time(std::string formatstr, bool rounded) const;
/** Get single parts of the time */
public: int get_year();
public: int get_mon ();
......@@ -86,6 +111,41 @@ public: int get_min ();
public: int get_sec ();
public: long get_msec();
// Get data
public: virtual double get_data(char id);
protected: virtual int get_data(double values[]);
public: virtual int get_data(std::vector<double>& values);
public: virtual double get_data(int channel);
// Set data
public: virtual int set_data(double value, int channel);
protected: virtual int set_data(double* values);
public: virtual int set_data(std::vector<double>& values);
// Get number of data channels
public: int get_Ndata();
// Get supplementary data
public: virtual double get_supp(char id);
private: virtual int get_supp(double* values);
public: virtual int get_supp(std::vector<double>& values);
public: virtual double get_supp(int channel);
// Set supplementary data
public: virtual int set_supp(double value,int channel);
private: virtual int set_supp(double* values);
public: virtual int set_supp(std::vector<double>& values);
// Get number of supplementary channels
public: int get_Nsupp();
// Set all (copy operator)
public: virtual int set_all(data_obs* data);
public: virtual int set_all(std::vector<double>& values);
private: virtual int get_all(double* data);
public: virtual int get_all(std::vector<double>& values);
public: int get_N();
public: int set_values_MD();
/** Get a string representation */
public: virtual int string(std::string* string, int precision);
......@@ -98,9 +158,15 @@ public: double timediff(data_obs* data) const;
/** Calculate median for odd number of data */
virtual int median_odd(std::vector <data_obs*>* data);
public: virtual int median_time(std::vector <data_obs*>* data);
private: virtual int median_odd_data(std::vector <data_obs*>* data);
/** Symmetric FIR filter */
virtual int filter_fir_sym(std::vector <data_obs*>* data,
public: virtual int filter_fir_sym(std::vector <data_obs*>* data,
std::vector <double>* win);
private: virtual int filter_fir_sym_data(std::vector <data_obs*>* data,
std::vector <double>* win);
private: virtual int filter_fir_sym_supp(std::vector <data_obs*>* data,
std::vector <double>* win);
/** Calculate median of even number of data */
......
......@@ -26,7 +26,6 @@ class data_obs_scalar : public data_obs
// Data
protected: double value;
protected: int quality;
protected: std::string raw_buffer;
//
// Constructors
......@@ -48,8 +47,12 @@ class data_obs_scalar : public data_obs
/** Get single data fields */
public: int get_quality();
public: double get_value();
// Get data values
double get_data(int channel);
// Get supplementary data channels
double get_supp(int channel);
/** Get single data fields */
/** Set single data fields */
public: int set_value(double data);
/** Get string */
......
......@@ -23,16 +23,6 @@ class data_obs_vector : public data_obs
// Private Class Variables
//
// Data
protected: double X;
protected: double Y;
protected: double Z;
protected: double T1;
protected: double T2;
//TODO Must be the same for all instances
protected: double MD; // Missing data value
//
// Constructors
//
......@@ -40,9 +30,19 @@ class data_obs_vector : public data_obs
/** Standard Construtor */
public:
data_obs_vector(double MD=-99999);
//TODO Maybe there is a better way to initialize MD with the
// standard value in data_obs
data_obs_vector(double MD=99999, int Nsupp=2);
data_obs_vector(int Nsupp);
data_obs_vector(data_obs_vector* data);
//
// Private Methods
//
private:
int init();
//
// Public Methods
......@@ -51,43 +51,24 @@ class data_obs_vector : public data_obs
public:
/** Set the data -> No checking of buffer done! Must be five fields long.*/
public: using data_obs::set_data;
int set_data(double X, double Y, double Z, double T1, double T2);
int set_data(double* data);
int set_data(data_obs_vector* data);
int set_data_MD();
//public: virtual int set_data(std::vector<double>& values);
/** Get the data */
public: using data_obs::get_data;
int get_data(double* X, double* Y, double* Z, double* T1, double* T2);
/** Get the data -> No checking of buffer done! Must be five fields long.*/
int get_data(double* data);
/** Get single data fields */
double get_X();
double get_Y();
double get_Z();
double get_T1();
double get_T2();
/** get the missing data value */
double get_MD();
/** Get a string representation of the form
"YYYY MM DD HH mm ss mil XXXXX.XX YYYYY.YY ZZZZZ.ZZ TT.TT TT.TT"
where mil: milliseconds*/
int string(std::string* string, int precision);
virtual int string(std::string* string, int precision);
/** Parse a string representation of the form
"YYYY MM DD HH mm ss mil XXXXX.XX YYYYY.YY ZZZZZ.ZZ TT.TT TT.TT"
where mil: milliseconds*/
int parse(std::string* string);
/** Calculate median for odd number of data */
int median_odd(std::vector <data_obs_vector*>* data);
/** Symmetric FIR filter */
int filter_fir_sym(std::vector <data_obs*>* data,
std::vector <double>* win);
virtual int parse(std::string* string);
};
......
......@@ -59,6 +59,10 @@ double valid_filter_rates[11];
static const int valid_filter_rates_num=11;
const char* filter_cmds[11];
/** Number of data channels */
int N_data = 3;
/** Number of supplementary channels */
int N_supp = 4;
/** Counting variable for binary data supplemental channels */
int supp_count=0;
......
This diff is collapsed.