Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from jpatton-USGS/site-info
Browse files Browse the repository at this point in the history
Added format for station information
  • Loading branch information
mguy-usgs authored May 11, 2017
2 parents 6b53dc6 + f667376 commit c2d80e2
Show file tree
Hide file tree
Showing 26 changed files with 1,465 additions and 103 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ seismic event detection made using a cross correlation algorithm.
event detection generated using an event detection or association algorithm.
* [Retract](format-docs/Retract.md) Format - A format to contain a seismic event
retraction made using an event detection algorithm.
* [Station](format-docs/Station.md) Format - A format to contain basic station
location and quality information.

## Supporting objects:
* [Hypocenter](format-docs/Hypocenter.md) Object - An object that contains
Expand All @@ -35,13 +37,13 @@ information about an amplitude as part of a pick.
* [Beam](format-docs/Beam.md) Object - An object that contains information
about a waveform beam as part of a pick.
* [Associated](format-docs/Associated.md) Object - An object that contains
associated information if a pick, beam, or correlation is included in an detection.
associated information if a pick or correlation is included in a detection.
* [Filter](format-docs/Filter.md) Object - An object that contains filter
information as part of a pick.
* [Site](format-docs/Site.md) Object - An object that defines the station used
to create a pick, beam, correlation,
to create a pick, correlation, or station.
* [Source](format-docs/Source.md) Object - An object that defines the
creator/source of a pick, correlation, or detection
creator/source of a pick, correlation, or detection.

## Supported Languages:
Currently a library written in C++11, and a Java 1.7 jar file exist to generate
Expand Down
16 changes: 2 additions & 14 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,8 @@ if (RUN_TESTS)
enable_testing()

# ----- TEST SOURCES ----- #
set (UNITTEST_SOURCES ${PROJECT_SOURCE_DIR}/tests/correlation_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/detection_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/pick_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/beam_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/retract_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/associated_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/site_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/source_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/amplitude_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/filter_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/hypocenter_unittest.cpp
${PROJECT_SOURCE_DIR}/tests/main.cpp
)

file(GLOB UNITTEST_SOURCES ${PROJECT_SOURCE_DIR}/tests/*.cpp)

if (NOT MSVC)
set(PTHREADLIB -pthread)
endif (NOT MSVC)
Expand Down
1 change: 1 addition & 0 deletions cpp/include/detection-formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
#include "util.h"
#include "base.h"
#include "retract.h"
#include "stationInfo.h"

#endif
35 changes: 26 additions & 9 deletions cpp/include/detection.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class detection: public detectionbase {
* \param newauthor - A std::string containing the author to use
* \param newlatitude - A double containing the latitude to use
* \param newlongitude - A double containing the longitude to use
* \param newdetectiontime - A double containing the new detection time to
* use
* \param newtime - A double containing the new time to use
* \param newdepth - A double containing the depth to use
* \param newlatitudeerror - A double containing the latitude error to use,
* std::numeric_limits<double>::quiet_NaN() to omit
Expand All @@ -60,6 +59,11 @@ class detection: public detectionbase {
* std::numeric_limits<double>::quiet_NaN() to omit
* \param newdeptherror - A double containing the depth error to use,
* std::numeric_limits<double>::quiet_NaN() to omit
* \param newdetectiontype - A std::string containing the detection type to
* use, empty string to omit
* \param newdetectiontime - A double containing the new time the detection
* was made, i.e. how quickly after origin time, use
* std::numeric_limits<double>::quiet_NaN() to omit
* \param neweventtype - A std::string containing the event type to use,
* empty string to omit
* \param newbayes - A double containing the bayes to use,
Expand All @@ -78,12 +82,13 @@ class detection: public detectionbase {
* vector to omit
*/
detection(std::string newid, std::string newagencyid, std::string newauthor,
double newlatitude, double newlongitude, double newdetectiontime,
double newlatitude, double newlongitude, double newtime,
double newdepth, double newlatitudeerror, double newlongitudeerror,
double newtimeerror, double newdeptherror,
std::string newdetectiontype, std::string neweventtype,
double newbayes, double newminimumdistance, double newrms,
double newgap, std::vector<detectionformats::pick> newpickdata,
std::string newdetectiontype, double newdetectiontime,
std::string neweventtype, double newbayes,
double newminimumdistance, double newrms, double newgap,
std::vector<detectionformats::pick> newpickdata,
std::vector<detectionformats::correlation> newcorrelationdata);

/**
Expand All @@ -99,6 +104,9 @@ class detection: public detectionbase {
* hypocenter to use
* \param newdetectiontype - A std::string containing the detection type to
* use, empty string to omit
* \param newdetectiontime - A double containing the new time the detection
* was made, i.e. how quickly after origin time, use
* std::numeric_limits<double>::quiet_NaN() to omit
* \param neweventtype - A std::string containing the event type to use,
* empty string to omit
* \param newbayes - A double containing the bayes to use,
Expand All @@ -118,9 +126,10 @@ class detection: public detectionbase {
*/
detection(std::string newid, detectionformats::source newsource,
detectionformats::hypocenter newhypocenter,
std::string newdetectiontype, std::string neweventtype,
double newbayes, double newminimumdistance, double newrms,
double newgap, std::vector<detectionformats::pick> newpickdata,
std::string newdetectiontype, double newdetectiontime,
std::string neweventtype, double newbayes,
double newminimumdistance, double newrms, double newgap,
std::vector<detectionformats::pick> newpickdata,
std::vector<detectionformats::correlation> newcorrelationdata);

/**
Expand Down Expand Up @@ -233,6 +242,14 @@ class detection: public detectionbase {
*/
double gap;

/**
* \brief detectiontime value
*
* An optional double containing the time the detection was made, i.e.
* how quickly after origin time.
*/
double detectiontime;

/**
* \brief pick data vector
*
Expand Down
6 changes: 3 additions & 3 deletions cpp/include/pick.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace detectionformats {
/**
* \brief detectionformats pick conversion class
*
* The detectionformats pick class is a conversion class used to create, parse, and
* validate the unassociated pick data format pick. The pick format uses
* The detectionformats pick class is a conversion class used to create, parse,
* and validate the unassociated pick data format pick. The pick format uses
* the JSON standard (www.json.org)
*
* pick is intended for use in seismic data messaging between seismic
Expand All @@ -36,7 +36,7 @@ class pick: public detectionbase {
* \brief pick constructor
*
* The constructor for the pick class.
* Initilizes members to null values.
* Initializes members to null values.
*/
pick();

Expand Down
180 changes: 180 additions & 0 deletions cpp/include/stationInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*****************************************
* This file is documented for Doxygen.
* If you modify this file please update
* the comments so that Doxygen will still
* be able to work.
****************************************/
#ifndef STATION_PICK_H
#define STATION_PICK_H

#include <string>

#include "site.h"

namespace detectionformats {

/**
* \brief detectionformats stationInfo conversion class
*
* The detectionformats stationInfo class is a conversion class used to create,
* parse, and validate the stationInfo data format. The stationInfo format uses
* the JSON standard (www.json.org)
*
* stationInfo is intended for use in seismic data messaging between seismic
* applications and organizations.
*
* stationInfo uses the Site common object.
*/
class stationInfo : public detectionbase {
public:
/**
* \brief stationInfo constructor
*
* The constructor for the stationInfo class.
* Initializes members to null values.
*/
stationInfo();

/**
* \brief stationInfo advanced constructor
*
* The advanced constructor for the stationInfo class.
* Initializes members to provided values.
*
* \param newstation - A std::string containing the station to use
* \param newchannel - A std::string containing the channel to use
* \param newnetwork - A std::string containing the network to use
* \param newlocation - A std::string containing the location to use
* \param newlatitude - A double containing the latitude to use
* \param newlongitude - A double containing the longitude to use
* \param newelevation - A double containing the elevation to use
* \param newquality - A double containing the quality to use,
* std::numeric_limits<double>::quiet_NaN() to omit
* \param newenable - A bool containing the enable flag to use
* \param newuseforteleseismic - A bool containing the use for teleseismic
* to use
*/
stationInfo(std::string newstation, std::string newchannel,
std::string newnetwork, std::string newlocation, double newlatitude,
double newlongitude, double newelevation, double newquality,
bool newenable, bool newuseforteleseismic);

/**
* \brief stationInfo alternate advanced constructor
*
* The alternate advanced constructor for the stationInfo class.
* Initializes members to provided values.
*
* \param newsite - A detectionformats::site containing the site to use
* \param newlatitude - A double containing the latitude to use
* \param newlongitude - A double containing the longitude to use
* \param newelevation - A double containing the elevation to use
* \param newquality - A double containing the quality to use,
* std::numeric_limits<double>::quiet_NaN() to omit
* \param newenable - A bool containing the enable flag to use
* \param newuseforteleseismic - A bool containing the use for teleseismic
* to use
*/
stationInfo(detectionformats::site newsite, double newlatitude,
double newlongitude, double newelevation, double newquality,
bool newenable, bool newuseforteleseismic);

/**
* \brief stationInfo advanced constructor
*
* The advanced constructor for the stationInfo class.
* Converts the provided object from a json::Object, populating members
* \param jsondocument - A json document.
*/
stationInfo(rapidjson::Value &json);

/**
* \brief stationInfo copy constructor
*
* The copy constructor for the stationInfo class.
* Copys members from provided stationInfo.
*
* \param newstation - A detectionformats::stationInfo to copy from
*/
stationInfo(const stationInfo &newstation);

/**
* \brief stationInfo destructor
*
* The destructor for the stationInfo class.
*/
~stationInfo();

/**
* \brief Convert to json object function
*
* Converts the contents of the class to a json object
* \return Returns a json::Object containing the class contents
*/
virtual rapidjson::Value & tojson(rapidjson::Value &json,
rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> &allocator)
override;

/**
* \brief Gets any errors in the class
*
* Gets any formatting errors in the class
* \return Returns a std::vector<std::string> containing the errors
*/
virtual std::vector<std::string> geterrors() override;

/**
* \brief stationInfo site
*
* A required detectionformats::site containing the site for this stationInfo
* message
*/
detectionformats::site site;

/**
* \brief latitude value
*
* A required double defining the latitude of this stationInfo
*/
double latitude;

/**
* \brief longitude value
*
* A required double defining the longitude of this stationInfo
*/
double longitude;

/**
* \brief elevation value
*
* A required double containing the elevation for this stationInfo
*/
double elevation;

/**
* \brief quality value
*
* An optional double containing the quality for this stationInfo
*/
double quality;

/**
* \brief quality value
*
* An optional bool containing the enable flag for this stationInfo
*/
bool enable;

/**
* \brief use for teleseismic value
*
* An optional bool containing the use for teleseismic flag for this stationInfo
*/
bool useforteleseismic;

protected:

};
}
#endif
6 changes: 3 additions & 3 deletions cpp/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
#define DETECTIONEXTENSION "jsondetect"
#define RETRACTEXTENSION "jsonrtct"
#define PICKEXTENSION "jsonpick"
#define BEAMEXTENSION "jsonbeam"
#define CORRELATIONEXTENSION "jsoncorl"
#define STATIONEXTENSION "jsonsta"

#define DETECTION_TYPE "Detection"
#define CORRELATION_TYPE "Correlation"
#define PICK_TYPE "Pick"
#define BEAM_TYPE "Beam"
#define RETRACT_TYPE "Retract"
#define STATION_TYPE "StationInfo"

/**
* @namespace detectionformats
Expand Down Expand Up @@ -85,7 +85,7 @@ namespace detectionformats
/**
* \brief detectionformats format types
*/
enum formattypes { picktype = 0, beamtype = 1, correlationtype = 2, detectiontype = 3, retracttype = 4, unknown = -1 };
enum formattypes { picktype = 0, correlationtype = 1, detectiontype = 2, retracttype = 3, stationtype = 4, unknown = -1 };

/**
* \brief detectionformats function to get the detection type for a provided json formatted string
Expand Down
Loading

0 comments on commit c2d80e2

Please sign in to comment.