Jpp  18.0.1-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
UNESCO.cc File Reference

Example program to plot UNESCO sound velocity. More...

#include <iostream>
#include <iomanip>
#include <string>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.h"
#include "JAcoustics/JUNESCO.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to plot UNESCO sound velocity.

Author
mdejong

Definition in file UNESCO.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file UNESCO.cc.

22 {
23  using namespace std;
24  using namespace JPP;
25 
26  string outputFile;
27  double D;
28  double S;
29  double T;
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Example program to plot UNESCO sound velocity.");
35 
36  zap['o'] = make_field(outputFile);
37  zap['D'] = make_field(D, "Depth [m]");
38  zap['S'] = make_field(S, "Salinity [ppk]") = 25.0;
39  zap['T'] = make_field(T, "Temperature [C]") = 14.3;
40  zap['d'] = make_field(debug) = 2;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48 
49  TFile out(outputFile.c_str(), "recreate");
50 
51  TH1D h1("h1", NULL, 1000, 0.0, 3500);
52  TH2D h2("h2", NULL, 1000, 10.0, 20.0, 1000, 25.0, 40.0);
53 
54  for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
55 
56  const Double_t D = h1.GetXaxis()->GetBinCenter(ix);
57  const double V = getVelocity(D, S, T);
58 
59  h1.SetBinContent(ix, V);
60  }
61 
62  for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
63  for (Int_t iy = 1; iy <= h2.GetXaxis()->GetNbins(); ++iy) {
64 
65  const Double_t T = h2.GetXaxis()->GetBinCenter(ix);
66  const Double_t S = h2.GetYaxis()->GetBinCenter(iy);
67 
68  const double V = getVelocity(D, S, T);
69  //const double vs = getVelocity(D, S, T) - getVelocity(D + 1, S, T);
70 
71  h2.SetBinContent(ix, iy, V);
72  }
73  }
74 
75  out.Write();
76  out.Close();
77 }
Utility class to parse command line options.
Definition: JParser.hh:1514
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
do set_variable OUTPUT_DIRECTORY $WORKDIR T
#define FATAL(A)
Definition: JMessage.hh:67
double getVelocity(const double D, const double S, const double T)
Get sound velocity according UNESCO equation.
Definition: JUNESCO.hh:23
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
int debug
debug level