Utilities

AstroBase.Util.CubicSplineMethod
CubicSpline(x, y)

Construct a cubic spline interpolator. x and y must have the same length and at least four elements.

Example

julia> x = 1:5;

julia> y = [2.0, 5.0, 3.2, 4.8, 6.7];

julia> spl = CubicSpline(x, y);

julia> spl(3.5)
3.5921875
source
AstroBase.Util.days_to_hmsMethod
days_to_hms(days)

Split days into hours, minutes, and seconds.

Example

julia> days_to_hms(0.314159)
(7, 32, 23.337600000000265)
source
AstroBase.Util.deg_to_dmsMethod
deg_to_dms(x)

Split x into degrees, arcminutes, and arcseconds.

Example

julia> deg_to_dms(90.314159)
(90, 18, 50.97240000001307)
source
AstroBase.Util.distanceMethod
distance(v1, v2)

Return the Euclidean (L2) distance between vectors v1 and v2.

Example

julia> distance([1.0, 0.0, 0.0], [0.0, 1.0, 0.0])
1.4142135623730951
source
AstroBase.Util.dms_to_degMethod
dms_to_deg(d, m, s)

Convert degrees d, arcminutes m, and arcseconds s to degrees.

Example

julia> dms_to_deg(90, 18, 50.97240000001307)
90.314159
source
AstroBase.Util.dms_to_radMethod
dms_to_rad(d, m, s)

Convert degrees d, arcminutes m, and arcseconds s to radians.

Example

julia> dms_to_rad(25, 42, 51.42857142857508)
0.4487989505128276
source
AstroBase.Util.hms_to_daysMethod
hms_to_days(h, m, s)

Convert hours h, minutes m, and seconds s to days.

Example

julia> hms_to_days(7, 32, 50.2)
0.3144699074074074
source
AstroBase.Util.rad_to_dmsMethod
rad_to_dms(x)

Convert x from radians into degrees, arcminutes, and arcseconds.

Example

julia> rad_to_dms(π/7)
(25, 42, 51.42857142857508)
source
AstroBase.Util.spherical_to_cartesianMethod
spherical_to_cartesian(theta, phi)

Convert spherical coordinates to Cartesian.

Arguments

  • theta: longitude angle in radians
  • phi: latitude angle in radians

Returns

  • x: magnitude of projection on x axis
  • y: magnitude of projection on y axis
  • z: magnitude of projection on z axis

References

source
Base.angleMethod
angle(v1, v2)

Returns the angle between vectors v1 and v2 in rad.

Example

julia> rad_to_deg(angle([1.0, 0.0, 0.0], [0.0, 1.0, 0.0]))
90.0
source