Binary PCK Hands-On Lesson (C) |
Table of ContentsBinary PCK Hands-On Lesson (C) Overview Note About HTML Links References Tutorials Required Readings The Permuted Index API Documentation Kernels Used CSPICE 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 (C)
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 ``cspice/'' 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/functions 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/functions 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 CSPICE functions perform functions of interest, as well as the names of the source files that contain these functions. API Documentation
For example the path of the source code of the str2et_c routine is
cspice/src/cspice/str2et_c.c 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. CSPICE Modules Used
CHAPTER EXERCISE FUNCTIONS NON-VOID KERNELS ------- --------- --------- --------- ---------- 1 mrotat furnsh_c dpr_c 1-5 str2et_c vsep_c spkpos_c vdist_c reclat_c subpnt_c 2 erotat furnsh_c dpr_c 1-2,4,6-8 str2et_c vsep_c spkpos_c spd_c reclat_c twopi_c timout_c vdist_c pxform_c subslr_cRefer to the headers of the various functions 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
#include <stdio.h> /* Standard CSPICE User Include File */ #include "SpiceUsr.h" /* Local Parameters */ #define METAKR "mrotat.tm" int main (void) { /* Local Variables */ SpiceChar * timstr; SpiceDouble dist; SpiceDouble et; SpiceDouble imoonv [3]; SpiceDouble lat; SpiceDouble lon; SpiceDouble ltime; SpiceDouble mmoonv [3]; SpiceDouble msub [3]; SpiceDouble pmoonv [3]; SpiceDouble psub [3]; SpiceDouble r; SpiceDouble sep; SpiceDouble srfvec [3]; SpiceDouble trgepc; /* Load the kernels this program requires. */ furnsh_c ( METAKR ); /* Convert our UTC string to seconds past J2000 TDB. */ timstr = "2007 JAN 1 00:00:00"; str2et_c ( timstr, &et ); /* Look up the apparent position of the Earth relative to the Moon's center in the IAU_MOON frame at ET. */ spkpos_c ( "earth", et, "iau_moon", "lt+s", "moon", imoonv, <ime ); /* Express the Earth direction in terms of longitude and latitude in the IAU_MOON frame. */ reclat_c ( imoonv, &r, &lon, &lat ); printf ( "\n" "Moon-Earth direction using low accuracy\n" "PCK and IAU_MOON frame:\n" "Earth lon (deg): %15.6f\n" "Earth lat (deg): %15.6f\n" "\n", lon * dpr_c(), lat * dpr_c() ); /* Look up the apparent position of the Earth relative to the Moon's center in the MOON_ME frame at ET. */ spkpos_c ( "earth", et, "moon_me", "lt+s", "moon", mmoonv, <ime ); /* Express the Earth direction in terms of longitude and latitude in the MOON_ME frame. */ reclat_c ( mmoonv, &r, &lon, &lat ); printf ( "Moon-Earth direction using high accuracy\n" "PCK and MOON_ME frame:\n" "Earth lon (deg): %15.6f\n" "Earth lat (deg): %15.6f\n" "\n", lon * dpr_c(), lat * dpr_c() ); /* Find the angular separation of the Earth position vectors in degrees. */ sep = dpr_c() * vsep_c( imoonv, mmoonv ); printf ( "For IAU_MOON vs MOON_ME frames:\n" ); printf ( "Moon-Earth vector separation angle (deg): " "%15.6f\n\n", sep ); /* Look up the apparent position of the Earth relative to the Moon's center in the MOON_PA frame at ET. */ spkpos_c ( "earth", et, "moon_pa", "lt+s", "moon", pmoonv, <ime ); /* Express the Earth direction in terms of longitude and latitude in the MOON_PA frame. */ reclat_c ( pmoonv, &r, &lon, &lat ); printf ( "Moon-Earth direction using high accuracy\n" "PCK and MOON_PA frame:\n" "Earth lon (deg): %15.6f\n" "Earth lat (deg): %15.6f\n" "\n", lon * dpr_c(), lat * dpr_c() ); /* Find the angular separation of the Earth position vectors in degrees. */ sep = dpr_c() * vsep_c( pmoonv, mmoonv ); printf ( "For MOON_PA vs MOON_ME frames:\n" ); printf ( "Moon-Earth vector separation angle (deg): " "%15.6f\n\n", sep ); /* Find the apparent sub-Earth point on the Moon at ET using the MOON_ME frame. */ subpnt_c ( "near point: ellipsoid", "moon", et, "moon_me", "lt+s", "earth", msub, &trgepc, srfvec ); /* Display the sub-point in latitudinal coordinates. */ reclat_c ( msub, &r, &lon, &lat ); printf ( "Sub-Earth point on Moon using high accuracy\n" "PCK and MOON_ME frame:\n" "Sub-Earth lon (deg): %15.6f\n" "Sub-Earth lat (deg): %15.6f\n\n", lon * dpr_c(), lat * dpr_c() ); /* Find the apparent sub-Earth point on the Moon at ET using the MOON_PA frame. */ subpnt_c ( "near point: ellipsoid", "moon", et, "moon_pa", "lt+s", "earth", psub, &trgepc, srfvec ); /* Display the sub-point in latitudinal coordinates. */ reclat_c ( psub, &r, &lon, &lat ); printf ( "Sub-Earth point on Moon using high accuracy\n" "PCK and MOON_PA frame:\n" "Sub-Earth lon (deg): %15.6f\n" "Sub-Earth lat (deg): %15.6f\n\n", lon * dpr_c(), lat * dpr_c() ); /* Find the distance between the sub-Earth points in km. */ dist = vdist_c( msub, psub ); printf ( "Distance between sub-Earth points (km): " "%15.6f\n", dist ); return ( 0 ); } 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
#include <stdio.h> /* Standard CSPICE User Include File */ #include "SpiceUsr.h" /* Local Parameters */ #define METAKR "erotat.tm" #define TIMLEN 36 int main (void) { /* Local Variables */ SpiceChar * timstr; SpiceChar outstr [TIMLEN]; SpiceDouble az; SpiceDouble dist; SpiceDouble el; SpiceDouble et; SpiceDouble hmoonv [3]; SpiceDouble hsub [3]; SpiceDouble itrfx [3]; SpiceDouble itrfz [3]; SpiceDouble lmoonv [3]; SpiceDouble lat; SpiceDouble lon; SpiceDouble lsub [3]; SpiceDouble ltime; SpiceDouble r; SpiceDouble rmat [3][3]; SpiceDouble sep; SpiceDouble srfvec [3]; SpiceDouble t; SpiceDouble topov [3]; SpiceDouble trgepc; static SpiceDouble x [3] = { 1.0, 0.0, 0.0}; static SpiceDouble z [3] = { 0.0, 0.0, 1.0}; SpiceInt i; SpiceInt j; /* Load the kernels this program requires. */ furnsh_c ( METAKR ); /* Convert our UTC string to seconds past J2000 TDB. */ timstr = "2007 JAN 1 00:00:00"; str2et_c ( timstr, &et ); /* Look up the apparent position of the Moon relative to the Earth's center in the IAU_EARTH frame at ET. */ spkpos_c ( "moon", et, "iau_earth", "lt+s", "earth", lmoonv, <ime ); /* Express the Moon direction in terms of longitude and latitude in the IAU_EARTH frame. */ reclat_c ( lmoonv, &r, &lon, &lat ); printf ( "\n" "Earth-Moon direction using low accuracy\n" "PCK and IAU_EARTH frame:\n" "Moon lon (deg): %15.6f\n" "Moon lat (deg): %15.6f\n" "\n", lon * dpr_c(), lat * dpr_c() ); /* Look up the apparent position of the Moon relative to the Earth's center in the ITRF93 frame at ET. */ spkpos_c ( "moon", et, "itrf93", "lt+s", "earth", hmoonv, <ime ); /* Express the Moon direction in terms of longitude and latitude in the ITRF93 frame. */ reclat_c ( hmoonv, &r, &lon, &lat ); printf ( "Earth-Moon direction using high accuracy\n" "PCK and ITRF93 frame:\n" "Moon lon (deg): %15.6f\n" "Moon lat (deg): %15.6f\n" "\n", lon * dpr_c(), lat * dpr_c() ); /* Find the angular separation of the Moon position vectors in degrees. */ sep = dpr_c() * vsep_c( lmoonv, hmoonv ); printf ( "Earth-Moon vector separation angle (deg): " "%15.6f\n\n", sep ); /* Next, express the +Z and +X axes of the ITRF93 frame in the IAU_EARTH frame. We'll do this for two times: et and et + 100 days. */ for ( i = 0; i < 2; i++ ) { /* Set the time, expressing the time delta in seconds. */ t = et + i*spd_c()*100; /* Convert the TDB time T to a string for output. */ timout_c ( t, "YYYY-MON-DD HR:MN:SC.### (UTC)", TIMLEN, outstr ); printf ( "Epoch: %s\n", outstr ); /* Find the rotation matrix for conversion of position vectors from the IAU_EARTH to the ITRF93 frame. */ pxform_c ( "iau_earth", "itrf93", t, rmat ); for ( j = 0; j < 3; j++ ) { itrfx[j] = rmat[0][j]; itrfz[j] = rmat[2][j]; } /* Display the angular offsets of the ITRF93 +X and +Z axes from their IAU_EARTH counterparts. */ sep = vsep_c ( itrfx, x ); printf ( "ITRF93 - IAU_EARTH +X axis separation angle " "(deg): %13.6f\n", sep * dpr_c() ); sep = vsep_c ( itrfz, z ); printf ( "ITRF93 - IAU_EARTH +Z axis separation angle " "(deg): %13.6f\n\n", sep * dpr_c() ); } /* Find the azimuth and elevation of apparent position of the Moon in the local topocentric reference frame at the DSN station DSS-13. First look up the Moon's position relative to the station in that frame. */ spkpos_c ( "moon", et, "dss-13_topo", "lt+s", "dss-13", topov, <ime ); /* Express the station-Moon direction in terms of longitude and latitude in the DSS-13_TOPO frame. */ reclat_c ( topov, &r, &lon, &lat ); /* Convert to azimuth/elevation. */ az = -lon; if ( az < 0.0 ) { az += twopi_c(); } el = lat; printf ( "DSS-13-Moon az/el using high accuracy " "PCK and DSS-13_TOPO frame:\n" ); printf ( "Moon Az (deg): %15.6f\n" "Moon El (deg): %15.6f\n\n", az * dpr_c(), el * dpr_c() ); /* Find the sub-solar point on the Earth at ET using the Earth body-fixed frame IAU_EARTH. Treat the Sun as the observer. */ subslr_c ( "near point: ellipsoid", "earth", et, "iau_earth", "lt+s", "sun", lsub, &trgepc, srfvec ); /* Display the sub-point in latitudinal coordinates. */ reclat_c ( lsub, &r, &lon, &lat ); printf ( "Sub-Solar point on Earth using low accuracy\n" "PCK and IAU_EARTH frame:\n" "Sub-Solar lon (deg): %15.6f\n" "Sub-Solar lat (deg): %15.6f\n\n", lon * dpr_c(), lat * dpr_c() ); /* Find the sub-solar point on the Earth at ET using the Earth body-fixed frame ITRF93. Treat the Sun as the observer. */ subslr_c ( "near point: ellipsoid", "earth", et, "itrf93", "lt+s", "sun", hsub, &trgepc, srfvec ); /* Display the sub-point in latitudinal coordinates. */ reclat_c ( hsub, &r, &lon, &lat ); printf ( "Sub-Solar point on Earth using high accuracy\n" "PCK and ITRF93 frame:\n" "Sub-Solar lon (deg): %15.6f\n" "Sub-Solar lat (deg): %15.6f\n\n", lon * dpr_c(), lat * dpr_c() ); /* Find the distance between the sub-solar point vectors in km. */ dist = vdist_c( lsub, hsub ); printf ( "Distance between sub-solar points (km): " "%15.6f\n", dist ); return ( 0 ); } 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 |