PHSRM Remote Sensing Hands-On Lesson (C) |
Table of ContentsPHSRM Remote Sensing Hands-On Lesson (C) Overview Note About HTML Links References Tutorials Required Readings The Permuted Index Source Code Header Comments Kernels Used CSPICE Modules Used Time Conversion (convtm) Task Statement Learning Goals Approach Solution Solution Meta-Kernel Solution Source Code Solution Sample Output Obtaining Target States and Positions (getsta) Task Statement Learning Goals Approach Solution Solution Meta-Kernel Solution Source Code Solution Sample Output Spacecraft Orientation and Reference Frames (xform) Task Statement Learning Goals Approach Solution Solution Meta-Kernel Solution Source Code Solution Sample Output Computing Sub-spacecraft and Sub-solar Points (subpts) Task Statement Learning Goals Approach Solution Solution Meta-Kernel Solution Source Code Solution Sample Output Intersecting Vectors with a Triaxial Ellipsoid (fovint) Task Statement Learning Goals Approach Solution Solution Meta-Kernel Solution Source Code Solution Sample Output PHSRM Remote Sensing Hands-On Lesson (C)
Overview
Note About HTML Links
In order for the links to be resolved, 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. ReferencesTutorials
Name Lesson steps/functions it describes --------------- ----------------------------------------- Time Time Conversion SCLK and LSK Time Conversion SPK Obtaining Ephemeris Data Frames Reference Frames Using Frames Reference Frames PCK Planetary Constants Data CK Spacecraft Orientation DataThese tutorials are available from the NAIF ftp server at JPL:
http://naif.jpl.nasa.gov/naif/tutorials.html Required Readings
Name Lesson steps/functions that it describes --------------- ----------------------------------------- time.req Time Conversion sclk.req SCLK Time Conversion spk.req Obtaining Ephemeris Data frames.req Using Reference Frames pck.req Obtaining Planetary Constants Data ck.req Obtaining Spacecraft Orientation Data naif_ids.req Determining Body ID Codes The Permuted Index
This text document provides a simple mechanism to discover what CSPICE functions perform a particular function of interest as well as the name of the source module that contains the function. Source Code Header Comments
For example the source code of the STR2ET/str2et_c routine is
toolkit/src/spicelib/str2et.forin the FORTRAN Toolkit and in
cspice/src/cspice/str2et_c.cin the C Toolkit. Since some of the FORTRAN routines are entry points they are usually 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 naif0009.tls LSK Generic LSK 2 phsrm_201008031645.tsc SCLK PHSRM SCLK 3 de421xs.bsp SPK Solar System Ephemeris 4 phobos_kiam_101231_v00.bsp SPK Phobos Ephemeris 5 phsrm_130114_130114_130214_nom2.bsp SPK PHSRM Spacecraft SPK 6 phsrm_v00.tf FK PHSRM FK 7 phsrm_sc_test2_111108_130214_v00.bc CK PHSRM Spacecraft CK 8 pck00009.tpc PCK Generic PCK 9 phsrm_tsns_v00.ti IK PHSRM TSNS IKThese SPICE kernels are included in the lesson package available from the PHSRM server at IKI:
http://spice.ikiweb.ru/PHSRM/kernels CSPICE Modules Used
CHAPTER EXERCISE FUNCTIONS NON-VOID KERNELS ------- --------- --------- --------- ------- 1 convtm furnsh_c 1,2 prompt_c str2et_c etcal_c timout_c sce2c_c sce2s_c 2 getsta furnsh_c vnorm_c 1,3-6 prompt_c str2et_c spkezr_c spkpos_c convrt_c 3 xform furnsh_c vsep_c 1-8 prompt_c str2et_c spkezr_c sxform_c mxvg_c spkpos_c pxform_c mxv_c convrt_c 4 subpts furnsh_c 1,3-6,8 prompt_c str2et_c subpt_c subsol_c 5 fovint furnsh_c dpr_c 1-9 prompt_c str2et_c bodn2c_c getfov_c sincpt_c reclat_c ilumin_c et2lst_cRefer to the headers of the various functions listed above, as detailed interface specifications are provided with the source code. Time Conversion (convtm)Task Statement
Learning Goals
Approach
When completing the ``calendar format'' step above, consider using one of two possible methods: etcal_c or timout_c. SolutionSolution Meta-Kernel
KPL/MK This is the meta-kernel used in the solution of the ``Time Conversion'' task in the Remote Sensing Hands On Lesson. \begindata KERNELS_TO_LOAD = ( 'kernels/lsk/naif0009.tls', 'kernels/sclk/phsrm_201008031645.tsc' ) \begintext Solution Source Code
#include <stdio.h> /* Standard CSPICE User Include File */ #include "SpiceUsr.h" /* Local Parameters */ #define METAKR "convtm.tm" #define SCLKID -555 #define STRLEN 50 int main (void) { /* Local Variables */ SpiceChar calet [STRLEN]; SpiceChar sclkst [STRLEN]; SpiceChar utctim [STRLEN]; SpiceDouble et; /* Load the kernels this program requires. Both the spacecraft clock kernel and a leapseconds kernel should be listed in the meta-kernel. */ furnsh_c ( METAKR ); /* Prompt the user for the input time string. */ prompt_c ( "Input UTC Time: ", STRLEN, utctim ); printf ( "Converting UTC Time: %s\n", utctim ); /* Convert utctim to ET. */ str2et_c ( utctim, &et ); printf ( " ET Seconds Past J2000: %16.3f\n", et ); /* Now convert ET to a calendar time string. This can be accomplished in two ways. */ etcal_c ( et, STRLEN, calet ); printf ( " Calendar ET (etcal_c): %s\n", calet ); /* Or use timout_c for finer control over the output format. The picture below was built by examining the header of timout_c. */ timout_c ( et, "YYYY-MON-DDTHR:MN:SC ::TDB", STRLEN, calet ); printf ( " Calendar ET (timout_c): %s\n", calet ); /* Convert ET to spacecraft clock time. */ sce2s_c ( SCLKID, et, STRLEN, sclkst ); printf ( " Spacecraft Clock Time: %s\n", sclkst ); return(0); } Solution Sample Output
Converting UTC Time: 2013-02-10 20:40:00 ET Seconds Past J2000: 413800866.185 Calendar ET (etcal_c): 2013 FEB 10 20:41:06.185 Calendar ET (timout_c): 2013-FEB-10T20:41:06 Spacecraft Clock Time: 1/0461:09600000 Obtaining Target States and Positions (getsta)Task Statement
Learning Goals
Approach
When deciding which SPK files to load, the Toolkit utility ``brief'' may be of some use. ``brief'' is located in the ``cspice/exe'' directory for C toolkits. Consult its user's guide available in ``cspice/doc/brief.ug'' for details. SolutionSolution Meta-Kernel
KPL/MK This is the meta-kernel used in the solution of the ``Obtaining Target States and Positions'' task in the Remote Sensing Hands On Lesson. \begindata KERNELS_TO_LOAD = ( 'kernels/lsk/naif0009.tls', 'kernels/spk/de421xs.bsp', 'kernels/spk/phobos_kiam_101231_v00.bsp', 'kernels/spk/phsrm_130114_130114_130214_nom2.bsp' 'kernels/fk/phsrm_v00.tf' ) \begintext Solution Source Code
#include <stdio.h> /* Standard CSPICE User Include File */ #include "SpiceUsr.h" /* Local Parameters */ #define METAKR "getsta.tm" #define STRLEN 50 int main (void) { /* Local Variables */ SpiceChar utctim [STRLEN]; SpiceDouble dist; SpiceDouble et; SpiceDouble ltime; SpiceDouble pos [3]; SpiceDouble state [6]; /* Load the kernels that this program requires. We will need a leapseconds kernel to convert input UTC time strings into ET. We also will need the necessary SPK files with coverage for the bodies in which we are interested. */ furnsh_c ( METAKR ); /* Prompt the user for the input time string. */ prompt_c ( "Input UTC Time: ", STRLEN, utctim ); printf ( "Converting UTC Time: %s\n", utctim ); /* Convert utctim to ET. */ str2et_c ( utctim, &et ); printf ( " ET seconds past J2000: %16.3f\n", et ); /* Compute the apparent state of Phobos as seen from PHSRM in the J2000 frame. All of the ephemeris readers return states in units of kilometers and kilometers per second. */ spkezr_c ( "PHOBOS", et, "J2000", "LT+S", "PHSRM", state, <ime ); printf ( " Apparent state of Phobos as seen " "from PHSRM in the J2000\n" ); printf ( " frame (km, km/s):\n" ); printf ( " X = %16.3f\n", state[0] ); printf ( " Y = %16.3f\n", state[1] ); printf ( " Z = %16.3f\n", state[2] ); printf ( " VX = %16.3f\n", state[3] ); printf ( " VY = %16.3f\n", state[4] ); printf ( " VZ = %16.3f\n", state[5] ); /* Compute the apparent position of Earth as seen from PHSRM in the J2000 frame. Note: We could have continued using spkezr_c and simply ignored the velocity components. */ spkpos_c ( "EARTH", et, "J2000", "LT+S", "PHSRM", pos, <ime ); printf ( " Apparent position of Earth as " "seen from PHSRM in the J2000\n" ); printf ( " frame (km): \n" ); printf ( " X = %16.3f\n", pos[0] ); printf ( " Y = %16.3f\n", pos[1] ); printf ( " Z = %16.3f\n", pos[2] ); /* We need only display LTIME, as it is precisely the light time in which we are interested. */ printf ( " One way light time between PHSRM and " "the apparent position\n" ); printf ( " of Earth (seconds): %16.3f\n", ltime ); /* Compute the apparent position of the Sun as seen from Phobos in the J2000 frame. */ spkpos_c ( "SUN", et, "J2000", "LT+S", "PHOBOS", pos, <ime ); printf ( " Apparent position of Sun as seen " "from Phobos in the\n" ); printf ( " J2000 frame (km): \n" ); printf ( " X = %16.3f\n", pos[0] ); printf ( " Y = %16.3f\n", pos[1] ); printf ( " Z = %16.3f\n", pos[2] ); /* Now we need to compute the actual distance between the Sun and Phobos. The above SPKPOS call gives us the apparent distance, so we need to adjust our aberration correction appropriately. */ spkpos_c ( "SUN", et, "J2000", "NONE", "PHOBOS", pos, <ime ); /* Compute the distance between the body centers in kilometers. */ dist = vnorm_c ( pos ); /* Convert this value to AU using convrt_c. */ convrt_c ( dist, "KM", "AU", &dist ); printf ( " Actual distance between Sun and " "Phobos body centers:\n" ); printf ( " (AU): %16.3f\n", dist ); return(0); } Solution Sample Output
Converting UTC Time: 2013-02-10 20:40:00 ET seconds past J2000: 413800866.185 Apparent state of Phobos as seen from PHSRM in the J2000 frame (km, km/s): X = 43.646 Y = 5.698 Z = -20.731 VX = 0.008 VY = -0.002 VZ = -0.005 Apparent position of Earth as seen from PHSRM in the J2000 frame (km): X = -318212438.123 Y = 123091882.078 Z = 59808626.721 One way light time between PHSRM and the apparent position of Earth (seconds): 1155.441 Apparent position of Sun as seen from Phobos in the J2000 frame (km): X = -201733820.746 Y = 39838264.775 Z = 23717367.433 Actual distance between Sun and Phobos body centers: (AU): 1.384 Spacecraft Orientation and Reference Frames (xform)Task Statement
Learning Goals
Approach
You may find it useful to consult the permuted index, the headers of various source modules, and the following toolkit documentation:
SolutionSolution Meta-Kernel
KPL/MK This is the meta-kernel used in the solution of the ``Spacecraft Orientation and Reference Frames'' task in the Remote Sensing Hands On Lesson. \begindata KERNELS_TO_LOAD = ( 'kernels/lsk/naif0009.tls', 'kernels/sclk/phsrm_201008031645.tsc', 'kernels/spk/de421xs.bsp', 'kernels/spk/phobos_kiam_101231_v00.bsp', 'kernels/spk/phsrm_130114_130114_130214_nom2.bsp', 'kernels/fk/phsrm_v00.tf', 'kernels/ck/phsrm_sc_test2_111108_130214_v00.bc', 'kernels/pck/pck00009.tpc' ) \begintext Solution Source Code
#include <stdio.h> /* Standard CSPICE User Include File */ #include "SpiceUsr.h" /* Local Parameters */ #define METAKR "xform.tm" #define STRLEN 50 int main (void) { /* Local Variables */ SpiceChar utctim [STRLEN]; SpiceDouble et; SpiceDouble ltime; SpiceDouble state [6]; SpiceDouble bfixst [6]; SpiceDouble pos [3]; SpiceDouble sform [6][6]; SpiceDouble pform [3][3]; SpiceDouble bsight [3]; SpiceDouble sep; /* Load the kernels that this program requires. We will need: A leapseconds kernel A spacecraft clock kernel for PHSRM The necessary ephemerides A planetary constants file (PCK) A spacecraft orientation kernel for PHSRM (CK) A frame kernel (TF) */ furnsh_c ( METAKR ); /* Prompt the user for the input time string. */ prompt_c ( "Input UTC Time: ", STRLEN, utctim ); printf ( "Converting UTC Time: %s\n", utctim ); /* Convert utctim to ET. */ str2et_c ( utctim, &et ); printf ( " ET seconds past J2000: %16.3f\n", et ); /* Compute the apparent state of Phobos as seen from PHSRM in the J2000 reference frame. */ spkezr_c ( "PHOBOS", et, "J2000", "LT+S", "PHSRM", state, <ime ); /* Now obtain the transformation from the inertial J2000 frame to the non-inertial body-fixed IAU_PHOBOS frame. Since we want the apparent position, we need to subtract ltime from et. */ sxform_c ( "J2000", "IAU_PHOBOS", et-ltime, sform ); /* Now rotate the apparent J2000 state into IAU_PHOBOS with the following matrix multiplication: */ mxvg_c ( sform, state, 6, 6, bfixst ); /* Display the results. */ printf ( " Apparent state of Phobos as seen " "from PHSRM in the IAU_PHOBOS\n" ); printf ( " body-fixed frame (km, km/s):\n"); printf ( " X = %19.6f\n", bfixst[0] ); printf ( " Y = %19.6f\n", bfixst[1] ); printf ( " Z = %19.6f\n", bfixst[2] ); printf ( " VX = %19.6f\n", bfixst[3] ); printf ( " VY = %19.6f\n", bfixst[4] ); printf ( " VZ = %19.6f\n", bfixst[5] ); /* It is worth pointing out, all of the above could have been done with a single use of spkezr_c: */ spkezr_c ( "PHOBOS", et, "IAU_PHOBOS", "LT+S", "PHSRM", state, <ime ); /* Display the results. */ printf ( " Apparent state of Phobos as seen " "from PHSRM in the IAU_PHOBOS\n" ); printf ( " body-fixed frame (km, km/s) " "obtained using spkezr_c directly:\n" ); printf ( " X = %19.6f\n", state[0] ); printf ( " Y = %19.6f\n", state[1] ); printf ( " Z = %19.6f\n", state[2] ); printf ( " VX = %19.6f\n", state[3] ); printf ( " VY = %19.6f\n", state[4] ); printf ( " VZ = %19.6f\n", state[5] ); /* Note that the velocity found by using spkezr_c to compute the state in the IAU_PHOBOS frame differs at the few mm/second level from that found previously by calling spkezr_c and then sxform_c. Computing velocity via a single call to spkezr_c as we've done immediately above is slightly more accurate because it accounts for the effect of the rate of change of light time on the apparent angular velocity of the target's body-fixed reference frame. Now we are to compute the angular separation between the apparent position of the Sun as seen from the spacecraft and the normal vector of the solar array. First, compute the apparent position of the Sun as seen from PHSRM in the J2000 frame. */ spkpos_c ( "SUN", et, "J2000", "LT+S", "PHSRM", pos, <ime ); /* Now set the direction of the solar array normal at this same epoch. From reading the frame kernel we know that the solar array normal is nominally the +X axis of the PHSRM_SPACECRAFT frame defined there. */ bsight[0] = 1.0; bsight[1] = 0.0; bsight[2] = 0.0; /* Now compute the rotation matrix from PHSRM_SPACECRAFT into J2000. */ pxform_c ( "PHSRM_SPACECRAFT", "J2000", et, pform ); /* And multiply the result to obtain the nominal solar array normal in the J2000 reference frame. */ mxv_c ( pform, bsight, bsight ); /* Lastly compute the angular separation. */ convrt_c ( vsep_c(bsight, pos), "RADIANS", "DEGREES", &sep ); printf ( " Angular separation between the " "apparent position of\n" ); printf ( " Sun and the PHSRM " "solar array normal (degrees):\n"); printf ( " %16.3f\n", sep ); /* Or alternatively we can work in the spacecraft frame directly. */ spkpos_c ( "SUN", et, "PHSRM_SPACECRAFT", "LT+S", "PHSRM", pos, <ime ); /* the solar array normal is the X-axis in the PHSRM_SPACECRAFT frame. */ bsight[0] = 1.0; bsight[1] = 0.0; bsight[2] = 0.0; /* Lastly compute the angular separation. */ convrt_c ( vsep_c(bsight, pos), "RADIANS", "DEGREES", &sep ); printf ( " Angular separation between the " "apparent position of\n" ); printf ( " Sun and the PHSRM " "solar array normal computed\n" ); printf ( " using vectors in the PHSRM_SPACECRAFT " "frame (degrees):\n" ); printf ( " %16.3f\n", sep ); return(0); } Solution Sample Output
Converting UTC Time: 2013-02-10 20:40:00 ET seconds past J2000: 413800866.185 Apparent state of Phobos as seen from PHSRM in the IAU_PHOBOS body-fixed frame (km, km/s): X = 32.950479 Y = -35.796727 Z = -0.250178 VX = -0.004507 VY = -0.016033 VZ = -0.000054 Apparent state of Phobos as seen from PHSRM in the IAU_PHOBOS body-fixed frame (km, km/s) obtained using spkezr_c directly: X = 32.950479 Y = -35.796727 Z = -0.250178 VX = -0.004507 VY = -0.016033 VZ = -0.000054 Angular separation between the apparent position of Sun and the PHSRM solar array normal (degrees): 25.807 Angular separation between the apparent position of Sun and the PHSRM solar array normal computed using vectors in the PHSRM_SPACECRAFT frame (degrees): 25.807 Computing Sub-spacecraft and Sub-solar Points (subpts)Task Statement
Learning Goals
Approach
One point worth considering: Which method do you want to use to compute the sub-solar (or sub-observer) point? SolutionSolution Meta-Kernel
KPL/MK This is the meta-kernel used in the solution of the ``Computing Sub-spacecraft and Sub-solar Points'' task in the Remote Sensing Hands On Lesson. \begindata KERNELS_TO_LOAD = ( 'kernels/lsk/naif0009.tls', 'kernels/spk/de421xs.bsp', 'kernels/spk/phobos_kiam_101231_v00.bsp', 'kernels/spk/phsrm_130114_130114_130214_nom2.bsp', 'kernels/pck/pck00009.tpc' 'kernels/fk/phsrm_v00.tf' ) \begintext Solution Source Code
#include <stdio.h> /* Standard CSPICE User Include File */ #include "SpiceUsr.h" /* Local Parameters */ #define METAKR "subpts.tm" #define STRLEN 50 int main (void) { /* Local Variables */ SpiceChar utctim [STRLEN]; SpiceDouble et; SpiceDouble spoint [3]; SpiceDouble srfvec [3]; SpiceDouble trgepc; /* Load the kernels that this program requires. We will need: A leapseconds kernel The necessary ephemerides A planetary constants file (PCK) */ furnsh_c ( METAKR ); /* Prompt the user for the input time string. */ prompt_c ( "Input UTC Time: ", STRLEN, utctim ); printf ( "Converting UTC Time: %s\n", utctim ); /* Convert utctim to ET. */ str2et_c ( utctim, &et ); printf ( " ET seconds past J2000: %16.3f\n", et ); /* Compute the apparent sub-observer point of PHSRM on Phobos. */ subpnt_c ( "NEAR POINT: ELLIPSOID", "PHOBOS", et, "IAU_PHOBOS", "LT+S", "PHSRM", spoint, &trgepc, srfvec ); printf ( " Apparent sub-observer point of PHSRM " "on Phobos in the\n" ); printf ( " IAU_PHOBOS frame (km):\n" ); printf ( " X = %16.3f\n", spoint[0] ); printf ( " Y = %16.3f\n", spoint[1] ); printf ( " Z = %16.3f\n", spoint[2] ); printf ( " ALT = %16.3f\n", vnorm_c(srfvec) ); /* Compute the apparent sub-solar point on Phobos as seen from PHSRM. */ subslr_c ( "NEAR POINT: ELLIPSOID", "PHOBOS", et, "IAU_PHOBOS", "LT+S", "PHSRM", spoint, &trgepc, srfvec ); printf ( " Apparent sub-solar point on Phobos " "as seen from PHSRM in\n" ); printf ( " the IAU_PHOBOS frame (km):\n" ); printf ( " X = %16.3f\n", spoint[0] ); printf ( " Y = %16.3f\n", spoint[1] ); printf ( " Z = %16.3f\n", spoint[2] ); return(0); } Solution Sample Output
Converting UTC Time: 2013-02-10 20:40:00 ET seconds past J2000: 413800866.185 Apparent sub-observer point of PHSRM on Phobos in the IAU_PHOBOS frame (km): X = -9.501 Y = 7.897 Z = 0.040 ALT = 36.446 Apparent sub-solar point on Phobos as seen from PHSRM in the IAU_PHOBOS frame (km): X = -7.904 Y = 8.282 Z = -2.986 Intersecting Vectors with a Triaxial Ellipsoid (fovint)Task Statement
At each point of intersection compute the following:
Use this program to compute values at the epoch:
Learning Goals
Approach
SolutionSolution Meta-Kernel
KPL/MK This is the meta-kernel used in the solution of the ``Intersecting Vectors with a Triaxial Ellipsoid'' task in the Remote Sensing Hands On Lesson. \begindata KERNELS_TO_LOAD = ( 'kernels/lsk/naif0009.tls', 'kernels/sclk/phsrm_201008031645.tsc', 'kernels/spk/de421xs.bsp', 'kernels/spk/phobos_kiam_101231_v00.bsp', 'kernels/spk/phsrm_130114_130114_130214_nom2.bsp', 'kernels/fk/phsrm_v00.tf', 'kernels/ck/phsrm_sc_test2_111108_130214_v00.bc', 'kernels/pck/pck00009.tpc', 'kernels/ik/phsrm_tsns_v00.ti' ) \begintext Solution Source Code
#include <stdio.h> /* Standard CSPICE User Include File */ #include "SpiceUsr.h" #include <stdlib.h> /* Local Parameters */ #define METAKR "fovint.tm" #define STRLEN 50 #define BCVLEN 5 int main (void) { /* Local Variables */ SpiceChar ampm [STRLEN]; SpiceChar insfrm [STRLEN]; SpiceChar shape [STRLEN]; SpiceChar time [STRLEN]; SpiceChar utctim [STRLEN]; SpiceChar *vecnam[] = { "Boundary Corner 1", "Boundary Corner 2", "Boundary Corner 3", "Boundary Corner 4", "PHSRM TSNS NAC 1 Boresight" }; SpiceDouble bounds [BCVLEN][3]; SpiceDouble bsight [3]; SpiceDouble emissn; SpiceDouble et; SpiceDouble lat; SpiceDouble lon; SpiceDouble phase; SpiceDouble point [3]; SpiceDouble radius; SpiceDouble solar; SpiceDouble srfvec [3]; SpiceDouble trgepc; SpiceInt hr; SpiceInt i; SpiceInt mn; SpiceInt n; SpiceInt nacid; SpiceInt phoeid; SpiceInt sc; SpiceBoolean found; /* Load the kernels that this program requires. We will need: A leapseconds kernel. A SCLK kernel for PHSRM. Any necessary ephemerides. The PHSRM frame kernel. A PHSRM C-kernel. A PCK file with Phobos constants. The PHSRM TSNS I-kernel. */ furnsh_c ( METAKR ); /* Prompt the user for the input time string. */ prompt_c ( "Input UTC Time: ", STRLEN, utctim ); printf ( "Converting UTC Time: %s\n", utctim ); /* Convert utctim to ET. */ str2et_c ( utctim, &et ); printf ( " ET seconds past J2000: %16.3f\n", et ); /* Now we need to obtain the FOV configuration of the TSNS NAC 1 camera. To do this we will need the ID code for PHSRM_TSNS_NAC_1. */ bodn2c_c ( "PHSRM_TSNS_NAC_1", &nacid, &found ); /* Stop the program if the code was not found. */ if ( !found ) { printf ( "Unable to locate the ID code for " "PHSRM_TSNS_NAC_1\n" ); exit ( EXIT_FAILURE ); } /* Now retrieve the field of view parameters. */ getfov_c ( nacid, BCVLEN, STRLEN, STRLEN, shape, insfrm, bsight, &n, bounds ); /* Rather than treat BSIGHT as a separate vector, copy it into the last slot of BOUNDS. */ for ( i=0; i<3; i++ ) { bounds[4][i] = bsight[i]; } /* Now perform the same set of calculations for each vector listed in the BOUNDS array. */ for ( i=0; i<5; i++ ) { /* Call sincpt_c to determine coordinates of the intersection of this vector with the surface of Phobos. */ sincpt_c ( "Ellipsoid", "PHOBOS", et, "IAU_PHOBOS", "LT+S", "PHSRM", insfrm, bounds[i], point, &trgepc, srfvec, &found ); /* Check the found flag. Display a message if the point of intersection was not found, otherwise continue with the calculations. */ printf ( "Vector: %s\n", vecnam[i] ); if ( !found ) { printf ( "No intersection point found at " "this epoch for this vector.\n" ); } else { /* Now, we have discovered a point of intersection. Start by displaying the position vector in the IAU_PHOBOS frame of the intersection. */ printf ( " Position vector of surface intercept " "in the IAU_PHOBOS frame (km):\n" ); printf ( " X = %16.3f\n", point[0] ); printf ( " Y = %16.3f\n", point[1] ); printf ( " Z = %16.3f\n", point[2] ); /* Display the planetocentric latitude and longitude of the intercept. */ reclat_c ( point, &radius, &lon, &lat ); printf ( " Planetocentric coordinates of " "the intercept (degrees):\n" ); printf ( " LAT = %16.3f\n", lat * dpr_c() ); printf ( " LON = %16.3f\n", lon * dpr_c() ); /* Compute the illumination angles at this point. */ ilumin_c ( "Ellipsoid", "PHOBOS", et, "IAU_PHOBOS", "LT+S", "PHSRM", point, &trgepc, srfvec, &phase, &solar, &emissn ); printf ( " Phase angle (degrees): " "%16.3f\n", phase * dpr_c() ); printf ( " Solar incidence angle (degrees): " "%16.3f\n", solar * dpr_c() ); printf ( " Emission angle (degrees): " "%16.3f\n", emissn * dpr_c() ); } printf ( "\n" ); } /* Lastly compute the local solar time at the boresight intersection. */ if ( found ) { /* Get ID code of Phobos. */ bodn2c_c ( "PHOBOS", &phoeid, &found ); /* The ID code for PHOBOS is built-in to the library. However, it is good programming practice to get in the habit of checking your found-flags. */ if ( !found ) { printf ( "Unable to locate the body ID code " "for Phobos.\n" ); exit ( EXIT_FAILURE ); } /* Compute local solar time corresponding to the TDB light time corrected epoch at the intercept. */ et2lst_c ( trgepc, phoeid, lon, "PLANETOCENTRIC", STRLEN, STRLEN, &hr, &mn, &sc, time, ampm ); printf ( " Local Solar Time at boresight " "intercept (24 Hour Clock):\n" ); printf ( " %s\n", time ); } else { printf ( " No boresight intercept to " "compute local solar time.\n" ); } return(0); } Solution Sample Output
Converting UTC Time: 2013-02-10 20:40:00 ET seconds past J2000: 413800866.185 Vector: Boundary Corner 1 Position vector of surface intercept in the IAU_PHOBOS frame (km): X = -7.873 Y = 9.060 Z = -0.203 Planetocentric coordinates of the intercept (degrees): LAT = -0.971 LON = 130.989 Phase angle (degrees): 26.338 Solar incidence angle (degrees): 22.465 Emission angle (degrees): 12.132 Vector: Boundary Corner 2 Position vector of surface intercept in the IAU_PHOBOS frame (km): X = -7.889 Y = 9.044 Z = 0.340 Planetocentric coordinates of the intercept (degrees): LAT = 1.622 LON = 131.101 Phase angle (degrees): 25.527 Solar incidence angle (degrees): 26.790 Emission angle (degrees): 12.108 Vector: Boundary Corner 3 Position vector of surface intercept in the IAU_PHOBOS frame (km): X = -8.355 Y = 8.748 Z = 0.316 Planetocentric coordinates of the intercept (degrees): LAT = 1.498 LON = 133.684 Phase angle (degrees): 25.279 Solar incidence angle (degrees): 26.523 Emission angle (degrees): 8.968 Vector: Boundary Corner 4 Position vector of surface intercept in the IAU_PHOBOS frame (km): X = -8.338 Y = 8.764 Z = -0.226 Planetocentric coordinates of the intercept (degrees): LAT = -1.068 LON = 133.574 Phase angle (degrees): 26.096 Solar incidence angle (degrees): 22.151 Emission angle (degrees): 9.076 Vector: PHSRM TSNS NAC 1 Boresight Position vector of surface intercept in the IAU_PHOBOS frame (km): X = -8.120 Y = 8.909 Z = 0.057 Planetocentric coordinates of the intercept (degrees): LAT = 0.270 LON = 132.344 Phase angle (degrees): 25.807 Solar incidence angle (degrees): 24.456 Emission angle (degrees): 10.241 Local Solar Time at boresight intercept (24 Hour Clock): 12:34:36 |