33#
44import spiceypy
55
6+
67def visibl ():
78 #
89 # Local Parameters
910 #
10- METAKR = ' visibl.tm'
11+ METAKR = " visibl.tm"
1112 SCLKID = - 82
12- TDBFMT = ' YYYY MON DD HR:MN:SC.### TDB ::TDB'
13+ TDBFMT = " YYYY MON DD HR:MN:SC.### TDB ::TDB"
1314 MAXIVL = 1000
1415 MAXWIN = 2 * MAXIVL
1516 #
1617 # Load the meta-kernel.
1718 #
18- spiceypy .furnsh ( METAKR )
19+ spiceypy .furnsh (METAKR )
1920 #
2021 # Assign the inputs for our search.
2122 #
@@ -26,13 +27,13 @@ def visibl():
2627 # increase the accuracy of the occultation times we'll
2728 # compute using gfoclt.
2829 #
29- srfpt = ' DSS-14'
30- obsfrm = ' DSS-14_TOPO'
31- target = ' MEX'
32- abcorr = ' CN+S'
33- start = ' 2004 MAY 2 TDB'
34- stop = ' 2004 MAY 6 TDB'
35- elvlim = 6.0
30+ srfpt = " DSS-14"
31+ obsfrm = " DSS-14_TOPO"
32+ target = " MEX"
33+ abcorr = " CN+S"
34+ start = " 2004 MAY 2 TDB"
35+ stop = " 2004 MAY 6 TDB"
36+ elvlim = 6.0
3637 #
3738 # The elevation limit above has units of degrees; we convert
3839 # this value to radians for computation using SPICE routines.
@@ -46,17 +47,17 @@ def visibl():
4647 # reference frame is required for the target since its
4748 # orientation is not used.
4849 #
49- back = target
50- bshape = ' POINT'
51- bframe = ' '
52- front = ' MARS'
53- fshape = ' ELLIPSOID'
54- fframe = ' IAU_MARS'
50+ back = target
51+ bshape = " POINT"
52+ bframe = " "
53+ front = " MARS"
54+ fshape = " ELLIPSOID"
55+ fframe = " IAU_MARS"
5556 #
5657 # The occultation type should be set to 'ANY' for a point
5758 # target.
5859 #
59- occtyp = ' any'
60+ occtyp = " any"
6061 #
6162 # Since SPICE doesn't directly support the AZ/EL coordinate
6263 # system, we use the equivalent constraint
@@ -66,9 +67,9 @@ def visibl():
6667 # in the latitudinal coordinate system, where the reference
6768 # frame is topocentric and is centered at the viewing location.
6869 #
69- crdsys = ' LATITUDINAL'
70- coord = ' LATITUDE'
71- relate = '>'
70+ crdsys = " LATITUDINAL"
71+ coord = " LATITUDE"
72+ relate = ">"
7273 #
7374 # The adjustment value only applies to absolute extrema
7475 # searches; simply give it an initial value of zero
@@ -86,52 +87,64 @@ def visibl():
8687 #
8788 # Display a banner for the output report:
8889 #
89- print (' \n Inputs for target visibility search:\n ' )
90- print (f' Target = { target } ' )
91- print (f' Observation surface location = { srfpt } ' )
90+ print (" \n Inputs for target visibility search:\n " )
91+ print (f" Target = { target } " )
92+ print (f" Observation surface location = { srfpt } " )
9293 print (f" Observer's reference frame = { obsfrm } " )
93- print (f' Blocking body = { front } ' )
94+ print (f" Blocking body = { front } " )
9495 print (f" Blocker's reference frame = { fframe } " )
95- print (f' Elevation limit (degrees) = { elvlim :f} ' )
96- print (f' Aberration correction = { abcorr } ' )
97- print (f' Step size (seconds) = { stepsz :f} ' )
96+ print (f" Elevation limit (degrees) = { elvlim :f} " )
97+ print (f" Aberration correction = { abcorr } " )
98+ print (f" Step size (seconds) = { stepsz :f} " )
9899 #
99100 # Convert the start and stop times to ET.
100101 #
101- etbeg = spiceypy .str2et ( start )
102- etend = spiceypy .str2et ( stop )
102+ etbeg = spiceypy .str2et (start )
103+ etend = spiceypy .str2et (stop )
103104 #
104105 # Display the search interval start and stop times
105106 # using the format shown below.
106107 #
107108 # 2004 MAY 06 20:15:00.000 (TDB)
108109 #
109- btmstr = spiceypy .timout ( etbeg , TDBFMT )
110- print (f' Start time = { btmstr } ' )
110+ btmstr = spiceypy .timout (etbeg , TDBFMT )
111+ print (f" Start time = { btmstr } " )
111112 etmstr = spiceypy .timout (etend , TDBFMT )
112- print (f' Stop time = { etmstr } ' )
113+ print (f" Stop time = { etmstr } " )
113114
114- print ( ' ' )
115+ print (" " )
115116 #
116117 # Initialize the "confinement" window with the interval
117118 # over which we'll conduct the search.
118119 #
119120 cnfine = spiceypy .cell_double (2 )
120- spiceypy .wninsd ( etbeg , etend , cnfine )
121+ spiceypy .wninsd (etbeg , etend , cnfine )
121122 #
122123 # In the call below, the maximum number of window
123124 # intervals gfposc can store internally is set to MAXIVL.
124125 # We set the cell size to MAXWIN to achieve this.
125126 #
126- riswin = spiceypy .cell_double ( MAXWIN )
127+ riswin = spiceypy .cell_double (MAXWIN )
127128 #
128129 # Now search for the time period, within our confinement
129130 # window, during which the apparent target has elevation
130131 # at least equal to the elevation limit.
131132 #
132- spiceypy .gfposc ( target , obsfrm , abcorr , srfpt ,
133- crdsys , coord , relate , revlim ,
134- adjust , stepsz , MAXIVL , cnfine , riswin )
133+ spiceypy .gfposc (
134+ target ,
135+ obsfrm ,
136+ abcorr ,
137+ srfpt ,
138+ crdsys ,
139+ coord ,
140+ relate ,
141+ revlim ,
142+ adjust ,
143+ stepsz ,
144+ MAXIVL ,
145+ cnfine ,
146+ riswin ,
147+ )
135148 #
136149 # Now find the times when the apparent target is above
137150 # the elevation limit and is not occulted by the
@@ -147,76 +160,100 @@ def visibl():
147160 #
148161 # Find occultations within the view period window.
149162 #
150- print ( ' Searching using ellipsoid target shape model...' )
151- eocwin = spiceypy .cell_double ( MAXWIN )
152- fshape = 'ELLIPSOID'
153- spiceypy .gfoclt ( occtyp , front , fshape , fframe ,
154- back , bshape , bframe , abcorr ,
155- srfpt , stepsz , riswin , eocwin )
156- print ( ' Done.' )
163+ print (" Searching using ellipsoid target shape model..." )
164+ eocwin = spiceypy .cell_double (MAXWIN )
165+ fshape = "ELLIPSOID"
166+ spiceypy .gfoclt (
167+ occtyp ,
168+ front ,
169+ fshape ,
170+ fframe ,
171+ back ,
172+ bshape ,
173+ bframe ,
174+ abcorr ,
175+ srfpt ,
176+ stepsz ,
177+ riswin ,
178+ eocwin ,
179+ )
180+ print (" Done." )
157181 #
158182 # Subtract the occultation window from the view period
159183 # window: this yields the time periods when the target
160184 # is visible.
161185 #
162- evswin = spiceypy .wndifd ( riswin , eocwin )
186+ evswin = spiceypy .wndifd (riswin , eocwin )
163187 #
164188 # Repeat the search using low-resolution DSK data
165189 # for the front body.
166190 #
167- print ( ' Searching using DSK target shape model...' )
168- docwin = spiceypy .cell_double ( MAXWIN )
169- fshape = 'DSK/UNPRIORITIZED'
170- spiceypy .gfoclt ( occtyp , front , fshape , fframe ,
171- back , bshape , bframe , abcorr ,
172- srfpt , stepsz , riswin , docwin )
173- print ( ' Done.\n ' )
174- dvswin = spiceypy .wndifd ( riswin , docwin )
191+ print (" Searching using DSK target shape model..." )
192+ docwin = spiceypy .cell_double (MAXWIN )
193+ fshape = "DSK/UNPRIORITIZED"
194+ spiceypy .gfoclt (
195+ occtyp ,
196+ front ,
197+ fshape ,
198+ fframe ,
199+ back ,
200+ bshape ,
201+ bframe ,
202+ abcorr ,
203+ srfpt ,
204+ stepsz ,
205+ riswin ,
206+ docwin ,
207+ )
208+ print (" Done.\n " )
209+ dvswin = spiceypy .wndifd (riswin , docwin )
175210 #
176211 # The function wncard returns the number of intervals
177212 # in a SPICE window.
178213 #
179- winsiz = spiceypy .wncard ( evswin )
214+ winsiz = spiceypy .wncard (evswin )
180215 if winsiz == 0 :
181- print ( ' No events were found.' )
216+ print (" No events were found." )
182217 else :
183218 #
184219 # Display the visibility time periods.
185220 #
186221 print (
187- f' Visibility start and stop times of { target } as seen from { srfpt } \n '
188- ' using both ellipsoidal and DSK target shape models:\n '
222+ f" Visibility start and stop times of { target } as seen from { srfpt } \n "
223+ " using both ellipsoidal and DSK target shape models:\n "
189224 )
190- for i in range (winsiz ):
225+ for i in range (winsiz ):
191226 #
192227 # Fetch the start and stop times of
193228 # the ith interval from the ellipsoid
194229 # search result window evswin.
195230 #
196- [intbeg , intend ] = spiceypy .wnfetd ( evswin , i )
231+ [intbeg , intend ] = spiceypy .wnfetd (evswin , i )
197232 #
198233 # Convert the rise time to TDB calendar strings.
199234 # Write the results.
200235 #
201- btmstr = spiceypy .timout ( intbeg , TDBFMT )
202- etmstr = spiceypy .timout ( intend , TDBFMT )
203- print (f' Ell: { btmstr } : { etmstr } ' )
236+ btmstr = spiceypy .timout (intbeg , TDBFMT )
237+ etmstr = spiceypy .timout (intend , TDBFMT )
238+ print (f" Ell: { btmstr } : { etmstr } " )
204239 #
205240 # Fetch the start and stop times of
206241 # the ith interval from the DSK
207242 # search result window dvswin.
208243 #
209- [dintbg , dinten ] = spiceypy .wnfetd ( dvswin , i )
244+ [dintbg , dinten ] = spiceypy .wnfetd (dvswin , i )
210245 #
211246 # Convert the rise time to TDB calendar strings.
212247 # Write the results.
213248 #
214- btmstr = spiceypy .timout ( dintbg , TDBFMT )
215- etmstr = spiceypy .timout ( dinten , TDBFMT )
216- print (f' DSK: { btmstr } : { etmstr } \n ' )
249+ btmstr = spiceypy .timout (dintbg , TDBFMT )
250+ etmstr = spiceypy .timout (dinten , TDBFMT )
251+ print (f" DSK: { btmstr } : { etmstr } \n " )
217252 #
218253 # End of result display loop.
219254 #
220- spiceypy .unload ( METAKR )
221- if __name__ == '__main__' :
222- visibl ()
255+ spiceypy .unload (METAKR )
256+
257+
258+ if __name__ == "__main__" :
259+ visibl ()
0 commit comments