Skip to content

Commit

Permalink
Merge pull request #94 from project8/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pslocum authored Oct 8, 2019
2 parents 23d3703 + c553cb2 commit 51b0853
Show file tree
Hide file tree
Showing 60 changed files with 2,465 additions and 4,379 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ set_property( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFI
set (LOCUST_MC_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/Source/Generators/
${CMAKE_CURRENT_SOURCE_DIR}/Source/Transmitters/
${CMAKE_CURRENT_SOURCE_DIR}/Source/RxComponents/
${CMAKE_CURRENT_SOURCE_DIR}/Source/Transforms/
${CMAKE_CURRENT_SOURCE_DIR}/Source/Core/
${CMAKE_CURRENT_SOURCE_DIR}/Source/Kassiopeia/
Expand Down
16 changes: 7 additions & 9 deletions Config/Tutorial/LocustDrivingAntennaTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,22 @@

"simulation":
{
"egg-filename": "/home/penny/locust_mc/cbuild/bin/locust_mc.egg",
"egg-filename": "/Users/psurukuc/P8/Apps/locust_mc/run_dir/locust_mc.egg",
"n-records": 1,
"record-size": 81920,
"n-channels": 1
},


"gaussian-noise":

"lpf-fft":
{
"noise-floor": 4.2e-22,
"domain": "time"
},

"digitizer":
{
"v-range": 3.0e-8,
"v-offset": -1.5e-8
},

"decimate-signal":
{
}

}

10 changes: 9 additions & 1 deletion Config/Tutorial/LocustFakeTrack.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

"simulation":
{
"egg-filename": "/home/penny/locust_mc/cbuild/bin/locust.egg",
"egg-filename": "/Users/psurukuc/P8/Apps/locust_mc/run_dir/locust_mc.egg",
"n-records": 1,
"n-channels": 1,
"record-size": 4194304
Expand All @@ -44,6 +44,14 @@
{
"v-range": 1.0e-5,
"v-offset": -0.5e-5
},

"decimate-signal":
{
},

"lpf-fft":
{
}

}
32 changes: 15 additions & 17 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ set( LOCUST_MC_HEADER_FILES
Core/LMCSimulationController.hh
Core/LMCThreeVector.hh
Core/LMCVisitor.hh
Core/LMCPowerCombiner.hh
Core/LMCReceiver.hh
Core/LMCPatchAntenna.hh
Core/LMCChannel.hh
Core/LMCFIRHandler.hh

Generators/LMCDigitizer.hh
Generators/LMCGaussianNoiseGenerator.hh
Generators/LMCTestSignalGenerator.hh
Generators/LMCTestFIRFilterGenerator.hh
Generators/LMCDecimateSignalGenerator.hh
Generators/LMCLowPassFilterFFTGenerator.hh
Generators/LMCHighPassFilterFFTGenerator.hh
Expand All @@ -50,13 +46,15 @@ set( LOCUST_MC_HEADER_FILES
Generators/LMCDipoleSignalGenerator.cc
Generators/LMCPlaneWaveSignalGenerator.hh

Transmitters/LMCFieldEstimator.hh
Transmitters/LMCFieldBuffer.hh
Transmitters/LMCAntennaSignalTransmitter.hh
Transforms/LMCHilbertTransform.hh

# Generators/LMCBasebandTrackGenerator.hh
# Generators/LMCTrappedElectronGenerator.hh

RxComponents/LMCPowerCombiner.hh
RxComponents/LMCReceiver.hh
RxComponents/LMCPatchAntenna.hh
RxComponents/LMCChannel.hh

)


Expand All @@ -70,15 +68,11 @@ set( LOCUST_MC_SOURCE_FILES
Core/LMCSimulationController.cc
Core/LMCThreeVector.cc
Core/LMCVisitor.cc
Core/LMCPatchAntenna.cc
Core/LMCChannel.cc
Core/LMCPowerCombiner.cc
Core/LMCReceiver.cc
Core/LMCFIRHandler.cc

Generators/LMCDigitizer.cc
Generators/LMCGaussianNoiseGenerator.cc
Generators/LMCTestSignalGenerator.cc
Generators/LMCTestFIRFilterGenerator.cc
Generators/LMCDecimateSignalGenerator.cc
Generators/LMCLowPassFilterFFTGenerator.cc
Generators/LMCHighPassFilterFFTGenerator.cc
Expand All @@ -87,13 +81,15 @@ set( LOCUST_MC_SOURCE_FILES
Generators/LMCDipoleSignalGenerator.cc
Generators/LMCPlaneWaveSignalGenerator.cc

Transmitters/LMCFieldEstimator.cc
Transmitters/LMCFieldBuffer.cc
Transmitters/LMCAntennaSignalTransmitter.cc
Transforms/LMCHilbertTransform.cc

RxComponents/LMCPowerCombiner.cc
RxComponents/LMCReceiver.cc
RxComponents/LMCPatchAntenna.cc
RxComponents/LMCChannel.cc

# Generators/LMCBasebandTrackGenerator.cc
# Generators/LMCTrappedElectronGenerator.cc
)

if (locust_mc_BUILD_WITH_KASSIOPEIA)
Expand All @@ -107,6 +103,7 @@ if (locust_mc_BUILD_WITH_KASSIOPEIA)
Core/LMCGlobalsDeclaration.hh
Core/LMCGlobalsDefinition.hh
Core/LMCParticle.hh
Core/LMCLienardWiechert.hh
Core/LMCHFSSReader.hh

Kassiopeia/LMCCyclotronRadiationExtractor.hh
Expand All @@ -126,6 +123,7 @@ if (locust_mc_BUILD_WITH_KASSIOPEIA)

Core/LMCHFSSReader.cc
Core/LMCParticle.cc
Core/LMCLienardWiechert.cc

Kassiopeia/LMCFieldCalculator.cc
Kassiopeia/LMCFieldCalculatorBuilder.cc
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/LMCException.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define LMCEXCEPTION_HH_

#include <sstream>
//#include <Exception> // pls edit
//#include <Exception>

namespace locust
{
Expand Down
130 changes: 130 additions & 0 deletions Source/Core/LMCFIRHandler.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* LMCFIRHandlerCore.cc
*
* Created on: May 11, 2018
* Author: P. T. Surukuchi
*/

#include "LMCConst.hh"
#include "LMCFIRHandler.hh"

#include "logger.hh"

namespace locust
{
LOGGER( lmclog, "FIRHandlerCore" );

FIRHandlerCore::FIRHandlerCore():
fNFIRBins(-99),
fFIRResolution(1e-12),
fNFIRSkips(1)
{
}

FIRHandlerCore::~FIRHandlerCore()
{
}

bool FIRHandlerCore::Configure(const scarab::param_node& aParam)
{
return true;
}

bool FIRHandlerCore::ends_with(const std::string &str, const std::string &suffix)
{
//copied from https://stackoverflow.com/a/20446239
return str.size() >= suffix.size() &&
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
}

bool FIRHandlerCore::ReadFIRFile()
{
fNFIRBins=0;
if(!ends_with(fFIRFilename,".txt"))
{
LERROR(lmclog,"The FIR file should end in .txt");
return false;
}
double firIndex;
double filterMagnitude;
FILE *firFile;
firFile=fopen(fFIRFilename.c_str(),"r");
//logic copied from /LMCPatchSignalGenerator.cc
int count=0;
while (!feof(firFile)){
fscanf(firFile,"%lf %lf",&firIndex,&filterMagnitude);
if (count%fNFIRSkips==0)
{
fFIRFilter.push_back(filterMagnitude);
++fNFIRBins;
}
++count;
}
fclose(firFile);
return true;
}

double FIRHandlerCore::ConvolveWithFIRFilter(std::deque<double> delayedVoltageBuffer)
{
double convolution=0.0;
if(fNFIRBins<=0){
LERROR(lmclog,"Number of bins in the filter should be positive");
}
for(int i=0;i<fNFIRBins;++i)
{
convolution+=fFIRFilter[i]*delayedVoltageBuffer[i];
}
return convolution;
}

FIRTransmitterHandler::FIRTransmitterHandler():FIRHandlerCore()
{
}

FIRTransmitterHandler::~FIRTransmitterHandler()
{
}

bool FIRTransmitterHandler::Configure(const scarab::param_node& aParam)
{
if( aParam.has( "fir-transmitter-filename" ) )
{
fFIRFilename=aParam["fir-transmitter-filename"]().as_string();
}
if( aParam.has( "fir-transmitter-dt" ) )
{
fFIRResolution=aParam["fir-transmitter-dt"]().as_double();
}
if( aParam.has( "fir-transmitter-nskips" ) )
{
fNFIRSkips=aParam["fir-transmitter-nskips"]().as_int();
}
return true;
}

FIRReceiverHandler::FIRReceiverHandler():FIRHandlerCore()
{
}

FIRReceiverHandler::~FIRReceiverHandler()
{
}

bool FIRReceiverHandler::Configure(const scarab::param_node& aParam)
{
if( aParam.has( "fir-receiver-filename" ) )
{
fFIRFilename=aParam["fir-receiver-filename"]().as_string();
}
if( aParam.has( "fir-receiver-dt" ) )
{
fFIRResolution=aParam["fir-receiver-dt"]().as_double();
}
if( aParam.has( "fir-receiver-nskips" ) )
{
fNFIRSkips=aParam["fir-receiver-nskips"]().as_int();
}
return true;
}

} /* namespace locust */
103 changes: 103 additions & 0 deletions Source/Core/LMCFIRHandler.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#ifndef LMCFIRHANDLERCORE_HH_
#define LMCFIRHANDLERCORE_HH_

#include "LMCException.hh"
#include "param.hh"

namespace locust
{
/*!
@class FIRHandlerCore
@author P. T. Surukuchi
@brief Handles opening of the FIR files, saving them into objects to be used for convolution
@details
Available configuration options:
- "fir-transmitter(receiver)-filename": string -- The location of the file containing impulse response
- "fir-transmitter(receiver)-dt": double (1e-12) -- The size of filter sample width (seconds)
- "fir-transmitter(receiver)-nskips": int (1) -- Number of skips to be peformed in reading from the FIR file, this will deteremine the number of FIR bins
*/

class FIRHandlerCore
{
public:
FIRHandlerCore();
virtual ~FIRHandlerCore();

// Member functions
virtual bool Configure( const scarab::param_node& aNode);
bool ReadFIRFile();
double ConvolveWithFIRFilter(std::deque<double>);// Convolve input signal (voltage or field) with FIR
int GetFilterSize() const;//Number of entries in the filter
double GetFilterResolution() const;//Get the resolution of the filter

protected:

// Member variables
std::string fFIRFilename;
std::vector<double> fFIRFilter;
int fNFIRBins;
double fFIRResolution;
int fNFIRSkips;
// bool fIsTransmitter;//Ad-hoc definition of FIR filter type if true transmitter other-wise receiver

//Member functions
//Check weather the given input string ends with another string
//PTS: Should be moved into a core class
bool ends_with(const std::string &, const std::string &);
};

inline int FIRHandlerCore::GetFilterSize() const
{
return fNFIRBins;
}

inline double FIRHandlerCore::GetFilterResolution() const
{
return fFIRResolution;
}

/*!
@class FIRTransmitterHandler
@author P. T. Surukuchi
@brief Handles transmitter FIR, saving them into objects to be used for convolution
@details
Available configuration options:
- "fir-transmitter-filename": string -- The location of the file containing impulse response function
- "fir-transmitter-dt": double (1e-12) -- The size of filter sample width (seconds)
- "fir-transmitter-nskips": int (1) -- Number of skips to be peformed in reading from the FIR file, this will deteremine the number of FIR bins
*/

class FIRTransmitterHandler: public FIRHandlerCore
{
public:
FIRTransmitterHandler();
virtual ~FIRTransmitterHandler();

// Member functions
bool Configure( const scarab::param_node& aNode);
};

/*!
@class FIRReceiverHandler
@author P. T. Surukuchi
@brief Handles receiver FIR, saving them into objects to be used for convolution
@details
Available configuration options:
- "fir-transmitter-filename": string -- The location of the file containing impulse response function
- "fir-transmitter-dt": double (1e-12) -- The size of filter sample width (seconds)
- "fir-transmitter-nskips": int (1) -- Number of skips to be peformed in reading from the FIR file, this will deteremine the number of FIR bins
*/

class FIRReceiverHandler: public FIRHandlerCore
{
public:
FIRReceiverHandler();
virtual ~FIRReceiverHandler();

// Member functions
bool Configure( const scarab::param_node& aNode);
};

} /*namespace locust*/

#endif/*LMCFIRHANDLERCORE_HH_ */
Loading

0 comments on commit 51b0853

Please sign in to comment.