Skip to content
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*.pyc

#chart configurations I use to debug
test/

# Distribution / packaging
develop-eggs/
dist/
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ The following settings can be included in a `StarCharter` configuration file:
* `grid_col` - Colour to use when drawing grid of RA/Dec lines
* `label_ecliptic` - Boolean (0 or 1) indicating whether to label the months along the ecliptic, showing the Sun's annual progress
* `label_font_size_scaling` - Scaling factor to be applied to the font size of all star and DSO labels (default 1.0)
* `label_meridian` Boolean (0 or 1) indicating whether to label declination lines multiple of 10 degrees along the vernal meridian
* `language` - The language used for the constellation names. Either "english" or "french".
* `mag_alpha` - The multiplicative scaling factor to apply to the radii of stars differing in magnitude by one <mag_step>
* `mag_max` - Used to regulate the size of stars. A star of this magnitude is drawn with size mag_size_norm. Also, this is the brightest magnitude of star which is shown in the magnitude key below the chart.
Expand All @@ -220,6 +221,7 @@ The following settings can be included in a `StarCharter` configuration file:
* `maximum_dso_label_count` - The maximum number of deep sky objects which may be labelled
* `maximum_star_count` - The maximum number of stars to draw. If this is exceeded, only the brightest stars are shown.
* `maximum_star_label_count` - The maximum number of stars which may be labelled
* `meridian_col` - Colour to use when drawing a line along the vernal meridian
* `messier_only` - Boolean (0 or 1) indicating whether we plot only Messier objects, and no other deep sky objects
* `must_show_all_ephemeris_labels` - Boolean (0 or 1) indicating whether we show all ephemeris text labels, even if they collide with other text.
* `output_filename` - The target filename for the star chart. The file type (svg, png, eps or pdf) is inferred from the file extension.
Expand All @@ -229,6 +231,7 @@ The following settings can be included in a `StarCharter` configuration file:
* `plot_equator` - Boolean (0 or 1) indicating whether to draw a line along the equator
* `plot_galactic_plane` - Boolean (0 or 1) indicating whether to draw a line along the galactic plane
* `plot_galaxy_map` - Boolean (0 or 1) indicating whether to draw a shaded map of the Milky Way behind the star chart
* `plot_meridian` - Boolean (0 or 1) indicating whether we plot the vernal meridian
* `plot_stars` - Boolean (0 or 1) indicating whether we plot any stars
* `position_angle` - The position angle of the plot - i.e. the tilt of north, counter-clockwise from up, at the centre of the plot
* `projection` - Select projection to use. Set to either flat, peters, gnomonic, sphere or alt_az
Expand All @@ -244,8 +247,26 @@ The following settings can be included in a `StarCharter` configuration file:
* `star_mag_labels` - Boolean (0 or 1) indicating whether we label the magnitudes of stars
* `star_names` - Boolean (0 or 1) indicating whether we label the English names of stars
* `star_variable_labels` - Boolean (0 or 1) indicating whether we label the variable-star designations of stars, e.g. V337_Car
* `dec_ticks_on_round_edge` - Boolean (o or 1) indicating whether lines of constant declination (or galactic latitude) put a tick on the round edge of an Alt_Az chart
* `ra_ticks_on_round_edge` - Boolean (o or 1) indicating whether lines of constant right ascension (or galactic longitude) put a tick on the round edge of an Alt_Az chart
* `title` - The heading to write at the top of the star chart
* `width` - The width of the star chart, in cm
* `x_label_slant` - A slant to apply to all labels on the horizontal axes
* `y_label_slant` - A slant to apply to all labels on the vertical axes
* `zodiacal_only` - Boolean (0 or 1) indicating whether we plot only the zodiacal constellations

# Changelog

## Functionalities

* Extended `alt_az` plotting to draw charts of arbitrary (<360°) angular width. E.G., this is useful to plot a chart of all stars you can see throughout the year
* Implemented ticks on round edge of the chart in `alt_az` mode, with the possibility to choose whether RA, Dec or both lines put ticks on it
* Possibility to plot the vernal meridian, with the option to put a tick on it every 10° of declination

## New configuration parameters

* `label_meridian`
* `meridian_col`
* `plot_meridian`
* `dec_ticks_on_round_edge`
* `ra_ticks_on_round_edge`
2 changes: 1 addition & 1 deletion src/astroGraphics/constellations.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void plot_constellation_boundaries(chart_config *s, line_drawer *ld) {

// Set up line-drawing class
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);
ld_label(ld, NULL, 1, 1);
ld_label(ld, NULL, 1, 1, 1);

// Open file defining the celestial coordinates of the constellation boundaries
file = fopen(SRCDIR "../data/constellations/downloads/boundaries.dat", "r");
Expand Down
6 changes: 3 additions & 3 deletions src/astroGraphics/ephemeris.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void plot_ephemeris(chart_config *s, line_drawer *ld, cairo_page *page, int trac
// Set line colour
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);
cairo_set_source_rgb(s->cairo_draw, s->ephemeris_col.red, s->ephemeris_col.grn, s->ephemeris_col.blu);
ld_label(ld, NULL, 1, 1);
ld_label(ld, NULL, 1, 1, 1);

// Loop over the points in the ephemeris, and draw a line across the star chart
const ephemeris *e = &s->ephemeris_data[trace_num];
Expand Down Expand Up @@ -591,7 +591,7 @@ void plot_ephemeris(chart_config *s, line_drawer *ld, cairo_page *page, int trac

// Draw tick mark
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);
ld_label(ld, NULL, 1, 1);
ld_label(ld, NULL, 1, 1, 1);
ld_point(ld, x + graph_coords_tick_len * sin(theta), y - graph_coords_tick_len * cos(theta), NULL);
ld_point(ld, x - graph_coords_tick_len * sin(theta), y + graph_coords_tick_len * cos(theta), NULL);
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);
Expand Down Expand Up @@ -894,4 +894,4 @@ double draw_ephemeris_table(chart_config *s, double legend_y_pos, int draw_outpu
}

return legend_y_pos;
}
}
112 changes: 107 additions & 5 deletions src/astroGraphics/greatCircles.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void plot_great_circle(double ra0, double dec0, chart_config *s, line_dra
dec0 = dec0 * M_PI / 180;
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);
for (i = 0; i <= N_SAMPLES; i++) {
const double l = 2 * M_PI * ((double) i) / N_SAMPLES;
const double l = 2 * M_PI * ((double) i) / (N_SAMPLES-1);
double a[3] = {cos(l), sin(l), 0.};
double ra, dec, x, y;

Expand Down Expand Up @@ -97,6 +97,56 @@ static void plot_great_circle(double ra0, double dec0, chart_config *s, line_dra
}
}

//small modification to print half circle, useful for meridians.

static void plot_great_half_circle(double ra0, double dec0, chart_config *s, line_drawer *ld,
cairo_page *page, int n_labels, gc_label *labels, colour colour) {
int i;
ra0 = ra0 * M_PI / 180;
dec0 = dec0 * M_PI / 180;
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);
for (i = 0; i <= N_SAMPLES; i++) {
const double l = M_PI * ((double) i) / (N_SAMPLES-1);
double a[3] = {cos(l), sin(l), 0.};
double ra, dec, x, y;

rotate_xz(a, a, dec0 - (M_PI / 2));
rotate_xy(a, a, ra0);

dec = asin(a[2]);
ra = atan2(a[1], a[0]);
plane_project(&x, &y, s, ra, dec, 0);
ld_point(ld, x, y, NULL);
}
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);

if (n_labels)
for (i = 0; i < n_labels; i++) {
const double l = M_PI*(labels[i].xpos) / 180;
double a[3] = {cos(l), sin(l), 0.};
double ra, dec, x, y, xtemp, ytemp;

rotate_xz(a, a, dec0 - (M_PI / 2));
rotate_xy(a, a, ra0);

dec = asin(a[2]);
ra = atan2(a[1], a[0]);
plane_project(&x, &y, s, ra, dec, 0);
plane_project(&xtemp, &ytemp, s, ra-0.0000000001/(dec-M_PI/2), dec, 0);
//very, VERY brutal 1st order approximation
ld_point(ld, x+(xtemp-x)/sqrt((x-xtemp)*(x-xtemp)+(y-ytemp)*(y-ytemp))/50, y+(ytemp-y)/sqrt(((x-xtemp)*(x-xtemp))+((y-ytemp)*(y-ytemp)))/50, NULL);
ld_point(ld, x, y, NULL);
plane_project(&xtemp, &ytemp, s, ra+0.000000001/(dec-M_PI/2), dec, 0);
ld_point(ld, x+(xtemp-x)/sqrt((x-xtemp)*(x-xtemp)+(y-ytemp)*(y-ytemp))/50, y+(ytemp-y)/sqrt(((x-xtemp)*(x-xtemp))+((y-ytemp)*(y-ytemp)))/50, NULL);
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);
plane_project(&xtemp, &ytemp, s, ra+0.1/(dec-M_PI/2), dec, 0);

chart_label_buffer(page, s, colour, labels[i].label,
&(label_position) {x+(xtemp-x)/sqrt(((x-xtemp)*(x-xtemp))+((y-ytemp)*(y-ytemp)))/25, y+(ytemp-y)/sqrt(((x-xtemp)*(x-xtemp))+((y-ytemp)*(y-ytemp)))/25, 0, 0, -1}, 1,
0, 1, 2.0, 1, 0, 0, -0.5);
}
}

//! plot_equator - Draw a line along the celestial equator
//! \param s - A <chart_config> structure defining the properties of the star chart to be drawn.
//! \param ld - A <line_drawer> structure used to draw lines on a cairo surface.
Expand All @@ -110,6 +160,34 @@ void plot_equator(chart_config *s, line_drawer *ld, cairo_page *page) {

plot_great_circle(0, 90, s, ld, page, 0, NULL, s->equator_col);
}
// plots RA=0 meridian
void plot_meridian(chart_config *s, line_drawer *ld, cairo_page *page) {
gc_label labels[17] = {{"-80", 10},
{"-70", 20},
{"-60", 30},
{"-50", 40},
{"-40", 50},
{"-30", 60},
{"-20", 70},
{"-10", 80},
{"0", 90},
{"10", 100},
{"20", 110},
{"30", 120},
{"40", 130},
{"50", 140},
{"60", 150},
{"70", 160},
{"80", 170},
};
// Set line colour
ld_pen_up(ld, GSL_NAN, GSL_NAN, NULL, 1);
cairo_set_source_rgb(s->cairo_draw, s->meridian_col.red, s->meridian_col.grn, s->meridian_col.blu);
cairo_set_line_width(s->cairo_draw, s->great_circle_line_width);

plot_great_half_circle(-90, 0, s, ld, page, s->label_meridian ? 17 : 0, labels,
s->meridian_col);
}

//! plot_galactic_plane - Draw a line along the plane of the Milky Way
//! \param s - A <chart_config> structure defining the properties of the star chart to be drawn.
Expand Down Expand Up @@ -161,7 +239,7 @@ void plot_ecliptic(chart_config *s, line_drawer *ld, cairo_page *page) {
//! \param legend_y_pos - The vertical pixel position of the top of the next legend to go under the star chart.

double draw_great_circle_key(chart_config *s, double legend_y_pos) {
const int N = (s->plot_equator != 0) + (s->plot_ecliptic != 0) + (s->plot_galactic_plane != 0);
const int N = (s->plot_meridian != 0) + (s->plot_equator != 0) + (s->plot_ecliptic != 0) + (s->plot_galactic_plane != 0);
const double w_left = 0.4; // The left margin
const double w_item = 4.2 * s->font_size; // The width of each legend item (cm)

Expand All @@ -188,12 +266,12 @@ double draw_great_circle_key(chart_config *s, double legend_y_pos) {
// Reset font weight
cairo_select_font_face(s->cairo_draw, s->font_family, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);

// Draw item on legend showing the colour of the equator
// Draw item on legend showing the colour of the meridian
if (s->plot_equator != 0) {
const char *label = "The Equator";
const char *label = "Vernal Meridian";

// Draw a line in the right colour
cairo_set_source_rgb(s->cairo_draw, s->equator_col.red, s->equator_col.grn, s->equator_col.blu);
cairo_set_source_rgb(s->cairo_draw, s->meridian_col.red, s->meridian_col.grn, s->meridian_col.blu);
cairo_new_path(s->cairo_draw);
cairo_move_to(s->cairo_draw, x * s->cm, y1 * s->cm);
cairo_line_to(s->cairo_draw, (x + size) * s->cm, y1 * s->cm);
Expand All @@ -216,6 +294,30 @@ double draw_great_circle_key(chart_config *s, double legend_y_pos) {
if (s->plot_ecliptic != 0) {
const char *label = "Ecliptic Plane";

// Draw item on legend showing the colour of the equator
if (s->plot_equator != 0) {
const char *label = "The Equator";

// Draw a line in the right colour
cairo_set_source_rgb(s->cairo_draw, s->equator_col.red, s->equator_col.grn, s->equator_col.blu);
cairo_new_path(s->cairo_draw);
cairo_move_to(s->cairo_draw, x * s->cm, y1 * s->cm);
cairo_line_to(s->cairo_draw, (x + size) * s->cm, y1 * s->cm);
cairo_stroke(s->cairo_draw);

// Write a text label next to it
cairo_set_source_rgb(s->cairo_draw, 0, 0, 0);
cairo_text_extents(s->cairo_draw, label, &extents);
cairo_move_to(s->cairo_draw,
(x + 0.1 + size * 1.25) * s->cm - extents.x_bearing,
y1 * s->cm - extents.height / 2 - extents.y_bearing
);
cairo_show_text(s->cairo_draw, label);

// Advance horizontally to draw the next item in the legend
x += w_item;
}

// Draw a line in the right colour
cairo_set_source_rgb(s->cairo_draw, s->ecliptic_col.red, s->ecliptic_col.grn, s->ecliptic_col.blu);
cairo_new_path(s->cairo_draw);
Expand Down
2 changes: 2 additions & 0 deletions src/astroGraphics/greatCircles.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

void plot_equator(chart_config *s, line_drawer *ld, cairo_page *page);

void plot_meridian(chart_config *s, line_drawer *ld, cairo_page *page);

void plot_galactic_plane(chart_config *s, line_drawer *ld, cairo_page *page);

void plot_ecliptic(chart_config *s, line_drawer *ld, cairo_page *page);
Expand Down
6 changes: 4 additions & 2 deletions src/astroGraphics/raDecLines.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ void plot_ra_dec_lines(chart_config *s, line_drawer *ld) {

// Tell the line drawing class what label should be placed on the edge of the star chart when we cross it
// Lines of constant RA only create tick labels on the horizontal axes, not the vertical axes
ld_label(ld, label, 1, 0);
// Lines of constant declination create a tick on the round edge of the chart in Alt_Az mode if and only if ordered to do so
ld_label(ld, label, 1, 0, s->ra_ticks_on_round_edge);

// Trace the path of this line across chart
for (j = 0; j < N_POINTS; j++) {
Expand Down Expand Up @@ -214,7 +215,8 @@ void plot_ra_dec_lines(chart_config *s, line_drawer *ld) {

// Tell the line drawing class what label should be placed on the edge of the star chart when we cross it
// Lines of constant declination only create tick labels on the vertical axes, not the horizontal axes
ld_label(ld, label, 0, 1);
// Lines of constant declination create a tick on the round edge of the chart in Alt_Az mode if and only if ordered to do so
ld_label(ld, label, 0, 1, s->dec_ticks_on_round_edge);

// Trace the path of this line across chart
for (j = 0; j < N_POINTS; j++) {
Expand Down
38 changes: 34 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ void render_chart(chart_config *s) {
plot_background_image(s);

// Initialise module for tracing lines on the star chart
ld_init(&ld, s, page.x_labels, page.x2_labels, page.y_labels, page.y2_labels);
ld_init(&ld, s, page.x_labels, page.x2_labels, page.y_labels, page.y2_labels, page.r_labels);

// Draw the line of the equator
if (s->plot_equator) plot_equator(s, &ld, &page);

// Draw the line of the vernal meridian
if (s->plot_meridian) plot_meridian(s, &ld, &page);

// Draw the line of the galactic plane
if (s->plot_galactic_plane) plot_galactic_plane(s, &ld, &page);

Expand Down Expand Up @@ -350,7 +353,19 @@ int main(int argc, char **argv) {
CHECK_KEYVALNUM("axis_ticks_value_only")
settings_destination->axis_ticks_value_only = (int) key_val_num;
continue;
} else if (strcmp(key, "axis_label") == 0) {
} else if (strcmp(key, "ra_ticks_on_round_edge") == 0) {
//! ra_ticks_on_round_edge - If 1, constant RA labels will place ticks on the round edge in Alt_Az mode.
//! If 0, they won't
CHECK_KEYVALNUM("ra_ticks_on_round_edge")
settings_destination->ra_ticks_on_round_edge = (int) key_val_num;
continue;
} else if (strcmp(key, "dec_ticks_on_round_edge") == 0) {
//! dec_ticks_on_round_edge - If 1, constant Dec labels will place ticks on the round edge in Alt_Az mode.
//! If 0, they won't
CHECK_KEYVALNUM("dec_ticks_on_round_edge")
settings_destination->dec_ticks_on_round_edge = (int) key_val_num;
continue;
} else if (strcmp(key, "axis_label") == 0) {
//! axis_label - Boolean (0 or 1) indicating whether to write "Right ascension" and "Declination" on the
//! vertical/horizontal axes
CHECK_KEYVALNUM("axis_label")
Expand Down Expand Up @@ -476,7 +491,7 @@ int main(int argc, char **argv) {
} else if (strcmp(key_val, "alt_az") == 0) {
settings_destination->projection = SW_PROJECTION_ALTAZ;
settings_destination->aspect = 1.;
settings_destination->angular_width = 180.;
//settings_destination->angular_width = 180.;
} else {
snprintf(temp_err_string, FNAME_LENGTH,
"Bad input file. projection should equal 'flat', 'gnomonic', 'sphere' or 'alt_az'.");
Expand Down Expand Up @@ -720,7 +735,18 @@ int main(int argc, char **argv) {
CHECK_KEYVALNUM("plot_equator")
settings_destination->plot_equator = (int) key_val_num;
continue;
} else if (strcmp(key, "ecliptic_col") == 0) {
}else if (strcmp(key, "plot_meridian") == 0) {
//! plot_meridian - Boolean (0 or 1) indicating whether to draw a line along the vernal meridian
CHECK_KEYVALNUM("plot_meridian")
settings_destination->plot_meridian = (int) key_val_num;
continue;
} else if (strcmp(key, "label_meridian") == 0) {
//! label_meridian - Boolean (0 or 1) indicating whether to label Dec degrees along the
//! vernal meridian, useful to label Dec lines in Alt_Az charts
CHECK_KEYVALNUM("label_meridian")
settings_destination->label_meridian = (int) key_val_num;
continue;
} else if (strcmp(key, "ecliptic_col") == 0) {
//! ecliptic_col - Colour to use when drawing a line along the ecliptic
settings_destination->ecliptic_col = colour_from_string(key_val);
continue;
Expand All @@ -732,6 +758,10 @@ int main(int argc, char **argv) {
//! equator_col - Colour to use when drawing a line along the equator
settings_destination->equator_col = colour_from_string(key_val);
continue;
} else if (strcmp(key, "meridian_col") == 0) {
//! meridian_col - Colour to use when drawing a line along the equator
settings_destination->meridian_col = colour_from_string(key_val);
continue;
} else if (strcmp(key, "plot_galaxy_map") == 0) {
//! plot_galaxy_map - Boolean (0 or 1) indicating whether to draw a shaded map of the Milky Way behind
//! the star chart
Expand Down
Loading