|
| 1 | +#!/bin/bash |
| 2 | +verb=false |
| 3 | +[ -n "$testverb" ] && verb=true |
| 4 | + |
| 5 | +[ -d "$srcdir" ] || { echo srcdir not set; exit 1; } |
| 6 | +${HOPS_SETUP-'false'} || . $srcdir/chk_env.sh |
| 7 | + |
| 8 | + |
| 9 | +if [ ! -d "$srcdir/3764" ]; then |
| 10 | + echo "Directory $srcdir/3764 does not exist, will not apply this test" |
| 11 | + exit 127 |
| 12 | +fi |
| 13 | + |
| 14 | +export DATADIR=`cd $srcdir/3764; pwd` |
| 15 | +RET_VAL=0 |
| 16 | +EXP_DIR=$DATADIR |
| 17 | +D2M4_EXP_NUM=. |
| 18 | +MK4_SCAN_DIR=104-1228 |
| 19 | +SCAN_DIR=104-1228a |
| 20 | +cd $EXP_DIR |
| 21 | + |
| 22 | +export HOPS_PLOT_DATA_MASK=0x83FFFFFF |
| 23 | + |
| 24 | +echo "Running: fourfit4 -m 4 -c ./test2.cf -b AS -P RR ./${SCAN_DIR}/" |
| 25 | +output_file=$(time fourfit4 -m 4 -c ./test2.cf -b AS -P RR ./${SCAN_DIR} 2>&1 | awk '{print $NF}') |
| 26 | +echo "fourfit4 output file: $output_file" |
| 27 | + |
| 28 | +#basic procedure to generate adhoc_phase file for consumption by fourfit3 (note: 3!) |
| 29 | +#fringex4 -i 1 -v 6 ./104-1228a/AS.Aa-Sw.X.RR.2GAB6T.1.frng -O ./out.alist |
| 30 | +#adhoc-baseline.pl -a ./out.alist -b AS |
| 31 | +#in general case, call: |
| 32 | +#print_adhoc_lines.pl |
| 33 | +#to generate control file lines, |
| 34 | +#then tweak the new control file (test_adhoc_phase.cf) to point to the adhoc files: |
| 35 | +#fourfit -c ./test_adhoc_phase.cf -P RR -b AS -pt ./104-1228/ |
| 36 | + |
| 37 | +#also, just for this test, we also have the silly step of reversing the channel labels |
| 38 | +#in the control file test...because the control files in this |
| 39 | +#directory are also testing the freq <-> channel labelling feature (which flipped the nominal order) |
| 40 | + |
| 41 | +#call fringex4 with 1 second bins on the new fringe file to generate an alist file |
| 42 | +echo "fringex4 -i 1 -v 6 ${output_file} -O ./out.alist" |
| 43 | +fringex4 -i 1 -v 6 ${output_file} -O ./out.alist |
| 44 | + |
| 45 | +#generate the adhoc phase files for stations A & S with Vincent's perl script |
| 46 | +echo "adhoc-baseline.pl -o adhoc_phase_test -a ./out.alist -b AS" |
| 47 | +adhoc-baseline.pl -o adhoc_phase_test -a ./out.alist -b AS |
| 48 | + |
| 49 | +#generate the control file lines |
| 50 | +echo "print_adhoc_lines.pl -b adhoc_phase_test -s AS" |
| 51 | +print_adhoc_lines.pl -b adhoc_phase_test -s AS | tee ./adhoc_lines.txt |
| 52 | + |
| 53 | +#do in-place sed replacement of the channel ordering labels |
| 54 | +#This is not normal procedure! But rather due to the peculiarities of this test directory |
| 55 | +#and how test2.cf was put together |
| 56 | +sed -i 's/abcdefghijklmnopqrstuvwxyzABCDEF/FEDCBAzyxwvutsrqponmlkjihgfedcba/g' adhoc_lines.txt |
| 57 | + |
| 58 | +#concatenate test2.cf and adhoc_lines.txt into test_adhoc.cf |
| 59 | +cat test2.cf adhoc_lines.txt > test_adhoc.cf |
| 60 | + |
| 61 | +#now run fourfit3 with the adhoc file |
| 62 | +echo "Running: fourfit3 -m 4 -c ./test_adhoc.cf -b AS -P RR ./${MK4_SCAN_DIR} set plot_data_dir ./chk_adhoc " |
| 63 | +time fourfit3 -m 1 -c ./test_adhoc.cf -b AS -P RR ./${MK4_SCAN_DIR} set plot_data_dir ./chk_adhoc 2>&1 | tee ./ff.out |
| 64 | + |
| 65 | +#grab the SNR value |
| 66 | +SNR=$(grep "fourfit3: SNR" ./ff.out | awk '{print $NF}') |
| 67 | +result=$(echo "($SNR > 120) && ($SNR < 125)" | bc) |
| 68 | +echo "The SNR of the fourfit3 adhoc'd fringe = $SNR" |
| 69 | +echo "fourfit3 result ok (121 < SNR < 125)? $result" # prints 1 if true, 0 if false |
| 70 | + |
| 71 | +#now run fourfit4 with the adhoc file |
| 72 | +echo "Running: fourfit4 -m 4 -c ./test_adhoc.cf -b AS -P RR ./${SCAN_DIR}" |
| 73 | +output_file2=$(fourfit4 -m 4 -c ./test_adhoc.cf -b AS -P RR ./${SCAN_DIR} 2>&1 | awk '{print $NF}') |
| 74 | +echo "fourfit4 output file: $output_file2" |
| 75 | + |
| 76 | +#convert the fringe file to json |
| 77 | +hops2json ${output_file2} |
| 78 | + |
| 79 | +#use jq (json query) to extract the plot_data element and pipe to file |
| 80 | +echo "jq '.[].tags.plot_data | select( . != null )' "${output_file2}.json" > tee ./fdump_adhoc.json" |
| 81 | +jq '.[].tags.plot_data | select( . != null )' "${output_file2}.json" > ./fdump_adhoc.json |
| 82 | + |
| 83 | +#now compare the results between fourfit3 and fourfit4, tolerance 0.5% |
| 84 | +compjsonpdd.py -r 0.003 ./fdump_adhoc.json ./chk_adhoc/104-1228-AS-B-RR.* |
| 85 | +RET_VAL=$? |
| 86 | + |
| 87 | +exit $RET_VAL |
0 commit comments