SPEDE Instrument kernel =========================================================================== This instrument kernel (I-kernel) contains SMART-1 Spacecraft Potential, Electron and Dust Experiment (SPEDE) Sun Avoidance Field-of-View. Version and Date --------------------------------------------------------------------------- Version 2.0 -- December 22, 2005 -- Jorge Diaz del Rio, RSSD/ESA FORTRAN and C IK Code examples included. Comment area improved. Version 1.0 -- November 30, 2005 -- Jorge Diaz del Rio, RSSD/ESA Correction in the sign of the field-of-view vectors of SPEDE-X sensor. Typo corrected in the SPEDE frame names. Version 0.0 -- February 16, 2005 -- Jorge Diaz del Rio, RSSD/ESA Preliminary Version. Pending review and approval by SPEDE instrument team. References --------------------------------------------------------------------------- 1. ``Kernel Pool Required Reading'' 2. ``C-kernel Required Reading'' 3. ``SPEDE Experiment ICD'', S1-SPE-EID-3001, Issue 3.0, September 25, 2001. 4. SMART-1 Frames Definition Kernel (FK), latest version. 5. Email from Walter Schmidt, 14 Feb 2005, containing the SMART-1 wire-model coordinates obtained from the Plasma Modeling working group of the 2004 SPINE workshop. Implementation Notes -------------------------------------------------------- Applications that need SPICE I-kernel data must ``load'' the I-kernel file, normally during program initialization. Loading the kernel using the SPICELIB routine FURNSH causes the data items and their associated values present in the kernel to become associated with a data structure called the ``kernel pool.'' The application program may then obtain the value(s) for any IK data item using the SPICELIB routines GDPOOL, GIPOOL, GCPOOL. The GETFOV routine may also be used if the file contains instrument field-of-view (FOV) specifications. See [1] for details. This file was created with, and can be updated with a text editor or word processor. Conventions for Specifying Data -------------------------------------------------------- Data items are specified using ``keyword=value'' assignments [1]. All keywords referencing values in this I-kernel start with the characters `INS' followed by the NAIF SMART-1 instrument ID code, constructed using the spacecraft ID number, -238, followed by the NAIF three digit ID number for SPEDE booms (600 and 610). These IDs are defined in [4] as follows: Instrument name ID -------------------- ------- SMART1_SPEDE+X -238600 SMART1_SPEDE-X -238610 The remainder of the keyword is an underscore character followed by the unique name of the data item. For example, the SPEDE +X boom sun avoidance field-of-view shape is specified by: INS-238600_FOV_SHAPE The upper bound on the length of all keywords is 32 characters. If a keyword is included in more then one file, or if the same keyword appears more than once within a single file, the last assignment supersedes any earlier assignments. Instrument Overview -------------------------------------------------------- From [TBD]: "SPEDE description. To be copied from TBD source provided by the SPEDE team." Mounting Alignment -------------------------------------------------------- Refer to the latest version of the SMART-1 Frames Definition Kernel (FK) [4] for the SPEDE reference frame definitions and mounting alignment information. Sun Avoidance FOV Definitions --------------------------------------------------------------------------- This section contains assignments defining the SPEDE sun avoidance field-of-view. These definitions are based on the SPEDE booms mounting information provided in [5]. The analysis of data from plasma instruments requires continuous knowledge of the orientation of the sensor with respect to the incident sun light, i.e. it is required to know whether or not the sun light is illuminating the sensor since this might affect the read-outs of the instrument due to, e.g., thermal constraints. The geometry of the S/C side panels and the position of the SPEDE booms are required to identify in which cases the sun is illuminating the SPEDE sensor. The sun avoidance field-of-view has been implemented to help in the identification such cases. The SPEDE booms are rigidly mounted on both the +X and -X sides of the Spacecraft. One boom is in shadow whenever the spacecraft bus is between the tip of the boom and the light coming from the sun. The sun avoidance field of view defines a easy way to determine whether or not a sensor is shaded by the spacecraft bus, by computing the times when the sun is partially inside the field-of-view. For an example of how to compute this event, please refer to the section ''IK Code Example'' at the end of this file. The sun avoidance field of view is defined by a pyramid whose vertex is located along the boom's +Z axis, placed slightly above the boom's tip to guarantee that the complete sensor is in shadow. The pyramid's base is defined by the spacecraft deck where the boom is mounted on. Therefore, the sun avoidance field of view is a fake rectangular shaped field of view, whose boresight is points from the sensor toward the spacecraft. The dimensions the spacecraft deck where the boom is mounted plus the length of the boom itself define the angular size of this sun avoidance field of view. The following diagrams describe the position of the +X boom and sensor and how field-of-view is defined. Both diagrams show the SPEDE +X sensor reference frame and the real dimensions of the +X spacecraft deck and boom. +X Panel View (Z-Y Plane) ------------------------- (A) .----------------x----------------. | | | .---..-----. | | | .-----..---. | \\ \ | 0.380 | / // | | // \ | | | / \\ | | \\ \ /| | |\ / // | | // |===||-----0.555------O-------0.555----||===| \\ | | \\ / \| SPEDE Boom |/ \ // | | // / | | \ \\ | | \\ / | | \ // | `---''-----' | | `-----``---' | | | | | | `---------------------------------' <-----o +Zsp+x +Ysp+x | | | v +Xsp+x +Zsp+x is out of the page. +Y Panel View (X-Z Plane) ------------------------- ------x. | | `. | | . `. | |' `. | | 58.4 `. 0.369| `. | | `. Edge of the | | `. imaginary | | `. pyramid | | `. ---|------------------.`. 0.022|------------------|--o(V) <------ ---|------------------' | Boresight | | +X SPEDE Boom | | direction | | | | | | | | | | | | | | | | 0.514|----- 0.600 ------| | | | | +Zsp+x | | | o----> | |-------- pyh --------| | | | | | | v +Xsp+x ------x +Ysp+x is out of the page. By using the point (A), it is possible to compute the precise altitude of the pyramid's vertex (V) with respect to the S/C X panel. This vertex will also define the origin of the boom's frame. It can be computed as follows: 0.600 x 0.380 pyh = -------------------- x 1000 = 617.886245 mm. 0.369 The situation for the -X panel can be described by the same diagrams as for the +X panel, the only difference being the orientation of the SPEDE -X boom frame (SMART1_SPEDE-X). As seen in the diagrams, the boresight direction of the Sun Avoidance Field-of-View is opposite to the +Z-axis of the SPEDE Boom frame. Using the information described above, and taking into account that the SMART1_SPEDE+X and SMART1_SPEDE-X frames are rotated 180 degrees around the +Y axis with respect to one another, it is possible to define the following corner points for each of the boom's Sun Avoidance Field-of-Views (values in millimeters): Boom | #Corner | X | Y | Z ------------------------------------------------------------------ SPEDE +X | 1 | -380.000 | 555.000 | -617.886245 | 2 | 525.000 | 555.000 | -617.886245 | 3 | 525.000 | -555.000 | -617.886245 | 4 | -380.000 | -555.000 | -617.886245 ------------------------------------------------------------------ SPEDE -X | 1 | 380.000 | 555.000 | -617.886245 | 2 | -525.000 | 555.000 | -617.886245 | 3 | -525.000 | -555.000 | -617.886245 | 4 | 380.000 | -555.000 | -617.886245 ------------------------------------------------------------------ \begindata INS-238600_FOV_FRAME = 'SMART1_SPEDE+X' INS-238600_FOV_SHAPE = 'RECTANGLE' INS-238600_BORESIGHT = ( 0.0 0.0 -617.886245 ) INS-238600_FOV_BOUNDARY_CORNERS = ( -380.000 555.000 -617.886245 525.000 555.000 -617.886245 525.000 -555.000 -617.886245 -380.000 -555.000 -617.886245 ) INS-238610_FOV_FRAME = 'SMART1_SPEDE-X' INS-238610_FOV_SHAPE = 'RECTANGLE' INS-238610_BORESIGHT = ( 0.0 0.0 -617.886245 ) INS-238610_FOV_BOUNDARY_CORNERS = ( 380.000 555.000 -617.886245 -525.000 555.000 -617.886245 -525.000 -555.000 -617.886245 380.000 -555.000 -617.886245 ) \begintext Platform ID --------------------------------------------------------------------------- This number is the NAIF instrument ID of the platform on which the instrument is mounted. Both SPEDE booms are mounted directly on the spacecraft bus, so the IDs are the same. \begindata INS-238600_PLATFORM_ID = ( -238000 ) INS-238610_PLATFORM_ID = ( -238000 ) \begintext IK Code Example --------------------------------------------------------------------------- This section contains an example code, in Interactive Data Language (IDL), C and FORTRAN, illustrating how the Sun Avoidance Field-of-View can be used to determine whether the Sun is illuminating a SPEDE Boom or not. The examples are presented as stand-alone functions with SPICE-style header, ready to be cut-n-paste and called from an application. IDL Example [TBW] C Example /* -Procedure shadow ( Find whether or not the SPEDE sensor is in shadow ) -Abstract Determine whether or not a given SPEDE sensor is shaded by the Earth, the Moon or any of the spacecraft structures -- spacecraft bus or solar panels -- -Required_Reading KERNEL Required Reading (kernel.req) CK Required Reading (ck.req) SPK Required Reading (spk.req) Latest SPEDE IK File (SMART1_SPEDE_Vxx.TI -- version 2 or later ) Latest SMART-1 FK File (SMART1_Vxx.TF -- version 8 or later ) -Keywords GEOMETRY */ #include #include "SpiceUsr.h" SpiceBoolean shadow ( ConstSpiceChar * sensor, SpiceDouble time ) /* -Brief_I/O VARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- sensor I SPEDE sensor name time I Time at which to evaluate the condition. shadow O SPICETRUE if SENSOR is in shadow, SPICEFALSE otherwise. -Detailed_Input sensor is the full NAIF name of the SPEDE sensor. For example, SMART1_SPEDE+X or SMART1_SPEDE-X time is the time at which to evaluate the condition, expressed as seconds past J2000 TDB. -Detailed_Output shadow is a logical flag indicating the state of the sensor. If the sensor is in shadow at the epoch TIME, "shadow" is returned with the value SPICETRUE. Otherwise it is returned with the value SPICEFALSE. -Paramters ROOM is the amount of room allocated for the boundary vectors of the 'Sun-avoidance-Field-of-view'. This FoV has 4 vectors. FRMLN is the maximum character string length for NAIF frame names. This number is 32 characters. SHAPLN is the maximum character string length for NAIF field-of-view shape identifiers as required by the getfov_c routine. This number is 32 characters. KWDLN is the maximum character string length for NAIF keywords. This number is 32 characters. -Exceptions 1) The error 'NOIDMAPPINGDATA' is signaled if NAIF name <-> ID mapping for SMART-1 instruments provided in the SMART-1 FK file have not been loaded, or if there is no instrument ID associated with the input SENSOR name. 2) If the SPEDE IK file is not loaded, an error will be signaled by the CSPICE routine (getfov_c) called by this routine. 3) If there is not enough data to compute the position of the Sun, Earth and/or Moon with respect to the SENSOR in the sensor's frame, an error will be signaled by the SPICE SPK/FK/CK subsystem. 4) If there is no PCK containing constants for the Sun, Earth and Moon, an error will be signaled by the CSPICE routine (bodvrd_c) called by this routine. 5) If there is no SPK and/or CK data for the SMART-1 Solar Panels, an error will be signaled by the SPICE SPK/FK/CK subsystem. -Files 1) SMART-1 FK and SPEDE IK files must be loaded prior to calling this subroutine. 2) SPK data for the Sun, Earth, Moon, SMART-1 spacecraft and SMART-1 spacecraft structures (SPEDE sensors and Solar Panels) must be loaded prior to calling this subroutine. 3) CK data for the SMART-1 spacecraft and SMART-1 Solar Panels must be loaded prior to calling this subroutine. 4) PCK file containing the Sun, Earth, and Moon radii must be loaded prior to calling this subroutine. 5) Since the CK subsystem is used, an SMART-1 SCLK file must be loaded prior to calling this subroutine. -Particulars This routine determines whether or not the SPEDE sensor is shaded by any of the spacecraft structures or the Earth or the Moon. All bodies -- Sun, Earth and Moon -- are regarded as being spherical. The Sun and the Moon are already spheres in the IAU tri-axial model provided in SPICE PCK files. The radius of the spherical Earth is considered to be the smallest radius of those given by the IAU tri-axial model. Under this assumption, the routine will return SPICEFALSE for some case where, if using a tri-axial ellipsoid model instead of the spherical one, the sensor would be in shadow. The Solar Panels are considered to have zero millimeters thickness, which means that this routine will return SPICEFALSE for some case where, if using the real thickness of the solar panels, the sensor would be in shadow. -Examples /. In this example, the routine checks whether the SPEDE sensor on the -X boom is in shadow or not, starting at June 1, 2004 UTC with a time step of 1 hour,over 100 iterations. ./ #include #include "SpiceUsr.h" SpiceBoolean shadow ( ConstSpiceChar * sensor, SpiceDouble time ); int main( int argc, char * argv[] ) { /. Local Constants ./ #define sensor "SMART1_SPEDE-X" #define tbeg "2004-06-01T00:00:00" #define step 3600.0 #define maxitr 100 /. Local Variables ./ SpiceChar strtim[20]; SpiceDouble time; SpiceInt i ; /. Load the required LSK and SCLK files: ./ furnsh_c ( "../lsk/NAIF0008.TLS" ); furnsh_c ( "../sclk/SMART1_051207_FAKE.TSC" ); /. Load the required SPK files: - SPK for the Sun, Earth and Moon. - SMART-1 spacecraft - SMART-1 spacecraft structures ( SPEDE sensors and Solar Panels ) ./ furnsh_c ( "../spk/DE405S.BSP" ); furnsh_c ( "../spk/ORES_______________00125.BSP" ); furnsh_c ( "../spk/SMART1_STRUCT_V01.BSP" ); /. Load the required CK files: - SMART-1 spacecraft - SMART-1 Solar Panels ./ furnsh_c ( "../ck/ATNS_P030929010023_00188.BC" ); furnsh_c ( "../ck/SMART1_SA_040601_001.BC" ); /. Load the required PCK files: - Generic PCK file. ./ furnsh_c ( "../pck/PCK00008.TPC" ); /. Load the required FK and IK files: - SMART-1 FK, version v08 or later. - SPEDE IK, version v02 or later ./ furnsh_c ( "../fk/SMART1_V08.TF" ); furnsh_c ( "SMART1_SPEDE_V02.TI" ); /. Convert the start time to Ephemeris Time (ET) ./ str2et_c ( tbeg, &time ); for ( i = 0 ; i < maxitr ; i++ ) { et2utc_c ( time, "ISOC", 0, 20, strtim ); if ( shadow ( sensor, time ) ) { printf("SENSOR IN SHADOW %s\n", strtim ); } else { printf("SENSOR IN SUN-LIGHT %s\n", strtim ); } time += step; } return ( 0 ); } -Restrictions None. -Literature_References None. -Author_and_Institution J. Diaz del Rio (RSSD/ESA) -Version -SHADOW Version 1.0.0, 20-DEC-2005 (JDR) -& */ { /* Begin shadow */ /* Local Parameters */ #define ROOM 4 #define FRMLN 32 #define SHAPLN 32 #define KWDLN 32 /* Local Constants */ ConstSpiceChar *sapt[KWDLN] = { "S/C", "SA+Y", "SA-Y" }; ConstSpiceChar *body[KWDLN] = { "EARTH", "MOON" }; ConstSpiceDouble y[3] = { 0.0, 1.0, 0.0 }; /* Local Variables */ SpiceChar frame[FRMLN]; SpiceChar corner[KWDLN]; SpiceChar saname[KWDLN]; SpiceChar shape[SHAPLN]; /* We will have 3 different boresights: one from the Sun-Avoidance FoV and another two from the Solar Panel-Sensor vectors. */ SpiceDouble bsight[3][3]; /* We will have also 3 different boundary vectors sets, one for each bsight */ SpiceDouble bvects[3][ROOM][3]; SpiceDouble lt ; SpiceDouble nvect1[3]; SpiceDouble nvect2[3]; SpiceDouble bodang; SpiceDouble bodpos[3]; SpiceDouble radii[3]; SpiceDouble radius; SpiceDouble sun[3]; SpiceDouble sunang; SpiceInt i; SpiceInt instid; SpiceInt j; SpiceInt k; SpiceInt loc; SpiceInt n; SpiceInt nbv[3]; SpiceBoolean found; SpiceBoolean next; /* Standard CSPICE error handling. */ if ( return_c () ) return; else chkin_c ( "shadow" ); /* Get the Instrument ID associated to the sensor SENSOR */ bodn2c_c ( sensor, &instid, &found ); if ( !found ) { setmsg_c ( "Cannot determine NAIF ID for #." ); errch_c ( "#", sensor ); sigerr_c ( "NOIDMAPPINGDATA" ); chkout_c ( "SHADOW" ); return; } /* Get the Sun-avoidance Field-of-view of the sensor SENSOR */ getfov_c ( instid, ROOM, SHAPLN, FRMLN, shape, frame,bsight[0], nbv, bvects[0] ); /* Get the SENSOR - Sun vector, in the SENSOR frame. */ spkpos_c ( "SUN", time, frame, "LT", sensor, sun, < ); /* Check whether the Sun is occulted by the Earth or the Moon: we will consider the Sun, the Earth and the Moon spheres. We will use the following radius for the Sun, Earth and Moon: - Sun: largest radius - Earth: smallest radius - Moon: smallest radius */ bodvrd_c ( "SUN", "RADII", 3, &n, radii ); radius = maxd_c ( n, radii[0], radii[1], radii[2]); sunang = asin ( radius / vnorm_c ( sun ) ); for ( i = 0 ; i < 2 ; i++ ) { bodvrd_c ( body[i], "RADII", 3, &n, radii ); radius = mind_c ( n, radii[0], radii[1], radii[2]); spkpos_c ( body[i], time, frame, "LT", sensor, bodpos, < ); bodang = asin ( radius / vnorm_c ( bodpos ) ); /* Is the Sun occulted by the BODY? */ if ( vsep_c ( sun, bodpos ) < (sunang + bodang) ) { chkout_c ( "shadow" ); return ( SPICETRUE ); } } /* Check the occultation of the Sun by any S/C structure. Make all vectors unitary. */ vhat_c ( bsight[0], bsight[0] ); vhat_c ( sun, sun ); for ( i = 0 ; i < nbv[0] ; i++ ) { vhat_c ( bvects[0][i], bvects[0][i] ); } /* Check the angular separation between the Sun-avoidance field-of-view of the sensor SENSOR and SUN position is within 90 degrees. */ if ( vsep_c ( sun, bsight[0]) < halfpi_c () ) { /* Check whether the angular separation between the Sun vector and the +Y axis is bigger than 15 degrees. In this case, due to the configuration of the sensors and the solar panels, it is impossible that the shadow would be caused by the solar panels. We can skip this computations */ if ( vsep_c ( sun , y ) < ( halfpi_c () / 6.0 ) ) { /* Generate the other two Sun Avoidance Field-of-views. The boundary vectors are defined by each of the Solar Panel corner points and the sensor position. */ for ( i = 1 ; i < 3 ; i++ ) { repmc_c ( "SMART1_%_C#","%", sapt[i], KWDLN, saname ); /* We will have 4 boundary vectors, since we have only 4 solar panel corner points. */ nbv[i] = 4; for ( j = 0 ; j < nbv[i] ; j++ ) { /* Create the Solar Panel Corner point name string. */ repmi_c ( saname, "#", j + 1, KWDLN, corner ); /* Get the vectors from the sensor to the solar panels corner points. */ spkpos_c ( corner, time, frame, "NONE", sensor, bvects[i][j], < ); /* Make this vector unitary. */ vhat_c ( bvects[i][j], bvects[i][j] ); } /* Compute the bsight vector associated to this FoV. */ ucrss_c ( bvects[i][0], bvects[i][2], nvect1 ); ucrss_c ( bvects[i][1], bvects[i][3], nvect2 ); /* Check whether the angular separation between the normal vector to the planes is bigger than "sunang".If not, then we consider that this Solar Panel cannot block the light from the sun. */ if ( vsep_c ( nvect1, nvect2 ) > sunang ) { ucrss_c ( nvect1, nvect2, bsight[i] ); /* bsight should look in the same 'direction' as the bvects */ if ( vdot_c ( bvects[i][0], bsight[i] ) < 0.0 ) { vminus_c ( bsight[i], bsight[i] ); } } else { nbv[i] = 0; } } } else { nbv[1] = 0; nbv[2] = 0; } /* For each of the FoVs: Check whether or not the sun, as an sphere is within the Field-of-view defined by the sensor and the corner points of each structure (solar panels or spacecraft bus). */ for ( i = 0 ; i < 3 ; i++ ) { /* If number of boundary vectors is zero, we have no FoV. */ if ( nbv[i] != 0 ) { next = SPICEFALSE; for ( j = 1 ; j <= nbv[i] ; j++ ) { if ( j < nbv[i] ) k = j; else k = 0; /* Find the normal vector to the plane defined by two consecutive boundary vectors. */ ucrss_c ( bvects[i][j-1], bvects[i][k], nvect1 ); if ( vsep_c ( nvect1, bsight[i]) > halfpi_c () ) { if ( vsep_c ( nvect1, sun ) < ( halfpi_c () - sunang ) ) next = SPICETRUE; } else{ if ( vsep_c ( nvect1, sun ) > ( halfpi_c () + sunang ) ) next = SPICETRUE; } } /* If we reach this point, it means that one S/C structure is blocking the sun light. Notify this and return. */ if ( !next ) { chkout_c ( "shadow" ); return ( SPICETRUE ); } } } } /* We are done. Checkout and exit. */ chkout_c ( "shadow" ); return ( SPICEFALSE ); } /* End of shadow */ FORTRAN Example C$ Procedure SHADOW ( Find whether or not the SPEDE sensor is in shadow ) LOGICAL FUNCTION SHADOW ( SENSOR, TIME ) C$ Abstract C C Determine whether or not a given SPEDE sensor is shaded by the Earth, C the Moon or any of the spacecraft structures -- spacecraft bus or C solar panels -- C C$ Required_Reading C C KERNEL Required Reading (kernel.req) C CK Required Reading (ck.req) C SPK Required Reading (spk.req) C Latest SPEDE IK File (SMART1_SPEDE_Vxx.TI -- version 2 or later ) C Latest SMART-1 FK File (SMART1_Vxx.TF -- version 8 or later ) C C$ Keywords C C GEOMETRY C C$ Declarations IMPLICIT NONE CHARACTER*(*) SENSOR DOUBLE PRECISION TIME C$ Brief_I/O C C VARIABLE I/O DESCRIPTION C -------- --- -------------------------------------------------- C SENSOR I SPEDE sensor name C TIME I Time at which to evaluate the condition. C SHADOW O .TRUE. if SENSOR is in shadow, .FALSE. otherwise. C C$ Detailed_Input C C SENSOR is the full NAIF name of the SPEDE sensor. For example, C SMART1_SPEDE+X or SMART1_SPEDE-X C C TIME is the time at which to evaluate the condition, expressed C as seconds past J2000 TDB. C C$ Detailed_Output C C SHADOW is a logical flag indicating the state of the SENSOR. C If the SENSOR is in shadow at the epoch TIME, SHADOW is C returned with the value .TRUE. Otherwise it is returned C with the value .FALSE. C C$ Parameters C C ROOM is the amount of room allocated for the boundary vectors C of the 'Sun-avoidance-Field-of-view'. This FoV has C 4 vectors. C C FRMLN is the maximum character string length for NAIF frame C names. This number is 32 characters. C C SHAPLN is the maximum character string length for NAIF C field-of-view shape identifiers as required by the GETFOV C routine. This number is 32 characters. C C KWDLN is the maximum character string length for NAIF keywords. C This number is 32 characters. C C$ Exceptions C C 1) The error 'NOIDMAPPINGDATA' is signaled if NAIF name <-> ID mapping C for SMART-1 instruments provided in the SMART-1 FK file have not C been loaded, or if there is no instrument ID associated with the C input SENSOR name. C C 2) If the SPEDE IK file is not loaded, an error will be signaled by C the SPICE routine (GETFOV) called by this routine. C C 3) If there is not enough data to compute the position of the Sun, C Earth and/or Moon with respect to the SENSOR in the sensor's C frame, an error will be signaled by the SPICE SPK/FK/CK subsystem. C C 4) If there is no PCK containing constants for the Sun, Earth and C Moon, an error will be signaled by the SPICE routine (BODVRD) C called by this routine. C C 5) If there is no SPK and/or CK data for the SMART-1 Solar Panels, an C error will be signaled by the SPICE SPK/FK/CK subsystem. C C$ Files C C 1) SMART-1 FK and SPEDE IK files must be loaded prior to calling this C subroutine. C C 2) SPK data for the Sun, Earth, Moon, SMART-1 spacecraft and SMART-1 C spacecraft structures (SPEDE sensors and Solar Panels) must be C loaded prior to calling this subroutine. C C 3) CK data for the SMART-1 spacecraft and SMART-1 Solar Panels must be C loaded prior to calling this subroutine. C C 4) PCK file containing the Sun, Earth, and Moon radii must be loaded C prior to calling this subroutine. C C 5) Since the CK subsystem is used, an SMART-1 SCLK file must be loaded C prior to calling this subroutine. C C$ Particulars C C This routine determines whether or not the SPEDE SENSOR is shaded C by any of the spacecraft structures or the Earth or the Moon. C All bodies -- Sun, Earth and Moon -- are regarded as being spherical. C C The Sun and the Moon are already spheres in the IAU tri-axial model C provided in SPICE PCK files. The radius of the spherical Earth is C considered to be the smallest radius of those given by the IAU C tri-axial model. Under this assumption, the routine will return C .FALSE. for some case where, if using a tri-axial ellipsoid model C instead of the spherical one, the SENSOR would be in shadow. C C The Solar Panels are considered to have zero millimeters thickness, C which means that this routine will return .FALSE. for some case C where, if using the real thickness of the solar panels, the SENSOR C would be in shadow. C C$ Examples C C C C C In this example, the routine checks whether the SPEDE sensor C C on the -X boom is in shadow or not, starting at June 1, 2004 C C (UTC) with a time step of 1 hour, over 100 iterations. C C C C PROGRAM SHADOW_EXAMPLE C IMPLICIT NONE C C C C C Functions C C C LOGICAL SHADOW C C C C C Local Constants C C C CHARACTER*(*) SENSOR C PARAMETER ( SENSOR = 'SMART1_SPEDE-X' ) C C CHARACTER*(*) TBEG C PARAMETER ( TBEG = '2004-06-01T00:00:00' ) C C DOUBLE PRECISION STEP C PARAMETER ( STEP = 3600.0D0 ) C C INTEGER MAXITR C PARAMETER ( MAXITR = 100 ) C C C C C Local Variables C C C CHARACTER*(20) STRTIM C DOUBLE PRECISION TIME C INTEGER I C C C C C Load the required LSK and SCLK files: C C C CALL FURNSH ( '../lsk/NAIF0008.TLS' ) C CALL FURNSH ( '../sclk/SMART1_051207_FAKE.TSC' ) C C C C C Load the required SPK files: C C - SPK for the Sun, Earth and Moon. C C - SMART-1 spacecraft C C - SMART-1 spacecraft structures ( SPEDE sensors and C C Solar Panels ) C C C CALL FURNSH ( '../spk/DE405S.BSP' ) C CALL FURNSH ( '../spk/ORES_______________00125.BSP' ) C CALL FURNSH ( '../spk/SMART1_STRUCT_V01.BSP' ) C C C C C Load the required CK files: C C - SMART-1 spacecraft C C - SMART-1 Solar Panels C C C CALL FURNSH ( '../ck/ATNS_P030929010023_00188.BC' ) C CALL FURNSH ( '../ck/SMART1_SA_040601_001.BC' ) C C C C C Load the required PCK files: C C - Generic PCK file. C C C CALL FURNSH ( '../pck/PCK00008.TPC' ) C C C C C Load the required FK and IK files: C C - SMART-1 FK, version v08 or later. C C - SPEDE IK, version v02 or later C C C CALL FURNSH ( '../fk/SMART1_V08.TF' ) C CALL FURNSH ( 'SMART1_SPEDE_V02.TI' ) C C C C C C Convert the input time to Ephemeris Time (ET) C C C CALL STR2ET ( TBEG, TIME ) C C DO I = 1, MAXITR C C CALL ET2UTC ( TIME, 'ISOC', 0, STRTIM ) C IF ( SHADOW ( SENSOR, TIME ) ) THEN C WRITE(*,'(A20,A25)'), 'SENSOR IN SHADOW', STRTIM C ELSE C WRITE(*,'(A20,A25)'), 'SENSOR IN SUN-LIGHT', STRTIM C END IF C C TIME = TIME + STEP C C END DO C C END C C C C$ Restrictions C C None. C C$ Literature_References C C None. C C$ Author_and_Institution C C J. Diaz del Rio (RSSD/ESA) C C$ Version C C- SHADOW Version 1.0.0, 19-DEC-2005 (JDR) C C-& C C SPICELIB functions C DOUBLE PRECISION HALFPI DOUBLE PRECISION VDOT DOUBLE PRECISION VNORM DOUBLE PRECISION VSEP LOGICAL RETURN C C Local parameters C INTEGER ROOM PARAMETER ( ROOM = 4 ) INTEGER FRMLN PARAMETER ( FRMLN = 32 ) INTEGER SHAPLN PARAMETER ( SHAPLN = 32 ) INTEGER KWDLN PARAMETER ( KWDLN = 32 ) C C Local variables C CHARACTER*(KWDLN) BODY ( 2 ) CHARACTER*(FRMLN) FRAME CHARACTER*(KWDLN) CORNER CHARACTER*(KWDLN) SANAME CHARACTER*(KWDLN) SAPT ( 3 ) CHARACTER*(SHAPLN) SHAPE C C We will have 3 different boresights: one from the C Sun-Avoidance FoV and another two from the Solar C Panel-Sensor vectors. C DOUBLE PRECISION BSIGHT ( 3, 3 ) C C We will have also 3 different boundary vectors sets, C one for each BSIGHT C DOUBLE PRECISION BVECTS ( 3, ROOM, 3 ) DOUBLE PRECISION LT DOUBLE PRECISION NVECT1 ( 3 ) DOUBLE PRECISION NVECT2 ( 3 ) DOUBLE PRECISION BODANG DOUBLE PRECISION BODPOS ( 3 ) DOUBLE PRECISION RADII ( 3 ) DOUBLE PRECISION RADIUS DOUBLE PRECISION SUN ( 3 ) DOUBLE PRECISION SUNANG DOUBLE PRECISION Y ( 3 ) INTEGER I INTEGER INSTID INTEGER J INTEGER K INTEGER LOC INTEGER N INTEGER NBV ( 3 ) LOGICAL FOUND LOGICAL NEXT C C Initial values C C C Initialize the origin vector. C Initialize the Solar Array corner point C keywords C DATA SAPT / 'S/C', 'SA+Y', 'SA-Y' / DATA BODY / 'EARTH', 'MOON' / DATA Y / 0.D0, 1.D0, 0.D0 / C C Standard SPICE error handling. C IF ( RETURN () ) THEN RETURN ELSE CALL CHKIN ( 'SHADOW' ) END IF C C Set SHADOW to false C SHADOW = .FALSE. C C Get the Instrument ID associated to the C sensor SENSOR C CALL BODN2C ( SENSOR, INSTID, FOUND ) IF ( .NOT. FOUND ) THEN CALL SETMSG ( 'Cannot determine NAIF ID for #.' ) CALL ERRCH ( '#', SENSOR ) CALL SIGERR ( 'NOIDMAPPINGDATA' ) CALL CHKOUT ( 'SHADOW' ) RETURN END IF C C Get the Sun-avoidance Field-of-view of C the sensor SENSOR C CALL GETFOV ( INSTID, ROOM, SHAPE, FRAME, BSIGHT, NBV, BVECTS ) C C Get the SENSOR - Sun vector, in the SENSOR frame. C CALL SPKPOS ( 'SUN', TIME, FRAME, 'LT', SENSOR, SUN, LT ) C C Check whether the Sun is occulted by the Earth or the C Moon: we will consider the Sun, the Earth and the Moon C as spheres. C C We will use the following radius for the Sun, Earth and C Moon: C - Sun: largest radius C - Earth: smallest radius C - Moon: smallest radius C CALL BODVRD ( 'SUN', 'RADII', 3, N, RADII ) CALL MAXAD ( RADII, N, RADIUS, LOC ) SUNANG = DASIN ( RADIUS / VNORM( SUN ) ) DO I= 1, 2 CALL BODVRD ( BODY(I), 'RADII', 3, N, RADII ) CALL MINAD ( RADII, N, RADIUS, LOC ) CALL SPKPOS ( BODY(I), TIME, FRAME, 'LT', SENSOR, . BODPOS, LT ) BODANG = DASIN ( RADIUS / VNORM( BODPOS ) ) C C Is the Sun occulted by the BODY? C IF ( VSEP( SUN, BODPOS ) .LT. ( SUNANG + BODANG ) ) THEN SHADOW = .TRUE. CALL CHKOUT ( 'SHADOW' ) RETURN END IF END DO C C Check the occultation of the Sun by any S/C structure. C C C Make all vectors unitary. C CALL VHATIP ( BSIGHT( 1, 1 ) ) CALL VHATIP ( SUN ) DO I = 1, NBV( 1 ) CALL VHATIP ( BVECTS(1, I, 1) ) END DO C C Check the angular separation between the Sun-avoidance C field-of-view of the sensor SENSOR and SUN position is C within 90 degrees. C IF ( VSEP ( SUN, BSIGHT( 1, 1) ) .LT. HALFPI() ) THEN C C Check whether the angular separation between the Sun C vector and the +Y axis is bigger than 15 degrees. In C this case, due to the configuration of the sensors and C the solar panels, it is impossible that the shadow would C be caused by the solar panels. We can skip this computations C IF ( VSEP ( SUN, Y ) .LT. (HALFPI() / 6.D0) ) THEN C C Generate the other two Sun Avoidance Field-of-views. C The boundary vectors are defined by each of the Solar C Panel corner points and the sensor position. C DO I = 2, 3 CALL REPMC ( 'SMART1_%_C#','%', SAPT(I), SANAME ) C C We will have 4 boundary vectors, since we have only C 4 solar panel corner points. C NBV( I ) = 4 DO J = 1, NBV( I ) C C Create the Solar Panel Corner point name string. C CALL REPMI ( SANAME, '#', J, CORNER ) C C Get the vectors from the sensor to the solar panels C corner points. C CALL SPKPOS ( CORNER, TIME, FRAME, 'NONE', SENSOR, . BVECTS( 1, J, I ), LT ) C C Make this vector unitary. C CALL VHATIP ( BVECTS(1, J, I ) ) END DO C C Compute the BSIGHT vector associated to this FoV. C CALL UCRSS ( BVECTS( 1, 1, I ), BVECTS( 1, 3, I ), . NVECT1 ) CALL UCRSS ( BVECTS( 1, 2, I ), BVECTS( 1, 4, I ), . NVECT2 ) C C Check whether the angular separation between the normal vector C to the planes is bigger than SUNANG.If not, then we consider C that this Solar Panel cannot block the light from the sun. C IF ( VSEP ( NVECT1, NVECT2 ) .GT. SUNANG ) THEN CALL UCRSS ( NVECT1, NVECT2, BSIGHT( 1, I ) ) C C BSIGHT should look in the same 'direction' as the BVECTS C IF ( VDOT( BVECTS( 1, 1, I ), BSIGHT( 1, I ) ) . .LT. 0.0 ) THEN CALL VMINUS( BSIGHT( 1, I ), BSIGHT( 1, I ) ) END IF ELSE NBV(I) = 0 END IF END DO ELSE NBV( 2 ) = 0 NBV( 3 ) = 0 END IF C C For each of the FoVs: C Check whether or not the sun, as an sphere is within the Field-of-view C defined by the sensor and the corner points of each structure (solar C panels or spacecraft bus). C DO I = 1, 3 C C If number of boundary vectors is zero, we have no C FoV. C IF ( .NOT. ( NBV( I ) .EQ. 0 ) ) THEN NEXT = .FALSE. DO J = 2, NBV( I ) + 1 IF ( J .LE. NBV( I ) ) THEN K = J ELSE K = 1 END IF C C Find the normal vector to the plane defined by C two consecutive boundary vectors. C CALL UCRSS ( BVECTS( 1, J-1, I), BVECTS( 1, K, I), . NVECT1 ) IF ( VSEP ( NVECT1, BSIGHT(1,I) ) .GT. HALFPI() ) THEN IF ( VSEP( NVECT1, SUN ) .LT. . ( HALFPI() - SUNANG ) ) THEN NEXT = .TRUE. END IF ELSE IF ( VSEP( NVECT1, SUN ) .GT. . ( HALFPI() + SUNANG ) ) THEN NEXT = .TRUE. END IF END IF END DO C C If we reach this point, it means that one C S/C structure is blocking the sun light. Notify this C and return. C IF ( .NOT. NEXT ) THEN SHADOW = .TRUE. CALL CHKOUT ( 'SHADOW' ) RETURN END IF END IF END DO END IF C C We are done. Checkout and exit C CALL CHKOUT ( 'SHADOW' ) RETURN END