Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
xaxis.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 
61 struct X_AXIS_ARRAY {
62  double chans;
63  double vel;
64  double freq;
65 };
66 
68 
69 /* This version was from xgraphic.c */
70 int computeXaxis(image, logit)
71 struct LP_IMAGE_INFO *image;
72 int logit;
73 {
74  int i, n;
75  struct HEADER *h;
76  float *p;
77 
78  h = &image->head;
79 
80  n = h->noint;
81  if(image->pinfo.x1mode == XMODE_FREQ)
82  {
83  if(logit)
84  {
85  st_report("# Loading X1-Axis with Frequency Values");
86  }
87 
88  p = &image->x1data[0];
89  if( h->sideband == 2.0)
90  {
91  for(i=0;i<n;i++,p++)
92  {
93  *p = -(h->refpt * h->freqres) + ((float)i * h->freqres);
94  }
95  }
96  else
97  {
98  for(i=0;i<n;i++,p++)
99  {
100  *p = +(h->refpt * h->freqres) - ((float)i * h->freqres);
101  *p *= -1.0;
102  }
103  }
104  }
105  else
106  if(image->pinfo.x1mode == XMODE_VEL)
107  {
108 
109  if(logit)
110  {
111  st_report("# Loading X1-Axis with Velocity Values");
112  }
113 
114  p = &image->x1data[0];
115  if( h->sideband == 2.0)
116  {
117  for(i=0;i<h->noint;i++,p++)
118  {
119  *p = (float)(h->refpt_vel - (h->refpt * h->deltax) + ((i+1) * h->deltax));
120  }
121  }
122  else
123  {
124  for(i=0;i<h->noint;i++,p++)
125  {
126  *p = (float)(h->refpt_vel - (h->refpt * h->deltax) + ((i+1) * h->deltax));
127  }
128  }
129  }
130  else
131  if(image->pinfo.x1mode == XMODE_CHAN)
132  {
133  if(logit)
134  {
135  st_report("# Loading X1-Axis with Channel Numbers");
136  }
137 
138  p = &image->x1data[0];
139  for(i=0;i<h->noint;i++,p++)
140  {
141  *p = (float)i;
142  }
143  }
144 
145  if(image->pinfo.x2mode == XMODE_FREQ)
146  {
147  if(logit)
148  {
149  st_report("# Loading X2-Axis with Frequency Values");
150  }
151 
152  p = &image->x2data[0];
153  if( h->sideband == 2.0)
154  {
155  for(i=0;i<n;i++,p++)
156  {
157  *p = -(h->refpt * h->freqres) + ((float)i * h->freqres);
158  }
159  }
160  else
161  {
162  for(i=0;i<n;i++,p++)
163  {
164  *p = +(h->refpt * h->freqres) - ((float)i * h->freqres);
165  *p *= -1.0;
166  }
167  }
168  }
169  else
170  if(image->pinfo.x2mode == XMODE_VEL)
171  {
172 
173  if(logit)
174  {
175  st_report("# Loading X2-Axis with Velocity Values");
176  }
177 
178  p = &image->x2data[0];
179  if( h->sideband == 2.0)
180  {
181  for(i=0;i<h->noint;i++,p++)
182  {
183  *p = (float)(h->refpt_vel - (h->refpt * h->deltax) + ((i+1) * h->deltax));
184  }
185  }
186  else
187  {
188  for(i=0;i<h->noint;i++,p++)
189  {
190  *p = (float)(h->refpt_vel - (h->refpt * h->deltax) + ((i+1) * h->deltax));
191  }
192  }
193  }
194  else
195  if(image->pinfo.x2mode == XMODE_CHAN)
196  {
197  if(logit)
198  {
199  st_report("# Loading X2-Axis with Channel Numbers");
200  }
201 
202  p = &image->x2data[0];
203  for(i=0;i<h->noint;i++,p++)
204  {
205  *p = (float)i;
206  }
207  }
208 
209  return(0);
210 }
211 
212 
213 int makeXaxisArray(image)
214 struct LP_IMAGE_INFO *image;
215 {
216  int i, n;
217  struct HEADER *h;
218  struct X_AXIS_ARRAY *p;
219 
220  h = &image->head;
221  n = h->noint;
222 
223  p = &x_axis_array[0];
224  if( h->sideband == 2.0)
225  {
226  for(i=0;i<n;i++,p++)
227  {
228  p->chans = (double)i;
229  p->freq = -(h->refpt * h->freqres) + ((float)i * h->freqres);
230  }
231  }
232  else
233  {
234  for(i=0;i<n;i++,p++)
235  {
236  p->chans = (double)i;
237  p->freq = +(h->refpt * h->freqres) - ((float)i * h->freqres);
238  p->freq *= -1.0;
239  }
240  }
241 
242  p = &x_axis_array[0];
243  if( h->sideband == 2.0)
244  {
245  for(i=0;i<h->noint;i++,p++)
246  {
247  p->vel = (float)(h->refpt_vel - (h->refpt * h->deltax) + ((i+1) * h->deltax));
248  }
249  }
250  else
251  {
252  for(i=0;i<h->noint;i++,p++)
253  {
254  p->vel = (float)(h->refpt_vel - (h->refpt * h->deltax) + ((i+1) * h->deltax));
255  }
256  }
257 
258  return(0);
259 }
260 
261 
262 int findXaxisElement(image, x1, x2, b, e)
263 struct LP_IMAGE_INFO *image;
264 double x1, x2;
265 int *b, *e;
266 {
267  int i, indx, n;
268  double ddiff;
269  struct HEADER *h;
270  struct X_AXIS_ARRAY *p;
271 
272  *b = 0;
273  *e = 0;
274 
275  h = &image->head;
276  n = h->noint;
277 
278  if(image->pinfo.x1mode == XMODE_FREQ)
279  {
280  ddiff = 99999999.9;
281  p = &x_axis_array[0];
282  for(i=0;i<n;i++,p++)
283  {
284  if(fabs(p->freq-x1) < ddiff)
285  {
286  indx = i;
287  ddiff = fabs(p->freq-x1);
288  }
289  }
290 
291  *b = indx;
292 
293  ddiff = 99999999.9;
294  p = &x_axis_array[0];
295  for(i=0;i<n;i++,p++)
296  {
297  if(fabs(p->freq-x2) < ddiff)
298  {
299  indx = i;
300  ddiff = fabs(p->freq-x2);
301  }
302  }
303 
304  *e = indx;
305 
306  return(0);
307  }
308  else
309  if(image->pinfo.x1mode == XMODE_VEL)
310  {
311  ddiff = 99999999.9;
312  p = &x_axis_array[0];
313  for(i=0;i<n;i++,p++)
314  {
315  if(fabs(p->vel-x1) < ddiff)
316  {
317  indx = i;
318  ddiff = fabs(p->vel-x1);
319  }
320  }
321 
322  *b = indx;
323 
324  ddiff = 99999999.9;
325  p = &x_axis_array[0];
326  for(i=0;i<n;i++,p++)
327  {
328  if(fabs(p->vel-x2) < ddiff)
329  {
330  indx = i;
331  ddiff = fabs(p->vel-x2);
332  }
333  }
334 
335  *e = indx;
336 
337  return(0);
338  }
339  else
340  if(image->pinfo.x1mode == XMODE_CHAN)
341  {
342  *b = (int)x1;
343  *e = (int)x2;
344 
345  return(0);
346  }
347  else
348  {
349  return(1);
350  }
351 
352  return(1);
353 }
double noint
Definition: header.h:211
#define MAX_CHANS
Definition: defines.h:38
Definition: header.h:13
double freq
Definition: xaxis.c:64
double sideband
Definition: header.h:143
#define XMODE_CHAN
Definition: defines.h:97
double refpt_vel
Definition: header.h:175
int findXaxisElement(struct LP_IMAGE_INFO *image, double x1, double x2, int *b, int *e)
Definition: xaxis.c:262
double vel
Definition: xaxis.c:63
#define XMODE_FREQ
Definition: defines.h:95
double refpt
Definition: header.h:207
void st_report()
int makeXaxisArray(struct LP_IMAGE_INFO *image)
Definition: xaxis.c:213
double deltax
Definition: header.h:209
int computeXaxis(struct LP_IMAGE_INFO *image, int logit)
Definition: xaxis.c:70
#define XMODE_VEL
Definition: defines.h:96
double freqres
Definition: header.h:199
struct X_AXIS_ARRAY x_axis_array[MAX_CHANS]
Definition: xaxis.c:67
double chans
Definition: xaxis.c:62