#!/bin/csh -f #+ # check_keywords -- verify presence of AO and DCS keywords in image header # # Purpose: # When a new image is read out, parse the header and determine # whether the AO and DCS keywords have all been included. # # Usage: # check_keywords [-verbose] [image1 .. imageN] # # Arguments: # -verbose = print status for good images as well as bad # image = name of the image(s) to check [default is to monitor continuously] # # Output: # written to STDOUT # # Restrictions: # # Exit values: # 0 = normal completion # 1 = wrong number of arguments # # Example: # 1) Check OSIRIS, AO, and DCS keywords in a series of images: # check_keywords *.fits # # 2) Check keywords for new images as they come out: # check_keywords #- # Modification history: # 2002-Oct-04 GDW Original version # 2010-Sep-20 jlyke Adapted for OSIRIS # 2021-Mar-17 jlyke Updated for new host and new keywords #----------------------------------------------------------------------- set buf = $0 set cmd = $buf:t set usage = "Usage: $cmd spec|image [-verbose] [file1 ... fileN]" # tvflip/utc are first/last DCS header keywords set dcs_keywords = (ra dec el rotposn tvflip utc) # trkwtyst/aoopsmod are first/last AO header keywords # aofmx-SC, obwf-OBS, wsfrrt-NGWFC, trkwyyst-TRICK, aoopsmod-AuMisc set ao_keywords = (aofmx obwf wsfrrt trkwtyst aoopsmod) # dtmploc1/wfdm are first/last OSIRIS header keywords # ifilter, sscale depended on global server set osiris_keywords = (ifilter sscale dtmploc1 wfdm) # datafile/pscale are first last o[is]ds header keywords set ods_keywords = (datafile pscale) set stat = 0 set verb = 0 # flag check... switch ($1) case "S*": case "s*": set M = "S" set mode = "spec" breaksw case "I*": case "i*": set M = "I" set mode = "imag" breaksw default: printf "$usage\n" exit 1 breaksw endsw shift while ($#argv > 0) # check on verbose flag... if ( $1 == "-verbose" ) then set verb = 1 shift continue endif # no flags found; break... break end # remaining args are image names... if ( $#argv >= 1 ) then set images = ( $* ) endif # make check... while (1) # get image... if ( $?images ) then set im = $images[1] shift images else wfgo ${mode} set im = `lastimage ${mode}` # if ($#im == 0) then # printf "No image to check\n" # break # endif endif if ( $im != "" ) then # reset stats to good... set ods_stat = 0 set osiris_stat = 0 set dcs_stat = 0 set ao_stat = 0 # check for certain o[is]ds keywords, including the last one written... set n_ods = `fitshead $im $ods_keywords | wc -l` if ( $n_ods != $#ods_keywords ) then set ods_stat = 1 set stat = 1 endif # check for certain osiris keywords, including the last one written... set n_osiris = `fitshead $im $osiris_keywords | wc -l` if ( $n_osiris != $#osiris_keywords ) then set osiris_stat = 1 set stat = 1 endif # check for certain DCS keywords, including the last one written... set n_dcs = `fitshead $im $dcs_keywords | wc -l` if ( $n_dcs != $#dcs_keywords ) then set dcs_stat = 1 set stat = 1 endif # check for certain DCS keywords, including the last one written... set n_ao = `fitshead $im $ao_keywords | wc -l` if ( $n_ao != $#ao_keywords ) then set ao_stat = 1 set stat = 1 endif # print status... if ( $ods_stat && $osiris_stat && $ao_stat && $dcs_stat ) then printf "ERROR -- missing O${M}DS, OSIRIS, DCS, and AO keywords in image $im\n" else if ( $ods_stat ) then printf "ERROR -- missing O${M}DS keywords in image $im\n" else if ( $osiris_stat ) then printf "ERROR -- missing OSIRIS keywords in image $im\n" else if ( $ao_stat ) then printf "ERROR -- missing AO keywords in image $im\n" else if ( $dcs_stat ) then printf "ERROR -- missing DCS keywords in image $im\n" else if ( $verb ) then printf "Verified O${M}DS, OSIRIS, DCS, and AO keywords in image $im\n" endif # break out if we are out images to process... if ( $?images == 1 ) then if ( $#images == 0 ) then break endif endif endif end exit $stat