OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_get_sample_time.c
Go to the documentation of this file.
1 /* file: GEO_get_sample_time.c */
2 
3 #include "GEO_geo.h"
4 #include "GEO_global_arrays.h"
5 #include "GEO_inst.h"
6 #include "GEO_parameters.h"
7 #include "GEO_output.h"
8 #include "PGS_MODIS_35251.h"
9 
10 PGSt_double GEO_get_sample_time(
11  focal_plane_geometry_struct const *geometry_params,
12  const int sample_number
13  )
14 {
15 /*
16 !C*****************************************************************************
17 !Description: subroutine in Instrument Model of the Level-1A geolocation
18  software to calculate the sample time offset of a pixel from
19  the sector start time. It incorporates the time offset from
20  the first band collected (Band 30) to the selected band and
21  also corrects for the latch-up time (trailing edge) to the
22  sample center time. The equations are derived in the
23  Geolocation ATBD (pp. 32-33).
24 
25 !Input Parameters:
26  geometry_params - Numbers describing the MODIS instrument
27  sample_number - the sample number
28 
29 !Output Parameters:
30  None
31 
32 Return values:
33  The sample time offset in seconds from the EV sector start time.
34 
35 Externally Defined:
36  FIRST_BAND "GEO_geo.h"
37  GEO_DOUBLE_FILLVALUE "GEO_output.h"
38  LATCH_TO_CENTER "GEO_geo.h"
39  MODIS_E_BAD_INPUT_ARG "PGS_MODIS_35251.h"
40 
41 Call functions: None
42 
43 Called by: GEO_locate_one_scan "GEO_output.h"
44 
45 !Revision History:
46  $Log: GEO_get_sample_time.c,v $
47  Revision 6.2 2009/05/15 16:42:35 xgeng
48  Corrected the formula to calculate the sample time
49 
50  Xu Geng (xu.geng@saic.com)
51  Revision 6.1 2009/05/06 19:10:18 xgeng
52  Changed all global variables into pointer parameters.
53  Considered sample time for high resolution bands.
54 
55  Revision 2.2 1999/02/08 22:31:12 kuyper
56  Corrected to reflect fact that EV start time corresponds to the start of
57  integration for band 30, not the end.
58 
59  * Revision 2.1 1997/10/21 18:16:22 kuyper
60  * Returned from ClearCase
61  *
62  * Revision 1.5.1.1 1997/07/21 22:20:17 kuyper
63  * Merged in out-of-sequence changes.
64  *
65  * Revision 1.5 1997/07/21 16:24:34 kuyper
66  * Baselined Version 1
67  *
68  *Parallel development:
69  * Revision 1.6 1997/04/21 22:33:23 fhliang
70  * commented unused argument (LL.12-14).
71  *
72  * Revision 1.5 1997/03/26 18:06:20 fhliang
73  * Initial revision of SDST delivery of GEO_get_sample_time.c.
74  *
75  Revision 1.4 1996/07/24 21:02:24 kuyper
76  Declared arguments const.
77 
78  Revision 1.3 1996/07/23 23:06:58 kuyper
79  Inserted required '!' in comments.
80  Changed constants to double to avoid conversions.
81  Made implicit casts explicit.
82 
83  Revision 1.2 1996/07/18 16:40:53 kuyper
84  Included self-checking header file.
85  Replaced extern declaration of sample_time with definition.
86  Replaced other extern declarations with corresponding header files.
87 
88 
89  4/25/95
90  Ruiming Chen
91  Finished coding.
92 
93  6/12/95
94  Frederick S. Patt (patt@modis-xl.gsfc.nasa.gov)
95  Revised to change hardcoded values to defined constants
96  and improve documentation.
97 
98  6/22/95
99  Frederick S. Patt (patt@modis-xl.gsfc.nasa.gov)
100  Added band_number as global variable.
101 
102 !Team-unique Header:
103  This software is developed by the MODIS Science Data Support
104  Team for the National Aeronautics and Space Administration,
105  Goddard Space Flight Center, under contract NAS5-32373.
106 
107 !END*************************************************************************
108 */
109 
110  double t_sample = 1.0/3000.0;
111  char filefunc[] = __FILE__ ", GEO_get_sample_time";
112 
113  if (geometry_params == NULL) {
114  modsmf(MODIS_E_BAD_INPUT_ARG, "geometry_params is null", filefunc);
115  return GEO_DOUBLE_FILLVALUE;
116  }
117 
118  /* calculate the sample time */
119  t_sample = geometry_params->t_frame /
120  (double)geometry_params->N_samp[geometry_params->band_number];
121 
122  return t_sample*(double)(sample_number + 1 -
123  geometry_params->N_samp[geometry_params->band_number]) +
124  geometry_params->t_frame*(
125  geometry_params->band_position[geometry_params->band_number] -
126  geometry_params->F_offset[geometry_params->band_number] -
127  geometry_params->band_position[FIRST_BAND]) +
128  LATCH_TO_CENTER*(t_sample + geometry_params->t_reset);
129 
130 }
131 
#define NULL
Definition: decode_rs.h:63
#define MODIS_E_BAD_INPUT_ARG
double band_position[MAX_BAND_NUMBER_PLUS_ONE]
#define GEO_DOUBLE_FILLVALUE
Definition: GEO_output.h:106
unsigned short N_samp[MAX_BAND_NUMBER_PLUS_ONE]
#define FIRST_BAND
Definition: GEO_geo.h:99
#define LATCH_TO_CENTER
Definition: GEO_geo.h:100
integer, parameter double
double F_offset[MAX_BAND_NUMBER+1]
PGSt_double GEO_get_sample_time(focal_plane_geometry_struct const *geometry_params, const int sample_number)