MISR Toolkit  1.5.1
misr_init.c
Go to the documentation of this file.
1 #include "misrproj.h" /* Prototype for this function */
2 #include "errormacros.h" /* Error macros */
3 
4 int nb;
5 int nl_var;
6 int ns;
7 float absOffset[NBLOCK];
8 float relOffset[NBLOCK-1];
9 double ulc[2];
10 double lrc[2];
11 double sx;
12 double sy;
13 double xc;
14 double yc;
15 
16 #define FUNC_NAMEm "misr_init"
17 
19 const int nblock, /* Number of blocks */
20 const int nline, /* Number of lines in a block */
21 const int nsample, /* Number of samples in a block */
22 const float relOff[NOFFSET],/* Block offsets */
23 const double ulc_coord[], /* Upper left corner coord. in meters */
24 const double lrc_coord[] /* Lower right corner coord. in meters */
25 )
26 {
27  int i; /* Offset index */
28  char msg[STRLEN]; /* Warning message */
29 
30 /* Argument checks */
31 
32  if (nblock < 1 || nblock > NBLOCK) {
33  sprintf(msg,"nblock is out of range (1 < %d < %d)", nblock, NBLOCK);
34  WRN_LOG_JUMP(msg);
35  }
36 
37 /* Convert relative offsets to absolute offsets */
38 
39  absOffset[0] = 0.0;
40  for (i = 1; i < NBLOCK; i++) {
41  absOffset[i] = absOffset[i-1] + relOff[i-1];
42  relOffset[i-1] = relOff[i-1];
43  }
44 
45 /* Set ulc and lrc SOM coordinates */
46 /* Note; ulc y and lrc y are reversed in the structural metadata. */
47 
48  ulc[0] = ulc_coord[0];
49  ulc[1] = lrc_coord[1];
50  lrc[0] = lrc_coord[0];
51  lrc[1] = ulc_coord[1];
52 
53 /* Set number of blocks, lines and samples */
54 
55  nb = nblock;
56  nl_var = nline;
57  ns = nsample;
58 
59 /* Compute pixel size in ulc/lrc units (meters) */
60 
61  sx = (lrc[0] - ulc[0]) / nl_var;
62  sy = (lrc[1] - ulc[1]) / ns;
63 
64 /* Adjust ulc to be in the center of the pixel */
65 
66  xc = ulc[0] + sx / 2.0;
67  yc = ulc[1] + sy / 2.0;
68 
69  return(0);
70 
71  ERROR_HANDLE:
72  return(1);
73 }
int misr_init(const int nblock, const int nline, const int nsample, const float relOff[NOFFSET], const double ulc_coord[], const double lrc_coord[])
Definition: misr_init.c:18
#define STRLEN
Definition: misrproj.h:6
double ulc[2]
Definition: misr_init.c:9
double xc
Definition: misr_init.c:13
float absOffset[NBLOCK]
Definition: misr_init.c:7
int ns
Definition: misr_init.c:6
float relOffset[NBLOCK-1]
Definition: misr_init.c:8
#define NOFFSET
Definition: misrproj.h:8
double lrc[2]
Definition: misr_init.c:10
#define WRN_LOG_JUMP(msg)
Definition: errormacros.h:32
#define NBLOCK
Definition: MisrProjParam.h:51
double yc
Definition: misr_init.c:14
double sx
Definition: misr_init.c:11
int nl_var
Definition: misr_init.c:5
int nb
Definition: misr_init.c:4
double sy
Definition: misr_init.c:12

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