Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
scansum.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 
64 int recordScanSum(indx, s)
65 int indx;
66 struct SCAN_SUM *s;
67 {
68  int wif; /* which IF */
69  double sq, trms;
70  struct LP_IMAGE_INFO *image = h0;
71 
72 
73  wif = getFeed(h0->head.scan) -1;
74 
75  st_print("Recording Scan Sum, indx %d, IF %d\n", indx, wif);
76 
77  /* we are doint the 250's so shift it down. */
78  if(env->issmt && h0->head.freqres == 0.250 && wif > 3)
79  {
80  wif -= 4;
81  }
82 
83  if(wif > -1 && wif < MAX_IFS)
84  {
85  s->scan[wif] = h0->head.scan;
86  s->ut[wif] = h0->head.ut;
87  s->lst[wif] = h0->head.lst;
88  s->az[wif] = h0->head.az;
89  s->el[wif] = h0->head.el;
90  s->tsys[wif] = h0->head.stsys;
91  s->tcal[wif] = h0->head.tcal;
92 
93  s->peak[wif] = env->datamax;
94 
95  /* Go compute the baseline which computes
96  the rms of the baseline region */
97  computeBaseLine(image);
98 
99  if(env->hwdc < 0.5)
100  {
101  setHWDC(image);
102  }
103 
104  sq = sqrt(fabs(image->head.freqres) * 1e6 * image->head.inttime * env->hwdc);
105 
106  if(sq > 0.0)
107  {
108  trms = image->head.stsys * 2.0 / sq;
109  }
110  else
111  {
112  st_fail("sqrt(freqres * inttime * hwdc) = %f", sq);
113  trms = 99999.0;
114  }
115 
116  s->rms[wif] = trms;
117  }
118  else
119  {
120  st_fail("Computed IF %d, out of range", wif);
121  return(1);
122  }
123 
124  return(0);
125 }
126 
127 
128 int scansum()
129 {
130  int indx, scan;
131  struct SCAN_SUM *s;
132 
133  if(isSet(PF_I_FLAG))
134  {
135  bzero((char *)&ss, sizeof(ss));
136 
137  return(0);
138  }
139 
140  if(isSet(PF_R_FLAG))
141  {
142  if(isSpecFivePoint(&h0->head))
143  {
144  st_print("Skipping 5-Point Scan\n");
145  return(0);
146  }
147 
148  scan = (int)h0->head.scan;
149  if(ss.last_scan == 0)
150  {
151  ss.last_scan = scan;
152  }
153 
154  if(ss.last_scan != scan)
155  {
156  ss.nscans++;
157  ss.last_scan = scan;
158  }
159 
160  indx = ss.nscans;
161 
162  if(indx == 0)
163  {
164  strcpy(ss.magic, "SCAN_SUM_SEND");
165 
166  bcopy((char *)&h0->head, (char *)&ss.head, sizeof(ss.head));
167  }
168 
169  s = &ss.scans[indx];
170 
171  recordScanSum(indx, s);
172 
173  return(0);
174  }
175 
176  if(isSet(PF_S_FLAG))
177  {
178  /* Set the defaults */
181 
182  if(isSet(PF_U_FLAG))
183  {
185  }
186  else
187  if(isSet(PF_A_FLAG))
188  {
190  }
191  else
192  if(isSet(PF_E_FLAG))
193  {
195  }
196  else
197  if(isSet(PF_U_FLAG))
198  {
200  }
201  else
202  if(isSet(PF_L_FLAG))
203  {
205  }
206  else
207  if(isSet(PF_N_FLAG))
208  {
210  }
211 
212  if(isSet(PF_M_FLAG))
213  {
215  }
216  else
217  if(isSet(PF_T_FLAG))
218  {
220  }
221  else
222  if(isSet(PF_C_FLAG))
223  {
225  }
226 
227  ss.plotwin = env->plotwin;
228  ss.xdelay = env->xdelay;
229  ss.yscale = env->yscale;
230  ss.ylower = env->ylower;
231  ss.yupper = env->yupper;
232 
233  st_report("Sending SCAN_SUM Struct to XGraphics");
234 
235  sock_write(xgraphic, (char *)&ss, sizeof(ss));
236 
237  return(0);
238  }
239 
240  return(0);
241 }
struct SOCK * xgraphic
Definition: linuxpops.c:75
struct LP_IMAGE_INFO * h0
Definition: image.c:74
struct SCAN_SUM_SEND ss
Definition: scansum.c:61
int getFeed()
double az
Definition: header.h:82
double scan
Definition: header.h:35
#define SCAN_SUM_X_SCANS
Definition: scan_sum.h:6
int last_scan
Definition: scan_sum.h:36
int sock_write(struct SOCK *s, char *message, int l)
double el[MAX_IFS]
Definition: scan_sum.h:23
#define SCAN_SUM_Y_RMS
Definition: scan_sum.h:14
Definition: parse.h:8
double tcal[MAX_IFS]
Definition: scan_sum.h:28
double rms[MAX_IFS]
Definition: scan_sum.h:26
int scan
#define SCAN_SUM_Y_TSYS
Definition: scan_sum.h:15
int setHWDC(struct LP_IMAGE_INFO *image)
Definition: line.c:884
float ylower
Definition: scan_sum.h:45
struct HEADER head
Definition: scan_sum.h:34
double tcal
Definition: header.h:202
#define SCAN_SUM_X_LST
Definition: scan_sum.h:8
int xdelay
Definition: env.h:144
#define SCAN_SUM_X_NUM
Definition: scan_sum.h:11
int computeBaseLine(struct LP_IMAGE_INFO *image)
Definition: baseline.c:200
int issmt
Definition: env.h:63
int scansum(void)
Definition: scansum.c:128
char magic[16]
Definition: scan_sum.h:33
struct ENVIRONMENT * env
Definition: linuxpops.c:71
double peak[MAX_IFS]
Definition: scan_sum.h:25
double hwdc
Definition: env.h:205
int isSet(int flag)
Definition: parse.c:646
struct HEADER head
Definition: image.h:104
double lst[MAX_IFS]
Definition: scan_sum.h:21
double lst
Definition: header.h:63
#define SCAN_SUM_X_EL
Definition: scan_sum.h:10
double datamax
Definition: env.h:180
float yupper
Definition: scan_sum.h:46
#define SCAN_SUM_X_UT
Definition: scan_sum.h:7
int isSpecFivePoint(struct HEADER *h)
Definition: line.c:2186
void st_fail()
struct SCAN_SUM scans[MAX_SCAN_SUM]
Definition: scan_sum.h:51
double ylower
Definition: env.h:287
#define SCAN_SUM_Y_PEAK
Definition: scan_sum.h:13
double stsys
Definition: header.h:203
double ut[MAX_IFS]
Definition: scan_sum.h:20
int plotwin
Definition: env.h:129
int yscale
Definition: env.h:149
double scan[MAX_IFS]
Definition: scan_sum.h:19
int recordScanSum(int indx, struct SCAN_SUM *s)
Definition: scansum.c:64
#define SCAN_SUM_Y_TCAL
Definition: scan_sum.h:16
void st_report()
double el
Definition: header.h:83
double tsys[MAX_IFS]
Definition: scan_sum.h:27
double yupper
Definition: env.h:288
double inttime
Definition: header.h:210
#define SCAN_SUM_X_AZ
Definition: scan_sum.h:9
void st_print()
#define MAX_IFS
Definition: accum.h:5
double freqres
Definition: header.h:199
double ut
Definition: header.h:62
double az[MAX_IFS]
Definition: scan_sum.h:22