maxMinTOD.c

Go to the documentation of this file.
00001 /*******************************************************************************
00002 *   M3:  maxMinTOD.c                                                           *
00003 *                                                                              *
00004 *   Version 2.0.2 May 2007                                                     *
00005 *                                                                              *
00006 *   Copyright (C) 2004-2007  C.M. Cantalupo                                    *
00007 *                                                                              *
00008 *   This program is free software; you can redistribute it and/or modify       *
00009 *   it under the terms of the GNU General Public License as published by       *
00010 *   the Free Software Foundation; either version 2 of the License, or          *
00011 *   (at your option) any later version.                                        *
00012 *                                                                              *
00013 *   This program is distributed in the hope that it will be useful,            *
00014 *   but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00015 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
00016 *   GNU General Public License for more details.                               *
00017 *                                                                              *
00018 *   You should have received a copy of the GNU General Public License          *
00019 *   along with this program; if not, write to the Free Software                *
00020 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  *
00021 *                                                                              *
00022 *******************************************************************************/
00023 
00024 
00071 /*   Christopher M. Cantalupo November 2007 */
00072 
00073 
00074 #include <stdlib.h>
00075 #include <math.h>
00076 #include "M3.h"
00077 
00078 #define STRING_LENGTH 256
00079 
00080 
00081 
00082 int main( int argc, char **argv )
00083 {
00084   M3_RunConfigStruct *runConfig;
00085   M3_DataSetLL *dataSet;
00086   M3_IntervalLL *intervalNode;
00087   int notDone;
00088   int64_t i, j, k, l, n;
00089   M3_Interval interval;
00090   double *tod = NULL;
00091   double maxVal = -HUGE_VAL, minVal = HUGE_VAL;
00092 
00093   /* Read run config from disk */
00094   M3_RunConfigStruct_Read(&runConfig, argv[1], M3_SPRINGTIDE_RUN_TYPE );
00095 
00096   /* Go through all of the dataSets (detectors) */
00097   for ( notDone = M3_RunConfigStruct_GetDataSetRoot( runConfig, &dataSet );
00098         notDone;
00099         M3_DataSetLL_GetNextNodeInList( &dataSet ))
00100   {
00101     /* Go through the covered intervals */
00102     for( notDone = M3_DataSetLL_GetCoveredIntervalRoot( dataSet, &intervalNode);
00103          notDone;
00104          notDone = M3_IntervalLL_GetNextNodeInList( &intervalNode ) )
00105     {
00106       /* Retrieve the interval structure from the list node */
00107       M3_IntervalLL_GetInterval( intervalNode, &interval );
00108       /* Count the number of samples in the interval*/
00109       n = interval.lastSample - interval.firstSample + 1;
00110 
00111       /* If we have alread allocated tod and pointing, call realloc */
00112       if( tod )
00113       {
00114         tod = (double*)realloc( tod, sizeof(double)*n);
00115       }
00116       /* Otherwise allocate memory with malloc */
00117       else
00118       {
00119         tod = (double*)malloc( sizeof(double)*n);
00120       }
00121 
00122       /* Get the time ordered data*/
00123       M3_DataSetLL_GetTOD( dataSet, interval, tod );
00124 
00125       /* Cycle over all of the samples in the interval. */
00126       /* i keeps track of the time index from the beginning of the interval */
00127       for( i = 0; i < n; i++ )
00128       {
00129         if( tod[i] > maxVal )
00130           maxVal = tod[i];
00131         if( tod[i] < minVal )
00132           minVal = tod[i];
00133       }
00134     }
00135   }
00136   fprintf(stdout, "maximum = %.8e\n", maxVal);
00137   fprintf(stdout, "minimum = %.8e\n", minVal);
00138 
00139   free(tod);
00140 
00141   return 0;
00142 }
00143 

Generated on Mon Nov 24 10:05:12 2008 for M3 by  doxygen 1.5.3-20071008