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/weather_*_*.log
# aste-1s:/cosmos3/aste/nro/log/weather/2010/weather_*_*.log.gz
# /cosmos3/aste/nro/log/radiometer/*.tau: HHMMSS tau
# /cosmos3/aste/nro/log/radiometer/2010/*.tau.gz
# /cosmos3/aste/nro/log/rx/sisrx/sisrx_*_*.log YYYY/MM/DD HH:MM 1-4CH
# /cosmos3/aste/nro/log/ant/antlog_*.log YYYY/MM/DD HH:MM:SS Az El
#
# 2010/06/16 Original by Tai Oshima
# 2010/07/29 mod by Tai Oshima
#
set thisfile = $0:t
set DATADIR1 = /cosmos3/aste/nro/log/weather
set DATADIR2 = /cosmos3/aste/nro/log/radiometer
set DATADIR3 = /cosmos3/aste/nro/log/rx/sisrx
set DATADIR4 = /cosmos3/aste/nro/log/ant/antlog
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 log1 = weath_current.log
set log2 = tau_current.log
set log3 = sis_current.log
set log4 = ant_current.log
# 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
# get current ?days data + calculation of dew point temperature
cd $OUTDIR
rm -f $log1 $log2 $log3 $log4
touch $log1
touch $log2
touch $log3
touch $log4
@ d = $days
while ($d >= 0)
set date = `date -u +"%Y/%m/%d %H:%M" --date "${date2} $d days ago"`
# weather
set dat1 = `echo weather_${date[1]}|sed 's/\///g'`
if (`ls $DATADIR1/${year}/${dat1}_*.log.gz` != "") then
foreach log ($DATADIR1/${year}/${dat1}_*.log.gz)
zcat $log | awk '{if($5>-50 && $6>0 && $10>0){g=a*$5/(b+$5)+log($6/100);Td=b*g/(a-g);print $1,$2,$3,$4,$5,$6,Td,$8,$9,$10,$11}else{printf "\n"}}' a=17.271 b=237.7 >> $log1
echo "" >> $log1
end
endif
if (`ls $DATADIR1/${dat1}_*.log` != "") then
foreach log ($DATADIR1/${dat1}_*.log)
cat $log | awk '{if($5>-50 && $6>0 && $10>0){g=a*$5/(b+$5)+log($6/100);Td=b*g/(a-g);print $1,$2,$3,$4,$5,$6,Td,$8,$9,$10,$11}else{printf "\n"}}' a=17.271 b=237.7 >> $log1
echo "" >> $log1
end
endif
# tau
set dat2 = `echo ${date[1]}.tau|sed 's/\///g;s/^20//'`
if (`ls $DATADIR2/${year}/${dat2}.gz` != "") then
foreach log ($DATADIR2/${year}/${dat2}.gz)
zcat $log | awk '($2-mm>3){printf "\n"}{print date,$1":"$2":"$3,$4;mm=$2}' date=$date[1] >> $log2
echo "" >> $log2
end
endif
if (`ls $DATADIR2/${dat2}` != "") then
foreach log ($DATADIR2/${dat2})
cat $log | awk '($2-mm>3){printf "\n"}{print date,$1":"$2":"$3,$4;mm=$2}' date=$date[1] >> $log2
echo "" >> $log2
end
endif
# SCD temperature
set dat3 = `echo sisrx_${date[1]}|sed 's/\///g'`
if (`ls $DATADIR3/${dat3}_*.log` != "") then
foreach log ($DATADIR3/${dat3}_*.log)
cat $log | awk '{print $1,$2,$3,$4,$5,$6}' >> $log3
echo "" >> $log3
end
endif
# Antenna log
set dat4 = `echo ant_${date[1]}|sed 's/\///g'`
if (`ls $DATADIR4/${year}/${dat4}*.log.gz` != "") then
foreach log ($DATADIR4/${year}/${dat4}*.log.gz)
zcat $log | awk '{print $1,$2,$4,$5,$10,$11,$12,$13,$14,$15}' |sed 's/:.. / /' |grep "$date[1]" >> $log4
echo "" >> $log4
end
endif
if (`ls $DATADIR4/${dat4}*.log` != "") then
foreach log ($DATADIR4/${dat4}*.log)
cat $log | awk '{print $1,$2,$4,$5,$10,$11,$12,$13,$14,$15}' |sed 's/:.. / /' |grep "$date[1]" >> $log4
echo "" >> $log4
end
endif
@ d --
end
# make plots with gnuplot
# weather data
if (! -s $log1) 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
# Temp.
set term png $pngopt
set output '$img1'
set yrange [-30:40]
set ylabel "Temperature [C]"
plot '$log1' using 1:3 t "Obs. Room Temp." w l, \
'$log1' using 1:5 t "Outside Temp." w l, \
'$log1' using 1:7 t "Dew Point Temp." w l
## Humid.
#set output '$img2'
#set yrange [0:100]
#set ylabel "Humidity [%]"
#plot '$log1' using 1:4 t "Room Humid." w l, \
#'$log1' 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 '$log1' 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 '$log1' using 1:4 t "Obs. Room Humid." w l, \
'$log1' 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 '$log1' 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 '$log1' 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 yrange [0:35]
set ylabel "WindSp. [m/s]"
plot '$log1' using 1:10 t "Speed" w l
set nomultiplot
EOF
endif
# tau
if (! -s $log2) 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 '$log2' using 1:3 t "tau220GHz" w l
EOF
endif
# SCD temperature
if (! -s $log3) 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 '$log3' using 1:3 t "CH1" w l,\
'$log3' using 1:4 t "CH2" w l,\
'$log3' using 1:5 t "CH3" w l,\
'$log3' using 1:6 t "CH4" w l
EOF
endif
# Az, El
if (! -s $log4) 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 '$log4' using 1:8 t "X theta" w l,\
'$log4' using 1:9 t "Y theta" w l,\
'$log4' 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 '$log4' using 1:5 t "X" w l,\
'$log4' using 1:6 t "Y" w l,\
'$log4' 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 '$log4' using 1:3 t "Az" w l,\
'$log4' using 1:4 t "El" w l
set nomultiplot
EOF
endif
rm -f $log1 $log2 $log3 $log4
exit