Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
software/JAcoustics/JSeabed.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <vector>
5 
6 #include "JDetector/JTripod.hh"
7 #include "JDetector/JDetector.hh"
9 
10 #include "JSupport/JMeta.hh"
11 
12 #include "Jeep/JContainer.hh"
13 #include "Jeep/JParser.hh"
14 #include "Jeep/JMessage.hh"
15 
16 
17 /**
18  * \file
19  * Auxiliary application to apply tilt angles to seabed.
20  * \author mdejong
21  */
22 int main(int argc, char **argv)
23 {
24  using namespace std;
25  using namespace JPP;
26 
27  typedef JContainer< vector<JTripod> > tripods_container;
28 
29  string detectorFile;
30  string tripodsFile;
31  double Tx;
32  double Ty;
33  int debug;
34 
35  try {
36 
37  JParser<> zap("Auxiliary application to apply tilt angles to seabed.");
38 
39  zap['a'] = make_field(detectorFile, "detector file.");
40  zap['T'] = make_field(tripodsFile, "tripods file.");
41  zap['x'] = make_field(Tx, "tilt angle x-z [rad]");
42  zap['y'] = make_field(Ty, "tilt angle y-z [rad]");
43  zap['d'] = make_field(debug) = 1;
44 
45  zap(argc, argv);
46  }
47  catch(const exception& error) {
48  FATAL(error.what() << endl);
49  }
50 
51 
53 
54  try {
55  tripods.load(tripodsFile.c_str());
56  }
57  catch(const exception& error) {
58  FATAL(error.what() << endl);
59  }
60 
61 
62  JDetector detector;
63 
64  try {
65  load(detectorFile, detector);
66  }
67  catch(const exception& error) {
68  FATAL(error.what() << endl);
69  }
70 
71 
72  JUTMPosition pos = detector.getUTMPosition();
73 
74  if (!tripods.empty()) {
75 
76  pos = JUTMPosition(0.0, 0.0, 0.0);
77 
78  for (tripods_container::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
79  pos += i->getUTMPosition();
80  }
81 
82  pos /= tripods.size();
83  }
84 
85 
86  detector.comment.add(JMeta(argc, argv));
87 
88  for (JDetector::iterator i = detector.begin(); i != detector.end(); ++i) {
89 
90  const double dz = Tx * (i->getX() + detector.getX() - pos.getX()) + Ty * (i->getY() + detector.getY() - pos.getY());
91 
92  *i += JPosition3D(0.0, 0.0, dz);
93  }
94 
95  store(detectorFile, detector);
96 
97 
98  tripods.comment.add(JMeta(argc, argv));
99 
100  for (tripods_container::iterator i = tripods.begin(); i != tripods.end(); ++i) {
101 
102  const double dz = Tx * (i->getX() - pos.getX()) + Ty * (i->getY() - pos.getY());
103 
104  *i += JUTMPosition(0.0, 0.0, dz);
105  }
106 
107  tripods.store(tripodsFile.c_str());
108 
109  return 0;
110 }
Utility class to parse command line options.
Definition: JParser.hh:1711
int main(int argc, char *argv[])
Definition: Main.cc:15
then fatal Number of tripods
Definition: JFootprint.sh:45
Data structure for detector geometry and calibration.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
ROOT I/O of application specific meta data.
JContainer< std::vector< JTripod > > tripods_container
Definition: JSydney.cc:78
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
do set_variable DETECTOR_TXT $WORKDIR detector
Data structure for tripod.
Container I/O.
int debug
debug level