Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ad4a8ab
First iteration, xpol is there with issues
Dec 3, 2024
45d22b8
Fixed bugs
Dec 3, 2024
8f40808
Commit to check if condor is having a problem
Dec 6, 2024
57cb153
First iteration of Tx cross-pol
Dec 6, 2024
9aa5eea
Files reading works now
Dec 9, 2024
7a11181
Added setting to (de)activate crosspol responses
Dec 9, 2024
0fa56ea
Deleted print
Dec 9, 2024
46e88a6
Retabbed my birefringence stuff. Don't use vim.
Dec 9, 2024
5844c4a
New antenna factor application ready, will clean comments after modif…
Dec 9, 2024
41acd30
ApplyAntFactors_Tdomain sanity checked! Deleting comments.
Dec 9, 2024
2cc50ab
This is better
Dec 9, 2024
f6b051d
Don't read cross-pol files if not simulating cross-pol
Dec 9, 2024
7412ade
Addec cross-pol responses to the function ApplyAnt_..._FirstTwo
Dec 9, 2024
3f80468
Now go back to 56 frequencies on the files as it used to be
Dec 10, 2024
3eb7177
Deleting debugging prints
Dec 10, 2024
0924797
Rx and Tx crosspol in EVENT_TYPES 11 and 12
Dec 10, 2024
9336007
EVENT_TYPE 11 and 12 usable now! Adding crosspol to neutrinos and arb…
Dec 10, 2024
74e34ef
Read crosspol files always to avoid problems calculating heff_crosspol
Dec 10, 2024
3cab2ff
Addec x-pol to neutrinos, Veff passed. Will finish applying ApplyAntF…
Dec 10, 2024
376d119
Right before touching the InvertAntFactors... functions
Dec 10, 2024
10cb826
Added new invert functions, to invert the new apply functions. Next, …
Dec 10, 2024
cec6eec
Dropped the _new subscripts
Dec 10, 2024
15713d4
Ready to make a pull request, will just sanity check waveforms for th…
Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 113 additions & 66 deletions Detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,7 @@ Detector::Detector(Settings * settings1, IceModel * icesurface, string setupfile

// change coordinate from flat surface to curved Earth surface
//FlattoEarth_ARA(icesurface);

FlattoEarth_ARA_sharesurface(icesurface); // this one will share the lowest surface at each station.

getDiodeModel(settings1); // set diode_real and fdiode_real values.
Expand All @@ -2204,10 +2205,17 @@ inline void Detector::ReadAllAntennaGains(Settings *settings1){
std::string VgainTopFile;
std::string HgainFile;
std::string TxgainFile;
std::string TxgainFileCross;
std::string VgainCrossFile;
std::string VgainTopCrossFile;
std::string HgainCrossFile;


//Adding step to read Tx gain. Will hardcode to PVA gain for now.
TxgainFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/PVA_RealizedGainAndPhase_Copol_Kansas2024.txt";

TxgainFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/PVA_RealizedGainAndPhase_Copol_Kansas2024.txt";
TxgainFileCross = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/PVA_RealizedGainAndPhase_Crosspol_Kansas2024.txt";


if (settings1->ANTENNA_MODE == 0){
// use the orignal Vpol/Hpol gains
VgainFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_bicone6in_output.txt";
Expand Down Expand Up @@ -2256,20 +2264,34 @@ inline void Detector::ReadAllAntennaGains(Settings *settings1){
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";
}

// Add cross-pol gain files
VgainCrossFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_BVpol_RealizedGainAndPhase_Crosspol_Kansas2024.txt";
VgainTopCrossFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_BVpol_RealizedGainAndPhase_Crosspol_Kansas2024.txt"; //Should be TV but it's not working due to a negative SWR (first SWR entry) -ASG 12/09/24
HgainCrossFile = string(getenv("ARA_SIM_DIR"))+"/data/antennas/realizedGain/ARA_Hpol_RealizedGainAndPhase_Crosspol_Kansas2024.txt";



// Check for ALL_ANT_V_ON, then set all antennas to VPol if true
if (settings1->ALL_ANT_V_ON == 1) {
HgainFile = VgainFile;
VgainTopFile = VgainFile;
}

//Read in antenna gain files.
//Read in antenna co-pol gain files.
ReadAntennaGain(VgainFile, settings1, eVPol);
ReadAntennaGain(VgainTopFile, settings1, eVPolTop);
ReadAntennaGain(HgainFile, settings1, eHPol);
ReadAntennaGain(TxgainFile, settings1, eTx);

// Read cross-pol Rx gain files
ReadAntennaGain(VgainCrossFile, settings1, eVPolCross);
ReadAntennaGain(VgainTopCrossFile, settings1, eVPolTopCross);
ReadAntennaGain(HgainCrossFile, settings1, eHPolCross);
ReadAntennaGain(TxgainFileCross, settings1, eTxCross);

}

//Defining function that reads in TX antenna impedances
inline void Detector::ReadAllAntennaImpedance(Settings *settings1) {

Expand Down Expand Up @@ -2312,32 +2334,51 @@ inline void Detector::ReadAntennaGain(string filename, Settings *settings1, EAnt

// make sure dummy variables point to the right variables
switch(type) {
case(eVPol) :
gain = &Vgain;
phase = &Vphase;
transAnt_databin = &transV_databin;
break;
case(eVPolTop) :
gain = &VgainTop;
phase = &VphaseTop;
transAnt_databin = &transVTop_databin;
break;
case(eHPol) :
gain = &Hgain;
phase = &Hphase;
transAnt_databin = &transH_databin;
break;
case(eTx) :
gain = &Txgain;
phase = &Txphase;
break;
default :
throw runtime_error("Unknown antenna type!");
case(eVPol):
gain = &Vgain;
phase = &Vphase;
transAnt_databin = &transV_databin;
break;
case(eVPolTop):
gain = &VgainTop;
phase = &VphaseTop;
transAnt_databin = &transVTop_databin;
break;
case(eHPol):
gain = &Hgain;
phase = &Hphase;
transAnt_databin = &transH_databin;
break;
case(eVPolCross): // Cross-pol VPol
gain = &VgainCross;
phase = &VphaseCross;
transAnt_databin = &transVCross_databin;
break;
case(eVPolTopCross): // Cross-pol VPol Top
gain = &VgainTopCross;
phase = &VphaseTopCross;
transAnt_databin = &transVTopCross_databin;
break;
case(eHPolCross): // Cross-pol HPol
gain = &HgainCross;
phase = &HphaseCross;
transAnt_databin = &transHCross_databin;
break;
case(eTx):
gain = &Txgain;
phase = &Txphase;
break;
case(eTxCross):
gain = &TxgainCross;
phase = &TxphaseCross;
break;
default:
throw runtime_error("Unknown antenna type!");
}

// open the requested file
ifstream NecOut( filename.c_str() );

// initialize some variables used for read-in
const int N = freq_step;
double Transm[N];
Expand Down Expand Up @@ -2419,7 +2460,7 @@ inline void Detector::ReadAntennaGain(string filename, Settings *settings1, EAnt
// check the line is what we expected (gain for a particular theta/phi)
if(words.size() != 5)
throw runtime_error("Antenna gain file data line not properly formatted! "+filename);

// save dB gain and phase and check they are sensible
double thisdBGain = stof(words[2]);
double thisPhase = stof(words[4]);
Expand Down Expand Up @@ -2837,7 +2878,7 @@ double Detector::GetAntPhase( double freq, double theta, double phi, int ant_m )
}


double Detector::GetGain_1D_OutZero( double freq, double theta, double phi, int ant_m, int string_number, int ant_number, bool useInTransmitterMode) {
double Detector::GetGain_1D_OutZero( double freq, double theta, double phi, int ant_m, int string_number, int ant_number, bool useInTransmitterMode, bool useCrossPol) {

/*
The purpose of this function is to interpolate the globally defined gain arrays (Vgain, VgainTop, Hgain, Txgain)
Expand All @@ -2849,37 +2890,40 @@ double Detector::GetGain_1D_OutZero( double freq, double theta, double phi, int

//Assign local pointer to gain array specified in the function argument
//VPol Rx
if ( Detector_mode == 5 ){ // Phased Array mode
if ( useInTransmitterMode ) tempGain = &Txgain; // Transmitter mode
else if ( ant_m == 1 ) tempGain = &Hgain; // PA Hpols
else {
if ( string_number == 0 ) tempGain = &Vgain; // PA Vpols
else {
if ( ant_number == 1 ) tempGain = &VgainTop; // A5 Top VPols
else tempGain = &Vgain; // A5 Bottom Vpols
if (Detector_mode == 5) { // Phased Array mode
if (useInTransmitterMode) {
tempGain = useCrossPol ? &TxgainCross : &Txgain; // Transmitter mode
} else if (ant_m == 1) {
tempGain = useCrossPol ? &HgainCross : &Hgain; // HPol
} else { // VPol
if (string_number == 0) {
tempGain = useCrossPol ? &VgainCross : &Vgain;
} else {
if (ant_number == 1) {
tempGain = useCrossPol ? &VgainTopCross : &VgainTop; // A5 Top VPols
} else {
tempGain = useCrossPol ? &VgainCross : &Vgain; // A5 Bottom VPols
}
}
}
}
else { // Traditional Station mode
if ( ant_m == 0 and not useInTransmitterMode) {
if (ant_number == 0) {
tempGain = &Vgain;
}
else if (ant_number == 2) {
tempGain = &VgainTop;
} else { // Traditional Station mode
if (!useInTransmitterMode) {
if (ant_m == 0) { // VPol
if (ant_number == 0) {
tempGain = useCrossPol ? &VgainCross : &Vgain;
} else if (ant_number == 2) {
tempGain = useCrossPol ? &VgainTopCross : &VgainTop;
}
} else if (ant_m == 1) { // HPol
tempGain = useCrossPol ? &HgainCross : &Hgain;
}
} else { // Tx mode
tempGain = useCrossPol ? &TxgainCross : &Txgain;
}
//HPol Rx
else if ( ant_m == 1 and not useInTransmitterMode) {
tempGain = &Hgain;
}
//Tx
else if (useInTransmitterMode) {
tempGain = &Txgain;
}
else {
throw runtime_error("In GetGain_1D_OutZero: No appropriate gain model for this simulation setup.");
}
}

if (!tempGain) {
throw runtime_error("In GetGain_1D_OutZero: No appropriate gain model for this simulation setup.");
}

// check if angles range actually theta 0-180, phi 0-360
Expand Down Expand Up @@ -2984,22 +3028,25 @@ double Detector::GetImpedance( double freq, int ant_m, int ant_number, bool useI



double Detector::GetAntPhase_1D( double freq, double theta, double phi, int ant_m, bool useInTransmitterMode ) {
double Detector::GetAntPhase_1D( double freq, double theta, double phi, int ant_m, bool useInTransmitterMode, bool useCrossPol ) {

//Creating tempPhase array to make this function more dynamic for Rx and Tx mode.
double (*tempPhase)[freq_step_max][ang_step_max] = nullptr;

//VPol Rx
if ( ant_m == 0 and not useInTransmitterMode) {
tempPhase = &Vphase;
}
//HPol Rx
else if ( ant_m == 1 and not useInTransmitterMode) {
tempPhase = &Hphase;

// Assign tempPhase based on polarization type and cross-pol flag
if (!useInTransmitterMode) {
if (ant_m == 0) { // VPol
tempPhase = useCrossPol ? &VphaseCross : &Vphase;
} else if (ant_m == 1) { // HPol
tempPhase = useCrossPol ? &HphaseCross : &Hphase;
}
} else { // Transmitter mode
tempPhase = useCrossPol ? &TxphaseCross : &Txphase;
}
//Tx
else if (useInTransmitterMode) {
tempPhase = &Txphase;

if (!tempPhase) {
throw runtime_error("In GetAntPhase_1D: No appropriate phase model for this simulation setup.");
}

// check if angles range actually theta 0-180, phi 0-360
Expand Down Expand Up @@ -3479,7 +3526,7 @@ inline void Detector::FlattoEarth_ARA(IceModel *icesurface) {


inline void Detector::FlattoEarth_ARA_sharesurface(IceModel *icesurface) { // each station share the lowest surface

double Dist = 0.; //for sqrt(x^2 + y^2)
double R1 = icesurface->Surface(0.,0.); // from core of earth to surface at theta, phi = 0.
//--------------------------------------------------
Expand Down
28 changes: 25 additions & 3 deletions Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ enum EAntennaType {
eVPol, // (bottom) Vpol
eVPolTop, // top Vpol
eHPol, // Hpol
eTx // transmitter
eTx, // transmitter
eTxCross, // transmitter
eVPolCross, // Cross-pol VPol
eVPolTopCross, // Cross-pol VPol Top
eHPolCross // Cross-pol HPol
};

class Detector {
Expand All @@ -234,6 +238,14 @@ class Detector {
double Hgain[freq_step_max][ang_step_max];
double Hphase[freq_step_max][ang_step_max];
double Freq[freq_step_max];

// Cross-pol arrays
double VgainCross[freq_step_max][ang_step_max];
double VphaseCross[freq_step_max][ang_step_max];
double VgainTopCross[freq_step_max][ang_step_max];
double VphaseTopCross[freq_step_max][ang_step_max];
double HgainCross[freq_step_max][ang_step_max];
double HphaseCross[freq_step_max][ang_step_max];

//Define impedance and gain for receiving antenna
double RealImpedanceV[freq_step_max];
Expand All @@ -248,6 +260,11 @@ class Detector {
double ImagImpedanceTx[freq_step_max];
double Txgain[freq_step_max][ang_step_max];
double Txphase[freq_step_max][ang_step_max];


double TxgainCross[freq_step_max][ang_step_max];
double TxphaseCross[freq_step_max][ang_step_max];

void ReadImpedance(string filename, double (*TempRealImpedance)[freq_step_max], double (*TempImagImpedance)[freq_step_max]);
void ReadAllAntennaImpedance(Settings *settings1);

Expand Down Expand Up @@ -340,6 +357,11 @@ class Detector {
vector <double> transVTop_databin;
vector <double> transH_databin;

// Cross-pol data bins
std::vector<double> transVCross_databin;
std::vector<double> transVTopCross_databin;
std::vector<double> transHCross_databin;


void ReadAmplifierNoiseFigure(Settings *settings1);
vector< vector<double> > amplifierNoiseFig_ch;
Expand Down Expand Up @@ -376,7 +398,7 @@ class Detector {
double GetGain(double freq, double theta, double phi, int ant_m, int ant_o); //read antenna gain at certain angle, certain type, and certain orientation
double GetGain(double freq, double theta, double phi, int ant_m); //read antenna gain at certain angle, certain type. (orientation : default)

double GetGain_1D_OutZero(double freq, double theta, double phi, int ant_m, int string_number=0, int ant_number=0, bool useInTransmitterMode=false); //read antenna gain at certain angle, certain type. (orientation : default) and use 1-D interpolation to get gain, if freq bigger than freq range, return 0 gain
double GetGain_1D_OutZero(double freq, double theta, double phi, int ant_m, int string_number=0, int ant_number=0, bool useInTransmitterMode=false, bool useCrossPol=false); //read antenna gain at certain angle, certain type. (orientation : default) and use 1-D interpolation to get gain, if freq bigger than freq range, return 0 gain

//Creating function to interpolate antenna impedance to frequency binning.
double GetImpedance(double freq, int ant_m=0, int ant_number=0, bool useInTransmitterMode=false);
Expand All @@ -386,7 +408,7 @@ class Detector {

double GetAntPhase(double freq, double theta, double phi, int ant_m); // return antenna phase with 2-D interpolation

double GetAntPhase_1D(double freq, double theta, double phi, int ant_m, bool useInTransmitterMode=false); // return antenna phase with 1-D interpolation
double GetAntPhase_1D(double freq, double theta, double phi, int ant_m, bool useInTransmitterMode=false, bool useCrossPol=false); // return antenna phase with 1-D interpolation


double GetFilterGain(int bin) { return FilterGain[bin]; } // same bin with Vgain, Hgain
Expand Down
Loading