Line data Source code
1 : //# FlagAgentSummary.h: This file contains the interface definition of the FlagAgentSummary class. 2 : //# 3 : //# CASA - Common Astronomy Software Applications (http://casa.nrao.edu/) 4 : //# Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved. 5 : //# Copyright (C) European Southern Observatory, 2011, All rights reserved. 6 : //# 7 : //# This library is free software; you can redistribute it and/or 8 : //# modify it under the terms of the GNU Lesser General Public 9 : //# License as published by the Free software Foundation; either 10 : //# version 2.1 of the License, or (at your option) any later version. 11 : //# 12 : //# This library is distributed in the hope that it will be useful, 13 : //# but WITHOUT ANY WARRANTY, without even the implied warranty of 14 : //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 : //# Lesser General Public License for more details. 16 : //# 17 : //# You should have received a copy of the GNU Lesser General Public 18 : //# License along with this library; if not, write to the Free Software 19 : //# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 : //# MA 02111-1307 USA 21 : //# $Id: $ 22 : 23 : #ifndef FlagAgentSummary_H_ 24 : #define FlagAgentSummary_H_ 25 : 26 : #include <unordered_map> 27 : 28 : #include <flagging/Flagging/FlagAgentBase.h> 29 : 30 : namespace casa { //# NAMESPACE CASA - BEGIN 31 : 32 : class FlagAgentSummary : public FlagAgentBase { 33 : 34 : struct summary 35 : { 36 404 : summary() 37 404 : { 38 404 : accumflags.clear(); 39 404 : accumtotal.clear(); 40 404 : accumChannelflags.clear(); 41 404 : accumChanneltotal.clear(); 42 404 : accumPolarizationflags.clear(); 43 404 : accumPolarizationtotal.clear(); 44 404 : accumAntScanflags.clear(); 45 404 : accumAntScantotal.clear(); 46 404 : accumTotalFlags = 0; 47 404 : accumTotalCount = 0; 48 404 : } 49 : 50 : std::unordered_map<std::string, std::unordered_map<std::string, casacore::uInt64> > accumflags; 51 : std::unordered_map<std::string, std::unordered_map<std::string, casacore::uInt64> > accumtotal; 52 : 53 : std::unordered_map<casacore::Int, std::unordered_map<casacore::uInt, casacore::uInt64> > accumChannelflags; 54 : std::unordered_map<casacore::Int, std::unordered_map<casacore::uInt, casacore::uInt64> > accumChanneltotal; 55 : 56 : std::unordered_map<casacore::Int, std::unordered_map<std::string, casacore::uInt64> > accumPolarizationflags; 57 : std::unordered_map<casacore::Int, std::unordered_map<std::string, casacore::uInt64> > accumPolarizationtotal; 58 : 59 : std::unordered_map<casacore::Int, std::unordered_map<casacore::Int, casacore::uInt64> > accumAntScanflags; 60 : std::unordered_map<casacore::Int, std::unordered_map<casacore::Int, casacore::uInt64> > accumAntScantotal; 61 : 62 : casacore::uInt64 accumTotalFlags, accumTotalCount; 63 : }; 64 : 65 : public: 66 : 67 : FlagAgentSummary(FlagDataHandler *dh, casacore::Record config); 68 : ~FlagAgentSummary(); 69 : 70 : casacore::Record getResult(); 71 : 72 : protected: 73 : 74 : // Common functionality for each visBuffer (don't repeat at the row level) 75 : void preProcessBuffer(const vi::VisBuffer2 &visBuffer); 76 : 77 : // Add flags sum into summary fields 78 : void postProcessBuffer(); 79 : 80 : // Compute flags for a given mapped visibility point 81 : bool computeRowFlags(const vi::VisBuffer2 &visBuffer, FlagMapper &flags, casacore::uInt row); 82 : 83 : // Parse configuration parameters 84 : void setAgentParameters(casacore::Record config); 85 : 86 : // Get the summary dictionary, and 'view' reports. 87 : FlagReport getReport(); 88 : 89 : // Utility method to facilitate creation of sub-summaries per field 90 : void getResultCore(casacore::Record &summary); 91 : 92 : private: 93 : 94 : // Build simple plot-reports from the summary dictionary 95 : FlagReport buildFlagCountPlots(); 96 : std::unordered_map<casacore::Int , std::vector<casacore::Double> > frequencyList; 97 : 98 : casacore::Bool spwChannelCounts; 99 : casacore::Bool spwPolarizationCounts; 100 : casacore::Bool baselineCounts; 101 : casacore::Bool fieldCounts; 102 : casacore::String display_p; 103 : 104 : std::unordered_map<std::string, summary* > fieldSummaryMap; 105 : summary *currentSummary; 106 : casacore::Int arrayId; 107 : casacore::Int fieldId; 108 : casacore::Int spw; 109 : casacore::Int scan; 110 : casacore::Int observationId; 111 : // to count total flags (whether on/off) in the current buffer 112 : size_t bufferTotal = 0; 113 : // to count total flags (on) in the current buffer 114 : size_t bufferFlags = 0; 115 : 116 : string arrayId_str; 117 : string fieldId_str; 118 : string spw_str; 119 : string observationId_str; 120 : 121 : }; 122 : 123 : 124 : } //# NAMESPACE CASA - END 125 : 126 : #endif /* FlagAgentSummary_H_ */ 127 :