Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
etime.c
Go to the documentation of this file.
1 #include "ds_extern.h"
2 
3 
4 struct DSTIME etime[] = {
5 
6 /* otf.c */
7  { "otfInit", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
8  { "freeOtfMemory", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
9  { "otfGridInit", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
10  { "do_addHeader", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
11  { "checkScanHeader", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
12  { "addScanHeader", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
13  { "remScanHeaders", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
14  { "do_ignoreScan", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
15  { "checkIgnoreScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
16  { "addIgnoreScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
17  { "remIgnoreScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
18  { "do_saveIgnoreScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
19  { "do_printIgnoreScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
20  { "do_clearIgnore", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
21  { "checkMapScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
22  { "addMapScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
23  { "remMapScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
24  { "do_printMapScans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
25  { "getNumSpectra", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
26  { "displaySingleOtfSpectra", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
27  { "stuffOtf", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
28  { "goWriteSingleChan", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
29  { "displaySingleChan", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
30  { "displayArrayGraph", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
31  { "do_otf", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
32  { "do_otfRegular", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
33  { "doOtfGridRePaint", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
34  { "doOtfGridReSize", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
35  { "do_otfRmBadChan", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
36  { "spikeCheck", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
37  { "computeInten", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
38  { "computeMinMax", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
39  { "computeShade", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
40  { "scaleData", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
41  { "subtractPredictedRA", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
42  { "placeBeamSize", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
43  { "initGrid", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
44  { "paintOtfGrid", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
45  { "putOtfGrid", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
46  { "drawColorBar", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
47  { "fillOtfGrid", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
48  { "accumDataIntoWork", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
49  { "zeroWorkArray", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
50  { "normalizeAndCal", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
51  { "insertVersion", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
52  { "shiftOtfChans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
53  { "accumWorkIntoGrid", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
54  { "recomputeBaseLines", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
55  { "computeBaseLine", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
56  { "computeRms", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
57  { "printKeySymHelp", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
58  { "dispatchOtfGridEvents", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
59  { "checkKeyPress", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
60  { "do_otfSendPlot", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
61  { "getRequestedCell", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
62  { "otfGridDisplaySpec", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
63  { "displayRequestedOtf", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
64  { "displayOtfGridSpectra", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
65  { "getBaselines", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
66  { "do_otfVelRun", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
67  { "do_otfGridDump", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
68  { "do_otfGridLoad", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
69  { "do_baseLines", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
70  { "do_otfBaseLine", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
71  { "do_otfBeamSize", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
72  { "do_otfGridInit", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
73  { "do_otfChans", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
74  { "do_otfTime", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
75  { "do_otfRms", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
76  { "do_otfTsys", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
77  { "do_otfDisplayArray", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
78  { "do_otfSingleBin", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
79  { "do_otfSingleChan", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
80  { "do_otfGridScale", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
81  { "do_otfGamma", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
82  { "do_otfColorChoice", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
83  { "do_otfNumColors", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
84  { "do_otfInterp", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
85  { "otfInterp", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
86  { "interpAndPlot", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
87  { "createXimage", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
88  { "do_otfChannelMap", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
89  { "getChanOTF", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
90  { "do_otfIFchoice", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
91  { "do_otfLoadChoice", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
92  { "createInterpTable", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
93  { "findInterp", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
94  { "do_otfSpectralSum", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
95  { "do_otf3dcube", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
96  { "do_otf3dplot", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
97  { "do_otfRmRMS", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
98  { "do_otfSpectraDebug", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
99  { "do_otfBadChan", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
100  { "fetchMapCell", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
101  { "setMapCell", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
102  { "findNextCell", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
103  { "do_fullInterpFill", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
104  { "do_otfFixBadCells", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
105  { "do_otfListCells", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
106  { "do_otfCutOff", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
107  { "forceDrawGrid", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
108  { "do_otfGridRa", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
109  { "do_otfGridDec", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
110  { "do_otfGridVelocity", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
111  { "do_otfGridNoint", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
112  { "do_otfGridAllowVelShift", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
113  { "do_otfGridCols", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
114  { "do_otfGridRows", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
115  { "do_otfGridRestfreq", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
116  { "do_otfGridFreqres", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
117  { "do_otfGridSizeRa", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
118  { "do_otfGridSizeDec", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
119  { "do_otfGridCellSizeRa", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
120  { "do_otfGridCellSizeDec", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
121  { "do_otfGridChanCompress", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
122  { "do_otfStatus", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
123  { "do_ephemObj", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
124  { "do_otfLockScale", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
125  { "interpAndWrite", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
126  { "lsqfit", 0, 0, 0, 0, 0.0, 0.0, 0.0 },
127 
128 /* xx.c */
129 
130  { NULL, 0, 0, 0, 0, 0.0, 0.0, 0.0 }
131 };
132 
133 
135 {
136  struct timeval tvv,*tp;
137  double d;
138 
139  tp = &tvv;
140  gettimeofday(tp,0);
141 
142  d = (double)tp->tv_sec + (double)tp->tv_usec / 1.0e6;
143 
144  return(d);
145 }
146 
147 
148 
150 {
151  int i;
152  struct DSTIME *p;
153 
154  p=&etime[0];
155 
156  for(i=0;p->funcName;i++,p++)
157  {
158  p->indx = i;
159  p->scalls = 0;
160  p->ecalls = 0;
161  p->stime = 0.0;
162  p->etime = 0.0;
163  p->ttime = 0.0;
164  }
165 
166  return(0);
167 }
168 
169 
171 {
172  do_etimeInit();
173 
174  return(0);
175 }
176 
177 /*
178 struct DSTIME {
179  char *funcName;
180 
181  int indx;
182  int pad;
183 
184  int scalls;
185  int ecalls;
186 
187  double stime;
188  double etime;
189 
190  double ttime;
191 };
192 */
193 
195 {
196  int i;
197  struct DSTIME *p;
198  char tbuf[256];
199  FILE *fp;
200 
201  if((fp = fopen("etime_funcs.h", "w")) == NULL)
202  {
203  log_msg("Unable to open etime_funcs.h");
204 
205  return(1);
206  }
207 
208  fprintf(fp, "#ifndef DSTIME_FUNCS_H\n");
209  fprintf(fp, "#define DSTIME_FUNCS_H\n\n");
210 
211  p=&etime[0];
212  for(i=0;p->funcName;i++,p++)
213  {
214  strcpy(tbuf, p->funcName);
215  strupr(tbuf);
216 
217  fprintf(fp, "#define %24.24s %5d\n", tbuf, p->indx);
218  }
219 
220  fprintf(fp, "\n#define MAX_DSTIME_FUNCTIONS %5d\n", i);
221 
222  fprintf(fp, "\n#endif\n");
223 
224  printf("Wrote %d defines to 'etime_funcs.h'\n", i);
225 
226  return(0);
227 }
228 
229 
231 {
232  int i;
233  struct DSTIME *p;
234  double tpercall;
235  double ttime = 0.0;
236 
237  printf("\n");
238 
239  p=&etime[0];
240  for(i=0;p->funcName;i++,p++)
241  {
242  if(p->ecalls)
243  {
244  tpercall = p->ttime / p->ecalls;
245  }
246  else
247  {
248  tpercall = 0.0;
249  }
250 
251  printf("%24.24s %5d %10d %10d %12.6lf %e\n",
252  p->funcName,
253  p->indx,
254  p->scalls,
255  p->ecalls,
256  p->ttime,
257  tpercall);
258 
259  ttime += p->ttime;
260  }
261 
262  printf(" Total Execution Time: %12.6lf Seconds\n", ttime);
263 
264  return(0);
265 }
266 
267 
268 int do_etime(func, action)
269 int func, action;
270 {
271  struct DSTIME *p;
272 
273  if(func < 0 || func > MAX_DSTIME_FUNCTIONS)
274  {
275  fprintf(stderr, "Bad function indx %d", func);
276  return(1);
277  }
278 
279  p=&etime[func];
280 
281  if(action == DSTIME_START)
282  {
283  p->stime = getElapseTime();
284  p->scalls++;
285 
286  return(0);
287  }
288 
289  if(action == DSTIME_STOP)
290  {
291  p->etime = getElapseTime();
292  p->ecalls++;
293 
294  p->ttime += (p->etime - p->stime);
295 
296  return(0);
297  }
298 
299 
300  return(0);
301 }
302 
303 
304 /*
305 
306 #ifdef DO_DSTIME
307  do_etime(OTFGRIDINIT, DSTIME_START);
308 #endif
309 
310 #ifdef DO_DSTIME
311  do_etime(OTFGRIDINIT, DSTIME_STOP);
312 #endif
313 
314  */
int do_etimeInit(void)
Definition: etime.c:149
char * funcName
Definition: etime.h:10
int do_etimeDump(void)
Definition: etime.c:194
int do_etime(int func, int action)
Definition: etime.c:268
struct DSTIME etime[]
Definition: etime.c:4
double stime
Definition: etime.h:18
#define MAX_DSTIME_FUNCTIONS
Definition: etime_funcs.h:125
FILE * fp
Definition: linuxpops.c:70
Definition: etime.h:9
char * strupr(char *str)
#define DSTIME_START
Definition: etime.h:6
double etime
Definition: etime.h:19
int log_msg(const char *fmt,...)
double getElapseTime(void)
Definition: etime.c:134
int ecalls
Definition: etime.h:15
double ttime
Definition: etime.h:21
int scalls
Definition: etime.h:16
#define DSTIME_STOP
Definition: etime.h:7
int do_etimeClear(void)
Definition: etime.c:170
int do_etimeShow(void)
Definition: etime.c:230
int indx
Definition: etime.h:12