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

Task #1892: starting implementation of quality statistics

parent 486ed354
No related branches found
No related tags found
No related merge requests found
...@@ -283,6 +283,7 @@ CEP/DP3/AOFlagger/include/AOFlagger/msio/mask2d.h -text ...@@ -283,6 +283,7 @@ CEP/DP3/AOFlagger/include/AOFlagger/msio/mask2d.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/measurementset.h -text CEP/DP3/AOFlagger/include/AOFlagger/msio/measurementset.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/parmtable.h -text CEP/DP3/AOFlagger/include/AOFlagger/msio/parmtable.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/pngfile.h -text CEP/DP3/AOFlagger/include/AOFlagger/msio/pngfile.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/qualitydata.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/rawdescfile.h -text CEP/DP3/AOFlagger/include/AOFlagger/msio/rawdescfile.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/rawreader.h -text CEP/DP3/AOFlagger/include/AOFlagger/msio/rawreader.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/rspreader.h -text CEP/DP3/AOFlagger/include/AOFlagger/msio/rspreader.h -text
...@@ -519,6 +520,7 @@ CEP/DP3/AOFlagger/src/msio/indirectbaselinereader.cpp -text ...@@ -519,6 +520,7 @@ CEP/DP3/AOFlagger/src/msio/indirectbaselinereader.cpp -text
CEP/DP3/AOFlagger/src/msio/mask2d.cpp -text CEP/DP3/AOFlagger/src/msio/mask2d.cpp -text
CEP/DP3/AOFlagger/src/msio/measurementset.cpp -text CEP/DP3/AOFlagger/src/msio/measurementset.cpp -text
CEP/DP3/AOFlagger/src/msio/pngfile.cpp -text CEP/DP3/AOFlagger/src/msio/pngfile.cpp -text
CEP/DP3/AOFlagger/src/msio/qualitydata.cpp -text
CEP/DP3/AOFlagger/src/msio/rspreader.cpp -text CEP/DP3/AOFlagger/src/msio/rspreader.cpp -text
CEP/DP3/AOFlagger/src/msio/samplerow.cpp -text CEP/DP3/AOFlagger/src/msio/samplerow.cpp -text
CEP/DP3/AOFlagger/src/msio/segmentedimage.cpp -text CEP/DP3/AOFlagger/src/msio/segmentedimage.cpp -text
......
/***************************************************************************
* Copyright (C) 2008 by A.R. Offringa *
* offringa@astro.rug.nl *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef MSIO_QUALITY_DATA_H
#define MSIO_QUALITY_DATA_H
#include <ms/MeasurementSets/MeasurementSet.h>
/**
@author A.R. Offringa <offringa@astro.rug.nl>
*/
struct StatisticalValue {
StatisticalValue(unsigned _polarizationCount) :
polarizationCount(_polarizationCount),
values(new std::complex<float>[_polarizationCount])
{
}
StatisticalValue(const StatisticalValue &source) :
polarizationCount(source.polarizationCount),
values(new std::complex<float>[source.polarizationCount])
{
kindIndex = source.kindIndex;
for(unsigned i=0;i<polarizationCount;++i)
values[i] = source.values[i];
}
~StatisticalValue()
{
delete[] values;
}
StatisticalValue &operator=(const StatisticalValue &source)
{
if(polarizationCount != source.polarizationCount)
{
polarizationCount = source.polarizationCount;
delete[] values;
values = new std::complex<float>[polarizationCount];
}
kindIndex = source.kindIndex;
for(unsigned i=0;i<polarizationCount;++i)
values[i] = source.values[i];
return *this;
}
unsigned polarizationCount;
int kindIndex;
std::complex<float> *values;
};
class QualityData {
public:
enum StatisticKind
{
RFIRatioStatistic,
FlaggedRatioStatistic,
CountStatistic,
MeanStatistic,
RFIMeanStatistic,
RFICountStatistic,
SumP2Statistic,
SumP4Statistic,
VarianceStatistic,
VarianceOfVarianceStatistic,
SkewnessStatistic,
KurtosisStatistic,
SignalToNoiseStatistic,
DMeanStatistic,
DSumP2Statistic,
DSumP4Statistic,
DVarianceStatistic,
DVarianceOfVarianceStatistic,
DCountStatistic
};
enum StatisticDimension
{
TimeDimension,
FrequencyDimension,
BaselineDimension,
BaselineTimeDimension
};
enum QualityTable
{
KindNameTable,
TimeStatisticTable,
FrequencyStatisticTable,
BaselineStatisticTable,
BaselineTimeStatisticTable
};
QualityData(casa::Table &measurementSet)
{
_measurementSet = new casa::Table(measurementSet);
}
QualityData(const std::string &measurementSetName)
{
_measurementSet = new casa::Table(measurementSetName);
}
~QualityData()
{
delete _measurementSet;
}
bool TableExists(enum QualityTable table) const
{
return _measurementSet->isReadable(TableToName(table));
}
const std::string &KindToName(const enum StatisticKind kind) const
{
return _kindToNameTable[(int) kind];
}
const std::string &TableToName(const enum QualityTable table) const
{
return _tableToNameTable[(int) table];
}
bool StatisticAvailable(enum QualityTable table, enum StatisticKind kind) const
{
return TableExists(KindNameTable) && TableExists(table) && hasOneEntry(table, kind);
}
void InitializeEmptyStatistic(enum QualityTable table, enum StatisticKind kind)
{
if(!TableExists(table))
InitializeEmptyTable(table);
else
removeStatistic(table, kind);
}
void InitializeEmptyTable(enum QualityTable table)
{
if(TableExists(table))
removeEntries(table);
else
createTable(table);
}
void RemoveTable(enum QualityTable table)
{
if(TableExists(table))
{
casa::Table::deleteTable(TableToName(table));
}
}
void RemoveAllStatistics()
{
RemoveTable(BaselineTimeStatisticTable);
RemoveTable(BaselineStatisticTable);
RemoveTable(FrequencyStatisticTable);
RemoveTable(TimeStatisticTable);
RemoveTable(KindNameTable);
}
int StoreKindName(enum StatisticKind kind);
void StoreTimeValue(double time, double frequency, const StatisticalValue &value);
private:
casa::Table *_measurementSet;
const static std::string _kindToNameTable[];
const static std::string _tableToNameTable[];
bool hasOneEntry(enum QualityTable table, enum StatisticKind kind) const;
void removeStatistic(enum QualityTable table, enum StatisticKind kind);
void removeEntries(enum QualityTable table);
void createTable(enum QualityTable table);
};
#endif
...@@ -93,7 +93,7 @@ class RankOperatorROCExperiment : public UnitTest { ...@@ -93,7 +93,7 @@ class RankOperatorROCExperiment : public UnitTest {
} }
}; };
const unsigned RankOperatorROCExperiment::_repeatCount = 2; const unsigned RankOperatorROCExperiment::_repeatCount = 100;
inline rfiStrategy::Strategy *RankOperatorROCExperiment::createThresholdStrategy() inline rfiStrategy::Strategy *RankOperatorROCExperiment::createThresholdStrategy()
{ {
......
...@@ -1024,6 +1024,7 @@ void MSWindow::onSetToOne() ...@@ -1024,6 +1024,7 @@ void MSWindow::onSetToOne()
real->SetAll(1.0); real->SetAll(1.0);
imaginary->SetAll(0.0); imaginary->SetAll(0.0);
TimeFrequencyData newData(data.Polarisation(), real, imaginary); TimeFrequencyData newData(data.Polarisation(), real, imaginary);
newData.SetMask(data);
_timeFrequencyWidget.SetNewData(newData, _timeFrequencyWidget.GetMetaData()); _timeFrequencyWidget.SetNewData(newData, _timeFrequencyWidget.GetMetaData());
_timeFrequencyWidget.Update(); _timeFrequencyWidget.Update();
} catch(std::exception &e) } catch(std::exception &e)
...@@ -1043,6 +1044,7 @@ void MSWindow::onSetToI() ...@@ -1043,6 +1044,7 @@ void MSWindow::onSetToI()
real->SetAll(0.0); real->SetAll(0.0);
imaginary->SetAll(1.0); imaginary->SetAll(1.0);
TimeFrequencyData newData(data.Polarisation(), real, imaginary); TimeFrequencyData newData(data.Polarisation(), real, imaginary);
newData.SetMask(data);
_timeFrequencyWidget.SetNewData(newData, _timeFrequencyWidget.GetMetaData()); _timeFrequencyWidget.SetNewData(newData, _timeFrequencyWidget.GetMetaData());
_timeFrequencyWidget.Update(); _timeFrequencyWidget.Update();
} catch(std::exception &e) } catch(std::exception &e)
...@@ -1062,6 +1064,7 @@ void MSWindow::onSetToOnePlusI() ...@@ -1062,6 +1064,7 @@ void MSWindow::onSetToOnePlusI()
real->SetAll(1.0); real->SetAll(1.0);
imaginary->SetAll(1.0); imaginary->SetAll(1.0);
TimeFrequencyData newData(data.Polarisation(), real, imaginary); TimeFrequencyData newData(data.Polarisation(), real, imaginary);
newData.SetMask(data);
_timeFrequencyWidget.SetNewData(newData, _timeFrequencyWidget.GetMetaData()); _timeFrequencyWidget.SetNewData(newData, _timeFrequencyWidget.GetMetaData());
_timeFrequencyWidget.Update(); _timeFrequencyWidget.Update();
} catch(std::exception &e) } catch(std::exception &e)
......
/***************************************************************************
* Copyright (C) 2008 by A.R. Offringa *
* offringa@astro.rug.nl *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <AOFlagger/msio/qualitydata.h>
const std::string QualityData::_kindToNameTable[] =
{
"RFIRatio",
"FlaggedRatio",
"Count",
"Mean",
"RFIMean",
"RFICount",
"SumP2",
"SumP4",
"Variance",
"VarianceOfVariance",
"Skewness",
"Kurtosis",
"SignalToNoise",
"DMean",
"DSumP2",
"DSumP4",
"DVariance",
"DVarianceOfVariance",
"DCount"
};
const std::string QualityData::_tableToNameTable[] =
{
"QUALITY_KIND_NAME",
"QUALITY_TIME_STATISTIC",
"QUALITY_FREQUENCY_STATISTIC",
"QUALITY_BASELINE_STATISTIC",
"QUALITY_BASELINE_TIME_STATISTIC"
};
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