; ;$Header: /cassini2/uvis_fm/daps_tools/RCS/convert_sclk.pro,v 1.9 2005/07/11 15:28:18 uvis_fm Exp uvis_fm $ ; pro cg_convert_sclk, sclk_input, mill_input, scet ; ; History ; Original version aj 10/99 ; - Use SCLKSCET.0041 ; - Use SCLKSCET.0043 10/22/99 ; - Use SCLKSCET.0048 06/05/00 ; - Use SCLKSCET.0053 11/10/00 ; - Use SCLKSCET.0061 11/02/01 ; - Use SCLKSCET.0083 06/24/03 ; - Use SCLKSCET.0084 01/02/04 ; - Use SCLKSCET.0085 08/30/04 ; - Use SCLKSCET.0087 12/14/04 ; - Use SCLKSCET.0091 07/11/05 IF N_PARAMS() LE 0 THEN BEGIN PRINT, ' To convert from spacecraft clock (sclk) to' PRINT, ' spacecraft event time (scet) enter the following ' PRINT, ' at the IDL prompt:' PRINT, ' convert_sclk, sclk_second, sclk_millisecond, scet' PRINT, ' where sclk_second is the spacecraft second and' PRINT, ' sclk_millisecond the millisecond value derived from' PRINT, ' the fractional portion of the sclk' PRINT, ' The DAPS routine returns the sclk in second and millisecond' PRINT, ' (see sctime_sec_start and sctime_ms_start)' PRINT, ' In the CCSDS header the time is returned as second and' PRINT, ' a fractional part (milliseconds = fractional part * 3.096)' PRINT, ' The scet is returned as UTC time in the parameter scet, in' PRINT, ' in structure of the following form:' PRINT, 'scet = { scet_dp, $' PRINT, ' year: long(0), $' PRINT, ' doy : long(0), $' PRINT, ' hour: long(0), $' PRINT, ' min : long(0), $' PRINT, ' sec : double(0.0)}' RETURN ENDIF ; declare variables sclk0 = long(0) fract0= long(0) scet0 = strarr(21) year0 = long(0) doy0 = long(0) hour0 = long(0) min0 = long(0) sec0 = double(0.0) rate0 = double(0.0) sclk1 = long(0) fract1= long(0) scet1 = strarr(21) year1 = long(0) doy1 = long(0) hour1 = long(0) min1 = long(0) sec1 = double(0.0) rate1 = double(0.0) timesec = double(0.0) scet = { scet_dp, $ year: long(0), $ doy : long(0), $ hour: long(0), $ min : long(0), $ sec : double(0.0)} find = 0 ; derived from SCLKSCET.00061 released 2001-298 conversion_string = [ $ ' 694224018.000 1980-001T00:00:00.000 50.184 0.000000000', $ ' 694224019.000 1980-001T00:00:00.000 51.184 1.000000000', $ ' 741484819.000 1981-182T00:00:00.000 51.184 0.000000000', $ ' 741484820.000 1981-182T00:00:00.000 52.184 1.000000000', $ ' 773020820.000 1982-182T00:00:00.000 52.184 0.000000000', $ ' 773020821.000 1982-182T00:00:00.000 53.184 1.000000000', $ ' 804556821.000 1983-182T00:00:00.000 53.184 0.000000000', $ ' 804556822.000 1983-182T00:00:00.000 54.184 1.000000000', $ ' 867715222.000 1985-182T00:00:00.000 54.184 0.000000000', $ ' 867715223.000 1985-182T00:00:00.000 55.184 1.000000000', $ ' 946684823.000 1988-001T00:00:00.000 55.184 0.000000000', $ ' 946684824.000 1988-001T00:00:00.000 56.184 1.000000000', $ '1009843224.000 1990-001T00:00:00.000 56.184 0.000000000', $ '1009843225.000 1990-001T00:00:00.000 57.184 1.000000000', $ '1041379225.000 1991-001T00:00:00.000 57.184 0.000000000', $ '1041379226.000 1991-001T00:00:00.000 58.184 1.000000000', $ '1088640026.000 1992-183T00:00:00.000 58.184 0.000000000', $ '1088640027.000 1992-183T00:00:00.000 59.184 1.000000000', $ '1120176027.000 1993-182T00:00:00.000 59.184 0.000000000', $ '1120176028.000 1993-182T00:00:00.000 60.184 1.000000000', $ '1151712028.000 1994-182T00:00:00.000 60.184 0.000000000', $ '1151712029.000 1994-182T00:00:00.000 61.184 1.000000000', $ '1199145629.000 1996-001T00:00:00.000 61.184 0.000000000', $ '1199145630.000 1996-001T00:00:00.000 62.184 1.000000000', $ '1246406430.000 1997-182T00:00:00.000 62.184 0.000000000', $ '1246406431.000 1997-182T00:00:00.000 63.184 1.000000000', $ '1255186000.000 1997-283T14:46:09.000 63.184 0.927453191', $ '1255187000.000 1997-283T15:01:36.453 63.184 0.999992616', $ '1255597500.000 1997-288T09:03:13.422 63.184 1.083168076', $ '1255598500.000 1997-288T09:21:16.590 63.184 0.999992517', $ '1255879000.000 1997-291T15:16:14.491 63.184 0.999859301', $ '1255880000.000 1997-291T15:32:54.350 63.184 0.999993381', $ '1259000000.000 1997-327T18:12:33.699 63.184 1.000037684', $ '1259001000.000 1997-327T18:29:13.736 63.184 0.999993392', $ '1260250000.000 1997-342T05:25:45.483 63.184 1.000033168', $ '1260251000.000 1997-342T05:42:25.516 63.184 0.999993423', $ '1262500000.000 1998-003T06:25:30.724 63.184 0.999946560', $ '1262501000.000 1998-003T06:42:10.671 63.184 0.999993388', $ '1266100000.000 1998-044T22:25:06.874 63.184 1.000058907', $ '1266101000.000 1998-044T22:41:46.933 63.184 0.999993426', $ '1268100000.000 1998-068T01:58:13.792 63.184 1.000031093', $ '1268101000.000 1998-068T02:14:53.823 63.184 0.999993447', $ '1271380000.000 1998-106T01:04:32.336 63.184 0.999843044', $ '1271381000.000 1998-106T01:21:12.179 63.184 0.999993420', $ '1281800000.000 1998-226T15:30:03.622 63.184 0.999954653', $ '1281801000.000 1998-226T15:46:43.577 63.184 0.999993396', $ '1287800000.000 1998-296T02:09:23.960 63.184 0.999960502', $ '1287801000.000 1998-296T02:26:03.920 63.184 0.999993389', $ '1290000000.000 1998-321T13:15:49.382 63.184 0.999947476', $ '1290001000.000 1998-321T13:32:29.330 63.184 0.999993351', $ '1293840276.050 1999-001T00:00:00.000 63.184 0.000000000', $ '1293840277.050 1999-001T00:00:00.000 64.184 0.999993351', $ '1294500000.000 1999-008T15:15:18.418 64.184 1.000043601', $ '1294501000.000 1999-008T15:31:58.462 64.184 0.999993432', $ '1295970000.000 1999-025T15:35:08.814 64.184 0.999944758', $ '1295971000.000 1999-025T15:51:48.758 64.184 0.999993374', $ '1298100000.000 1999-050T07:14:54.651 64.184 0.999943591', $ '1298101000.000 1999-050T07:31:34.595 64.184 0.999993339', $ '1302899000.000 1999-105T20:17:42.636 64.184 1.000246717', $ '1302900000.000 1999-105T20:34:22.882 64.184 0.999993395', $ '1307999000.000 1999-164T20:57:09.203 64.184 1.000134843', $ '1308000000.000 1999-164T21:13:49.338 64.184 0.999993451', $ '1311944000.000 1999-210T12:46:43.509 64.184 0.999950089', $ '1311945000.000 1999-210T13:03:23.459 64.184 0.999993429', $' '1317211000.000 1999-271T11:49:28.856 64.184 0.999950987', $ '1317212000.000 1999-271T12:06:08.807 64.184 0.999993401', $ '1319019000.000 1999-292T10:02:36.883 64.184 0.999947996', $ '1319020000.000 1999-292T10:19:16.831 64.184 0.999993378', $ '1322726000.000 1999-335T07:45:32.290 64.184 0.999947499', $ '1322727000.000 1999-335T08:02:12.237 64.184 0.999993363', $ '1326835000.000 2000-017T21:08:24.972 64.184 0.999946549', $ '1326836000.000 2000-017T21:25:04.919 64.184 0.999993351', $ '1329540000.000 2000-049T04:31:26.940 64.184 1.000042904', $ '1329541000.000 2000-049T04:48:06.983 64.184 0.999993390', $ '1336324000.000 2000-127T16:57:22.147 64.184 0.999949197', $ '1336325000.000 2000-127T17:14:02.097 64.184 0.999993356', $ '1337646000.000 2000-143T00:10:33.320 64.184 1.000071280', $ '1337647000.000 2000-143T00:27:13.392 64.184 0.999993415', $ '1340024000.000 2000-170T12:43:37.739 64.184 1.000047729', $ '1340025000.000 2000-170T13:00:17.787 64.184 0.999993437', $ '1344677000.000 2000-224T09:13:07.256 64.184 0.999894641', $ '1344678000.000 2000-224T09:29:47.151 64.184 0.999992894', $ '1347529000.000 2000-257T09:26:06.892 64.184 1.000024035', $ '1347530000.000 2000-257T09:42:46.916 64.184 0.999992972', $ '1348733000.000 2000-271T07:52:38.461 64.184 1.000058357', $ '1348734000.000 2000-271T08:09:18.520 64.184 0.999993100', $ '1350801000.000 2000-295T06:19:04.258 64.184 0.999933250', $ '1350802000.000 2000-295T06:35:44.191 64.184 0.999993075', $ '1363231000.000 2001-073T03:04:18.120 64.184 1.000027170', $ '1363232000.000 2001-073T03:20:58.147 64.184 0.999993078', $ '1369439000.000 2001-144T23:30:15.182 64.184 0.999629659', $ '1369440000.000 2001-144T23:46:54.812 64.184 0.999992864', $ '1370045000.000 2001-151T23:50:10.495 64.184 1.000063365', $ '1370046000.000 2001-152T00:06:50.558 64.184 0.999993049', $ '1372117000.000 2001-175T23:23:16.162 64.184 0.999937727', $ '1372118000.000 2001-175T23:39:56.100 64.184 0.999992960', $ '1373326000.000 2001-189T23:13:07.596 64.184 0.999949792', $ '1373327000.000 2001-189T23:29:47.545 64.184 0.999992925', $ '1375181000.000 2001-211T10:29:34.428 64.184 0.999956658', $ '1375182000.000 2001-211T10:46:14.385 64.184 0.999992889', $ '1377536000.000 2001-238T16:39:17.646 64.184 1.000081366', $ '1377537000.000 2001-238T16:55:57.727 64.184 0.999993068', $ '1378461000.000 2001-249T09:35:51.322 64.184 0.999933327', $ '1378462000.000 2001-249T09:52:31.255 64.184 0.999992910', $ '1382691000.000 2001-298T08:35:21.271 64.184 1.000029368', $ '1382692000.000 2001-298T08:52:01.301 64.184 0.999993006', $ '1387273000.000 2001-351T09:21:29.261 64.184 1.000031910', $ '1387274000.000 2001-351T09:38:09.293 64.184 0.999993082', $ '1389259000.000 2002-009T09:01:15.561 64.184 0.999939059', $ '1389260000.000 2002-009T09:17:55.500 64.184 0.999992909', $ '1394680000.000 2002-072T02:50:37.067 64.184 0.999944116', $ '1394681000.000 2002-072T03:07:17.011 64.184 0.999992856', $ '1396191000.000 2002-089T14:33:46.224 64.184 1.000048958', $ '1396192000.000 2002-089T14:50:26.273 64.184 0.999992947', $ '1397174000.000 2002-100T23:36:59.347 64.184 0.999946049', $ '1397175000.000 2002-100T23:53:39.293 64.184 0.999992896', $ '1402371000.000 2002-161T03:13:02.381 64.184 1.000039012', $ '1402372000.000 2002-161T03:29:42.420 64.184 0.999993066', $ '1404134000.000 2002-181T12:56:10.202 64.184 1.000034579', $ '1404135000.000 2002-181T13:12:50.237 64.184 0.999993089', $ '1404941000.000 2002-190T21:06:04.667 64.184 0.999958157', $ '1404942000.000 2002-190T21:22:44.625 64.184 0.999992976', $ '1407360000.000 2002-218T21:02:27.641 64.184 0.999892966', $ '1407361000.000 2002-218T21:19:07.534 64.184 0.999992892', $ '1409854000.000 2002-247T17:48:49.814 64.184 0.999950462', $ '1409855000.000 2002-247T18:05:29.764 64.184 0.999992875', $ '1412770000.000 2002-281T11:48:28.995 64.184 1.000043275', $ '1412771000.000 2002-281T12:05:09.038 64.184 0.999992981', $ '1414414000.000 2002-300T12:28:17.506 64.184 0.999958795', $ '1414415000.000 2002-300T12:44:57.465 64.184 0.999992869', $ '1418203000.000 2002-344T08:57:50.453 64.184 1.000269729', $ '1418204000.000 2002-344T09:14:30.723 64.184 0.999992979', $ '1418694000.000 2002-350T01:21:07.283 64.184 1.000053905', $ '1418695000.000 2002-350T01:37:47.337 64.184 0.999993064', $ '1422001000.000 2003-023T07:57:24.407 64.184 0.999926227', $ '1422002000.000 2003-023T08:14:04.333 64.184 0.999992970', $ '1423032000.000 2003-035T06:20:37.092 64.184 0.999877647', $ '1423033000.000 2003-035T06:37:16.970 64.184 0.999992850', $ '1424247000.000 2003-049T07:50:28.290 64.184 0.999890528', $ '1424248000.000 2003-049T08:07:08.180 64.184 0.999992742', $ '1425629000.000 2003-065T07:43:38.157 64.184 1.000050036', $ '1425630000.000 2003-065T08:00:18.207 64.184 0.999992863', $ '1427182000.000 2003-083T07:06:47.130 64.184 0.999942456', $ '1427183000.000 2003-083T07:23:27.073 64.184 0.999992749', $ '1427789000.000 2003-090T07:43:22.679 64.184 1.000273365', $ '1427790000.000 2003-090T08:00:02.952 64.184 0.999993379', $ '1429602000.000 2003-111T07:19:50.955 64.184 1.000067559', $ '1429603000.000 2003-111T07:36:31.022 64.184 0.999993423', $ '1430755000.000 2003-124T15:36:23.445 64.184 1.000051120', $ '1430756000.000 2003-124T15:53:03.496 64.184 0.999993467', $ '1447837000.000 2003-322T08:34:31.906 64.184 1.000051264', $ '1447838000.000 2003-322T08:51:11.957 64.184 0.999993476', $ '1459143000.000 2004-088T05:06:38.203 64.184 1.000036842', $ '1459144000.000 2004-088T05:23:18.240 64.184 0.999993487', $ '1475673000.000 2004-279T12:44:50.587 64.184 0.999954612', $ '1475674000.000 2004-279T13:01:30.541 64.184 0.999993474', $ '1480342000.000 2004-333T13:41:00.078 64.184 1.000049321', $ '1480343000.000 2004-333T13:57:40.127 64.184 0.999993489', $ '1488155000.000 2005-057T23:56:49.263 64.184 1.000096576', $ '1488156000.000 2005-058T00:13:29.360 64.184 0.999993695', $ '1488577000.000 2005-062T21:10:06.706 64.184 0.999915371', $ '1488578000.000 2005-062T21:26:46.621 64.184 0.999993570', $ '1491864000.000 2005-100T22:13:05.492 64.184 1.000060440', $ '1491865000.000 2005-100T22:29:45.552 64.184 0.999993591', $ '1496267000.000 2005-151T21:15:57.340 64.184 1.000053721', $ '1496268000.000 2005-151T21:32:37.393 64.184 0.999993626'] fract_input = (long(mill_input) * 256L) / 1000 nb_element = size(conversion_string) for i = 0, nb_element(1) - 2 do begin reads, conversion_string(i), sclk0, fract0, year0, day0, hour0, $ min0, sec0, tmp, rate0, $ format='(i10,1x,i3,4x,i4,1x,i3,1x,i2,1x,i2,1x,f6.3,1x,f6.3,1x,f12.9)' reads, conversion_string(i + 1), sclk1, fract1, year1, day1, hour1, $ min1, sec1, tmp, rate1, $ format='(i10,1x,i3,4x,i4,1x,i3,1x,i2,1x,i2,1x,f6.3,1x,f6.3,1x,f12.9)' if (((sclk_input gt sclk0) or $ ((sclk_input eq sclk0) and (fract_input ge fract0))) $ and ((sclk_input lt sclk1) or $ ((sclk_input eq sclk1) and (fract_input lt fract1)))) then begin ; use sclk0 and exit the loop find = 1 goto, end_of_loop endif endfor end_of_loop: if (find eq 0) then begin sclk0 = sclk1 fract0 = fract1 year0 = year1 doy0 = doy1 hour0 = hour1 min0 = min1 sec0 = sec1 rate0 = rate1 endif ;print, sclk_input, sclk0 nb_of_seconds = (double(sclk_input - sclk0) + $ double(fract_input - fract0)/(256.0D0)) $ * rate0 timesec = sec0 + nb_of_seconds ;print, timesec nb_of_minutes = long(timesec/(60.0D0)) timesec = timesec - double(nb_of_minutes * 60) ;print, "Seconds: ", timesec,format='(a9,f14.5)' timmin = min0 + nb_of_minutes nb_of_hours = long(timmin/60.0) timmin = timmin - float(nb_of_hours * 60) ;print, "Minutes: ",timmin timhour = hour0 + nb_of_hours nb_of_days = long(timhour/24.0) timhour = timhour - float(nb_of_days * 24) ;print, "Hours :",timhour timday = day0 + nb_of_days ;print, "Days :", timday repeat begin if ((year0 mod 4) eq 0) then begin daytmp = timday - 366 if daytmp gt 0 then begin year0 = year0 + 1 timday = daytmp endif endif else begin daytmp = timday - 365 if daytmp gt 0 then begin year0 = year0 + 1 timday = daytmp endif endelse endrep until (daytmp le 0) ;print, "Year : ", year0 ;print, "Doy : ", timday ;print, "Hours : ", timhour ;print, "Min : ", timmin ;print, "Seconds: ", timesec,format='(a9,f14.5)' scet.year = year0 scet.doy = timday scet.hour = timhour scet.min = timmin scet.sec = timesec end