PHSRM Geometric Event Finding Hands-On Lesson (FORTRAN) |
Table of ContentsPHSRM Geometric Event Finding Hands-On Lesson (FORTRAN) Overview Note About HTML Links References Tutorials Required Readings The Permuted Index Source Code Header Comments Kernels Used SPICE Routines Used Find View Periods Task Statement Learning Goals Approach Solution steps Solution Solution Meta-Kernel Solution Code Solution Sample Output Find Times when Target is Visible Task Statement Learning Goals Approach Solution steps Solution Solution Code Solution Sample Output PHSRM Geometric Event Finding Hands-On Lesson (FORTRAN)
Overview
In this lesson the student is asked to construct a program that finds the time intervals, within a specified time range, when the Phobos Sample Return spacecraft (PHSRM) is visible from the USSURIYSK tracking station. Possible occultation of the spacecraft by Mars is to be considered. 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/routines 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 Lunar-Earth PCK Lunar and Earth Orientation Data GF The SPICE Geometry Ginder (GF) subsystemThese tutorials are available from the NAIF ftp server at JPL:
http://naif.jpl.nasa.gov/naif/tutorials.html Required Readings
Name Lesson steps/routines that it describes --------------- ----------------------------------------- cells.req Cell/window initialization frames.req Using reference frames gf.req The SPICE geometry finder (GF) subsystem kernel.req Loading SPICE kernels naif_ids.req Body and reference frame names pck.req Obtaining planetary constants data spk.req Computing positions and velocities time.req UTC to ET time conversion windows.req The SPICE window data type 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. This 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. Source Code Header Comments
For example path of the source code of the STR2ET routine is
toolkit/src/spicelib/str2et.for Kernels Used
File Name Type Description ----------------------- ---- -------------------------- de421xs.bsp SPK Planetary ephemeris SPK earthstns_phsrm_itrf93_110118.bsp SPK Russian stations SPK earthstns_phsrm_topo_110118.tf FK Russian stations FK earth_070425_370426_predict.bpc PCK Binary PCK for Earth phsrm_130114_130114_130214_nom2.bsp SPK PHSRM trajectory SPK naif0009.tls LSK Generic LSK pck00009.tpc PCK Generic PCK phsrm_v00.tf FK PHSRM FKThese SPICE kernels are included in the lesson package available from the PHSRM server at IKI:
http://spice.ikiweb.ru/PHSRM/kernels SPICE Routines Used
Name Function that it performs ---------- --------------------------------------------------- FURNSH Loads kernels, individually or listed in meta-kernel GFOCLT Solve for times of occultation or transit GFPOSC Solve for times when a position vector coordinate constraint is met REPMC Substitute a substring for a marker in a string REPMF Substitute double precision value for marker in string RPD Return number of radians per degree SSIZED Set the size of a d.p. cell STR2ET Converts a time string to ET seconds past J2000 TIMOUT Format a time string for output TOSTDO Write a string to standard output WNCARD Return cardinality of a SPICE window WNDIFD Find the difference of two d.p. windows WNFETD Fetch a specified interval from a d.p. window WNINSD Insert an interval into a d.p. windowRefer to the headers of the various routines listed above, as detailed interface specifications are provided with the source code. Find View PeriodsTask Statement
2013 JAN 17 TDB 2013 JAN 27 TDBwhen PHSRM is visible from the tracking station USSURIYSK. These time intervals are frequently called ``view periods.'' The spacecraft is considered visible if its apparent position (that is, its position corrected for light time and stellar aberration) has elevation of at least 6 degrees in the topocentric reference frame USSURIYSK_TOPO. In this exercise, we ignore the possibility of occultation of the spacecraft by Mars. Use a search step size that ensures that no view periods of duration 5 minutes or longer will be missed by the search. Display the start and stop times of these intervals using TDB calendar dates and millisecond precision. Learning Goals
ApproachSolution steps
Preparation:
SolutionSolution Meta-Kernel
KPL/MK Example meta-kernel for geometric event finding hands-on coding lesson. Version 1.0.0 21-JUL-2011 (BVS) Identify names of kernels to load: \begindata KERNELS_TO_LOAD = ( 'kernels/spk/de421xs.bsp' 'kernels/spk/earthstns_phsrm_itrf93_110118.bsp' 'kernels/fk/earthstns_phsrm_topo_110118.tf' 'kernels/pck/earth_070425_370426_predict.bpc' 'kernels/lsk/naif0009.tls' 'kernels/spk/phsrm_130114_130114_130214_nom2.bsp' 'kernels/pck/pck00009.tpc' 'kernels/fk/phsrm_v00.tf' ) \begintext Solution Code
PROGRAM VIEWPR IMPLICIT NONE C C Find and display the window of times when the PHSRM C spacecraft is above a specified elevation limit in the C topocentric reference frame of tracking station USSURIYSK. C C C SPICELIB functions C DOUBLE PRECISION RPD INTEGER WNCARD C C Global GF parameters: we import from this file C the definition of the GF workspace size parameter C C NWMAX C INCLUDE 'gf.inc' C C Local parameters C C Format string for time output: C CHARACTER*(*) TDBFMT PARAMETER ( TDBFMT = . 'YYYY MON DD HR:MN:SC.### (TDB) ::TDB' ) C C The meta-kernel: C CHARACTER*(*) METAKR PARAMETER ( METAKR = 'viewpr.tm' ) C C Maximum number of intervals in any window: C INTEGER MAXIVL PARAMETER ( MAXIVL = 1000 ) C C Maximum result window size: C INTEGER MAXWIN PARAMETER ( MAXWIN = 2 * MAXIVL ) C C SPICELIB cell bound: C INTEGER LBCELL PARAMETER ( LBCELL = -5 ) C C String length parameters: C INTEGER CORLEN PARAMETER ( CORLEN = 10 ) INTEGER FRNMLN PARAMETER ( FRNMLN = 32 ) INTEGER LNSIZE PARAMETER ( LNSIZE = 200 ) INTEGER NAMLEN PARAMETER ( NAMLEN = 32 ) INTEGER OPLEN PARAMETER ( OPLEN = 50 ) INTEGER TIMLEN PARAMETER ( TIMLEN = 50 ) C C Local variables C CHARACTER*(CORLEN) ABCORR CHARACTER*(NAMLEN) CRDSYS CHARACTER*(NAMLEN) COORD CHARACTER*(LNSIZE) LINE CHARACTER*(FRNMLN) OBSFRM CHARACTER*(OPLEN) RELATE CHARACTER*(NAMLEN) SRFPT CHARACTER*(TIMLEN) START CHARACTER*(TIMLEN) STOP CHARACTER*(NAMLEN) TARGET CHARACTER*(TIMLEN) TIMSTR CHARACTER*(LNSIZE) TITLE DOUBLE PRECISION ADJUST C C Confinement window used to store interval to be searched: C DOUBLE PRECISION CNFINE ( LBCELL : MAXWIN ) DOUBLE PRECISION ELVLIM DOUBLE PRECISION ETBEG DOUBLE PRECISION ETEND DOUBLE PRECISION INTBEG DOUBLE PRECISION INTEND DOUBLE PRECISION REVLIM C C STEPSZ is the step size, measured in seconds, used to search C for times bracketing a state transition. C DOUBLE PRECISION STEPSZ C C Result window used to store rise/set times: C DOUBLE PRECISION RISWIN ( LBCELL : MAXWIN ) C C Workspace array: C DOUBLE PRECISION WORK ( LBCELL : MAXWIN, NWMAX ) INTEGER I INTEGER WINSIZ C C Load the meta-kernel. C CALL FURNSH ( METAKR ) C C Assign the inputs for our search. C C Since we're interested in the apparent location of the C target, we use light time and stellar aberration C corrections. We use the "converged Newtonian" form C of the light time correction because this choice may C increase the accuracy of the occultation times we'll C compute using GFOCLT. C SRFPT = 'USSURIYSK' OBSFRM = 'USSURIYSK_TOPO' TARGET = 'PHSRM' ABCORR = 'CN+S' START = '2013 JAN 17 TDB' STOP = '2013 JAN 27 TDB' ELVLIM = 6.0D0 C C The elevation limit above has units of degrees; we convert C this value to radians for computation using SPICE routines. C We'll store the equivalent value in radians in REVLIM. C REVLIM = RPD() * ELVLIM C C Since SPICE doesn't directly support the AZ/EL coordinate C system, we use the equivalent constraint C C latitude > REVLIM C C in the latitudinal coordinate system, where the reference C frame is topocentric and is centered at the viewing location. C CRDSYS = 'LATITUDINAL' COORD = 'LATITUDE' RELATE = '>' C C The adjustment value only applies to absolute extrema C searches; simply give it an initial value of zero C for this inequality search. C ADJUST = 0.D0 C C STEPSZ is the step size, measured in seconds, used to search C for times bracketing a state transition. Since we don't expect C any events of interest to be shorter than five minutes, and C since the separation between events is well over 5 minutes, C we'll use this value as our step size. Units are seconds. C STEPSZ = 300.D0 C C Display a banner for the output report: C TITLE = 'Inputs for target visibility search:' CALL TOSTDO ( ' ' ) CALL TOSTDO ( TITLE ) CALL TOSTDO ( ' ' ) LINE = ' Target = #' CALL REPMC ( LINE, '#', TARGET, LINE ) CALL TOSTDO ( LINE ) LINE = ' Observation surface location = #' CALL REPMC ( LINE, '#', SRFPT, LINE ) CALL TOSTDO ( LINE ) LINE = ' Observer''s reference frame = #' CALL REPMC ( LINE, '#', OBSFRM, LINE ) CALL TOSTDO ( LINE ) LINE = ' Elevation limit (degrees) = #' CALL REPMF ( LINE, '#', ELVLIM, 7, 'F', LINE ) CALL TOSTDO ( LINE ) LINE = ' Aberration correction = #' CALL REPMC ( LINE, '#', ABCORR, LINE ) CALL TOSTDO ( LINE ) LINE = ' Step size (seconds) = #' CALL REPMF ( LINE, '#', STEPSZ, 9, 'F', LINE ) CALL TOSTDO ( LINE ) C C Convert the start and stop times to ET. C CALL STR2ET ( START, ETBEG ) CALL STR2ET ( STOP, ETEND ) C C Display the search interval start and stop times C using the format shown below. C C 2013 JAN 25 20:15:00.000 (TDB) C CALL TIMOUT ( ETBEG, TDBFMT, TIMSTR ) LINE = ' Start time = '//TIMSTR CALL TOSTDO ( LINE ) CALL TIMOUT ( ETEND, TDBFMT, TIMSTR ) LINE = ' Stop time = '//TIMSTR CALL TOSTDO ( LINE ) CALL TOSTDO ( ' ' ) C C Every SPICELIB window must have its size initialized. C C Initialize the "confinement" window with the interval C over which we'll conduct the search. C CALL SSIZED ( MAXWIN, CNFINE ) CALL WNINSD ( ETBEG, ETEND, CNFINE ) C C Initialize the result window; this window will contain C the rise/set times found by our search. C CALL SSIZED ( MAXWIN, RISWIN ) C C In the call below, the workspace dimensions are C C ( MAXWIN, NWMAX ) C C Now search for the time period, within our confinement C window, during which the apparent target has elevation C at least equal to the elevation limit. C CALL GFPOSC ( TARGET, OBSFRM, ABCORR, SRFPT, . CRDSYS, COORD, RELATE, REVLIM, . ADJUST, STEPSZ, CNFINE, MAXWIN, . NWMAX, WORK, RISWIN ) C C The function WNCARD returns the number of intervals C in a SPICE window. C WINSIZ = WNCARD( RISWIN ) IF ( WINSIZ .EQ. 0 ) THEN WRITE (*,*) 'No events were found.' ELSE C C Display the view periods. C LINE = 'Visibility times of # as seen from #:' CALL REPMC ( LINE, '#', TARGET, LINE ) CALL REPMC ( LINE, '#', SRFPT, LINE ) CALL TOSTDO ( LINE ) CALL TOSTDO ( ' ' ) DO I = 1, WINSIZ C C Fetch the start and stop times of the Ith interval C from the search result window VISWIN. C CALL WNFETD ( RISWIN, I, INTBEG, INTEND ) C C Convert the rise time to a TDB calendar string. C CALL TIMOUT ( INTBEG, TDBFMT, TIMSTR ) C C Write the string to standard output. C IF ( I .EQ. 1 ) THEN LINE = 'Visibility or window start time: #' ELSE LINE = 'Visibility start time: #' END IF CALL REPMC ( LINE, '#', TIMSTR, LINE ) CALL TOSTDO ( LINE ) C C Convert the set time to a TDB calendar string. C CALL TIMOUT ( INTEND, TDBFMT, TIMSTR ) C C Write the string to standard output. C IF ( I .EQ. WINSIZ ) THEN LINE = 'Visibility or window stop time: #' ELSE LINE = 'Visibility stop time: #' END IF CALL REPMC ( LINE, '#', TIMSTR, LINE ) CALL TOSTDO ( LINE ) CALL TOSTDO ( ' ' ) END DO END IF END Solution Sample Output
After compiling the program, execute it. The output is:
Inputs for target visibility search: Target = PHSRM Observation surface location = USSURIYSK Observer's reference frame = USSURIYSK_TOPO Elevation limit (degrees) = 6.000000 Aberration correction = CN+S Step size (seconds) = 300.000000 Start time = 2013 JAN 17 00:00:00.000 (TDB) Stop time = 2013 JAN 27 00:00:00.000 (TDB) Visibility times of PHSRM as seen from USSURIYSK: Visibility or window start time: 2013 JAN 17 00:33:31.361 (TDB) Visibility stop time: 2013 JAN 17 09:02:45.225 (TDB) Visibility start time: 2013 JAN 18 00:31:30.565 (TDB) Visibility stop time: 2013 JAN 18 09:03:09.674 (TDB) Visibility start time: 2013 JAN 19 00:29:28.884 (TDB) Visibility stop time: 2013 JAN 19 09:03:34.081 (TDB) Visibility start time: 2013 JAN 20 00:27:26.144 (TDB) Visibility stop time: 2013 JAN 20 09:03:58.190 (TDB) Visibility start time: 2013 JAN 21 00:25:22.338 (TDB) Visibility stop time: 2013 JAN 21 09:04:21.910 (TDB) Visibility start time: 2013 JAN 22 00:23:17.607 (TDB) Visibility stop time: 2013 JAN 22 09:04:45.379 (TDB) Visibility start time: 2013 JAN 23 00:21:12.160 (TDB) Visibility stop time: 2013 JAN 23 09:05:08.811 (TDB) Visibility start time: 2013 JAN 24 00:19:06.175 (TDB) Visibility stop time: 2013 JAN 24 09:05:32.377 (TDB) Visibility start time: 2013 JAN 25 00:16:59.683 (TDB) Visibility stop time: 2013 JAN 25 09:05:56.090 (TDB) Visibility start time: 2013 JAN 26 00:14:52.583 (TDB) Visibility or window stop time: 2013 JAN 26 09:06:19.734 (TDB) Find Times when Target is VisibleTask Statement
Display each of the intervals in the result window as a pair of start and stop times. Express each time as a TDB calendar date using the same format as in the previous program. Learning Goals
ApproachSolution steps
SolutionSolution Code
PROGRAM VISIBL IMPLICIT NONE C C Find and display the window of times when the PHSRM C spacecraft is above a specified elevation limit in the C topocentric reference frame of tracking station USSURIYSK C and is not occulted by Mars. C C C SPICELIB functions C DOUBLE PRECISION RPD INTEGER WNCARD C C Global GF parameters: we import from this file C the definition of the GF workspace size parameter C C NWMAX C C and the occultation parameters C C OCCLN C SHPLEN C INCLUDE 'gf.inc' C C Local parameters C C Format string for time output: C CHARACTER*(*) TDBFMT PARAMETER ( TDBFMT = . 'YYYY MON DD HR:MN:SC.### (TDB) ::TDB' ) C C The meta-kernel: C CHARACTER*(*) METAKR PARAMETER ( METAKR = 'viewpr.tm' ) C C Maximum number of events we can handle in our event set: C INTEGER MAXEVT PARAMETER ( MAXEVT = 1000 ) C C Maximum result window size: C INTEGER MAXWIN PARAMETER ( MAXWIN = 2 * MAXEVT ) C C SPICELIB cell bound: C INTEGER LBCELL PARAMETER ( LBCELL = -5 ) C C String length parameters: C INTEGER BDNMLN PARAMETER ( BDNMLN = 36 ) INTEGER CORLEN PARAMETER ( CORLEN = 10 ) INTEGER FRNMLN PARAMETER ( FRNMLN = 32 ) INTEGER LNSIZE PARAMETER ( LNSIZE = 200 ) INTEGER NAMLEN PARAMETER ( NAMLEN = 32 ) INTEGER OPLEN PARAMETER ( OPLEN = 50 ) INTEGER TIMLEN PARAMETER ( TIMLEN = 50 ) C C Local variables C CHARACTER*(CORLEN) ABCORR CHARACTER*(BDNMLN) BACK CHARACTER*(FRNMLN) BFRAME CHARACTER*(BDNMLN) BSHAPE CHARACTER*(NAMLEN) CRDSYS CHARACTER*(NAMLEN) COORD CHARACTER*(FRNMLN) FFRAME CHARACTER*(FRNMLN) FRAME CHARACTER*(BDNMLN) FRONT CHARACTER*(SHPLEN) FSHAPE CHARACTER*(LNSIZE) LINE CHARACTER*(OCLLN) OCCTYP CHARACTER*(OPLEN) RELATE CHARACTER*(NAMLEN) SRFPT CHARACTER*(TIMLEN) START CHARACTER*(TIMLEN) STOP CHARACTER*(NAMLEN) TARGET CHARACTER*(TIMLEN) TIMSTR CHARACTER*(LNSIZE) TITLE DOUBLE PRECISION ADJUST C C Confinement window used to store interval to be searched: C DOUBLE PRECISION CNFINE ( LBCELL : MAXEVT ) DOUBLE PRECISION ELVLIM DOUBLE PRECISION ETBEG DOUBLE PRECISION ETEND DOUBLE PRECISION INTBEG DOUBLE PRECISION INTEND DOUBLE PRECISION REVLIM C C STEPSZ is the step size, measured in seconds, used to search C for times bracketing a state transition. C DOUBLE PRECISION STEPSZ C C Result window used to store occultation times: C DOUBLE PRECISION OCCWIN ( LBCELL : MAXWIN ) C C Result window used to store rise/set times: C DOUBLE PRECISION RISWIN ( LBCELL : MAXWIN ) C C Result window used to store visibility periods: C DOUBLE PRECISION VISWIN ( LBCELL : MAXWIN ) C C Workspace array: C DOUBLE PRECISION WORK ( LBCELL : MAXWIN, NWMAX ) INTEGER I INTEGER WINSIZ C C Load the meta-kernel. C CALL FURNSH ( METAKR ) C C Assign the inputs for our search. C SRFPT = 'USSURIYSK' FRAME = 'USSURIYSK_TOPO' TARGET = 'PHSRM' ABCORR = 'CN+S' START = '2013 JAN 17 TDB' STOP = '2013 JAN 27 TDB' ELVLIM = 6.0D0 C C The elevation limit above has units of degrees; we convert C this value to radians for computation using SPICE routines. C We'll store the equivalent value in radians in REVLIM. C REVLIM = RPD() * ELVLIM C Since we're interested in the apparent location of the C target, we use light time and stellar aberration C corrections. C C Since SPICE doesn't directly support the AZ/EL coordinate C system, we use the equivalent constraint C C latitude > REVLIM C C in the latitudinal coordinate system, where the reference C frame is topocentric and is centered at the viewing location. C CRDSYS = 'LATITUDINAL' COORD = 'LATITUDE' RELATE = '>' C C STEPSZ is the step size, measured in seconds, used to search C for times bracketing a state transition. Since we don't expect C any events of interest to be shorter than five minutes, and C since the separation between events is well over 5 minutes, C we'll use this value as our step size. Units are seconds. C STEPSZ = 300.D0 C C We model the target shape as a point and the blocking body's C shape as an ellipsoid. No body-fixed reference frame is C required for the target since its orientation is not used. C BACK = TARGET BSHAPE = 'POINT' BFRAME = ' ' FRONT = 'MARS' FSHAPE = 'ELLIPSOID' FFRAME = 'IAU_MARS' C C The occultation type should be set to 'ANY' for a point C target. C OCCTYP = 'ANY' C C Display a banner for the output report: C TITLE = 'Inputs for target visibility search:' CALL TOSTDO ( ' ' ) CALL TOSTDO ( TITLE ) CALL TOSTDO ( ' ' ) LINE = ' Target = #' CALL REPMC ( LINE, '#', TARGET, LINE ) CALL TOSTDO ( LINE ) LINE = ' Observation surface location = #' CALL REPMC ( LINE, '#', SRFPT, LINE ) CALL TOSTDO ( LINE ) LINE = ' Observer''s reference frame = #' CALL REPMC ( LINE, '#', FRAME, LINE ) CALL TOSTDO ( LINE ) LINE = ' Blocking body = #' CALL REPMC ( LINE, '#', FRONT, LINE ) CALL TOSTDO ( LINE ) LINE = ' Blocker''s reference frame = #' CALL REPMC ( LINE, '#', FFRAME, LINE ) CALL TOSTDO ( LINE ) LINE = ' Elevation limit (degrees) = #' CALL REPMF ( LINE, '#', ELVLIM, 7, 'F', LINE ) CALL TOSTDO ( LINE ) LINE = ' Aberration correction = #' CALL REPMC ( LINE, '#', ABCORR, LINE ) CALL TOSTDO ( LINE ) LINE = ' Step size (seconds) = #' CALL REPMF ( LINE, '#', STEPSZ, 9, 'F', LINE ) CALL TOSTDO ( LINE ) C C Convert the start and stop times to ET. C CALL STR2ET ( START, ETBEG ) CALL STR2ET ( STOP, ETEND ) C C Display the search interval start and stop times C using the format shown below. C C 2013 JAN 25 20:15:00.000 (TDB) C CALL TIMOUT ( ETBEG, TDBFMT, TIMSTR ) LINE = ' Start time = '//TIMSTR CALL TOSTDO ( LINE ) CALL TIMOUT ( ETEND, TDBFMT, TIMSTR ) LINE = ' Stop time = '//TIMSTR CALL TOSTDO ( LINE ) CALL TOSTDO ( ' ' ) C C Every SPICELIB window must have its size initialized. C C Initialize the "confinement" window with the interval C over which we'll conduct the search. C CALL SSIZED ( MAXWIN, CNFINE ) CALL WNINSD ( ETBEG, ETEND, CNFINE ) C C Initialize the result window; this window will contain C the rise/set times found by our search. C CALL SSIZED ( MAXWIN, RISWIN ) C C Initialize the occultation and visibility windows. C CALL SSIZED ( MAXWIN, OCCWIN ) CALL SSIZED ( MAXWIN, VISWIN ) C C The adjustment value only applies to absolute extrema C searches; simply give it an initial value of zero C for this inequality search. C ADJUST = 0.D0 C C Note that the workspace dimensions are ( MAXWIN, NWMAX ). C C Now search for the time period, within our confinement C window, during which the apparent target has elevation C at least equal to the elevation limit. C CALL GFPOSC ( TARGET, FRAME, ABCORR, SRFPT, . CRDSYS, COORD, RELATE, REVLIM, . ADJUST, STEPSZ, CNFINE, MAXWIN, . NWMAX, WORK, RISWIN ) C C Now find the times when the apparent target is above C the elevation limit and is not occulted by the C blocking body (Mars). We'll find the times when the target C is above the elevation limit and *is* occulted, then subtract C that window from the view period window RISWIN found above. C C For this occultation search, we can use RISWIN as C the confinement window because we're not interested in C occultations that occur when the target is below the C elevation limit. C C Find occultations within the view period window. C CALL GFOCLT ( OCCTYP, FRONT, FSHAPE, FFRAME, . BACK, BSHAPE, BFRAME, ABCORR, . SRFPT, STEPSZ, RISWIN, OCCWIN ) C C Subtract the occultation window from the view period C window: this yields the time periods when the target C is visible. C CALL WNDIFD ( RISWIN, OCCWIN, VISWIN ) C C The function WNCARD returns the number of intervals C in a SPICE window. C WINSIZ = WNCARD( VISWIN ) IF ( WINSIZ .EQ. 0 ) THEN WRITE (*,*) 'No events were found.' ELSE C C Display the visibility time periods. C LINE = 'Visibility times of # as seen from #:' CALL REPMC ( LINE, '#', TARGET, LINE ) CALL REPMC ( LINE, '#', SRFPT, LINE ) CALL TOSTDO ( LINE ) CALL TOSTDO ( ' ' ) DO I = 1, WINSIZ C C Fetch the start and stop times of the Ith interval C from the search result window VISWIN. C CALL WNFETD ( VISWIN, I, INTBEG, INTEND ) C C Convert the rise time to a TDB calendar string. C CALL TIMOUT ( INTBEG, TDBFMT, TIMSTR ) C C Write the string to standard output. C IF ( I .EQ. 1 ) THEN LINE = 'Visibility or window start time: #' ELSE LINE = 'Visibility start time: #' END IF CALL REPMC ( LINE, '#', TIMSTR, LINE ) CALL TOSTDO ( LINE ) CALL TIMOUT ( INTEND, TDBFMT, TIMSTR ) C C Write the string to standard output. C IF ( I .EQ. WINSIZ ) THEN LINE = 'Visibility or window stop time: #' ELSE LINE = 'Visibility stop time: #' END IF CALL REPMC ( LINE, '#', TIMSTR, LINE ) CALL TOSTDO ( LINE ) CALL TOSTDO ( ' ' ) END DO END IF END Solution Sample Output
After compiling the program, execute it. The output is:
Inputs for target visibility search: Target = PHSRM Observation surface location = USSURIYSK Observer's reference frame = USSURIYSK_TOPO Blocking body = MARS Blocker's reference frame = IAU_MARS Elevation limit (degrees) = 6.000000 Aberration correction = CN+S Step size (seconds) = 300.000000 Start time = 2013 JAN 17 00:00:00.000 (TDB) Stop time = 2013 JAN 27 00:00:00.000 (TDB) Visibility times of PHSRM as seen from USSURIYSK: Visibility or window start time: 2013 JAN 17 00:33:31.361 (TDB) Visibility stop time: 2013 JAN 17 01:47:16.462 (TDB) Visibility start time: 2013 JAN 17 02:07:19.374 (TDB) Visibility stop time: 2013 JAN 17 09:02:45.225 (TDB) Visibility start time: 2013 JAN 18 00:31:30.565 (TDB) Visibility stop time: 2013 JAN 18 00:47:36.315 (TDB) Visibility start time: 2013 JAN 18 01:05:44.180 (TDB) Visibility stop time: 2013 JAN 18 08:26:58.267 (TDB) Visibility start time: 2013 JAN 18 08:45:15.036 (TDB) Visibility stop time: 2013 JAN 18 09:03:09.674 (TDB) Visibility start time: 2013 JAN 19 00:29:28.884 (TDB) Visibility stop time: 2013 JAN 19 07:26:28.944 (TDB) Visibility start time: 2013 JAN 19 07:42:20.612 (TDB) Visibility stop time: 2013 JAN 19 09:03:34.081 (TDB) Visibility start time: 2013 JAN 20 00:27:26.144 (TDB) Visibility stop time: 2013 JAN 20 06:25:05.813 (TDB) Visibility start time: 2013 JAN 20 06:40:32.764 (TDB) Visibility stop time: 2013 JAN 20 09:03:58.190 (TDB) Visibility start time: 2013 JAN 21 00:25:22.338 (TDB) Visibility stop time: 2013 JAN 21 05:25:49.659 (TDB) Visibility start time: 2013 JAN 21 05:38:51.869 (TDB) Visibility stop time: 2013 JAN 21 09:04:21.910 (TDB) Visibility start time: 2013 JAN 22 00:23:17.607 (TDB) Visibility stop time: 2013 JAN 22 04:24:38.313 (TDB) Visibility start time: 2013 JAN 22 04:35:28.127 (TDB) Visibility stop time: 2013 JAN 22 09:04:45.379 (TDB) Visibility start time: 2013 JAN 23 00:21:12.160 (TDB) Visibility stop time: 2013 JAN 23 03:24:26.753 (TDB) Visibility start time: 2013 JAN 23 03:34:27.263 (TDB) Visibility stop time: 2013 JAN 23 09:05:08.811 (TDB) Visibility start time: 2013 JAN 24 00:19:06.175 (TDB) Visibility stop time: 2013 JAN 24 02:26:30.810 (TDB) Visibility start time: 2013 JAN 24 02:29:39.646 (TDB) Visibility stop time: 2013 JAN 24 09:05:32.377 (TDB) Visibility start time: 2013 JAN 25 00:16:59.683 (TDB) Visibility stop time: 2013 JAN 25 09:05:56.090 (TDB) Visibility start time: 2013 JAN 26 00:14:52.583 (TDB) Visibility or window stop time: 2013 JAN 26 09:06:19.734 (TDB) |