MISR Toolkit  1.5.1
MtkPixelTime.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkPixelTime =
4 = =
5 =============================================================================
6 
7  Jet Propulsion Laboratory
8  MISR
9  MISR Toolkit
10 
11  Copyright 2006, California Institute of Technology.
12  ALL RIGHTS RESERVED.
13  U.S. Government Sponsorship acknowledged.
14 
15 ============================================================================*/
16 
17 #include "MisrCoordQuery.h"
18 #include "MisrFileQuery.h"
19 #include "MisrUtil.h"
20 #include "MisrError.h"
21 
22 #define TIME_BETWEEN_LINE 0.0408 /* Seconds */
23 
42  MTKt_TimeMetaData time_metadata,
43  double som_x,
44  double som_y,
45  char pixel_time[MTKd_DATETIME_LEN] )
46 {
47  MTKt_status status; /* Return status */
48  MTKt_status status_code; /* Return code of this function */
49  int block;
50  float line_275;
51  float sample_275;
52  int trfm = -1;
53  int transform;
54  double delta_line;
55  double delta_samp;
56  double C1, C2, C3, C4, C5, C6;
57  double delta_imgl;
58  double offset;
59  double tai_ref_time;
60 
61  if (pixel_time == NULL)
63 
64  status = MtkSomXYToBls(time_metadata.path,MAXRESOLUTION,som_x,som_y,&block,&line_275,&sample_275);
65  MTK_ERR_COND_JUMP(status);
66 
67  /* Make line relative to start of orbit */
68  line_275 += (float)(512.0 * (block - 1));
69 
70  if (block < time_metadata.start_block || block > time_metadata.end_block ||
71  time_metadata.number_transform[block] <= 0)
73 
74  /* Determine which transform to use */
75  for (transform = 0; transform < NGRIDCELL; ++transform)
76  {
77  if (time_metadata.start_line[block][transform] == 0 &&
78  time_metadata.number_line[block][transform] == 0)
79  continue;
80 
81  if (line_275 > time_metadata.start_line[block][transform] &&
82  line_275 < time_metadata.start_line[block][transform] +
83  time_metadata.number_line[block][transform])
84  {
85  trfm = transform;
86  break;
87  }
88  }
89 
90  if (trfm < 0 || trfm > 1)
92 
93  delta_line = line_275 - time_metadata.som_ctr_x[block][trfm];
94  delta_samp = sample_275 - time_metadata.som_ctr_y[block][trfm];
95 
96  C1 = time_metadata.coeff_line[block][0][trfm];
97  C2 = time_metadata.coeff_line[block][1][trfm];
98  C3 = time_metadata.coeff_line[block][2][trfm];
99  C4 = time_metadata.coeff_line[block][3][trfm];
100  C5 = time_metadata.coeff_line[block][4][trfm];
101  C6 = time_metadata.coeff_line[block][5][trfm];
102 
103  delta_imgl = C1 + C2 * delta_line + C3 * delta_samp + C4 * delta_samp * delta_samp +
104  C5 * delta_line * delta_samp + C6 * delta_samp * delta_samp * delta_samp;
105 
106  offset = delta_imgl * TIME_BETWEEN_LINE;
107 
108  status = MtkUtcToTai(time_metadata.ref_time[block][trfm], &tai_ref_time);
109  MTK_ERR_COND_JUMP(status);
110 
111  status = MtkTaiToUtc(tai_ref_time + offset, pixel_time);
112  MTK_ERR_COND_JUMP(status);
113 
114  return MTK_SUCCESS;
115 
116 ERROR_HANDLE:
117  return status_code;
118 }
MTKt_int32 number_transform[NBLOCK+1]
Definition: MisrFileQuery.h:82
MTKt_status MtkTaiToUtc(double secTAI93, char utc_datetime[MTKd_DATETIME_LEN])
Convert TAI93 to UTC.
Definition: MtkTaiToUtc.c:32
MTKt_status MtkSomXYToBls(int path, int resolution_meters, double som_x, double som_y, int *block, float *line, float *sample)
Convert SOM X, SOM Y to block, line, sample.
Definition: MtkSomXYToBls.c:33
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_double som_ctr_y[NBLOCK+1][NGRIDCELL]
Definition: MisrFileQuery.h:88
MTKt_status MtkUtcToTai(char utc_datetime[MTKd_DATETIME_LEN], double *secTAI93)
Convert UTC to TAI93.
Definition: MtkUtcToTai.c:32
MTKt_char8 ref_time[NBLOCK+1][NGRIDCELL][MTKd_DATETIME_LEN]
Definition: MisrFileQuery.h:83
MTKt_double coeff_line[NBLOCK+1][6][NGRIDCELL]
Definition: MisrFileQuery.h:86
MTKt_int32 number_line[NBLOCK+1][NGRIDCELL]
Definition: MisrFileQuery.h:85
MTKt_double som_ctr_x[NBLOCK+1][NGRIDCELL]
Definition: MisrFileQuery.h:87
#define MAXRESOLUTION
Definition: MisrProjParam.h:22
#define NGRIDCELL
Definition: MisrFileQuery.h:74
MTKt_int32 end_block
Definition: MisrFileQuery.h:80
MTKt_status MtkPixelTime(MTKt_TimeMetaData time_metadata, double som_x, double som_y, char pixel_time[MTKd_DATETIME_LEN])
Given SOM Coordinates compute pixel time.
Definition: MtkPixelTime.c:41
Time Metadata.
Definition: MisrFileQuery.h:77
#define TIME_BETWEEN_LINE
Definition: MtkPixelTime.c:22
MTKt_int32 start_line[NBLOCK+1][NGRIDCELL]
Definition: MisrFileQuery.h:84
#define MTK_ERR_COND_JUMP(code)
Definition: MisrError.h:188
MTKt_status
Definition: MisrError.h:11
HDFFCLIBAPI intf * offset
#define MTKd_DATETIME_LEN
Definition: MisrUtil.h:149

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51