1 /*
2 
3 -Procedure spkw05_c ( Write SPK segment, type 5 )
4 
5 -Abstract
6 
7    Write an SPK segment of type 5 given a time-ordered set of
8    discrete states and epochs, and the gravitational parameter
9    of a central body.
10 
11 -Disclaimer
12 
13    THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
14    CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
15    GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
16    ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
17    PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
18    TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
19    WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
20    PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
21    SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
22    SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
23 
24    IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
25    BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
26    LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
27    INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
28    REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
29    REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
30 
31    RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
32    THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
33    CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
34    ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
35 
36 -Required_Reading
37 
38    SPK
39    SPC
40    NAIF_IDS
41 
42 -Keywords
43 
44    EPHEMERIS
45 
46 */
47    #include <string.h>
48    #include "SpiceUsr.h"
49    #include "SpiceZfc.h"
50    #include "SpiceZmc.h"
51    #undef    spkw05_c
52 
53 
spkw05_c(SpiceInt handle,SpiceInt body,SpiceInt center,ConstSpiceChar * frame,SpiceDouble first,SpiceDouble last,ConstSpiceChar * segid,SpiceDouble gm,SpiceInt n,ConstSpiceDouble states[][6],ConstSpiceDouble epochs[])54    void spkw05_c ( SpiceInt                handle,
55                    SpiceInt                body,
56                    SpiceInt                center,
57                    ConstSpiceChar        * frame,
58                    SpiceDouble             first,
59                    SpiceDouble             last,
60                    ConstSpiceChar        * segid,
61                    SpiceDouble             gm,
62                    SpiceInt                n,
63                    ConstSpiceDouble        states [][6],
64                    ConstSpiceDouble        epochs []      )
65 /*
66 
67 -Brief_I/O
68 
69    Variable  I/O  Description
70    --------  ---  --------------------------------------------------
71    handle     I   Handle of an SPK file open for writing.
72    body       I   Body code for ephemeris object.
73    center     I   Body code for the center of motion of the body.
74    frame      I   The reference frame of the states.
75    first      I   First valid time for which states can be computed.
76    last       I   Last valid time for which states can be computed.
77    segid      I   Segment identifier.
78    gm         I   Gravitational parameter of central body.
79    n          I   Number of states and epochs.
80    states     I   States.
81    epochs     I   Epochs.
82 
83 -Detailed_Input
84 
85    handle      is the file handle of an SPK file that has been
86                opened for writing.
87 
88    body        is the NAIF ID for the body whose states are
89                to be recorded in an SPK file.
90 
91    center      is the NAIF ID for the center of motion associated
92                with BODY.
93 
94    frame       is the reference frame that states are referenced to,
95                for example "J2000".
96 
97    first       are the bounds on the ephemeris times, expressed as
98    last        seconds past J2000, for which the states can be used
99                to interpolate a state for BODY.
100 
101    segid       is the segment identifier. An SPK segment identifier
102                may contain up to 40 characters.
103 
104    gm          is the gravitational parameter of the central body
105                ( in units of kilometers **3 / seconds **2 ).
106 
107    n           is the number of states and epochs to be stored
108                in the segment.
109 
110    states      contains a time-ordered array of geometric states
111                ( x, y, z, dx/dt, dy/dt, dz/dt, in kilometers and
112                kilometers per second ) of the target body with
113                respect to the central body specified in the segment
114                descriptor.
115 
116    epochs      contains the epochs (ephemeris seconds past J2000)
117                corresponding to the states in states.  Epochs must
118                form a strictly increasing sequence.
119 
120 -Detailed_Output
121 
122    None.  A type 5 segment is written to the file attached to handle.
123 
124 -Parameters
125 
126    None.
127 
128 -Exceptions
129 
130    1) If the input epochs do not form an increasing sequence, the
131       error SPICE(UNORDEREDTIMES) will be signaled.
132 
133    2) If the number of states and epochs is not positive then the
134       error SPICE(NUMSTATESNOTPOS) will be signaled.
135 
136    3) If FIRST is greater than LAST then the error
137       SPICE(BADDESCRTIMES) will be signaled.
138 
139    4) If SEGID is more than 40 characters long, the error
140       SPICE(SEGIDTOOLONG) is signaled.
141 
142    5) If SEGID contains any nonprintable characters, the error
143       SPICE(NONPRINTABLECHARS) is signaled.
144 
145    6) Any file I/O problems will be detected and diagnosed by one
146       of the DAF routines called by this routine.
147 
148    7) The error SPICE(EMPTYSTRING) is signaled if either input
149       string does not contain at least one character, since the
150       input strings cannot be converted to a Fortran-style string
151       in this case.
152 
153    8) The error SPICE(NULLPOINTER) is signaled if either input string
154       pointer is null.
155 
156 -Files
157 
158    A new type 05 SPK segment is written to the SPK file attached
159    to handle.
160 
161 -Particulars
162 
163    This routine writes an SPK type 05 data segment to the open SPK
164    file according to the format described in the type 05 section of
165    the SPK Required Reading. The SPK file must have been opened with
166    write access.
167 
168 -Examples
169 
170    Suppose that you have states and are prepared to produce
171    a segment of type 05 in an SPK file.
172 
173    The following code fragment could be used to add the new segment
174    to a previously opened SPK file attached to handle. The file must
175    have been opened with write access.
176 
177       #include "SpiceUsr.h"
178              .
179              .
180              .
181       /.
182       Create a segment identifier.
183       ./
184       ConstSpiceChar  * segid = "MY_SAMPLE_SPK_TYPE_5_SEGMENT";
185 
186       /.
187       Write the segment.
188       ./
189       spkw05_c ( SpiceInt                handle,
190                  SpiceInt                body,
191                  SpiceInt                center,
192                  ConstSpiceChar        * frame,
193                  SpiceDouble             first,
194                  SpiceDouble             last,
195                  ConstSpiceChar        * segid,
196                  SpiceDouble             gm,
197                  SpiceInt                n,
198                  SpiceDouble             states,
199                  SpiceDouble             epochs  );
200 
201 -Restrictions
202 
203    None.
204 
205 -Literature_References
206 
207    None.
208 
209 -Author_and_Institution
210 
211    N.J. Bachman    (JPL)
212    K.R. Gehringer  (JPL)
213    J.M. Lynch      (JPL)
214    W.L. Taber      (JPL)
215    I.M. Underwood  (JPL)
216 
217 -Version
218 
219    -CSPICE Version 1.0.0, 23-JUN-1999 (NJB)(KRG)(JML)(WLT)(IMU)
220 
221 -Index_Entries
222 
223    write spk type_5 ephemeris data segment
224 
225 -&
226 */
227 
228 { /* Begin spkw05_c */
229 
230 
231 
232    /*
233    Participate in error tracing.
234    */
235    chkin_c ( "spkw05_c" );
236 
237 
238    /*
239    Check the input strings to make sure the pointers
240    are non-null and the string lengths are non-zero.
241    */
242    CHKFSTR ( CHK_STANDARD, "spkw05_c", frame );
243    CHKFSTR ( CHK_STANDARD, "spkw05_c", segid );
244 
245 
246    /*
247    Write the segment.  Note that the state array DOES NOT require
248    transposition!
249    */
250 
251    spkw05_ ( ( integer    * ) &handle,
252              ( integer    * ) &body,
253              ( integer    * ) &center,
254              ( char       * ) frame,
255              ( doublereal * ) &first,
256              ( doublereal * ) &last,
257              ( char       * ) segid,
258              ( doublereal * ) &gm,
259              ( integer    * ) &n,
260              ( doublereal * ) states,
261              ( doublereal * ) epochs,
262              ( ftnlen       ) strlen(frame),
263              ( ftnlen       ) strlen(segid)  );
264 
265    chkout_c ( "spkw05_c" );
266 
267 } /* End spkw05_c */
268