1 /* 2 3 -Procedure sct2e_c ( SCLK ticks to ET ) 4 5 -Abstract 6 7 Convert encoded spacecraft clock (`ticks') to ephemeris 8 seconds past J2000 (ET). 9 10 -Disclaimer 11 12 THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE 13 CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. 14 GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE 15 ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE 16 PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" 17 TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY 18 WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A 19 PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC 20 SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 21 SOFTWARE AND RELATED MATERIALS, HOWEVER USED. 22 23 IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA 24 BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT 25 LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, 26 INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, 27 REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE 28 REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. 29 30 RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF 31 THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY 32 CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE 33 ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. 34 35 -Required_Reading 36 37 SCLK 38 TIME 39 40 -Keywords 41 42 CONVERSION 43 TIME 44 45 */ 46 47 #include "SpiceUsr.h" 48 #include "SpiceZfc.h" 49 sct2e_c(SpiceInt sc,SpiceDouble sclkdp,SpiceDouble * et)50 void sct2e_c ( SpiceInt sc, 51 SpiceDouble sclkdp, 52 SpiceDouble * et ) 53 /* 54 55 -Brief_I/O 56 57 Variable I/O Description 58 -------- --- -------------------------------------------------- 59 sc I NAIF spacecraft ID code. 60 sclkdp I SCLK, encoded as ticks since spacecraft clock 61 start. 62 et O Ephemeris time, seconds past J2000. 63 64 -Detailed_Input 65 66 sc is a NAIF integer code for a spacecraft, one of 67 whose encoded clock values is represented by 68 sclkdp. 69 70 sclkdp is an encoded spacecraft clock value. sclkdp 71 represents time measured from spacecraft clock 72 start: partition information IS reflected in the 73 encoded value. 74 75 -Detailed_Output 76 77 et is the epoch, specified as ephemeris seconds past 78 J2000, that corresponds to sclkdp. 79 80 -Parameters 81 82 None. 83 84 -Exceptions 85 86 1) This routine assumes that that an SCLK kernel appropriate 87 to the spacecraft clock identified by the input argument sc 88 has been loaded. If an SCLK kernel has not been loaded, 89 does not contain all of the required data, or contains 90 invalid data, error diagnoses will be performed by routines 91 called by this routine. The output argument et will not be 92 modified. 93 94 2) When using SCLK kernels that map SCLK to a time system other 95 than ET (also called barycentric dynamical time---`TDB'), it 96 is necessary to have a leapseconds kernel loaded at the time 97 this routine is called. If a leapseconds kernel is required 98 for conversion between SCLK and ET but is not loaded, the 99 error will be diagnosed by routines called by this routine. 100 The output argument et will not be modified. 101 102 The time system that an SCLK kernel maps SCLK to is indicated 103 by the variable SCLK_TIME_SYSTEM_nn in the kernel, where nn 104 is the negative of the NAIF integer code for the spacecraft. 105 The time system used in a kernel is TDB if and only if the 106 variable is assigned the value 1. 107 108 109 3) If the clock type for the spacecraft clock identified by 110 sc is not supported by this routine, the error 111 SPICE(NOTSUPPORTED) is signalled. The output argument et 112 will not be modified. 113 114 4) If the input argument sclkdp is invalid, the error will be 115 diagnosed by routines called by this routine. The output 116 argument et will not be modified. 117 118 -Files 119 120 None. 121 122 -Particulars 123 124 This routine operates on encoded SCLK values. These values 125 are obtained by calling the CSPICE routine scencd_c or other 126 SCLK conversion routines. The advantage of encoded SCLK, as 127 opposed to character string representations of SCLK is that 128 encoded SCLK values are easy to perform arithmetic operations on. 129 Additionally, working with encoded SCLK reduces the overhead of 130 repeated conversion of character strings to integers or double 131 precision numbers. 132 133 To convert a string representation of an SCLK value to ET, use 134 the CSPICE routine scs2e_c. 135 136 -Examples 137 138 1) Encode a Galileo SCLK string, and convert the encoded value 139 to ET; use these time values to look up both GLL orbiter 140 scan platform's pointing and the GLL--Earth state vector 141 for an epoch specified by an SCLK string. 142 143 During program initialization, load the leapseconds and 144 SCLK kernels. We will pretend that these files are named 145 "leapseconds.ker" and "gllsclk.ker". To use this code 146 fragment, you must substitute the actual names of these 147 kernel files for the names used here. 148 149 /. 150 load leapseconds and sclk kernels: 151 ./ 152 furnsh_c ( "leapseconds.ker" ); 153 furnsh_c ( "gllsclk.ker" ); 154 155 /. 156 The mission is Galileo, which has spacecraft ID -77. 157 Let's assume that the SCLK string is 158 159 1 / 1900000:00:00 160 161 The number 1, followed by a slash, indicates that the 162 epoch is in the first partition. 163 164 The next step is to encode this SCLK string, and also 165 find the corresponding ET value: 166 ./ 167 168 scencd_c ( -77, "1/ 1900000:00:00", &sclkdp ); 169 sct2e_c ( -77, sclkdp, &et ); 170 171 172 We'll assume that you've already loaded SPK and CK files 173 containing ephemeris data for the GLL orbiter and the 174 Earth, as well as scan platform pointing. Now you're 175 ready to call both ckgp_c, which expects the input epoch to 176 be specified by an encoded SCLK string, and spkez_c, which 177 expects the epoch to be specified as an ephemeris time. 178 179 /. 180 Find scan platform pointing cmat and s/c--target 181 vector (first 3 components of state) at epoch. 182 We assume that CK and SPK kernels have been loaded 183 already, via cklpf_c and spklef_c respectively. 184 185 Use tolerance of 80 ticks for the CK look-up. 186 ./ 187 scanpl = -77001; 188 earth = 399; 189 tol = 80.0; 190 191 ckgp_c ( scanpl, sclkdp, tol, refsys, 192 cmat, &clkout, &found ); 193 194 if ( !found ) 195 { 196 [ Indicate to user that pointing was not 197 available ] 198 } 199 200 spkez_c ( earth, et, refsys, corr, 201 -77, state, < ); 202 203 204 205 2) Convert an encoded Voyager 2 SCLK value to UTC, using calendar 206 format, with 3 digits of precision. 207 208 Again, your initialization code must load the leapseconds 209 and SCLK kernels: 210 211 /. 212 load leapseconds and SCLK kernels: 213 ./ 214 furnsh_c ( "leapseconds.ker" ); 215 furnsh_c ( "vgr2sclk.ker" ); 216 217 218 To find the UTC value corresponding to the encoded 219 Voyager 2 SCLK value sclkdp, you can use the code fragment 220 221 sct2e_c ( -32, sclkdp, &et ); 222 et2utc_c ( et, "c", 3, UTCLEN, utc ); 223 224 where UTCLEN is a constant indicating the available 225 room in the string utc. A value of 25 characters suffices. 226 227 228 -Restrictions 229 230 1) An SCLK kernel appropriate to the spacecraft clock identified 231 by SC must be loaded at the time this routine is called. 232 233 2) If the SCLK kernel used with this routine does not map SCLK 234 directly to barycentric dynamical time, a leapseconds kernel 235 must be loaded at the time this routine is called. 236 237 -Literature_References 238 239 [1] CK Required Reading 240 241 [2] SPK Required Reading 242 243 -Author_and_Institution 244 245 N.J. Bachman (JPL) 246 247 -Version 248 249 -CSPICE Version 1.0.1, 14-AUG-2006 (EDW) 250 251 Replace mention of ldpool_c with furnsh_c. 252 253 -CSPICE Version 1.0.0, 08-FEB-1998 (NJB) 254 255 Based on SPICELIB Version 1.0.2, 10-APR-1992 (NJB) (WLT) 256 257 -Index_Entries 258 259 spacecraft_clock ticks to ephemeris time 260 261 -& 262 */ 263 264 { /* Begin sct2e_c */ 265 266 267 /* 268 Local variables 269 */ 270 SpiceDouble loc_et; 271 272 273 /* 274 Participate in error handling 275 */ 276 chkin_c ( "sct2e_c"); 277 278 279 /* 280 Carry out the conversion. 281 */ 282 sct2e_ ( ( integer * ) &sc, 283 ( doublereal * ) &sclkdp, 284 ( doublereal * ) &loc_et ); 285 286 /* 287 Assign the output argument. 288 */ 289 *et = loc_et; 290 291 292 chkout_c ( "sct2e_c"); 293 294 295 } /* End sct2e_c */ 296