LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - ImageStatsBase.tcc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 53 0.0 %
Date: 2024-10-09 13:55:54 Functions: 0 5 0.0 %

          Line data    Source code
       1             : //# Copyright (C) 1998,1999,2000,2001,2003
       2             : //# Associated Universities, Inc. Washington DC, USA.
       3             : //#
       4             : //# This program is free software; you can redistribute it and/or modify it
       5             : //# under the terms of the GNU General Public License as published by the Free
       6             : //# Software Foundation; either version 2 of the License, or (at your option)
       7             : //# any later version.
       8             : //#
       9             : //# This program is distributed in the hope that it will be useful, but WITHOUT
      10             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      11             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
      12             : //# more details.
      13             : //#
      14             : //# You should have received a copy of the GNU General Public License along
      15             : //# with this program; if not, write to the Free Software Foundation, Inc.,
      16             : //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      17             : //#
      18             : //# Correspondence concerning AIPS++ should be addressed as follows:
      19             : //#        Internet email: casa-feedback@nrao.edu.
      20             : //#        Postal address: AIPS++ Project Office
      21             : //#                        National Radio Astronomy Observatory
      22             : //#                        520 Edgemont Road
      23             : //#                        Charlottesville, VA 22903-2475 USA
      24             : //#
      25             : //# $Id: $
      26             : 
      27             : #ifndef IMAGEANALYSIS_IMAGESTATSBASE_TCC
      28             : #define IMAGEANALYSIS_IMAGESTATSBASE_TCC
      29             : 
      30             : #include <imageanalysis/ImageAnalysis/ImageStatsBase.h>
      31             : 
      32             : namespace casa {
      33             : 
      34           0 : template <class T> ImageStatsBase<T>::ImageStatsBase(
      35             :     const SPCIIT image, const Record *const &regionPtr, const String& maskInp,
      36             :     const casacore::String& outname, casacore::Bool overwrite
      37             : ) : ImageTask<T>(
      38             :         image, regionPtr, maskInp, outname, overwrite
      39           0 :     ), _statistics(), _algConf() {
      40           0 :     _algConf.algorithm = StatisticsData::CLASSICAL;
      41           0 : }
      42             : 
      43           0 : template <class T> ImageStatsBase<T>::~ImageStatsBase() {}
      44             : 
      45             : template <class T> void ImageStatsBase<T>::configureBiweight(Int maxIter) {
      46             :     if (
      47             :         _algConf.algorithm != StatisticsData::BIWEIGHT
      48             :         || maxIter != _algConf.mi
      49             :     ) {
      50             :         _algConf.algorithm = StatisticsData::BIWEIGHT;
      51             :         _algConf.mi = maxIter;
      52             :         _statistics.reset();
      53             :     }
      54             : }
      55             : 
      56           0 : template <class T> void ImageStatsBase<T>::configureChauvenet(
      57             :     casacore::Double zscore, casacore::Int maxIterations
      58             : ) {
      59           0 :     if (
      60           0 :         _algConf.algorithm != StatisticsData::CHAUVENETCRITERION
      61           0 :         || ! casacore::near(_algConf.zs, zscore)
      62           0 :         || maxIterations != _algConf.mi
      63             :     ) {
      64           0 :         _algConf.algorithm = StatisticsData::CHAUVENETCRITERION;
      65           0 :         _algConf.zs = zscore;
      66           0 :         _algConf.mi = maxIterations;
      67           0 :         _statistics.reset();
      68             :     }
      69           0 : }
      70             : 
      71             : template <class T> void ImageStatsBase<T>::configureClassical(
      72             :     ImageStatsData::PreferredClassicalAlgorithm p
      73             : ) {
      74             :     if (
      75             :         _algConf.algorithm != casacore::StatisticsData::CLASSICAL
      76             :         || p != _prefClassStatsAlg
      77             :     ) {
      78             :         _algConf.algorithm = casacore::StatisticsData::CLASSICAL;
      79             :         _prefClassStatsAlg = p;
      80             :         _statistics.reset();
      81             :     }
      82             : }
      83             : 
      84             : template <class T> void ImageStatsBase<T>::configureFitToHalf(
      85             :     FitToHalfStatisticsData::CENTER centerType,
      86             :     FitToHalfStatisticsData::USE_DATA useData,
      87             :     casacore::Double centerValue
      88             : ) {
      89             :     if (
      90             :         _algConf.algorithm != StatisticsData::FITTOHALF
      91             :         || _algConf.ct != centerType
      92             :         || _algConf.ud != useData
      93             :         || (
      94             :             centerType == FitToHalfStatisticsData::CVALUE
      95             :             && ! casacore::near(_algConf.cv, centerValue)
      96             :         )
      97             :     ) {
      98             :         _algConf.algorithm = StatisticsData::FITTOHALF;
      99             :         _algConf.ct = centerType;
     100             :         _algConf.ud = useData;
     101             :         _algConf.cv = centerValue;
     102             :         _statistics.reset();
     103             :     }
     104             : }
     105             : 
     106             : template <class T>
     107             : void ImageStatsBase<T>::configureHingesFences(casacore::Double f) {
     108             :     if (
     109             :         _algConf.algorithm != StatisticsData::HINGESFENCES
     110             :         || ! casacore::near(_algConf.hf, f)
     111             :     ) {
     112             :         _algConf.algorithm = StatisticsData::HINGESFENCES;
     113             :         _algConf.hf = f;
     114             :         _statistics.reset();
     115             :     }
     116             : }
     117             : 
     118           0 : template <class T> String ImageStatsBase<T>::_configureAlgorithm() {
     119           0 :     String myAlg;
     120           0 :     switch (_algConf.algorithm) {
     121           0 :     case StatisticsData::BIWEIGHT:
     122           0 :         _statistics->configureBiweight(_algConf.mi, 6.0);
     123           0 :         myAlg = "Biweight";
     124           0 :         break;
     125           0 :     case StatisticsData::CHAUVENETCRITERION:
     126           0 :         _statistics->configureChauvenet(_algConf.zs, _algConf.mi);
     127           0 :         myAlg = "Chauvenet Criterion/Z-score";
     128           0 :         break;
     129           0 :     case StatisticsData::CLASSICAL:
     130           0 :         switch (_prefClassStatsAlg) {
     131           0 :         case ImageStatsData::AUTO:
     132           0 :             _statistics->configureClassical();
     133           0 :             break;
     134           0 :         case ImageStatsData::TILED_APPLY:
     135           0 :             _statistics->configureClassical(0, 0, 1, 1);
     136           0 :             break;
     137           0 :         case ImageStatsData::STATS_FRAMEWORK:
     138           0 :             _statistics->configureClassical(1, 1, 0, 0);
     139           0 :             break;
     140           0 :         default:
     141           0 :             ThrowCc("Unhandled classical stats type");
     142             :         }
     143           0 :         myAlg = "Classic";
     144           0 :         break;
     145           0 :     case StatisticsData::FITTOHALF:
     146           0 :         _statistics->configureFitToHalf(_algConf.ct, _algConf.ud, _algConf.cv);
     147           0 :         myAlg = "Fit-to-Half";
     148           0 :         break;
     149           0 :     case StatisticsData::HINGESFENCES:
     150           0 :         _statistics->configureHingesFences(_algConf.hf);
     151           0 :         myAlg = "Hinges-Fences";
     152           0 :         break;
     153           0 :     default:
     154           0 :         ThrowCc(
     155             :             "Logic Error: Unhandled statistics algorithm "
     156             :             + String::toString(_algConf.algorithm)
     157             :         );
     158             :     }
     159           0 :     return myAlg;
     160           0 : }
     161             : 
     162             : }
     163             : 
     164             : #endif

Generated by: LCOV version 1.16