RdbStatsPercentilesAve.cc

00001 // File:  RdbStatsPercentilesAve.cc
00002 
00003 // --8<--8<--8<--8<--
00004 //
00005 // Copyright (C) 2006 Smithsonian Astrophysical Observatory
00006 //
00007 // This file is part of rdbstats
00008 //
00009 // rdbstats is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 //
00014 // rdbstats is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this program; if not, write to the 
00021 //       Free Software Foundation, Inc. 
00022 //       51 Franklin Street, Fifth Floor
00023 //       Boston, MA  02110-1301, USA
00024 //
00025 // -->8-->8-->8-->8--
00026 
00027 #include "RdbStatsPercentilesAve.h"
00028 
00029 // The user specified percentiles.  For example: --percentiles 12,34,45
00030 RdbStatsPercentilesAve::RdbStatsPercentilesAve( RDB& irdbtable,
00031                                                 const string& name,
00032                                                 const string& percent_list,
00033                                                 bool implicitquartile )
00034   throw( Exception ) try : RdbStatsPercentiles( irdbtable, name,
00035                                                 percent_list,
00036                                                 implicitquartile ) {
00037 
00038     try {
00039 
00040 #ifdef TRACEFCT
00041       TraceFct tf( "RdbStatsPercentilesAve::RdbStatsPercentilesAve( RDB&, "
00042                    "const string&, const string& ) throw( Exception )" );
00043 #endif
00044 
00045     } catch ( Exception& E ) {
00046 
00047       throw;
00048 
00049     } catch ( exception& e ) {
00050 
00051       throw Exception( e.what( ) );
00052 
00053     }
00054 
00055   } catch ( Exception& E ) {
00056 
00057     // exception thrown by RdbStatsPercentiles class is caught here
00058     throw;
00059 
00060   } catch ( exception& e ) {
00061 
00062     // exception thrown by RdbStatsPercentiles class is caught here
00063     throw Exception( e.what( ) );
00064 
00065   }
00066 
00067 // --quartiles was entered at the command line.
00068 RdbStatsPercentilesAve::RdbStatsPercentilesAve( RDB& irdbtable,
00069                                                 const string& name )
00070   throw( Exception ) try : RdbStatsPercentiles( irdbtable, name ) {
00071 
00072     try {
00073 
00074 #ifdef TRACEFCT
00075       TraceFct tf( "RdbStatsPercentilesAve::RdbStatsPercentilesAve( RDB&, "
00076                    "const string&, const string& ) throw( Exception )" );
00077 #endif
00078 
00079     } catch ( Exception& E ) {
00080 
00081       throw;
00082 
00083     } catch ( exception& e ) {
00084 
00085       throw Exception( e.what( ) );
00086 
00087     }
00088 
00089   } catch ( Exception& E ) {
00090 
00091     // exception thrown by RdbStatsPercentiles class is caught here
00092     throw;
00093 
00094   } catch ( exception& e ) {
00095 
00096     // exception thrown by RdbStatsPercentiles class is caught here
00097     throw Exception( e.what( ) );
00098 
00099   }
00100 
00101 int RdbStatsPercentilesAve::calculate_statistics( ) throw( ) {
00102 
00103 #ifdef TRACEFCT
00104   TraceFct tf( "double RdbStatsPercentilesAve::calculate_statistics( ) "
00105                "throw( )" );
00106 #endif
00107 
00108   // calculate the regular-stats and the percentiles.
00109   if ( 0 == this->RdbStatsPercentiles::calculate_statistics( ) )
00110     return 0;
00111 
00112   // normalize the result wrt the average.
00113   double norm_factor = get_absolute_average( );
00114   normalize_results( norm_factor );
00115 
00116   return num_n;
00117 
00118 }