Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getMIIseacurrent.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 # Script to request and transform data from the MII instrumented line.
5 # 1 - a request is formed to the DB storing the data. The order of the fields is
6 # fixed and must stay the same for the next steps :
7 # time, current speed, error on current speed, current direction, error on current direction
8 # A given period can be specified by providing two strings of the form 2019-05-01T12:00:00Z
9 # The data are written into a ASC file (csv text file).
10 # 2 - The awk program splits the file in two separated text files with the header dropped for the
11 # moment. The angles are converted from degrees with 0 at North and counting clockwise into
12 # radians with 0 at East and counting anticlockwise. They are not further reduded to [-pi,+pi]
13 # to keep a continuity of values (the current is often directed toward West)
14 
15 if [ -z $JPP_DIR ]; then
16  echo "Variable JPP_DIR undefined."
17  exit
18 fi
19 
20 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
21 
23 set_variable DIR $JPP_DIR/examples/JAcoustics/
25 
26 set_variable MII_ASC $WORKDIR/MII.asc
27 set_variable CurSpeed_TXT $WORKDIR/MII_CurrentSpeed.txt
28 set_variable CurSpeed_ROOT $WORKDIR/MII_CurrentSpeed.root
29 set_variable CurSpeed_GIF $WORKDIR/MII_CurrentSpeed.gif
30 set_variable CurDirec_TXT $WORKDIR/MII_CurrentDirection.txt
31 set_variable CurDirec_ROOT $WORKDIR/MII_CurrentDirection.root
32 set_variable CurDirec_GIF $WORKDIR/MII_CurrentDirection.gif
33 
34 if ( do_usage $* ); then
35  usage "$script <tmin> <tmax> or"\
36  "\n$script clean" \
37  "\nwhere <tmin> and <tmax> are strings of the form 2019-05-01T12:00:00Z" \
38  "\nand clean will remove the output file" \
39  "\n" \
40  "\nScript to request sea current data from the erddap.osupytheas.fr database." \
41  "\nthe validity of the datetimes is not checked by the script."
42 fi
43 
44 case $# in
46  2) set_variable TMAX $argv[2];
47  set_variable TMIN $argv[1];;
48  *) fatal "Wrong number of arguments.";;
49 esac
50 
51 function clean()
52 {
53  rm -f $MII_ASC
54  rm -f $CurSpeed_TXT
55  rm -f $CurDirec_TXT
56  rm -f $CurSpeed_ROOT
57  rm -f $CurDirec_ROOT
58  rm -f $CurSpeed_GIF
59  rm -f $CurDirec_GIF
60  exit
61 }
62 case "$OPTION" in
64  "") ;;
65  *) fatal "Wrong option $OPTION.";;
66 esac
67 
68 
69 if [[ -n "$TMIN" && -n "$TMAX" ]]; then
70  uTMIN=`date -d $TMIN +%s --utc`
71  uTMAX=`date -d $TMAX +%s --utc`
72  echo "Obtaining sea current speed and direction between" $TMIN "("$uTMIN") and" $TMAX "("$uTMAX")"
73  wget -O $MII_ASC "https://erddap.osupytheas.fr/erddap/tabledap/Emso_Aquadopp_64c7_8059_4af9.asc?time,Speed_mean,Speed_std,Direction_mean,Direction_std&time>=$uTMIN&time<=$uTMAX"
74 fi
75 # The ASC use the comma as separator. We split the file in two simple "space separated text files.
76 # One for the strength of the sea current. One for the direction of the sea current.
77 # The direction value are converted from deg to rad and inverted from clockwise to anticlockwise
78 # The header is dropped for the moment since it has to be correctly handled using awk command.
79 # It has currently 11 lines. A smarter way of handling the header and the fields must be found.
80 
81 if [[ -f $MII_ASC ]]; then
82  awk -F',' '{if ( NR>11 ) {print $1 " " $2 " " $3;};}' $MII_ASC > $CurSpeed_TXT
83  awk -F',' '{if ( NR>11 ) {print $1 " " (90.0 - $4)/57.2958 " " $5/57.2958 ;}}' $MII_ASC > $CurDirec_TXT
84 fi
85 if [[ -f $CurSpeed_TXT ]]; then
86  JGraph \
87  -f $CurSpeed_TXT \
89 
90  JPlot1D \
91  -f $CurSpeed_ROOT:\.\* \
92  -w 2000x500 \
93  -t "$TIMESTAMP" \
94  -\> "Date" \
95  -\^ "Current speed [m.s-1]" \
96  -T "Sea current speed at ORCA site " \
97  -o $CurSpeed_GIF
98 fi
99 if [[ -f $CurDirec_TXT ]]; then
100  JGraph \
101  -f $CurDirec_TXT \
102  -o $CurDirec_ROOT
103 
104  JPlot1D \
105  -f $CurDirec_ROOT:\.\* \
106  -w 2000x500 \
107  -t "$TIMESTAMP" \
108  -\> "Date" \
109  -\^ "Current direction [rad]" \
110  -T "Sea current direction at ORCA site " \
111  -o $CurDirec_GIF
112 fi
data_type w[N+1][M+1]
Definition: JPolint.hh:741
void set_variable(const std::string &name, const std::string &value)
Set environment variable.
exit
Definition: JPizza.sh:36
do set_array DAQHEADER JPrintDAQHeader f
Definition: JTuneHV.sh:74
do echo Generating $dir eval DIR
Definition: JPlotNPE1D.sh:52
then uTMIN
then echo
case $OPTION in clean clean
do set_variable OUTPUT_DIRECTORY $WORKDIR T
do $DIR JTransitTime o
Definition: JTransitTime.sh:44
then awk F
* usage
*set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2,-2] set_variable OUTPUT_FILE $argv[-1]
Definition: JDomino.sh:39
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:45
alias put_queue eval echo n
Definition: qlib.csh:19
then display $WORKDIR
Definition: plot-Domino.sh:127
then usage $script< detector >< run >< outputfile > fi case set_variable OPTION
Definition: JTuna.sh:26
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
script
Definition: JAcoustics.sh:2
then awk $MII_ASC $CurSpeed_TXT awk then JGraph f $CurSpeed_TXT o $CurSpeed_ROOT JPlot1D f $CurSpeed_ROOT
then usage $script< detector file >< inputfile > fi case set_variable WORKDIR
Definition: JLegolas.sh:28
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62