OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_get_view_vec.c
Go to the documentation of this file.
1 #include "PGS_MODIS_35251.h"
2 #include "GEO_inst.h"
3 #include "GEO_parameters.h"
4 #include "GEO_product.h"
5 #include "GEO_util.h"
6 #include "smfio.h"
7 
9  const int scan_number,
10  const int sample_number,
11  const int num_detectors,
12  double u_inst[MAX_DETECTORS][3]
13  )
14 /*
15 !C*****************************************************************************
16 !Description:
17  Routine in Instrument Model of the Level-1A geolocation software to
18  calculate the view vectors for a sample. This routine calls functions
19  to compute the mirror normal vector. It then reflects the telescope
20  view vectors off of the mirror to determine the view vectors in the
21  instrument frame.
22 
23 !Input Parameters:
24  scan_number The scan number
25  sample_number The sample number
26  num_detectors The number of detectors in the sample
27 
28 !Output Parameters:
29  u_inst View vectors in instrument coordinates
30 
31 Return Values:
32  FAIL If any GEO_get_inst_mirr_normal() fails
33  SUCCESS Otherwise
34 
35 Externally Defined:
36  FAIL "GEO_basic.h"
37  MODIS_E_GEO "PGS_MODIS_35251.h"
38  SUCCESS "GEO_basic.h"
39  T_tel2inst "GEO_parameters.h"
40  u_tel "GEO_parameters.h"
41 
42 Called by:
43  GEO_earth_location
44 
45 Routines Called:
46  GEO_get_inst_mirr_normal "GEO_inst.h"
47  GEO_mat_vec_mul3 "GEO_util.h"
48  GEO_vec_prod3 "GEO_util.h"
49  modsmf "smfio.h"
50 
51 !Revision History:
52  $Log: GEO_get_view_vec.c,v $
53  Revision 4.2 2003/11/21 21:38:29 vlin
54  Global variables added
55 
56  Revision 4.1 2003/08/08 16:25:42 vlin
57  Moved call to GEO_get_sample_time() to a higher level.
58  Changed to use generic message mnemonic.
59 
60  Revision 3.1 2002/06/11 13:13:34 kuyper
61  Corrected off-by-one loop error.
62 
63  Revision 2.1 1997/10/21 18:16:22 kuyper
64  Returned from ClearCase
65 
66  4/25/95
67  Ruiming Chen (rchen@ltpmail.gsfc.nasa.gov)
68  Finished coding.
69 
70 !Team-unique Header:
71  This software is developed by the MODIS Science Data Support
72  Team for the National Aeronautics and Space Administration,
73  Goddard Space Flight Center, under contract NAS5-32373.
74 
75 !END
76 *****************************************************************************/
77 
78 {
79  double u_img[3] = {0.0}; /* viewing vector in instrument coordinate system */
80  double n_inst_normal[3] = {0.0}; /* normalize n_inst */
81  double un_prod = 0.0; /* product of u_img and n_inst_normal */
82  int i = 0, j = 0;
83  char filefunc[] = __FILE__ ", GEO_get_view_vec";
84 
85 
86  if (GEO_get_inst_mirr_normal(scan_number, sample_number, n_inst_normal)
87  != SUCCESS) {
88  modsmf(MODIS_E_GEO, "GEO_get_inst_mirr_normal()", filefunc);
89  return FAIL;
90  }
91 
92  for (i = 0; i < num_detectors; i++) {
93  /* transfer global variable u_tel to instrument coordinate system u_img */
94  GEO_mat_vec_mul3(T_tel2inst, &u_tel[i][0], u_img);
95 
96  /* calculate the viewing vector u_inst */
97  GEO_vec_prod3(u_img, n_inst_normal, &un_prod);
98  for (j = 0; j < 3; ++j)
99  u_inst[i][j] = u_img[j] - 2.0*un_prod*n_inst_normal[j];
100  }
101  return SUCCESS;
102 }
#define SUCCESS
Definition: ObpgReadGrid.h:15
int j
Definition: decode_rs.h:73
#define FAIL
Definition: ObpgReadGrid.h:18
double u_tel[DETECTORS_QKM][3]
#define MODIS_E_GEO
int GEO_get_inst_mirr_normal(const int scan_number, const int sample_number, double n_inst_normal[3])
const int MAX_DETECTORS
void GEO_vec_prod3(double vec1[3], double vec2[3], double *const prod)
Definition: GEO_vec_prod3.c:6
double T_tel2inst[3][3]
void GEO_mat_vec_mul3(double mat[3][3], double vec1[3], double vec[3])
int GEO_get_view_vec(const int scan_number, const int sample_number, const int num_detectors, double u_inst[MAX_DETECTORS][3])
int i
Definition: decode_rs.h:71