OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
l3_get_org.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <math.h>
5 #include "fmt_check.h"
6 #define PI 3.141592653589793
7 #define RADCONV PI/180.L
8 
9 void l3_get_org(int resolve, l3_org_str *l3_org)
10 /*******************************************************************
11 
12  fmt_rd_dim
13 
14  purpose: set up the organization information for a L3 based on the
15  resolve value
16 
17  Returns type: none
18 
19  Parameters: (in calling order)
20  Type Name I/O Description
21  ---- ---- --- -----------
22  int resolve I approximate bin size in km
23  currently valid values:
24  1, 2, 4, 9, 36
25  l3_org_str * l3_org I/O organization information
26 
27  Modification history:
28  Programmer Date Description of change
29  ---------- ---- ---------------------
30  W. Robinson, SAIC 5 Apr 2005 Original development
31 
32  *******************************************************************/
33  {
34  int res_val[5] = {1, 2, 4, 9, 36};
35  int numrows[5] = {17280, 8640, 4320, 2160, 540};
36  float64 latbin;
37  int i;
38 
39  /*
40  * first, find the # rows for the resolve value
41  */
42  for (i = 0; i < 5; i++) {
43  if (resolve == res_val[i]) {
44  l3_org->numrows = numrows[i];
45  break;
46  }
47  }
48 
49  /*
50  * get the bins at the equator and the vertical size
51  */
52  l3_org->bins_eq = (int32) l3_org->numrows * 2;
53  l3_org->vsize = (float64) (180.L / l3_org->numrows);
54 
55  /*
56  * For each row, set up the rest
57  */
58  l3_org->hsize = (float64 *) malloc(l3_org->numrows * sizeof ( float64));
59  l3_org->start_bin = (int32 *) malloc(l3_org->numrows * sizeof ( int32));
60  l3_org->max_bin = (int32 *) malloc(l3_org->numrows * sizeof ( int32));
61 
62  l3_org->start_bin[0] = 1;
63  latbin = (90.0L / l3_org->numrows) - 90.0L;
64  l3_org->max_bin[0] = (int32) (cos(latbin * RADCONV) *
65  l3_org->bins_eq + 0.5);
66  l3_org->hsize[0] = 360. / l3_org->max_bin[0];
67 
68  /*
69  printf( "WDR debug %s: line 0, lat, start, # = %f %d %d\n", __FILE__,
70  latbin, l3_org->start_bin[0], l3_org->max_bin[0] );
71  */
72 
73  for (i = 1; i < l3_org->numrows; i++) {
74  latbin = ((float64) i + 0.5) * (180.0L / l3_org->numrows) - 90.0L;
75  l3_org->max_bin[i] = (int32) (cos(latbin * RADCONV) *
76  l3_org->bins_eq + 0.5);
77  l3_org->start_bin[i] = l3_org->start_bin[i - 1] +
78  l3_org->max_bin[i - 1];
79  l3_org->hsize[i] = 360. / l3_org->max_bin[i];
80  /*
81  printf( "WDR debug %s: line %d, lat, start, # = %f %d %d\n", __FILE__,
82  i, latbin, l3_org->start_bin[i], l3_org->max_bin[i] );
83  */
84  }
85  return;
86 }
#define L(lambda, T)
Definition: PreprocessP.h:185
void l3_get_org(int resolve, l3_org_str *l3_org)
Definition: l3_get_org.c:9
#define RADCONV
Definition: l3_get_org.c:7
int i
Definition: decode_rs.h:71