Line data Source code
1 : /* 2 : * VisBufferComponents.cc 3 : * 4 : * Created on: Aug 20, 2012 5 : * Author: jjacobs 6 : */ 7 : 8 : #include <stdcasa/UtilJ.h> 9 : #include <msvis/MSVis/VisBufferComponents2.h> 10 : #include <map> 11 : 12 : using namespace std; 13 : 14 : using namespace casacore; 15 : namespace casa { 16 : 17 : namespace vi { 18 : 19 : const VisBufferComponents2 VisBufferComponents2::all_p = initializeAll (); 20 : 21 : VisBufferComponents2 22 556198 : VisBufferComponents2::operator+ (const VisBufferComponents2 & other) const 23 : { 24 556198 : VisBufferComponents2 result = * this; 25 : 26 556198 : result.set_p.insert (other.begin(), other.end()); 27 : 28 556198 : return result; 29 : } 30 : 31 : VisBufferComponents2 & 32 0 : VisBufferComponents2::operator+= (const VisBufferComponents2 & other) 33 : { 34 0 : if (& other != this){ 35 : 36 0 : set_p.insert (other.set_p.begin(), other.set_p.end()); 37 : } 38 : 39 0 : return * this; 40 : } 41 : 42 : VisBufferComponents2 & 43 93360 : VisBufferComponents2::operator+= (VisBufferComponent2 componentToAdd) 44 : { 45 93360 : set_p.insert (componentToAdd); 46 : 47 93360 : return * this; 48 : } 49 : 50 : 51 : VisBufferComponents2 52 0 : VisBufferComponents2::all () 53 : { 54 0 : return all_p; 55 : } 56 : 57 : VisBufferComponents2::const_iterator 58 758963 : VisBufferComponents2::begin () const 59 : { 60 758963 : return set_p.begin(); 61 : } 62 : 63 : Bool 64 6397818 : VisBufferComponents2::contains (VisBufferComponent2 component) const 65 : { 66 6397818 : return utilj::containsKey (component, set_p); 67 : } 68 : 69 : Bool 70 14667 : VisBufferComponents2::empty () const 71 : { 72 14667 : return set_p.empty(); 73 : } 74 : 75 : VisBufferComponents2::const_iterator 76 1315161 : VisBufferComponents2::end () const 77 : { 78 1315161 : return set_p.end(); 79 : } 80 : 81 : VisBufferComponents2 82 0 : VisBufferComponents2::exceptThese (std::initializer_list<VisBufferComponent2> components) 83 : { 84 0 : VisBufferComponents2 result = all(); 85 : 86 0 : for (auto component : components){ 87 0 : result.set_p.erase (component); 88 : } 89 : 90 0 : return result; 91 : } 92 : 93 : VisBufferComponents2 94 1 : VisBufferComponents2::initializeAll () 95 : { 96 : 97 1 : VisBufferComponents2 all; 98 : 99 : // VisBufferComponent2 100 : // writableComponents [] = {Corrected, 101 : // CorrectedCube, 102 : // Flag, 103 : // FlagCube, 104 : // FlagRow, 105 : // Model, 106 : // ModelCube, 107 : // Observed, 108 : // ObservedCube, 109 : // Sigma, 110 : // SigmaMat, 111 : // Weight, 112 : // WeightMat, 113 : // Unknown}; 114 : 115 68 : for (Int i = 0; i < static_cast<int> (VisBufferComponent2::N_VisBufferComponents2); i++){ 116 : 117 67 : all.set_p.insert (static_cast<VisBufferComponent2> (i)); 118 : } 119 : 120 1 : return all; 121 : } 122 : 123 : 124 : String 125 1972 : VisBufferComponents2::name (VisBufferComponent2 id) 126 : { 127 : // This method is called only occasionally for debugging so at this time a 128 : // brute-force implmentation is acceptable. 129 : 130 3944 : map<VisBufferComponent2,String> names; 131 : 132 1972 : names [VisBufferComponent2::AllBeamOffsetsZero] = "AllBeamOffsetsZero"; 133 1972 : names [VisBufferComponent2::AntennaMounts] = "AntennaMounts"; 134 1972 : names [VisBufferComponent2::Antenna1] = "Antenna1"; 135 1972 : names [VisBufferComponent2::Antenna2] = "Antenna2"; 136 1972 : names [VisBufferComponent2::ArrayId] = "ArrayId"; 137 1972 : names [VisBufferComponent2::BeamOffsets] = "BeamOffsets"; 138 1972 : names [VisBufferComponent2::CorrType] = "CorrType"; 139 1972 : names [VisBufferComponent2::DataDescriptionIds] = "DataDescriptionIds"; 140 1972 : names [VisBufferComponent2::Direction1] = "Direction1"; 141 1972 : names [VisBufferComponent2::Direction2] = "Direction2"; 142 1972 : names [VisBufferComponent2::Exposure] = "Exposure"; 143 1972 : names [VisBufferComponent2::Feed1] = "Feed1"; 144 1972 : names [VisBufferComponent2::FeedPa1] = "FeedPa1"; 145 1972 : names [VisBufferComponent2::Feed2] = "Feed2"; 146 1972 : names [VisBufferComponent2::FeedPa2] = "FeedPa2"; 147 1972 : names [VisBufferComponent2::FieldId] = "FieldId"; 148 : //names [VisBufferComponent2::Flag] = "Flag"; 149 1972 : names [VisBufferComponent2::FlagCategory] = "FlagCategory"; 150 1972 : names [VisBufferComponent2::FlagCube] = "FlagCube"; 151 1972 : names [VisBufferComponent2::FlagCubes] = "FlagCubes"; 152 1972 : names [VisBufferComponent2::FlagRow] = "FlagRow"; 153 1972 : names [VisBufferComponent2::FloatData] = "FloatData"; 154 1972 : names [VisBufferComponent2::Frequencies] = "Frequencies"; 155 1972 : names [VisBufferComponent2::ImagingWeight] = "ImagingWeight"; 156 1972 : names [VisBufferComponent2::JonesC] = "JonesC"; 157 1972 : names [VisBufferComponent2::NAntennas] = "NAntennas"; 158 1972 : names [VisBufferComponent2::NChannels] = "NChannels"; 159 1972 : names [VisBufferComponent2::NCorrelations] = "NCorrelations"; 160 1972 : names [VisBufferComponent2::NRows] = "NRows"; 161 1972 : names [VisBufferComponent2::NShapes] = "NShapes"; 162 1972 : names [VisBufferComponent2::NRowsPerShape] = "NRowsPerShape"; 163 1972 : names [VisBufferComponent2::NChannelsPerShape] = "NChannelsPerShape"; 164 1972 : names [VisBufferComponent2::NCorrelationsPerShape] = "NCorrelationsPerShape"; 165 1972 : names [VisBufferComponent2::ObservationId] = "ObservationId"; 166 1972 : names [VisBufferComponent2::PhaseCenter] = "PhaseCenter"; 167 1972 : names [VisBufferComponent2::PolFrame] = "PolFrame"; 168 1972 : names [VisBufferComponent2::PolarizationId] = "PolarizationId"; 169 1972 : names [VisBufferComponent2::ProcessorId] = "ProcessorId"; 170 1972 : names [VisBufferComponent2::ReceptorAngles] = "ReceptorAngles"; 171 1972 : names [VisBufferComponent2::RowIds] = "RowIds"; 172 1972 : names [VisBufferComponent2::Scan] = "Scan"; 173 1972 : names [VisBufferComponent2::Sigma] = "Sigma"; 174 1972 : names [VisBufferComponent2::Sigmas] = "Sigmas"; 175 1972 : names [VisBufferComponent2::SpectralWindows] = "SpectralWindows"; 176 1972 : names [VisBufferComponent2::StateId] = "StateId"; 177 1972 : names [VisBufferComponent2::Time] = "Time"; 178 1972 : names [VisBufferComponent2::TimeCentroid] = "TimeCentroid"; 179 1972 : names [VisBufferComponent2::TimeInterval] = "TimeInterval"; 180 1972 : names [VisBufferComponent2::Weight] = "Weight"; 181 1972 : names [VisBufferComponent2::Weights] = "Weights"; 182 1972 : names [VisBufferComponent2::WeightScaled] = "WeightScaled"; 183 1972 : names [VisBufferComponent2::WeightSpectrum] = "WeightSpectrum"; 184 1972 : names [VisBufferComponent2::WeightSpectra] = "WeightSpectra"; 185 1972 : names [VisBufferComponent2::SigmaSpectrum] = "SigmaSpectrum"; 186 1972 : names [VisBufferComponent2::SigmaSpectra] = "SigmaSpectra"; 187 1972 : names [VisBufferComponent2::WeightSpectrumScaled] = "WeightSpectrumScaled"; 188 1972 : names [VisBufferComponent2::Uvw] = "Uvw"; 189 1972 : names [VisBufferComponent2::VisibilityCorrected] = "VisibilityCorrected"; 190 1972 : names [VisBufferComponent2::VisibilityModel] = "VisibilityModel"; 191 1972 : names [VisBufferComponent2::VisibilityObserved] = "VisibilityObserved"; 192 1972 : names [VisBufferComponent2::VisibilityCubeCorrected] = "VisibilityCubeCorrected"; 193 1972 : names [VisBufferComponent2::VisibilityCubeModel] = "VisibilityCubeModel"; 194 1972 : names [VisBufferComponent2::VisibilityCubeObserved] = "VisibilityCubeObserved"; 195 1972 : names [VisBufferComponent2::VisibilityCubeFloat] = "VisibilityCubeFloat"; 196 1972 : names [VisBufferComponent2::VisibilityCubesCorrected] = "VisibilityCubesCorrected"; 197 1972 : names [VisBufferComponent2::VisibilityCubesModel] = "VisibilityCubesModel"; 198 1972 : names [VisBufferComponent2::VisibilityCubesObserved] = "VisibilityCubesObserved"; 199 1972 : names [VisBufferComponent2::VisibilityCubesFloat] = "VisibilityCubesFloat"; 200 : 201 1972 : assert (names.size() == static_cast<int> (VisBufferComponent2::N_VisBufferComponents2)); 202 : 203 3944 : return names [id]; 204 : } 205 : 206 : VisBufferComponents2 207 12480 : VisBufferComponents2::none () 208 : { 209 12480 : return VisBufferComponents2 (); 210 : } 211 : 212 : VisBufferComponents2 213 556198 : VisBufferComponents2::singleton (VisBufferComponent2 component) 214 : { 215 556198 : VisBufferComponents2 result; 216 556198 : result.set_p.insert (component); 217 : 218 556198 : return result; 219 : } 220 : 221 : VisBufferComponents2 222 61839 : VisBufferComponents2::these (std::initializer_list<VisBufferComponent2> components) 223 : { 224 61839 : VisBufferComponents2 result; 225 : 226 1262943 : for (auto component : components){ 227 1201104 : result.set_p.insert (component); 228 : } 229 : 230 61839 : return result; 231 : } 232 : 233 : 234 : String 235 0 : VisBufferComponents2::toString () const 236 : { 237 0 : String result = "{"; 238 : 239 0 : for (const_iterator i = begin(); i != end(); i++){ 240 0 : result += name (*i) + ","; 241 : } 242 : 243 0 : * result.rbegin() = '}'; // replace last "," with "}" 244 : 245 0 : return result; 246 : } 247 : 248 : 249 : } // end namespace vi 250 : 251 : using namespace casacore; 252 : } // end namespace casa