1
0
Fork 0

Giza-only version of skymap

giza-pure
Jeff Moe 2022-08-20 13:01:13 -06:00
parent 3103df3574
commit cbe9e3c807
1 changed files with 159 additions and 159 deletions

View File

@ -5,7 +5,6 @@
#include <time.h>
#include <getopt.h>
#include <ctype.h>
#include <cpgplot.h>
#include <wcslib/cel.h>
#include "sgdp4h.h"
#include <giza.h>
@ -432,7 +431,7 @@ plot_apex (float h, float beta)
rr = h + XKMPER;
cpgsci (3);
giza_set_colour_index (3);
for (theta = 0.0; theta <= 360.0; theta += 1.0)
{
satpos.x = rr * cos (theta * D2R) * cos (beta * D2R);
@ -461,14 +460,14 @@ plot_apex (float h, float beta)
}
if (theta == 0.0)
cpgmove ((float) rx, (float) ry);
giza_move_float ((float) rx, (float) ry);
else
{
cpgdraw ((float) rx, (float) ry);
cpgmove ((float) rx, (float) ry);
giza_draw_float ((float) rx, (float) ry);
giza_move_float ((float) rx, (float) ry);
}
}
cpgsci (1);
giza_set_colour_index (1);
return;
}
@ -590,12 +589,12 @@ plot_xyz (double mjd0, char *filename)
forward (s.ra, s.de, &s.rx, &s.ry);
}
cpgsci (3);
cpgpt1 (s.rx, s.ry, 17);
cpgsch (0.6);
cpgtext (s.rx, s.ry, " xyz");
cpgsch (1.0);
cpgsci (1);
giza_set_colour_index (3);
giza_single_point_float (s.rx, s.ry, 17);
giza_set_character_height_float (0.6);
giza_text_float (s.rx, s.ry, " xyz");
giza_set_character_height_float (1.0);
giza_set_colour_index (1);
printf ("%s %6.3f %6.3f %.1f km\n", m.nfd, s.ra, s.de, s.r);
return;
@ -924,7 +923,7 @@ main (int argc, char *argv[])
plot_skymap ();
cpgend ();
giza_close_device ();
return 0;
}
@ -954,7 +953,7 @@ plot_graves_visibility (void)
graves_xyz (m.mjd, &grvpos, &grvvel);
obspos_xyz (m.mjd, &obspos, &obsvel);
cpgsci (2);
giza_set_colour_index (2);
for (h = 300; h <= 1200; h += 100)
{
for (i = 0; i < sizeof (azil) / sizeof (azil[0]); i++)
@ -1004,15 +1003,15 @@ plot_graves_visibility (void)
forward (ra, de, &rx, &ry);
}
if (i == 0)
cpgmove (rx, ry);
giza_move_float (rx, ry);
else
{
cpgdraw (rx, ry);
cpgmove (rx, ry);
giza_draw_float (rx, ry);
giza_move_float (rx, ry);
}
}
}
cpgsci (1);
giza_set_colour_index (1);
return;
}
@ -1118,17 +1117,17 @@ plot_visibility (float h)
if (p < -psun)
{
strcpy (state, "eclipsed");
cpgsci (14);
giza_set_colour_index (14);
}
else if (p > -psun && p < psun)
{
strcpy (state, "umbra");
cpgsci (15);
giza_set_colour_index (15);
}
else if (p > psun)
{
strcpy (state, "sunlit");
cpgsci (7);
giza_set_colour_index (7);
}
// Phase
@ -1166,18 +1165,19 @@ plot_visibility (float h)
nc = (int) cmax + 1.0;
// Plot contours
cpgsci (7);
cpgcont (cont, nx, ny, 1, nx, 1, ny, c, nc, tr);
giza_set_colour_index (7);
giza_contour_float (cont, nx, ny, 1, nx, 1, ny, c, nc, tr);
// Label contours
cpgsch (0.8);
giza_set_character_height_float (0.8);
for (i = 0; i < nc; i++)
{
sprintf (state, "%.0f", c[i]);
cpgconl (cont, nx, ny, 1, nx, 1, ny, c[i], tr, state, 300, 18);
// XXX Partially implmented in giza. Where does this appear? XXX
// cpgconl (cont, nx, ny, 1, nx, 1, ny, c[i], tr, state, 300, 18);
}
cpgsch (1.0);
cpgsci (1);
giza_set_character_height_float (1.0);
giza_set_colour_index (1);
return;
}
@ -1189,7 +1189,7 @@ init_plot (char *psfile, float width, float height)
int i;
giza_open_device_size_float ("/xs", "skymap", width, height, 3);
cpgslw (1);
giza_set_line_width_float (1);
skymap_plot_renew ();
@ -1480,10 +1480,10 @@ skymap_plot_fov ()
x=(float) rx;
y=(float) ry;
if (j==0)
cpgmove(x,y);
giza_move_float(x,y);
else {
cpgdraw(x,y);
cpgmove(x,y);
giza_draw_float(x,y);
giza_move_float(x,y);
}
}
}
@ -1501,11 +1501,11 @@ skymap_plot_fov ()
x = (float) rx;
y = (float) ry;
if (j == 0)
cpgmove (x, y);
giza_move_float (x, y);
else
{
cpgdraw (x, y);
cpgmove (x, y);
giza_draw_float (x, y);
giza_move_float (x, y);
}
}
}
@ -1526,13 +1526,13 @@ skymap_plothorizontal_grid ()
char line[LIM], filename[LIM];
// Get setup
cpgqch (&sch);
cpgqls (&sls);
cpgqci (&sci);
giza_get_character_height_float (&sch);
giza_get_line_style (&sls);
giza_get_colour_index (&sci);
// Plot grid
cpgsci (15);
cpgsls (2);
giza_set_colour_index (15);
giza_set_line_style (2);
// Altitudes
if (m.grid == 1)
@ -1547,14 +1547,14 @@ skymap_plothorizontal_grid ()
x = (float) rx;
y = (float) ry;
if (i == 0)
cpgmove (x, y);
giza_move_float (x, y);
if (fabs (x) <= 1.5 * m.w && fabs (y) <= m.w)
{
cpgdraw (x, y);
cpgmove (x, y);
giza_draw_float (x, y);
giza_move_float (x, y);
}
else
cpgmove (x, y);
giza_move_float (x, y);
}
}
@ -1569,19 +1569,19 @@ skymap_plothorizontal_grid ()
x = (float) rx;
y = (float) ry;
if (i == 0)
cpgmove (x, y);
giza_move_float (x, y);
if (fabs (x) <= 1.5 * m.w && fabs (y) <= m.w)
{
cpgdraw (x, y);
cpgmove (x, y);
giza_draw_float (x, y);
giza_move_float (x, y);
}
else
cpgmove (x, y);
giza_move_float (x, y);
}
}
}
cpgsci (1);
cpgsls (1);
giza_set_colour_index (1);
giza_set_line_style (1);
// Plot horizon
for (i = 0; i < m.nmax; i++)
@ -1593,15 +1593,15 @@ skymap_plothorizontal_grid ()
x = (float) rx;
y = (float) ry;
if (i == 0)
cpgmove (x, y);
giza_move_float (x, y);
if (fabs (x) <= 1.5 * m.w && fabs (y) <= m.w)
{
cpgsci (255);
cpgdraw (x, y);
cpgmove (x, y);
giza_set_colour_index (255);
giza_draw_float (x, y);
giza_move_float (x, y);
}
else
cpgmove (x, y);
giza_move_float (x, y);
}
// Use real horizon
@ -1622,15 +1622,15 @@ skymap_plothorizontal_grid ()
x = (float) rx;
y = (float) ry;
if (i == 0)
cpgmove (x, y);
giza_move_float (x, y);
if (fabs (x) <= 1.5 * m.w && fabs (y) <= m.w)
{
cpgsci (255);
cpgdraw (x, y);
cpgmove (x, y);
giza_set_colour_index (255);
giza_draw_float (x, y);
giza_move_float (x, y);
}
else
cpgmove (x, y);
giza_move_float (x, y);
i++;
}
fclose (file);
@ -1650,13 +1650,13 @@ skymap_plotequatorial_grid ()
int sci, sls;
// Get setup
cpgqch (&sch);
cpgqls (&sls);
cpgqci (&sci);
giza_get_character_height_float (&sch);
giza_get_line_style (&sls);
giza_get_colour_index (&sci);
// Plot grid
cpgsci (15);
cpgsls (2);
giza_set_colour_index (15);
giza_set_line_style (2);
// Declinations
if (m.grid == 1)
@ -1671,14 +1671,14 @@ skymap_plotequatorial_grid ()
x = (float) rx;
y = (float) ry;
if (i == 0)
cpgmove (x, y);
giza_move_float (x, y);
if (fabs (x) <= 1.5 * m.w && fabs (y) <= m.w)
{
cpgdraw (x, y);
cpgmove (x, y);
giza_draw_float (x, y);
giza_move_float (x, y);
}
else
cpgmove (x, y);
giza_move_float (x, y);
}
}
@ -1693,19 +1693,19 @@ skymap_plotequatorial_grid ()
x = (float) rx;
y = (float) ry;
if (i == 0)
cpgmove (x, y);
giza_move_float (x, y);
if (fabs (x) <= 1.5 * m.w && fabs (y) <= m.w)
{
cpgdraw (x, y);
cpgmove (x, y);
giza_draw_float (x, y);
giza_move_float (x, y);
}
else
cpgmove (x, y);
giza_move_float (x, y);
}
}
}
cpgsci (1);
cpgsls (1);
giza_set_colour_index (1);
giza_set_line_style (1);
// Plot equatorial
for (i = 0; i < m.nmax; i++)
@ -1717,14 +1717,14 @@ skymap_plotequatorial_grid ()
x = (float) rx;
y = (float) ry;
if (i == 0)
cpgmove (x, y);
giza_move_float (x, y);
if (fabs (x) <= 1.5 * m.w && fabs (y) <= m.w)
{
cpgdraw (x, y);
cpgmove (x, y);
giza_draw_float (x, y);
giza_move_float (x, y);
}
else
cpgmove (x, y);
giza_move_float (x, y);
}
return;
@ -1743,7 +1743,7 @@ skymap_plotconstellations (char *filename)
char line[LIM];
FILE *file;
cpgsci (4);
giza_set_colour_index (4);
// Loop over file
file = fopen (filename, "r");
if (file == NULL)
@ -1770,20 +1770,20 @@ skymap_plotconstellations (char *filename)
x = (float) rx;
y = (float) ry;
if (i == 0)
cpgmove (x, y);
giza_move_float (x, y);
// if (fabs(x)<=m.w && fabs(y)<=m.w) {
if (flag == 0)
cpgmove (x, y);
giza_move_float (x, y);
if (flag == 1)
{
cpgdraw (x, y);
cpgmove (x, y);
giza_draw_float (x, y);
giza_move_float (x, y);
}
// } else
// cpgmove(x,y);
// giza_move_float(x,y);
}
fclose (file);
cpgsci (1);
giza_set_colour_index (1);
return;
}
@ -1921,8 +1921,8 @@ skymap_plotstars (char *filename)
m.minmag) / (m.maxmag -
m.minmag);
rad *= m.w / 90.0;
cpgsci (255);
cpgcirc (x, y, rad);
giza_set_colour_index (255);
giza_circle_float (x, y, rad);
}
}
fclose (file);
@ -1967,8 +1967,8 @@ skymap_plotstars (char *filename)
m.minmag) / (m.maxmag -
m.minmag);
rad *= m.w / 90.0;
cpgsci (255);
cpgcirc (x, y, rad);
giza_set_colour_index (255);
giza_circle_float (x, y, rad);
}
}
fclose (file);
@ -2102,11 +2102,11 @@ skymap_plotsatellite (char *filename, int satno, double mjd0, double dt)
// Visibility
if (s.p - s.pearth < -s.psun)
{
cpgsci (14);
giza_set_colour_index (14);
}
else if (s.p - s.pearth > -s.psun && s.p - s.pearth < s.psun)
{
cpgsci (15);
giza_set_colour_index (15);
}
else if (s.p - s.pearth > s.psun)
{
@ -2114,15 +2114,15 @@ skymap_plotsatellite (char *filename, int satno, double mjd0, double dt)
{
if (Isat == priority[i])
{
cpgsci (2);
giza_set_colour_index (2);
break;
}
else
{
if (s.salt < 0.0)
cpgsci (7);
giza_set_colour_index (7);
else
cpgsci (8);
giza_set_colour_index (8);
}
}
}
@ -2131,9 +2131,9 @@ skymap_plotsatellite (char *filename, int satno, double mjd0, double dt)
if (m.graves != 0)
{
if (s.illumg == 1)
cpgsci (2);
giza_set_colour_index (2);
else
cpgsci (14);
giza_set_colour_index (14);
}
// In field of view
@ -2148,32 +2148,32 @@ skymap_plotsatellite (char *filename, int satno, double mjd0, double dt)
// Plot satellites
if (flag == 0)
{
cpgsch (0.8);
giza_set_character_height_float (0.8);
if (s.age < 25)
cpgpt1 (x, y, 17);
giza_single_point_float (x, y, 17);
else if (s.age < 50)
cpgpt1 (x, y, 4);
giza_single_point_float (x, y, 4);
else
cpgpt1 (x, y, 6);
cpgsch (0.6);
giza_single_point_float (x, y, 6);
giza_set_character_height_float (0.6);
// Print name if in viewport
if (fabs (x) < 1.5 * m.w && fabs (y) < m.w && x < 1.32 * m.w
&& y < 0.96 * m.w && m.pflag == 1)
cpgtext (x, y, norad);
cpgsch (isch);
cpgmove (x, y);
giza_text_float (x, y, norad);
giza_set_character_height_float (isch);
giza_move_float (x, y);
flag = 1;
}
else
{
cpgdraw (x, y);
cpgmove (x, y);
giza_draw_float (x, y);
giza_move_float (x, y);
}
}
}
fclose (fp);
cpgsci (1);
giza_set_colour_index (1);
return;
}
@ -2543,17 +2543,17 @@ planar_search (char *filename, int satno, float rmin, float rmax, int nr,
if (p < -psun)
{
strcpy (state, "eclipsed");
cpgsci (14);
giza_set_colour_index (14);
}
else if (p > -psun && p < psun)
{
strcpy (state, "umbra");
cpgsci (15);
giza_set_colour_index (15);
}
else if (p > psun)
{
strcpy (state, "sunlit");
cpgsci (7);
giza_set_colour_index (7);
}
// Phase
@ -2605,29 +2605,29 @@ planar_search (char *filename, int satno, float rmin, float rmax, int nr,
if (altg >= 15.0 && altg <= 40.0
&& modulo (azig - 180.0, 360.0) >= 90.0
&& modulo (azig - 180.0, 360.0) <= 270.0)
cpgsci (2);
giza_set_colour_index (2);
else
cpgsci (15);
giza_set_colour_index (15);
}
if (i == 0)
cpgmove ((float) rx, (float) ry);
giza_move_float ((float) rx, (float) ry);
else
{
cpgdraw ((float) rx, (float) ry);
cpgmove ((float) rx, (float) ry);
giza_draw_float ((float) rx, (float) ry);
giza_move_float ((float) rx, (float) ry);
}
cpgsci (1);
giza_set_colour_index (1);
}
// Plot brightest point
if (graves == 0)
{
cpgsch (1.0);
cpgsci (7);
cpgpt1 ((float) rx0, (float) ry0, 4);
giza_set_character_height_float (1.0);
giza_set_colour_index (7);
giza_single_point_float ((float) rx0, (float) ry0, 4);
if (altmax > 0.0)
cpgpt1 ((float) rx1, (float) ry1, 17);
cpgsci (1);
giza_single_point_float ((float) rx1, (float) ry1, 17);
giza_set_colour_index (1);
}
}
@ -2785,12 +2785,12 @@ skymap_plotmoon (void)
else if (strcmp (m.orientation, "equatorial") == 0)
forward (ra, de, &rx, &ry);
cpgsci (14);
giza_set_colour_index (14);
if (m.w > 60.0)
cpgcirc ((float) rx, (float) ry, 2.0);
giza_circle_float ((float) rx, (float) ry, 2.0);
else
cpgcirc ((float) rx, (float) ry, 0.25);
cpgsci (1);
giza_circle_float ((float) rx, (float) ry, 0.25);
giza_set_colour_index (1);
return;
}
@ -2805,12 +2805,12 @@ skymap_plotsun (void)
else if (strcmp (m.orientation, "equatorial") == 0)
forward (m.sra, m.sde, &rx, &ry);
cpgsci (7);
giza_set_colour_index (7);
if (m.w > 60.0)
cpgcirc ((float) rx, (float) ry, 2.0);
giza_circle_float ((float) rx, (float) ry, 2.0);
else
cpgcirc ((float) rx, (float) ry, 0.25);
cpgsci (1);
giza_circle_float ((float) rx, (float) ry, 0.25);
giza_set_colour_index (1);
return;
}
@ -2871,7 +2871,7 @@ plot_skymap (void)
double ra, de, azi, alt, rx, ry;
xyz_t sunpos;
giza_set_colour_palette (1);
cpgscf (1);
giza_set_font ("Helvetica");
status = read_camera (fov);
if (status == -1)
@ -2904,50 +2904,50 @@ plot_skymap (void)
sunpos_xyz (m.mjd, &sunpos, &m.sra, &m.sde);
equatorial2horizontal (m.mjd, m.sra, m.sde, &m.sazi, &m.salt);
cpgscr (0, 0.0, 0.0, 0.0);
cpgeras ();
giza_set_colour_representation_float (0, 0.0, 0.0, 0.0);
giza_draw_background ();
// Create window
cpgsvp (0.01, 0.99, 0.01, 0.99);
cpgwnad (-1.5 * m.w, 1.5 * m.w, -m.w, m.w);
giza_set_viewport_float (0.01, 0.99, 0.01, 0.99);
giza_set_window_equal_scale_float (-1.5 * m.w, 1.5 * m.w, -m.w, m.w);
// Set background
if (m.salt > 0.0)
cpgscr (0, 0.0, 0.0, 0.4);
giza_set_colour_representation_float (0, 0.0, 0.0, 0.4);
else if (m.salt > -6.0)
cpgscr (0, 0.0, 0.0, 0.3);
giza_set_colour_representation_float (0, 0.0, 0.0, 0.3);
else if (m.salt > -12.0)
cpgscr (0, 0.0, 0.0, 0.2);
giza_set_colour_representation_float (0, 0.0, 0.0, 0.2);
else if (m.salt > -18.0)
cpgscr (0, 0.0, 0.0, 0.1);
giza_set_colour_representation_float (0, 0.0, 0.0, 0.1);
else
cpgscr (0, 0.0, 0.0, 0.0);
cpgsci (0);
cpgrect (-1.5 * m.w, 1.5 * m.w, -m.w, m.w);
cpgsci (15);
cpgsch (1.0);
cpgbox ("BC", 0., 0, "BC", 0., 0);
cpgpt1 (0.0, 0.0, 2);
giza_set_colour_representation_float (0, 0.0, 0.0, 0.0);
giza_set_colour_index (0);
giza_rectangle (-1.5 * m.w, 1.5 * m.w, -m.w, m.w);
giza_set_colour_index (15);
giza_set_character_height_float (1.0);
giza_box ("BC", 0., 0, "BC", 0., 0);
giza_single_point_float (0.0, 0.0, 2);
// Plot field-of-view
if (fov >= 0)
{
cpgsfs (2);
giza_set_fill (2);
cpgrect (-m.fw, m.fw, -m.fh, m.fh);
cpgsfs (1);
giza_rectangle (-m.fw, m.fw, -m.fh, m.fh);
giza_set_fill (1);
}
// Top left string
cpgsch (0.8);
cpgsci (15);
giza_set_character_height_float (0.8);
giza_set_colour_index (15);
mjd2date (m.mjd, m.nfd);
sprintf (text,
"%s UTC; %s (%04d) [%+.4f\\u\\(2218)\\d, %+.4f\\u\\(2218)\\d, %.0fm]",
m.nfd, m.observer, m.site_id, m.lat, m.lng,
m.alt * 1000.0);
cpgmtxt ("T", 0.6, 0.0, 0.0, text);
giza_annotate_float ("T", 0.6, 0.0, 0.0, text);
// Top right string
if (m.planar == 0)
@ -3001,7 +3001,7 @@ plot_skymap (void)
sprintf (text, "Planar search: %05d", m.pssatno);
}
}
cpgmtxt ("T", 0.6, 1.0, 1.0, text);
giza_annotate_float ("T", 0.6, 1.0, 1.0, text);
// Bottom string
dec2s (m.ra0 / 15.0, sra, 0, 5);
@ -3011,8 +3011,8 @@ plot_skymap (void)
sra, sde, modulo (m.azi0 - 180.0, 360.0), m.alt0, m.q,
3.0 * m.w, 2.0 * m.w, m.level, m.orientation, m.maxmag,
m.camera, m.length);
cpgmtxt ("B", 1.0, 0.0, 0.0, text);
cpgsch (1.0);
giza_annotate_float ("B", 1.0, 0.0, 0.0, text);
giza_set_character_height_float (1.0);
// Plot everything
if (m.plotstars == 1)
@ -3052,7 +3052,7 @@ plot_skymap (void)
if (Isatsel >= 0 && m.leoflag >= 0)
{
cpgslw (1);
giza_set_line_width_float (1);
skymap_plotsatellite (m.tlefile, Isatsel, m.mjd, m.length);
}
}
@ -3086,7 +3086,7 @@ plot_skymap (void)
plot_graves_visibility ();
// Get time
cpgcurs (&x, &y, &c);
giza_get_key_press_float (&x, &y, &c);
// Help
if (c == 'h' || c == 'H')
@ -3872,7 +3872,7 @@ plot_iod (char *filename)
double azi, alt, rx, ry;
float x, y;
cpgsci (2);
giza_set_colour_index (2);
file = fopen (filename, "r");
if (file == NULL)
{
@ -3900,12 +3900,12 @@ plot_iod (char *filename)
x = (float) rx;
y = (float) ry;
cpgpt1 (x, y, 4);
giza_single_point_float (x, y, 4);
}
}
}
fclose (file);
cpgsci (1);
giza_set_colour_index (1);
return;