ssapy.utils

This module provides functions for coordinate transformations, vector operations, celestial mechanics, and mathematical utilities.

Functions

altitude_to_zenithangle(altitude[, deg])

Convert altitude angle to zenith angle.

angle_between_vectors(vector1, vector2)

Calculates the angle (in radians) between two vectors.

cart2sph_deg(x, y, z)

Convert Cartesian coordinates to spherical coordinates in degrees.

cart_to_cyl(x, y, z)

Convert Cartesian coordinates to cylindrical coordinates.

catalog_to_apparent(ra, dec, t[, observer, ...])

Convert ra/dec of stars from catalog positions (J2000/ICRS) to apparent positions, correcting for proper motion, parallax, annual and diurnal aberration.

check_lunar_collision(r, times[, m])

Checks if the trajectory of a particle intersects with the Moon.

cluster_emcee_walkers(chain, lnprob, lnprior)

Down-select emcee walkers to those with the largest posterior mean.

continueClass(cls)

Re-open the decorated class, adding any new definitions into the original. For example: .. code-block:: python class Foo: pass @continueClass class Foo: def run(self): return None is equivalent to: .. code-block:: python class Foo: def run(self): return None .. warning:: Python's built-in super function does not behave properly in classes decorated with continueClass. Base class methods must be invoked directly using their explicit types instead.

dd_to_dms(degree_decimal)

Converts a Decimal Degree (DD) value to Degree-Minute-Second (DMS) format.

dd_to_hms(degree_decimal)

Converts Decimal Degrees (DD) to Hour-Minute-Second (HMS) format.

deg0to360(array_)

Normalize angles in degrees to the range [0, 360].

deg0to360array(array_)

Normalize an array of angles in degrees to the range [0, 360].

deg90to90(val_in)

Normalize angles to the range [-90, 90].

deg90to90array(array_)

Normalize an array of angles to the range [0, 90].

dms_to_dd(dms)

Converts coordinates from Degree-Minute-Second (DMS) format to Decimal Degrees (DD).

dms_to_deg(coords)

Convert coordinates from degrees, minutes, and seconds (DMS) format to decimal degrees.

dms_to_rad(coords)

Convert coordinates from degrees, minutes, and seconds (DMS) format to radians.

ecliptic_to_equatorial(lon, lat[, degrees])

Convert ecliptic coordinates (longitude, latitude) to equatorial right ascension (RA) and declination (DEC).

ecliptic_xyz_to_equatorial(xc, yc, zc[, xe, ...])

Convert ecliptic Cartesian coordinates (X, Y, Z) to equatorial right ascension (RA) and declination (DEC).

ecliptic_xyz_to_equatorial_xyz(xc, yc, zc)

Convert ecliptic rectangular coordinates (X, Y, Z) to equatorial rectangular coordinates.

einsum_norm(a[, indices])

Compute the norm of an array using Einstein summation notation with customizable indices.

equatorial_to_ecliptic(right_ascension, ...)

Convert equatorial coordinates (RA, DEC) to ecliptic longitude and latitude.

equatorial_to_horizontal(observer_latitude, ...)

Convert equatorial coordinates (declination and either right ascension or hour angle) to horizontal coordinates (azimuth and altitude) for a given observer's latitude.

equatorial_xyz_to_ecliptic_xyz(xq, yq, zq)

Convert equatorial rectangular coordinates (X, Y, Z) to ecliptic rectangular coordinates.

find_all_zeros(f, low, high[, n])

Attempt to find all zeros of a function between given bounds.

find_extrema_brackets(fs)

Find triplets bracketing extrema from an ordered set of function evaluations.

find_file(filename[, ext])

Find a file in the current directory or the ssapy datadir.

find_nearest_indices(A, B)

Finds the indices of the nearest values in array A for each value in array B.

find_smallest_bounding_cube(r[, pad])

Find the smallest bounding cube for a set of 3D coordinates, with optional padding.

gcrf_to_ecef_bad(r_gcrf, t)

Convert position vectors from the GCRF (Geocentric Celestial Reference Frame) to the ECEF (Earth-Centered, Earth-Fixed) frame.

gcrf_to_itrf(r_gcrf, t[, v])

Converts a position vector in the GCRF (Geocentric Celestial Reference Frame) to the ITRF (International Terrestrial Reference Frame) in Cartesian coordinates.

gcrf_to_itrf_astropy(state_vectors, t)

Converts position vectors from the GCRF (Geocentric Celestial Reference Frame) to the ITRF (International Terrestrial Reference Frame) using Astropy.

gcrf_to_lat_lon(r, t)

Converts a position vector in the GCRF (Geocentric Celestial Reference Frame) to latitude, longitude, and height coordinates on Earth.

gcrf_to_lunar(r, t[, v])

Transform position and velocity vectors from the GCRF (Geocentric Celestial Reference Frame) to a lunar-centric frame.

gcrf_to_lunar_fixed(r, t[, v])

Transform position and velocity vectors from the GCRF (Geocentric Celestial Reference Frame) to a Moon-fixed (lunar-centric) frame.

gcrf_to_radec(gcrf_coords)

gcrf_to_sim_geo(r_gcrf, t[, h])

Transforms a position vector in the GCRF (Geocentric Celestial Reference Frame) to a simplified geostationary-like coordinate system.

gcrf_to_teme(t)

Return the rotation matrix that converts GCRS cartesian coordinates to TEME cartesian coordinates.

get_angle(a, b, c)

Calculate the angle between two vectors where b is the vertex of the angle.

get_kernel_cov(kernel_mat, weights)

Get the covariance matrix of kernel_mat.

get_normed_weights(ln_weights)

Computes normalized weights from log-weights.

get_times(duration, freq[, t0])

Calculate a list of times spaced equally apart over a specified duration.

hms_to_dd(hms)

Converts Hour-Minute-Second (HMS) format to Decimal Degrees (DD).

horizontal_to_equatorial(observer_latitude, ...)

Convert horizontal coordinates (azimuth and altitude) to equatorial coordinates (hour angle and declination).

iers_interp(t)

Interpolate IERS values

inert2rot(x, y, xe, ye[, xs, ys])

Transform inertial coordinates to rotated coordinates relative to the Earth.

interpolate_points_between(r, m)

Interpolates points between the given points.

isAttributeSafeToTransfer(name, value)

Return True if an attribute is safe to monkeypatch-transfer to another class.

lb_to_tan(lb, b[, mul, mub, lcen, bcen])

Convert lb-like coordinates & proper motions to orthographic tangent plane.

lb_to_tp(lb, b)

Convert lb-like coordinates to theta-phi like coordinates.

lb_to_unit(r, d)

Convert lb-like coordinates to unit vectors.

lonlat_distance(lat1, lat2, lon1, lon2)

Calculate the great-circle distance between two points on Earth's surface using the Haversine formula.

moonPos(t)

Compute GCRF position of the moon.

newton_raphson(guess, f[, fprime, eps, maxiter])

Find a root of a univariate function with known gradient using Newton-Raphson iterations.

norm(arr)

Compute the Euclidean norm of an array over the last axis while preserving leading axes.

normSq(arr)

Compute the squared norm of an array over the last axis while preserving leading axes.

normed(arr)

Normalize an array along the last axis to have unit length.

ntw_to_r(r, v, ntw[, relative])

Convert NTW coordinates to cartesian coordinates, using r, v to define NTW system.

num_wraps(ang)

Return number of times angle ang has wrapped around.

perpendicular_vectors(v)

Returns two vectors that are perpendicular to v and each other.

points_on_circle(r, v, rad[, num_points])

Generate points on a circle in 3D space.

proper_motion_ra_dec([r, v, x, y, z, vx, ...])

Calculate the proper motion in right ascension (RA) and declination (DEC) for celestial objects.

ra_dec([r, v, x, y, z, vx, vy, vz, r_earth, ...])

Calculate the Right Ascension (RA) and Declination (Dec) of an object relative to Earth's position.

rad0to2pi(angles)

Normalize angles in radians to the range [0, 2π].

regularize_default(particles, weights[, ...])

Perform particle regularization.

resample(particles, ln_weights[, obs_times, pod])

Resample particles to achieve more uniform weights.

rightascension_to_hourangle(right_ascension, ...)

Convert right ascension to hour angle.

rotate_points_3d(points[, axis, theta])

Rotate a set of 3D points about a 3D axis by an angle theta in radians.

rotate_vector(v_unit, theta, phi[, ...])

Rotates a unit vector by specified angles and optionally plots the rotation path.

rotation_matrix_from_vectors(vec1, vec2)

Find the rotation matrix that aligns vec1 to vec2 :param vec1: A 3d "source" vector :param vec2: A 3d "destination" vector :return mat: A transform matrix (3x3) which when applied to vec1, aligns it with vec2.

rv_to_ntw(r, v, rcoord)

Convert coordinates to NTW coordinates, using r, v to define NTW system.

sample_points(x, C, npts[, sqrt])

Sample points around x according to covariance matrix.

sigma_points(f, x, C[, scale, fixed_dimensions])

Compute f(sigma points) for sigma points of C around x.

sim_lonlatrad(x, y, z, xe, ye, ze, xs, ys, zs)

Simulate longitude, latitude, and radius in a geocentric frame with the Sun at (0, 0).

subsample_high_lnprob(chain, lnprob, ...[, ...])

Select MCMC samples with probabilities above some relative threshold

sunPos(t[, fast])

Compute GCRF position of the sun.

sun_ra_dec(time_)

Calculate the Right Ascension (RA) and Declination (Dec) of the Sun at a given time.

tan_to_lb(xx, yy, lcen, bcen)

Convert orthographic tangent plane coordinates to lb coordinates.

teme_to_gcrf(t)

Return the rotation matrix that converts TEME cartesian coordinates to GCRS cartesian coordinates.

tp_to_lb(t, p)

Convert theta-phi-like coordinates to lb-like coordinates.

tp_to_unit(t, p)

Convert theta-phi-like coordinates to unit vectors.

unitAngle3(r1, r2)

Robustly compute angle between unit vectors r1 and r2.

unit_to_lb(unit)

Convert unit vectors to lb-like coordinates.

unit_to_tp(unit)

Convert unit vectors to theta-phi-like coordinates.

unit_vector(vector)

Returns the unit vector of the vector.

unscented_transform_mean_covar(f, x, C[, scale])

Compute mean and covariance matrix using unscented transform given a transformation f, a point x, and a covariance C.

v_from_r(r, t)

Calculate the velocity from position and time data.

xyz_to_ecliptic(xc, yc, zc[, xe, ye, ze, ...])

Convert rectangular coordinates (X, Y, Z) to ecliptic longitude and latitude.

xyz_to_equatorial(xq, yq, zq[, xe, ye, ze, ...])

Convert rectangular coordinates (X, Y, Z) to equatorial right ascension (RA) and declination (DEC).

xyz_to_lb(x, y, z)

Convert x, y, z vectors to lb-like coordinates.

xyz_to_tp(x, y, z)

Convert x, y, z vectors to theta-phi-like coordinates.

zenithangle_to_altitude(zenith_angle[, deg])

Convert zenith angle to altitude angle.

Classes

LRU_Cache(user_function[, maxsize])

Simplified Least Recently Used Cache.

Time(val[, val2, format, scale, precision, ...])

Represent and manipulate times and dates for astronomy.

lazy_property(fget)

meant to be used for lazy evaluation of an object attribute.

Class Inheritance Diagram

Inheritance diagram of ssapy.utils.LRU_Cache, ssapy.utils.lazy_property