<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/bin/csh
set findir = /users/rsg/observatory/buoy/pml/L4/postdeploy

foreach file(*.RAW)
   set stem = `echo $file:r | sed 's/F//'`
   echo $stem
   set yyyy = `echo $stem | cut -c1-4`
   set jjj = `echo $stem | cut -c5-7 | awk '{printf("%d", $1)}'`

   set nit_slope2 = 0.0
   set nit_slope = 0.0
   set nit_offset = 0.0
   set oxy_slope = 1.0

   if ($yyyy == "2009") then  
      set nit_slope2 = 0.0   
      set nit_slope = 0.053828
      set nit_offset = 3.873
      set oxy_slope = 44.6596
   endif
   
   set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}.cal`
   
   if ($yyyy == "2010") then 
      set nit_slope2 = -0.000113087
      set nit_slope = 0.0647568
      set nit_offset = -11.4855
      if ($jjj &lt; 343) then
         set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}a.cal`
      else 
         set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}b.cal`
      endif
   endif
   
   if ($yyyy == "2011") then 
      if ($jjj &lt; 16) then 
         set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}a.cal`
      else
         set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}b.cal`
      endif
      if ($jjj &gt;= 96 &amp;&amp; $jjj &lt; 180) then
         set nit_slope2 = 0.0
         set nit_slope = 0.202888
         set nit_offset = -35.9718
      else
         set nit_slope2 = 0.0
         set nit_slope = 0.0
         set nit_offset = -8.78471
      endif
   endif
   
   if (($yyyy == "2010" &amp;&amp; $jjj &gt;= 343) || ($yyyy == "2011" &amp;&amp; $jjj &lt; 61)) then
      set optics_cal = `echo cal/Hse297_2010343_2011061.cal`
   else
      set optics_cal = `echo cal/Hse298_${yyyy}.cal`
   endif
   
   if ($yyyy == "2012") then 
      set optics_cal = `echo cal/Hse298_${yyyy}.cal`
      set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}.cal`
   endif

   if ($yyyy == "2013") then 
      set optics_cal = `echo cal/Hse298_${yyyy}.cal`
      if ($jjj &lt; 73) then 
         set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}a.cal`
      endif
      if ($jjj &gt;= 73 &amp;&amp; $jjj &lt; 252) then
         set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}b.cal`
      endif  
      if ($jjj &gt;=  252) then
         set offset_file = `echo cal/L4_buoy_offsets_{$yyyy}c.cal`
      endif  
   endif
   
   if ($yyyy == "2018" || $yyyy == "2019") then
      set optics_cal = `echo cal/Hse297b_${yyyy}.cal`
   endif
   
   echo $yyyy $jjj $optics_cal $offset_file
   
   process_storx_binary $file $optics_cal $offset_file &gt; ${stem}.txt
   
   mkdir $findir/$stem
   echo "Creating GPS file ..."
   echo "Year Serial Time Lat Lon" &gt; $findir/$stem/${stem}_GPS.txt
   cat ${stem}.txt | grep GPS | sed 's/GPS//' | nawk '/\./{printf("%04d %03d %5.2f %7.3f %7.3f\n",year,julian,$1,$2,$3)}' year=$yyyy julian=$jjj  &gt;&gt; $findir/$stem/${stem}_GPS.txt

   echo "Creating MPB file ..."
   echo "Year Serial Time Prs Tmp Hum Dir Spd" &gt; $findir/$stem/${stem}_MPB.txt
   cat ${stem}.txt | grep MPB | sed 's/MPB//' | nawk '/\./{printf("%04d %03d %5.2f %6.1f %5.1f %5.1f %5.1f %4.1f\n",year,julian,$1,$2,$3,$4,$5,$6)}' year=$yyyy julian=$jjj &gt;&gt; $findir/$stem/${stem}_MPB.txt

   echo "Creating WQM file ..."
   echo "Year Serial Time SST Sal Oxy Chl NTU" &gt; $findir/$stem/${stem}_WQM.txt
   cat ${stem}.txt | grep WQM | sed 's/WQM//' | sed '/3600\.00/d' | nawk '/\./{printf("%04d %03d %5.2f %5.2f %5.2f %6.2f %5.2f %5.2f\n",year,julian,$1,$2,$3,$4*oxy,$5,$6)}' year=$yyyy julian=$jjj oxy=$oxy_slope &gt;&gt; $findir/$stem/${stem}_WQM.txt

   echo "Creating PHL file ..."
   echo "Year Serial Time pH1 pH2" &gt; $findir/$stem/${stem}_PHL.txt
   cat ${stem}.txt | grep PHL | sed 's/PHL//' | nawk '/\./{printf("%04d %03d %5.2f %5.2f %5.2f\n",year,julian,$1,$2,$3)}' year=$yyyy julian=$jjj &gt;&gt; $findir/$stem/${stem}_PHL.txt

   echo "Creating CDM file ..."
   echo "Year Serial Time CDM" &gt; $findir/$stem/${stem}_CDM.txt
   cat ${stem}.txt | grep CDM | sed 's/CDM//' | nawk '/\./{printf("%04d %03d %5.2f %5.2f\n",year,julian,$1,$2,$3)}' year=$yyyy julian=$jjj &gt;&gt; $findir/$stem/${stem}_CDM.txt

   echo "Creating HSE file ..."
   set wavelengths = `cat ${stem}.txt | grep HSE | sed 's/HSE//' | nawk '$0 ~ /Time/ {print $0}'` 
   echo "Year Serial $wavelengths" &gt; $findir/$stem/${stem}_HSE.txt
   cat ${stem}.txt | grep HSE | sed 's/HSE//' | nawk '$0 !~ /Time/ {print year " " julian $0}' year=$yyyy julian=$jjj &gt;&gt; $findir/$stem/${stem}_HSE.txt
   
   if ($yyyy == "2011" &amp;&amp; $jjj &lt; 61) then
      echo "No nutrient data available for this period"
   else
      echo "Creating NLF file ..."
      echo "Year Serial Time NLF" &gt; $findir/$stem/${stem}_NLF.txt
      cat ${stem}.txt | grep LF | sed 's/NLF//' | sed 's/SLF//' | nawk '/\./{printf("%04d %03d %5.2f %5.2f\n",year,julian,$1,$2+slope2*(julian+$1/24.)^2+(julian+$1/24.)*slope + offset)}' year=$yyyy julian=$jjj slope2=$nit_slope2 slope=$nit_slope offset=$nit_offset &gt;&gt; $findir/$stem/${stem}_NLF.txt
   endif

   /bin/mv $file $findir/$stem
   
   /bin/rm ${stem}.txt
   
end



exit(0)

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