grid.tex 13.9 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
\section{Horizontal grids}
\label{HORIZONTAL_GRIDS}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
4
5
6
Physical quantities of climate models are typically stored on a horizonal grid.
The maximum number of supported grid cells is 2147483647 (INT\_MAX).
This corresponds to a global regular lon/lat grid with 65455x32727
Uwe Schulzweida's avatar
Uwe Schulzweida committed
7
grid cells and a global resolution of 0.0055 degree.
8
9
10
11

\subsection{Grid area weights}
\label{GRID_AREA_WEIGHTS}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
12
One single point of a horizontal grid represents the mean of a grid cell.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
13
These grid cells are typically of different sizes, because the grid points are of varying distance.
14
15
16
17
18
19
20
21

Area weights are individual weights for each grid cell. 
%They take into account the different grid cell sizes when needed by a {\CDO} operator. 
They are needed to compute the area weighted mean or
variance of a set of grid cells (e.g. \htmlref{fldmean}{fldmean} - the mean value of all grid cells).
In {\CDO} the area weights are derived from the grid cell area.
If the cell area is not available then it will be computed from the geographical coordinates via spherical triangles.
This is only possible if the geographical coordinates of the grid cell corners are available or derivable.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
22
Otherwise {\CDO} gives a warning message and uses constant area weights for all grid cells.
23

Uwe Schulzweida's avatar
Uwe Schulzweida committed
24
The cell area is read automatically from a NetCDF input file if a variable has the
25
26
27
28
29
30
31
32
33
34
corresponding ``cell\_measures'' attribute, e.g.:

\begin{lstlisting}[frame=single, backgroundcolor=\color{pcolor1}, basicstyle=\small]
var:cell_measures = "area: cell_area" ;
\end{lstlisting}

If the computed cell area is not desired 
then the {\CDO} operator \htmlref{setgridarea}{setgridarea} can be used to
set or overwrite the grid cell area.

Uwe Schulzweida's avatar
Uwe Schulzweida committed
35
\subsection{Grid description}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
36
\label{GRID_DESCRIPTION}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
37

Uwe Schulzweida's avatar
Uwe Schulzweida committed
38
In the following situations it is necessary to give a description of a horizontal grid:
Uwe Schulzweida's avatar
Uwe Schulzweida committed
39
40
41

\begin{itemize}
\item Changing the grid description (operator: \htmlref{setgrid}{setgrid})
Uwe Schulzweida's avatar
Uwe Schulzweida committed
42
\item Horizontal interpolation (all remapping operators)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
43
\item Generating of variables (operator: \htmlref{const}{const}, \htmlref{random}{random})
Uwe Schulzweida's avatar
Uwe Schulzweida committed
44
45
\end{itemize}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
46
As now described, there are several possibilities to define a horizontal grid.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
47

Uwe Schulzweida's avatar
Uwe Schulzweida committed
48
\subsubsection{Predefined grids}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
49

50
51
Predefined grids are available for global regular, gaussian or icosahedral-hexagonal GME grids.
% They have the following predefined grid names: 
Uwe Schulzweida's avatar
Uwe Schulzweida committed
52
%\texttt{r<NX>x<NY>}, \texttt{lon=<LON>/lat=<LAT>}, \texttt{n<N>} and \texttt{gme<NI>}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
53

Uwe Schulzweida's avatar
Uwe Schulzweida committed
54
55
56
57
58
\subsubsection*{Global regular grid: \texttt{global\_<DXY>}}
    \texttt{global\_<DXY>} defines a global regular lon/lat grid.
    The grid increment \texttt{<DXY>} can be selected at will.
    The longitudes start at \texttt{<DXY>}/2 - 180$^\circ$ and the
    latitudes start at \texttt{<DXY>}/2 - 90$^\circ$.
59

Uwe Schulzweida's avatar
Uwe Schulzweida committed
60
61
62
63
64
\subsubsection*{Global regular grid: \texttt{r<NX>x<NY>}}
    \texttt{r<NX>x<NY>} defines a global regular lon/lat grid.
    The number of the longitudes \texttt{<NX>} and the latitudes \texttt{<NY>} can be selected at will.
    The longitudes start at 0$^\circ$ with an increment of (360/\texttt{<NX>})$^\circ$.
    The latitudes go from south to north with an increment of (180/\texttt{<NY>})$^\circ$.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
65

Uwe Schulzweida's avatar
Uwe Schulzweida committed
66
67
\subsubsection*{One grid point: \texttt{lon=<LON>/lat=<LAT>}}
    \texttt{lon=<LON>/lat=<LAT>} defines a lon/lat grid with only one grid point.
68

Uwe Schulzweida's avatar
Uwe Schulzweida committed
69
70
\subsubsection*{Global Gaussian grid: \texttt{n<N>}}
    \texttt{n<N>} defines a global Gaussian grid. \texttt{N} specifies the number of
Uwe Schulzweida's avatar
Uwe Schulzweida committed
71
    latitudes lines between the Pole and the Equator.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
72
    The longitudes start at 0$^\circ$ with an increment of (360/nlon)$^\circ$.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
73
74
    The gaussian latitudes go from north to south.

Uwe Schulzweida's avatar
Uwe Schulzweida committed
75
%\subsubsection*{Spherical harmonics: t$<$RES$>$spec}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
76
77
78
%    t$<$RES$>$spec defines the spectral coefficients of a global gaussian grid.
%    Each valid triangular resolution can be used for $<$RES$>$.

Uwe Schulzweida's avatar
Uwe Schulzweida committed
79
80
81
\subsubsection*{Global icosahedral-hexagonal GME grid: \texttt{gme<NI>}}
    \texttt{gme<NI>} defines a global icosahedral-hexagonal GME grid.
    \texttt{NI} specifies the number of intervals on a main triangle side.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
82

Uwe Schulzweida's avatar
Uwe Schulzweida committed
83
\subsubsection{Grids from data files}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
84
85

You can use the grid description from an other datafile.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
86
87
88
The format of the datafile and the grid of the data field must be supported by {\CDO} .
Use the operator '\htmlref{sinfo}{sinfo}' to get short informations about your variables and the grids.
If there are more then one grid in the datafile the grid description of the first variable will be used.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
89

Uwe Schulzweida's avatar
Uwe Schulzweida committed
90
\subsubsection{SCRIP grids}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
91

92
93
94
SCRIP (Spherical Coordinate Remapping and Interpolation Package) uses
a common grid description for curvilinear and unstructured grids.
For more information about the convention see \cite{SCRIP}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
95
96
This grid description is stored in NetCDF. Therefor it is only
available if {\CDO} was compiled with NetCDF support!
Uwe Schulzweida's avatar
Uwe Schulzweida committed
97
98
99
100

\vspace{2mm}

%\begin{minipage}[t]{\textwidth}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
101
SCRIP grid description example of a curvilinear MPIOM \cite{MPIOM} GROB3 grid (only the NetCDF header):
Uwe Schulzweida's avatar
Uwe Schulzweida committed
102
\begin{lstlisting}[frame=single, backgroundcolor=\color{pcolor1}, basicstyle=\footnotesize]
Uwe Schulzweida's avatar
Uwe Schulzweida committed
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
    netcdf grob3s {
    dimensions:
            grid_size = 12120 ;
            grid_xsize = 120 ;
            grid_ysize = 101 ;
            grid_corners = 4 ;
            grid_rank = 2 ;
    variables:
            int grid_dims(grid_rank) ;
            float grid_center_lat(grid_ysize, grid_xsize) ;
                    grid_center_lat:units = "degrees" ;
                    grid_center_lat:bounds = "grid_corner_lat" ;
            float grid_center_lon(grid_ysize, grid_xsize) ;
                    grid_center_lon:units = "degrees" ;
                    grid_center_lon:bounds = "grid_corner_lon" ;
            int grid_imask(grid_ysize, grid_xsize) ;
                    grid_imask:units = "unitless" ;
                    grid_imask:coordinates = "grid_center_lon grid_center_lat" ;
            float grid_corner_lat(grid_ysize, grid_xsize, grid_corners) ;
                    grid_corner_lat:units = "degrees" ;
            float grid_corner_lon(grid_ysize, grid_xsize, grid_corners) ;
                    grid_corner_lon:units = "degrees" ;

    // global attributes:
                    :title = "grob3s" ;
    }
\end{lstlisting}
%\end{minipage}

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
% \subsubsection{PINGO grids}

% PINGO uses a very simple grid description in ASCII format
% to describe regular longitude/latitude or global gaussian grids.
% All PINGO grid description files are supported by {\CDO}. 
% For more information about this format see \cite{PINGO}.

% \vspace{2mm}

% %\begin{minipage}[t]{\textwidth}
% PINGO grid description example of a T21 gaussian grid:
% \begin{lstlisting}[frame=single, backgroundcolor=\color{pcolor1}, basicstyle=\footnotesize]
%     Grid Description File
%     (Comments start at non digit characters and end at end of line)
%     First part: The dimensions.
%     64 32 = Number of longitudes and latitudes
%     Second part: The listed longitudes.
%     2 means equidistant longitudes
%     0.000000 5.625000 = Most western and second most western longitude
%     Third part: The listed latitudes.
%     32 means all 32 latitudes are given in the following list:
%      85.761  80.269  74.745  69.213  63.679  58.143  52.607  47.070
%      41.532  35.995  30.458  24.920  19.382  13.844   8.307   2.769
%      -2.769  -8.307 -13.844 -19.382 -24.920 -30.458 -35.995 -41.532
%     -47.070 -52.607 -58.143 -63.679 -69.213 -74.745 -80.269 -85.761
% \end{lstlisting}
% %\end{minipage}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
159

Uwe Schulzweida's avatar
Uwe Schulzweida committed
160
\subsubsection{CDO grids}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
161

Uwe Schulzweida's avatar
Uwe Schulzweida committed
162
All supported grids can also be described with the {\CDO} grid description.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
163
%The {\CDO} grid description is an ASCII formatted file.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
164
%It is a common grid description for all available grids.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
165
166
167
168
The following keywords can be used to describe a grid:

\vspace{3mm}
\begin{tabular}[b]{lll}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
169
Keyword           & Datatype     & Description \\ \hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
170
171
172
173
174
175
176
177
178
179
\textbf{gridtype}     & STRING       & Type of the grid (gaussian, lonlat, curvilinear, unstructured). \\
\textbf{gridsize}     & INTEGER      & Size of the grid. \\
\textbf{xsize}        & INTEGER      & Size in x direction (number of longitudes). \\
\textbf{ysize}        & INTEGER      & Size in y direction (number of latitudes). \\
\textbf{xvals}        & FLOAT ARRAY  & X values of the grid cell center. \\
\textbf{yvals}        & FLOAT ARRAY  & Y values of the grid cell center.\\
\textbf{nvertex}      & INTEGER      & Number of the vertices for all grid cells. \\
\textbf{xbounds}      & FLOAT ARRAY  & X bounds of each gridbox. \\
\textbf{ybounds}      & FLOAT ARRAY  & Y bounds of each gridbox. \\
\textbf{xfirst, xinc} & FLOAT, FLOAT & Macros to define xvals with a constant increment, \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
180
                         &                         & xfirst is the x value of the first grid cell center. \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
181
\textbf{yfirst, yinc} & FLOAT, FLOAT & Macros to define yvals with a constant increment, \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
182
                         &                         & yfirst is the y value of the first grid cell center. \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
183
184
185
186
187
188
%xname        & STRING       & name of the x axis \\
%xlongname    & STRING       & longname of the x axis \\
\textbf{xunits}       & STRING       & units of the x axis \\
%yname        & STRING       & name of the y axis \\
%ylongname    & STRING       & longname of the y axis \\
\textbf{yunits}       & STRING       & units of the y axis \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
189
190
191
192
\end{tabular}

\vspace{4mm}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
193
Which keywords are necessary depends on the gridtype.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
194
195
The following table gives an overview of the default values or the size
with respect to the different grid types.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215

%\vspace{2mm}
%\begin{tabular}[b]{|c|c|c|c|c|c|c|c|c|}
%\hline
%gridtype    & gridsize     & xsize & ysize & xvals    & yvals    & nvertex & xbounds     & ybounds \\
%\hline
%\hline
%gaussian    & xsize*ysize  & nlon  & nlat  & xsize    & ysize    & 2       & 2*xsize     & 2*ysize \\
%\hline
%lonlat      & xsize*ysize  & nlon  & nlat  & xsize    & ysize    & 2       & 2*xsize     & 2*ysize \\
%\hline 
%curvilinear & xsize*ysize  & nlon  & nlat  & gridsize & gridsize & 4       & 4*gridsize  & 4*gridsize \\
%\hline
%cell        & ncell        &       &       & gridsize & gridsize & nv      & nv*gridsize & nv*gridsize \\
%\hline
%\end{tabular}
%\vspace{2mm}

\vspace{2mm}
\hspace{2cm}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
216
\begin{tabular}[c]{|>{\columncolor{pcolor1}}l|c|c|c|c|c|}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
217
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
218
219
\rowcolor{pcolor1}
\cellcolor{pcolor2}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
220
221
222
223
224
gridtype   & lonlat      & gaussian    & projection &curvilinear & unstructured \\
\hline
gridsize   & xsize*ysize & xsize*ysize & xsize*ysize & xsize*ysize & \textbf{ncell} \\
\hline
xsize      & \textbf{nlon} & \textbf{nlon} & \textbf{nx} & \textbf{nlon} & gridsize \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
225
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
226
ysize      & \textbf{nlat} & \textbf{nlat} & \textbf{ny} &  \textbf{nlat} & gridsize \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
227
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
228
xvals      & xsize & xsize & xsize &  gridsize & gridsize \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
229
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
230
yvals      & ysize & ysize & ysize &  gridsize & gridsize \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
231
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
232
nvertex    & 2 & 2 & 2 &  4 & \textbf{nv} \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
233
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
234
xbounds    & 2*xsize & 2*xsize & 2*xsize &  4*gridsize & nv*gridsize \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
235
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
236
ybounds    & 2*ysize & 2*ysize & 2*xsize &  4*gridsize & nv*gridsize \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
237
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
238
xunits    & degrees & degrees & m &  degrees & degrees \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
239
\hline
Uwe Schulzweida's avatar
Uwe Schulzweida committed
240
 yunits    & degrees & degrees & m &  degrees & degrees \\
Uwe Schulzweida's avatar
Uwe Schulzweida committed
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
\hline
%xname      &  &  &  &  \\
%\hline
%xlongname  &  &  &  &  \\
%\hline
%xunits     &  &  &  &  \\
%\hline
%yname      &  &  &  &  \\
%\hline
%ylongname  &  &  &  &  \\
%\hline
%yunits     &  &  &  &  \\
%\hline
\end{tabular}

\vspace{3mm}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
258
The keywords nvertex, xbounds and ybounds are optional if area weights are not needed.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
259
The grid cell corners xbounds and ybounds have to rotate counterclockwise.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
260
261
262
263

\vspace{2mm}

%\begin{minipage}[t]{\textwidth}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
264
{\CDO} grid description example of a T21 gaussian grid:
Uwe Schulzweida's avatar
Uwe Schulzweida committed
265
\begin{lstlisting}[frame=single, backgroundcolor=\color{pcolor1}, basicstyle=\footnotesize]
Uwe Schulzweida's avatar
Uwe Schulzweida committed
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
    gridtype = gaussian
    xsize    = 64
    ysize    = 32
    xfirst   =  0
    xinc     = 5.625
    yvals    = 85.76  80.27  74.75  69.21  63.68  58.14  52.61  47.07
               41.53  36.00  30.46  24.92  19.38  13.84   8.31   2.77
               -2.77  -8.31 -13.84 -19.38 -24.92 -30.46 -36.00 -41.53
              -47.07 -52.61 -58.14 -63.68 -69.21 -74.75 -80.27 -85.76
\end{lstlisting}
%\end{minipage}

\vspace{2mm}

%\begin{minipage}[t]{\textwidth}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
281
{\CDO} grid description example of a global regular grid with 60x30 points:
Uwe Schulzweida's avatar
Uwe Schulzweida committed
282
\begin{lstlisting}[frame=single, backgroundcolor=\color{pcolor1}, basicstyle=\footnotesize]
Uwe Schulzweida's avatar
Uwe Schulzweida committed
283
284
285
286
287
288
289
290
291
292
    gridtype = lonlat
    xsize    =   60
    ysize    =   30
    xfirst   = -177
    xinc     =    6
    yfirst   =  -87
    yinc     =    6
\end{lstlisting}
%\end{minipage}

Uwe Schulzweida's avatar
Uwe Schulzweida committed
293
% \vspace{2mm}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
294

Uwe Schulzweida's avatar
Uwe Schulzweida committed
295
296
297
% For a lon/lat grid with a rotated pole, the north pole must be defined.
% As far as you define the keywords xnpole/ynpole all coordinate values
% are for the rotated system.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
298

Uwe Schulzweida's avatar
Uwe Schulzweida committed
299
\vspace{2mm}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
300

Uwe Schulzweida's avatar
Uwe Schulzweida committed
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
%\begin{minipage}[t]{\textwidth}
{\CDO} grid description example of a regional rotated lon/lat grid:
\begin{lstlisting}[frame=single, backgroundcolor=\color{pcolor1}, basicstyle=\footnotesize]
   gridtype = projection
   xsize    = 81
   ysize    = 91
   xunits   = "degrees"
   yunits   = "degrees"
   xfirst   =  -19.5
   xinc     =    0.5
   yfirst   =  -25.0
   yinc     =    0.5
   grid_mapping_name = rotated_latitude_longitude
   grid_north_pole_longitude = -170
   grid_north_pole_latitude = 32.5
\end{lstlisting}
%\end{minipage}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
318

Uwe Schulzweida's avatar
Uwe Schulzweida committed
319
Example {\CDO} descriptions of a curvilinear and an unstructured grid can be found
Uwe Schulzweida's avatar
Uwe Schulzweida committed
320
in \htmlref{Appendix C}{appendixgrid}.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355

%#define  GRID_GENERIC             1
%#define  GRID_GAUSSIAN            2
%#define  GRID_GAUSSIAN_REDUCED    3
%#define  GRID_LONLAT              4
%#define  GRID_SPECTRAL            5
%#define  GRID_FOURIER             6
%#define  GRID_TRIANGULAR          7
%#define  GRID_TRAJECTORY          8
%#define  GRID_CELL                9
%#define  GRID_CURVILINEAR        10

%gaussian   curv cell
%regular    curv cell
%triangular      cell

%regular (regelmaessig)
%square (quadratisches) grid is a grid formed by tiling the plane regularly with squares
%A triangular grid, also called an isometric grid (Gardner 1986, pp. 209-210), is a grid fo
%rmed by tiling the plane regularly with equilateral triangles. 

%quadrilateral (vierseitige)

%rectangular (rechteckig)
%  gaussian
%  regular lon/lat

%nonrectangular

%  triangular
%  hexagonal (GME)
%  curvilinear (krummlinig)
%  generic

% retilinear (geradlinig)