Skip to content

Instantly share code, notes, and snippets.

@NikosAlexandris
Last active December 19, 2024 20:42
Show Gist options
  • Save NikosAlexandris/28c889ee19df3d9b414271f66fcd5a88 to your computer and use it in GitHub Desktop.
Save NikosAlexandris/28c889ee19df3d9b414271f66fcd5a88 to your computer and use it in GitHub Desktop.
Experimental polar plots of horizon height angles using Uniplot
import numpy
from uniplot import plot
from rich import print
# Generate equidistant azimuthal directions, say 64 + 1
azimuthal_directions_degrees = numpy.linspace(0, 360, 65)
azimuthal_directions_radians = numpy.radians(azimuthal_directions_degrees)
x_azimuth = numpy.sin(azimuthal_directions_radians)
y_azimuth = numpy.cos(azimuthal_directions_radians)
# Horizon profile : horizon height angles around a location in degrees
horizon_profile_degrees = numpy.random.uniform(0, 33, 64)
horizon_profile_degrees = numpy.append(horizon_profile_degrees, horizon_profile_degrees[0])
horizon_profile_radians = numpy.radians(horizon_profile_degrees)
x_horizon = numpy.cos(horizon_profile_radians)
y_horizon = numpy.sin(horizon_profile_radians)
# Let's create a "directional fin" _from_ North !
horizon_profile_degrees_fin_north = numpy.copy(horizon_profile_degrees)
horizon_profile_degrees_fin_north[1:-1] = 0
# for East, South and West too.
horizon_profile_degrees_fin_east = numpy.roll(numpy.copy(horizon_profile_degrees_fin_north), 16)
horizon_profile_degrees_fin_before_east = numpy.roll(numpy.copy(horizon_profile_degrees_fin_east), -1)
horizon_profile_degrees_fin_after_east = numpy.roll(numpy.copy(horizon_profile_degrees_fin_east), -1)
horizon_profile_degrees_fin_south = numpy.roll(numpy.copy(horizon_profile_degrees_fin_north), 32)
horizon_profile_degrees_fin_west = numpy.roll(numpy.copy(horizon_profile_degrees_fin_north), 48)
# degrees to radians
horizon_profile_radians_fin_north = numpy.radians(horizon_profile_degrees_fin_north)
horizon_profile_radians_fin_before_east = numpy.radians(horizon_profile_degrees_fin_before_east)
horizon_profile_radians_fin_east = numpy.radians(horizon_profile_degrees_fin_east)
horizon_profile_radians_fin_after_east = numpy.radians(horizon_profile_degrees_fin_after_east)
horizon_profile_radians_fin_south = numpy.radians(horizon_profile_degrees_fin_south)
horizon_profile_radians_fin_west = numpy.radians(horizon_profile_degrees_fin_west)
# get x and y polar coordinates ?
x_horizon_fin_north = numpy.cos(horizon_profile_radians_fin_north)
x_horizon_fin_before_east = numpy.cos(horizon_profile_radians_fin_before_east)
x_horizon_fin_east = numpy.cos(horizon_profile_radians_fin_east)
x_horizon_fin_after_east = numpy.cos(horizon_profile_radians_fin_after_east)
x_horizon_fin_south = numpy.cos(horizon_profile_radians_fin_south)
x_horizon_fin_west = numpy.cos(horizon_profile_radians_fin_west)
y_horizon_fin_north = numpy.sin(horizon_profile_radians_fin_north)
y_horizon_fin_after_east = numpy.sin(horizon_profile_radians_fin_before_east)
y_horizon_fin_east = numpy.sin(horizon_profile_radians_fin_east)
y_horizon_fin_before_east = numpy.sin(horizon_profile_radians_fin_after_east)
y_horizon_fin_south = numpy.sin(horizon_profile_radians_fin_south)
y_horizon_fin_west = numpy.sin(horizon_profile_radians_fin_west)
# Define directional fins
x_fin_north = x_azimuth
y_fin_north = y_azimuth - y_horizon_fin_north
# Split before east
x_fin_before_east = x_azimuth - y_horizon_fin_before_east
y_fin_before_east = y_azimuth
# East
x_fin_east = x_azimuth - y_horizon_fin_east
y_fin_east = y_azimuth
# Split after east
x_fin_after_east = x_azimuth - y_horizon_fin_after_east
y_fin_after_east = y_azimuth
# South
x_fin_south = x_azimuth
y_fin_south = y_azimuth + y_horizon_fin_south
# West
x_fin_west = x_azimuth + y_horizon_fin_west *1.3
y_fin_west = y_azimuth
# Plot'em !
colors = ["cyan", "red"]
print(f"[reverse]North[/reverse]")
plot(
xs=azimuthal_directions_degrees,
ys=horizon_profile_degrees_fin_north,
lines=True,
width=45,
height=6,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["North fin"],
)
plot(
xs=[x_azimuth, x_fin_north],
ys=[y_azimuth, y_fin_north],
lines=True,
width=45,
height=20,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "North fin"],
)
print(f"[reverse]Before East[/reverse]")
plot(
xs=azimuthal_directions_degrees,
ys=horizon_profile_degrees_fin_before_east,
lines=True,
width=45,
height=6,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Before East fin"],
)
plot(
xs=[x_azimuth, x_fin_before_east],
ys=[y_azimuth, y_fin_before_east],
lines=True,
width=45,
height=20,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "Before East fin"],
)
print(f"[reverse]East[/reverse]")
plot(
xs=azimuthal_directions_degrees,
ys=horizon_profile_degrees_fin_east,
lines=True,
width=45,
height=6,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["East fin"],
)
plot(
xs=[x_azimuth, x_fin_east],
ys=[y_azimuth, y_fin_east],
lines=True,
width=45,
height=20,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "East fin"],
)
print(f"[reverse]After East[/reverse]")
plot(
xs=azimuthal_directions_degrees,
ys=horizon_profile_degrees_fin_after_east,
lines=True,
width=45,
height=6,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "After East fin"],
)
plot(
xs=[x_azimuth, x_fin_after_east],
ys=[y_azimuth, y_fin_after_east],
lines=True,
width=45,
height=20,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "After East fin"],
)
plot(
xs=azimuthal_directions_degrees,
ys=horizon_profile_degrees_fin_south,
lines=True,
width=45,
height=6,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "North fin"],
)
plot(
xs=[x_azimuth, x_fin_south],
ys=[y_azimuth, y_fin_south],
lines=True,
width=45,
height=20,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "South fin"],
)
plot(
xs=azimuthal_directions_degrees,
ys=horizon_profile_degrees_fin_west,
lines=True,
width=45,
height=6,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "North fin"],
)
plot(
xs=[x_azimuth, x_fin_west],
ys=[y_azimuth, y_fin_west],
lines=True,
width=45,
height=20,
x_gridlines=[],
y_gridlines=[],
color=colors,
legend_labels=["Horizon", "West fin"],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment