Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
stack.c
Go to the documentation of this file.
1 /*
2 Copyright 2021 Arizona Board of Regents on behalf of the University of Arizona.
3 
4 For commercial uses, to obtain a license to sell and or sublicense copies of
5 the Software please contact the University of Arizona at Tech Launch Arizona:
6 lewish@tla.arizona.edu.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction for non-commercial use educational and
11 research purposes, including without limitation the rights to use, copy,
12 modify, merge, publish, distribute, and to permit persons to whom the Software
13 is furnished to do so, subject to the following conditions:
14 
15 The entire above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25 
26 1. Additional Required Provisions
27 
28 1.1. Arbitration. The parties agree that if a dispute arises between them
29 concerning this Agreement, the parties may be required to submit the matter to
30 arbitration pursuant to Arizona law.
31 
32 1.2. Applicable Law and Venue. This Agreement shall be interpreted pursuant
33 to the laws of the State of Arizona. Any arbitration or litigation between the
34 Parties shall be conducted in Pima County, ARIZONA, and LICENSEE hereby
35 submits to venue and jurisdiction in Pima County, ARIZONA.
36 
37 1.3. Non-Discrimination. The Parties agree to be bound by state and federal
38 laws and regulations governing equal opportunity and non-discrimination and
39 immigration.
40 
41 1.4. Appropriation of Funds. The Parties recognize that performance by
42 ARIZONA may depend upon appropriation of funds by the State Legislature of
43 ARIZONA. If the Legislature fails to appropriate the necessary funds, or if
44 ARIZONA’S appropriation is reduced during the fiscal year, ARIZONA may cancel
45 this Agreement without further duty or obligation. ARIZONA will notify
46 LICENSEE as soon as reasonably possible after it knows of the loss of funds.
47 
48 1.5. Conflict of Interest. This Agreement is subject to the provisions of
49 A.R.S. 38-511 and other conflict of interest regulations. Within three years
50 of the EFFECTIVE DATE, ARIZONA may cancel this Agreement if any person
51 significantly involved in initiating, negotiating, drafting, securing, or
52 creating this Agreement for or on behalf of ARIZONA becomes an employee or
53 consultant in any capacity of LICENSEE with respect to the subject matter of
54 this Agreement.
55 
56  */
57 
58 
59 #include "extern.h"
60 
62 
63 /* Stack routines; empty, fill, add, delete, list, inc */
64 int doStack()
65 {
66 
68  {
69  st_report("Stack Entered");
70  }
71 
72  if(isSet(PF_E_FLAG))
73  {
74  stackEmpty();
75  }
76  else
77  if(isSet(PF_F_FLAG))
78  {
79  stackFill();
80  }
81  else
82  if(isSet(PF_G_FLAG))
83  {
84  subArgs(2, "%.2f", env->stackscan);
85  p_getScan();
86  }
87  else
88  if(isSet(PF_L_FLAG))
89  {
90  stackList();
91  }
92  else
93  if(isSet(PF_I_FLAG))
94  {
95  stackInc();
96  }
97  else
98  if(isSet(PF_A_FLAG)) /* Not sure about this one */
99  {
100  stackAdd();
101  }
102  else
103  if(isSet(PF_R_FLAG))
104  {
105  stackReset();
106  }
107  else
108  {
110  return(1);
111  }
112 
113  return(0);
114 }
115 
116 
118 {
119  int i, indx=0;
120  struct HEADER *p;
121 
123  {
124  st_report("Inside Stack Fill");
125  }
126 
127  /* First clear out old stack */
128  stackEmpty();
129 
130  p = &sa[0];
131 
132  /* Now find the qualified scans */
133  for(i=0;i<env->numofscans;i++,p++)
134  {
135  /* Check the most obvious critiria */
136  if(!meetsCritiria(p, CHECK_ALL))
137  {
138  continue;
139  }
140 
141  if(env->mode == MODE_SPEC)
142  {
143  /* Check for proper LINE* Mode */
144  if(strncmp(p->obsmode, "LINEBSP", 7) &&
145  strncmp(p->obsmode, "LINEPS", 6) &&
146  strncmp(p->obsmode, "LINEFS", 6) &&
147  strncmp(p->obsmode, "LINETPON", 8) &&
148  strncmp(p->obsmode, "LINEAPS", 7)) /* We only process BSP, APS & PS so far*/
149  {
150  continue; /* Not Spectral */
151  }
152 
153  if(p->openpar[5] == 5555.5) /* a BSP focal */
154  {
155  continue; /* Ignore */
156  }
157  }
158  else
159  {
160  if(strncmp(p->obsmode, "CONTSEQ", 7)) /* We only process Seq */
161  {
162  continue; /* No good */
163  }
164  }
165 
166  /* Is this scan ignored??? */
167  if(isScanIgnored(p->scan))
168  {
170  continue;
171  }
172 
173  /* Made it this far; add it in */
174 
175  sstack[indx++] = p->scan;
176  }
177 
178  env->acount = indx;
179 
180  st_report("Added %d scans to stack", env->acount);
181 
182  stackReset();
183 
184  return(0);
185 }
186 
187 
189 {
190  /* Reset stack pointer to zero */
191  env->stackindx = 0; /* No it's pointing to the first element */
193  env->stackdone = 0;
194 
196  {
197  st_report("Stack Pointing reset to Zero");
198  }
199 
200  return(0);
201 }
202 
203 
205 {
206  int i;
207 
209  {
210  st_report("Inside Stack List");
211  }
212 
213  for(i=0;i<env->acount;i++)
214  {
215  if(!(i%8))
216  {
217  st_print("\n%4d: ", i+1);
218  }
219 
220  st_print("%8.2f", sstack[i]);
221  }
222 
223  if(env->acount)
224  {
225  st_print("\n");
226  }
227 
228  return(0);
229 }
230 
231 
233 {
235  {
236  st_report("Inside Stack Empty");
237  }
238 
239  bzero((char *)&sstack, sizeof(sstack));
240 
241  env->stackindx = 0;
242  env->acount = 0;
243  env->stackdone = 0;
244 
245  return(0);
246 }
247 
248 
249 int stackAdd()
250 {
251  st_report("Inside Stack Add: Not implemented yet");
252 
253  return(0);
254 }
255 
256 
257 int stackInc()
258 {
260  {
261  st_report("Inside Stack Inc");
262  }
263 
264  env->stackindx++;
265 
267 
268  if(env->stackindx >= env->acount)
269  {
270  st_report("stack(): Reached end of stack");
271  env->stackdone = 1;
272  env->stackindx = env->acount;
273  }
274 
275  return(0);
276 }
#define VERBOSE_BATCH
Definition: defines.h:74
double scan
Definition: header.h:35
int stackAdd(void)
Definition: stack.c:249
double stackscan
Definition: env.h:268
struct PARSE_STACK * args
Definition: parse.h:196
Definition: parse.h:8
Definition: header.h:13
int printH_FlagHelp(char *cmd)
Definition: help.c:430
struct HEADER * sa
Definition: linuxpops.c:72
int stackInc(void)
Definition: stack.c:257
double openpar[10]
Definition: header.h:155
int stackindx
Definition: env.h:138
int incrementRejIgnored(void)
Definition: reject.c:169
int stackReset(void)
Definition: stack.c:188
struct ENVIRONMENT * env
Definition: linuxpops.c:71
int stackList(void)
Definition: stack.c:204
int isSet(int flag)
Definition: parse.c:646
int doStack(void)
Definition: stack.c:64
int stackFill(void)
Definition: stack.c:117
int stackdone
Definition: env.h:137
double indx
Definition: header.h:84
char obsmode[8]
Definition: header.h:41
int meetsCritiria(struct HEADER *p, int mask)
Definition: observe.c:90
int acount
Definition: env.h:21
int stackEmpty(void)
Definition: stack.c:232
float sstack[MAX_STACK]
Definition: stack.c:61
int isScanIgnored(double scan)
Definition: ignore.c:181
int mode
Definition: env.h:75
#define MODE_SPEC
Definition: defines.h:87
void st_report()
int numofscans
Definition: env.h:85
#define MAX_STACK
Definition: defines.h:143
void subArgs(int wt, const char *fmt,...)
Definition: parse.c:430
#define CHECK_ALL
Definition: defines.h:64
void st_print()
char * firstArg
Definition: parse.h:180
int p_getScan()
Definition: io.c:796
int verboseLevel
Definition: linuxpops.c:80