Skip to content

Commit

Permalink
Merge pull request #170 from project8/hotfix/array2vector
Browse files Browse the repository at this point in the history
Hotfix/array2vector
  • Loading branch information
pslocum authored Nov 10, 2020
2 parents c9b6be9 + 788fd9b commit ec8ff02
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 24 deletions.
5 changes: 2 additions & 3 deletions Source/Generators/LMCArraySignalGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,10 @@ namespace locust
if (fabs(EFieldBuffer[channel*fNElementsPerStrip+element].front()) > 0.) // field arrived yet?
{

double* HilbertMagPhaseMean = new double[3];
std::vector<double> HilbertMagPhaseMean; HilbertMagPhaseMean.resize(3);
HilbertMagPhaseMean = fHilbertTransform.GetMagPhaseMean(EFieldBuffer[channel*fNElementsPerStrip+element], EFrequencyBuffer[channel*fNElementsPerStrip+element]);
HilbertMag = HilbertMagPhaseMean[0];
HilbertPhase = HilbertMagPhaseMean[1];
delete[] HilbertMagPhaseMean;

for (int i=0; i < nfilterbins; i++) // populate filter with field.
{
Expand Down Expand Up @@ -438,7 +437,7 @@ namespace locust
Receiver* currentElement = allRxChannels[channelIndex][elementIndex];
sampleIndex = channelIndex*signalSize*aSignal->DecimationFactor() + index; // which channel and which sample

double* tFieldSolution = new double[2];
std::vector<double> tFieldSolution; //tFieldSolution.resize(2);
if (!fTransmitter->IsKassiopeia())
{
tFieldSolution = fTransmitter->GetEFieldCoPol(tTotalElementIndex, 1./(fAcquisitionRate*1.e6*aSignal->DecimationFactor()));
Expand Down
12 changes: 6 additions & 6 deletions Source/Transforms/LMCHilbertTransform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ namespace locust
}


double* HilbertTransform::GetMagPhaseMean(std::deque<double> FieldBuffer, std::deque<double> FrequencyBuffer)
std::vector<double> HilbertTransform::GetMagPhaseMean(std::deque<double> FieldBuffer, std::deque<double> FrequencyBuffer)
{

fftw_complex* transformeddata = Transform( FieldBuffer );
unsigned hilbertindex = fbufferMargin;
double* magphasemean = new double[3];
std::vector<double> magphasemean; magphasemean.resize(3);

double mag = pow(transformeddata[hilbertindex][0]*transformeddata[hilbertindex][0] + transformeddata[hilbertindex][1]*transformeddata[hilbertindex][1], 0.5);
double mean = 0.; // this is set to zero in HilbertTransform::Transform().
Expand Down Expand Up @@ -133,9 +133,9 @@ namespace locust
}


double* HilbertTransform::GetSpan( fftw_complex* array, int IQ, int size )
std::vector<double> HilbertTransform::GetSpan( fftw_complex* array, int IQ, int size )
{
double* span = new double[2];
std::vector<double> span; span.resize(2);
double max = -99.;
double min = 99.;
for (unsigned i=size/4; i<3*size/4; i++)
Expand Down Expand Up @@ -230,8 +230,8 @@ namespace locust
}


double* spanI = GetSpan(originaldata, 0, FieldBuffer.size());
double* spanQ = GetSpan(originaldata, 1, FieldBuffer.size());
std::vector<double> spanI = GetSpan(originaldata, 0, FieldBuffer.size());
std::vector<double> spanQ = GetSpan(originaldata, 1, FieldBuffer.size());

for (int i = 0; i < windowsize; ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Transforms/LMCHilbertTransform.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace locust
HilbertTransform();
virtual ~HilbertTransform();
bool Configure( const scarab::param_node& aNode);
double* GetMagPhaseMean(std::deque<double> FieldBuffer, std::deque<double> FrequencyBuffer);
std::vector<double> GetMagPhaseMean(std::deque<double> FieldBuffer, std::deque<double> FrequencyBuffer);
void SetBufferSize( int aBufferSize );
void SetBufferMargin( int aBufferMargin );
int GetBufferSize();
Expand All @@ -46,7 +46,7 @@ namespace locust
double* GetFrequencyData(std::deque<double> FrequencyBuffer);
double GetMean( std::deque<double> FieldBuffer );
double GetMean( fftw_complex* array, int IQ, int size );
double* GetSpan( fftw_complex* array, int IQ, int size );
std::vector<double> GetSpan( fftw_complex* array, int IQ, int size );
double GetPhase( double VI, double VQ, double VMean);
double QuadrantCorrection( double VI, double HilbertPhase, double HilbertMean );
int fbufferMargin;
Expand Down
4 changes: 2 additions & 2 deletions Source/Transmitters/LMCAntennaSignalTransmitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace locust
}


double* AntennaSignalTransmitter::GetEFieldCoPol(int fieldPointIndex, double dt)
std::vector<double> AntennaSignalTransmitter::GetEFieldCoPol(int fieldPointIndex, double dt)
{
LMCThreeVector pointOfInterest=GetFieldPoint(fieldPointIndex);
double estimatedField=0.0;
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace locust

} // nAntennas

double* FieldSolution = new double[2];
std::vector<double> FieldSolution; FieldSolution.resize(2);
FieldSolution[0] = estimatedField / fTransmitterHardware->GetPropagationDistance(pointOfInterest); // field at point
FieldSolution[1] = 2. * LMCConst::Pi() * fInputFrequency; // rad/s

Expand Down
2 changes: 1 addition & 1 deletion Source/Transmitters/LMCAntennaSignalTransmitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace locust
bool Configure( const scarab::param_node& aNode );

/// Generate the electric field based on the voltage input from the config file and convolution with FIR
virtual double* GetEFieldCoPol(int fieldPointIndex, double dt);
virtual std::vector<double> GetEFieldCoPol(int fieldPointIndex, double dt);

/// Get initial phase delay
double GetInitialPhaseDelay();
Expand Down
5 changes: 3 additions & 2 deletions Source/Transmitters/LMCKassTransmitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace locust
fFieldSolver.AddFieldPoint(fieldPoint);
}

double* KassTransmitter::SolveKassFields(LMCThreeVector pointOfInterest, LMCThreeVector coPolDirection, double tReceiverTime, unsigned tTotalElementIndex)
std::vector<double> KassTransmitter::SolveKassFields(LMCThreeVector pointOfInterest, LMCThreeVector coPolDirection, double tReceiverTime, unsigned tTotalElementIndex)
{

fFieldSolver.SetFieldEvent(tReceiverTime, tTotalElementIndex);
Expand All @@ -63,7 +63,8 @@ namespace locust
double tEFieldCoPol = tRadiatedElectricField.Dot(coPolDirection);
SetIncidentKVector(tTotalElementIndex,tRadiatedElectricField.Cross(tRadiatedMagneticField));

double* tSolution = new double[2];
std::vector<double> tSolution;
tSolution.resize(2);
tSolution[0] = tEFieldCoPol;
tSolution[1] = tDopplerFrequency;

Expand Down
5 changes: 2 additions & 3 deletions Source/Transmitters/LMCKassTransmitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "LMCLienardWiechert.hh"
#include "LMCGlobalsDeclaration.hh"


namespace locust
{

Expand Down Expand Up @@ -44,8 +43,8 @@ namespace locust

virtual bool IsKassiopeia();

double* SolveKassFields(LMCThreeVector pointOfInterest, LMCThreeVector coPolDirection, double tReceiverTime, unsigned tTotalElementIndex);
void InitializeFieldPoint(LMCThreeVector fieldPoint);
std::vector<double> SolveKassFields(LMCThreeVector pointOfInterest, LMCThreeVector coPolDirection, double tReceiverTime, unsigned tTotalElementIndex);
void InitializeFieldPoint(LMCThreeVector fieldPoint);

private:

Expand Down
4 changes: 2 additions & 2 deletions Source/Transmitters/LMCPlaneWaveTransmitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace locust
//fIncidentKVector.SetComponents(cos(fAOI), 0.0, sin(fAOI));
}

double* PlaneWaveTransmitter::GetEFieldCoPol(int fieldPointIndex, double dt)
std::vector<double> PlaneWaveTransmitter::GetEFieldCoPol(int fieldPointIndex, double dt)
{
double initialPhaseDelay = GetPropagationPhaseDelay(fieldPointIndex);
double fieldAmp = fAmplitude;
Expand All @@ -84,7 +84,7 @@ namespace locust
double fieldValue = fieldAmp*cos(fPhaseDelay + initialPhaseDelay);
//AddIncidentKVector(pointOfInterest);

double* fieldSolution = new double[2];
std::vector<double> fieldSolution; fieldSolution.resize(2);
fieldSolution[0] = fieldValue;
fieldSolution[1] = 2. * LMCConst::Pi() * fRF_Frequency; // rad/s

Expand Down
2 changes: 1 addition & 1 deletion Source/Transmitters/LMCPlaneWaveTransmitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace locust

bool Configure( const scarab::param_node& aNode );

virtual double* GetEFieldCoPol(int fieldIndexPoint, double dt);
virtual std::vector<double> GetEFieldCoPol(int fieldIndexPoint, double dt);


private:
Expand Down
4 changes: 2 additions & 2 deletions Source/Transmitters/LMCTransmitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ namespace locust
virtual void TxSayHello();

virtual bool Configure( const scarab::param_node& ){};
virtual double* GetEFieldCoPol(int fieldPointIndex, double dt) {};
virtual std::vector<double> GetEFieldCoPol(int fieldPointIndex, double dt) {};

virtual double* SolveKassFields(LMCThreeVector pointOfInterest, LMCThreeVector coPolDirection, double tReceiverTime, unsigned tTotalElementIndex) {};
virtual std::vector<double> SolveKassFields(LMCThreeVector pointOfInterest, LMCThreeVector coPolDirection, double tReceiverTime, unsigned tTotalElementIndex) {};
virtual void InitializeFieldPoint(LMCThreeVector fieldPoint);

virtual bool IsKassiopeia() {return false;};
Expand Down

0 comments on commit ec8ff02

Please sign in to comment.