LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - ImageCollapserData.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 78 0.0 %
Date: 2024-10-29 13:38:20 Functions: 0 4 0.0 %

          Line data    Source code
       1             : #include <imageanalysis/ImageAnalysis/ImageCollapserData.h>
       2             : 
       3             : #include <casacore/casa/BasicSL/String.h>
       4             : #include <casacore/casa/Exceptions/Error.h>
       5             : 
       6             : using namespace casacore;
       7             : namespace casa {
       8             : 
       9             : std::shared_ptr<std::map<uInt, String>> ImageCollapserData::_funcNameMap = nullptr;
      10             : std::shared_ptr<std::map<uInt, String>> ImageCollapserData::_minMatchMap = nullptr;
      11             : std::shared_ptr<std::set<ImageCollapserData::AggregateType>>
      12             : ImageCollapserData::_degenAxesSupported = nullptr;
      13             : 
      14           0 : std::shared_ptr<const std::map<uInt, String>> ImageCollapserData::funcNameMap() {
      15           0 :         if (! _funcNameMap) {
      16           0 :                 std::map<uInt, String> ref;
      17           0 :                 ref[(uInt)FLUX] = "flux";
      18           0 :                 ref[(uInt)MADM] = "madm";
      19           0 :                 ref[(uInt)MAX] = "max";
      20           0 :                 ref[(uInt)MEAN] = "mean";
      21           0 :                 ref[(uInt)MEDIAN] = "median";
      22           0 :                 ref[(uInt)MIN] = "min";
      23           0 :                 ref[(uInt)NPTS] = "npts";
      24           0 :                 ref[(uInt)RMS] = "rms";
      25           0 :                 ref[(uInt)SQRTSUM] = "sqrtsum";
      26           0 :                 ref[(uInt)SQRTSUM_NPIX_BEAM] = "sqrtsum_npix_beam";
      27           0 :                 ref[(uInt)SQRTSUM_NPIX] = "sqrtsum_npix";
      28           0 :                 ref[(uInt)STDDEV] = "stddev";
      29           0 :                 ref[(uInt)SUM] = "sum";
      30           0 :                 ref[(uInt)VARIANCE] = "variance";
      31           0 :                 ref[(uInt)XMADM] = "xmadm";
      32           0 :                 ref[(uInt)ZERO] = "zero";
      33           0 :                 _funcNameMap.reset(new std::map<uInt, String>(ref));
      34           0 :         }
      35           0 :         return _funcNameMap;
      36             : }
      37             : 
      38           0 : std::shared_ptr<const std::map<uInt, String>> ImageCollapserData::minMatchMap() {
      39           0 :         if (! _minMatchMap) {
      40           0 :                 std::map<uInt, String> ref;
      41           0 :                 ref[(uInt)FLUX] = "f";
      42           0 :                 ref[(uInt)MADM] = "mad";
      43           0 :                 ref[(uInt)MAX] = "max";
      44           0 :                 ref[(uInt)MEAN] = "mea";
      45           0 :                 ref[(uInt)MEDIAN] = "med";
      46           0 :                 ref[(uInt)MIN] = "mi";
      47           0 :                 ref[(uInt)NPTS] = "n";
      48           0 :                 ref[(uInt)RMS] = "r";
      49           0 :                 ref[(uInt)SQRTSUM] = "sqrtsum";
      50           0 :                 ref[(uInt)SQRTSUM_NPIX_BEAM] = "sqrtsum_npix_beam";
      51           0 :                 ref[(uInt)SQRTSUM_NPIX] = "sqrtsum_npix";
      52           0 :                 ref[(uInt)STDDEV] = "st";
      53           0 :                 ref[(uInt)SUM] = "su";
      54           0 :                 ref[(uInt)VARIANCE] = "v";
      55           0 :                 ref[(uInt)XMADM] = "x";
      56           0 :                 ref[(uInt)ZERO] = "z";
      57           0 :                 _minMatchMap.reset(new std:: map<uInt, String>(ref));
      58           0 :         }
      59           0 :         return _minMatchMap;
      60             : }
      61             : 
      62           0 : ImageCollapserData::AggregateType ImageCollapserData::aggregateType(
      63             :         const String& aggString
      64             : ) {
      65           0 :         ThrowIf (
      66             :                 aggString.empty(),
      67             :                 "Aggregate function name is not specified and it must be."
      68             :         );
      69           0 :         String agg = aggString;
      70           0 :         agg.downcase();
      71           0 :         auto funcNamePtr = funcNameMap();
      72           0 :         auto minMatch = minMatchMap();
      73           0 :         for (const auto& p: *minMatch) {
      74           0 :             auto key = p.first;
      75           0 :             auto minMatch = p.second;
      76           0 :             auto funcName = (*funcNamePtr).at(key);
      77           0 :             if (
      78           0 :                 agg.startsWith(minMatch)
      79           0 :                 && funcName.startsWith(agg)
      80             :             ) {
      81           0 :                 return (AggregateType)key;
      82             :             }
      83           0 :         }
      84           0 :         ThrowCc("Unknown aggregate function specified by " + aggString);
      85           0 : }
      86             : 
      87             : std::shared_ptr<const std::set<ImageCollapserData::AggregateType>>
      88           0 : ImageCollapserData::aggTypesSupportedDegenAxes() {
      89           0 :     if (! _degenAxesSupported) {
      90           0 :         std::set<AggregateType> ref;
      91           0 :         ref.insert(MADM);
      92           0 :         ref.insert(MAX);
      93           0 :         ref.insert(MEAN);
      94           0 :         ref.insert(MEDIAN);
      95           0 :         ref.insert(MIN);
      96           0 :         ref.insert(NPTS);
      97           0 :         ref.insert(RMS);
      98           0 :         ref.insert(STDDEV);
      99           0 :         ref.insert(SUM);
     100           0 :         ref.insert(VARIANCE);
     101           0 :         ref.insert(XMADM);
     102           0 :         _degenAxesSupported.reset(new std::set<AggregateType>(ref));
     103           0 :     }
     104           0 :     return _degenAxesSupported;
     105             : }
     106             : 
     107             : 
     108             : }

Generated by: LCOV version 1.16