void moonradec(double time, double *ra, double *dec) { double ttime, asnode, amon, peri, em, aim, aam, vsm, alamm, moonsun, evn, var; double x, y, z, xx, yy, zz, ram, decm, ha, inc; /* calc moon ra and dec */ /* see notes and formulae Astronomical Almanac page D2 Moon, 1999 */ ttime = tosecs(1999, 0, 0, 0, 0); /* Jan 0 1999 */ ttime = (time - ttime) / 86400.00; /* asnode=long of mean ascending node */ asnode = 144.452077 - 0.05295377 * ttime; /* amon=omga plus mean lunar longitude */ amon = 69.167124 + 13.17639648 * ttime; /* peri=asnode plus mean lunar longitude of perigee */ peri = 42.524057 + 0.11140353 * ttime; /* moonsun is the elongation of moon from the sun */ moonsun = 149.940812 + 12.19074912 * ttime; /* em is the eccentricity of lunar orbit */ em = 0.054900489; /* aim=inclination of lunar orbit to ecliptic */ aim = 5.1453964 * PI / 180.0; /* vsm=true anomaly */ /* the following are correction terms */ vsm = 2.0 * em * sin((amon - peri) * PI / 180.0); /* elliptical orbit */ evn = (1.274 / 57.3) * sin((2 * moonsun - (amon - peri)) * PI / 180.0); /* evection */ var = (0.658 / 57.3) * sin(2 * moonsun * PI / 180.0); /* variation */ alamm = (amon - asnode) * PI / 180.0 + vsm + evn + var; x = cos(alamm); y = sin(alamm); z = 0; xx = x; yy = y * cos(aim); zz = y * sin(aim); ram = atan2(yy, xx) + asnode * PI / 180.0; decm = atan2(zz, sqrt(xx * xx + yy * yy)); x = cos(ram) * cos(decm); y = sin(ram) * cos(decm); z = sin(decm); inc = 23.45 * PI / 180.0; xx = x; yy = y * cos(inc) - z * sin(inc); zz = z * cos(inc) + y * sin(inc); /* aam is the semi-major axis of orbit earth radii */ aam = 60.2665; z = zz - sin(d1.lat) / aam; /* correct for parallax */ ha = gst(time) - d1.lon; x = xx - cos(d1.lat) * cos(ha) / aam; y = yy - cos(d1.lat) * sin(ha) / aam; *ra = atan2(y, x); if (*ra < 0) *ra += TWOPI; *dec = atan2(z, sqrt(x * x + y * y)); }
void azel_to_radec(double time, double az, double el, double *ra, double *dec) // convert from azimuth and elevation to ra and dec { double north, west, zen, pole, rad, ha; north = cos(az * PI / 180.0) * cos(el * PI / 180.0); west = -sin(az * PI / 180.0) * cos(el * PI / 180.0); zen = sin(el * PI / 180.0); pole = north * cos(d1.lat) + zen * sin(d1.lat); rad = zen * cos(d1.lat) - north * sin(d1.lat); *dec = atan2(pole, sqrt(rad * rad + west * west)); ha = atan2(west, rad); *ra = -ha + gst(time) - d1.lon; if (*ra < 0) *ra += TWOPI; }
double cmdfile(void) // reads command file /* drives the schedule with stop time yyyy:ddd:hh:mm:ss or LST:hh:mm:ss or just : for immediate scheduling or :n for scheduling for n secs - will wait for source to be within limits followed by keywords: sourcename (any name in catalog) stow calibrate quit clearint // clears intergation record (turns on data file if not already on) [filename] [recmode] roff (turns off data file) freq fcenter_MHz [bandwidth_MHz] mode n for 25 point b for beamswitch */ { double secs, secnow, lst, freq, bw; int i, j, n, line, yr, day, hr, min, se, ss; int da, mn, sc; int ix, iy; char str[256], txt[256]; char *p, *k; FILE *file1; GdkColor color; if ((file1 = fopen(d1.cmdfnam, "r")) == NULL) { printf(" Unable to open %s\n", d1.cmdfnam); return 0.0; } secs = secnow = d1.secs; i = 1; line = 0; ss = 0; k = 0; str[255] = 0; while ((k = fgets(str, 80, file1)) != 0 && i == 1) { line++; // printf("line %d %s",line,str); if (str[0] != '*' && str[0] != ' ' && str[0] != '#' && strlen(str) > 2 && line > d1.cmdfline) { if (str[0] != 'L' && str[0] != ':') { // yyyy:ddd:hh:mm:ss sscanf(str, "%d:%d:%d:%d:%d", &yr, &day, &hr, &min, &se); secs = tosecs(yr, day, hr, min, se); } // d.dtext(440.0, ylim + 40.0, gg, Color.red, "cmd err " + str); if (str[0] == 'L' && strstr(str, "LST")) { // "LST:%2d:%2d:%2d",&hr,&min,&sec hr = min = se = 0; sscanf(str, "LST:%d:%d:%d", &hr, &min, &se); lst = gst(secnow) - d1.lon; secs = hr * 3600.0 + min * 60.0 + se - lst * 86400.0 / (PI * 2.0); if (secs < 0) secs += 86400.0; if (secs > 86400.0) secs -= 86400.0; if (secs < 0) secs += 86400.0; if (secs > 86400.0) secs -= 86400.0; secs += secnow; } // d.dtext(440.0, ylim + 40.0, gg, Color.red, "cmd err " + str); if (str[0] == ':' && str[1] != ' ') { ss = 0; sscanf(str, ":%d", &ss); secs += ss; } // d.dtext(440.0, ylim + 40.0, gg, Color.red, "cmd err " + str); for (n = 0; n < (int) strlen(str); n++) if (str[n] == '\n') str[n] = ' '; if (secs >= secnow) { // System.out.println("secs "+secs+" secnow "+secnow); for (j = 0; j < d1.nsou; j++) { if ((p = strstr(str, sounam[j]))) { strncpy(soutrack, sounam[j], sizeof(soutrack) - 1); if (ss < 2) secs += 2; // add time d1.track = 1; d1.bsw = 0; d1.azoff = 0; d1.eloff = 0; // check for mode if (p && *p) { // note p before *p p = strchr(p, ' '); if (p && *p) { if (strchr(p, 'n')) { d1.scan = 1; } if (strchr(p, 'b')) { d1.bsw = 1; } } } } } if (strstr(str, "azel")) { j = sscanf(str, "%*s %*s %lf %lf", &d1.azcmd, &d1.elcmd); if (j == 2) { if (d1.printout) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("cmdf %s", str); } if (ss < 2) secs += 2; // add time d1.track = 0; soutrack[0] = 0; } } if (strstr(str, "offset")) { sscanf(str, "%*s %*s %lf %lf", &d1.azoff, &d1.eloff); } if (strstr(str, "stow")) { d1.azcmd = d1.azlim1; d1.elcmd = d1.ellim1; soutrack[0] = 0; d1.stow = 1; } if (strstr(str, "calibrate")) d1.docal = 1; if (strstr(str, "record")) { d1.record = 1; if (sscanf(str, "%*s %*s %255s", d1.filname) == 1) d1.foutstatus = 1; } if (strstr(str, "quit") && d1.stow == -1) { d1.run = 0; gtk_exit(0); } if (strstr(str, "roff")) d1.record = 0; if (strstr(str, "clearint")) d1.clearint = 1; if (strstr(str, "freq")) { bw = 4.0; sscanf(str, "%*s %*s %lf %lf", &freq, &bw); if (bw > 0 && bw <= 10.0) d1.fbw = bw / d1.bw; if (freq > 1200.0 && freq < 1800.0) { d1.freq = freq; d1.iffreq = d1.freq - d1.lofreq; d1.f1 = d1.iffreq / d1.bw - d1.fbw * 0.5; d1.f2 = d1.iffreq / d1.bw + d1.fbw * 0.5; d1.fc = (d1.f1 + d1.f2) * 0.5; if (d1.printout) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("new freq %f %f\n", d1.freq, d1.iffreq); } d1.freqchng = 1; } } } i = 0; ix = midx * 1.05; iy = midy * 0.99; if (d1.displ && str[0]) { color.red = 0; color.green = 0xffff; color.blue = 0; gdk_color_parse("green", &color); gtk_widget_modify_fg(drawing_area, GTK_STATE_NORMAL, &color); gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midx * 0.4, midy * 0.05); sprintf(txt, "line %2d %s", line, str); gdk_draw_text(pixmap, fixed_font, drawing_area->style->fg_gc[GTK_STATE_NORMAL], ix, iy, txt, strlen(txt) - 1); } if (d1.printout) { toyrday(d1.secs, &yr, &da, &hr, &mn, &sc); printf("%4d:%03d:%02d:%02d:%02d %3s ", yr, da, hr, mn, sc, d1.timsource); printf("line %2d %s\n", line, str); } } } d1.cmdfline = line; fclose(file1); if (k == 0) { if (d1.displ) { ix = midx * 1.05; iy = midy * 0.99; color.red = 0; color.green = 0xffff; color.blue = 0; gdk_color_parse("green", &color); gtk_widget_modify_fg(drawing_area, GTK_STATE_NORMAL, &color); gdk_draw_rectangle(pixmap, drawing_area->style->white_gc, TRUE, ix, iy - midy * 0.04, midx * 0.4, midy * 0.05); sprintf(txt, "line %2d : end_of_file", line); gdk_draw_text(pixmap, fixed_font, drawing_area->style->fg_gc[GTK_STATE_NORMAL], ix, iy, txt, strlen(txt) - 1); } d1.cmdfl = 0; d1.cmdfline = 0; } return secs; }
/* Function: reduce * * Reduces a symmetric or Hermitian definite generalized eigenvalue problem to a standard problem after factorizing the right-hand side matrix. * * Parameters: * A - Left-hand side matrix. * B - Right-hand side matrix. */ void reduce(K* const& A, K* const& B) const { int info; potrf("L", &(Eigensolver<K>::_n), B, &(Eigensolver<K>::_n), &info); gst(&i__1, "L", &(Eigensolver<K>::_n), A, &(Eigensolver<K>::_n), B, &(Eigensolver<K>::_n), &info); }
void zerospectra(int mode) { int i, j, yr, da, hr, mn, sc; double az, el, secs, ra, dec; secs = d1.secs; if (!mode) { for (i = 0; i < d1.nfreq; i++) avspec[i] = avspecoff[i] = avspecon[i] = 0; d1.pwron = d1.pwroff = 0; d1.numon = d1.numoff = d1.integ = 0; } if (d1.cmdfl && secs > d1.secstop && !d1.slew && !d1.scan && !d1.docal && mode) d1.secstop = cmdfile(); d1.vlsr = 0.0; az = -1; for (i = 0; d1.track >= 0 && i < d1.nsou; i++) { if (strstr(sounam[i], soutrack) && soutrack[0]) { toyrday(secs, &yr, &da, &hr, &mn, &sc); d1.year = yr; if (strstr(sounam[i], "Sun") || strstr(sounam[i], "Moon")) { if (strstr(sounam[i], "Sun")) sunradec(secs, &ra, &dec); else moonradec(secs, &ra, &dec); radec_azel(gst(secs) - ra - d1.lon, dec, d1.lat, &az, &el); } else if (soutype[i]) { az = ras[i] * PI / 180.0; el = decs[i] * PI / 180.0; azel_to_radec(secs, ras[i], decs[i], &ra, &dec); } else { precess(ras[i], decs[i], &ra, &dec, epoc[i], d1.year); radec_azel(gst(secs) - ra - d1.lon, dec, d1.lat, &az, &el); } d1.vlsr = vlsr(secs, ra, dec); sprintf(souinfo, "%s %4d", to_radecp(ra, dec), yr); } } if (d1.track && az >= 0.0) { if (d1.scan > 0) { i = (d1.scan - 1) / 5; j = (d1.scan - 1) % 5; d1.eloff = (i - 2) * d1.beamw * 0.5; d1.azoff = (j - 2) * d1.beamw * 0.5 / cos(el + d1.eloff * PI / 180.0); d1.scan++; if (d1.scan > 26) { d1.scan = 0; if (d1.displ) gtk_tooltips_set_tip(tooltips, button_npoint, "click to start npoint scan", NULL); d1.azoff = d1.eloff = 0; d1.domap = 1; } } if (d1.bsw == 1) d1.bswint = 0; if (d1.bsw > 0 && d1.bswint == 0) { if (d1.bsw == 1) d1.clearint = 1; i = (d1.bsw - 1) % 4; j = 0; if (i == 1) j = -1; if (i == 3) j = 1; d1.azoff = j * d1.beamw / cos(el); d1.bsw++; } } if (az >= 0 && d1.stow != 1) { d1.azcmd = az * 180.0 / PI + d1.azoff; d1.elcmd = el * 180.0 / PI + d1.eloff; // printf("inzero azcmd %f ellim2 %f\n",d1.azcmd,d1.ellim2); } else { azel_to_radec(secs, d1.azcmd, d1.elcmd, &ra, &dec); d1.vlsr = vlsr(secs, ra, dec); } if (mode == 0) { d1.integ = 0.0; pwr = 0.0; } }