3 #include <fwk/CentralConfig.h>
5 #include <utl/ErrorLogger.h>
6 #include <utl/Reader.h>
7 #include <utl/config.h>
8 #include <utl/TraceAlgorithm.h>
10 #include <evt/Event.h>
11 #include <revt/REvent.h>
12 #include <revt/Station.h>
13 #include <revt/Channel.h>
31 topBranch.
GetChild(
"MedianSortAlgorithmLimit").
GetData(fMedianSortAlgorithmLimit);
42 WARNING(
"No radio event found!");
46 REvent& rEvent =
event.GetREvent();
50 for (
auto& station : rEvent.StationsRange()) {
51 for (
auto& channel : station.ChannelsRange()) {
53 if (!channel.IsActive())
57 info <<
"Supressing RFI of channel " << channel.GetId()
58 <<
" of station " << channel.GetStationId() <<
".";
63 MedianFilter(spectrum);
72 RdChannelMedianFilter::Finish()
83 for (
const auto& val : spectrum)
89 unsigned int filterSizeBins = fFilterSizeBins;
90 if (fFilterBandwidth > 0) {
91 filterSizeBins = trunc(fFilterBandwidth/spectrum.GetBinning()/2.) * 2 + 1;
94 info <<
"Use median filter size of " << filterSizeBins
95 <<
" bins, corresponding to a bandwidth of "
96 << filterSizeBins*spectrum.GetBinning()/
megahertz <<
" MHz.";
101 if (filterSizeBins > amplitude.
GetSize()) {
103 info <<
"Size of median filter (" << fFilterSizeBins
104 <<
" samples) should not be larger than the size of the spectrum ("
105 << amplitude.
GetSize() <<
" samples)";
107 filterSizeBins = amplitude.
GetSize();
114 double median = TraceAlgorithm::Median(amplitude, 0, filterSizeBins-1, fMedianSortAlgorithmLimit);
123 for (i = 0; i < ceil(filterSizeBins/2.0); ++i)
124 if (
abs(spectrum[i]) > 0)
125 spectrum[i] *= median/
abs(spectrum[i]);
126 else spectrum[i] = median;
129 for(;i < (spectrum.GetSize()-ceil(filterSizeBins/2.0)); ++i)
130 if (
abs(spectrum[i]) > 0)
132 TraceAlgorithm::Median(amplitude, i-trunc(filterSizeBins/2.0),
133 i+ceil(filterSizeBins/2.0)-1, fMedianSortAlgorithmLimit)/
abs(spectrum[i]);
136 TraceAlgorithm::Median(amplitude, i-trunc(filterSizeBins/2.0),
137 i+ceil(filterSizeBins/2.0)-1, fMedianSortAlgorithmLimit);
140 median = TraceAlgorithm::Median(amplitude, spectrum.
GetSize()-filterSizeBins,
141 spectrum.GetSize()-1, fMedianSortAlgorithmLimit);
142 for(;i < spectrum.GetSize(); ++i)
143 if (
abs(spectrum[i]) > 0)
144 spectrum[i] *= median/
abs(spectrum[i]);
145 else spectrum[i] = median;
Interface class to access to the Radio part of an event.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
#define INFOIntermediate(y)
Class representing a document branch.
std::vector< std::complex< double > >::size_type SizeType
double abs(const SVector< n, T > &v)
constexpr double megahertz
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
ResultFlag
Flag returned by module methods to the RunController.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
void PushBack(const T &value)
Insert a single value at the end.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)