1 /* sct2e.f -- translated by f2c (version 19980913).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
8 /* $Procedure SCT2E ( SCLK ticks to ET ) */
sct2e_(integer * sc,doublereal * sclkdp,doublereal * et)9 /* Subroutine */ int sct2e_(integer *sc, doublereal *sclkdp, doublereal *et)
10 {
11 /* System generated locals */
12 integer i__1;
13
14 /* Local variables */
15 extern /* Subroutine */ int chkin_(char *, ftnlen), scte01_(integer *,
16 doublereal *, doublereal *), sigerr_(char *, ftnlen), chkout_(
17 char *, ftnlen), setmsg_(char *, ftnlen), errint_(char *, integer
18 *, ftnlen);
19 extern integer sctype_(integer *);
20 extern logical return_(void);
21
22 /* $ Abstract */
23
24 /* Convert encoded spacecraft clock (`ticks') to ephemeris */
25 /* seconds past J2000 (ET). */
26
27 /* $ Disclaimer */
28
29 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
30 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
31 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
32 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
33 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
34 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
35 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
36 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
37 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
38 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
39
40 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
41 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
42 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
43 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
44 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
45 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
46
47 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
48 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
49 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
50 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
51
52 /* $ Required_Reading */
53
54 /* SCLK */
55 /* TIME */
56
57 /* $ Keywords */
58
59 /* CONVERSION */
60 /* TIME */
61
62 /* $ Declarations */
63 /* $ Brief_I/O */
64
65 /* Variable I/O Description */
66 /* -------- --- -------------------------------------------------- */
67 /* SC I NAIF spacecraft ID code. */
68 /* SCLKDP I SCLK, encoded as ticks since spacecraft clock */
69 /* start. */
70 /* ET O Ephemeris time, seconds past J2000. */
71
72 /* $ Detailed_Input */
73
74 /* SC is a NAIF integer code for a spacecraft, one of */
75 /* whose encoded clock values is represented by */
76 /* SCLKDP. */
77
78 /* SCLKDP is an encoded spacecraft clock value. SCLKDP */
79 /* represents time measured from spacecraft clock */
80 /* start: partition information IS reflected in the */
81 /* encoded value. */
82
83 /* $ Detailed_Output */
84
85 /* ET is the epoch, specified as ephemeris seconds past */
86 /* J2000, that corresponds to SCLKDP. */
87
88 /* $ Parameters */
89
90 /* None. */
91
92 /* $ Exceptions */
93
94 /* 1) This routine assumes that that an SCLK kernel appropriate */
95 /* to the spacecraft clock identified by the input argument SC */
96 /* has been loaded. If an SCLK kernel has not been loaded, */
97 /* does not contain all of the required data, or contains */
98 /* invalid data, error diagnoses will be performed by routines */
99 /* called by this routine. The output argument ET will not be */
100 /* modified. */
101
102 /* 2) When using SCLK kernels that map SCLK to a time system other */
103 /* than ET (also called barycentric dynamical time---`TDB'), it */
104 /* is necessary to have a leapseconds kernel loaded at the time */
105 /* this routine is called. If a leapseconds kernel is required */
106 /* for conversion between SCLK and ET but is not loaded, the */
107 /* error will be diagnosed by routines called by this routine. */
108 /* The output argument ET will not be modified. */
109
110 /* The time system that an SCLK kernel maps SCLK to is indicated */
111 /* by the variable SCLK_TIME_SYSTEM_nn in the kernel, where nn */
112 /* is the negative of the NAIF integer code for the spacecraft. */
113 /* The time system used in a kernel is TDB if and only if the */
114 /* variable is assigned the value 1. */
115
116
117 /* 3) If the clock type for the spacecraft clock identified by */
118 /* SC is not supported by this routine, the error */
119 /* SPICE(NOTSUPPORTED) is signalled. The output argument ET */
120 /* will not be modified. */
121
122 /* 4) If the input argument SCLKDP is invalid, the error will be */
123 /* diagnosed by routines called by this routine. The output */
124 /* argument ET will not be modified. */
125
126 /* $ Files */
127
128 /* None. */
129
130 /* $ Particulars */
131
132 /* This routine operates on encoded SCLK values. These values */
133 /* are obtained by calling the SPICELIB routine SCENCD or other */
134 /* SCLK conversion routines. The advantage of encoded SCLK, as */
135 /* opposed to character string representations of SCLK is that */
136 /* encoded SCLK values are easy to perform arithmetic operations on. */
137 /* Additionally, working with encoded SCLK reduces the overhead of */
138 /* repeated conversion of character strings to integers or double */
139 /* precision numbers. */
140
141 /* To convert a string representation of an SCLK value to ET, use */
142 /* the SPICELIB routine SCS2E. */
143
144 /* See the SCLK Required Reading for a list of the entire set of */
145 /* SCLK conversion routines. */
146
147 /* $ Examples */
148
149 /* 1) Encode a Galileo SCLK string, and convert the encoded value */
150 /* to ET; use these time values to look up both GLL orbiter */
151 /* scan platform's pointing and the GLL--Earth state vector */
152 /* for an epoch specified by an SCLK string. */
153
154 /* During program initialization, load the leapseconds and */
155 /* SCLK kernels. We will pretend that these files are named */
156 /* "LEAPSECONDS.KER" and "GLLSCLK.KER". To use this code */
157 /* fragment, you must substitute the actual names of these */
158 /* kernel files for the names used here. */
159
160 /* C */
161 /* C Load leapseconds and SCLK kernels: */
162 /* C */
163 /* CALL FURNSH ( 'LEAPSECONDS.KER' ) */
164 /* CALL FURNSH ( 'SCLK.KER' ) */
165
166 /* The mission is Galileo, which has spacecraft ID -77. */
167 /* Let's assume that the SCLK string is */
168
169 /* 1 / 1900000:00:00 */
170
171 /* The number 1, followed by a slash, indicates that the */
172 /* epoch is in the first partition. */
173
174 /* The next step is to encode this SCLK string, and also */
175 /* find the corresponding ET value: */
176
177 /* CALL SCENCD ( -77, '1/ 1900000:00:00', SCLKDP ) */
178 /* CALL SCT2E ( -77, SCLKDP, ET ) */
179
180 /* We'll assume that you've already loaded SPK and CK files */
181 /* containing ephemeris data for the GLL orbiter and the */
182 /* Earth, as well as scan platform pointing. Now you're */
183 /* ready to call both CKGP, which expects the input epoch to */
184 /* be specified by an encoded SCLK string, and SPKEZ, which */
185 /* expects the epoch to be specified as an ephemeris time. */
186
187 /* C */
188 /* C Find scan platform pointing CMAT and s/c--target */
189 /* C vector (first 3 components of STATE) at epoch. */
190 /* C We assume that CK and SPK kernels have been loaded */
191 /* C already, via CKLPF and SPKLEF respectively. */
192 /* C */
193 /* SCANPL = -77001 */
194 /* EARTH = 399 */
195
196 /* CALL CKGP ( SCANPL, */
197 /* . SCLKDP, */
198 /* . TOL, */
199 /* . REFSYS, */
200 /* . CMAT, */
201 /* . CLKOUT, */
202 /* . FOUND ) */
203
204 /* IF ( .NOT. FOUND ) THEN */
205
206 /* [ Indicate to user that pointing was not */
207 /* available ] */
208
209 /* END IF */
210
211
212 /* CALL SPKEZ ( EARTH, */
213 /* . ET, */
214 /* . REFSYS, */
215 /* . CORR, */
216 /* . -77, */
217 /* . STATE, */
218 /* . LT ) */
219
220
221
222 /* 2) Convert an encoded Voyager 2 SCLK value to UTC, using calendar */
223 /* format, with 3 digits of precision. */
224
225 /* Again, your initialization code must load the leapseconds */
226 /* and SCLK kernels: */
227
228 /* C */
229 /* C Load leapseconds and SCLK kernels: */
230 /* C */
231 /* CALL FURNSH ( 'LEAPSECONDS.KER' ) */
232 /* CALL FURNSH ( 'VGR2SCLK.KER' ) */
233
234
235 /* To find the UTC value corresponding to the encoded */
236 /* Voyager 2 SCLK value SCLKDP, you can use the code fragment */
237
238 /* CALL SCT2E ( -32, SCLKDP, ET ) */
239 /* CALL ET2UTC ( ET, 'C', 3, UTC ) */
240
241 /* $ Restrictions */
242
243 /* 1) An SCLK kernel appropriate to the spacecraft clock identified */
244 /* by SC must be loaded at the time this routine is called. */
245
246 /* 2) If the SCLK kernel used with this routine does not map SCLK */
247 /* directly to barycentric dynamical time, a leapseconds kernel */
248 /* must be loaded at the time this routine is called. */
249
250 /* $ Literature_References */
251
252 /* [1] CK Required Reading */
253
254 /* [2] SPK Required Reading */
255
256 /* $ Author_and_Institution */
257
258 /* N.J. Bachman (JPL) */
259
260 /* $ Version */
261
262 /* - SPICELIB Version 1.0.4, 22-AUG-2006 (EDW) */
263
264 /* Replaced references to LDPOOL with references */
265 /* to FURNSH. */
266
267 /* - SPICELIB Version 1.0.3, 09-MAR-1999 (NJB) */
268
269 /* Explicit list of SCLK conversion routines in Particulars */
270 /* section has been replaced by a pointer to the SCLK Required */
271 /* Reading. */
272
273 /* - SPICELIB Version 1.0.2, 10-APR-1992 (NJB) (WLT) */
274
275 /* The $Brief_I/O section now lists ET correctly as an output */
276 /* from this routine. Header was updated to reflect possibility */
277 /* of needing to load a leapseconds kernel before calling this */
278 /* routine. Comment section for permuted index source lines was */
279 /* added following the header. */
280
281 /* - SPICELIB Version 1.0.1, 12-OCT-1990 (NJB) */
282
283 /* Restrictions section no longer states that you must load the */
284 /* leapseconds kernel prior to calling this routine. */
285
286 /* The examples have been slightly re-written. */
287
288 /* - SPICELIB Version 1.0.0, 03-SEP-1990 (NJB) */
289
290 /* -& */
291 /* $ Index_Entries */
292
293 /* spacecraft_clock ticks to ephemeris time */
294
295 /* -& */
296 /* $ Revisions */
297
298 /* - SPICELIB Version 1.0.1, 12-OCT-1990 (NJB) */
299
300 /* Restrictions section no longer states that you must load the */
301 /* leapseconds kernel prior to calling this routine. */
302
303 /* The examples have been slightly re-written. In particular, */
304 /* they no longer use calls to CLPOOL. */
305
306 /* -& */
307
308 /* SPICELIB functions */
309
310
311 /* Standard SPICE error handling. */
312
313 if (return_()) {
314 return 0;
315 } else {
316 chkin_("SCT2E", (ftnlen)5);
317 }
318
319 /* Just hand off the conversion to the appropriate routine. */
320
321 if (sctype_(sc) == 1) {
322 scte01_(sc, sclkdp, et);
323 } else {
324 setmsg_("Clock type # is not supported.", (ftnlen)30);
325 i__1 = sctype_(sc);
326 errint_("#", &i__1, (ftnlen)1);
327 sigerr_("SPICE(NOTSUPPORTED)", (ftnlen)19);
328 chkout_("SCT2E", (ftnlen)5);
329 return 0;
330 }
331 chkout_("SCT2E", (ftnlen)5);
332 return 0;
333 } /* sct2e_ */
334
335