Binary PCK Hands-On Lesson (FORTRAN) |
Table of ContentsBinary PCK Hands-On Lesson (FORTRAN) Overview Note About HTML Links References Tutorials Required Readings The Permuted Index API Documentation Kernels Used SPICE Modules Used Moon rotation (mrotat) Task Statement Learning Goals Approach Solution Solution Meta-Kernel Solution Source Code Solution Sample Output Earth rotation (erotat) Task Statement Learning Goals Approach Solution Solution Meta-Kernel Solution Source Code Solution Sample Output Binary PCK Hands-On Lesson (FORTRAN)
Overview
Note About HTML Links
In order for the links to be resolved, if not done already by installing the lessons package under the Toolkit's ``doc/html'' directory, create a subdirectory called ``lessons'' under the ``doc/html'' directory of the ``toolkit/'' tree and copy this document to that subdirectory before loading it into a Web browser. References
Of these documents, the ``Tutorials'' contains the highest level descriptions with the least number of details while the ``Required Reading'' documents contain much more detailed specifications. The most complete specifications are provided in the ``API Documentation''. Tutorials
Name Lesson steps/routines it describes ---------------- ----------------------------------------------- Frames Moon rotation, Earth rotation PCK Moon rotation, Earth rotation ``High Accuracy Orientation and Body-Fixed frames for Moon and Earth'' (backup) Moon rotation, Earth rotationThese tutorials are available from the NAIF server at JPL:
https://naif.jpl.nasa.gov/naif/tutorials.html Required Readings
Name Lesson steps/routines that it describes --------------- ----------------------------------------- frames.req Using reference frames pck.req Obtaining planetary constants data spk.req Obtaining ephemeris data time.req Time conversion The Permuted Index
This text document provides a simple mechanism by which users can discover which SPICE routines perform functions of interest, as well as the names of the source files that contain these routines. It is particularly useful for FORTRAN programmers because some of the routines are entry points; the names of these routines do not translate directly into the name of the respective source files that contain them. API Documentation
For example the path of the source code of the STR2ET routine is
toolkit/src/spicelib/str2et.forSince some of the FORTRAN routines are entry points they may be part of a source file that has different name. The ``Permuted Index'' document mentioned above can be used to locate the name of their source file. Kernels Used
# FILE NAME TYPE DESCRIPTION -- ------------------------------ ---- ------------------------------ 1 naif0008.tls LSK Generic LSK 2 de414_2000_2020.bsp SPK Solar System Ephemeris 3 moon_060721.tf FK Lunar FK 4 pck00008.tpc PCK NAIF text PCK 5 moon_pa_de403_1950-2198.bpc PCK Moon binary PCK 6 earthstns_itrf93_050714.bsp SPK DSN station Ephemeris 7 earth_topo_050714.tf FK Earth topocentric FK 8 earth_000101_070725_070503.bpc PCK Earth binary PCKThese SPICE kernels are included in the lesson package. SPICE Modules Used
CHAPTER EXERCISE ROUTINES FUNCTIONS KERNELS ------- --------- --------- --------- ---------- 1 mrotat FURNSH DPR 1-5 STR2ET VSEP SPKPOS VDIST RECLAT SUBPNT 2 erotat FURNSH DPR 1-2,4,6-8 STR2ET VSEP SPKPOS SPD RECLAT TWOPI TIMOUT VDIST PXFORM SUBSLRRefer to the headers of the various routines listed above, as detailed interface specifications are provided with the source code. Moon rotation (mrotat)Task Statement
Learning Goals
Approach
SolutionSolution Meta-Kernel
KPL/MK Meta-kernel for the ``Moon Rotation'' task in the Binary PCK Hands On Lesson. The names and contents of the kernels referenced by this meta-kernel are as follows: File name Contents --------------------------- ------------------------------------ naif0008.tls Generic LSK de414_2000_2020.bsp Solar System Ephemeris moon_060721.tf Lunar FK pck00008.tpc NAIF text PCK moon_pa_de403_1950-2198.bpc Moon binary PCK \begindata KERNELS_TO_LOAD = ( 'kernels/lsk/naif0008.tls' 'kernels/spk/de414_2000_2020.bsp' 'kernels/fk/moon_060721.tf' 'kernels/pck/pck00008.tpc' 'kernels/pck/moon_pa_de403_1950-2198.bpc' ) \begintext Solution Source Code
PROGRAM MROTAT IMPLICIT NONE C C SPICELIB functions C DOUBLE PRECISION DPR DOUBLE PRECISION VDIST DOUBLE PRECISION VSEP C C Local parameters C CHARACTER*(*) METAKR PARAMETER ( METAKR = 'mrotat.tm' ) INTEGER TIMLEN PARAMETER ( TIMLEN = 35 ) C C Local variables C CHARACTER*(TIMLEN) TIMSTR DOUBLE PRECISION DIST DOUBLE PRECISION ET DOUBLE PRECISION IMOONV ( 3 ) DOUBLE PRECISION LAT DOUBLE PRECISION LON DOUBLE PRECISION LTIME DOUBLE PRECISION MMOONV ( 3 ) DOUBLE PRECISION MSUB ( 3 ) DOUBLE PRECISION PMOONV ( 3 ) DOUBLE PRECISION PSUB ( 3 ) DOUBLE PRECISION R DOUBLE PRECISION SEP DOUBLE PRECISION SRFVEC ( 3 ) DOUBLE PRECISION TRGEPC C C Load the kernels this program requires. C CALL FURNSH ( METAKR ) C C Convert our UTC string to seconds past J2000 TDB. C TIMSTR = '2007 JAN 1 00:00:00' CALL STR2ET ( TIMSTR, ET ) C C Look up the apparent position of the Earth relative C to the Moon's center in the IAU_MOON frame at ET. C CALL SPKPOS ( 'EARTH', ET, 'IAU_MOON', . 'LT+S', 'MOON', IMOONV, LTIME ) C C Express the Earth direction in terms of longitude C and latitude in the IAU_MOON frame. C CALL RECLAT ( IMOONV, R, LON, LAT ) WRITE (*,'(A)') ' ' WRITE (*,'(A)') 'Moon-Earth direction using low accuracy' WRITE (*,'(A)') 'PCK and IAU_MOON frame:' WRITE (*, '(A,F15.6)' ) 'Earth lon (deg): ', . LON*DPR() WRITE (*, '(A,F15.6)' ) 'Earth lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Look up the apparent position of the Earth relative C to the Moon's center in the MOON_ME frame at ET. C CALL SPKPOS ( 'EARTH', ET, 'MOON_ME', . 'LT+S', 'MOON', MMOONV, LTIME ) C C Express the Earth direction in terms of longitude C and latitude in the MOON_ME frame. C CALL RECLAT ( MMOONV, R, LON, LAT ) WRITE (*,'(A)') 'Moon-Earth direction using high accuracy' WRITE (*,'(A)') 'PCK and MOON_ME frame:' WRITE (*, '(A,F15.6)' ) 'Earth lon (deg): ', . LON*DPR() WRITE (*, '(A,F15.6)' ) 'Earth lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Find the angular separation of the Earth position C vectors in degrees. C SEP = DPR() * VSEP( MMOONV, IMOONV ) WRITE (*, '(A)' ) 'For IAU_MOON vs MOON_ME frames:' WRITE (*, '(A,F15.6)' ) .'Moon-Earth vector separation angle (deg): ', SEP WRITE (*,*) ' ' C C Look up the apparent position of the Earth relative C to the Moon's center in the MOON_PA frame at ET. C CALL SPKPOS ( 'EARTH', ET, 'MOON_PA', . 'LT+S', 'MOON', PMOONV, LTIME ) C C Express the Earth direction in terms of longitude C and latitude in the MOON_PA frame. C CALL RECLAT ( PMOONV, R, LON, LAT ) WRITE (*,'(A)') 'Moon-Earth direction using high accuracy' WRITE (*,'(A)') 'PCK and MOON_PA frame:' WRITE (*, '(A,F15.6)' ) 'Earth lon (deg): ', . LON*DPR() WRITE (*, '(A,F15.6)' ) 'Earth lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Find the angular separation of the Earth position C vectors in degrees. C SEP = DPR() * VSEP( MMOONV, PMOONV ) WRITE (*, '(A)' ) 'For MOON_PA vs MOON_ME frames:' WRITE (*, '(A,F15.6)' ) .'Moon-Earth vector separation angle (deg): ', SEP WRITE (*,*) ' ' C C Find the apparent sub-Earth point on the Moon at ET using C the MOON_ME frame. C CALL SUBPNT ( 'NEAR POINT: ELLIPSOID', . 'MOON', ET, 'MOON_ME', 'LT+S', . 'EARTH', MSUB, TRGEPC, SRFVEC ) C C Display the sub-Earth point in latitudinal coordinates. C CALL RECLAT ( MSUB, R, LON, LAT ) WRITE (*,'(A)') .'Sub-Earth point on Moon using high accuracy' WRITE (*,'(A)') 'PCK and MOON_ME frame:' WRITE (*, '(A,F15.6)' ) 'Sub-Earth lon (deg): ', . LON *DPR() WRITE (*, '(A,F15.6)' ) 'Sub-Earth lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Find the apparent sub-Earth point on the Moon at ET using C the MOON_PA frame. C CALL SUBPNT ( 'NEAR POINT: ELLIPSOID', . 'MOON', ET, 'MOON_PA', 'LT+S', . 'EARTH', PSUB, TRGEPC, SRFVEC ) C C Display the sub-point in latitudinal coordinates. C CALL RECLAT ( PSUB, R, LON, LAT ) WRITE (*,'(A)') .'Sub-Earth point on Moon using high accuracy' WRITE (*,'(A)') 'PCK and MOON_PA frame:' WRITE (*, '(A,F15.6)' ) 'Sub-Earth lon (deg): ', . LON *DPR() WRITE (*, '(A,F15.6)' ) 'Sub-Earth lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Find the distance between the sub-Earth points C in km. C DIST = VDIST( MSUB, PSUB ) WRITE (*, '(A,F15.6)' ) .'Distance between sub-Earth points (km): ', DIST END Solution Sample Output
Moon-Earth direction using low accuracy PCK and IAU_MOON frame: Earth lon (deg): 3.613102 Earth lat (deg): -6.438342 Moon-Earth direction using high accuracy PCK and MOON_ME frame: Earth lon (deg): 3.611229 Earth lat (deg): -6.439501 For IAU_MOON vs MOON_ME frames: Moon-Earth vector separation angle (deg): 0.002194 Moon-Earth direction using high accuracy PCK and MOON_PA frame: Earth lon (deg): 3.593319 Earth lat (deg): -6.417582 For MOON_PA vs MOON_ME frames: Moon-Earth vector separation angle (deg): 0.028235 Sub-Earth point on Moon using high accuracy PCK and MOON_ME frame: Sub-Earth lon (deg): 3.611419 Sub-Earth lat (deg): -6.439501 Sub-Earth point on Moon using high accuracy PCK and MOON_PA frame: Sub-Earth lon (deg): 3.593509 Sub-Earth lat (deg): -6.417582 Distance between sub-Earth points (km): 0.856182 Earth rotation (erotat)Task Statement
For each of the two epochs ET and ET + 100 days, examine the differences between the axes of the ITRF93 and IAU_EARTH frames using the following method:
Find the azimuth and elevation of the apparent position of the Moon as seen from the DSN station DSS-13 by the following steps:
Learning Goals
Understanding of topocentric frames and computation of target geometry relative to a surface location on the Earth. Knowledge of SPICE kernels required to support such computations. Approach
SolutionSolution Meta-Kernel
KPL/MK Meta-kernel for the ``Earth Rotation'' task in the Binary PCK Hands On Lesson. The names and contents of the kernels referenced by this meta-kernel are as follows: File name Contents ------------------------------ --------------------------------- naif0008.tls Generic LSK de414_2000_2020.bsp Solar System Ephemeris earthstns_itrf93_050714.bsp DSN station Ephemeris earth_topo_050714.tf Earth topocentric FK pck00008.tpc NAIF text PCK earth_000101_070725_070503.bpc Earth binary PCK \begindata KERNELS_TO_LOAD = ( 'kernels/lsk/naif0008.tls' 'kernels/spk/de414_2000_2020.bsp' 'kernels/spk/earthstns_itrf93_050714.bsp' 'kernels/fk/earth_topo_050714.tf' 'kernels/pck/pck00008.tpc' 'kernels/pck/earth_000101_070725_070503.bpc' ) \begintext Solution Source Code
PROGRAM EROTAT IMPLICIT NONE C C SPICELIB functions C DOUBLE PRECISION DPR DOUBLE PRECISION SPD DOUBLE PRECISION TWOPI DOUBLE PRECISION VDIST DOUBLE PRECISION VSEP C C Local parameters C CHARACTER*(*) METAKR PARAMETER ( METAKR = 'erotat.tm' ) INTEGER TIMLEN PARAMETER ( TIMLEN = 35 ) C C Local variables C CHARACTER*(TIMLEN) TIMSTR CHARACTER*(TIMLEN) OUTSTR DOUBLE PRECISION AZ DOUBLE PRECISION DIST DOUBLE PRECISION EL DOUBLE PRECISION ET DOUBLE PRECISION HMOONV ( 3 ) DOUBLE PRECISION HSUB ( 3 ) DOUBLE PRECISION ITRFX ( 3 ) DOUBLE PRECISION ITRFZ ( 3 ) DOUBLE PRECISION LMOONV ( 3 ) DOUBLE PRECISION LAT DOUBLE PRECISION LON DOUBLE PRECISION LSUB ( 3 ) DOUBLE PRECISION LTIME DOUBLE PRECISION R DOUBLE PRECISION RMAT ( 3, 3 ) DOUBLE PRECISION SEP DOUBLE PRECISION SRFVEC ( 3 ) DOUBLE PRECISION T DOUBLE PRECISION TOPOV ( 3 ) DOUBLE PRECISION TRGEPC DOUBLE PRECISION X ( 3 ) DOUBLE PRECISION Z ( 3 ) INTEGER I INTEGER J DATA X / 1.D0, 0.D0, 0.D0 / DATA Z / 0.D0, 0.D0, 1.D0 / C C Load the kernels this program requires. C CALL FURNSH ( METAKR ) C C Convert our UTC string to seconds past J2000 TDB. C TIMSTR = '2007 JAN 1 00:00:00' CALL STR2ET ( TIMSTR, ET ) C C Look up the apparent position of the Moon relative C to the Earth's center in the IAU_EARTH frame at ET. C CALL SPKPOS ( 'MOON', ET, 'IAU_EARTH', . 'LT+S', 'EARTH', LMOONV, LTIME ) C C Express the Moon direction in terms of longitude C and latitude in the IAU_EARTH frame. C CALL RECLAT ( LMOONV, R, LON, LAT ) WRITE (*,'(A)') ' ' WRITE (*,'(A)') 'Earth-Moon direction using low accuracy' WRITE (*,'(A)') 'PCK and IAU_EARTH frame:' WRITE (*, '(A,F15.6)' ) 'Moon lon (deg): ', . LON*DPR() WRITE (*, '(A,F15.6)' ) 'Moon lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Look up the apparent position of the Moon relative C to the Earth's center in the ITRF93 frame at ET. C CALL SPKPOS ( 'MOON', ET, 'ITRF93', . 'LT+S', 'EARTH', HMOONV, LTIME ) C C Express the Moon direction in terms of longitude C and latitude in the ITRF93 frame. C CALL RECLAT ( HMOONV, R, LON, LAT ) WRITE (*,'(A)') 'Earth-Moon direction using high accuracy' WRITE (*,'(A)') 'PCK and ITRF93 frame:' WRITE (*, '(A,F15.6)' ) 'Moon lon (deg): ', . LON*DPR() WRITE (*, '(A,F15.6)' ) 'Moon lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Find the angular separation of the Moon position C vectors in degrees. C SEP = DPR() * VSEP( LMOONV, HMOONV ) WRITE (*, '(A,F15.6)' ) .'Earth-Moon vector separation angle (deg): ', SEP WRITE (*,*) ' ' C C Next, express the +Z and +X axes of the ITRF93 frame in C the IAU_EARTH frame. We'll do this for two times: ET C and ET + 100 days. C DO I = 1, 2 C C Set the time, expressing the time delta in C seconds. C T = ET + (I-1)*SPD()*100 C C Convert the TDB time T to a string for output. C CALL TIMOUT ( T, . 'YYYY-MON-DD HR:MN:SC.### (UTC)', . OUTSTR ) WRITE (*,'(2A)') 'Epoch: ', OUTSTR C C Find the rotation matrix for conversion of position C vectors from the IAU_EARTH to the ITRF93 frame. C CALL PXFORM ( 'IAU_EARTH', 'ITRF93', T, RMAT ) DO J = 1, 3 ITRFX(J) = RMAT(1,J) ITRFZ(J) = RMAT(3,J) END DO C C Display the angular offsets of the ITRF93 +X and +Z C axes from their IAU_EARTH counterparts. C SEP = VSEP ( ITRFX, X ) WRITE (*, '(A,F13.6)' ) . 'ITRF93 - IAU_EARTH +X axis separation angle ' . // '(deg): ', SEP * DPR() SEP = VSEP ( ITRFZ, Z ) WRITE (*, '(A,F13.6)' ) . 'ITRF93 - IAU_EARTH +Z axis separation angle ' . // '(deg): ', SEP * DPR() WRITE (*,*) ' ' END DO C C Find the azimuth and elevation of the apparent C position of the Moon in the local topocentric C reference frame at the DSN station DSS-13. C First look up the Moon's position relative to the C station in that frame. C CALL SPKPOS ( 'MOON', ET, 'DSS-13_TOPO', . 'LT+S', 'DSS-13', TOPOV, LTIME ) C C Express the station-Moon direction in terms of C longitude and latitude in the DSS-13_TOPO frame. C CALL RECLAT ( TOPOV, R, LON, LAT ) C C Convert to azimuth/elevation. C AZ = -LON IF ( AZ .LT. 0 ) THEN AZ = AZ + TWOPI() END IF EL = LAT WRITE (*,'(A)') . 'DSS-13-Moon az/el using high accuracy ' .// 'PCK and DSS-13_TOPO frame:' WRITE (*, '(A,F15.6)' ) 'Moon Az (deg): ', . AZ * DPR() WRITE (*, '(A,F15.6)' ) 'Moon El (deg): ', . EL * DPR() WRITE (*,*) ' ' C C Find the sub-solar point on the Earth at ET using the C Earth body-fixed frame IAU_EARTH. Treat the Sun as C the observer. C CALL SUBSLR ( 'NEAR POINT: ELLIPSOID', . 'EARTH', ET, 'IAU_EARTH', 'LT+S', . 'SUN', LSUB, TRGEPC, SRFVEC ) C C Display the sub-point in latitudinal coordinates. C CALL RECLAT ( LSUB, R, LON, LAT ) WRITE (*,'(A)') .'Sub-Solar point on Earth using low accuracy' WRITE (*,'(A)') 'PCK and IAU_EARTH frame:' WRITE (*, '(A,F15.6)' ) 'Sub-Solar lon (deg): ', . LON *DPR() WRITE (*, '(A,F15.6)' ) 'Sub-Solar lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Find the sub-solar point on the Earth at ET using the C Earth body-fixed frame ITRF93. Treat the Sun as C the observer. C CALL SUBSLR ( 'NEAR POINT: ELLIPSOID', . 'EARTH', ET, 'ITRF93', 'LT+S', . 'SUN', HSUB, TRGEPC, SRFVEC ) C C Display the sub-point in latitudinal coordinates. C CALL RECLAT ( HSUB, R, LON, LAT ) WRITE (*,'(A)') .'Sub-Solar point on Earth using high accuracy' WRITE (*,'(A)') 'PCK and ITRF93 frame:' WRITE (*, '(A,F15.6)' ) 'Sub-Solar lon (deg): ', . LON*DPR() WRITE (*, '(A,F15.6)' ) 'Sub-Solar lat (deg): ', . LAT*DPR() WRITE (*,*) ' ' C C Find the distance between the sub-solar point C vectors in km. C DIST = VDIST( LSUB, HSUB ) WRITE (*, '(A,F15.6)' ) .'Distance between sub-solar points (km): ', DIST END Solution Sample Output
Earth-Moon direction using low accuracy PCK and IAU_EARTH frame: Moon lon (deg): -35.496272 Moon lat (deg): 26.416959 Earth-Moon direction using high accuracy PCK and ITRF93 frame: Moon lon (deg): -35.554286 Moon lat (deg): 26.419156 Earth-Moon vector separation angle (deg): 0.052002 Epoch: 2007-JAN-01 00:00:00.000 (UTC) ITRF93 - IAU_EARTH +X axis separation angle (deg): 0.057677 ITRF93 - IAU_EARTH +Z axis separation angle (deg): 0.002326 Epoch: 2007-APR-10 23:59:59.998 (UTC) ITRF93 - IAU_EARTH +X axis separation angle (deg): 0.057787 ITRF93 - IAU_EARTH +Z axis separation angle (deg): 0.002458 DSS-13-Moon az/el using high accuracy PCK and DSS-13_TOPO frame: Moon Az (deg): 72.169006 Moon El (deg): 20.689488 Sub-Solar point on Earth using low accuracy PCK and IAU_EARTH frame: Sub-Solar lon (deg): -177.100531 Sub-Solar lat (deg): -22.910377 Sub-Solar point on Earth using high accuracy PCK and ITRF93 frame: Sub-Solar lon (deg): -177.157874 Sub-Solar lat (deg): -22.912593 Distance between sub-solar points (km): 5.881861 |