7 #define N_INTEG_CHANS 10
28 char *
months[] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
29 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" };
47 int doingSpecFive = 0;
51 float sfxb[] = { 0.20, 0.20, 0.20, 0.05, 0.35 };
52 float sfxe[] = { 0.30, 0.30, 0.30, 0.15, 0.45 };
53 float sfyb[] = { 0.60, 0.13, 0.35, 0.35, 0.35 };
54 float sfye[] = { 0.85, 0.35, 0.60, 0.60, 0.60 };
63 struct _SPEC_FIVE specfives[5][20];
65 int specFiveChannel = 0;
74 struct SPEC_FIVE_PARAMS {
83 struct SPEC_FIVE_PARAMS sfp;
101 float *
xdata, freqres;
111 noint = (int)head->
noint;
124 sprintf(temp,
" %7.2f %8.8s", head->
scan, head->
backend);
129 if( (xdata = (
float *)malloc((
unsigned)(noint*
sizeof(
float)))) == NULL)
143 xdata[i] =
startRes - ((float)i*freqres);
150 xdata[i] = -
startRes + ((float)i*freqres);
179 cp = strtok(tmp,
"\n\t ");
186 log_msg(
"do_spectraCombine(), no begin scan specified");
190 cp = strtok((
char *)NULL,
"\n\t ");
197 log_msg(
"do_spectraCombine(), no begin scan specified");
201 cp = strtok((
char *)NULL,
"\n\t ");
208 log_msg(
"do_spectraCombine(), no IF specified");
212 strcpy(sc_image.magic,
"DS_IMAGE_INFO");
237 int i, j, k, n, indx, fac;
238 double accumX, accumY;
240 if(sc_image.scanct == 0)
248 if(sc_image.scan_noint > 1024)
250 n = sc_image.scan_noint;
265 if(sc_image.doBaseline)
266 sc_image.ydata[j++] = accumY / fac -((float)i *sc_image.a +sc_image.b);
268 sc_image.ydata[j++] = accumY / fac;
271 sc_image.noint = 1024;
275 if(sc_image.doBaseline)
277 for(i=0;i<sc_image.noint;i++)
278 sc_image.ydata[i] =
workingY[i] - ((
float)i * sc_image.a + sc_image.b);
282 for(i=0;i<sc_image.noint;i++)
290 sc_image.tsys = (float)(
workingTsys / (
double)sc_image.scanct);
314 float *i, iwt, *o, owt;
316 chan = (int)((head->
scan - (
int)head->
scan) * 100.0 + 0.005) - 1;
325 log_msg(
"Scan %.2f already in Spectral Accum", head->
scan);
329 if(sc_image.freqres == 0.0)
330 sc_image.freqres = (float)head->
freqres;
332 if( fabs(sc_image.freqres - (
float)head->
freqres) > 0.029 )
334 log_msg(
"specCombineData(), Freq Res %.3f, scan #%.2f not the same",
338 if(sc_image.ra == 0.0)
339 sc_image.ra = (float)head->
epocra / 15.0;
341 if( fabs(sc_image.ra - (
float)head->
epocra / 15.0 ) > 0.001 && !
ignorePos)
343 log_msg(
"specCombineData(), Ra %.3f, scan #%.2f not the same", head->
epocra, head->
scan);
346 if(sc_image.dec == 0.0)
347 sc_image.dec = (float)head->
epocdec;
351 log_msg(
"specCombineData(), Dec %.3f, scan #%.2f not the same", head->
epocdec, head->
scan);
355 if(sc_image.noint == 0)
356 sc_image.noint = sc_image.scan_noint = (int)head->
noint;
358 if( sc_image.scan_noint != (
int)head->
noint )
360 log_msg(
"specCombineData(), Noint %3d, scan #%.2f not the same as accumalator %3d", (
int)head->
noint, head->
scan, sc_image.scan_noint);
366 if( sc_image.sb != (
int)head->
sideband )
371 if(sc_image.freq == 0.0)
374 if( fabs(sc_image.freq - head->
restfreq) > 0.0001 )
376 log_msg(
"specCombineData(), Freq %.5f, scan #%.2f not the same",
380 if(sc_image.vel == 0.0)
388 if(sc_image.cal == 0.0)
389 sc_image.cal = (float)head->
tcal;
391 if( fabs(sc_image.cal - (
float)head->
tcal) > 100.0 )
393 log_msg(
"specCombineData(), Tcal %.1f, scan #%.2f not the same", head->
tcal, head->
scan);
397 if(sc_image.bscan == 0.0)
398 sc_image.bscan = (float)head->
scan;
400 sc_image.synfreq = head->
synfreq;
401 sc_image.escan = (
float)head->
scan;
402 sc_image.date = (float)head->
utdate;
403 sc_image.dv = (
float)head->
deltax;
405 log_msg(
"specCombineData(), adding scan %.2f", head->
scan);
409 strncpy(sc_image.source, head->
object, 16);
410 sc_image.source[15] =
'\0';
411 strncpy(sc_image.coordcd, head->
coordcd, 8);
412 sc_image.coordcd[7] =
'\0';
416 sc_image.time += (float)head->
inttime;
425 for(k=0;k<sc_image.scan_noint;k++, i++, o++)
426 *o = (*o * owt + *i * iwt) / (owt + iwt);
430 bcopy((
char *)xdata, (
char *)&
workingX, sc_image.scan_noint*
sizeof(
float));
444 for(p=spec_scans_head; p; p=q)
450 spec_scans_head = NULL;
462 if(spec_scans_head == NULL)
467 fprintf(stderr,
"Error of addSpecScans(malloc(%ld))\n",
sizeof(
struct SPEC_SCANS));
470 spec_scans_head->
scan = s;
471 spec_scans_head->
next = NULL;
475 for(m=spec_scans_head;m->
next; m=m->
next)
483 fprintf(stderr,
"Error of addSpecScans(malloc(%ld))\n",
sizeof(
struct SPEC_SCANS));
499 if(spec_scans_head == NULL)
502 for(m=spec_scans_head;m->
next; m=m->
next)
529 char raStr[20], decStr[20], timeStr[20], mapStr[60], buf[256];
540 yr = (int)image->date;
541 mon = (
int)((image->date - (float)yr) * 100.0);
542 day = (int)((image->date - (
float)yr) * 10000.0 +0.5)-mon*100.0;
544 sprintf(buf,
"%16.16s %3d SCANS: %7.2f-%7.2f INT=%s DATE: %2d %s %2.2d",
549 timeStr, day,
months[mon-1], yr-2000);
555 sprintf(mapStr,
" Col %3d Row %3d ", image->col,image->row);
559 sprintf(mapStr,
"( %s %s )", raStr, decStr);
562 sprintf(buf,
"%s=%s %s %s CAL= %5.1f TSYS= %5.0f",
572 sprintf(buf,
"FREQ= %.2f SYN= %10.8f VEL= %7.1f DV= %6.2f FR= %4.0f SB= %d",
574 image->synfreq / 1000.0,
577 image->freqres * 1000.0,
581 sprintf(buf,
"Rms %8.3fK",image->rms);
590 float xb, xe, yb, ye;
604 data = &im->
ydata[0];
606 noint = (int)im->
noint;
623 if( (xdata = (
float *)malloc((
unsigned)(noint*
sizeof(
float)))) == NULL)
673 log_msg(
"doSpecPlot(): depreceiated");
710 log_msg(
"putChanTemp(): depreceiated");
727 log_msg(
"doSpecPlotWinEvent()");
730 if(last_image == NULL)
739 case ButtonPressMask:
752 if(
xgr_findWindow(event->xbutton.display, event->xbutton.window, &w))
754 log_msg(
"xgr_findWindow() returned Non Zero");
760 x = ((float)event->xbutton.x - (
float)w->
plotxb) / x - 0.5;
763 y = ((float)w->
plotye - (
float)
event->xbutton.y) / y - 0.5;
765 fchan = (float)im->
noint;
767 fchan = x * fchan + (fchan / 2.0);
776 if(chan > im->
noint-1)
783 log_msg(
"X = %f, Y = %f, Chan = %.2f, %d = %f", x, y, fchan, chan, im->
ydata[chan]);
struct SPEC_SCANS * spec_scans_head
struct SPECTRA_DISPLAY_PARAMS sdp[MAX_IF_NUMS]
int doSpecWinRepaint(void)
int xgr_drawBin(float *xdata, float *ydata, int n, int color)
#define MAX_DATA_CHANNELS
int xgr_drawBox(double x, double y, double x2, double y2, int color)
char * strcmprs(char *str)
int checkKeyPress(XEvent *event)
int log_perror(char *msg)
int xgr_drawText(double x, double y, char *msg, int clr, int f)
int determine_min_max(float *ydata, int dl, double scan)
int combineData(float *xdata, float *yd, struct HEADER *head)
float workingY[MAX_CHANS]
struct LP_IMAGE_INFO last_image
int display_image(double xb, double xe, double yb, double ye, struct DS_IMAGE_INFO *im)
int doSpecPlotWinEvent(XEvent *event, unsigned int mask)
int computeBaseLine(struct LP_IMAGE_INFO *image)
int do_ignorePos(char *buf)
char * filename_ctssource[]
int do_spectraCombine(char *buf)
int sexagesimal(double dang, char *str, int prec)
int log_msg(const char *fmt,...)
int putChanTemp(int c, double t)
int addSpecScans(double s)
int do_sendSpecComb(void)
int xgr_findWindow(Display *dpy, Window win, struct WINDOW **w)
int do_scanDone(char *buf)
int checkSpecScans(double s)
int xgr_setFont(struct XGR_ *s, int f)
float xdata[MAX_ATM_ELEMENTS]
int putHeader(struct DS_IMAGE_INFO *image)
float workingX[MAX_CHANS]
int doSpecPlot(struct DS_IMAGE_INFO *im)
int display_spectra(double xb, double xe, double yb, double ye, float *data, struct HEADER *head, int procSpec)
int doSpecWinReSize(void)
float ydata[MAX_DATA_CHANNELS]