<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/bin/csh
# Module: L4_amos_timeseries.csh
# Author: Tim Smyth
# Date: 21/04/2016
# Version: 1.0
# 

alias julian /users/rsg/panorama/panorama.svn/bin/julian

set execdir = /users/rsg/observatory/buoy/pml/bin
set downloaddir = /users/rsg/observatory/buoy/pml/download/L4/AMOS
set finaldir = /users/rsg/observatory/buoy/pml/download/L4/AMOS

# make long files for all the parameters
# Met files - this is more consistent with the current output from the E1 buoy
echo "Creating time-series met files"
set header = `echo "Date,Time,Lat,Lon,Temperature(C),Humidity(%),Pressure(mb),Direction(deg),Wind(m/s),Gust(m/s)"` 

echo $header &gt; $finaldir/L4_AMOS_timeseries.txt

set years = (2014 2015 2016 2017 2018)
set years = (2018 2019)
set this_year = `date +%Y`

foreach year($years)
   echo $year
   set diroffset = 0
   if ($year &gt;= 2016) then
      # need to take of 90 degree offset
      # awk statement takes care of the over 360 issue
      set diroffset = 90
   endif
   #dos2unix $finaldir/${year}/????????/*.sbd
   if ($year == $this_year) then 
      set files = `ls $finaldir/????????/*.sbd`
   else
      set files = `ls $finaldir/${year}/????????/*.sbd`
   endif
   
   foreach file($files)
      if ($year &gt;= 2015) then 
         cat $file | awk -v offset=$diroffset 'BEGIN {FS = ","; RS = "\n"} {if ($1 ~ /2/ &amp;&amp; $5 &lt;= 502600 &amp;&amp; NF == 15 &amp;&amp; $11/10 &lt; 270.) {printf "%06d,%04d,%2.4f,%1.4f,%2.1f,%3.1f,%4.2f,%3.1f,%2.2f,%2.1f\n",$2,$3,$5/10000,$6/10000,$7/10,$8/10,$9/100,($11/10)+offset,$12/100,$13/10}}{if ($1 ~ /2/ &amp;&amp; $5 &lt;= 502600 &amp;&amp; NF == 15 &amp;&amp; $11/10 &gt;= 270.) {printf "%06d,%04d,%2.4f,%1.4f,%2.1f,%3.1f,%4.2f,%3.1f,%2.2f,%2.1f\n",$2,$3,$5/10000,$6/10000,$7/10,$8/10,$9/100,($11/10)+offset-360,$12/100,$13/10}}' \
         &gt;&gt; $finaldir/L4_AMOS_timeseries_{$year}.txt
      else
         cat $file | awk -v offset=$diroffset 'BEGIN {FS = ","; RS = "\n"} {if ($1 ~ /2/ &amp;&amp; $5 &lt;= 502600 &amp;&amp; NF == 15) {printf "%06d,%04d,%2.4f,%1.4f,%2.1f,%3.1f,%4.2f,%3.1f,%2.2f,%2.1f\n",$2,$3,$5/10000,$6/10000,$7/10,$8/10,$9/100,$11/10,$12/100,$13/10}}' \
         &gt;&gt; $finaldir/L4_AMOS_timeseries_{$year}.txt
      endif
      
   end
end

cat $finaldir/L4_AMOS_timeseries_20??.txt &gt;&gt; $finaldir/L4_AMOS_timeseries.txt

exit(0)


</pre></body></html>