#/usr/bin


set timewindow = "2016-10-20T23:54/2016-11-16T23:59"
#set timewindow = "2016-10-20T23:54/2016-10-26T23:59"

# hobo pressure xy plot
sed 's/,/ /g' hobos/10-20-2016-PH-TSFC.csv | sed 's/\// /g' | sed 's/:/ /g' | awk '{ if (($8=="AM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9; if (($8=="AM") && ($5 >= 12))print $4+2000"-"$2"-"$3"T"$5-12":"$6":"$7, $9; if (($8=="PM") && ($5 >= 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9;  if (($8=="PM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5+12":"$6":"$7, $9}' >! testx
psxy testx -R$timewindow/5/25 -JX6i/1.5i -Ba1/a5E -W4/blue -K -P >! plot_PH.ps 

# NOAA water level xy plot
sed 's/,/ /g' env_data/CO-OPS__8452660_2__wl.csv | awk '{if (NF == 9) print $1"T"$2, $3}' >! test
psxy test -R$timewindow/-1/2 -J -Ba1WSn -W4 -K -O >> plot_PH.ps 



# hobo pressure xy plot
sed 's/,/ /g' hobos/10-20-2016-PH-PTBTM.csv | sed 's/\// /g' | sed 's/:/ /g' | awk '{ if (($8=="AM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9; if (($8=="AM") && ($5 >= 12))print $4+2000"-"$2"-"$3"T"$5-12":"$6":"$7, $9; if (($8=="PM") && ($5 >= 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9;  if (($8=="PM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5+12":"$6":"$7, $9}' >! teste
psxy teste -R$timewindow/100/130 -J -Ba1/a5E -W4/red -K -O -Y1.5i>> plot_PH.ps 

# NOAA water level xy plot
sed 's/,/ /g' env_data/CO-OPS__8452660_2__wl.csv | awk '{if (NF == 9) print $1"T"$2, $3}' >! test
psxy test -R$timewindow/-1/2 -J -Ba1WSn -W4 -K -O >> plot_PH.ps 


# NOAA wind speed xy plot
sed 's/,/ /g' env_data/CO-OPS_8452660_from_20161020_to_20161116_met.csv | sed 's/\// /g'  | awk '{print $3"-"$1"-"$2"T"$4, $5}'>! testD
psxy testD -R$timewindow/0/40 -J -Ba10E -W4/green -K -O -Y1.5i >> plot_PH.ps 

# NOAA air temp xy plot
sed 's/,/ /g' env_data/CO-OPS_8452660_from_20161020_to_20161116_met.csv | sed 's/\// /g'  | awk '{print $3"-"$1"-"$2"T"$4, $8}' | awk '{ if (NF == 2) print $0}' >! testD
psxy testD -R$timewindow/0/70 -J -Ba10Wn -W4 -K -O >> plot_PH.ps 


# hobo pressure xy plot
sed 's/,/ /g' hobos/10-20-2016-PH-PTBTM.csv | sed 's/\// /g' | sed 's/:/ /g' | awk '{ if (($8=="AM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9; if (($8=="AM") && ($5 >= 12))print $4+2000"-"$2"-"$3"T"$5-12":"$6":"$7, $9; if (($8=="PM") && ($5 >= 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9;  if (($8=="PM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5+12":"$6":"$7, $9}' >! teste
psxy teste -R$timewindow/100/130 -J -Ba1/a5WeSn -W4/red -K -O -Y2.5i>> plot_PH.ps 

# hobo pressure xy plot
sed 's/,/ /g' hobos/10-20-2016-CR-PTBTM.csv | sed 's/\// /g' | sed 's/:/ /g' | awk '{ if (($8=="AM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9; if (($8=="AM") && ($5 >= 12))print $4+2000"-"$2"-"$3"T"$5-12":"$6":"$7, $9; if (($8=="PM") && ($5 >= 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9;  if (($8=="PM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5+12":"$6":"$7, $9}' >! teste
psxy teste -R$timewindow/100/130 -J  -W4/red -K -O >> plot_PH.ps 










# hobo pressure xy plot
sed 's/,/ /g' hobos/10-20-2016-CR-TSFC.csv | sed 's/\// /g' | sed 's/:/ /g' | awk '{ if (($8=="AM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9; if (($8=="AM") && ($5 >= 12))print $4+2000"-"$2"-"$3"T"$5-12":"$6":"$7, $9; if (($8=="PM") && ($5 >= 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9;  if (($8=="PM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5+12":"$6":"$7, $9}' >! testx
psxy testx -R$timewindow/5/25 -JX6i/1.5i -Ba1/a5E -W4/blue -K -P >! plot_CR.ps 

# NOAA water level xy plot
sed 's/,/ /g' env_data/CO-OPS__8452660_2__wl.csv | awk '{if (NF == 9) print $1"T"$2, $3}' >! test
psxy test -R$timewindow/-1/2 -J -Ba1WSn -W4 -K -O >> plot_CR.ps 



# hobo pressure xy plot
sed 's/,/ /g' hobos/10-20-2016-CR-PTBTM.csv | sed 's/\// /g' | sed 's/:/ /g' | awk '{ if (($8=="AM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9; if (($8=="AM") && ($5 >= 12))print $4+2000"-"$2"-"$3"T"$5-12":"$6":"$7, $9; if (($8=="PM") && ($5 >= 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9;  if (($8=="PM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5+12":"$6":"$7, $9}' >! teste
psxy teste -R$timewindow/100/130 -J -Ba1/a5E -W4/red -K -O -Y1.5i>> plot_CR.ps 

# NOAA water level xy plot
sed 's/,/ /g' env_data/CO-OPS__8452660_2__wl.csv | awk '{if (NF == 9) print $1"T"$2, $3}' >! test
psxy test -R$timewindow/-1/2 -J -Ba1WSn -W4 -K -O >> plot_CR.ps 


# NOAA wind speed xy plot
sed 's/,/ /g' env_data/CO-OPS_8452660_from_20161020_to_20161116_met.csv | sed 's/\// /g'  | awk '{print $3"-"$1"-"$2"T"$4, $5}'>! testD
psxy testD -R$timewindow/0/40 -J -Ba10E -W4/green -K -O -Y1.5i >> plot_CR.ps 

# NOAA air temp xy plot
sed 's/,/ /g' env_data/CO-OPS_8452660_from_20161020_to_20161116_met.csv | sed 's/\// /g'  | awk '{print $3"-"$1"-"$2"T"$4, $8}' | awk '{ if (NF == 2) print $0}' >! testD
psxy testD -R$timewindow/0/70 -J -Ba10Wn -W4 -K -O >> plot_CR.ps 

# hobo pressure xy plot
sed 's/,/ /g' hobos/10-20-2016-PH-PTBTM.csv | sed 's/\// /g' | sed 's/:/ /g' | awk '{ if (($8=="AM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9; if (($8=="AM") && ($5 >= 12))print $4+2000"-"$2"-"$3"T"$5-12":"$6":"$7, $9; if (($8=="PM") && ($5 >= 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9;  if (($8=="PM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5+12":"$6":"$7, $9}' >! teste
psxy teste -R$timewindow/100/130 -J -Ba1/a5WeSn -W4/red -K -O -Y2.5i>> plot_CR.ps 

# hobo pressure xy plot
sed 's/,/ /g' hobos/10-20-2016-CR-PTBTM.csv | sed 's/\// /g' | sed 's/:/ /g' | awk '{ if (($8=="AM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9; if (($8=="AM") && ($5 >= 12))print $4+2000"-"$2"-"$3"T"$5-12":"$6":"$7, $9; if (($8=="PM") && ($5 >= 12)) print $4+2000"-"$2"-"$3"T"$5":"$6":"$7, $9;  if (($8=="PM") && ($5 < 12)) print $4+2000"-"$2"-"$3"T"$5+12":"$6":"$7, $9}' >! teste
psxy teste -R$timewindow/100/130 -J  -W4/red -K -O >> plot_CR.ps 

