1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#include "aoqplotcontroller.h"
#include "antennapagecontroller.h"
#include "baselinepagecontroller.h"
#include "blengthpagecontroller.h"
#include "frequencypagecontroller.h"
#include "tfpagecontroller.h"
#include "timepagecontroller.h"
#include "../aoqplotwindow.h"
#include "../baselineplotpage.h"
#include "../blengthplotpage.h"
#include "../frequencyplotpage.h"
#include "../histogrampage.h"
#include "../plotsheet.h"
#include "../summarypage.h"
#include "../timefrequencyplotpage.h"
#include "../../structures/msmetadata.h"
#include "../../quality/combine.h"
#include "../../quality/histogramtablesformatter.h"
#include "../../quality/histogramcollection.h"
#include "../../quality/statisticscollection.h"
AOQPlotController::AOQPlotController() : _isOpen(false), _window(nullptr) {}
AOQPlotController::~AOQPlotController() {}
void AOQPlotController::close() {
if (_isOpen) {
_statCollection.reset();
_histCollection.reset();
_fullStats.reset();
_isOpen = false;
}
}
void AOQPlotController::readMetaInfoFromMS(const string& filename) {
const MSMetaData ms(filename);
_polarizationCount = ms.PolarizationCount();
const unsigned antennaCount = ms.AntennaCount();
_antennas.clear();
for (unsigned a = 0; a < antennaCount; ++a)
_antennas.push_back(ms.GetAntennaInfo(a));
}
void AOQPlotController::ReadStatistics(const std::vector<std::string>& files,
bool downsampleTime, bool downsampleFreq,
size_t timeSize, size_t freqSize,
bool correctHistograms) {
close();
if (!files.empty()) {
const std::string& firstFile = *files.begin();
readMetaInfoFromMS(firstFile);
quality::FileContents contents = quality::ReadAndCombine(files, true);
_statCollection = std::make_unique<StatisticsCollection>(
std::move(contents.statistics_collection));
_histCollection = std::make_unique<HistogramCollection>(
std::move(contents.histogram_collection));
if (_window != nullptr)
_window->SetShowHistograms(!_histCollection->Empty());
if (downsampleTime) {
std::cout << "Lowering time resolution..." << std::endl;
_statCollection->LowerTimeResolution(timeSize);
}
if (downsampleFreq) {
std::cout << "Lowering frequency resolution..." << std::endl;
_statCollection->LowerFrequencyResolution(freqSize);
}
std::cout << "Integrating baseline statistics to one channel..."
<< std::endl;
_statCollection->IntegrateBaselinesToOneChannel();
std::cout << "Regridding time statistics..." << std::endl;
_statCollection->RegridTime();
std::cout << "Copying statistics..." << std::endl;
_fullStats = std::make_unique<StatisticsCollection>(*_statCollection);
std::cout << "Integrating time statistics to one channel..." << std::endl;
_statCollection->IntegrateTimeToOneChannel();
std::cout << "Opening statistics panel..." << std::endl;
_isOpen = true;
}
}
void AOQPlotController::Save(const AOQPlotController::PlotSavingData& data,
size_t width, size_t height) {
const std::string& prefix = data.filenamePrefix;
const QualityTablesFormatter::StatisticKind kind = data.statisticKind;
std::cout << "Saving " << prefix << "-antennas.pdf...\n";
AntennaePageController antController;
antController.SetStatistics(_statCollection.get(), _antennas);
antController.SavePdf(prefix + "-antennas.pdf", kind);
std::cout << "Saving " << prefix << "-baselines.pdf...\n";
BaselinePageController baselController;
// BaselinePlotPage baselPage(&baselController);
baselController.SetStatistics(_statCollection.get(), _antennas);
baselController.SavePdf(prefix + "-baselines.pdf", kind, width, height);
std::cout << "Saving " << prefix << "-baselinelengths.pdf...\n";
BLengthPageController blenController;
blenController.SetStatistics(_statCollection.get(), _antennas);
blenController.SavePdf(prefix + "-baselinelengths.pdf", kind);
std::cout << "Saving " << prefix << "-timefrequency.pdf...\n";
TFPageController tfController;
tfController.SetStatistics(_fullStats.get(), _antennas);
tfController.SavePdf(prefix + "-timefrequency.pdf", kind, width, height);
std::cout << "Saving " << prefix << "-time.pdf...\n";
TimePageController timeController;
timeController.SetStatistics(_statCollection.get(), _antennas);
timeController.SavePdf(prefix + "-time.pdf", kind);
std::cout << "Saving " << prefix << "-frequency.pdf...\n";
FrequencyPageController freqController;
freqController.SetStatistics(_statCollection.get(), _antennas);
freqController.SavePdf(prefix + "-frequency.pdf", kind);
}
void AOQPlotController::Initialize(AOQPageController* controller,
bool averagedStats) {
if (averagedStats)
controller->SetStatistics(_statCollection.get(), _antennas);
else
controller->SetStatistics(_fullStats.get(), _antennas);
controller->SetHistograms(_histCollection.get());
}
|