Skip to content

Commit 4abbafe

Browse files
committed
adding test using dummy_vis to verify fourfit4 can process at least 256 channels
1 parent 5a946e3 commit 4abbafe

3 files changed

Lines changed: 75 additions & 15 deletions

File tree

source/cpp_src/Applications/dummy_vis.cc

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ int main(int argc, char** argv)
326326
std::string baseline_shortname = "AB";
327327
std::string ref_station = "A";
328328
std::string rem_station = "B";
329+
std::string ref_station_code = "Aa";
330+
std::string rem_station_code = "Bb";
329331
std::string ref_station_name = "DUMMY_A";
330332
std::string rem_station_name = "DUMMY_B";
331333
std::string root_code = "abcdef";
@@ -563,17 +565,17 @@ int main(int argc, char** argv)
563565
// =========================================================
564566

565567

566-
std::cout<<"baseline_name"<<baseline_name<<std::endl;
567-
std::cout<<"ref station"<<ref_station<<std::endl;
568-
std::cout<<"rem station"<<rem_station<<std::endl;
568+
std::cout<<"baseline_name: "<<baseline_name<<std::endl;
569+
std::cout<<"ref station: "<<ref_station<<std::endl;
570+
std::cout<<"rem station: "<<rem_station<<std::endl;
569571

570572
vis.Insert(std::string("name"), std::string("visibilities"));
571573
vis.Insert(std::string("baseline"), baseline_name);
572574
vis.Insert(std::string("baseline_shortname"), baseline_shortname);
573-
vis.Insert(std::string("reference_station"), ref_station);
574-
vis.Insert(std::string("remote_station"), rem_station);
575-
vis.Insert(std::string("reference_station_name"), ref_station);
576-
vis.Insert(std::string("remote_station_name"), rem_station);
575+
vis.Insert(std::string("reference_station"), ref_station_code);
576+
vis.Insert(std::string("remote_station"), rem_station_code);
577+
vis.Insert(std::string("reference_station_name"), ref_station_name);
578+
vis.Insert(std::string("remote_station_name"), rem_station_name);
577579
vis.Insert(std::string("reference_station_mk4id"), ref_station);
578580
vis.Insert(std::string("remote_station_mk4id"), rem_station);
579581
vis.Insert(std::string("correlation_date"), start_time);
@@ -622,10 +624,10 @@ int main(int argc, char** argv)
622624
wt.Insert(std::string("name"), std::string("weights"));
623625
wt.Insert(std::string("baseline"), baseline_name);
624626
wt.Insert(std::string("baseline_shortname"), baseline_shortname);
625-
wt.Insert(std::string("reference_station"), ref_station);
626-
wt.Insert(std::string("remote_station"), rem_station);
627-
wt.Insert(std::string("reference_station_name"), ref_station);
628-
wt.Insert(std::string("remote_station_name"), rem_station);
627+
wt.Insert(std::string("reference_station"), ref_station_code);
628+
wt.Insert(std::string("remote_station"), rem_station_code);
629+
wt.Insert(std::string("reference_station_name"), ref_station_name);
630+
wt.Insert(std::string("remote_station_name"), rem_station_name);
629631
wt.Insert(std::string("reference_station_mk4id"), ref_station);
630632
wt.Insert(std::string("remote_station_mk4id"), rem_station);
631633
wt.Insert(std::string("correlation_date"), std::string("2025-01-01T00:00:00"));
@@ -651,11 +653,11 @@ int main(int argc, char** argv)
651653
tags.Insert(std::string("root_code"), root_code);
652654
tags.Insert(std::string("baseline"), baseline_name);
653655
tags.Insert(std::string("baseline_shortname"), baseline_shortname);
654-
tags.Insert(std::string("reference_station"), ref_station);
655-
tags.Insert(std::string("remote_station"), rem_station);
656+
tags.Insert(std::string("reference_station"), ref_station_code);
657+
tags.Insert(std::string("remote_station"), rem_station_code);
656658
tags.Insert(std::string("reference_station_name"), ref_station_name);
657-
tags.Insert(std::string("remote_station_name"), rem_station);
658-
tags.Insert(std::string("reference_station_mk4id"), ref_station_name);
659+
tags.Insert(std::string("remote_station_name"), rem_station_name);
660+
tags.Insert(std::string("reference_station_mk4id"), ref_station);
659661
tags.Insert(std::string("remote_station_mk4id"), rem_station);
660662
tags.Insert(std::string("correlation_date"), std::string("2025-01-01T00:00:00"));
661663
tags.Insert(std::string("origin"), std::string("simulated"));
@@ -744,6 +746,8 @@ int main(int argc, char** argv)
744746
std::string vex_string = GetVexString();
745747
mho_json vex_obj = mho_json::parse(vex_string);
746748

749+
750+
747751
//write out the 'ovex'/'vex' json object as a json file
748752
std::string root_file = "./dummy.";
749753
root_file += root_code + "." + "root.json";

source/cpp_src/Applications/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ if(BASH_PROGRAM)
3535
chk_adhoc_phase_poly
3636
chk_adhoc_phase_sinewave
3737
chk_adhoc_flagging
38+
chk_highnchannels
3839
)
3940
endif(PY_EXE)
4041

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
if [ ! -d "$srcdir/dummy" ]; then
9+
mkdir -p "$srcdir/dummy"
10+
fi
11+
12+
export DATADIR=`cd $srcdir/dummy; pwd`
13+
RET_VAL=0
14+
EXP_DIR=$DATADIR
15+
cd $EXP_DIR
16+
SNR_VAL=200
17+
NCHAN=256
18+
CHANW=64
19+
NAPS=30
20+
NSPECPTS=128
21+
22+
#run dummy_vis to generate fake visibilty data to test if we can process n_channels > 128 (here we test 256)
23+
dummy_vis --snr ${SNR_VAL} -c ${NCHAN} -w ${CHANW} -n ${NAPS} -s ${NSPECPTS}
24+
25+
echo "Running: fourfit4 -m 4 -b AB -P XX ./"
26+
output_file=$(fourfit4 -m 4 -b AB -P XX ./ 2>&1 | awk '{print $NF}')
27+
echo "fourfit4 output file: $output_file"
28+
29+
#convert the fringe file to json
30+
hops2json ${output_file}
31+
32+
#use jq (json query) to extract the plot_data element and pipe to file
33+
echo "jq '.[].tags.parameters.fringe.snr | select( . != null )' "${output_file}.json" > ./fdump.json"
34+
jq '.[].tags.parameters.fringe.snr | select( . != null )' "${output_file}.json" > ./fdump.json
35+
36+
#use jq (json query) to extract the plot_data element and pipe to file
37+
echo "jq '.[].tags.parameters.config.nchannels | select( . != null )' "${output_file}.json" > ./nchan.json"
38+
jq '.[].tags.parameters.config.nchannels | select( . != null )' "${output_file}.json" > ./nchan.json
39+
40+
NCHAN_USED=$(cat ./nchan.json)
41+
echo "fourfit4 used: $NCHAN_USED channels."
42+
43+
#determine if the SNR is near the specified value of SNR_VAL
44+
SNR=$(cat ./fdump.json)
45+
46+
result=$(echo "sqrt(($SNR - $SNR_VAL)^2) < 1.0" | bc -l)
47+
echo "The calculated SNR of the simulated fringe = $SNR, expected: $SNR_VAL"
48+
echo "Result ok? $result" # prints 1 if true, 0 if false
49+
50+
#invert the logic for the return code (0 is normal, 1 is fail)
51+
if [ "$result" -eq 1 ]; then
52+
exit 0
53+
else
54+
exit 1
55+
fi

0 commit comments

Comments
 (0)