Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
obsmodes.c
Go to the documentation of this file.
1 #include "ds_extern.h"
2 #include "ds_proto.h"
3 
4 #ifdef GALACTIC
5 #undef GALACTIC
6 #endif
7 
8 #ifdef AZEL
9 #undef AZEL
10 #endif
11 
12 #ifdef USERDEF
13 #undef USERDEF
14 #endif
15 
16 
17 static int font1 = FONT_SIZE_NORMAL;
18 
19 extern struct HEADER onhead01;
20 
21 /*
22 , onhead02, onhead03,
23  onhead04, onhead05, onhead06,
24  onhead07, onhead08, onhead09,
25  onhead10, onhead11, onhead12,
26  onhead13, onhead14, onhead15,
27  onhead16;
28  */
29 
30 extern float *ondata01, *ondata02, *ondata03,
35  *ondata16;
36 
37 extern struct HEADER offhead01;
38 
39 extern float *offdata01, *offdata02, *offdata03,
44  *offdata16;
45 
46 extern struct HEADER gainshead01;
47 
48 extern float *gainsdata01, *gainsdata02, *gainsdata03,
53  *gainsdata16;
54 
55 extern float scanNum, otfIFNumber, datamin, datamax;
56 extern int chanSelOTF, lockScale;
57 extern char filename[], gfilename[], source[], prgName[];
59 
60 int mhz_4if_mode = 0;
61 int khz_4if_mode = 0;
62 int aos_4if_mode = 0;
63 int non_if_mode = 0;
64 int dbe_mode = 0;
65 
66 struct XBE_POS m4[] = { { COL_1+0.05, COL_2,},
67  { COL_2+0.05, COL_3 },
68  { COL_3+0.05, COL_4 },
69  { COL_4+0.05, COL_5 },
70 };
71 
72 struct XBE_POS m3[] = { { COL_1 +0.05, COL_2B },
73  { COL_2B+0.05, COL_3B },
74  { COL_3B+0.05, COL_5 },
75 };
76 
77 struct XBE_POS m2[] = { { COL_1+0.05, COL_3 },
78  { COL_3+0.05, COL_5 },
79 };
80 
81 struct XBE_POS m1[] = { { COL_1+0.05, COL_5 },
82 };
83 
85 
86  /* FFB-A */ /* FFB-B */ /* FFB-C */ /* FFB-D */
87  { 1, 0.01, 0.66, 1.0, &ondata01, &onhead01, 0, &mhz_4if_mode, BACKEND_FFB, "F1M-1"},
88  { 1, 0.02, 0.66, 1.0, &ondata01, &onhead01, 0, &mhz_4if_mode, BACKEND_FFB, "F1M-2"},
89  { 1, 0.03, 0.66, 1.0, &ondata01, &onhead01, 0, &mhz_4if_mode, BACKEND_FFB, "F1M-3"},
90  { 1, 0.04, 0.66, 1.0, &ondata01, &onhead01, 0, &mhz_4if_mode, BACKEND_FFB, "F1M-4"},
91 
92  /* FB2-A */ /* FB2-B */ /* FB2-C */ /* FB2-D */
93  { 1, 0.05, 0.33, 0.66, &ondata01, &onhead01, 0, &khz_4if_mode, BACKEND_FFB, "FQM-1"},
94  { 1, 0.06, 0.33, 0.66, &ondata01, &onhead01, 0, &khz_4if_mode, BACKEND_FFB, "FQM-2"},
95  { 1, 0.07, 0.33, 0.66, &ondata01, &onhead01, 0, &khz_4if_mode, BACKEND_FFB, "FQM-3"},
96  { 1, 0.08, 0.33, 0.66, &ondata01, &onhead01, 0, &khz_4if_mode, BACKEND_FFB, "FQM-4"},
97 
98  /* AOS-AB */
99  { 1, 0.01, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_AOS, "A1M-1"},
100  { 1, 0.02, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_AOS, "A1M-2"},
101  { 0, 0.02, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_AOS, "A1M-3"},
102  { 0, 0.02, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_AOS, "A1M-4"},
103 
104  /* AOS-C */
105  { 1, 0.05, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_AOS, "AQM-1"},
106  { 0, 0.05, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_AOS, "AQM-2"},
107  { 0, 0.05, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_AOS, "AQM-3"},
108  { 0, 0.05, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_AOS, "AQM-4"},
109 
110  /* CTS-A */
111  { 1, 0.01, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_CTS, "C50-1"},
112  { 0, 0.01, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_CTS, "C50-2"},
113  { 0, 0.01, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_CTS, "C50-3"},
114  { 0, 0.01, 0.009, 0.33, &ondata01, &onhead01, 0, &aos_4if_mode, BACKEND_CTS, "C50-4"},
115 
116  /* DBE */
117  { 1, 0.01, 0.009, 0.33, &ondata01, &onhead01, 0, &dbe_mode, BACKEND_DBE},
118  { 1, 0.02, 0.009, 0.33, &ondata01, &onhead01, 0, &dbe_mode, BACKEND_DBE},
119  { 1, 0.03, 0.009, 0.33, &ondata01, &onhead01, 0, &dbe_mode, BACKEND_DBE},
120  { 1, 0.04, 0.009, 0.33, &ondata01, &onhead01, 0, &dbe_mode, BACKEND_DBE}
121 };
122 
123 
124 float ifnums[] = { 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08};
125 
126 int ignore_gains = 0,
128 
130 
131 float ifNumber = 0.01;
132 struct BOX_DATA bd;
133 
134 
135 int loadFile(ifNum)
136 float ifNum;
137 {
138  char *cp;
139  int ret=0;
140 
141  cp = filename;
142 
143  if( (ret = read_scan( scanNum + ifNum, cp, &ondata01, &onhead01)) != 0 )
144  return(ret);
145 
146  strncpy(source, onhead01.object, SRCLEN);
147  source[SRCLEN] = '\0';
148 
149  return(ret);
150 }
151 
152 
153 
155 {
156  restoreMsg=1;
157 
158  return(0);
159 }
160 
161 
162 
164 {
165  int i, n, k, ret;
166  float requestOff, requestGains;
167  char *cp;
168 
169  if(debug)
170  log_msg("Entering do_lineotf");
171 
172  k = chanSelOTF;
173 
174  otfIFNumber = sdp[k].ifnum;
175 
176  if(debug)
177  log_msg("Using %s for OTF", sdp[k].name);
178 
179  cp = filename;
180 
181  if(debug)
182  log_msg("Using %s file ", cp);
183 
185 
186  if(ret)
187  {
188  if(ret != -2)
189  {
190  log_msg("On scan #%.2f, NOT found in %s", scanNum+otfIFNumber, cp);
191  }
192 
193  return(0);
194  }
195 
196  requestOff = onhead01.offscan;
197 
198  if(read_scan( requestOff, cp, &offdata01, &offhead01))
199  {
200  log_msg("Off scan #%.2f, NOT found in %s", requestOff, cp);
201  return(0);
202  }
203 
204  requestGains = (double)((int)onhead01.gains) + otfIFNumber;
205 
206  cp = gfilename;
207 
208  if(read_scan( requestGains, cp, &gainsdata01, &gainshead01))
209  {
210  log_msg("Gain scan #%.2f, NOT found in %s", requestGains, cp);
211  return(0);
212  }
213 
214  if(ignore_gains)
215  {
216  log_msg("Ignoring Gains");
217 
218  n = (int)gainshead01.noint;
219 
220  for(i=0;i<n;i++)
221  {
222  gainsdata01[i] = 400.0;
223  }
224  }
225 
227 
229 
230  return(0);
231 }
232 
233 
235 struct HEADER *head;
236 {
237  char temp[128];
238 
239  lastGraph = 0;
240  xgr_clearScreen();
241  strncpy(source, head->object, SRCLEN);
242  source[SRCLEN] = '\0';
243  sprintf(temp, "Source: %s", source);
244  xgr_drawText(0.38, 0.985, temp, RED, font1);
245 
246  return(0);
247 }
248 
249 
250 
251 int clipDataProc(data, head, nchan, cd)
252 float *data;
253 struct HEADER *head;
254 int nchan, cd;
255 {
256  int i, j, n;
257 
258  if(cd == 0)
259  return(1);
260 
261  n = nchan - (cd*2);
262  for(j=0, i=cd;i<(n+cd);i++)
263  data[j++] = data[i];
264 
265  head->noint = head->noint - (cd*2);
266  head->datalen = head->datalen - (cd*2*sizeof(float));
267  head->refpt = head->refpt - (float)cd;
268 
269  return(0);
270 }
271 
272 
273 
274 
276 {
277  int i, first=1, j;
278  float old_y = -1.0;
279  struct SPECTRA_DISPLAY_PARAMS *p;
280 
282  khz_4if_mode = found_scans[FB2A] + found_scans[FB2B] + found_scans[FB2C] + found_scans[FB2D];
283  aos_4if_mode = found_scans[AOSA] + found_scans[AOSB] + found_scans[AOSC] + found_scans[CTSA];
284  dbe_mode = found_scans[DBEA] + found_scans[DBEB] + found_scans[DBEC] + found_scans[DBED];
285 
286  log_msg("FFB = %d, FB2 = %d, AOS = %d, DBE = %d", mhz_4if_mode, khz_4if_mode,
288 
289  for(i=0,p = &sdp[0];i<MAX_IF_NUMS;i++,p++)
290  {
291  if(p->active)
292  {
293  if(!read_scan(scanNum + p->ifnum, filename, p->data, p->head))
294  {
295  if(first)
296  {
297  setSourceName(p->head);
298  first = 0;
299  }
300 
301  if(old_y != p->yb)
302  {
303  j = 0;
304  old_y = p->yb;
305  }
306 
307  clipDataProc(*p->data, p->head, (int)p->head->noint, p->clip);
308 
309  if(*p->mode == 4)
310  display_spectra(m4[j].xb, m4[j].xe, p->yb, p->ye, *p->data, p->head, TRUE);
311  else
312  if(*p->mode == 3)
313  display_spectra(m3[j].xb, m3[j].xe, p->yb, p->ye, *p->data, p->head, TRUE);
314  else
315  if(*p->mode == 2)
316  display_spectra(m2[j].xb, m2[j].xe, p->yb, p->ye, *p->data, p->head, TRUE);
317  else
318  if(*p->mode == 1)
319  display_spectra(m1[j].xb, m1[j].xe, p->yb, p->ye, *p->data, p->head, TRUE);
320 
321  j++;
322  }
323  }
324  }
325 
326  return(0);
327 }
328 
329 
331 {
332  if(ondata01) {
334  free((char *)ondata01);
335  ondata01 = (float *)NULL;
336  }
337 /*
338  if(ondata02) {
339  printData(ondata02);
340  free((char *)ondata02);
341  ondata02 = (float *)NULL;
342  }
343  if(ondata03) {
344  printData(ondata03);
345  free((char *)ondata03);
346  ondata03 = (float *)NULL;
347  }
348  if(ondata04) {
349  printData(ondata04);
350  free((char *)ondata04);
351  ondata04 = (float *)NULL;
352  }
353  if(ondata05) {
354  printData(ondata05);
355  free((char *)ondata05);
356  ondata05 = (float *)NULL;
357  }
358  if(ondata06) {
359  printData(ondata06);
360  free((char *)ondata06);
361  ondata06 = (float *)NULL;
362  }
363  if(ondata07) {
364  printData(ondata07);
365  free((char *)ondata07);
366  ondata07 = (float *)NULL;
367  }
368  if(ondata08) {
369  printData(ondata08);
370  free((char *)ondata08);
371  ondata08 = (float *)NULL;
372  }
373  if(ondata09) {
374  printData(ondata09);
375  free((char *)ondata09);
376  ondata09 = (float *)NULL;
377  }
378 */
379 
380 
381  if(offdata01) {
382  free((char *)offdata01);
383  offdata01 = (float *)NULL;
384  }
385  if(offdata02) {
386  free((char *)offdata02);
387  offdata02 = (float *)NULL;
388  }
389  if(offdata03) {
390  free((char *)offdata03);
391  offdata03 = (float *)NULL;
392  }
393  if(offdata04) {
394  free((char *)offdata04);
395  offdata04 = (float *)NULL;
396  }
397  if(offdata05) {
398  free((char *)offdata05);
399  offdata05 = (float *)NULL;
400  }
401  if(offdata06) {
402  free((char *)offdata06);
403  offdata06 = (float *)NULL;
404  }
405  if(offdata07) {
406  free((char *)offdata07);
407  offdata07 = (float *)NULL;
408  }
409  if(offdata08) {
410  free((char *)offdata08);
411  offdata08 = (float *)NULL;
412  }
413  if(offdata09) {
414  free((char *)offdata09);
415  offdata09 = (float *)NULL;
416  }
417 
418 
419  if(gainsdata01) {
420  free((char *)gainsdata01);
421  gainsdata01 = (float *)NULL;
422  }
423  if(gainsdata02) {
424  free((char *)gainsdata02);
425  gainsdata02 = (float *)NULL;
426  }
427  if(gainsdata03) {
428  free((char *)gainsdata03);
429  gainsdata03 = (float *)NULL;
430  }
431  if(gainsdata04) {
432  free((char *)gainsdata04);
433  gainsdata04 = (float *)NULL;
434  }
435  if(gainsdata05) {
436  free((char *)gainsdata05);
437  gainsdata05 = (float *)NULL;
438  }
439  if(gainsdata06) {
440  free((char *)gainsdata06);
441  gainsdata06 = (float *)NULL;
442  }
443  if(gainsdata07) {
444  free((char *)gainsdata07);
445  gainsdata07 = (float *)NULL;
446  }
447  if(gainsdata08) {
448  free((char *)gainsdata08);
449  gainsdata08 = (float *)NULL;
450  }
451  if(gainsdata09) {
452  free((char *)gainsdata09);
453  gainsdata09 = (float *)NULL;
454  }
455 
456  return(0);
457 }
458 
459 
460 
461 int printData(f)
462 float *f;
463 {
464  int i=0, j=0;
465  char tb[20], outBuf[256];
466 
467  if(printDataLines)
468  {
469  strcpy(outBuf, " ");
470  while(i<printDataLines)
471  {
472  sprintf(tb, "%.4f ", f[j]);
473  strcat(outBuf, tb);
474  j++;
475  if(!(j%10))
476  {
477  log_msg("%s\n", outBuf);
478  strcpy(outBuf, " ");
479  i++;
480  }
481  }
482  }
483 
484  return(0);
485 }
struct HEADER * head
Definition: spectra.h:42
float * ondata10
Definition: dataserv.c:77
int loadFile()
Definition: io.c:440
#define SRCLEN
Definition: defines.h:9
float * offdata07
Definition: dataserv.c:86
float * offdata11
Definition: dataserv.c:86
struct SPECTRA_DISPLAY_PARAMS sdp[MAX_IF_NUMS]
Definition: obsmodes.c:84
#define DBEC
Definition: spectra.h:31
#define DBED
Definition: spectra.h:32
struct XBE_POS m1[]
Definition: obsmodes.c:81
#define BACKEND_AOS
Definition: defines.h:36
float * offdata03
Definition: dataserv.c:86
int first
Definition: dbase.c:106
#define COL_3B
Definition: spectra.h:5
float otfIFNumber
Definition: otf.c:23
#define COL_5
Definition: spectra.h:7
double noint
Definition: header.h:211
int lockScale
Definition: xgr.c:31
double datalen
Definition: header.h:34
struct XBE_POS m4[]
Definition: obsmodes.c:66
float * gainsdata08
Definition: dataserv.c:95
struct BOX_DATA bd
Definition: obsmodes.c:132
int clipDataProc(float *data, struct HEADER *head, int nchan, int cd)
Definition: obsmodes.c:251
float * ondata07
Definition: dataserv.c:77
float * ondata11
Definition: dataserv.c:77
#define BACKEND_CTS
Definition: defines.h:37
float * ondata15
Definition: dataserv.c:77
char source[SRCLEN+1]
Definition: dataserv.c:52
#define AOSB
Definition: spectra.h:20
int xgr_drawText(double x, double y, char *msg, int clr, int f)
#define RED
Definition: colors.h:5
int mhz_4if_mode
Definition: obsmodes.c:60
int freeDataPointers(void)
Definition: obsmodes.c:330
int do_lineotf(void)
Definition: obsmodes.c:163
int read_scan()
#define AOSC
Definition: spectra.h:21
char filename[256]
Definition: dataserv.c:49
double offscan
Definition: header.h:115
Definition: header.h:13
struct HEADER onhead01
Definition: dataserv.c:67
float * ondata13
Definition: dataserv.c:77
float * offdata04
Definition: dataserv.c:86
float * offdata14
Definition: dataserv.c:86
float * ondata01
Definition: dataserv.c:77
int lastGraph
Definition: otf.c:26
float * gainsdata01
Definition: dataserv.c:95
int aos_4if_mode
Definition: obsmodes.c:62
#define FB2A
Definition: spectra.h:14
float * ondata02
Definition: dataserv.c:77
float * gainsdata06
Definition: dataserv.c:95
#define FONT_SIZE_NORMAL
Definition: dataFonts.h:7
float * offdata08
Definition: dataserv.c:86
struct HEADER * head
Definition: optical.h:17
float * gainsdata07
Definition: dataserv.c:95
#define COL_4
Definition: spectra.h:6
int debug
Definition: mailparse.c:29
float * offdata13
Definition: dataserv.c:86
float * ondata06
Definition: dataserv.c:77
double gains
Definition: header.h:145
float * ondata08
Definition: dataserv.c:77
float * ondata09
Definition: dataserv.c:77
float * offdata06
Definition: dataserv.c:86
struct XBE_POS m3[]
Definition: obsmodes.c:72
int log_msg(const char *fmt,...)
int found_scans[MAX_BACKENDS *MAX_PARTS]
Definition: dataserv.c:58
float * gainsdata16
Definition: dataserv.c:95
#define AOSA
Definition: spectra.h:19
char gfilename[256]
Definition: dataserv.c:50
int do_linedefault(void)
Definition: obsmodes.c:275
#define MAX_IF_NUMS
Definition: defines.h:31
float * gainsdata04
Definition: dataserv.c:95
double datamin
Definition: dataserv.c:44
int do_linetotalmapoff(void)
Definition: obsmodes.c:154
struct HEADER offhead01
Definition: dataserv.c:84
float * ondata04
Definition: dataserv.c:77
float * gainsdata05
Definition: dataserv.c:95
float * offdata16
Definition: dataserv.c:86
float * ondata05
Definition: dataserv.c:77
#define FFBD
Definition: spectra.h:12
int chanSelOTF
Definition: otf.c:24
#define CTSA
Definition: spectra.h:24
struct XBE_POS m2[]
Definition: obsmodes.c:77
#define COL_1
Definition: spectra.h:1
int non_if_mode
Definition: obsmodes.c:63
#define FB2C
Definition: spectra.h:16
#define FFBC
Definition: spectra.h:11
float * offhead10
Definition: dataserv.c:86
float * gainsdata13
Definition: dataserv.c:95
float * ondata16
Definition: dataserv.c:77
float * offdata09
Definition: dataserv.c:86
int printDataLines
Definition: dataserv.c:39
float * offdata05
Definition: dataserv.c:86
float * offdata15
Definition: dataserv.c:86
int setSourceName(struct HEADER *head)
Definition: obsmodes.c:234
float * offdata12
Definition: dataserv.c:86
float * offdata01
Definition: dataserv.c:86
#define FB2D
Definition: spectra.h:17
#define DBEA
Definition: spectra.h:29
int printData(float *f)
Definition: obsmodes.c:461
float ifNumber
Definition: obsmodes.c:131
float * offdata02
Definition: dataserv.c:86
int fitFail
Definition: dataserv.c:104
int restoreMsg
Definition: obsmodes.c:127
struct HEADER gainshead01
Definition: dataserv.c:93
#define BACKEND_FFB
Definition: defines.h:35
double refpt
Definition: header.h:207
int ignoreThisChan
Definition: read_scan.c:12
float * ondata12
Definition: dataserv.c:77
double datamax
Definition: dataserv.c:44
#define MAX_PARTS
Definition: backends.h:15
#define MAX_BACKENDS
Definition: backends.h:14
float * gainsdata15
Definition: dataserv.c:95
float * gainsdata03
Definition: dataserv.c:95
float * gainsdata10
Definition: dataserv.c:95
#define FB2B
Definition: spectra.h:15
float scanNum
Definition: dataserv.c:46
#define BACKEND_DBE
Definition: defines.h:38
int do_otf(float *data, struct HEADER *head, float *offdata, float *gainsdata)
Definition: otf.c:1006
float * ondata03
Definition: dataserv.c:77
float * gainsdata12
Definition: dataserv.c:95
float * gainsdata14
Definition: dataserv.c:95
char prgName[80]
Definition: dataserv.c:52
#define COL_2
Definition: spectra.h:2
#define DBEB
Definition: spectra.h:30
float ifnums[]
Definition: obsmodes.c:124
int dbe_mode
Definition: obsmodes.c:64
#define TRUE
Definition: xgraphic.c:39
float * ondata14
Definition: dataserv.c:77
#define COL_2B
Definition: spectra.h:3
int ignore_gains
Definition: obsmodes.c:126
#define FFBB
Definition: spectra.h:10
char object[16]
Definition: header.h:40
float * gainsdata02
Definition: dataserv.c:95
int display_spectra(double xb, double xe, double yb, double ye, float *data, struct HEADER *head, int procSpec)
#define FFBA
Definition: spectra.h:9
#define COL_3
Definition: spectra.h:4
int xgr_checkForEvents(void)
Definition: xgr.c:2547
float * gainsdata11
Definition: dataserv.c:95
float * gainsdata09
Definition: dataserv.c:95
int khz_4if_mode
Definition: obsmodes.c:61
int xgr_clearScreen(void)
Definition: xgr.c:921