ssapy_toolkit.Plots.plotutils

Functions

check_type(var)

Classify 'var' into one of VarType cases.

create_sphere(cx, cy, cz, r[, resolution])

Create sphere coordinates with center (cx, cy, cz) and radius r.

darken(color[, amount])

Darken a color by reducing its lightness.

display_figure(figname[, display])

drawEarth(time[, ngrid, R, rfactor])

drawMoon(time[, ngrid, R, rfactor])

drawSphere(xCenter, yCenter, zCenter, r[, ...])

draw_dashed_circle(ax, normal_vector, ...[, ...])

generate_rainbow_colors(num_iterations)

is_list_of_arrays(lst)

is_list_of_lists(lst)

load_earth_file()

load_moon_file()

make_black(fig, *axes)

make_white(fig, *axes)

rgb(minimum, maximum, value)

save_plot(figure, save_path[, dpi])

Save a Matplotlib figure as JPG (or append to PDF if save_path ends with .pdf).

save_plot_to_pdf(figure, pdf_path)

Save a Matplotlib figure as a PNG embedded in a PDF file.

valid_orbits(r, t[, drop_empty, warn])

Normalize r and t into parallel lists of shape-(n,3) ndarrays and astropy Time objects.

yufig(figure, save_path[, dpi])

Save a Matplotlib figure.

Classes

VarType(value)

class ssapy_toolkit.Plots.plotutils.VarType(value)[source]

Bases: Enum

ARRAY = 3
LIST_ARRAYS = 4
LIST_LISTS = 5
MIXED_LIST = 6
NONE = 1
OTHER = 7
TIME = 2
ssapy_toolkit.Plots.plotutils.check_type(var)[source]

Classify ‘var’ into one of VarType cases.

ssapy_toolkit.Plots.plotutils.create_sphere(cx, cy, cz, r, resolution=360)[source]

Create sphere coordinates with center (cx, cy, cz) and radius r.

Return type:

np.ndarray of shape (3, 2*resolution, resolution)

ssapy_toolkit.Plots.plotutils.darken(color, amount=0.5)[source]

Darken a color by reducing its lightness.

Parameters:
  • color (str) – Named color or hex string.

  • amount (float or iterable of floats in [0,1]) – 0 -> no change, 1 -> black. Iterable returns multiple shades.

Return type:

list of RGB tuples in 0..1

ssapy_toolkit.Plots.plotutils.display_figure(figname, display='IPython')[source]
ssapy_toolkit.Plots.plotutils.drawEarth(time, ngrid=100, R=6378137.0, rfactor=1)[source]
Parameters:
  • time (array_like or astropy.time.Time (n,)) – If float (array), then should correspond to GPS seconds; i.e., seconds since 1980-01-06 00:00:00 UTC

  • ngrid (int) – Number of grid points in Earth model.

  • R (float) – Earth radius in meters. Default is WGS84 value.

  • rfactor (float) – Factor by which to enlarge Earth (for visualization purposes)

ssapy_toolkit.Plots.plotutils.drawMoon(time, ngrid=100, R=1738100.0, rfactor=1)[source]
Parameters:
  • time (array_like or astropy.time.Time (n,)) – If float (array), then should correspond to GPS seconds; i.e., seconds since 1980-01-06 00:00:00 UTC

  • ngrid (int) – Number of grid points in Moon model.

  • R (float) – Moon radius in meters.

  • rfactor (float) – Factor by which to enlarge Moon (for visualization purposes)

ssapy_toolkit.Plots.plotutils.drawSphere(xCenter, yCenter, zCenter, r, res=10j, flatten=True)[source]
ssapy_toolkit.Plots.plotutils.draw_dashed_circle(ax, normal_vector, radius, dashes, dash_length=0.1, label='Dashed Circle')[source]
ssapy_toolkit.Plots.plotutils.generate_rainbow_colors(num_iterations)[source]
ssapy_toolkit.Plots.plotutils.is_list_of_arrays(lst)[source]
ssapy_toolkit.Plots.plotutils.is_list_of_lists(lst)[source]
ssapy_toolkit.Plots.plotutils.load_earth_file()[source]
ssapy_toolkit.Plots.plotutils.load_moon_file()[source]
ssapy_toolkit.Plots.plotutils.make_black(fig, *axes)[source]
ssapy_toolkit.Plots.plotutils.make_white(fig, *axes)[source]
ssapy_toolkit.Plots.plotutils.rgb(minimum, maximum, value)[source]
ssapy_toolkit.Plots.plotutils.save_plot(figure, save_path, dpi=200)[source]

Save a Matplotlib figure as JPG (or append to PDF if save_path ends with .pdf).

ssapy_toolkit.Plots.plotutils.save_plot_to_pdf(figure, pdf_path)[source]

Save a Matplotlib figure as a PNG embedded in a PDF file.

If the specified PDF already exists, append a new page; otherwise create it.

ssapy_toolkit.Plots.plotutils.valid_orbits(r, t, drop_empty=True, warn=True)[source]

Normalize r and t into parallel lists of shape-(n,3) ndarrays and astropy Time objects.

Accepts:
r:
  • (3,), (1,3), (N,3), (B,N,3) ndarray

  • list/tuple of any of the above

t:
  • None

  • scalar (float/int) interpreted as GPS seconds (broadcast)

  • ndarray of GPS seconds: (N,) or (B,N)

  • astropy.time.Time (scalar or array)

  • list/tuple of scalars/ndarrays/Time, matching number of tracks

Additionally (if drop_empty=True):
  • removes empty r-tracks (Ni==0)

  • if t is a per-track list/tuple with the same length as the original r_list, removes the corresponding t entries too

  • prints a warning when any are removed

Returns:

r_list: list[np.ndarray] where each is (Ni,3) t_list: list[astropy.time.Time] where each has len Ni

ssapy_toolkit.Plots.plotutils.yufig(figure, save_path, dpi=200)[source]

Save a Matplotlib figure.

Behavior:
  • If save_path has no extension -> save as JPG (‘.jpg’ is appended).

  • If save_path ends with ‘.pdf’ (case-insensitive) -> append/write to PDF via save_plot_to_pdf.

  • If save_path has any other extension -> use it directly with figure.savefig().