MISR Toolkit  1.5.1
misrinv.c
Go to the documentation of this file.
1 #include "misrproj.h" /* Prototype for this function */
2 #include "errormacros.h" /* Error macros */
3 
4 extern int nb;
5 extern int nl_var;
6 extern int ns;
7 extern float absOffset[NBLOCK];
8 extern double ulc[2];
9 extern double lrc[2];
10 extern double sx;
11 extern double sy;
12 extern double xc;
13 extern double yc;
14 
15 #define FUNC_NAMEm "misrinv"
16 
17 int misrinv(
18 const int block, /* Input block */
19 const float line, /* Input line */
20 const float sample, /* Input sample */
21 double* x, /* Output SOM X coordinate */
22 double* y /* Output SOM Y coordinate */
23 )
24 {
25  int n; /* Number of line to current block */
26  char msg[STRLEN]; /* Warning message */
27 
28 /* Check Arguments */
29 
30  if (block < 1 || block > NBLOCK) {
31  sprintf(msg, "block is out of range (0 < %d < %d)", block, nb);
32  WRN_LOG_JUMP(msg);
33  }
34 
35  if (line < -0.5 || line > nl_var - 0.5) {
36  sprintf(msg, "line is out of range (0 < %e < %d)", line, nl_var);
37  WRN_LOG_JUMP(msg);
38  }
39 
40  if (sample < -0.5 || sample > ns - 0.5) {
41  sprintf(msg, "sample is out of range (0 < %e < %d)", sample, ns);
42  WRN_LOG_JUMP(msg);
43  }
44 
45 /* Compute SOM x/y coordinates in ulc/lrc units (meters) */
46 
47  n = (int)((block - 1) * nl_var * sx);
48  *x = (double)(xc + n + (line * sx));
49  *y = (double)(yc + ((sample + absOffset[block-1]) * sy));
50 
51  return(0);
52 
53  ERROR_HANDLE:
54 
55  *x = -1e-9;
56  *y = -1e-9;
57  return(1);
58 }
59 
int ns
Definition: misr_init.c:6
int nl_var
Definition: misr_init.c:5
double xc
Definition: misr_init.c:13
float absOffset[NBLOCK]
Definition: misr_init.c:7
int nb
Definition: misr_init.c:4
#define STRLEN
Definition: misrproj.h:6
double lrc[2]
Definition: misr_init.c:10
double sy
Definition: misr_init.c:12
double ulc[2]
Definition: misr_init.c:9
double sx
Definition: misr_init.c:11
#define WRN_LOG_JUMP(msg)
Definition: errormacros.h:32
#define NBLOCK
Definition: MisrProjParam.h:51
HDFFCLIBAPI _fcd _fcd intf * n
double yc
Definition: misr_init.c:14
int misrinv(const int block, const float line, const float sample, double *x, double *y)
Definition: misrinv.c:17

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