grid.h 5.16 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
#ifndef _GRID_H
#define _GRID_H

4
#include "cdi.h"
5
#include <stdbool.h>
6

Uwe Schulzweida's avatar
Uwe Schulzweida committed
7
typedef unsigned char mask_t;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
8

9
10
11
12
13
typedef struct grid_t grid_t;

struct gridVirtTable
{
  void (*destroy)(grid_t *gridptr);
Thomas Jahns's avatar
Thomas Jahns committed
14
15
16
  grid_t *(*copy)(grid_t *gridptr);
  void (*copyScalarFields)(grid_t *gridptrOrig, grid_t *gridptrDup);
  void (*copyArrayFields)(grid_t *gridptrOrig, grid_t *gridptrDup);
17
18
19
20
21
22
23
24
25
26
27
28
29
  void (*defXVals)(grid_t *gridptr, const double *xvals);
  void (*defYVals)(grid_t *gridptr, const double *yvals);
  void (*defMask)(grid_t *gridptr, const int *mask);
  void (*defMaskGME)(grid_t *gridptr, const int *mask);
  void (*defXBounds)(grid_t *gridptr, const double *xbounds);
  void (*defYBounds)(grid_t *gridptr, const double *ybounds);
  void (*defArea)(grid_t *gridptr, const double *area);
  double (*inqXVal)(grid_t *gridptr, int index);
  double (*inqYVal)(grid_t *gridptr, int index);
  int (*inqXVals)(grid_t *gridptr, double *xvals);
  int (*inqYVals)(grid_t *gridptr, double *yvals);
  const double *(*inqXValsPtr)(grid_t *gridptr);
  const double *(*inqYValsPtr)(grid_t *gridptr);
30
  /* return if for both grids, all xval and all yval are equal */
31
  bool (*compareXYFull)(grid_t *gridRef, grid_t *gridTest);
32
33
  /* return if for both grids, x[0], y[0], x[size-1] and y[size-1] are
   * respectively equal */
34
  bool (*compareXYAO)(grid_t *gridRef, grid_t *gridTest);
35
  void (*inqArea)(grid_t *gridptr, double *area);
36
  const double *(*inqAreaPtr)(grid_t *gridptr);
Thomas Jahns's avatar
Thomas Jahns committed
37
  int (*hasArea)(grid_t *gridptr);
38
39
40
41
42
43
44
45
  int (*inqMask)(grid_t *gridptr, int *mask);
  int (*inqMaskGME)(grid_t *gridptr, int *mask_gme);
  int (*inqXBounds)(grid_t *gridptr, double *xbounds);
  int (*inqYBounds)(grid_t *gridptr, double *ybounds);
  const double *(*inqXBoundsPtr)(grid_t *gridptr);
  const double *(*inqYBoundsPtr)(grid_t *gridptr);
};

46
47
struct gridaxis_t {
  char    name[CDI_MAX_NAME];
48
  char    longname[CDI_MAX_NAME];
49
  char    units[CDI_MAX_NAME];
50
  char    dimname[CDI_MAX_NAME];
51
  const char *stdname;
52
53
};

54
55
56
57
58
59
60
61
62
63
// Lambert Conformal Conic 2
struct grid_lcc2_t {
  short   defined;
  double  lon_0;
  double  lat_0;
  double  lat_1;
  double  lat_2;
  double  a;
};

64
struct grid_t {
Uwe Schulzweida's avatar
Uwe Schulzweida committed
65
66
67
  int     self;
  int     type;                   /* grid type                      */
  int     prec;                   /* grid precision                 */
68
  int     proj;                   /* grid projection                */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
69
70
  mask_t *mask;
  mask_t *mask_gme;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
71
72
73
74
75
76
77
78
  double *xvals;
  double *yvals;
  double *area;
  double *xbounds;
  double *ybounds;
  double  xfirst, yfirst;
  double  xlast, ylast;
  double  xinc, yinc;
79
  double  lcc_originLon;          /* Lambert Conformal Conic        */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
80
81
82
83
84
85
  double  lcc_originLat;
  double  lcc_lonParY;
  double  lcc_lat1;
  double  lcc_lat2;
  double  lcc_xinc;
  double  lcc_yinc;
86
87
  int     lcc_projflag;
  int     lcc_scanflag;
88
  short   lcc_defined;
89
  struct grid_lcc2_t lcc2;
90
  int     laea_defined;
91
92
93
  double  laea_lon_0;             /* Lambert Azimuthal Equal Area   */
  double  laea_lat_0;
  double  laea_a;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
94
  double  xpole, ypole, angle;    /* rotated north pole             */
95
96
97
98
  short   isCyclic;               /* TRUE for global cyclic grids   */
  short   isRotated;              /* TRUE for rotated grids         */
  short   xdef;                   /* 0: undefined 1:xvals 2:x0+xinc */
  short   ydef;                   /* 0: undefined 1:yvals 2:y0+yinc */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
99
  int     nd, ni, ni2, ni3;       /* parameter for GRID_GME         */
100
  int     number, position;       /* parameter for GRID_REFERENCE   */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
101
102
  int     trunc;                  /* parameter for GRID_SPECTEAL    */
  int     nvertex;
103
104
  char   *reference;
  unsigned char uuid[CDI_UUID_SIZE]; /* uuid for grid reference        */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
105
106
107
  int    *rowlon;
  int     nrowlon;
  int     size;
108
109
110
  int     xsize;                  /* number of values along X */
  int     ysize;                  /* number of values along Y */
  int     np;                     /* number of parallels between a pole and the equator */
Thomas Jahns's avatar
Thomas Jahns committed
111
112
  short   lcomplex;
  short   hasdims;
113
  char    vdimname[CDI_MAX_NAME];
Uwe Schulzweida's avatar
Uwe Schulzweida committed
114
  char   *name;
115
116
  struct gridaxis_t x;
  struct gridaxis_t y;
117
118
119
  const struct gridVirtTable *vtable;
  void *extraData;
};
Uwe Schulzweida's avatar
Uwe Schulzweida committed
120
121


Uwe Schulzweida's avatar
Uwe Schulzweida committed
122
void grid_init(grid_t *gridptr);
123
124
void
cdiGridTypeInit(grid_t *gridptr, int gridtype, int size);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
void grid_free(grid_t *gridptr);
126
grid_t *gridID2Ptr(int gridID);
127
extern const struct gridVirtTable cdiGridVtable;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
128

Thomas Jahns's avatar
Thomas Jahns committed
129
unsigned cdiGridCount(void);
130

Uwe Schulzweida's avatar
Uwe Schulzweida committed
131
132
133
const double *gridInqXvalsPtr(int gridID);
const double *gridInqYvalsPtr(int gridID);

134
135
const double *gridInqXboundsPtr(int gridID);
const double *gridInqYboundsPtr(int gridID);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
136
137
const double *gridInqAreaPtr(int gridID);

138
139
140
const char *gridInqXnamePtr(int gridID);
const char *gridInqYnamePtr(int gridID);

141
142
const char *gridInqReferencePtr(int gridID);

143
int gridGenerate(const grid_t *grid);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
144

Thomas Jahns's avatar
Thomas Jahns committed
145
void cdiGridGetIndexList(unsigned, int * );
Uwe Schulzweida's avatar
Uwe Schulzweida committed
146

147
148
void
gridUnpack(char * unpackBuffer, int unpackBufferSize,
149
           int * unpackBufferPos, int originNamespace, void *context,
150
151
           int force_id);

152
153
154
155
156
157
158
struct addIffNewRes
{
  int Id;
  int isNew;
};

struct addIffNewRes cdiVlistAddGridIfNew(int vlistID, grid_t *grid, int mode);
159

Uwe Schulzweida's avatar
Uwe Schulzweida committed
160
#endif
161
162
163
164
165
166
167
168
169
/*
 * Local Variables:
 * c-file-style: "Java"
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * show-trailing-whitespace: t
 * require-trailing-newline: t
 * End:
 */