| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ce6d5dd commit 1c8b3b8
13 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,19 @@ | |||
| 6 | 6 | is printed whether or not the program is currently in polar mode. | |
| 7 | 7 | Keywords for offset, font, etc as for the other axis label commands. | |
| 8 | 8 | ||
| 9 | + * src/axis.c src/gadgets.c src/gadgets.h src/graphics.c src/mouse.c | ||
| 10 | + src/plot2d.c src/set.c docs/gnuplod.doc: Support inverted r axis range. | ||
| 11 | + rrange must be linear and have fixed max/min (no autoscaling). | ||
| 12 | + | ||
| 13 | + Allows use of polar mode to display a projection of celestial horizontal | ||
| 14 | + coordinates (altitude + azimuth) with the zenith (altitude 90) at the | ||
| 15 | + center and the horizon (altitude 0) at the perimeter. Theta represents | ||
| 16 | + the azimuthal angle. | ||
| 17 | + | ||
| 18 | + * demo/solar_path.dem demo/solar_params.dem demo/all.dem: | ||
| 19 | + Use inverted rrange to display solar path at a specific latitude in | ||
| 20 | + celestial horizontal coordinates. | ||
| 21 | + | ||
| 9 | 22 | 2017-01-08 Ethan A Merritt <merritt@u.washington.edu> | |
| 10 | 23 | ||
| 11 | 24 | * src/axis.c (gen_tics) unset.c (unset_polar): Allow placement of tics | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,8 +29,12 @@ Changes not in 5.0 | |||
| 29 | 29 | * NEW wxt supports printing on Windows | |
| 30 | 30 | * NEW dumb suports ANSI colors and filled polygons | |
| 31 | 31 | * NEW terminal sixelgd (sixel terminal graphics using gdlib) | |
| 32 | - * NEW "set [m]ttics" controls placement of labels around perimeter of polar grid | ||
| 33 | 32 | * NEW windows graph windows can be docked to the wgnuplot text window | |
| 33 | + * NEW improveements, extensions, and bug fixes for polar graph mode | ||
| 34 | + * NEW "set [m]ttics" places labels around perimeter of polar grid | ||
| 35 | + * NEW "set rlabel" places a label above the r axis | ||
| 36 | + * NEW "set rrange [90:0]" plots in celestial horizontal coordinates | ||
| 37 | + * NEW "set border polar" uses border linetype for perimeter of polar plot | ||
| 34 | 38 | * CHANGE Revise placement of axis labels in 3D plots | |
| 35 | 39 | * CHANGE Timestamp is now placed relative to page rather than plot boundary | |
| 36 | 40 | * CHANGE Track font/enhanced for key title separately from the key entries | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | # | |
| 2 | - # $Id: all.dem,v 1.78 2017-01-04 01:00:23 sfeam Exp $ | ||
| 2 | + # $Id: all.dem,v 1.79 2017-01-11 04:13:58 sfeam Exp $ | ||
| 3 | 3 | # | |
| 4 | 4 | # Executes all demos (OK, MOST demos) in this directory. | |
| 5 | 5 | # This serves as a series of unit tests for non-interactive capabilities. | |
@@ -79,6 +79,10 @@ print "******************** file poldat.dem ********************" | |||
| 79 | 79 | load "poldat.dem" | |
| 80 | 80 | reset | |
| 81 | 81 | ||
| 82 | + print "******************** file solar_path.dem ****************" | ||
| 83 | + load "solar_path.dem" | ||
| 84 | + reset | ||
| 85 | + | ||
| 82 | 86 | print "******************** file ttics.dem ********************" | |
| 83 | 87 | load "ttics.dem" | |
| 84 | 88 | reset | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,67 @@ | |||
| 1 | + # | ||
| 2 | + # Calculate solar position in equitorial coordinates (ascension, declination) | ||
| 3 | + # then convert to horizontal coordinates (altitude, azimuth). | ||
| 4 | + # Parameters L, g, lambda, and eps are appoximated using values chosen | ||
| 5 | + # for accuracy in the era on either side of Jan 2000. | ||
| 6 | + # | ||
| 7 | + # Input: | ||
| 8 | + # Date - string with format "dd-mm-YYYY HH:MM" | ||
| 9 | + # Latitude - in degrees | ||
| 10 | + # | ||
| 11 | + # Output: | ||
| 12 | + # Function definitions | ||
| 13 | + # Azimuth(t) = Solar azimuth at time t | ||
| 14 | + # Altitude(t) = Solar altitude at time t | ||
| 15 | + # where t is time in seconds relative to local solar noon on Date. | ||
| 16 | + # | ||
| 17 | + # Local values: | ||
| 18 | + Minute = 60. | ||
| 19 | + Hour = 3600. | ||
| 20 | + Day = 86400. | ||
| 21 | + TimeFormat = "%d-%m-%Y %H:%M" | ||
| 22 | + phi = Latitude | ||
| 23 | + set angle degrees | ||
| 24 | + # | ||
| 25 | + # n = local time in days since noon on 1 Jan 2000 | ||
| 26 | + # L = mean solar longitude in ecliptic coordinates | ||
| 27 | + # = 280.460° + 0.9856474° * n | ||
| 28 | + # g = orbital anomaly | ||
| 29 | + # = 357.528° + 0.9856003° * n | ||
| 30 | + # lamba = solar longitude | ||
| 31 | + # = L + 1.915° * sin(g) + 0.020° * sin(2g) | ||
| 32 | + # eps = obliquity of the ecliptic | ||
| 33 | + # = 23.439° - 0.0000004° * n | ||
| 34 | + | ||
| 35 | + n = (strptime(TimeFormat, Date) - strptime(TimeFormat, "01-01-2000 12:00")) / Day | ||
| 36 | + | ||
| 37 | + L = n * 0.9856474 + 280.460 | ||
| 38 | + L = L - 360 * int(L / 360.) | ||
| 39 | + if (L < 0) { L += 360. } | ||
| 40 | + | ||
| 41 | + g = n * 0.9856003 + 357.528 | ||
| 42 | + g = g - 360 * int(g / 360.) | ||
| 43 | + if (g < 0) { g += 360. } | ||
| 44 | + | ||
| 45 | + lambda = L + 1.915 * sin(g) + 0.020 * sin(2*g) | ||
| 46 | + | ||
| 47 | + eps = 23.439 - n * 0.0000004 | ||
| 48 | + | ||
| 49 | + # Equatorial coordinates | ||
| 50 | + # RAsc = right ascension | ||
| 51 | + # Dec = declination | ||
| 52 | + | ||
| 53 | + RAsc = atan2( cos(eps) * sin(lambda), cos(lambda) ) | ||
| 54 | + Dec = asin( sin(eps) * sin(lambda) ) | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + # Horizontal coordinates | ||
| 58 | + | ||
| 59 | + h(t) = 360. * t / Day | ||
| 60 | + Altitude(t) = asin( sin(Dec) * sin(phi) + cos(Dec) * cos(phi) * cos(h(t)) ) | ||
| 61 | + | ||
| 62 | + cosAzi(t) = ( sin(Dec) * sin(phi) - cos(Dec) * cos(h(t)) * sin(phi) ) \ | ||
| 63 | + / cos(Altitude(t)) | ||
| 64 | + sinAzi(t) = ( -cos(Dec) * sin(h(t)) ) \ | ||
| 65 | + / cos(Altitude(t)) | ||
| 66 | + Azimuth(t) = atan2( sinAzi(t), cosAzi(t) ) | ||
| 67 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,84 @@ | |||
| 1 | + # | ||
| 2 | + # Calculate solar path in horizontal coordinates (altitude, azimuth) | ||
| 3 | + # Use gnuplot's polar mode with inverted R range so that the horizon | ||
| 4 | + # (altitude 0°) is at the perimeter and altitude 90° is at the center. | ||
| 5 | + # | ||
| 6 | + | ||
| 7 | + set label 1 at screen 0.02, 0.95 font ":Bold,10" | ||
| 8 | + set label 1 "Solar path at\nLatitude 47.47 N" | ||
| 9 | + set timestamp "Seattle - %d %b %Y" | ||
| 10 | + | ||
| 11 | + # Set up equations for Azimuth(t) and Altitude(t) | ||
| 12 | + # as a function of t, the number of seconds before or after noon | ||
| 13 | + # (local standard time) on the day of interest at a particular latitude. | ||
| 14 | + # Here we calculate for Seattle (47.47 N -122.28 W) | ||
| 15 | + | ||
| 16 | + Latitude = 47.47 | ||
| 17 | + Date = "21-12-2016 12:00" | ||
| 18 | + call 'solar_params.dem' | ||
| 19 | + | ||
| 20 | + array dummy[150] | ||
| 21 | + array winter_alt[150] | ||
| 22 | + array winter_azi[150] | ||
| 23 | + time = -12 * Hour | ||
| 24 | + do for [t = 1 : 150] { | ||
| 25 | + winter_alt[t] = Altitude(time) | ||
| 26 | + winter_azi[t] = Azimuth(time) | ||
| 27 | + dummy[t] = t | ||
| 28 | + time = time + 10 * Minute | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + Date = "21-06-2016 12:00" | ||
| 32 | + call 'solar_params.dem' | ||
| 33 | + | ||
| 34 | + array summer_alt[150] | ||
| 35 | + array summer_azi[150] | ||
| 36 | + time = -12 * Hour | ||
| 37 | + do for [t = 1 : 150] { | ||
| 38 | + summer_alt[t] = Altitude(time) | ||
| 39 | + summer_azi[t] = Azimuth(time) | ||
| 40 | + time = time + 10 * Minute | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + Date = strftime(TimeFormat,time(0)) | ||
| 44 | + call 'solar_params.dem' | ||
| 45 | + | ||
| 46 | + array today_alt[150] | ||
| 47 | + array today_azi[150] | ||
| 48 | + time = -12 * Hour | ||
| 49 | + do for [t = 1 : 150] { | ||
| 50 | + today_alt[t] = Altitude(time) | ||
| 51 | + today_azi[t] = Azimuth(time) | ||
| 52 | + time = time + 10 * Minute | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + # | ||
| 56 | + set angle degrees | ||
| 57 | + | ||
| 58 | + set polar | ||
| 59 | + set grid polar | ||
| 60 | + unset xtics | ||
| 61 | + unset ytics | ||
| 62 | + unset border | ||
| 63 | + unset key | ||
| 64 | + set size square | ||
| 65 | + set rrange [90:0] | ||
| 66 | + | ||
| 67 | + set ttics add ("N" 90, "E" 0, "S" -90, "W" 180) font ":Bold" | ||
| 68 | + set rtics format "%.0f°" | ||
| 69 | + set rtics 30 | ||
| 70 | + set rlabel "Altitude" offset -2 font ":Bold" | ||
| 71 | + | ||
| 72 | + # By convention North (azimuth 0°) should be at the top with angles | ||
| 73 | + # increasing clockwise, but gnuplot doesn't yet support anything but | ||
| 74 | + # theta=0 at the right and angles increasing counter-clockwise. | ||
| 75 | + # So we must manually label the angles and add an offset both to the | ||
| 76 | + # tic labels and to the plotted azimuthal angle. | ||
| 77 | + # | ||
| 78 | + # plot [t = -8*Hour : 8*Hour] '+' using (90-Azimuth(t)):(Altitude(t)) title "Winter Solstice" at end | ||
| 79 | + | ||
| 80 | + plot dummy using (90 - winter_azi[$1]):(winter_alt[$1]) lw 2 title " Winter Solstice" at beg left, \ | ||
| 81 | + dummy using (90 - summer_azi[$1]):(summer_alt[$1]) lw 2 title " Summer Solstice" at beg left, \ | ||
| 82 | + dummy using (90 - today_azi[$1]):(today_alt[$1]) lw 2 title "Today " at end right | ||
| 83 | + | ||
| 84 | + pause -1 "<cr> to continue" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - C RCS $Id: gnuplot.doc,v 1.1042 2017-01-10 21:22:54 sfeam Exp $ | ||
| 1 | + C RCS $Id: gnuplot.doc,v 1.1043 2017-01-11 04:13:59 sfeam Exp $ | ||
| 2 | 2 | C | |
| 3 | 3 | C Copyright (C) 1986 - 1993, 1998, 1999, 2000, 2001, 2004 Thomas Williams, Colin Kelley et al. | |
| 4 | 4 | C | |
@@ -216,10 +216,14 @@ C | |||
| 216 | 216 | ||
| 217 | 217 | * New full-featured terminal driver for sixel graphics (see `sixelgd`). | |
| 218 | 218 | ||
| 219 | - * Polar grid elements (circles and radial lines) can be generated whether or | ||
| 220 | - not the program is in polar mode for the purpose of interpreting input | ||
| 221 | - coordinates. Tickmarks and labels around the perimeter of the polar grid | ||
| 222 | - are controlled by `set ttics`. See `ttics`. | ||
| 219 | + * Significant improvements and extensions to the polar coordinate system. | ||
| 220 | + Previous versions of gnuplot produced incorrect or unexpected results for | ||
| 221 | + out-of-range values of r and for rrange inverted (e.g. rrange [90:0]). | ||
| 222 | + Inverted rrange can now be used to generate plots in a celestial horizontal | ||
| 223 | + coordinates (center = zenith = altitude 90, perimeter = horizon = altitude 0). | ||
| 224 | + Polar grid elements (circles and radial lines) can now be generated whether or | ||
| 225 | + not the program is in polar mode. Tickmarks and labels around the perimeter | ||
| 226 | + of the polar grid are controlled by `set ttics`. See `ttics`. | ||
| 223 | 227 | ||
| 224 | 228 | * `windows` graph windows can be docked to the wgnuplot text window, which is | |
| 225 | 229 | especially useful with Windows in "tablet mode". | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | #ifndef lint | |
| 2 | - static char *RCSid() { return RCSid("$Id: axis.c,v 1.216 2017-01-08 04:41:22 sfeam Exp $"); } | ||
| 2 | + static char *RCSid() { return RCSid("$Id: axis.c,v 1.217 2017-01-11 04:13:59 sfeam Exp $"); } | ||
| 3 | 3 | #endif | |
| 4 | 4 | ||
| 5 | 5 | /* GNUPLOT - axis.c */ | |
@@ -1048,6 +1048,8 @@ gen_tics(struct axis *this, tic_callback callback) | |||
| 1048 | 1048 | if (nonlinear(this)) | |
| 1049 | 1049 | internal = eval_link_function(this->linked_to_primary, mark->position) | |
| 1050 | 1050 | - eval_link_function(this->linked_to_primary, polar_shift); | |
| 1051 | + else if (inverted_raxis) | ||
| 1052 | + internal = R_AXIS.set_min - mark->position; | ||
| 1051 | 1053 | else | |
| 1052 | 1054 | internal = axis_log_value(this, mark->position) | |
| 1053 | 1055 | - axis_log_value(this, polar_shift); | |
@@ -1403,8 +1405,11 @@ gen_tics(struct axis *this, tic_callback callback) | |||
| 1403 | 1405 | } else if (this->tictype == DT_DMS) { | |
| 1404 | 1406 | gstrdms(label, this->ticfmt, (double)user); | |
| 1405 | 1407 | } else if (this->index == POLAR_AXIS) { | |
| 1406 | - internal = axis_log_value(this, tic) | ||
| 1407 | - - axis_log_value(this, R_AXIS.min); | ||
| 1408 | + if (inverted_raxis) | ||
| 1409 | + internal = R_AXIS.min - tic; | ||
| 1410 | + else | ||
| 1411 | + internal = axis_log_value(this, tic) | ||
| 1412 | + - axis_log_value(this, R_AXIS.min); | ||
| 1408 | 1413 | gprintf(label, sizeof(label), this->ticfmt, log10_base, tic); | |
| 1409 | 1414 | } else if (this->index >= PARALLEL_AXES) { | |
| 1410 | 1415 | /* FIXME: needed because ticfmt is not maintained for parallel axes */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | #ifndef lint | |
| 2 | - static char *RCSid() { return RCSid("$Id: gadgets.c,v 1.133 2016-11-08 05:41:24 sfeam Exp $"); } | ||
| 2 | + static char *RCSid() { return RCSid("$Id: gadgets.c,v 1.134 2017-01-11 04:13:59 sfeam Exp $"); } | ||
| 3 | 3 | #endif | |
| 4 | 4 | ||
| 5 | 5 | /* GNUPLOT - gadgets.c */ | |
@@ -127,6 +127,7 @@ int timelabel_bottom = TRUE; | |||
| 127 | 127 | ||
| 128 | 128 | /* flag for polar mode */ | |
| 129 | 129 | TBOOLEAN polar = FALSE; | |
| 130 | + TBOOLEAN inverted_raxis = FALSE; | ||
| 130 | 131 | ||
| 131 | 132 | /* zero threshold, may _not_ be 0! */ | |
| 132 | 133 | double zero = ZERO; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -458,6 +458,7 @@ extern text_label timelabel; | |||
| 458 | 458 | extern int timelabel_bottom; | |
| 459 | 459 | ||
| 460 | 460 | extern TBOOLEAN polar; | |
| 461 | + extern TBOOLEAN inverted_raxis; /* true if R_AXIS.set_min > R_AXIS.set_max */ | ||
| 461 | 462 | ||
| 462 | 463 | #define ZERO 1e-8 /* default for 'zero' set option */ | |
| 463 | 464 | extern double zero; /* zero threshold, not 0! */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | #ifndef lint | |
| 2 | - static char *RCSid() { return RCSid("$Id: graphics.c,v 1.539 2017-01-08 04:53:16 sfeam Exp $"); } | ||
| 2 | + static char *RCSid() { return RCSid("$Id: graphics.c,v 1.540 2017-01-11 04:13:59 sfeam Exp $"); } | ||
| 3 | 3 | #endif | |
| 4 | 4 | ||
| 5 | 5 | /* GNUPLOT - graphics.c */ | |
@@ -242,8 +242,8 @@ place_grid(int layer) | |||
| 242 | 242 | if (R_AXIS.ticmode && (raxis || polar)) { | |
| 243 | 243 | /* Piggyback on the xtick2d_callback. Avoid a call to the full */ | |
| 244 | 244 | /* axis_output_tics(), which wasn't really designed for this axis. */ | |
| 245 | - tic_start = map_y(0); /* Always equivalent to tics on phi=0 axis */ | ||
| 246 | - tic_mirror = tic_start; /* tic extends on both sides of phi=0 */ | ||
| 245 | + tic_start = map_y(0); /* Always equivalent to tics on theta=0 axis */ | ||
| 246 | + tic_mirror = tic_start; /* tic extends on both sides of theta=0 */ | ||
| 247 | 247 | tic_text = tic_start - t->v_char; | |
| 248 | 248 | rotate_tics = R_AXIS.tic_rotate; | |
| 249 | 249 | if (rotate_tics == 0) | |
@@ -3400,14 +3400,15 @@ xtick2d_callback( | |||
| 3400 | 3400 | if (this_axis->index == POLAR_AXIS) { | |
| 3401 | 3401 | double x = place, y = 0, s = sin(0.1), c = cos(0.1); | |
| 3402 | 3402 | int i; | |
| 3403 | - int ogx = map_x(x); | ||
| 3404 | - int ogy = map_y(0); | ||
| 3405 | - int gx, gy; | ||
| 3403 | + int ogx, ogy, gx, gy; | ||
| 3406 | 3404 | ||
| 3407 | 3405 | if (place > largest_polar_circle) | |
| 3408 | 3406 | largest_polar_circle = place; | |
| 3409 | 3407 | else if (-place > largest_polar_circle) | |
| 3410 | 3408 | largest_polar_circle = -place; | |
| 3409 | + | ||
| 3410 | + ogx = map_x(x); | ||
| 3411 | + ogy = map_y(0); | ||
| 3411 | 3412 | for (i = 1; i <= 63 /* 2pi/0.1 */ ; ++i) { | |
| 3412 | 3413 | { | |
| 3413 | 3414 | /* cos(t+dt) = cos(t)cos(dt)-sin(t)cos(dt) */ | |
@@ -3941,14 +3942,19 @@ place_raxis() | |||
| 3941 | 3942 | ||
| 3942 | 3943 | x0 = map_x(0); | |
| 3943 | 3944 | y0 = map_y(0); | |
| 3944 | - rightend = (R_AXIS.autoscale & AUTOSCALE_MAX) ? R_AXIS.max : R_AXIS.set_max; | ||
| 3945 | - xend = map_x( AXIS_LOG_VALUE(POLAR_AXIS,rightend) | ||
| 3946 | - - AXIS_LOG_VALUE(POLAR_AXIS,R_AXIS.set_min)); | ||
| 3945 | + if (inverted_raxis) { | ||
| 3946 | + xend = map_x(R_AXIS.set_min); | ||
| 3947 | + } else { | ||
| 3948 | + rightend = (R_AXIS.autoscale & AUTOSCALE_MAX) ? R_AXIS.max : R_AXIS.set_max; | ||
| 3949 | + xend = map_x( AXIS_LOG_VALUE(POLAR_AXIS,rightend) | ||
| 3950 | + - AXIS_LOG_VALUE(POLAR_AXIS,R_AXIS.set_min)); | ||
| 3951 | + } | ||
| 3947 | 3952 | yend = y0; | |
| 3948 | 3953 | term_apply_lp_properties(&border_lp); | |
| 3949 | 3954 | draw_clip_line(x0,y0,xend,yend); | |
| 3950 | 3955 | ||
| 3951 | 3956 | #ifdef EAM_OBJECTS | |
| 3957 | + if (!inverted_raxis) | ||
| 3952 | 3958 | if (!(R_AXIS.autoscale & AUTOSCALE_MIN) && R_AXIS.set_min != 0) | |
| 3953 | 3959 | place_objects( &raxis_circle, LAYER_FRONT, 2); | |
| 3954 | 3960 | #endif | |
| Back | FazBrowse Home | New Git URL |
0 commit comments