<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/bin/csh -f
# Needs to have the updated file from $AMOSdir/L4_AMOS_timeseries.txt
# to include the current year
set AMOSdir = /users/rsg/observatory/buoy/pml/download/L4/AMOS
set years = (2014 2015 2016 2017 2018)
set years = (2018 2019)

foreach year($years)
   set jday = 1
   while ($jday &lt; 366)
      set JJJ = `printf '%03d\n' $jday`
      set date = `julian -zeros $jday $year`
      set dd = `echo $date[1]`
      set mm = `echo $date[2]`
      set yy = `echo $year | cut -c 3-4`
      set datematch = `echo $dd$mm$yy`
      mkdir -p ${year}${JJJ}
      echo "Year Serial Time Prs Tmp Hum Dir Spd" &gt; ${year}${JJJ}/${year}${JJJ}_MPB_AMS.txt
      echo "Year Serial Time Lat Lon" &gt; ${year}${JJJ}/${year}${JJJ}_GPS_AMS.txt
      set nempty = `cat ${year}${JJJ}/${year}${JJJ}_MPB_AMS.txt | wc -c`
      set gpsempty = `cat ${year}${JJJ}/${year}${JJJ}_GPS_AMS.txt | wc -c`
      set hour = 0
      while($hour &lt; 24)
         set HH = `printf '%02d\n' $hour` 
         set datehourmatch = `echo $datematch,$HH`
         set Adata = `grep "${datehourmatch}50" $AMOSdir/L4_AMOS_timeseries.txt`
         set nchar = `echo $Adata | wc -c`
         if ($nchar &gt; 0) then
            # Create an AMOS version of the MPB and GPS files
            # MPB Year Serial Time Prs Tmp Hum Dir Spd(m/s)
            #set metdata = `echo ${hour}.10,$Adata | awk ' BEGIN {FS=","}{if ($8 &gt; 0 &amp;&amp; $9 &gt; 0 &amp;&amp; $6 &gt; 0 &amp;&amp; $7 &gt; 0 &amp;&amp; $10 &gt; 0) {printf("%5.2f %6.1f %5.1f %5.1f %5.1f %4.1f\n", $1,$8,$6,$7,$9,$10/1.944)}}'`
            set metdata = `echo ${hour}.10,$Adata | awk ' BEGIN {FS=","}{if ($8 &gt; 0 &amp;&amp; $9 &gt; 0 &amp;&amp; $6 &gt; 0 &amp;&amp; $7 &gt; 0 &amp;&amp; $10 &gt; 0) {printf("%5.2f %6.1f %5.1f %5.1f %5.1f %4.1f\n", $1,$8,$6,$7,$9,$10)}}'`
            set metout = `echo $year $JJJ $metdata`
            set nchar = `echo $metout | wc -c`
            if ($nchar &gt; 10) then
               echo $metout &gt;&gt; ${year}${JJJ}/${year}${JJJ}_MPB_AMS.txt
            endif 
            # GPS Year Serial Time Lat Lon
            set gpsdata = `echo ${hour}.10,$Adata | awk ' BEGIN {FS=","}{if ($4 &gt; 0 &amp;&amp; $5 &lt; 0) {printf("%5.2f %7.3f %7.3f\n", $1, $4, $5)}}'`
            set gpsout = `echo $year $JJJ $gpsdata`
            set gchar = `echo $gpsout | wc -c`
            if ($gchar &gt; 10) then 
               set lat = `echo $gpsout | awk '{print $4}'`
               set lat_degs = `echo $lat | cut -c1-2`
               set lat_decimal_mins = `echo $lat | cut -c3- | awk -v latdegs=$lat_degs '{if (latdegs &gt; 0.){printf("%6.3f\n", latdegs+$1*60./100.)}}'`
      
               set lon = `echo $gpsout | awk '{print $5}'`
               set lon_degs = `echo $lon | cut -c1-2`
               set lon_decimal_mins = `echo $lon | cut -c3- | awk -v londegs=$lon_degs '{if (londegs &lt; 0.){printf("%6.3f\n", londegs-$1*60./100.)}}'`           
               echo "$year $JJJ ${hour}.10 $lat_decimal_mins $lon_decimal_mins" &gt;&gt; ${year}${JJJ}/${year}${JJJ}_GPS_AMS.txt
            endif
         endif
         @ hour ++
         
      end

      # remove any files which have no data in
      set mpb_charsize = `cat ${year}${JJJ}/${year}${JJJ}_MPB_AMS.txt | wc -c`
      set gps_charsize = `cat ${year}${JJJ}/${year}${JJJ}_GPS_AMS.txt | wc -c`
      
      if ($nempty == $mpb_charsize) then
         /bin/rm -rf ${year}${JJJ}/${year}${JJJ}_MPB_AMS.txt 
      else
         echo "Creating ${year}${JJJ}/${year}${JJJ}_MPB_AMS.txt"
      endif
      
      if ($gpsempty == $gps_charsize) then
         /bin/rm -rf ${year}${JJJ}/${year}${JJJ}_GPS_AMS.txt 
      else
         echo " Creating ${year}${JJJ}/${year}${JJJ}_GPS_AMS.txt"
      endif
      
      #if ($nempty == $mpb_charsize &amp;&amp; $gpsempty == $gps_charsize) then
      #   /bin/rm -rf ${year}${JJJ}/
      #endif 
      
      @ jday ++
   
   end   

end




exit(0)
</pre></body></html>