Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ignore.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 double scan;
63 {
64  int i;
65 
66  for(i=0;i<MAX_IGNORED;i++)
67  {
68  if(env->ignoredscans[i] == 0.0)
69  {
70  st_report("Added %.2f to Ignored Scan Array", scan);
71  env->ignoredscans[i] = scan;
72  return(0);
73  }
74  }
75 
76  st_fail("Ignore Stack Full");
77 
78  return(1);
79 }
80 
81 
82 
83 
85 double scan;
86 {
87  int i;
88 
89  for(i=0;i<MAX_IGNORED;i++)
90  {
91  if(fabs(env->ignoredscans[i] - scan) < 0.005)
92  {
93  st_report("Removing %.2f from Ignored Scan Array", scan);
94  env->ignoredscans[i] = 0.0;
95  return(0);
96  }
97  }
98 
99  st_fail("Scan %.2f not found in removeIgnore()", scan);
100 
101  return(1);
102 }
103 
104 
105 
107 {
108  int i;
109  double scan;
110 
111  if(isSet(PF_C_FLAG))
112  {
113  clearIgnores();
114 
115  return(0);
116  }
117 
118  if(isSet(PF_L_FLAG))
119  {
120  tellIgnored();
121  return(0);
122  }
123 
124  for(i=1;i<MAX_TOKENS;i++)
125  {
126  if(strlen(args->tok[i]))
127  {
128  scan = atof(args->tok[i]);
129 
130  if(scan > 0.0)
131  {
132  addIgnore(scan);
133  }
134  else
135  if(scan < 0.0)
136  {
137  removeIgnore(scan * -1.0);
138  }
139  else
140  {
141  /*st_fail("Can't Add/Remove scan %.2f", scan)*/ ;
142  }
143  }
144  else
145  {
146  break;
147  }
148  }
149 
150  tellIgnored();
151 
152  return(0);
153 }
154 
155 
157 {
158  int i;
159 
160  st_print("%s # Ignored Scans: ", prompt);
161 
162  for(i=0;i<MAX_IGNORED;i++)
163  {
164  if(env->ignoredscans[i] > 0.0)
165  {
166  st_print("%8.2f ", env->ignoredscans[i]);
167 
168  if(i > 0 && !(i%8))
169  {
170  st_print("\n ");
171  }
172  }
173  }
174 
175  st_print("\n");
176 
177  return(0);
178 }
179 
180 
182 double scan;
183 {
184  int i;
185 
186  for(i=0;i<MAX_IGNORED;i++)
187  {
188  if(fabs(env->ignoredscans[i] - scan) < 0.005)
189  {
190  return(1);
191  }
192  }
193 
194  return(0);
195 }
196 
197 
199 {
200  st_report("Clearing out all Ignored Scans");
201 
202  bzero((char *)&env->ignoredscans, sizeof(env->ignoredscans));
203 
204  return(0);
205 }
206 
207 
209 {
210  FILE *fp;
211  char *string, line[256], fname[256];
212  double scan;
213 
214  if(strlen(args->secondArg) < 2)
215  {
216  st_warn("Missing arg for readIgnoreFile()");
217  return(1);
218  }
219 
220  strcpy(fname, args->secondArg);
221 
222  if((fp = fopen(fname, "r") ) <= (FILE *)0)
223  {
224  fprintf(stderr, "Unable to open file %s\n", fname);
225  return(0);
226  }
227 
228  while((string = fgets(line, sizeof(line), fp)) != NULL)
229  {
230  if(line[0] == '#')
231  {
232  continue;
233  }
234 
235  deNewLineIt(line); /* Clean it up */
236 
237  st_report("Parsing: %s", line);
238 
239  scan = atof(line);
240 
241  if(scan > 0.0)
242  {
243  addIgnore(scan);
244  }
245  else
246  if(scan < 0.0)
247  {
248  removeIgnore(scan * -1.0);
249  }
250  else
251  {
252  st_fail("Can't Add/Remove scan %.2f", scan);
253  }
254  }
255 
256  tellIgnored();
257 
258  fclose(fp);
259 
260  return(0);
261 }
262 
263 
265 {
266  int i, j = 0, ret;
267  char cmdBuf[256];
268  double scan;
269 
270  st_report("Displaying Ignored Scans");
271 
272  for(i=0;i<MAX_IGNORED;i++)
273  {
274  scan = env->ignoredscans[i];
275 
276  if(scan != 0.0)
277  {
278  sprintf(cmdBuf, "get %.2f", scan);
279  parseCmd(cmdBuf);
280 
281  sprintf(cmdBuf, "show");
282  parseCmd(cmdBuf);
283 
284  if(notSet(PF_N_FLAG))
285  {
286  ret = getYesNoQuit("Restore Scan %.2f: y/N ?", scan);
287 
288  if(ret == 1) /* 'y' */
289  {
290  sprintf(cmdBuf, "ignore %.2f", scan * -1.0);
291 
292  parseCmd(cmdBuf);
293  }
294  else
295  if(ret == 2) /* 'q' */
296  {
297  return(0);
298  }
299  }
300  else
301  {
302  xdelay(1000000);
303  }
304 
305  j++;
306  }
307  }
308 
309  st_report("Reviewed %d Ignoreed Scans", j);
310 
311  return(0);
312 }
char * prompt
Definition: makemem.c:101
struct PARSE_STACK * args
Definition: parse.h:196
int deNewLineIt(char *buf)
int removeIgnore(double scan)
Definition: ignore.c:84
int scan
int reviewIgnored()
Definition: ignore.c:264
int xdelay(int d)
Definition: linuxpops.c:3559
#define MAX_TOKENS
Definition: defines.h:40
FILE * fp
Definition: linuxpops.c:70
#define MAX_IGNORED
Definition: defines.h:39
char tok[MAX_TOKENS][MAX_TOKENS]
Definition: parse.h:176
double ignoredscans[MAX_IGNORED]
Definition: env.h:209
int ignoreScans()
Definition: ignore.c:106
int notSet(int flag)
Definition: parse.c:669
int addIgnore(double scan)
Definition: ignore.c:61
int getYesNoQuit()
struct ENVIRONMENT * env
Definition: linuxpops.c:71
int isSet(int flag)
Definition: parse.c:646
void st_warn()
void st_fail()
int isScanIgnored(double scan)
Definition: ignore.c:181
int clearIgnores()
Definition: ignore.c:198
void st_report()
char * secondArg
Definition: parse.h:181
void st_print()
int parseCmd(char *buf)
Definition: parse.c:2090
int readIgnoreFile()
Definition: ignore.c:208
int tellIgnored()
Definition: ignore.c:156