OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_interp_ECR.c
Go to the documentation of this file.
1 #include "GEO_earth.h"
2 #include "PGS_MODIS_35251.h"
3 
4 PGSt_SMF_status GEO_interp_ECR(
5  PGSt_double const base_time,
6  PGSt_integer const numValues,
7  const PGSt_double offsets[],
9  char asciiUTC[],
10  sc_state_struct sc_state[],
11  double T_sc2ecr[][3][3],
12  double T_inst2ecr[][3][3],
13  double positionECR[][3],
14  double velocityECR[][3],
15  PGSt_double rpy[],
16  uint32 sample_quality[][2]
17 ){
18 /******************************************************************************
19 !C
20 
21 !Description:
22  Routine in the Earth Location group of the Level-1A geolocation
23  software to interpolate the ephemeris, attitude, and orientation of the
24  satellite in ECR coordinates at a specified list of offsets from a
25  specified base time.
26 
27 !Input Parameters:
28  base_time TAI reference start time
29  numValues The number of values requested
30  offsets An array of numValues offsets, in seconds, from asciiUTC
31  params Geolocation parameters struct
32 
33 !Output Parameters:
34  asciiUTC The UTC time string corresponding to base_time
35  sc_state An array of numValues spacecraft kinematic state
36  records to be filled in for the specified times
37  T_sc2ecr An array of numValues transformation matrices from the
38  spacecraft to ECR coordinates for the spacecraft state.
39  T_inst2ecr An array of numValues transformation matrices from the
40  instrument to ECR coordinates for the spacecraft state.
41  positionECR An array of numValues spacecraft positions from
42  sc_state converted to ECR coordinates. Optional output
43  (may be set to NULL).
44  velocityECR An array of numValues spacecraft velocities from
45  sc_state converted to ECR coordinates. Optional output
46  (may be set to NULL).
47  rpy An array of roll, pitch, and yaw thermal corrections to
48  be filled in for the specified times.
49  sample_quality An array of numValues ephemeris and attitude quality
50  flags to be filled in for the specified times.
51 
52 Return Values:
53  MODIS_E_GEO If any subroutine fails.
54  MODIS_E_GEO_BAD_INPUT_ARG If any pointer argument is null.
55  PGS_S_SUCCESS Otherwise
56 
57 Externally Defined:
58  MODIS_E_GEO "PGS_MODIS_35251.h"
59  MODIS_E_GEO_BAD_INPUT_ARG "PGS_MODIS_35251.h"
60  PGS_S_SUCCESS "PGS_SMF.h"
61  PGS_TRUE "PGS_SMF.h"
62 
63 Called by:
64  GEO_locate_one_scan
65  GEO_solar_and_lunar_vectors
66 
67 Routines Called:
68  GEO_get_T_inst2ecr "GEO_earth.h"
69  GEO_interp_ephemeris_attitude "GEO_earth.h"
70  PGS_SMF_TestWarningLevel "PGS_SMF.h"
71  PGS_TD_TAItoUTC "PGS_TD.h"
72 
73 !Revision History:
74  $Log: GEO_interp_ECR.c,v $
75  Revision 6.3 2013/06/17 16:49:23 jkuyper
76  Dropped attitQuat, which is no longer needed.
77 
78  Revision 6.2 2010/05/19 22:06:36 kuyper
79  Helped resolve Bug 1969 by: Adding rpy as an output parameter filled in by call
80  to GEO_get_T_inst2ecr().
81  Helped resolve Bug 2742: by replacing max_extrap and sol_elev_cor with params,
82  adding sample_quality as an output parameters, and passing params and
83  sample_quality to GEO_interp_ephemeris_attitude().
84  Helped resolve Bug 2473 by defining scTagInfo, whose eulerAngleOrder member is
85  filled in by calling GEO_interp_ephemeris_attitude(), and then passed to
86  GEO_get_T_inst2ecr.
87 
88  James Kuyper Jr. James.R.Kuyper@NASA.gov
89 
90  Revision 6.1 2009/05/06 19:10:12 xgeng
91  Code updated to match the PDL change made in revision 6.1 and 6.2
92 
93  Revision 5.2 2004/11/02 01:15:35 kuyper
94  Added T_sc2ecr to the list of outputs.
95 
96  Revision 5.1 2004/09/23 15:08:09 kuyper
97  Added attitQuat and sol_elev_cor
98 
99  Revision 4.3 2003/11/17 23:18:32 vlin
100  data type for base_time is changed to float
101 
102  Revision 4.2 2003/08/22 22:04:27 kuyper
103  Added T_sc2ecr as a parameter to be passed to GEO_get_T_inst2ecr().
104 
105  Revision 4.1 2003/08/01 20:54:11 vlin
106  vlin@saicmodis.com
107 
108 
109 Requirements: None
110 
111 !Team-unique Header:
112 
113  This software is developed by the MODIS Science Data Support
114  Team for the National Aeronautics and Space Administration,
115  Goddard Space Flight Center, under contract NAS5-32373.
116 
117 Design Note: None
118 
119 !END
120 ******************************************************************************/
121 
122  PGSt_SMF_status status = PGS_S_SUCCESS;
123  PGSt_scTagInfo scTagInfo;
124  char msgbuf[128] = "";
125  char filefunc[] = __FILE__ ", GEO_interp_ECR";
126 
127  if (offsets == NULL || asciiUTC == NULL ||
128  sc_state == NULL || T_inst2ecr == NULL) {
129  sprintf(msgbuf,"offsets: %p, asciiUTC: %s, sc_state: %p, T_inst2ecr: %p",
130  (void *)offsets,asciiUTC,(void *)sc_state,(void *)T_inst2ecr);
131  modsmf(MODIS_E_BAD_INPUT_ARG, msgbuf, filefunc);
132  return MODIS_E_BAD_INPUT_ARG;
133  }
134 
135  scTagInfo.eulerAngleOrder[0] = -1; /* Mark as uninitialized */
136  status = PGS_TD_TAItoUTC(base_time, asciiUTC);
137  if (status != PGS_S_SUCCESS && PGS_SMF_TestWarningLevel(status) != PGS_TRUE){
138  sprintf(msgbuf, "PGS_TD_TAItoUTC(%.2f)", base_time);
139  modsmf(MODIS_E_GEO, msgbuf, filefunc);
140  return MODIS_E_GEO;
141  }
142 
143  if (GEO_interp_ephemeris_attitude(numValues, asciiUTC, base_time, offsets,
144  params, sc_state, sample_quality, &scTagInfo) != PGS_S_SUCCESS)
145  {
146  sprintf(msgbuf, "GEO_interp_ephemeris_attitude(%s)", asciiUTC);
147  modsmf(MODIS_E_GEO, msgbuf, filefunc);
148  return MODIS_E_GEO;
149  }
150 
151  if (GEO_get_T_inst2ecr(numValues, asciiUTC, offsets, sc_state,
152  (double (*)[3])params->sol_elev_cor, scTagInfo.eulerAngleOrder, T_sc2ecr,
153  T_inst2ecr, positionECR, velocityECR, rpy) != PGS_S_SUCCESS)
154  {
155  sprintf(msgbuf, "GEO_get_T_inst2ecr(%s)", asciiUTC);
156  modsmf(MODIS_E_GEO, msgbuf, filefunc);
157  return MODIS_E_GEO;
158  }
159  return PGS_S_SUCCESS;
160 }
161 
int status
Definition: l1_czcs_hdf.c:32
PGSt_SMF_status GEO_get_T_inst2ecr(PGSt_integer numValues, char asciiutc[], const PGSt_double offsets[], sc_state_struct const sc_state[], double sol_elev_cor[][3], PGSt_integer const eulerAngleOrder[], double T_sc2ecr[][3][3], double T_inst2ecr[][3][3], double ecr_position[][3], double ecr_velocity[][3], PGSt_double rpy[])
#define NULL
Definition: decode_rs.h:63
#define MODIS_E_BAD_INPUT_ARG
PGSt_SMF_status GEO_interp_ECR(PGSt_double const base_time, PGSt_integer const numValues, const PGSt_double offsets[], GEO_param_struct const *params, char asciiUTC[], sc_state_struct sc_state[], double T_sc2ecr[][3][3], double T_inst2ecr[][3][3], double positionECR[][3], double velocityECR[][3], PGSt_double rpy[], uint32 sample_quality[][2])
Definition: GEO_interp_ECR.c:4
#define MODIS_E_GEO
PGSt_SMF_status GEO_interp_ephemeris_attitude(PGSt_integer numValues, char asciiUTC[], PGSt_double target_time, const PGSt_double offsets[], GEO_param_struct const *params, sc_state_struct sc_state[], uint32 qualityFlags[][2], PGSt_scTagInfo *scTagInfo)