#!/bin/csh
alias julian /users/rsg/panorama/panorama.svn/bin/julian
set finaldir = /users/rsg/observatory/buoy/pml/download/E1

# In water files
echo "Creating time-series in-water files"
cat $finaldir/2015/????????/*S*.txt | awk 'BEGIN {FS = ","; RS = "\n"} {if (NF >= 33 && $6 == 0){printf "%06d,%06d,0.00,%f,0.00,%f,%f,%f,%f,%f\n",$2,$3,$8,$12,$21,$24,$27,$30}} \
                                            {if (NF >= 33 && $6 == 120){printf "%06d,%06d,%f,%f,0.00,%f,%f,%f,%f,%f\n",$2,$3,$7,$10,$14,$23,$26,$29,$32}}' \
      > $finaldir/buoy_water_E1_all_2015.txt

#   cat $finaldir/????????/*S*.txt | awk 'BEGIN {FS = ","; RS = "\n"} {if (NF >= 33){printf "%06d,%06d,0.00,%f,0.00,%f,%f,%f,%f,%f\n",$2,$3,$8,$12,$21,$24,$27,$30}}' \
#      > $finaldir/buoy_water_E1_all.txt
#endif
    
echo "Creating gnuplot compatible format file"
cat $finaldir/buoy_water_E1_all_2015.txt | awk 'BEGIN {FS=","} {printf "%d,%f,%f,%f,%f,%f,%f,%f,%f\n", $1$2,$3/2.77,$4,$5,$6,$7,$8,$9,$10}' > /tmp/buoy_water_E1_all.txt

echo "Creating plots"
pwd
/usr/bin/gnuplot /users/rsg/observatory/buoy/pml/bin/gnuplot/plot_temp_sal_ODAS51
/usr/bin/gnuplot /users/rsg/observatory/buoy/pml/bin/gnuplot/plot_oxygen_fluor_ODAS51


exit(0)
