From 380f239df4f66c12e99cfbbb22e2e3e0ed101fde Mon Sep 17 00:00:00 2001 From: jacobweiler Date: Tue, 10 Jun 2025 15:03:39 -0400 Subject: [PATCH 1/5] Added custom filepath read-in for beampattern in setup file --- AraSim.cc | 6 ++++++ Detector.cc | 8 ++++---- Settings.cc | 35 ++++++++++++++++++++++++++++++++++- Settings.h | 5 ++++- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/AraSim.cc b/AraSim.cc index 0aff60d1..f160dd68 100644 --- a/AraSim.cc +++ b/AraSim.cc @@ -73,6 +73,9 @@ int main(int argc, char **argv) { // read setup.txt file cout<<"MOOREBAY : "<MOOREBAY<EXPONENT<DETECTOR<VPOL_BEAMPATTERN )<VTOP_BEAMPATTERN )<HPOL_BEAMPATTERN )<DETECTOR<POSNU_RADIUS<EVENT_GENERATION_MODE << endl; + cout<<"VPOL_BEAMPATTERN : "<< string( settings1->VPOL_BEAMPATTERN )<VTOP_BEAMPATTERN )<HPOL_BEAMPATTERN )<EVENT_GENERATION_MODE == 1){ string evtfile = string(argv[argc - 1]); diff --git a/Detector.cc b/Detector.cc index 81ac7f59..29a678fb 100644 --- a/Detector.cc +++ b/Detector.cc @@ -2300,10 +2300,10 @@ inline void Detector::ReadAllAntennaGains(Settings *settings1){ VgainTopFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_TVpol_RealizedGainAndPhase_Copol_Kansas2024.txt"; HgainFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_Hpol_RealizedGainAndPhase_Copol_Kansas2024.txt"; } - else if (settings1->ANTENNA_MODE == 6) { //Adding antenna mode for custom gains. - VgainFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_BVpol_RealizedGainAndPhase_Copol_Custom.txt"; - VgainTopFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_TVpol_RealizedGainAndPhase_Copol_Custom.txt"; - HgainFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_Hpol_RealizedGainAndPhase_Copol_Custom.txt"; + else if (settings1->ANTENNA_MODE == 6) { //Adding antenna mode for custom gains (takes full path). + VgainFile = string( settings1->VPOL_BEAMPATTERN ); + VgainTopFile = string( settings1->VTOP_BEAMPATTERN ); + HgainFile = string( settings1->HPOL_BEAMPATTERN ); } // Check for ALL_ANT_V_ON, then set all antennas to VPol if true diff --git a/Settings.cc b/Settings.cc index 745a76d3..746650e4 100644 --- a/Settings.cc +++ b/Settings.cc @@ -34,7 +34,7 @@ void Settings::Initialize() { NDISCONES_PASS=3; DEBUG=false; // debugging option -outputdir="outputs"; // directory where outputs go + outputdir="outputs"; // directory where outputs go FREQ_LOW_SEAVEYS=200.E6; FREQ_HIGH_SEAVEYS=1200.E6; BW_SEAVEYS=FREQ_HIGH_SEAVEYS-FREQ_LOW_SEAVEYS; @@ -46,6 +46,9 @@ outputdir="outputs"; // directory where outputs go SIGMA_SELECT=0; // when in SIGMAPARAM=1 case, 0 : (default) use mean value, 1 : use upper bound, 2 : use lower bound +HPOL_BEAMPATTERN="./data/antennas/realizedGain/ARA_dipoletest1_output.txt"; // Default to original Ara Data +VTOP_BEAMPATTERN="./data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data +VPOL_BEAMPATTERN="./data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data // end of values from icemc @@ -727,6 +730,36 @@ void Settings::ReadFile(string setupfile) { else if (label == "ANTENNA_MODE"){ ANTENNA_MODE = atoi(line.substr(line.find_first_of("=") + 1).c_str()); } + else if (label == "VPOL_BEAMPATTERN"){ + size_t pos = line.find("="); // Variable position + size_t comment_pos = line.find("//", pos); // Comment Position + string fileloc = (comment_pos != string::npos) ? line.substr(pos + 1, comment_pos - pos - 1) : line.substr(pos + 1); + size_t start = fileloc.find_first_not_of(" \t\""); + size_t end = fileloc.find_last_not_of(" \t\""); + fileloc = fileloc.substr(start, end - start + 1); + + VPOL_BEAMPATTERN = fileloc; + } + else if (label == "VTOP_BEAMPATTERN"){ + size_t pos = line.find("="); // Variable position + size_t comment_pos = line.find("//", pos); // Comment Position + string fileloc = (comment_pos != string::npos) ? line.substr(pos + 1, comment_pos - pos - 1) : line.substr(pos + 1); + size_t start = fileloc.find_first_not_of(" \t\""); + size_t end = fileloc.find_last_not_of(" \t\""); + fileloc = fileloc.substr(start, end - start + 1); + + VTOP_BEAMPATTERN = fileloc; + } + else if (label == "HPOL_BEAMPATTERN"){ + size_t pos = line.find("="); // Variable position + size_t comment_pos = line.find("//", pos); // Comment Position + string fileloc = (comment_pos != string::npos) ? line.substr(pos + 1, comment_pos - pos - 1) : line.substr(pos + 1); + size_t start = fileloc.find_first_not_of(" \t\""); + size_t end = fileloc.find_last_not_of(" \t\""); + fileloc = fileloc.substr(start, end - start + 1); + + HPOL_BEAMPATTERN = fileloc; + } else if (label == "IMPEDANCE_RX_VPOL"){ IMPEDANCE_RX_VPOL = atoi(line.substr(line.find_first_of("=") + 1).c_str()); } diff --git a/Settings.h b/Settings.h index cf46fec5..5ab3abc4 100644 --- a/Settings.h +++ b/Settings.h @@ -320,7 +320,10 @@ class Settings // 5: use the Kansas lab measurements that treat top and bottom vpol separately. // 6: Uses custom antenna models that the user can specify with the custom files in data/antennas/realizedGain // The related wiki page for antenna models description:http://ara.icecube.wisc.edu/wiki/index.php/Antenna_model - + // Beampattern filepath strings + string VPOL_BEAMPATTERN; + string VTOP_BEAMPATTERN; + string HPOL_BEAMPATTERN; //Impedances of RX and TX antennas. All use the numbering scheme below: // 0: Simple 50 Ohm impedance model that matches the Zr=50 that's been historically used in AraSim // 1: Bottom VPol impedance model measured by Mohammad at Kansas From f5c1b2819a69c2fcbeb79082d327611f5f2e4e36 Mon Sep 17 00:00:00 2001 From: jacobweiler Date: Fri, 4 Jul 2025 12:58:16 -0400 Subject: [PATCH 2/5] Pull request changes - Changed language from beampattern to gain_file - Added warning if custom file name set but not in antenna_mode = 6 - Functionalized the parsing of the file paths from the settings file - Formatting changes --- AraSim.cc | 6 ------ Detector.cc | 6 +++--- Settings.cc | 62 ++++++++++++++++++++++++++--------------------------- Settings.h | 7 +++--- 4 files changed, 37 insertions(+), 44 deletions(-) diff --git a/AraSim.cc b/AraSim.cc index f160dd68..0aff60d1 100644 --- a/AraSim.cc +++ b/AraSim.cc @@ -73,9 +73,6 @@ int main(int argc, char **argv) { // read setup.txt file cout<<"MOOREBAY : "<MOOREBAY<EXPONENT<DETECTOR<VPOL_BEAMPATTERN )<VTOP_BEAMPATTERN )<HPOL_BEAMPATTERN )<DETECTOR<POSNU_RADIUS<EVENT_GENERATION_MODE << endl; - cout<<"VPOL_BEAMPATTERN : "<< string( settings1->VPOL_BEAMPATTERN )<VTOP_BEAMPATTERN )<HPOL_BEAMPATTERN )<EVENT_GENERATION_MODE == 1){ string evtfile = string(argv[argc - 1]); diff --git a/Detector.cc b/Detector.cc index 29a678fb..f8bbe6fc 100644 --- a/Detector.cc +++ b/Detector.cc @@ -2301,9 +2301,9 @@ inline void Detector::ReadAllAntennaGains(Settings *settings1){ HgainFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_Hpol_RealizedGainAndPhase_Copol_Kansas2024.txt"; } else if (settings1->ANTENNA_MODE == 6) { //Adding antenna mode for custom gains (takes full path). - VgainFile = string( settings1->VPOL_BEAMPATTERN ); - VgainTopFile = string( settings1->VTOP_BEAMPATTERN ); - HgainFile = string( settings1->HPOL_BEAMPATTERN ); + VgainFile = string( settings1->VPOL_GAIN_FILE ); + VgainTopFile = string( settings1->VTOP_GAIN_FILE ); + HgainFile = string( settings1->HPOL_GAIN_FILE ); } // Check for ALL_ANT_V_ON, then set all antennas to VPol if true diff --git a/Settings.cc b/Settings.cc index 7efe38ca..41b4da04 100644 --- a/Settings.cc +++ b/Settings.cc @@ -46,9 +46,9 @@ void Settings::Initialize() { SIGMA_SELECT=0; // when in SIGMAPARAM=1 case, 0 : (default) use mean value, 1 : use upper bound, 2 : use lower bound -HPOL_BEAMPATTERN="./data/antennas/realizedGain/ARA_dipoletest1_output.txt"; // Default to original Ara Data -VTOP_BEAMPATTERN="./data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data -VPOL_BEAMPATTERN="./data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data + HPOL_GAIN_FILE="./data/antennas/realizedGain/ARA_dipoletest1_output.txt"; // Default to original Ara Data + VTOP_GAIN_FILE="./data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data + VPOL_GAIN_FILE="./data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data // end of values from icemc @@ -730,35 +730,14 @@ void Settings::ReadFile(string setupfile) { else if (label == "ANTENNA_MODE"){ ANTENNA_MODE = atoi(line.substr(line.find_first_of("=") + 1).c_str()); } - else if (label == "VPOL_BEAMPATTERN"){ - size_t pos = line.find("="); // Variable position - size_t comment_pos = line.find("//", pos); // Comment Position - string fileloc = (comment_pos != string::npos) ? line.substr(pos + 1, comment_pos - pos - 1) : line.substr(pos + 1); - size_t start = fileloc.find_first_not_of(" \t\""); - size_t end = fileloc.find_last_not_of(" \t\""); - fileloc = fileloc.substr(start, end - start + 1); - - VPOL_BEAMPATTERN = fileloc; + else if (label == "VPOL_GAIN_FILE") { + VPOL_GAIN_FILE = ParseFilePath(line); } - else if (label == "VTOP_BEAMPATTERN"){ - size_t pos = line.find("="); // Variable position - size_t comment_pos = line.find("//", pos); // Comment Position - string fileloc = (comment_pos != string::npos) ? line.substr(pos + 1, comment_pos - pos - 1) : line.substr(pos + 1); - size_t start = fileloc.find_first_not_of(" \t\""); - size_t end = fileloc.find_last_not_of(" \t\""); - fileloc = fileloc.substr(start, end - start + 1); - - VTOP_BEAMPATTERN = fileloc; + else if (label == "VTOP_GAIN_FILE") { + VTOP_GAIN_FILE = ParseFilePath(line); } - else if (label == "HPOL_BEAMPATTERN"){ - size_t pos = line.find("="); // Variable position - size_t comment_pos = line.find("//", pos); // Comment Position - string fileloc = (comment_pos != string::npos) ? line.substr(pos + 1, comment_pos - pos - 1) : line.substr(pos + 1); - size_t start = fileloc.find_first_not_of(" \t\""); - size_t end = fileloc.find_last_not_of(" \t\""); - fileloc = fileloc.substr(start, end - start + 1); - - HPOL_BEAMPATTERN = fileloc; + else if (label == "HPOL_GAIN_FILE") { + HPOL_GAIN_FILE = ParseFilePath(line); } else if (label == "IMPEDANCE_RX_VPOL"){ IMPEDANCE_RX_VPOL = atoi(line.substr(line.find_first_of("=") + 1).c_str()); @@ -795,8 +774,12 @@ void Settings::ReadFile(string setupfile) { SOURCE_DEPTH = atof(line.substr(line.find_first_of("=") + 1).c_str()); } - - + if (ANTENNA_MODE != 6) { + if (!VPOL_GAIN_FILE.empty() || !VTOP_GAIN_FILE.empty() || !HPOL_GAIN_FILE.empty()) { + std::cerr << "Warning: Custom GAIN_FILE paths provided, " + << "but ANTENNA_MODE != 6. These files may be ignored." << std::endl; + } + } } } @@ -1181,3 +1164,18 @@ void Settings::SetGitCommitHash(){ std::cout<<"The Git Commit Hash: "< Date: Mon, 7 Jul 2025 12:33:30 -0400 Subject: [PATCH 3/5] Added less strict parsing requirements for file path - Now to define file path you just need the path in double quotes after an equal sign --- Settings.cc | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Settings.cc b/Settings.cc index 41b4da04..ce670a99 100644 --- a/Settings.cc +++ b/Settings.cc @@ -732,12 +732,21 @@ void Settings::ReadFile(string setupfile) { } else if (label == "VPOL_GAIN_FILE") { VPOL_GAIN_FILE = ParseFilePath(line); + if (VPOL_GAIN_FILE.empty()) { + std::cerr << "Warning: could not parse path from line: " << line << std::endl; + } } else if (label == "VTOP_GAIN_FILE") { VTOP_GAIN_FILE = ParseFilePath(line); + if (VTOP_GAIN_FILE.empty()) { + std::cerr << "Warning: could not parse path from line: " << line << std::endl; + } } else if (label == "HPOL_GAIN_FILE") { HPOL_GAIN_FILE = ParseFilePath(line); + if (HPOL_GAIN_FILE.empty()) { + std::cerr << "Warning: could not parse path from line: " << line << std::endl; + } } else if (label == "IMPEDANCE_RX_VPOL"){ IMPEDANCE_RX_VPOL = atoi(line.substr(line.find_first_of("=") + 1).c_str()); @@ -1165,17 +1174,21 @@ void Settings::SetGitCommitHash(){ } std::string Settings::ParseFilePath(const std::string& line) { - size_t pos = line.find("="); // Variable position - size_t comment_pos = line.find("//", pos); // Comment Position + size_t eq_pos = line.find('='); + if (eq_pos == std::string::npos) { + return ""; + } - std::string fileloc = (comment_pos != std::string::npos) - ? line.substr(pos + 1, comment_pos - pos - 1) - : line.substr(pos + 1); + // Search for the first quote after the '=' + size_t quote_start = line.find('"', eq_pos); + if (quote_start == std::string::npos) { + return ""; + } - size_t start = fileloc.find_first_not_of(" \t\""); - size_t end = fileloc.find_last_not_of(" \t\""); - if (start != std::string::npos && end != std::string::npos) { - fileloc = fileloc.substr(start, end - start + 1); + size_t quote_end = line.find('"', quote_start + 1); + if (quote_end == std::string::npos) { + return ""; } - return fileloc; + + return line.substr(quote_start + 1, quote_end - quote_start - 1); } \ No newline at end of file From c41bfe2aa954b4911edff64af9186d71553e2ae3 Mon Sep 17 00:00:00 2001 From: jacobweiler Date: Tue, 15 Jul 2025 10:05:27 -0400 Subject: [PATCH 4/5] Fixed default path to gain files + crashes when erroring --- Settings.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Settings.cc b/Settings.cc index ce670a99..87d7bfba 100644 --- a/Settings.cc +++ b/Settings.cc @@ -46,9 +46,9 @@ void Settings::Initialize() { SIGMA_SELECT=0; // when in SIGMAPARAM=1 case, 0 : (default) use mean value, 1 : use upper bound, 2 : use lower bound - HPOL_GAIN_FILE="./data/antennas/realizedGain/ARA_dipoletest1_output.txt"; // Default to original Ara Data - VTOP_GAIN_FILE="./data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data - VPOL_GAIN_FILE="./data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data + HPOL_GAIN_FILE=string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_dipoletest1_output.txt"; // Default to original Ara Data + VTOP_GAIN_FILE=string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data + VPOL_GAIN_FILE=string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_bicone6in_output.txt"; // Default to original Ara Data // end of values from icemc @@ -734,18 +734,24 @@ void Settings::ReadFile(string setupfile) { VPOL_GAIN_FILE = ParseFilePath(line); if (VPOL_GAIN_FILE.empty()) { std::cerr << "Warning: could not parse path from line: " << line << std::endl; + std::cerr << "Example Input: VPOL_GAIN_FILE=\"path/to/gain/file.txt\"" << std::endl; + std::abort(); } } else if (label == "VTOP_GAIN_FILE") { VTOP_GAIN_FILE = ParseFilePath(line); if (VTOP_GAIN_FILE.empty()) { std::cerr << "Warning: could not parse path from line: " << line << std::endl; + std::cerr << "Example Input: VTOP_GAIN_FILE=\"path/to/gain/file.txt\"" << std::endl; + std::abort(); } } else if (label == "HPOL_GAIN_FILE") { HPOL_GAIN_FILE = ParseFilePath(line); if (HPOL_GAIN_FILE.empty()) { std::cerr << "Warning: could not parse path from line: " << line << std::endl; + std::cerr << "Example Input: HPOL_GAIN_FILE=\"path/to/gain/file.txt\"" << std::endl; + std::abort(); } } else if (label == "IMPEDANCE_RX_VPOL"){ From 72d474de23d4b53b152022dd23d27937af1fb102 Mon Sep 17 00:00:00 2001 From: jacobweiler Date: Wed, 16 Jul 2025 08:30:07 -0400 Subject: [PATCH 5/5] Moved antenna mode check - moved to same area as other error checking if statements to have it not accidentally trigger --- Settings.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Settings.cc b/Settings.cc index 87d7bfba..b1514e8f 100644 --- a/Settings.cc +++ b/Settings.cc @@ -789,13 +789,6 @@ void Settings::ReadFile(string setupfile) { SOURCE_DEPTH = atof(line.substr(line.find_first_of("=") + 1).c_str()); } - if (ANTENNA_MODE != 6) { - if (!VPOL_GAIN_FILE.empty() || !VTOP_GAIN_FILE.empty() || !HPOL_GAIN_FILE.empty()) { - std::cerr << "Warning: Custom GAIN_FILE paths provided, " - << "but ANTENNA_MODE != 6. These files may be ignored." << std::endl; - } - } - } } setFile.close(); @@ -1166,6 +1159,16 @@ int Settings::CheckCompatibilitiesSettings() { num_err++; } + // checking antenna mode + if (ANTENNA_MODE != 6) { + if (!VPOL_GAIN_FILE.empty() || !VTOP_GAIN_FILE.empty() || !HPOL_GAIN_FILE.empty()) { + std::cerr << "Warning: Custom GAIN_FILE paths provided, " + << "but ANTENNA_MODE != 6. These files may be ignored." << std::endl; + num_err++; + } + } + + return num_err; }