Skip to content

Commit

Permalink
Merge c6b902c into 75bb7f8
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarLukas committed Feb 7, 2019
2 parents 75bb7f8 + c6b902c commit 236a9be
Show file tree
Hide file tree
Showing 8 changed files with 617 additions and 22 deletions.
40 changes: 39 additions & 1 deletion src/e.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export
et2utc,
etcal,
eul2m
eul2m,
edterm

"""
et2utc(et, format, prec)
Expand Down Expand Up @@ -91,3 +92,40 @@ function eul2m(angle3, angle2, angle1, axis3, axis2, axis1)
handleerror()
permutedims(r)
end

"""
edterm(trmtyp, source, target, et, fixref, obsrvr, abcorr)
Construct a rotation matrix from a set of Euler angles.
### Arguments ###
- `trmtyp`: Terminator type.
- `source`: Light source.
- `target`: Target body.
- `et`: Observation epoch.
- `fixref`: Body-fixed frame associated with target.
- `obsrvr`: Observer.
- `npts`: Number of points in terminator set.
- `abcorr`: Aberration correction.
### Output ###
- `trgepc`: Epoch associated with target center.
- `obspos`: Position of observer in body-fixed frame.
- `trmpts`: Terminator point set.
### References ###
- [NAIF Documentation](https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/edterm_c.html)
"""
function edterm(trmtyp, source, target, et, fixref, obsrvr, npts; abcorr="NONE")
trgepc = Ref{SpiceDouble}(0)
obspos = Array{SpiceDouble}(undef, 3)
trmpts = Array{SpiceDouble}(undef, 3, npts)
ccall((:edterm_c, libcspice), Cvoid,
(Cstring, Cstring, Cstring, SpiceDouble, Cstring, Cstring, Cstring, SpiceInt, Ref{SpiceDouble}, Ptr{SpiceDouble}, Ptr{SpiceDouble}),
trmtyp, source, target, et, fixref, abcorr, obsrvr, npts, trgepc, obspos, trmpts)
handleerror()
trgepc[], obspos, trmpts
end
89 changes: 89 additions & 0 deletions src/i.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
export
ilumin,
illumg

"""
ilumin(method, target, et, fixref, obsrvr, spoint, abcorr)
Find the illumination angles (phase, solar incidence, and emission) at a specified surface point of a target body.
This routine supersedes illum_c.
### Arguments ###
- `method`: Computation method.
- `target`: Name of target body.
- `et`: Epoch in ephemeris seconds past J2000 TDB.
- `fixref`: Body-fixed, body-centered target body frame.
- `obsrvr`: Name of observing body.
- `spoint`: Body-fixed coordinates of a target surface point.
- `abcorr`: Aberration correction.
### Output ###
- `trgepc`: Sub-solar point epoch.
- `srfvec`: Vector from observer to sub-solar point.
- `phase`: Phase angle at the surface point.
- `incdnc`: Solar incidence angle at the surface point.
- `emissn`: Emission angle at the surface point.
### References ###
- [NAIF Documentation](https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ilumin_c.html
"""
function ilumin(method, target, et, fixref, obsrvr, spoint; abcorr="NONE")
trgepc = Ref{SpiceDouble}(0)
srfvec = Array{SpiceDouble}(undef, 3)
phase = Ref{SpiceDouble}(0)
incdnc = Ref{SpiceDouble}(0)
emissn = Ref{SpiceDouble}(0)
ccall((:ilumin_c, libcspice), Cvoid,
(Cstring, Cstring, SpiceDouble, Cstring, Cstring, Cstring, Ptr{SpiceDouble}, Ref{SpiceDouble}, Ptr{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}),
method, target, et, fixref, abcorr, obsrvr, spoint, trgepc, srfvec, phase, incdnc, emissn)
handleerror()
trgepc[], srfvec, phase[], incdnc[], emissn[]
end

"""
illumg(method, target, ilusrc, et, fixref, obsrvr, spoint, abcorr)
Find the illumination angles (phase, incidence, and emission) at a specified surface point of a target body.
The surface of the target body may be represented by a triaxial ellipsoid or by topographic data provided by DSK files.
The illumination source is a specified ephemeris object.
### Arguments ###
- `method`: Computation method.
- `target`: Name of target body.
- `ilusrc`: Name of illumination source.
- `et`: Epoch in ephemeris seconds past J2000 TDB.
- `fixref`: Body-fixed, body-centered target body frame.
- `obsrvr`: Name of observing body.
- `spoint`: Body-fixed coordinates of a target surface point.
- `abcorr`: Aberration correction.
### Output ###
- `trgepc`: Sub-solar point epoch.
- `srfvec`: Vector from observer to sub-solar point.
- `phase`: Phase angle at the surface point.
- `incdnc`: Solar incidence angle at the surface point.
- `emissn`: Emission angle at the surface point.
### References ###
- [NAIF Documentation](https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/illumg_c.html
"""
function illumg(method, target, ilusrc, et, fixref, obsrvr, spoint; abcorr="NONE")
trgepc = Ref{SpiceDouble}(0)
srfvec = Array{SpiceDouble}(undef, 3)
phase = Ref{SpiceDouble}(0)
incdnc = Ref{SpiceDouble}(0)
emissn = Ref{SpiceDouble}(0)
ccall((:illumg_c, libcspice), Cvoid,
(Cstring, Cstring, Cstring, SpiceDouble, Cstring, Cstring, Cstring, Ptr{SpiceDouble}, Ref{SpiceDouble}, Ptr{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}),
method, target, ilusrc, et, fixref, abcorr, obsrvr, spoint, trgepc, srfvec, phase, incdnc, emissn)
handleerror()
trgepc[], srfvec, phase[], incdnc[], emissn[]
end
74 changes: 71 additions & 3 deletions src/r.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export
rav2xf,
rotate,
recrad
reclat,
recpgr,
recrad,
rotate

"""
rav2xf(rot, av)
Expand Down Expand Up @@ -30,6 +32,70 @@ function rav2xf(rot, av)
xform
end

"""
reclat(rectan)
Convert from rectangular coordinates to latitudinal coordinates.
### Arguments ###
- `rectan`: Rectangular coordinates of a point as an iterable with three elements.
### Output ###
Returns a tuple consisting of:
- `rad`: Distance of the point from the origin
- `lon`: Planetographic longitude of the point (radians)
- `lat`: Planetographic latitude of the point (radians)
### References ###
- [NAIF Documentation](https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/reclat_c.html)
"""
function reclat(rectan)
lon = Ref{SpiceDouble}()
lat = Ref{SpiceDouble}()
rad = Ref{SpiceDouble}()
ccall((:reclat_c, libcspice), Cvoid,
(Ptr{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}),
collect(rectan), rad, lon, lat)
rad[], lon[], lat[]
end

"""
recpgr(body, rectan, re, f)
Convert rectangular coordinates to planetographic coordinates.
### Arguments ###
- `body`: Body with which coordinate system is associated
- `rectan`: Rectangular coordinates of a point
- `re`: Equatorial radius of the reference spheroid
- `f`: flattening coefficient
### Output ###
- `lon`: Planetographic longitude of the point (radians).
- `lat`: Planetographic latitude of the point (radians).
- `alt`: Altitude of the point above reference spheroid.
### References ###
- [NAIF Documentation](https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/recpgr_c.html)
"""
function recpgr(body, rectan, re, f)
lon = Ref{SpiceDouble}()
lat = Ref{SpiceDouble}()
alt = Ref{SpiceDouble}()
ccall((:recpgr_c, libcspice), Cvoid,
(Cstring, Ptr{SpiceDouble}, SpiceDouble, SpiceDouble, Ref{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}),
body, rectan, re, f, lon, lat, alt)
handleerror()
lon[], lat[], alt[]
end

"""
rotate(angle, iaxis)
Expand Down Expand Up @@ -82,6 +148,8 @@ function recrad(rectan)
range = Ref{SpiceDouble}()
ra = Ref{SpiceDouble}()
dec = Ref{SpiceDouble}()
ccall((:recrad_c, libcspice), Cvoid, (Ptr{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}), rectan, range, ra, dec)
ccall((:recrad_c, libcspice), Cvoid,
(Ptr{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}, Ref{SpiceDouble}),
rectan, range, ra, dec)
range[], ra[], dec[]
end
Loading

0 comments on commit 236a9be

Please sign in to comment.