#! /bin/csh -f set noglob # set_config_by_time {T_OBS} {FSN} {DRMSSESSION} # source of config files, assume index keys: type, date, and segment: file set CONFIG_FILES = hmi_ground.test_config_files # target series to update. assume index key fsn, and other keys: date and keys from config files. set CONFIG_SERIES = hmi_ground.lev0_config # get time and FSN for this image set IMAGE_TIME = $1 set FSN = $2 if ($#argv == 3) then setenv DRMSSESSION $3 endif # echo In set_config_by_time, FSN=$FSN IMAGE_TIME=$IMAGE_TIME set IMAGE_SECS = `time_convert time=$IMAGE_TIME` # make temp file name set NOW = `date "+%Y%m%d_%H%M%S"` set TMP = /tmp/fsn_$NOW"_"$$ mkdir $TMP # loop through the possible types to get and process files # First get the "FTS" file with all keywords that is just before the image time # get filename for "FTS_LOG" config file at or just before this image time set FTS_INFO = `show_keys "ds=hmi_ground.test_config_files[? recnum = (select recnum from hmi_ground.test_config_files where type = 'fts_log' and date <= $IMAGE_SECS order by date desc limit 1) ?]" -p -q key=date seg=file ` if ($#FTS_INFO != 2) then echo Problem, no config data found for $IMAGE_TIME for FTS_LOG, $FTS_INFO exit endif # now get date and filename cp $FTS_INFO[2] $TMP/data # Add "... " around each line to preserve imbedded blanks in strings awk '{printf("\"%s \"\n",$0)}' <$TMP/data >$TMP/params set_keys -c ds=$CONFIG_SERIES FSN=$FSN T_OBS=$IMAGE_TIME FTS_FILE=$FTS_INFO[2] @$TMP/params # echo Set FTS params: # cat $TMP/params # Now have all params but look to see if more recent PCU info available set PCU_INFO = `show_keys "ds=hmi_ground.test_config_files[? recnum = (select recnum from hmi_ground.test_config_files where type = 'pcu' and date <= $IMAGE_SECS order by date desc limit 1) ?]" -p -q key=date seg=file ` set pcu_time = `time_convert time=$PCU_INFO[1]` set new_pcu = `echo $pcu_time ">=" $IMAGE_SECS | bc -l` if ($new_pcu == 1) then cp $PCU_INFO[2] $TMP/data # Add ".." around each line to preserve imbedded blanks in strings awk '{printf("\"%s \"\n",$0)}' <$TMP/data >$TMP/params set_keys "ds=$CONFIG_SERIES[$FSN][$IMAGE_TIME]" PCU_FILE=$PCU_INFO[2] @$TMP/params endif rm -rf $TMP