Skip to content

Commit 641d0f1

Browse files
committed
add in place compute methods.
1 parent f3d740c commit 641d0f1

3 files changed

Lines changed: 235 additions & 16 deletions

File tree

src/compute.jl

Lines changed: 115 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,63 @@ function compute(eph::Ephem,jd0::Float64,time::Float64,
4646
target::Integer,center::Integer)
4747
@_checkPointer eph.data "Ephemeris is not properly initialized!"
4848
result = Array{Float64,1}(undef,6)
49+
stat = unsafe_compute!(result,eph,jd0,time,target,center)
50+
@_checkStatus stat "Unable to compute ephemeris"
51+
return result
52+
end
53+
54+
"""
55+
unsafe_compute!(eph,jd0,time,target,center)
56+
57+
In place version of the compute function. Does not perform any checks!
58+
Compute position and velocity of target with respect to center at epoch
59+
jd0+time. This method does not support the NAIF numbering scheme.
60+
To get the best precision for the interpolation, the time is splitted in two
61+
floating-point numbers. The argument jd0 should be an integer and time should
62+
be a fraction of the day. But you may call this function with time=0 and jd0,
63+
the desired time, if you don't take care about precision.
64+
65+
This method does not support the NAIF body identification scheme.
66+
67+
Output units are:
68+
* AU and AU/day for position and velocity
69+
* rad and rad/day for librations
70+
* second and unitless for time ephemeris and time ephemeris rate
71+
72+
# Arguments
73+
- `result`: container for result. It is not checked if it is sufficiently large enough!
74+
- `jd0::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
75+
- `time::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
76+
- `target::Integer`: The body or reference point whose coordinates are required.
77+
- `center::Integer`: The origin of the coordinate system.
78+
79+
The possible values for target and center are :
80+
* 1 : Mercury Barycenter
81+
* 2 : Venus Barycenter
82+
* 3 : Earth
83+
* 4 : Mars Barycenter
84+
* 5 : Jupiter Barycenter
85+
* 6 : Saturn Barycenter
86+
* 7 : Uranus Barycenter
87+
* 8 : Neptune Barycenter
88+
* 9 : Pluto Barycenter
89+
* 10 : Moon
90+
* 11 : Sun
91+
* 12 : Solar Sytem barycenter
92+
* 13 : Earth-moon barycenter
93+
* 14 : Nutation angles
94+
* 15 : Librations
95+
* 16 : TT-TDB
96+
* 17 : TCG-TCB
97+
* asteroid number + 2000000 : asteroid
98+
99+
"""
100+
function unsafe_compute!(result,eph::Ephem,jd0::Float64,time::Float64,
101+
target::Integer,center::Integer)
49102
stat = ccall((:calceph_compute, libcalceph), Cint,
50103
(Ptr{Cvoid},Cdouble,Cdouble,Cint,Cint,Ref{Cdouble}),
51104
eph.data,jd0,time,target,center,result)
52-
@_checkStatus stat "Unable to compute ephemeris"
53-
return result
105+
return stat
54106
end
55107

56108
"""
@@ -75,11 +127,37 @@ function compute(eph::Ephem,jd0::Float64,time::Float64,
75127
target::Integer,center::Integer,unit::Integer)
76128
@_checkPointer eph.data "Ephemeris is not properly initialized!"
77129
result = Array{Float64,1}(undef,6)
130+
stat = unsafe_compute!(result,eph,jd0,time,target,center,unit)
131+
@_checkStatus stat "Unable to compute ephemeris"
132+
return result
133+
end
134+
135+
"""
136+
unsafe_compute!(result,eph,jd0,time,target,center,unit)
137+
138+
In place version of the compute function. Does not perform any checks!
139+
Compute position and velocity of target with respect to center
140+
at epoch jd0+time.
141+
To get the best precision for the interpolation, the time is splitted in two
142+
floating-point numbers. The argument jd0 should be an integer and time should
143+
be a fraction of the day. But you may call this function with time=0 and jd0,
144+
the desired time, if you don't take care about precision.
145+
146+
# Arguments
147+
- `result`: container for result. It is not checked if it is sufficiently large enough!
148+
- `jd0::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
149+
- `time::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
150+
- `target::Integer`: The body or reference point whose coordinates are required. The numbering system depends on the parameter unit.
151+
- `center::Integer`: The origin of the coordinate system. The numbering system depends on the parameter unit.
152+
- `unit::Integer` : The units of the result. This integer is a sum of some unit constants (unit*) and/or the constant useNaifId. If the unit contains useNaifId, the NAIF identification numbering system is used for the target and the center. If the unit does not contain useNaifId, the old number system is used for the target and the center.
153+
154+
"""
155+
function unsafe_compute!(result,eph::Ephem,jd0::Float64,time::Float64,
156+
target::Integer,center::Integer,unit::Integer)
78157
stat = ccall((:calceph_compute_unit, libcalceph), Cint,
79158
(Ptr{Cvoid},Cdouble,Cdouble,Cint,Cint,Cint,Ref{Cdouble}),
80159
eph.data,jd0,time,target,center,unit,result)
81-
@_checkStatus stat "Unable to compute ephemeris"
82-
return result
160+
return stat
83161
end
84162

85163
"""
@@ -110,9 +188,40 @@ function compute(eph::Ephem,jd0::Float64,time::Float64,
110188
@_checkPointer eph.data "Ephemeris is not properly initialized!"
111189
@_checkOrder order
112190
result = Array{Float64,1}(undef,3+3order)
191+
stat = unsafe_compute!(result,eph,jd0,time,target,center,unit,order)
192+
@_checkStatus stat "Unable to compute ephemeris"
193+
return result
194+
end
195+
196+
"""
197+
unsafe_compute!(result,eph,jd0,time,target,center,unit,order)
198+
199+
In place version of the compute function. Does not perform any checks!
200+
Compute position and derivatives up to order of target with respect to center
201+
at epoch jd0+time.
202+
To get the best precision for the interpolation, the time is splitted in two
203+
floating-point numbers. The argument jd0 should be an integer and time should
204+
be a fraction of the day. But you may call this function with time=0 and jd0,
205+
the desired time, if you don't take care about precision.
206+
207+
# Arguments
208+
- `result`: container for result. It is not checked if it is sufficiently large enough!
209+
- `jd0::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
210+
- `time::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
211+
- `target::Integer`: The body or reference point whose coordinates are required. The numbering system depends on the parameter unit.
212+
- `center::Integer`: The origin of the coordinate system. The numbering system depends on the parameter unit.
213+
- `unit::Integer` : The units of the result. This integer is a sum of some unit constants (unit*) and/or the constant useNaifId. If the unit contains useNaifId, the NAIF identification numbering system is used for the target and the center. If the unit does not contain useNaifId, the old number system is used for the target and the center.
214+
- `order::Integer` : The order of derivatives
215+
* 0: only the position is computed.
216+
* 1: only the position and velocity are computed.
217+
* 2: only the position, velocity and acceleration are computed.
218+
* 3: the position, velocity and acceleration and jerk are computed.
219+
220+
"""
221+
function unsafe_compute!(result,eph::Ephem,jd0::Float64,time::Float64,
222+
target::Integer,center::Integer,unit::Integer,order::Integer)
113223
stat = ccall((:calceph_compute_order, libcalceph), Cint,
114224
(Ptr{Cvoid},Cdouble,Cdouble,Cint,Cint,Cint,Cint,Ref{Cdouble}),
115225
eph.data,jd0,time,target,center,unit,order,result)
116-
@_checkStatus stat "Unable to compute ephemeris"
117-
return result
226+
return stat
118227
end

src/orient.jl

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Compute Euler angles and first derivative for the orientation of target at
55
epoch jd0+time.
6-
To get the best precision for the interpolation, the time is splitted in two
6+
To get the best precision for the interpolation, the time is split in two
77
floating-point numbers. The argument jd0 should be an integer and time should
88
be a fraction of the day. But you may call this function with time=0 and jd0,
99
the desired time, if you don't take care about precision.
@@ -19,19 +19,44 @@ function orient(eph::Ephem,jd0::Float64,time::Float64,
1919
target::Integer,unit::Integer)
2020
@_checkPointer eph.data "Ephemeris is not properly initialized!"
2121
result = Array{Float64,1}(undef,6)
22+
stat = unsafe_orient!(result,eph,jd0,time,target,unit)
23+
@_checkStatus stat "Unable to compute ephemeris"
24+
return result
25+
end
26+
27+
"""
28+
unsafe_orient!(result,eph,jd0,time,target,unit)
29+
30+
In place version of the orient function. Does not perform any checks!
31+
Compute Euler angles and first derivative for the orientation of target
32+
at epoch jd0+time.
33+
To get the best precision for the interpolation, the time is split in two
34+
floating-point numbers. The argument jd0 should be an integer and time should
35+
be a fraction of the day. But you may call this function with time=0 and jd0,
36+
the desired time, if you don't take care about precision.
37+
38+
# Arguments
39+
- `result`: container for result. It is not checked if it is sufficiently large enough!
40+
- `jd0::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
41+
- `time::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
42+
- `target::Integer`: The body whose orientation is required. The numbering system depends on the parameter unit.
43+
- `unit::Integer` : The units of the result. This integer is a sum of some unit constants (unit*) and/or the constant useNaifId. If the unit contains useNaifId, the NAIF identification numbering system is used for the target and the center. If the unit does not contain useNaifId, the old number system is used for the target and the center (see the list in the documentation of function compute). If the unit contains outputNutationAngles, the nutation angles are computed rather than the Euler angles.
44+
45+
"""
46+
function unsafe_orient!(result,eph::Ephem,jd0::Float64,time::Float64,
47+
target::Integer,unit::Integer)
2248
stat = ccall((:calceph_orient_unit, libcalceph), Cint,
2349
(Ptr{Cvoid},Cdouble,Cdouble,Cint,Cint,Ref{Cdouble}),
2450
eph.data,jd0,time,target,unit,result)
25-
@_checkStatus stat "Unable to compute ephemeris"
26-
return result
51+
return stat
2752
end
2853

2954
"""
3055
orient(eph,jd0,time,target,unit,order)
3156
3257
Compute Euler angles and derivatives up to order for the orientation of target
3358
at epoch jd0+time.
34-
To get the best precision for the interpolation, the time is splitted in two
59+
To get the best precision for the interpolation, the time is split in two
3560
floating-point numbers. The argument jd0 should be an integer and time should
3661
be a fraction of the day. But you may call this function with time=0 and jd0,
3762
the desired time, if you don't take care about precision.
@@ -53,9 +78,39 @@ function orient(eph::Ephem,jd0::Float64,time::Float64,
5378
@_checkPointer eph.data "Ephemeris is not properly initialized!"
5479
@_checkOrder order
5580
result = Array{Float64,1}(undef,3+3order)
81+
stat = unsafe_orient!(result,eph,jd0,time,target,unit,order)
82+
@_checkStatus stat "Unable to compute ephemeris"
83+
return result
84+
end
85+
86+
"""
87+
unsafe_orient!(result,eph,jd0,time,target,unit,order)
88+
89+
In place version of the orient function. Does not perform any checks!
90+
Compute Euler angles and derivatives up to order for the orientation of target
91+
at epoch jd0+time.
92+
To get the best precision for the interpolation, the time is split in two
93+
floating-point numbers. The argument jd0 should be an integer and time should
94+
be a fraction of the day. But you may call this function with time=0 and jd0,
95+
the desired time, if you don't take care about precision.
96+
97+
# Arguments
98+
- `result`: container for result. It is not checked if it is sufficiently large enough!
99+
- `jd0::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
100+
- `time::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
101+
- `target::Integer`: The body whose orientation is required. The numbering system depends on the parameter unit.
102+
- `unit::Integer` : The units of the result. This integer is a sum of some unit constants (unit*) and/or the constant useNaifId. If the unit contains useNaifId, the NAIF identification numbering system is used for the target and the center. If the unit does not contain useNaifId, the old number system is used for the target and the center (see the list in the documentation of function compute). If the unit contains outputNutationAngles, the nutation angles are computed rather than the Euler angles.
103+
- `order::Integer` : The order of derivatives
104+
* 0: only the angles are computed.
105+
* 1: only the angles and 1st derivatives are computed.
106+
* 2: only the angles, the 1st derivatives and 2nd derivatives are computed.
107+
* 3: the angles, the 1st derivatives, 2nd derivatives and 3rd derivatives are computed.
108+
109+
"""
110+
function unsafe_orient!(result,eph::Ephem,jd0::Float64,time::Float64,
111+
target::Integer,unit::Integer,order::Integer)
56112
stat = ccall((:calceph_orient_order, libcalceph), Cint,
57113
(Ptr{Cvoid},Cdouble,Cdouble,Cint,Cint,Cint,Ref{Cdouble}),
58114
eph.data,jd0,time,target,unit,order,result)
59-
@_checkStatus stat "Unable to compute ephemeris"
60-
return result
115+
return stat
61116
end

src/rotAngMom.jl

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,36 @@ function rotAngMom(eph::Ephem,jd0::Float64,time::Float64,
1919
target::Integer,unit::Integer)
2020
@_checkPointer eph.data "Ephemeris is not properly initialized!"
2121
result = Array{Float64,1}(undef,6)
22+
stat = unsafe_rotAngMom!(result,eph,jd0,time,target,unit)
23+
@_checkStatus stat "Unable to compute ephemeris"
24+
return result
25+
end
26+
27+
"""
28+
unsafe_rotAngMom!(result,eph,jd0,time,target,unit)
29+
30+
In place version of the rotAngMom function. Does not perform any checks!
31+
Compute angular momentum due to rotation and first derivative of target at
32+
epoch jd0+time.
33+
To get the best precision for the interpolation, the time is splitted in two
34+
floating-point numbers. The argument jd0 should be an integer and time should
35+
be a fraction of the day. But you may call this function with time=0 and jd0,
36+
the desired time, if you don't take care about precision.
37+
38+
# Arguments
39+
- `result`: container for result. It is not checked if it is sufficiently large enough!
40+
- `jd0::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
41+
- `time::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
42+
- `target::Integer`: The body whose angular momentum is required. The numbering system depends on the parameter unit.
43+
- `unit::Integer` : The units of the result. This integer is a sum of some unit constants (unit*) and/or the constant useNaifId. If the unit contains useNaifId, the NAIF identification numbering system is used for the target and the center. If the unit does not contain useNaifId, the old number system is used for the target and the center (see the list in the documentation of function compute). The angles are expressed in radians if unit contains unitRad.
44+
45+
"""
46+
function unsafe_rotAngMom!(result,eph::Ephem,jd0::Float64,time::Float64,
47+
target::Integer,unit::Integer)
2248
stat = ccall((:calceph_rotangmom_unit, libcalceph), Cint,
2349
(Ptr{Cvoid},Cdouble,Cdouble,Cint,Cint,Ref{Cdouble}),
2450
eph.data,jd0,time,target,unit,result)
25-
@_checkStatus stat "Unable to compute ephemeris"
26-
return result
51+
return stat
2752
end
2853

2954
"""
@@ -53,9 +78,39 @@ function rotAngMom(eph::Ephem,jd0::Float64,time::Float64,
5378
@_checkPointer eph.data "Ephemeris is not properly initialized!"
5479
@_checkOrder order
5580
result = Array{Float64,1}(undef,3+3order)
81+
stat = unsafe_rotAngMom!(result,eph,jd0,time,target,unit,order)
82+
@_checkStatus stat "Unable to compute ephemeris"
83+
return result
84+
end
85+
86+
"""
87+
unsafe_rotAngMom!(result,eph,jd0,time,target,unit,order)
88+
89+
In place version of the rotAngMom function. Does not perform any checks!
90+
Compute angular momentum due to rotation and derivatives up to order of target
91+
at epoch jd0+time.
92+
To get the best precision for the interpolation, the time is splitted in two
93+
floating-point numbers. The argument jd0 should be an integer and time should
94+
be a fraction of the day. But you may call this function with time=0 and jd0,
95+
the desired time, if you don't take care about precision.
96+
97+
# Arguments
98+
- `result`: container for result. It is not checked if it is sufficiently large enough!
99+
- `jd0::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
100+
- `time::Float64`: jd0+time must be equal to the Julian Day for the time coordinate corresponding to the ephemeris (usually TDB or TCB)
101+
- `target::Integer`: The body whose angular momentum is required. The numbering system depends on the parameter unit.
102+
- `unit::Integer` : The units of the result. This integer is a sum of some unit constants (unit*) and/or the constant useNaifId. If the unit contains useNaifId, the NAIF identification numbering system is used for the target and the center. If the unit does not contain useNaifId, the old number system is used for the target and the center (see the list in the documentation of function compute).
103+
- `order::Integer` : The order of derivatives
104+
* 0: only the angles are computed.
105+
* 1: only the angles and 1st derivatives are computed.
106+
* 2: only the angles, the 1st derivatives and 2nd derivatives are computed.
107+
* 3: the angles, the 1st derivatives, 2nd derivatives and 3rd derivatives are computed.
108+
109+
"""
110+
function unsafe_rotAngMom!(result,eph::Ephem,jd0::Float64,time::Float64,
111+
target::Integer,unit::Integer,order::Integer)
56112
stat = ccall((:calceph_rotangmom_order, libcalceph), Cint,
57113
(Ptr{Cvoid},Cdouble,Cdouble,Cint,Cint,Cint,Ref{Cdouble}),
58114
eph.data,jd0,time,target,unit,order,result)
59-
@_checkStatus stat "Unable to compute ephemeris"
60-
return result
115+
return stat
61116
end

0 commit comments

Comments
 (0)