<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/bin/csh 

set fAMOS = /users/rsg/observatory/buoy/pml/download/L4/AMOS/L4_AMOS_timeseries.txt
set ramedir = /users/rsg/observatory/metstation/data/ramehead/buoy_fmt
set header = `echo "Date,Time,Lat,Lon,Temperature(C),Humidity(%),Pressure(mb),Direction(deg),Wind(m/s),Gust(m/s),RameP(mb),RameT(C),RameH(%),RameDir(deg),RameW(m/s)"`
set fout = /users/rsg/observatory/buoy/pml/download/L4/AMOS/L4_AMOS_ramehead_comparison.txt
echo $header &gt; $fout

foreach line(`cat $fAMOS | awk '/\./{print $0}'`)
   #echo $line
   set ddmmyy = `echo $line | cut -c1-6`
   
   # look for a match in filename and then grep for the time in that file
   set yy = `echo $ddmmyy | cut -c5-6`
   set mm = `echo $ddmmyy | cut -c3-4`
   set dd = `echo $ddmmyy | cut -c1-2`
   set HH = `echo $line | cut -c8-9`
   
   set yyyy = `echo 20$yy`
   set jdate = `julian -zeros $dd $mm $yyyy`
   #echo $jdate
   if (-e $ramedir/${yy}${mm}${dd}_rame_met.dat) then 
      set matchfile = $ramedir/${yy}${mm}${dd}_rame_met.dat
      set ramematch = `grep $jdate[2].$jdate[1].$HH $matchfile | awk '/\./{print $2","$3","$4","$5","$6}'`
      echo $line","$ramematch &gt;&gt; $fout
      #echo $#ramematch
   else
      echo "No matching file for $line"
   endif
   #exit(0)
end

exit(0)

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