Skip to content
Snippets Groups Projects
Commit 07b8283a authored by Andre Offringa's avatar Andre Offringa
Browse files

Bug 1491: Fixing the time selection unused parameters, reported by P. Serra

parent 8ebdd62b
No related branches found
No related tags found
No related merge requests found
......@@ -36,35 +36,22 @@ class TimeSelectionFrame : public Gtk::Frame {
TimeSelectionFrame(rfiStrategy::TimeSelectionAction &action, EditStrategyWindow &editStrategyWindow)
: Gtk::Frame("Time selection"),
_editStrategyWindow(editStrategyWindow), _action(action),
_partCountLabel("Part count:"),
_partCountScale(0, 1000, 1),
_selectionCountLabel("Selection count:"),
_selectionCountScale(0, 1000, 1),
_thresholdLabel("Threshold:"),
_thresholdScale(0, 10, 0.1),
_applyButton(Gtk::Stock::APPLY)
{
_box.pack_start(_partCountLabel);
_partCountLabel.show();
_box.pack_start(_thresholdLabel);
_box.pack_start(_partCountScale);
_partCountScale.set_value(_action.PartCount());
_partCountScale.show();
_box.pack_start(_selectionCountLabel);
_selectionCountLabel.show();
_box.pack_start(_selectionCountScale);
_selectionCountScale.set_value(_action.SelectionCount());
_selectionCountScale.show();
_box.pack_start(_thresholdScale);
_thresholdScale.set_value(_action.Threshold());
_buttonBox.pack_start(_applyButton);
_applyButton.signal_clicked().connect(sigc::mem_fun(*this, &TimeSelectionFrame::onApplyClicked));
_applyButton.show();
_box.pack_start(_buttonBox);
_buttonBox.show();
add(_box);
_box.show();
_box.show_all();
}
private:
EditStrategyWindow &_editStrategyWindow;
......@@ -72,16 +59,13 @@ class TimeSelectionFrame : public Gtk::Frame {
Gtk::VBox _box;
Gtk::HButtonBox _buttonBox;
Gtk::Label _partCountLabel;
Gtk::HScale _partCountScale;
Gtk::Label _selectionCountLabel;
Gtk::HScale _selectionCountScale;
Gtk::Label _thresholdLabel;
Gtk::HScale _thresholdScale;
Gtk::Button _applyButton;
void onApplyClicked()
{
_action.SetPartCount((size_t) _partCountScale.get_value());
_action.SetSelectionCount((size_t) _selectionCountScale.get_value());
_action.SetThreshold(_thresholdScale.get_value());
_editStrategyWindow.UpdateAction(&_action);
}
};
......
......@@ -172,7 +172,7 @@ struct WSRTObservatorium : public Observatorium
void initBand()
{
GetBandInfo().windowIndex = 0;
GetBandInfo().channelCount = 16*16;
GetBandInfo().channelCount = 16*4;
SetChannelWidthHz(10000.0 * 256.0 * 16.0 / GetBandInfo().channelCount);
for(size_t i=0;i<GetBandInfo().channelCount;++i)
{
......
......@@ -31,7 +31,7 @@ namespace rfiStrategy {
*/
class TimeSelectionAction : public Action {
public:
TimeSelectionAction() : _partCount(25), _selectionCount(20), _manualSelection(false), _threshold(3.5)
TimeSelectionAction() : _threshold(3.5)
{
}
~TimeSelectionAction()
......@@ -43,28 +43,15 @@ namespace rfiStrategy {
}
virtual void Perform(ArtifactSet &artifacts, class ProgressListener &)
{
if(_manualSelection)
ManualSelection(artifacts);
else
AutomaticSelection(artifacts);
AutomaticSelection(artifacts);
}
virtual ActionType Type() const { return TimeSelectionActionType; }
size_t PartCount() const { return _partCount; }
void SetPartCount(size_t partCount) { _partCount = partCount; }
size_t SelectionCount() const { return _selectionCount; }
void SetSelectionCount(size_t selectionCount) { _selectionCount = selectionCount; }
num_t Threshold() const { return _threshold; }
void SetThreshold(num_t threshold) { _threshold = threshold; }
private:
void ManualSelection(ArtifactSet &artifacts);
void AutomaticSelection(ArtifactSet &artifacts);
size_t _partCount;
size_t _selectionCount;
bool _manualSelection;
num_t _threshold;
};
......
......@@ -218,7 +218,7 @@ class FilterResultsTest : public UnitTest {
statFile << '\n';
}
static void SaveImaged(rfiStrategy::ArtifactSet &artifacts, const std::string &filename, bool difference, double centerPower, double sidelobePower, double onAxisPower)
static void SaveImaged(const TimeFrequencyData &original, rfiStrategy::ArtifactSet &artifacts, const std::string &filename, bool difference, double centerPower, double sidelobePower, double onAxisPower)
{
UVImager imager(1024*1.5, 1024*1.5);
......@@ -226,7 +226,7 @@ class FilterResultsTest : public UnitTest {
if(difference)
{
data =
TimeFrequencyData::CreateTFDataFromDiff(artifacts.OriginalData(), artifacts.ContaminatedData());
TimeFrequencyData::CreateTFDataFromDiff(original, artifacts.ContaminatedData());
} else {
data =
new TimeFrequencyData(artifacts.ContaminatedData());
......@@ -260,14 +260,15 @@ class FilterResultsTest : public UnitTest {
artifacts.SetOriginalData(data.first);
artifacts.SetContaminatedData(data.first);
data.first.SetImagesToZero();
artifacts.SetRevisedData(data.first);
TimeFrequencyData zero(data.first);
zero.SetImagesToZero();
artifacts.SetRevisedData(zero);
artifacts.SetMetaData(data.second);
strategy->Perform(artifacts, listener);
SaveImaged(artifacts, appliedName, false, centerPower, sidelobePower, onAxisPower);
SaveImaged(artifacts, differenceName, true, centerPower, sidelobePower, onAxisPower);
SaveImaged(data.first, artifacts, appliedName, false, centerPower, sidelobePower, onAxisPower);
SaveImaged(data.first, artifacts, differenceName, true, centerPower, sidelobePower, onAxisPower);
}
static void RunAllMethods(std::pair<TimeFrequencyData, TimeFrequencyMetaDataPtr> data, const std::string &setPrefix, const std::string &setName, double centerPower, double sidelobePower, double onAxisPower)
......
......@@ -35,47 +35,6 @@
namespace rfiStrategy {
void TimeSelectionAction::ManualSelection(ArtifactSet &artifacts)
{
TimeFrequencyData &model = artifacts.RevisedData();
TimeFrequencyData &original = artifacts.OriginalData();
TimeFrequencyData &contaminated = artifacts.ContaminatedData();
size_t timeSteps = model.ImageWidth();
Mask2DPtr mask = Mask2D::CreateCopy(contaminated.GetSingleMask());
std::multimap<double, size_t> orderedQualities;
size_t
partCount = _partCount,
selectCount = _selectionCount;
if(partCount > original.ImageWidth())
partCount = original.ImageWidth();
if(selectCount > partCount)
selectCount = partCount;
Image2DCPtr
originalImg = original.GetSingleImage(),
modelImg = model.GetSingleImage();
for(size_t p = 0; p < partCount; ++p)
{
size_t
startX = p * timeSteps / partCount,
endX = (p+1) * timeSteps / partCount;
double quality = RFIStatistics::DataQuality(originalImg, modelImg, mask, startX, endX);
orderedQualities.insert(std::pair<double, size_t>(quality, p));
}
for(size_t i=0;i<partCount - selectCount; ++i)
{
std::map<double, size_t>::iterator mi = orderedQualities.begin();
size_t part = mi->second;
orderedQualities.erase(mi);
size_t
startX = part * timeSteps / partCount,
endX = (part+1) * timeSteps / partCount;
mask->SetAllVertically<true>(startX, endX);
}
contaminated.SetGlobalMask(mask);
}
/**
* Automatic selection selects all timesteps which RMS is higher than some value relative to the stddev of
* all timesteps.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment