Ignore:
Timestamp:
01/08/19 14:28:21 (6 years ago)
Author:
Daniela Dorner
Message:
added comments and functionality to fill only corrected R750 and not reference values
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/Tools/fill_r750.sh

    r19422 r19424  
    11#!/bin/bash
    22
     3# setup
    34sqlpw=/home/$USER/.mysql.pw.op
    45dbname=factdata
     6# fill only corrected R750
     7short="yes" # comment line to fill also reference values
     8
     9# setup for zd- and th-correction:
     10zd="cos(fZenithDistanceMean/180*Pi())"
     11min="TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn/60"
     12cor="pow("$zd", 1.94)*exp((1-1/"$zd")*0.331)*exp(2.39*(1-"$zd"))"
     13
     14# fill corrected R750
     15echo ""
     16echo "Filling the corrected R750 to the DB..."
     17query="UPDATE RunInfo SET "
     18query=$query" fR750Cor=round(fNumThreshold750/("$min")/("$cor"),2) "
     19query=$query" WHERE fRunTypeKey=1 AND NOT (("$min")/("$cor"))=0"
     20echo $query
     21mysql --defaults-file=$sqlpw -s -e "$query"
     22
     23# todo: replace this by trigger in DB (finalize correction formula for this)
     24
     25if [ "$short" == "yes" ]
     26then
     27   echo ""
     28   echo "Exit (short=yes)"
     29   exit
     30fi
     31
    532
    633# reference values for corrected R750
     
    97124       )
    98125
     126# fill reference values
     127echo ""
     128echo "Filling the reference values for the corrected R750 for "${#rates[@]}" periods to the DB..."
    99129for (( i=0; i < ${#rates[@]} ; i++))
    100130do
     
    106136   fi
    107137   query="UPDATE RunInfo SET fR750Ref="$rate" WHERE fPeriod="$i
    108    echo $query
     138   #echo $query
    109139   mysql --defaults-file=$sqlpw -u operator -h 10.0.100.21 $dbname -s -e "$query"
    110140done
    111141
    112142# several periods are split:
     143#   update the values for those
    113144# 71b
    114145query="UPDATE RunInfo SET fR750Ref=250.0 WHERE fPeriod=71 AND fNight>20170726"
     
    127158mysql --defaults-file=$sqlpw -s -e "$query"
    128159
    129 zd="cos(fZenithDistanceMean/180*Pi())"
    130 min="TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn/60"
    131 cor="pow("$zd", 1.94)*exp((1-1/"$zd")*0.331)*exp(2.39*(1-"$zd"))"
    132160
    133 # fill corrected R750
    134 query="UPDATE RunInfo SET "
    135 query=$query" fR750Cor=round(fNumThreshold750/("$min")/("$cor"),2) "
    136 query=$query" WHERE fRunTypeKey=1 AND NOT (("$min")/("$cor"))=0"
    137 echo $query
    138 mysql --defaults-file=$sqlpw -s -e "$query"
     161echo ""
     162echo "Done"
    139163
Note: See TracChangeset for help on using the changeset viewer.