Skip to content

Commit 4d16e14

Browse files
committed
Merge branch 'master'
2 parents fbd201e + 0505609 commit 4d16e14

5 files changed

Lines changed: 412 additions & 98 deletions

File tree

source/cpp_src/Fringe/include/MHO_ComputePlotData.hh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,17 @@ class MHO_ComputePlotData
188188
//exports the multitone pcal data (if it was applied)
189189
//to the plot dictionary
190190
void dump_multitone_pcmodel(mho_json& plot_dict,
191-
int station_flag, //0 = reference station, 1 = remote station,
192-
std::string pol //single char string
191+
int station_flag, //0 = reference station, 1 = remote station,
192+
std::string pol, //single char string
193+
std::string key_suffix = "" //appended to PLOT_INFO keys, e.g. "2" for second pol
193194
);
194195

195196
//exports the manual pcal data (pc_phases)
196197
//to the plot dictionary
197198
void dump_manual_pcmodel(mho_json& plot_dict,
198-
int station_flag, //0 = reference station, 1 = remote station,
199-
std::string pol //single char string
199+
int station_flag, //0 = reference station, 1 = remote station,
200+
std::string pol, //single char string
201+
std::string key_suffix = "" //appended to PLOT_INFO keys, e.g. "2" for second pol
200202
);
201203

202204
/**

source/cpp_src/Fringe/src/MHO_ComputePlotData.cc

Lines changed: 110 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <map>
2+
#include <set>
23
#include <vector>
34

45
#include "MHO_BasicFringeInfo.hh"
@@ -1155,10 +1156,45 @@ void MHO_ComputePlotData::DumpInfoToJSON(mho_json& plot_dict)
11551156
plot_dict["NPlots"] = nplot; //nchan+1
11561157
plot_dict["StartPlot"] = 0;
11571158

1159+
//determine whether this is a pseudo-Stokes I fringe
1160+
std::string polprod = std::get< POLPROD_AXIS >(*fVisibilities).at(0);
1161+
bool is_pseudo_stokes_I = (polprod == "I");
1162+
1163+
//for pseudo-Stokes I, derive the individual polarization characters at each station
1164+
std::vector< std::string > ref_pols_vec, rem_pols_vec;
1165+
if(is_pseudo_stokes_I)
1166+
{
1167+
std::vector< std::string > polprod_set;
1168+
fParamStore->Get("/config/polprod_set", polprod_set);
1169+
std::set< std::string > ref_set, rem_set;
1170+
for(auto& pp : polprod_set)
1171+
{
1172+
ref_set.insert(std::string(1, pp[0]));
1173+
rem_set.insert(std::string(1, pp[1]));
1174+
}
1175+
ref_pols_vec.assign(ref_set.begin(), ref_set.end()); //e.g. {"X","Y"}
1176+
rem_pols_vec.assign(rem_set.begin(), rem_set.end()); //e.g. {"X","Y"}
1177+
plot_dict["extra"]["ref_pols"] = ref_pols_vec;
1178+
plot_dict["extra"]["rem_pols"] = rem_pols_vec;
1179+
}
1180+
11581181
//add the 'PLOT_INFO' section
1159-
std::vector< std::string > pltheader{"#Ch", "Freq(MHz)", "Phase", "Ampl", "SbdBox", "APsRf", "APsRm",
1160-
"PCdlyRf", "PCdlyRm", "PCPhsRf", "PCPhsRm", "PCOffRf", "PCOffRm", "PCAmpRf",
1161-
"PCAmpRm", "ChIdRf", "TrkRf", "ChIdRm", "TrkRm"};
1182+
std::vector< std::string > pltheader;
1183+
if(is_pseudo_stokes_I)
1184+
{
1185+
//pseudo-Stokes I: include second-pol keys, omit Tracks and Chan ids
1186+
pltheader = {"#Ch", "Freq(MHz)", "Phase", "Ampl", "SbdBox", "APsRf", "APsRm",
1187+
"PCdlyRf", "PCdlyRf2", "PCdlyRm", "PCdlyRm2",
1188+
"PCPhsRf", "PCPhsRm", "PCPhsRf2", "PCPhsRm2",
1189+
"PCOffRf", "PCOffRm", "PCOffRf2", "PCOffRm2",
1190+
"PCAmpRf", "PCAmpRf2", "PCAmpRm", "PCAmpRm2"};
1191+
}
1192+
else
1193+
{
1194+
pltheader = {"#Ch", "Freq(MHz)", "Phase", "Ampl", "SbdBox", "APsRf", "APsRm",
1195+
"PCdlyRf", "PCdlyRm", "PCPhsRf", "PCPhsRm", "PCOffRf", "PCOffRm", "PCAmpRf",
1196+
"PCAmpRm", "ChIdRf", "TrkRf", "ChIdRm", "TrkRm"};
1197+
}
11621198
plot_dict["PLOT_INFO"]["header"] = pltheader;
11631199

11641200
//includes the 'All' channel
@@ -1190,35 +1226,67 @@ void MHO_ComputePlotData::DumpInfoToJSON(mho_json& plot_dict)
11901226
plot_dict["PLOT_INFO"]["PCOffRm"].push_back(0.0);
11911227
plot_dict["PLOT_INFO"]["PCAmpRf"].push_back(0.0);
11921228
plot_dict["PLOT_INFO"]["PCAmpRm"].push_back(0.0);
1193-
plot_dict["PLOT_INFO"]["ChIdRf"].push_back("-");
1194-
plot_dict["PLOT_INFO"]["TrkRf"].push_back("-");
1195-
plot_dict["PLOT_INFO"]["ChIdRm"].push_back("-");
1196-
plot_dict["PLOT_INFO"]["TrkRm"].push_back("-");
1197-
}
11981229

1199-
int station_flag;
1200-
std::string pol;
1201-
std::string polprod = std::get< POLPROD_AXIS >(*fVisibilities).at(0);
1230+
if(is_pseudo_stokes_I)
1231+
{
1232+
//initialize second-pol arrays
1233+
plot_dict["PLOT_INFO"]["PCdlyRf2"].push_back(0.0);
1234+
plot_dict["PLOT_INFO"]["PCdlyRm2"].push_back(0.0);
1235+
plot_dict["PLOT_INFO"]["PCPhsRf2"].push_back(0.0);
1236+
plot_dict["PLOT_INFO"]["PCPhsRm2"].push_back(0.0);
1237+
plot_dict["PLOT_INFO"]["PCOffRf2"].push_back(0.0);
1238+
plot_dict["PLOT_INFO"]["PCOffRm2"].push_back(0.0);
1239+
plot_dict["PLOT_INFO"]["PCAmpRf2"].push_back(0.0);
1240+
plot_dict["PLOT_INFO"]["PCAmpRm2"].push_back(0.0);
1241+
}
1242+
else
1243+
{
1244+
plot_dict["PLOT_INFO"]["ChIdRf"].push_back("-");
1245+
plot_dict["PLOT_INFO"]["TrkRf"].push_back("-");
1246+
plot_dict["PLOT_INFO"]["ChIdRm"].push_back("-");
1247+
plot_dict["PLOT_INFO"]["TrkRm"].push_back("-");
1248+
}
1249+
}
12021250

1203-
//export reference pcal stuff
1204-
station_flag = 0;
1205-
pol = polprod;
1206-
if(polprod.size() == 2)
1251+
if(is_pseudo_stokes_I)
12071252
{
1208-
pol = std::string(1, polprod[station_flag]);
1253+
//export pcal data for both polarizations at each station
1254+
//ref station, first pol (slot ""), second pol (slot "2")
1255+
dump_multitone_pcmodel(plot_dict, 0, ref_pols_vec[0], "");
1256+
dump_manual_pcmodel(plot_dict, 0, ref_pols_vec[0], "");
1257+
dump_multitone_pcmodel(plot_dict, 0, ref_pols_vec[1], "2");
1258+
dump_manual_pcmodel(plot_dict, 0, ref_pols_vec[1], "2");
1259+
//remote station, first pol (slot ""), second pol (slot "2")
1260+
dump_multitone_pcmodel(plot_dict, 1, rem_pols_vec[0], "");
1261+
dump_manual_pcmodel(plot_dict, 1, rem_pols_vec[0], "");
1262+
dump_multitone_pcmodel(plot_dict, 1, rem_pols_vec[1], "2");
1263+
dump_manual_pcmodel(plot_dict, 1, rem_pols_vec[1], "2");
12091264
}
1210-
dump_multitone_pcmodel(plot_dict, station_flag, pol);
1211-
dump_manual_pcmodel(plot_dict, station_flag, pol);
1212-
1213-
//export remote pcal stuff
1214-
station_flag = 1;
1215-
pol = polprod;
1216-
if(polprod.size() == 2)
1265+
else
12171266
{
1218-
pol = std::string(1, polprod[station_flag]);
1267+
int station_flag;
1268+
std::string pol;
1269+
1270+
//export reference pcal stuff
1271+
station_flag = 0;
1272+
pol = polprod;
1273+
if(polprod.size() == 2)
1274+
{
1275+
pol = std::string(1, polprod[station_flag]);
1276+
}
1277+
dump_multitone_pcmodel(plot_dict, station_flag, pol);
1278+
dump_manual_pcmodel(plot_dict, station_flag, pol);
1279+
1280+
//export remote pcal stuff
1281+
station_flag = 1;
1282+
pol = polprod;
1283+
if(polprod.size() == 2)
1284+
{
1285+
pol = std::string(1, polprod[station_flag]);
1286+
}
1287+
dump_multitone_pcmodel(plot_dict, station_flag, pol);
1288+
dump_manual_pcmodel(plot_dict, station_flag, pol);
12191289
}
1220-
dump_multitone_pcmodel(plot_dict, station_flag, pol);
1221-
dump_manual_pcmodel(plot_dict, station_flag, pol);
12221290

12231291
double fringe_amp = fParamStore->GetAs< double >("/fringe/famp");
12241292
double tsum_weights = fParamStore->GetAs< double >("/fringe/total_summed_weights");
@@ -1725,8 +1793,9 @@ std::string MHO_ComputePlotData::calc_error_code(const mho_json& plot_dict)
17251793
}
17261794

17271795
void MHO_ComputePlotData::dump_multitone_pcmodel(mho_json& plot_dict,
1728-
int station_flag, //0 = reference station, 1 = remote station
1729-
std::string pol //single char string
1796+
int station_flag, //0 = reference station, 1 = remote station
1797+
std::string pol, //single char string
1798+
std::string key_suffix //appended to PLOT_INFO keys, e.g. "2" for second pol
17301799
)
17311800
{
17321801
//workspace for segment retrieval
@@ -1832,11 +1901,11 @@ void MHO_ComputePlotData::dump_multitone_pcmodel(mho_json& plot_dict,
18321901
double ave_pc_mag = MHO_MathUtilities::average(pc_mag_segs);
18331902
if(station_flag == 0)
18341903
{
1835-
plot_dict["PLOT_INFO"]["PCAmpRf"][ch] = ave_pc_mag * 1000.0; //convert to fourfit units (?)
1904+
plot_dict["PLOT_INFO"]["PCAmpRf" + key_suffix][ch] = ave_pc_mag * 1000.0; //convert to fourfit units (?)
18361905
}
18371906
if(station_flag == 1)
18381907
{
1839-
plot_dict["PLOT_INFO"]["PCAmpRm"][ch] = ave_pc_mag * 1000.0;
1908+
plot_dict["PLOT_INFO"]["PCAmpRm" + key_suffix][ch] = ave_pc_mag * 1000.0;
18401909
}
18411910
}
18421911

@@ -1863,21 +1932,21 @@ void MHO_ComputePlotData::dump_multitone_pcmodel(mho_json& plot_dict,
18631932
if(station_flag == 0)
18641933
{
18651934
//convert to degrees
1866-
plot_dict["PLOT_INFO"]["PCPhsRf"][ch] = ave_pc_phase * (180. / M_PI);
1935+
plot_dict["PLOT_INFO"]["PCPhsRf" + key_suffix][ch] = ave_pc_phase * (180. / M_PI);
18671936
for(std::size_t j = 0; j < pc_phase_segs.size(); j++)
18681937
{
18691938
pc_phase_segs[j] *= (180. / M_PI);
18701939
}
1871-
plot_dict["extra"]["ref_mtpc_phase_segs"].push_back(pc_phase_segs);
1940+
plot_dict["extra"]["ref_mtpc_phase_segs" + key_suffix].push_back(pc_phase_segs);
18721941
}
18731942
if(station_flag == 1)
18741943
{
1875-
plot_dict["PLOT_INFO"]["PCPhsRm"][ch] = ave_pc_phase * (180. / M_PI);
1944+
plot_dict["PLOT_INFO"]["PCPhsRm" + key_suffix][ch] = ave_pc_phase * (180. / M_PI);
18761945
for(std::size_t j = 0; j < pc_phase_segs.size(); j++)
18771946
{
18781947
pc_phase_segs[j] *= (180. / M_PI);
18791948
}
1880-
plot_dict["extra"]["rem_mtpc_phase_segs"].push_back(pc_phase_segs);
1949+
plot_dict["extra"]["rem_mtpc_phase_segs" + key_suffix].push_back(pc_phase_segs);
18811950
}
18821951
}
18831952

@@ -1886,19 +1955,20 @@ void MHO_ComputePlotData::dump_multitone_pcmodel(mho_json& plot_dict,
18861955
double ave_pc_delay = MHO_MathUtilities::average(pc_delay_segs);
18871956
if(station_flag == 0)
18881957
{
1889-
plot_dict["PLOT_INFO"]["PCdlyRf"][ch] = ave_pc_delay * 1e9; //convert to ns
1958+
plot_dict["PLOT_INFO"]["PCdlyRf" + key_suffix][ch] = ave_pc_delay * 1e9; //convert to ns
18901959
}
18911960
if(station_flag == 1)
18921961
{
1893-
plot_dict["PLOT_INFO"]["PCdlyRm"][ch] = ave_pc_delay * 1e9;
1962+
plot_dict["PLOT_INFO"]["PCdlyRm" + key_suffix][ch] = ave_pc_delay * 1e9;
18941963
}
18951964
}
18961965
}
18971966
}
18981967

18991968
void MHO_ComputePlotData::dump_manual_pcmodel(mho_json& plot_dict,
1900-
int station_flag, //0 = reference station, 1 = remote station
1901-
std::string pol //single char string
1969+
int station_flag, //0 = reference station, 1 = remote station
1970+
std::string pol, //single char string
1971+
std::string key_suffix //appended to PLOT_INFO keys, e.g. "2" for second pol
19021972
)
19031973
{
19041974
//workspace for segment retrieval
@@ -1927,11 +1997,11 @@ void MHO_ComputePlotData::dump_manual_pcmodel(mho_json& plot_dict,
19271997
{
19281998
if(station_flag == 0)
19291999
{
1930-
plot_dict["PLOT_INFO"]["PCOffRf"][ch] = pc_phase * (180. / M_PI); //convert to fourfit units (?)
2000+
plot_dict["PLOT_INFO"]["PCOffRf" + key_suffix][ch] = pc_phase * (180. / M_PI); //convert to fourfit units (?)
19312001
}
19322002
if(station_flag == 1)
19332003
{
1934-
plot_dict["PLOT_INFO"]["PCOffRm"][ch] = pc_phase * (180. / M_PI);
2004+
plot_dict["PLOT_INFO"]["PCOffRm" + key_suffix][ch] = pc_phase * (180. / M_PI);
19352005
}
19362006
}
19372007
}

0 commit comments

Comments
 (0)