aste-1x:/home/asteobs/envmon_www/weath_plt_1x.csh
#!/bin/tcsh -f
# a script to plot weather data within 5days, which are found in
# aste-1s:/cosmos3/aste/nro/log/weather/{20??,.}/weather_*_*.log*
# aste-1s:/cosmos3/aste/nro/log/ant/cabin/{20??,.}/cabin_*_*.log* YYYY/MM/DD HH:MM T_upper_cabin(degC) T_main_cabin(degC)
# aste-1s:/cosmos3/aste/nro/log/radiometer/{20??,.}*.tau*: HHMMSS tau
# aste-1s:/cosmos3/aste/nro/log/rx/sisrx/sisrx_*_*.log YYYY/MM/DD HH:MM 1-4CH
# aste-1s:/cosmos3/aste/nro/log/ant/antlog_*.log YYYY/MM/DD HH:MM:SS Az El
# aste-1s:/cosmos3/aste/nro/log/genset/gen_*.log YYYY/MM/DD HH:MM:SS ? ? ? ? ? ? V Hz ? ? ? ? ?
#
# 2010/06/16 Original by Tai Oshima
# 2010/07/29 mod by Tai Oshima
# 2011/05/25 mod by Takashi Tsukagoshi added subref
# 2011/10/28 mod by Tai Oshima to deal with the missing weather data
# 2011/11/23 mod by Tai Oshima added cabin temperature, genset status
#
set thisfile = $0:t
set DATADIR10 = /cosmos3/aste/nro/log/weather
set DATADIR11 = /cosmos3/aste/nro/log/ant/cabin
set DATADIR20 = /cosmos3/aste/nro/log/radiometer
set DATADIR30 = /cosmos3/aste/nro/log/rx/sisrx
set DATADIR40 = /cosmos3/aste/nro/log/ant/antlog
set DATADIR50 = /cosmos3/aste/nro/log/genset
set OUTDIR = /home/asteobs/envmon_www
# data format of weather_*.log
#*1 : Date (GMT)
#*2 : Time (GMT)
#*3 : Temperature (Room) [C]
#*4 : Humidity (Room)
#*5 : Temperature (Outside) [C]
#*6 : Humidity (Outside)
#*7 : Solar Radiation
#*8 : Rainfall
#*9 : Pressure [hPa]
#*10 : Wind Velocity [m/s]
#*11 : Wind Direction [degree]
#*12 : ???
#*13 : ???
# init
set days = 1
set eopt = 0
set edate = ""
set etime = ""
set sopt = 0
set sdate = ""
set stime = ""
#set pngopt = 'size 320,240 medium'
set pngopt = ''
# get options
while (1)
switch ( $1:q )
case -h:
echo "$thisfile"
echo "generates a weather data plot within 24hrs"
echo "-days ? : plots ? days data"
echo "-e enddate endtime"
echo "-s startdate starttime"
echo " ex. -e 2010/01/02 00:00"
echo " ex. -s 2010/01/01 00:00"
echo " will both plot 2010/01/01 00:00 to 2010/01/02 00:00"
echo " if both -e and -s are given the time frame will be"
echo " startdate starttime to enddate endtime"
exit
case -days:
set days = $2:q
shift;shift
breaksw
case -e:
if ($3 == "") then
echo "specify both YYYY/MM/DD and HH:MM"
exit
endif
set eopt = 1
set edate = $2:q
set etime = $3:q
shift; shift; shift
breaksw
case -s:
if ($3 == "") then
echo "specify both YYYY/MM/DD and HH:MM"
exit
endif
set sopt = 1
set sdate = $2:q
set stime = $3:q
shift; shift; shift
breaksw
default
break
endsw
end
# filenames
set img1 = EnvTemp${days}day.png
set img2 = EnvHumi${days}day.png
set img3 = EnvPres${days}day.png
set img4 = EnvWind${days}day.png
set img5 = EnvTau${days}day.png
set img6 = EnvTscd${days}day.png
set img7 = EnvAnt${days}day.png
set img8 = EnvGen${days}day.png
set log10 = weath_current.tmp
set log11 = cabin_current.tmp
set log20 = tau_current.tmp
set log30 = sis_current.tmp
set log40 = ant_current.tmp
set log50 = gen_current.tmp
# get date and time
# default: endtime=now
set now = `date -u +"%Y/%m/%d %H:%M"`
# if endtime is given (time span = 5days fixed)
if($eopt) set now = `echo ${edate} ${etime}`
set date1 = `date -u +"%Y/%m/%d %H:%M" --date "${now} $days days ago"`
set date2 = `date -u +"%Y/%m/%d %H:%M" --date "${now}"`
# if starttime is given (time span = 5days fixed)
if ($sopt) then
set now = `echo ${sdate} ${stime}`
set date1 = `date -u +"%Y/%m/%d %H:%M" --date "${now}"`
set date2 = `date -u +"%Y/%m/%d %H:%M" --date "${now} $days days"`
endif
set year = `date -u +"%Y" --date "${now}"`
# if both starttime and endtime is given
if ($eopt && $sopt) then
set date1 = `echo $sdate $stime`
set date2 = `echo $edate $etime`
endif
# initialize logs
cd $OUTDIR
foreach id (10 11 20 30 40 50)
set log = (`eval echo \$log{$id}`)
rm -f $log
touch $log
end
# get current ?days data + calculation of dew point temperature
@ d = $days
while ($d >= 0)
set date = `date -u +"%Y/%m/%d %H:%M" --date "${date2} $d days ago"`
# weather
# gnuplot will ignore non numeric data such as "---"
set root = `echo weather_${date[1]}|sed 's/\///g'`
set id = 10
set LOG = (`eval echo \$log{$id}`)
set DIR = (`eval echo \$DATADIR{$id}`)
foreach ext (log log.gz )
set file = "${DIR}/{${year},.}/${root}*.${ext}"
echo "$file"
if (`ls $file` != "") then
foreach log ($file)
zcat -f $log | awk '($5<=-50){$5="---"}($6<=0){$6="---"}($10<=0){$10="---"}{g=a*$5/(b+$5)+log($6/100);$7=b*g/(a-g);print}' a=17.271 b=237.7 >> $LOG
echo "" >> $LOG
end
endif
end
# cabin temp
set root = `echo cabin_${date[1]}|sed 's/\///g'`
set id = 11
set LOG = (`eval echo \$log{$id}`)
set DIR = (`eval echo \$DATADIR{$id}`)
foreach ext (log log.gz )
set file = "${DIR}/{${year},.}/${root}*.${ext}"
echo "$file"
if (`ls $file` != "") then
foreach log ($file)
zcat -f $log | tr -s '\n' | awk '{print $1,$2,$3,$4}' >> $LOG
echo "" >> $LOG
end
endif
end
# tau
set root = `echo ${date[1]}.tau|sed 's/\///g;s/^20//'`
set id = 20
set LOG = (`eval echo \$log{$id}`)
set DIR = (`eval echo \$DATADIR{$id}`)
foreach ext (log log.gz )
set file = "${DIR}/{${year},.}/${root}*.${ext}"
echo "$file"
if (`ls $file` != "") then
foreach log ($file)
zcat -f $log | awk '($2-mm>3){printf "\n"}{print date,$1":"$2":"$3,$4;mm=$2}' date=$date[1] >> $LOG
echo "" >> $LOG
end
endif
end
# SCD temperature
set root = `echo sisrx_${date[1]}|sed 's/\///g'`
set id = 30
set LOG = (`eval echo \$log{$id}`)
set DIR = (`eval echo \$DATADIR{$id}`)
foreach ext (log log.gz )
set file = "${DIR}/{${year},.}/${root}*.${ext}"
echo "$file"
if (`ls $file` != "") then
foreach log ($file)
zcat -f $log | awk '{print $1,$2,$3,$4,$5,$6}' >> $LOG
echo "" >> $LOG
end
endif
end
# Antenna log
set root = `echo ant_${date[1]}|sed 's/\///g'`
set id = 40
set LOG = (`eval echo \$log{$id}`)
set DIR = (`eval echo \$DATADIR{$id}`)
foreach ext (log log.gz )
set file = "${DIR}/{${year},.}/${root}*.${ext}"
echo "$file"
if (`ls $file` != "") then
foreach log ($file)
zcat -f $log | awk '{print $1,$2,$4,$5,$10,$11,$12,$13,$14,$15}' |sed 's/:.. / /' |grep "$date[1]" >> $LOG
echo "" >> $LOG
end
endif
end
# genset V, Hz
set root = `echo gen_${date[1]}|sed 's/\///g'`
set id = 50
set LOG = (`eval echo \$log{$id}`)
set DIR = (`eval echo \$DATADIR{$id}`)
foreach ext (log log.gz )
set file = "${DIR}/{${year},.}/${root}*.${ext}"
echo "$file"
if (`ls $file` != "") then
foreach log ($file)
zcat -f $log | tr -s '\n' | awk '{print $1,$2,$9,$10}' >> $LOG
echo "" >> $LOG
end
endif
end
@ d --
end
# make plots with gnuplot
# weather data
if (! -s $log10) then
echo "weather data not found for specified time frame."
else
gnuplot <<EOF
set xdata time
set xlabel "UTC" 0.0,-1.0
set timefmt "%Y/%m/%d %H:%M"
set xrange ['${date1}':'${date2}']
set bmargin 4
set lmargin 10
set grid
set mytics 5
# Temp.
set term png $pngopt
set output '$img1'
set yrange [-30:40]
set ylabel "Temperature [C]"
plot '$log10' using 1:3 t "Obs. Room Temp." w l, \
'$log10' using 1:5 t "Outside Temp." w l, \
'$log10' using 1:7 t "Dew Point Temp." w l, \
'$log11' using 1:3 t "UpperCabin Temp." w l, \
'$log11' using 1:4 t " MainCabin Temp." w l
## Humid.
#set output '$img2'
#set yrange [0:100]
#set ylabel "Humidity [%]"
#plot '$log10' using 1:4 t "Room Humid." w l, \
# '$log10' using 1:6 t "Outside Humid." w l
# Pressure, Humidity, rain
set term png $pngopt
set output '$img3'
set multiplot
set size 1,0.25
set origin 0.0,0.0
set bmargin 4
set tmargin 0
set yrange [0:0.117]
set ylabel "Rain [mm]"
plot '$log10' using 1:8 t "Rain" w l
set origin 0.0,0.25
set size 1,0.35
set bmargin 0
set tmargin 0
set yrange [0:100]
set ylabel "Humidity [%]"
set format x ""
set xlabel ""
plot '$log10' using 1:4 t "Obs. Room Humid." w l, \
'$log10' using 1:6 t "Outside Humid." w l
set size 1,0.4
set origin 0.0,0.6
set bmargin 0
set tmargin 1
set format x ""
set xlabel ""
set yrange [557.5:580]
set ylabel "Pressure [hPa]"
plot '$log10' using 1:9 t "Press." w l
set nomultiplot
EOF
gnuplot <<EOF
set xdata time
set xlabel "UTC" 0.0,-1.0
set timefmt "%Y/%m/%d %H:%M"
set xrange ['${date1}':'${date2}']
set bmargin 4
set lmargin 10
set grid
# Wind
set term png $pngopt
set output '$img4'
set multiplot
set size 1,0.3
set origin 0.0,0.0
set bmargin 4
set tmargin 0
set ytics 90
set mytics 3
set yrange [0:360]
set ylabel "WindDir. [deg]"
set xlabel "UTC" 0.0,-1.0
plot '$log10' using 1:11 t "Dir" w l
set size 1,0.7
set origin 0.0,0.3
set bmargin 0
set tmargin 1
set format x ""
set xlabel ""
set ytics 0,5
set mytics 5
set yrange [0:35]
set ylabel "WindSp. [m/s]"
plot '$log10' using 1:10 t "Speed" w l
set nomultiplot
EOF
endif
# tau
if (! -s $log20) then
echo "tau data not found for specified time frame."
else
gnuplot <<EOF
set xdata time
set xlabel "UTC" 0.0,-1.0
set timefmt "%Y/%m/%d %H:%M"
set xrange ['${date1}':'${date2}']
set bmargin 4
set lmargin 10
set grid
# tau220GHz
set term png $pngopt
set output '$img5'
set yrange [0:0.25]
set ylabel "tau220GHz"
plot '$log20' using 1:3 t "tau220GHz" w l
EOF
endif
# SCD temperature
if (! -s $log30) then
echo "SCD temperature data not found for specified time frame."
else
gnuplot <<EOF
set xdata time
set xlabel "UTC" 0.0,-1.0
set timefmt "%Y/%m/%d %H:%M"
set xrange ['${date1}':'${date2}']
set bmargin 4
set lmargin 10
set grid
# SCD Temperature
set term png $pngopt
set output '$img6'
set yrange [1:300]
set ylabel "SCD Temperature[K]"
set log y
plot '$log30' using 1:3 t "CH1" w l,\
'$log30' using 1:4 t "CH2" w l,\
'$log30' using 1:5 t "CH3" w l,\
'$log30' using 1:6 t "CH4" w l
EOF
endif
# Az, El
if (! -s $log40) then
echo "Az, El data not found for specified time frame."
else
gnuplot <<EOF
set xdata time
set xlabel "UTC" 0.0,-1.0
set timefmt "%Y/%m/%d %H:%M"
set xrange ['${date1}':'${date2}']
set bmargin 4
set lmargin 10
set grid
# Az, El, Subref
set term png $pngopt
set output '$img7'
set multiplot
set size 1,0.3
set origin 0.0,0.0
set bmargin 4
set tmargin 0
set yrange [-0.5:0.5]
set ylabel "SRef theta"
plot '$log40' using 1:8 t "X theta" w l,\
'$log40' using 1:9 t "Y theta" w l,\
'$log40' using 1:10 t "Z theta" w l
set origin 0,0.3
set size 1,0.25
set bmargin 0
set tmargin 0
set format x ""
set xlabel ""
set yrange [-10:10]
set ylabel "SRef pos[mm]"
plot '$log40' using 1:5 t "X" w l,\
'$log40' using 1:6 t "Y" w l,\
'$log40' using 1:7 t "Z" w l
set origin 0,0.55
set size 1,0.45
set bmargin 0
set tmargin 1
set format x ""
set xlabel ""
set ytics 90
set mytics 3
set yrange [-270:270]
set ylabel "Az, El [deg]"
plot '$log40' using 1:3 t "Az" w l,\
'$log40' using 1:4 t "El" w l
set nomultiplot
EOF
endif
# genset data
if (! -s $log50) then
echo "genset data not found for specified time frame."
else
gnuplot <<EOF
set xdata time
set xlabel "UTC" 0.0,-1.0
set timefmt "%Y/%m/%d %H:%M"
set xrange ['${date1}':'${date2}']
set bmargin 4
set lmargin 10
set grid
# genset
set term png $pngopt
set output '$img8'
set multiplot
set size 1,0.3
set origin 0.0,0.0
set bmargin 4
set tmargin 0
set mytics 2
set yrange [55:65]
set ylabel "Freq. [Hz]"
set xlabel "UTC" 0.0,-1.0
plot '$log50' using 1:4 t "Freq." w l
set size 1,0.7
set origin 0.0,0.3
set bmargin 0
set tmargin 1
set mytics 5
set format x ""
set xlabel ""
set yrange [90:125]
set ylabel "Volt. [V]"
plot '$log50' using 1:3 t "Volt." w l
set nomultiplot
EOF
endif
# delete temporary files
#rm -f *.tmp
exit