1 /* illumg.f -- translated by f2c (version 19980913).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
8 /* Table of constant values */
9
10 static integer c__100 = 100;
11 static integer c__3 = 3;
12
13 /* $Procedure ILLUMG ( Illumination angles, general source ) */
illumg_(char * method,char * target,char * ilusrc,doublereal * et,char * fixref,char * abcorr,char * obsrvr,doublereal * spoint,doublereal * trgepc,doublereal * srfvec,doublereal * phase,doublereal * incdnc,doublereal * emissn,ftnlen method_len,ftnlen target_len,ftnlen ilusrc_len,ftnlen fixref_len,ftnlen abcorr_len,ftnlen obsrvr_len)14 /* Subroutine */ int illumg_(char *method, char *target, char *ilusrc,
15 doublereal *et, char *fixref, char *abcorr, char *obsrvr, doublereal *
16 spoint, doublereal *trgepc, doublereal *srfvec, doublereal *phase,
17 doublereal *incdnc, doublereal *emissn, ftnlen method_len, ftnlen
18 target_len, ftnlen ilusrc_len, ftnlen fixref_len, ftnlen abcorr_len,
19 ftnlen obsrvr_len)
20 {
21 /* Initialized data */
22
23 static integer shape = 0;
24 static logical first = TRUE_;
25 static char prvcor[5] = " ";
26 static char prvmth[80] = " "
27 " ";
28
29 /* Builtin functions */
30 integer s_cmp(char *, char *, ftnlen, ftnlen);
31 /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
32
33 /* Local variables */
34 extern /* Subroutine */ int zzbods2c_(integer *, char *, integer *,
35 logical *, char *, integer *, logical *, ftnlen, ftnlen);
36 extern doublereal vsep_(doublereal *, doublereal *);
37 extern /* Subroutine */ int vequ_(doublereal *, doublereal *);
38 integer type__;
39 static logical xmit;
40 extern /* Subroutine */ int zznamfrm_(integer *, char *, integer *, char *
41 , integer *, ftnlen, ftnlen), zzvalcor_(char *, logical *, ftnlen)
42 , zzsbfnrm_(integer *, integer *, integer *, doublereal *,
43 integer *, doublereal *, doublereal *), zzctruin_(integer *),
44 zzprsmet_(integer *, char *, integer *, char *, char *, logical *,
45 integer *, integer *, char *, char *, ftnlen, ftnlen, ftnlen,
46 ftnlen, ftnlen);
47 integer n;
48 extern /* Subroutine */ int zzsrftrk_(integer *, logical *);
49 doublereal s, radii[3];
50 extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
51 ftnlen, ftnlen);
52 static integer nsurf;
53 extern logical eqstr_(char *, char *, ftnlen, ftnlen);
54 static logical uselt, svfnd1, svfnd2;
55 static integer svctr1[2], svctr2[2];
56 extern logical failed_(void);
57 static integer svctr3[2], svctr4[2];
58 doublereal lt;
59 integer fxfcde, obscde;
60 extern /* Subroutine */ int bodvcd_(integer *, char *, integer *, integer
61 *, doublereal *, ftnlen);
62 static integer trgcde;
63 extern logical return_(void);
64 char pntdef[20], shpstr[9], subtyp[20], trmstr[20];
65 doublereal normal[3], obspos[3], opstat[6], tistat[6];
66 static integer center;
67 integer typeid;
68 static integer srflst[100];
69 logical attblk[15], surfup;
70 static char svtarg[36];
71 static integer svtcde;
72 static char svobsr[36];
73 static integer svobsc;
74 logical fnd;
75 static char svfref[32];
76 static integer svrefc;
77 extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *,
78 ftnlen), sigerr_(char *, ftnlen), frinfo_(integer *, integer *,
79 integer *, integer *, logical *), errint_(char *, integer *,
80 ftnlen), spkcpt_(doublereal *, char *, char *, doublereal *, char
81 *, char *, char *, char *, doublereal *, doublereal *, ftnlen,
82 ftnlen, ftnlen, ftnlen, ftnlen, ftnlen), spkcpo_(char *,
83 doublereal *, char *, char *, char *, doublereal *, char *, char *
84 , doublereal *, doublereal *, ftnlen, ftnlen, ftnlen, ftnlen,
85 ftnlen, ftnlen), surfnm_(doublereal *, doublereal *, doublereal *,
86 doublereal *, doublereal *), vminus_(doublereal *, doublereal *);
87 doublereal lti;
88 static logical pri;
89
90 /* $ Abstract */
91
92 /* Find the illumination angles (phase, incidence, and */
93 /* emission) at a specified surface point of a target body. */
94
95 /* The surface of the target body may be represented by a triaxial */
96 /* ellipsoid or by topographic data provided by DSK files. */
97
98 /* The illumination source is a specified ephemeris object. */
99
100 /* $ Disclaimer */
101
102 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
103 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
104 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
105 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
106 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
107 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
108 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
109 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
110 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
111 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
112
113 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
114 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
115 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
116 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
117 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
118 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
119
120 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
121 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
122 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
123 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
124
125 /* $ Required_Reading */
126
127 /* DSK */
128 /* FRAMES */
129 /* NAIF_IDS */
130 /* PCK */
131 /* SPK */
132 /* TIME */
133
134 /* $ Keywords */
135
136 /* ANGLES */
137 /* GEOMETRY */
138 /* ILLUMINATION */
139
140 /* $ Declarations */
141
142 /* File: dsk.inc */
143
144
145 /* Version 1.0.0 05-FEB-2016 (NJB) */
146
147 /* Maximum size of surface ID list. */
148
149
150 /* End of include file dsk.inc */
151
152 /* $ Abstract */
153
154 /* This file contains public, global parameter declarations */
155 /* for the SPICELIB Geometry Finder (GF) subsystem. */
156
157 /* $ Disclaimer */
158
159 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
160 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
161 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
162 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
163 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
164 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
165 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
166 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
167 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
168 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
169
170 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
171 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
172 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
173 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
174 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
175 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
176
177 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
178 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
179 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
180 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
181
182 /* $ Required_Reading */
183
184 /* GF */
185
186 /* $ Keywords */
187
188 /* GEOMETRY */
189 /* ROOT */
190
191 /* $ Restrictions */
192
193 /* None. */
194
195 /* $ Author_and_Institution */
196
197 /* N.J. Bachman (JPL) */
198 /* L.E. Elson (JPL) */
199 /* E.D. Wright (JPL) */
200
201 /* $ Literature_References */
202
203 /* None. */
204
205 /* $ Version */
206
207 /* - SPICELIB Version 2.0.0 29-NOV-2016 (NJB) */
208
209 /* Upgraded to support surfaces represented by DSKs. */
210
211 /* Bug fix: removed declaration of NVRMAX parameter. */
212
213 /* - SPICELIB Version 1.3.0, 01-OCT-2011 (NJB) */
214
215 /* Added NWILUM parameter. */
216
217 /* - SPICELIB Version 1.2.0, 14-SEP-2010 (EDW) */
218
219 /* Added NWPA parameter. */
220
221 /* - SPICELIB Version 1.1.0, 08-SEP-2009 (EDW) */
222
223 /* Added NWRR parameter. */
224 /* Added NWUDS parameter. */
225
226 /* - SPICELIB Version 1.0.0, 21-FEB-2009 (NJB) (LSE) (EDW) */
227
228 /* -& */
229
230 /* Root finding parameters: */
231
232 /* CNVTOL is the default convergence tolerance used by the */
233 /* high-level GF search API routines. This tolerance is */
234 /* used to terminate searches for binary state transitions: */
235 /* when the time at which a transition occurs is bracketed */
236 /* by two times that differ by no more than CNVTOL, the */
237 /* transition time is considered to have been found. */
238
239 /* Units are TDB seconds. */
240
241
242 /* NWMAX is the maximum number of windows allowed for user-defined */
243 /* workspace array. */
244
245 /* DOUBLE PRECISION WORK ( LBCELL : MW, NWMAX ) */
246
247 /* Currently no more than twelve windows are required; the three */
248 /* extra windows are spares. */
249
250 /* Callers of GFEVNT can include this file and use the parameter */
251 /* NWMAX to declare the second dimension of the workspace array */
252 /* if necessary. */
253
254
255 /* Callers of GFIDST should declare their workspace window */
256 /* count using NWDIST. */
257
258
259 /* Callers of GFSEP should declare their workspace window */
260 /* count using NWSEP. */
261
262
263 /* Callers of GFRR should declare their workspace window */
264 /* count using NWRR. */
265
266
267 /* Callers of GFUDS should declare their workspace window */
268 /* count using NWUDS. */
269
270
271 /* Callers of GFPA should declare their workspace window */
272 /* count using NWPA. */
273
274
275 /* Callers of GFILUM should declare their workspace window */
276 /* count using NWILUM. */
277
278
279 /* ADDWIN is a parameter used to expand each interval of the search */
280 /* (confinement) window by a small amount at both ends in order to */
281 /* accommodate searches using equality constraints. The loaded */
282 /* kernel files must accommodate these expanded time intervals. */
283
284
285 /* FRMNLN is a string length for frame names. */
286
287
288 /* FOVTLN -- maximum length for FOV string. */
289
290
291 /* Specify the character strings that are allowed in the */
292 /* specification of field of view shapes. */
293
294
295 /* Character strings that are allowed in the */
296 /* specification of occultation types: */
297
298
299 /* Occultation target shape specifications: */
300
301
302 /* Specify the number of supported occultation types and occultation */
303 /* type string length: */
304
305
306 /* Instrument field-of-view (FOV) parameters */
307
308 /* Maximum number of FOV boundary vectors: */
309
310
311 /* FOV shape parameters: */
312
313 /* circle */
314 /* ellipse */
315 /* polygon */
316 /* rectangle */
317
318
319 /* End of file gf.inc. */
320
321 /* $ Abstract */
322
323 /* Include file zzabcorr.inc */
324
325 /* SPICE private file intended solely for the support of SPICE */
326 /* routines. Users should not include this file directly due */
327 /* to the volatile nature of this file */
328
329 /* The parameters below define the structure of an aberration */
330 /* correction attribute block. */
331
332 /* $ Disclaimer */
333
334 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
335 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
336 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
337 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
338 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
339 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
340 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
341 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
342 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
343 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
344
345 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
346 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
347 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
348 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
349 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
350 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
351
352 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
353 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
354 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
355 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
356
357 /* $ Parameters */
358
359 /* An aberration correction attribute block is an array of logical */
360 /* flags indicating the attributes of the aberration correction */
361 /* specified by an aberration correction string. The attributes */
362 /* are: */
363
364 /* - Is the correction "geometric"? */
365
366 /* - Is light time correction indicated? */
367
368 /* - Is stellar aberration correction indicated? */
369
370 /* - Is the light time correction of the "converged */
371 /* Newtonian" variety? */
372
373 /* - Is the correction for the transmission case? */
374
375 /* - Is the correction relativistic? */
376
377 /* The parameters defining the structure of the block are as */
378 /* follows: */
379
380 /* NABCOR Number of aberration correction choices. */
381
382 /* ABATSZ Number of elements in the aberration correction */
383 /* block. */
384
385 /* GEOIDX Index in block of geometric correction flag. */
386
387 /* LTIDX Index of light time flag. */
388
389 /* STLIDX Index of stellar aberration flag. */
390
391 /* CNVIDX Index of converged Newtonian flag. */
392
393 /* XMTIDX Index of transmission flag. */
394
395 /* RELIDX Index of relativistic flag. */
396
397 /* The following parameter is not required to define the block */
398 /* structure, but it is convenient to include it here: */
399
400 /* CORLEN The maximum string length required by any aberration */
401 /* correction string */
402
403 /* $ Author_and_Institution */
404
405 /* N.J. Bachman (JPL) */
406
407 /* $ Literature_References */
408
409 /* None. */
410
411 /* $ Version */
412
413 /* - SPICELIB Version 1.0.0, 18-DEC-2004 (NJB) */
414
415 /* -& */
416 /* Number of aberration correction choices: */
417
418
419 /* Aberration correction attribute block size */
420 /* (number of aberration correction attributes): */
421
422
423 /* Indices of attributes within an aberration correction */
424 /* attribute block: */
425
426
427 /* Maximum length of an aberration correction string: */
428
429
430 /* End of include file zzabcorr.inc */
431
432 /* $ Abstract */
433
434 /* This include file defines the dimension of the counter */
435 /* array used by various SPICE subsystems to uniquely identify */
436 /* changes in their states. */
437
438 /* $ Disclaimer */
439
440 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
441 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
442 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
443 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
444 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
445 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
446 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
447 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
448 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
449 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
450
451 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
452 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
453 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
454 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
455 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
456 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
457
458 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
459 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
460 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
461 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
462
463 /* $ Parameters */
464
465 /* CTRSIZ is the dimension of the counter array used by */
466 /* various SPICE subsystems to uniquely identify */
467 /* changes in their states. */
468
469 /* $ Author_and_Institution */
470
471 /* B.V. Semenov (JPL) */
472
473 /* $ Literature_References */
474
475 /* None. */
476
477 /* $ Version */
478
479 /* - SPICELIB Version 1.0.0, 29-JUL-2013 (BVS) */
480
481 /* -& */
482
483 /* End of include file. */
484
485
486 /* File: zzdsk.inc */
487
488
489 /* Version 4.0.0 13-NOV-2015 (NJB) */
490
491 /* Changed parameter LBTLEN to CVTLEN. */
492 /* Added parameter LMBCRV. */
493
494 /* Version 3.0.0 05-NOV-2015 (NJB) */
495
496 /* Added parameters */
497
498 /* CTRCOR */
499 /* ELLCOR */
500 /* GUIDED */
501 /* LBTLEN */
502 /* PNMBRL */
503 /* TANGNT */
504 /* TMTLEN */
505 /* UMBRAL */
506
507 /* Version 2.0.0 04-MAR-2015 (NJB) */
508
509 /* Removed declaration of parameter SHPLEN. */
510 /* This name is already in use in the include */
511 /* file gf.inc. */
512
513 /* Version 1.0.0 26-JAN-2015 (NJB) */
514
515
516 /* Parameters supporting METHOD string parsing: */
517
518
519 /* Local method length. */
520
521
522 /* Length of sub-point type string. */
523
524
525 /* Length of curve type string. */
526
527
528 /* Limb type parameter codes. */
529
530
531 /* Length of terminator type string. */
532
533
534 /* Terminator type and limb parameter codes. */
535
536
537 /* Length of aberration correction locus string. */
538
539
540 /* Aberration correction locus codes. */
541
542
543 /* End of include file zzdsk.inc */
544
545 /* $ Brief_I/O */
546
547 /* Variable I/O Description */
548 /* -------- --- -------------------------------------------------- */
549 /* METHOD I Computation method. */
550 /* TARGET I Name of target body. */
551 /* ILUSRC I Name of illumination source. */
552 /* ET I Epoch in ephemeris seconds past J2000 TDB. */
553 /* FIXREF I Body-fixed, body-centered target body frame. */
554 /* ABCORR I Desired aberration correction. */
555 /* OBSRVR I Name of observing body. */
556 /* SPOINT I Body-fixed coordinates of a target surface point. */
557 /* TRGEPC O Target surface point epoch. */
558 /* SRFVEC O Vector from observer to target surface point. */
559 /* PHASE O Phase angle at the surface point. */
560 /* INCDNC O Source incidence angle at the surface point. */
561 /* EMISSN O Emission angle at the surface point. */
562
563 /* $ Detailed_Input */
564
565 /* METHOD is a short string providing parameters defining */
566 /* the computation method to be used. In the syntax */
567 /* descriptions below, items delimited by brackets */
568 /* are optional. */
569
570 /* METHOD may be assigned the following values: */
571
572 /* 'ELLIPSOID' */
573
574 /* The illumination angle computation uses a */
575 /* triaxial ellipsoid to model the surface of the */
576 /* target body. The ellipsoid's radii must be */
577 /* available in the kernel pool. */
578
579
580 /* 'DSK/UNPRIORITIZED[/SURFACES = <surface list>]' */
581
582 /* The illumination angle computation uses */
583 /* topographic data to model the surface of the */
584 /* target body. These data must be provided by */
585 /* loaded DSK files. */
586
587 /* The surface list specification is optional. The */
588 /* syntax of the list is */
589
590 /* <surface 1> [, <surface 2>...] */
591
592 /* If present, it indicates that data only for the */
593 /* listed surfaces are to be used; however, data */
594 /* need not be available for all surfaces in the */
595 /* list. If absent, loaded DSK data for any surface */
596 /* associated with the target body are used. */
597
598 /* The surface list may contain surface names or */
599 /* surface ID codes. Names containing blanks must */
600 /* be delimited by double quotes, for example */
601
602 /* SURFACES = "Mars MEGDR 128 PIXEL/DEG" */
603
604 /* If multiple surfaces are specified, their names */
605 /* or IDs must be separated by commas. */
606
607 /* See the Particulars section below for details */
608 /* concerning use of DSK data. */
609
610
611 /* Neither case nor white space are significant in */
612 /* METHOD, except within double-quoted strings. For */
613 /* example, the string ' eLLipsoid ' is valid. */
614
615 /* Within double-quoted strings, blank characters are */
616 /* significant, but multiple consecutive blanks are */
617 /* considered equivalent to a single blank. Case is */
618 /* not significant. So */
619
620 /* "Mars MEGDR 128 PIXEL/DEG" */
621
622 /* is equivalent to */
623
624 /* " mars megdr 128 pixel/deg " */
625
626 /* but not to */
627
628 /* "MARS MEGDR128PIXEL/DEG" */
629
630
631 /* TARGET is the name of the target body. TARGET is */
632 /* case-insensitive, and leading and trailing blanks in */
633 /* TARGET are not significant. Optionally, you may */
634 /* supply a string containing the integer ID code for */
635 /* the object. For example both 'MOON' and '301' are */
636 /* legitimate strings that indicate the Moon is the */
637 /* target body. */
638
639
640 /* ILUSRC is the name of the illumination source. This source */
641 /* may be any ephemeris object. Case, blanks, and */
642 /* numeric values are treated in the same way as for the */
643 /* input TARGET. */
644
645
646 /* ET is the epoch, expressed as seconds past J2000 TDB, */
647 /* for which the apparent illumination angles at the */
648 /* specified surface point on the target body, as seen */
649 /* from the observing body, are to be computed. */
650
651
652 /* FIXREF is the name of the body-fixed, body-centered */
653 /* reference frame associated with the target body. The */
654 /* input surface point SPOINT and the output vector */
655 /* SRFVEC are expressed relative to this reference */
656 /* frame. The string FIXREF is case-insensitive, and */
657 /* leading and trailing blanks in FIXREF are not */
658 /* significant. */
659
660
661 /* ABCORR is the aberration correction to be used in computing */
662 /* the position and orientation of the target body and */
663 /* the location of the illumination source. */
664
665 /* For remote sensing applications, where the apparent */
666 /* illumination angles seen by the observer are desired, */
667 /* normally either of the corrections */
668
669 /* 'LT+S' */
670 /* 'CN+S' */
671
672 /* should be used. These and the other supported options */
673 /* are described below. ABCORR may be any of the */
674 /* following: */
675
676 /* 'NONE' No aberration correction. */
677
678 /* Let LT represent the one-way light time between the */
679 /* observer and SPOINT (note: NOT between the observer */
680 /* and the target body's center). The following values */
681 /* of ABCORR apply to the "reception" case in which */
682 /* photons depart from SPOINT at the light-time */
683 /* corrected epoch ET-LT and *arrive* at the observer's */
684 /* location at ET: */
685
686 /* 'LT' Correct both the position of SPOINT as */
687 /* seen by the observer, and the position */
688 /* of the illumination source as seen by */
689 /* the target, for light time. Correct the */
690 /* orientation of the target for light */
691 /* time. */
692
693 /* 'LT+S' Correct both the position of SPOINT as */
694 /* seen by the observer, and the position */
695 /* of the illumination source as seen by */
696 /* the target, for light time and stellar */
697 /* aberration. Correct the orientation of */
698 /* the target for light time. */
699
700 /* 'CN' Converged Newtonian light time */
701 /* correction. In solving the light time */
702 /* equations for target and the */
703 /* illumination source, the "CN" */
704 /* correction iterates until the solution */
705 /* converges. */
706
707 /* 'CN+S' Converged Newtonian light time and */
708 /* stellar aberration corrections. This */
709 /* option produces a solution that is at */
710 /* least as accurate at that obtainable */
711 /* with the 'LT+S' option. Whether the */
712 /* 'CN+S' solution is substantially more */
713 /* accurate depends on the geometry of the */
714 /* participating objects and on the */
715 /* accuracy of the input data. In all */
716 /* cases this routine will execute more */
717 /* slowly when a converged solution is */
718 /* computed. */
719
720 /* The following values of ABCORR apply to the */
721 /* "transmission" case in which photons *arrive* at */
722 /* SPOINT at the light-time corrected epoch ET+LT and */
723 /* *depart* from the observer's location at ET: */
724
725 /* 'XLT' "Transmission" case: correct for */
726 /* one-way light time using a Newtonian */
727 /* formulation. This correction yields the */
728 /* illumination angles at the moment that */
729 /* SPOINT receives photons emitted from the */
730 /* observer's location at ET. */
731
732 /* The light time correction uses an */
733 /* iterative solution of the light time */
734 /* equation. The solution invoked by the */
735 /* 'XLT' option uses one iteration. */
736
737 /* Both the target position as seen by the */
738 /* observer, and rotation of the target */
739 /* body, are corrected for light time. */
740
741 /* 'XLT+S' "Transmission" case: correct for */
742 /* one-way light time and stellar */
743 /* aberration using a Newtonian */
744 /* formulation This option modifies the */
745 /* angles obtained with the 'XLT' option */
746 /* to account for the observer's and */
747 /* target's velocities relative to the */
748 /* solar system barycenter (the latter */
749 /* velocity is used in computing the */
750 /* direction to the apparent illumination */
751 /* source). */
752
753 /* 'XCN' Converged Newtonian light time */
754 /* correction. This is the same as XLT */
755 /* correction but with further iterations */
756 /* to a converged Newtonian light time */
757 /* solution. */
758
759 /* 'XCN+S' "Transmission" case: converged */
760 /* Newtonian light time and stellar */
761 /* aberration corrections. This option */
762 /* produces a solution that is at least as */
763 /* accurate at that obtainable with the */
764 /* 'XLT+S' option. Whether the 'XCN+S' */
765 /* solution is substantially more accurate */
766 /* depends on the geometry of the */
767 /* participating objects and on the */
768 /* accuracy of the input data. In all */
769 /* cases this routine will execute more */
770 /* slowly when a converged solution is */
771 /* computed. */
772
773
774 /* Neither case nor white space are significant in */
775 /* ABCORR. For example, the string */
776
777 /* 'Lt + s' */
778
779 /* is valid. */
780
781
782 /* OBSRVR is the name of the observing body. The observing body */
783 /* is an ephemeris object: it typically is a spacecraft, */
784 /* the earth, or a surface point on the earth. OBSRVR is */
785 /* case-insensitive, and leading and trailing blanks in */
786 /* OBSRVR are not significant. Optionally, you may */
787 /* supply a string containing the integer ID code for */
788 /* the object. For example both 'MOON' and '301' are */
789 /* legitimate strings that indicate the Moon is the */
790 /* observer. */
791
792 /* OBSRVR may be not be identical to TARGET. */
793
794
795 /* SPOINT is a surface point on the target body, expressed in */
796 /* Cartesian coordinates, relative to the body-fixed */
797 /* target frame designated by FIXREF. */
798
799 /* SPOINT need not be visible from the observer's */
800 /* location at the epoch ET. */
801
802 /* The components of SPOINT have units of km. */
803
804
805 /* $ Detailed_Output */
806
807
808 /* TRGEPC is the "surface point epoch." TRGEPC is defined as */
809 /* follows: letting LT be the one-way light time between */
810 /* the observer and the input surface point SPOINT, */
811 /* TRGEPC is either the epoch ET-LT or ET depending on */
812 /* whether the requested aberration correction is, */
813 /* respectively, for received radiation or omitted. LT */
814 /* is computed using the method indicated by ABCORR. */
815
816 /* TRGEPC is expressed as seconds past J2000 TDB. */
817
818
819 /* SRFVEC is the vector from the observer's position at ET to */
820 /* the aberration-corrected (or optionally, geometric) */
821 /* position of SPOINT, where the aberration corrections */
822 /* are specified by ABCORR. SRFVEC is expressed in the */
823 /* target body-fixed reference frame designated by */
824 /* FIXREF, evaluated at TRGEPC. */
825
826 /* The components of SRFVEC are given in units of km. */
827
828 /* One can use the SPICELIB function VNORM to obtain the */
829 /* distance between the observer and SPOINT: */
830
831 /* DIST = VNORM ( SRFVEC ) */
832
833 /* The observer's position OBSPOS, relative to the */
834 /* target body's center, where the center's position is */
835 /* corrected for aberration effects as indicated by */
836 /* ABCORR, can be computed via the call: */
837
838 /* CALL VSUB ( SPOINT, SRFVEC, OBSPOS ) */
839
840 /* To transform the vector SRFVEC to a time-dependent */
841 /* reference frame REF at ET, a sequence of calls is */
842 /* required. For example, let XFORM be 3x3 matrix */
843 /* describing the transformation between the target */
844 /* body-fixed frame at TRGEPC to the time-dependent */
845 /* frame REF at ET. Then SRFVEC can be transformed to */
846 /* the result REFVEC as follows: */
847
848 /* CALL PXFRM2 ( FIXREF, REF, TRGEPC, ET, XFORM ) */
849 /* CALL MXV ( XFORM, SRFVEC, REFVEC ) */
850
851
852 /* PHASE is the phase angle at SPOINT, as seen from OBSRVR at */
853 /* time ET. This is the angle between the negative of */
854 /* the vector SRFVEC and the SPOINT-source vector at */
855 /* TRGEPC. Units are radians. The range of PHASE is */
856 /* [0, pi]. */
857
858 /* INCDNC is the illumination source incidence angle at SPOINT, */
859 /* as seen from OBSRVR at time ET. This is the angle */
860 /* between the surface normal vector at SPOINT and the */
861 /* SPOINT-source vector at TRGEPC. Units are radians. */
862 /* The range of INCDNC is [0, pi]. */
863
864 /* EMISSN is the emission angle at SPOINT, as seen from OBSRVR */
865 /* at time ET. This is the angle between the surface */
866 /* normal vector at SPOINT and the negative of the */
867 /* vector SRFVEC. Units are radians. The range of EMISSN */
868 /* is [0, pi]. */
869
870
871 /* $ Parameters */
872
873 /* None. */
874
875 /* $ Exceptions */
876
877
878 /* 1) If the specified aberration correction is relativistic or */
879 /* calls for stellar aberration but not light time correction, */
880 /* the error SPICE(NOTSUPPORTED) is signaled. If the specified */
881 /* aberration correction is any other unrecognized value, the */
882 /* error will be diagnosed and signaled by a routine in the call */
883 /* tree of this routine. */
884
885 /* 2) If any of the target, observer, or illumination source */
886 /* input strings cannot be converted to an integer ID code, the */
887 /* error SPICE(IDCODENOTFOUND) is signaled. */
888
889 /* 3) If OBSRVR and TARGET map to the same NAIF integer ID code, */
890 /* the error SPICE(BODIESNOTDISTINCT) is signaled. */
891
892 /* 4) If the input target body-fixed frame FIXREF is not */
893 /* recognized, the error SPICE(NOFRAME) is signaled. A frame */
894 /* name may fail to be recognized because a required frame */
895 /* specification kernel has not been loaded; another cause is a */
896 /* misspelling of the frame name. */
897
898 /* 5) If the input frame FIXREF is not centered at the target body, */
899 /* the error SPICE(INVALIDFRAME) is signaled. */
900
901 /* 6) If the input argument METHOD is not recognized, the error */
902 /* SPICE(INVALIDMETHOD) is signaled. */
903
904 /* 7) If insufficient ephemeris data have been loaded prior to */
905 /* calling ILLUMG, the error will be diagnosed and signaled by a */
906 /* routine in the call tree of this routine. Note that when */
907 /* light time correction is used, sufficient ephemeris data must */
908 /* be available to propagate the states of observer, target, and */
909 /* the illumination source to the solar system barycenter. */
910
911 /* 8) If the computation method specifies an ellipsoidal target */
912 /* shape and triaxial radii of the target body have not been */
913 /* loaded into the kernel pool prior to calling ILLUMG, the */
914 /* error will be diagnosed and signaled by a routine in the call */
915 /* tree of this routine. */
916
917 /* 9) The target must be an extended body: if any of the radii of */
918 /* the target body are non-positive, the error will be */
919 /* diagnosed and signaled by routines in the call tree of this */
920 /* routine. */
921
922 /* 10) If PCK data specifying the target body-fixed frame */
923 /* orientation have not been loaded prior to calling ILLUMG, */
924 /* the error will be diagnosed and signaled by a routine in the */
925 /* call tree of this routine. */
926
927 /* 11) If METHOD specifies that the target surface is represented by */
928 /* DSK data, and no DSK files are loaded for the specified */
929 /* target, the error is signaled by a routine in the call tree */
930 /* of this routine. */
931
932 /* 12) If METHOD specifies that the target surface is represented */
933 /* by DSK data, and data representing the portion of the surface */
934 /* on which SPOINT is located are not available, an error will */
935 /* be signaled by a routine in the call tree of this routine. */
936
937 /* 13) If METHOD specifies that the target surface is represented */
938 /* by DSK data, SPOINT must lie on the target surface, not above */
939 /* or below it. A small tolerance is used to allow for round-off */
940 /* error in the calculation determining whether SPOINT is on the */
941 /* surface. If, in the DSK case, SPOINT is too far from the */
942 /* surface, an error will be signaled by a routine in the call */
943 /* tree of this routine. */
944
945 /* If the surface is represented by a triaxial ellipsoid, SPOINT */
946 /* is not required to be close to the ellipsoid; however, the */
947 /* results computed by this routine will be unreliable if SPOINT */
948 /* is too far from the ellipsoid. */
949
950 /* $ Files */
951
952 /* Appropriate kernels must be loaded by the calling program before */
953 /* this routine is called. */
954
955 /* The following data are required: */
956
957 /* - SPK data: ephemeris data for target, observer, and the */
958 /* illumination source must be loaded. If aberration */
959 /* corrections are used, the states of target, observer, and */
960 /* the illumination source relative to the solar system */
961 /* barycenter must be calculable from the available ephemeris */
962 /* data. Typically ephemeris data are made available by loading */
963 /* one or more SPK files via FURNSH. */
964
965 /* - PCK data: rotation data for the target body must be */
966 /* loaded. These may be provided in a text or binary PCK file. */
967
968 /* - Shape data for the target body: */
969
970 /* PCK data: */
971
972 /* If the target body shape is modeled as an ellipsoid, */
973 /* triaxial radii for the target body must be loaded into */
974 /* the kernel pool. Typically this is done by loading a */
975 /* text PCK file via FURNSH. */
976
977 /* Triaxial radii are also needed if the target shape is */
978 /* modeled by DSK data, but the DSK NADIR method is */
979 /* selected. */
980
981 /* DSK data: */
982
983 /* If the target shape is modeled by DSK data, DSK files */
984 /* containing topographic data for the target body must be */
985 /* loaded. If a surface list is specified, data for at */
986 /* least one of the listed surfaces must be loaded. */
987
988 /* The following data may be required: */
989
990 /* - Frame data: if a frame definition is required to convert the */
991 /* observer and target states to the body-fixed frame of the */
992 /* target, that definition must be available in the kernel */
993 /* pool. Typically the definition is supplied by loading a */
994 /* frame kernel via FURNSH. */
995
996 /* - Surface name-ID associations: if surface names are specified */
997 /* in METHOD, the association of these names with their */
998 /* corresponding surface ID codes must be established by */
999 /* assignments of the kernel variables */
1000
1001 /* NAIF_SURFACE_NAME */
1002 /* NAIF_SURFACE_CODE */
1003 /* NAIF_SURFACE_BODY */
1004
1005 /* Normally these associations are made by loading a text */
1006 /* kernel containing the necessary assignments. An example */
1007 /* of such an assignment is */
1008
1009 /* NAIF_SURFACE_NAME += 'Mars MEGDR 128 PIXEL/DEG' */
1010 /* NAIF_SURFACE_CODE += 1 */
1011 /* NAIF_SURFACE_BODY += 499 */
1012
1013 /* In all cases, kernel data are normally loaded once per program */
1014 /* run, NOT every time this routine is called. */
1015
1016
1017 /* $ Particulars */
1018
1019 /* SPICELIB contains four routines that compute illumination angles: */
1020
1021 /* ILLUMF (same as this routine, except that illumination */
1022 /* and visibility flags are returned) */
1023
1024 /* ILLUMG (this routine) */
1025
1026 /* ILUMIN (same as ILLUMG, except that the sun is fixed */
1027 /* as the illumination source) */
1028
1029 /* ILLUM (deprecated) */
1030
1031 /* ILLUMF is the most capable of the set. */
1032
1033
1034 /* Illumination angles */
1035 /* =================== */
1036
1037 /* The term "illumination angles" refers to the following set of */
1038 /* angles: */
1039
1040
1041 /* phase angle Angle between the vectors from the */
1042 /* surface point to the observer and */
1043 /* from the surface point to the */
1044 /* illumination source. */
1045
1046 /* incidence angle Angle between the surface normal at */
1047 /* the specified surface point and the */
1048 /* vector from the surface point to the */
1049 /* illumination source. */
1050
1051 /* emission angle Angle between the surface normal at */
1052 /* the specified surface point and the */
1053 /* vector from the surface point to the */
1054 /* observer. */
1055
1056 /* The diagram below illustrates the geometric relationships */
1057 /* defining these angles. The labels for the incidence, emission, */
1058 /* and phase angles are "inc.", "e.", and "phase". */
1059
1060
1061 /* * */
1062 /* illumination source */
1063
1064 /* surface normal vector */
1065 /* ._ _. */
1066 /* |\ /| illumination */
1067 /* \ phase / source vector */
1068 /* \ . . / */
1069 /* . . */
1070 /* \ ___ / */
1071 /* . \/ \/ */
1072 /* _\ inc./ */
1073 /* . / \ / */
1074 /* . | e. \ / */
1075 /* * <--------------- * surface point on */
1076 /* viewing vector target body */
1077 /* location to viewing */
1078 /* (observer) location */
1079
1080
1081 /* Note that if the target-observer vector, the target normal vector */
1082 /* at the surface point, and the target-illumination source vector */
1083 /* are coplanar, then phase is the sum of the incidence and emission */
1084 /* angles. This rarely occurs; usually */
1085
1086 /* phase angle < incidence angle + emission angle */
1087
1088 /* All of the above angles can be computed using light time */
1089 /* corrections, light time and stellar aberration corrections, or no */
1090 /* aberration corrections. In order to describe apparent geometry as */
1091 /* observed by a remote sensing instrument, both light time and */
1092 /* stellar aberration corrections should be used. */
1093
1094 /* The way aberration corrections are applied by this routine */
1095 /* is described below. */
1096
1097 /* Light time corrections */
1098 /* ====================== */
1099
1100 /* Observer-target surface point vector */
1101 /* ------------------------------------ */
1102
1103 /* Let ET be the epoch at which an observation or remote */
1104 /* sensing measurement is made, and let ET - LT ("LT" stands */
1105 /* for "light time") be the epoch at which the photons */
1106 /* received at ET were emitted from the surface point SPOINT. */
1107 /* Note that the light time between the surface point and */
1108 /* observer will generally differ from the light time between */
1109 /* the target body's center and the observer. */
1110
1111
1112 /* Target body's orientation */
1113 /* ------------------------- */
1114
1115 /* Using the definitions of ET and LT above, the target body's */
1116 /* orientation at ET - LT is used. The surface normal is */
1117 /* dependent on the target body's orientation, so the body's */
1118 /* orientation model must be evaluated for the correct epoch. */
1119
1120
1121 /* Target body -- illumination source vector */
1122 /* ----------------------------------------- */
1123
1124 /* The surface features on the target body near SPOINT will */
1125 /* appear in a measurement made at ET as they were at ET-LT. */
1126 /* In particular, lighting on the target body is dependent on */
1127 /* the apparent location of the illumination source as seen */
1128 /* from the target body at ET-LT. So, a second light time */
1129 /* correction is used to compute the position of the */
1130 /* illumination source relative to the surface point. */
1131
1132
1133 /* Stellar aberration corrections */
1134 /* ============================== */
1135
1136 /* Stellar aberration corrections are applied only if */
1137 /* light time corrections are applied as well. */
1138
1139 /* Observer-target surface point body vector */
1140 /* ----------------------------------------- */
1141
1142 /* When stellar aberration correction is performed, the */
1143 /* direction vector SRFVEC is adjusted so as to point to the */
1144 /* apparent position of SPOINT: considering SPOINT to be an */
1145 /* ephemeris object, SRFVEC points from the observer's */
1146 /* position at ET to the light time and stellar aberration */
1147 /* corrected position of SPOINT. */
1148
1149 /* Target body-illumination source vector */
1150 /* -------------------------------------- */
1151
1152 /* The target body-illumination source vector is the apparent */
1153 /* position of the illumination source, corrected for light */
1154 /* time and stellar aberration, as seen from the target body */
1155 /* at time ET-LT. */
1156
1157
1158 /* Using DSK data */
1159 /* ============== */
1160
1161 /* DSK loading and unloading */
1162 /* ------------------------- */
1163
1164 /* DSK files providing data used by this routine are loaded by */
1165 /* calling FURNSH and can be unloaded by calling UNLOAD or */
1166 /* KCLEAR. See the documentation of FURNSH for limits on numbers */
1167 /* of loaded DSK files. */
1168
1169 /* For run-time efficiency, it's desirable to avoid frequent */
1170 /* loading and unloading of DSK files. When there is a reason to */
1171 /* use multiple versions of data for a given target body---for */
1172 /* example, if topographic data at varying resolutions are to be */
1173 /* used---the surface list can be used to select DSK data to be */
1174 /* used for a given computation. It is not necessary to unload */
1175 /* the data that are not to be used. This recommendation presumes */
1176 /* that DSKs containing different versions of surface data for a */
1177 /* given body have different surface ID codes. */
1178
1179
1180 /* DSK data priority */
1181 /* ----------------- */
1182
1183 /* A DSK coverage overlap occurs when two segments in loaded DSK */
1184 /* files cover part or all of the same domain---for example, a */
1185 /* given longitude-latitude rectangle---and when the time */
1186 /* intervals of the segments overlap as well. */
1187
1188 /* When DSK data selection is prioritized, in case of a coverage */
1189 /* overlap, if the two competing segments are in different DSK */
1190 /* files, the segment in the DSK file loaded last takes */
1191 /* precedence. If the two segments are in the same file, the */
1192 /* segment located closer to the end of the file takes */
1193 /* precedence. */
1194
1195 /* When DSK data selection is unprioritized, data from competing */
1196 /* segments are combined. For example, if two competing segments */
1197 /* both represent a surface as sets of triangular plates, the */
1198 /* union of those sets of plates is considered to represent the */
1199 /* surface. */
1200
1201 /* Currently only unprioritized data selection is supported. */
1202 /* Because prioritized data selection may be the default behavior */
1203 /* in a later version of the routine, the UNPRIORITIZED keyword is */
1204 /* required in the METHOD argument. */
1205
1206
1207 /* Syntax of the METHOD input argument */
1208 /* ----------------------------------- */
1209
1210 /* The keywords and surface list in the METHOD argument */
1211 /* are called "clauses." The clauses may appear in any */
1212 /* order, for example */
1213
1214 /* DSK/<surface list>/UNPRIORITIZED */
1215 /* DSK/UNPRIORITIZED/<surface list> */
1216 /* UNPRIORITIZED/<surface list>/DSK */
1217
1218 /* The simplest form of the METHOD argument specifying use of */
1219 /* DSK data is one that lacks a surface list, for example: */
1220
1221 /* 'DSK/UNPRIORITIZED' */
1222
1223 /* For applications in which all loaded DSK data for the target */
1224 /* body are for a single surface, and there are no competing */
1225 /* segments, the above string suffices. This is expected to be */
1226 /* the usual case. */
1227
1228 /* When, for the specified target body, there are loaded DSK */
1229 /* files providing data for multiple surfaces for that body, the */
1230 /* surfaces to be used by this routine for a given call must be */
1231 /* specified in a surface list, unless data from all of the */
1232 /* surfaces are to be used together. */
1233
1234 /* The surface list consists of the string */
1235
1236 /* SURFACES = */
1237
1238 /* followed by a comma-separated list of one or more surface */
1239 /* identifiers. The identifiers may be names or integer codes in */
1240 /* string format. For example, suppose we have the surface */
1241 /* names and corresponding ID codes shown below: */
1242
1243 /* Surface Name ID code */
1244 /* ------------ ------- */
1245 /* 'Mars MEGDR 128 PIXEL/DEG' 1 */
1246 /* 'Mars MEGDR 64 PIXEL/DEG' 2 */
1247 /* 'Mars_MRO_HIRISE' 3 */
1248
1249 /* If data for all of the above surfaces are loaded, then */
1250 /* data for surface 1 can be specified by either */
1251
1252 /* 'SURFACES = 1' */
1253
1254 /* or */
1255
1256 /* 'SURFACES = "Mars MEGDR 128 PIXEL/DEG"' */
1257
1258 /* Double quotes are used to delimit the surface name because */
1259 /* it contains blank characters. */
1260
1261 /* To use data for surfaces 2 and 3 together, any */
1262 /* of the following surface lists could be used: */
1263
1264 /* 'SURFACES = 2, 3' */
1265
1266 /* 'SURFACES = "Mars MEGDR 64 PIXEL/DEG", 3' */
1267
1268 /* 'SURFACES = 2, Mars_MRO_HIRISE' */
1269
1270 /* 'SURFACES = "Mars MEGDR 64 PIXEL/DEG", Mars_MRO_HIRISE' */
1271
1272 /* An example of a METHOD argument that could be constructed */
1273 /* using one of the surface lists above is */
1274
1275 /* 'DSK/UNPRIORITIZED/SURFACES = ' */
1276 /* // '"Mars MEGDR 64 PIXEL/DEG", 3' */
1277
1278
1279 /* Aberration corrections using DSK data */
1280 /* ------------------------------------- */
1281
1282 /* For irregularly shaped target bodies, the distance between the */
1283 /* observer and the nearest surface intercept need not be a */
1284 /* continuous function of time; hence the one-way light time */
1285 /* between the intercept and the observer may be discontinuous as */
1286 /* well. In such cases, the computed light time, which is found */
1287 /* using an iterative algorithm, may converge slowly or not at */
1288 /* all. In all cases, the light time computation will terminate, */
1289 /* but the result may be less accurate than expected. */
1290
1291
1292 /* $ Examples */
1293
1294 /* The numerical results shown for this example may differ across */
1295 /* platforms. The results depend on the SPICE kernels used as */
1296 /* input, the compiler and supporting libraries, and the machine */
1297 /* specific arithmetic implementation. */
1298
1299 /* 1) Find the phase, solar incidence, and emission angles at the */
1300 /* sub-solar and sub-spacecraft points on Mars as seen from the */
1301 /* Mars Global Surveyor spacecraft at a specified UTC time. Use */
1302 /* light time and stellar aberration corrections. */
1303
1304 /* Use both an ellipsoidal Mars shape model and topographic data */
1305 /* provided by a DSK file. */
1306
1307 /* Use the meta-kernel shown below to load the required SPICE */
1308 /* kernels. */
1309
1310 /* KPL/MK */
1311
1312 /* File: illumg_ex1.tm */
1313
1314 /* This meta-kernel is intended to support operation of SPICE */
1315 /* example programs. The kernels shown here should not be */
1316 /* assumed to contain adequate or correct versions of data */
1317 /* required by SPICE-based user applications. */
1318
1319 /* In order for an application to use this meta-kernel, the */
1320 /* kernels referenced here must be present in the user's */
1321 /* current working directory. */
1322
1323 /* The names and contents of the kernels referenced */
1324 /* by this meta-kernel are as follows: */
1325
1326 /* File name Contents */
1327 /* --------- -------- */
1328 /* de430.bsp Planetary ephemeris */
1329 /* mar097.bsp Mars satellite ephemeris */
1330 /* pck00010.tpc Planet orientation and */
1331 /* radii */
1332 /* naif0011.tls Leapseconds */
1333 /* mgs_ext12_ipng_mgs95j.bsp MGS ephemeris */
1334 /* megr90n000cb_plate.bds Plate model based on */
1335 /* MEGDR DEM, resolution */
1336 /* 4 pixels/degree. */
1337
1338 /* \begindata */
1339
1340 /* KERNELS_TO_LOAD = ( 'de430.bsp', */
1341 /* 'mar097.bsp', */
1342 /* 'pck00010.tpc', */
1343 /* 'naif0011.tls', */
1344 /* 'mgs_ext12_ipng_mgs95j.bsp', */
1345 /* 'megr90n000cb_plate.bds' ) */
1346 /* \begintext */
1347
1348
1349
1350 /* Example code begins here. */
1351
1352
1353 /* PROGRAM EX1 */
1354 /* IMPLICIT NONE */
1355 /* C */
1356 /* C SPICELIB functions */
1357 /* C */
1358 /* DOUBLE PRECISION DPR */
1359 /* C */
1360 /* C Local parameters */
1361 /* C */
1362 /* CHARACTER*(*) F1 */
1363 /* PARAMETER ( F1 = '(A,F15.9)' ) */
1364
1365 /* CHARACTER*(*) F2 */
1366 /* PARAMETER ( F2 = '(A)' ) */
1367
1368 /* CHARACTER*(*) F3 */
1369 /* PARAMETER ( F3 = '(A,2(2X,L))' ) */
1370
1371 /* CHARACTER*(*) META */
1372 /* PARAMETER ( META = 'illumg_ex1.tm' ) */
1373
1374 /* INTEGER NAMLEN */
1375 /* PARAMETER ( NAMLEN = 32 ) */
1376
1377 /* INTEGER TIMLEN */
1378 /* PARAMETER ( TIMLEN = 25 ) */
1379
1380 /* INTEGER CORLEN */
1381 /* PARAMETER ( CORLEN = 5 ) */
1382
1383 /* INTEGER MTHLEN */
1384 /* PARAMETER ( MTHLEN = 50 ) */
1385
1386 /* INTEGER NMETH */
1387 /* PARAMETER ( NMETH = 2 ) */
1388 /* C */
1389 /* C Local variables */
1390 /* C */
1391 /* CHARACTER*(CORLEN) ABCORR */
1392 /* CHARACTER*(NAMLEN) FIXREF */
1393 /* CHARACTER*(MTHLEN) ILUMTH ( NMETH ) */
1394 /* CHARACTER*(NAMLEN) OBSRVR */
1395 /* CHARACTER*(MTHLEN) SUBMTH ( NMETH ) */
1396 /* CHARACTER*(NAMLEN) TARGET */
1397 /* CHARACTER*(TIMLEN) UTC */
1398
1399 /* DOUBLE PRECISION ET */
1400 /* DOUBLE PRECISION SRFVEC ( 3 ) */
1401 /* DOUBLE PRECISION SSCEMI */
1402 /* DOUBLE PRECISION SSCPHS */
1403 /* DOUBLE PRECISION SSCPT ( 3 ) */
1404 /* DOUBLE PRECISION SSCSOL */
1405 /* DOUBLE PRECISION SSLEMI */
1406 /* DOUBLE PRECISION SSLPHS */
1407 /* DOUBLE PRECISION SSLSOL */
1408 /* DOUBLE PRECISION SSOLPT ( 3 ) */
1409 /* DOUBLE PRECISION TRGEPC */
1410
1411 /* INTEGER I */
1412
1413
1414 /* C */
1415 /* C Initial values */
1416 /* C */
1417 /* DATA ILUMTH / 'Ellipsoid', */
1418 /* . 'DSK/Unprioritized' / */
1419
1420 /* DATA SUBMTH / 'Near Point/Ellipsoid', */
1421 /* . 'DSK/Nadir/Unprioritized' / */
1422
1423 /* C */
1424 /* C Load kernel files. */
1425 /* C */
1426 /* CALL FURNSH ( META ) */
1427 /* C */
1428 /* C Convert the UTC request time string to seconds past */
1429 /* C J2000 TDB. */
1430 /* C */
1431 /* UTC = '2003 OCT 13 06:00:00 UTC' */
1432
1433 /* CALL UTC2ET ( UTC, ET ) */
1434
1435 /* WRITE (*,F2) ' ' */
1436 /* WRITE (*,F2) 'UTC epoch is '//UTC */
1437 /* C */
1438 /* C Assign observer and target names. The acronym MGS */
1439 /* C indicates Mars Global Surveyor. See NAIF_IDS for a */
1440 /* C list of names recognized by SPICE. Also set the */
1441 /* C aberration correction flag. */
1442 /* C */
1443 /* TARGET = 'Mars' */
1444 /* OBSRVR = 'MGS' */
1445 /* FIXREF = 'IAU_MARS' */
1446 /* ABCORR = 'CN+S' */
1447
1448 /* DO I = 1, NMETH */
1449 /* C */
1450 /* C Find the sub-solar point on Mars as */
1451 /* C seen from the MGS spacecraft at ET. Use the */
1452 /* C "near point" style of sub-point definition */
1453 /* C when the shape model is an ellipsoid, and use */
1454 /* C the "nadir" style when the shape model is */
1455 /* C provided by DSK data. This makes it easy to */
1456 /* C verify the solar incidence angle when */
1457 /* C the target is modeled as an ellipsoid. */
1458 /* C */
1459 /* CALL SUBSLR ( SUBMTH(I), TARGET, ET, */
1460 /* . FIXREF, ABCORR, OBSRVR, */
1461 /* . SSOLPT, TRGEPC, SRFVEC ) */
1462 /* C */
1463 /* C Now find the sub-spacecraft point. */
1464 /* C */
1465 /* CALL SUBPNT ( SUBMTH(I), TARGET, ET, */
1466 /* . FIXREF, ABCORR, OBSRVR, */
1467 /* . SSCPT, TRGEPC, SRFVEC ) */
1468 /* C */
1469 /* C Find the phase, solar incidence, and emission */
1470 /* C angles at the sub-solar point on Mars as */
1471 /* C seen from MGS at time ET. */
1472 /* C */
1473 /* CALL ILLUMG ( ILUMTH(I), TARGET, 'SUN', */
1474 /* . ET, FIXREF, ABCORR, */
1475 /* . OBSRVR, SSOLPT, TRGEPC, */
1476 /* . SRFVEC, SSLPHS, SSLSOL, */
1477 /* . SSLEMI ) */
1478 /* C */
1479 /* C Do the same for the sub-spacecraft point. */
1480 /* C */
1481 /* CALL ILLUMG ( ILUMTH(I), TARGET, 'SUN', */
1482 /* . ET, FIXREF, ABCORR, */
1483 /* . OBSRVR, SSCPT, TRGEPC, */
1484 /* . SRFVEC, SSCPHS, SSCSOL, */
1485 /* . SSCEMI ) */
1486 /* C */
1487 /* C Convert the angles to degrees and write them out. */
1488 /* C */
1489 /* SSLPHS = DPR() * SSLPHS */
1490 /* SSLSOL = DPR() * SSLSOL */
1491 /* SSLEMI = DPR() * SSLEMI */
1492
1493 /* SSCPHS = DPR() * SSCPHS */
1494 /* SSCSOL = DPR() * SSCSOL */
1495 /* SSCEMI = DPR() * SSCEMI */
1496
1497 /* WRITE (*,F2) ' ' */
1498 /* WRITE (*,F2) ' ILLUMG method: '//ILUMTH(I) */
1499 /* WRITE (*,F2) ' SUBPNT method: '//SUBMTH(I) */
1500 /* WRITE (*,F2) ' SUBSLR method: '//SUBMTH(I) */
1501 /* WRITE (*,F2) ' ' */
1502 /* WRITE (*,F2) ' Illumination angles at the ' */
1503 /* . // 'sub-solar point:' */
1504 /* WRITE (*,F2) ' ' */
1505
1506 /* WRITE (*,F1) ' Phase angle (deg.): ', */
1507 /* . SSLPHS */
1508 /* WRITE (*,F1) ' Solar incidence angle (deg.): ', */
1509 /* . SSLSOL */
1510 /* WRITE (*,F1) ' Emission angle (deg.): ', */
1511 /* . SSLEMI */
1512 /* WRITE (*,F2) ' ' */
1513
1514 /* IF ( I .EQ. 1 ) THEN */
1515 /* WRITE (*,F2) ' The solar incidence angle ' */
1516 /* . // 'should be 0.' */
1517 /* WRITE (*,F2) ' The emission and phase ' */
1518 /* . // 'angles should be equal.' */
1519 /* WRITE (*,F2) ' ' */
1520 /* END IF */
1521
1522
1523 /* WRITE (*,F2) ' Illumination angles at the ' */
1524 /* . // 'sub-s/c point:' */
1525 /* WRITE (*,F2) ' ' */
1526 /* WRITE (*,F1) ' Phase angle (deg.): ', */
1527 /* . SSCPHS */
1528 /* WRITE (*,F1) ' Solar incidence angle (deg.): ', */
1529 /* . SSCSOL */
1530 /* WRITE (*,F1) ' Emission angle (deg.): ', */
1531 /* . SSCEMI */
1532 /* WRITE (*,F2) ' ' */
1533
1534 /* IF ( I .EQ. 1 ) THEN */
1535 /* WRITE (*,F2) ' The emission angle ' */
1536 /* . // 'should be 0.' */
1537 /* WRITE (*,F2) ' The solar incidence ' */
1538 /* . // 'and phase angles should be equal.' */
1539 /* END IF */
1540
1541 /* END DO */
1542
1543 /* END */
1544
1545
1546 /* When this program was executed on a PC/Linux/gfortran 64-bit */
1547 /* platform, the output was: */
1548
1549
1550 /* UTC epoch is 2003 OCT 13 06:00:00 UTC */
1551
1552 /* ILLUMG method: Ellipsoid */
1553 /* SUBPNT method: Near Point/Ellipsoid */
1554 /* SUBSLR method: Near Point/Ellipsoid */
1555
1556 /* Illumination angles at the sub-solar point: */
1557
1558 /* Phase angle (deg.): 138.370270685 */
1559 /* Solar incidence angle (deg.): 0.000000000 */
1560 /* Emission angle (deg.): 138.370270685 */
1561
1562 /* The solar incidence angle should be 0. */
1563 /* The emission and phase angles should be equal. */
1564
1565 /* Illumination angles at the sub-s/c point: */
1566
1567 /* Phase angle (deg.): 101.439331040 */
1568 /* Solar incidence angle (deg.): 101.439331041 */
1569 /* Emission angle (deg.): 0.000000002 */
1570
1571 /* The emission angle should be 0. */
1572 /* The solar incidence and phase angles should be equal. */
1573
1574 /* ILLUMG method: DSK/Unprioritized */
1575 /* SUBPNT method: DSK/Nadir/Unprioritized */
1576 /* SUBSLR method: DSK/Nadir/Unprioritized */
1577
1578 /* Illumination angles at the sub-solar point: */
1579
1580 /* Phase angle (deg.): 138.387071677 */
1581 /* Solar incidence angle (deg.): 0.967122745 */
1582 /* Emission angle (deg.): 137.621480599 */
1583
1584 /* Illumination angles at the sub-s/c point: */
1585
1586 /* Phase angle (deg.): 101.439331359 */
1587 /* Solar incidence angle (deg.): 101.555993667 */
1588 /* Emission angle (deg.): 0.117861156 */
1589
1590
1591 /* $ Restrictions */
1592
1593 /* None. */
1594
1595 /* $ Literature_References */
1596
1597 /* None. */
1598
1599 /* $ Author_and_Institution */
1600
1601 /* N.J. Bachman (JPL) */
1602 /* B.V. Semenov (JPL) */
1603
1604 /* $ Version */
1605
1606 /* - SPICELIB Version 2.0.0, 04-APR-2017 (NJB) */
1607
1608 /* 07-APR-2016 (NJB) */
1609
1610 /* Upgraded to support surfaces represented by DSKs. */
1611
1612 /* - SPICELIB Version 1.0.0, 31-MAR-2014 (NJB)(BVS) */
1613
1614 /* -& */
1615 /* $ Index_Entries */
1616
1617 /* illumination angles general source */
1618 /* lighting angles general source */
1619 /* phase angle general source */
1620 /* incidence angle general source */
1621 /* emission angle general source */
1622
1623 /* -& */
1624 /* $ Revisions */
1625
1626 /* None. */
1627
1628 /* -& */
1629
1630 /* SPICELIB functions */
1631
1632
1633 /* Local parameters */
1634
1635
1636 /* Saved body name length. */
1637
1638
1639 /* Saved frame name length. */
1640
1641
1642 /* Local variables */
1643
1644
1645 /* Saved name/ID item declarations. */
1646
1647
1648 /* Saved frame name/ID item declarations. */
1649
1650
1651 /* Saved surface name/ID item declarations. */
1652
1653
1654 /* Saved variables */
1655
1656
1657 /* Saved name/ID items. */
1658
1659
1660 /* Saved frame name/ID items. */
1661
1662
1663 /* Saved surface name/ID items. */
1664
1665
1666 /* Note: XMIT need not be saved, since it's used only */
1667 /* for error checking when an aberration correction flag */
1668 /* is parsed. */
1669
1670
1671 /* Initial values */
1672
1673
1674 /* Standard SPICE error handling. */
1675
1676 if (return_()) {
1677 return 0;
1678 }
1679 chkin_("ILLUMG", (ftnlen)6);
1680
1681 /* Counter initialization is done separately. */
1682
1683 if (first) {
1684
1685 /* Initialize counters. */
1686
1687 zzctruin_(svctr1);
1688 zzctruin_(svctr2);
1689 zzctruin_(svctr3);
1690 }
1691
1692 /* If necessary, parse the aberration correction flag. */
1693
1694 if (first || s_cmp(abcorr, prvcor, abcorr_len, (ftnlen)5) != 0) {
1695
1696 /* Make sure the results of this block won't be reused */
1697 /* if we bail out due to an error. */
1698
1699 s_copy(prvcor, " ", (ftnlen)5, (ftnlen)1);
1700
1701 /* The aberration correction flag differs from the value it */
1702 /* had on the previous call, if any. Analyze the new flag. */
1703
1704 zzvalcor_(abcorr, attblk, abcorr_len);
1705 if (failed_()) {
1706 chkout_("ILLUMG", (ftnlen)6);
1707 return 0;
1708 }
1709
1710 /* Set logical flags indicating the attributes of the requested */
1711 /* correction: */
1712
1713 /* XMIT is .TRUE. when the correction is for transmitted */
1714 /* radiation. */
1715
1716 /* USELT is .TRUE. when any type of light time correction */
1717 /* (normal or converged Newtonian) is specified. */
1718
1719 /* USESTL indicates stellar aberration corrections. */
1720
1721
1722 /* The above definitions are consistent with those used by */
1723 /* ZZVALCOR. */
1724
1725 xmit = attblk[4];
1726 uselt = attblk[1];
1727
1728 /* The aberration correction flag is recognized; save it. */
1729
1730 s_copy(prvcor, abcorr, (ftnlen)5, abcorr_len);
1731
1732 /* We do NOT set FIRST to .FALSE. here, since we're not */
1733 /* yet done with it. */
1734
1735 }
1736
1737 /* Get the target ID code here, since it will be needed */
1738 /* for the initialization calls below. */
1739
1740 zzbods2c_(svctr1, svtarg, &svtcde, &svfnd1, target, &trgcde, &fnd, (
1741 ftnlen)36, target_len);
1742 if (! fnd) {
1743 setmsg_("The target, '#', is not a recognized name for an ephemeris "
1744 "object. The cause of this problem may be that you need an up"
1745 "dated version of the SPICE Toolkit. ", (ftnlen)155);
1746 errch_("#", target, (ftnlen)1, target_len);
1747 sigerr_("SPICE(IDCODENOTFOUND)", (ftnlen)21);
1748 chkout_("ILLUMG", (ftnlen)6);
1749 return 0;
1750 }
1751
1752 /* Check whether the surface name/ID mapping has been updated. */
1753
1754 zzsrftrk_(svctr4, &surfup);
1755
1756 /* If necessary, parse the method specification. PRVMTH */
1757 /* and the derived flags NEAR and ELIPSD start out with */
1758 /* valid values. PRVMTH records the last valid value of */
1759 /* METHOD; ELIPSD is the corresponding shape flag. */
1760
1761 if (first || surfup || s_cmp(method, prvmth, method_len, (ftnlen)80) != 0)
1762 {
1763
1764 /* Set the previous method string to an invalid value, so it */
1765 /* cannot match any future, valid input. This will force this */
1766 /* routine to parse the input method on the next call if any */
1767 /* failure occurs in this branch. Once success is assured, we can */
1768 /* record the current method in the previous method string. */
1769
1770 s_copy(prvmth, " ", (ftnlen)80, (ftnlen)1);
1771
1772 /* Parse the method string. If the string is valid, the */
1773 /* outputs SHAPE and SUBTYP will always be be set. However, */
1774 /* SUBTYP is not used in this routine. */
1775
1776 /* For DSK shapes, the surface list array and count will be set */
1777 /* if the method string contains a surface list. */
1778
1779 zzprsmet_(&trgcde, method, &c__100, shpstr, subtyp, &pri, &nsurf,
1780 srflst, pntdef, trmstr, method_len, (ftnlen)9, (ftnlen)20, (
1781 ftnlen)20, (ftnlen)20);
1782 if (failed_()) {
1783 chkout_("ILLUMG", (ftnlen)6);
1784 return 0;
1785 }
1786 if (eqstr_(shpstr, "ELLIPSOID", (ftnlen)9, (ftnlen)9)) {
1787 shape = 1;
1788 } else if (eqstr_(shpstr, "DSK", (ftnlen)9, (ftnlen)3)) {
1789 shape = 2;
1790 } else {
1791
1792 /* This is a backstop check. */
1793
1794 setmsg_("[1] Returned shape value from method string was <#>.", (
1795 ftnlen)52);
1796 errch_("#", shpstr, (ftnlen)1, (ftnlen)9);
1797 sigerr_("SPICE(BUG)", (ftnlen)10);
1798 chkout_("ILLUMG", (ftnlen)6);
1799 return 0;
1800 }
1801
1802 /* There should be no subtype specification in the method */
1803 /* string. */
1804
1805 if (s_cmp(subtyp, " ", (ftnlen)20, (ftnlen)1) != 0) {
1806 setmsg_("Spurious sub-observer point type <#> was present in the"
1807 " method string #. The sub-observer type is valid in the "
1808 "method strings for SUBPNT and SUBSLR, but is not applica"
1809 "ble for ILLUMG.", (ftnlen)182);
1810 errch_("#", subtyp, (ftnlen)1, (ftnlen)20);
1811 errch_("#", method, (ftnlen)1, method_len);
1812 sigerr_("SPICE(INVALIDMETHOD)", (ftnlen)20);
1813 chkout_("ILLUMG", (ftnlen)6);
1814 return 0;
1815 }
1816 s_copy(prvmth, method, (ftnlen)80, method_len);
1817 }
1818
1819 /* At this point, the first pass actions were successful. */
1820
1821 first = FALSE_;
1822
1823 /* Obtain integer codes for the observer and */
1824 /* illumination source. */
1825
1826 zzbods2c_(svctr2, svobsr, &svobsc, &svfnd2, obsrvr, &obscde, &fnd, (
1827 ftnlen)36, obsrvr_len);
1828 if (! fnd) {
1829 setmsg_("The observer, '#', is not a recognized name for an ephemeri"
1830 "s object. The cause of this problem may be that you need an "
1831 "updated version of the SPICE Toolkit. ", (ftnlen)157);
1832 errch_("#", obsrvr, (ftnlen)1, obsrvr_len);
1833 sigerr_("SPICE(IDCODENOTFOUND)", (ftnlen)21);
1834 chkout_("ILLUMG", (ftnlen)6);
1835 return 0;
1836 }
1837
1838 /* Check the observer and target body codes. If they are equal, */
1839 /* signal an error. */
1840
1841 if (obscde == trgcde) {
1842 setmsg_("In computing illumination angles, the observing body and ta"
1843 "rget body are the same. Both are #.", (ftnlen)94);
1844 errch_("#", obsrvr, (ftnlen)1, obsrvr_len);
1845 sigerr_("SPICE(BODIESNOTDISTINCT)", (ftnlen)24);
1846 chkout_("ILLUMG", (ftnlen)6);
1847 return 0;
1848 }
1849
1850 /* Determine the attributes of the frame designated by FIXREF. */
1851
1852 zznamfrm_(svctr3, svfref, &svrefc, fixref, &fxfcde, (ftnlen)32,
1853 fixref_len);
1854 frinfo_(&fxfcde, ¢er, &type__, &typeid, &fnd);
1855 if (failed_()) {
1856 chkout_("ILLUMG", (ftnlen)6);
1857 return 0;
1858 }
1859 if (! fnd) {
1860 setmsg_("Reference frame # is not recognized by the SPICE frame subs"
1861 "ystem. Possibly a required frame definition kernel has not b"
1862 "een loaded.", (ftnlen)130);
1863 errch_("#", fixref, (ftnlen)1, fixref_len);
1864 sigerr_("SPICE(NOFRAME)", (ftnlen)14);
1865 chkout_("ILLUMG", (ftnlen)6);
1866 return 0;
1867 }
1868
1869 /* Make sure that FIXREF is centered at the target body's center. */
1870
1871 if (center != trgcde) {
1872 setmsg_("Reference frame # is not centered at the target body #. The"
1873 " ID code of the frame center is #.", (ftnlen)93);
1874 errch_("#", fixref, (ftnlen)1, fixref_len);
1875 errch_("#", target, (ftnlen)1, target_len);
1876 errint_("#", ¢er, (ftnlen)1);
1877 sigerr_("SPICE(INVALIDFRAME)", (ftnlen)19);
1878 chkout_("ILLUMG", (ftnlen)6);
1879 return 0;
1880 }
1881
1882 /* Get the sign S prefixing LT in the expression for TRGEPC. */
1883 /* When light time correction is not used, setting S = 0 */
1884 /* allows us to seamlessly set TRGEPC equal to ET. */
1885
1886 /* We don't support transmission corrections, so S is never */
1887 /* set to 1. */
1888
1889 if (uselt) {
1890 if (xmit) {
1891 s = 1.;
1892 } else {
1893 s = -1.;
1894 }
1895 } else {
1896 s = 0.;
1897 }
1898
1899 /* Look up the state of the surface point relative to the observer. */
1900 /* The body-fixed frame of the surface point is to be evaluated */
1901 /* at the epoch of the surface point, not at the epoch of the */
1902 /* center of the frame; we indicate this by setting the input */
1903 /* argument EVLREF to 'TARGET'. */
1904
1905 spkcpt_(spoint, target, fixref, et, fixref, "TARGET", abcorr, obsrvr,
1906 opstat, <, target_len, fixref_len, fixref_len, (ftnlen)6,
1907 abcorr_len, obsrvr_len);
1908 if (failed_()) {
1909 chkout_("ILLUMG", (ftnlen)6);
1910 return 0;
1911 }
1912
1913 /* TRGEPC is the epoch associated with the surface point. Below, */
1914 /* since S is set to 0.D0 if no aberration corrections are used, we */
1915 /* require no logical branch. */
1916
1917 *trgepc = *et + s * lt;
1918
1919 /* Now find the state of the illumination source as seen by */
1920 /* the surface point at TRGEPC. We want to evaluate the orientation */
1921 /* of the body-fixed frame of the surface point at the epoch */
1922 /* associated with the surface point, not at the epoch associated */
1923 /* with the frame's center; we indicate this by setting the input */
1924 /* argument EVLREF to 'OBSERVER'. */
1925
1926 spkcpo_(ilusrc, trgepc, fixref, "OBSERVER", abcorr, spoint, target,
1927 fixref, tistat, <i, ilusrc_len, fixref_len, (ftnlen)8,
1928 abcorr_len, target_len, fixref_len);
1929 if (failed_()) {
1930 chkout_("ILLUMG", (ftnlen)6);
1931 return 0;
1932 }
1933
1934 /* Find the surface normal at SPOINT. This computation depends */
1935 /* on target body shape model. */
1936
1937 if (shape == 1) {
1938
1939 /* We'll need the radii of the target body. */
1940
1941 bodvcd_(&trgcde, "RADII", &c__3, &n, radii, (ftnlen)5);
1942 surfnm_(radii, &radii[1], &radii[2], spoint, normal);
1943
1944 /* We check FAILED at the end of the IF block. */
1945
1946 } else if (shape == 2) {
1947
1948 /* Compute the outward unit normal at SPOINT on the surface */
1949 /* defined by the designated DSK data. */
1950
1951 zzsbfnrm_(&trgcde, &nsurf, srflst, et, &fxfcde, spoint, normal);
1952
1953 /* We check FAILED at the end of the IF block. */
1954
1955 } else {
1956
1957 /* We've already checked the computation method input argument, */
1958 /* so we don't expect to arrive here. This code is present for */
1959 /* safety. */
1960
1961 setmsg_("The computation method # was not recognized. ", (ftnlen)45);
1962 errch_("#", method, (ftnlen)1, method_len);
1963 sigerr_("SPICE(INVALIDMETHOD)", (ftnlen)20);
1964 chkout_("ILLUMG", (ftnlen)6);
1965 return 0;
1966 }
1967
1968 /* Check for errors before calling math routines. */
1969
1970 if (failed_()) {
1971 chkout_("ILLUMG", (ftnlen)6);
1972 return 0;
1973 }
1974
1975 /* We'll need the negative of the observer-surface point position */
1976 /* for the following angle computation. Set the output SRFVEC while */
1977 /* we're at it. */
1978
1979 vequ_(opstat, srfvec);
1980 vminus_(srfvec, obspos);
1981
1982 /* Find the illumination angles. VSEP will give us angular */
1983 /* separation in radians. */
1984
1985 *phase = vsep_(obspos, tistat);
1986 *incdnc = vsep_(normal, tistat);
1987 *emissn = vsep_(normal, obspos);
1988
1989 /* TRGEPC has already been set. */
1990
1991 chkout_("ILLUMG", (ftnlen)6);
1992 return 0;
1993 } /* illumg_ */
1994
1995