Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
905a0f6a
Commit
905a0f6a
authored
Nov 25, 2008
by
Uwe Schulzweida
Browse files
add support for GRID type SINUSOIDAL
parent
b9751ad8
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
905a0f6a
2008-12-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* add support for GRID type SINUSOIDAL
* add support of GRIB level type MEANSEA
* cdf_inq_contents: check zaxis type "depth_blow_sea/land" (bug fix)
...
...
app/cdi.c
View file @
905a0f6a
...
...
@@ -246,6 +246,7 @@ static void printGridInfo(int vlistID)
int
ngrids
,
index
;
int
gridID
,
gridtype
,
trunc
,
gridsize
,
xsize
,
ysize
;
int
nbyte0
;
char
xname
[
128
],
yname
[
128
],
xunits
[
128
],
yunits
[
128
];
ngrids
=
vlistNgrids
(
vlistID
);
for
(
index
=
0
;
index
<
ngrids
;
index
++
)
...
...
@@ -256,22 +257,27 @@ static void printGridInfo(int vlistID)
gridsize
=
gridInqSize
(
gridID
);
xsize
=
gridInqXsize
(
gridID
);
ysize
=
gridInqYsize
(
gridID
);
gridInqXname
(
gridID
,
xname
);
gridInqYname
(
gridID
,
yname
);
gridInqXunits
(
gridID
,
xunits
);
gridInqYunits
(
gridID
,
yunits
);
/* nbyte0 = fprintf(stdout, " %4d : %-23s : ",*/
nbyte0
=
fprintf
(
stdout
,
" %4d : %-12s > "
,
gridID
+
1
,
gridNamePtr
(
gridtype
));
if
(
gridtype
==
GRID_LONLAT
||
gridtype
==
GRID_SINUSOIDAL
||
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_GAUSSIAN_REDUCED
)
{
double
lon
first
=
0
.
0
,
lon
last
=
0
.
0
;
double
lat
first
=
0
.
0
,
lat
last
=
0
.
0
;
double
lon
inc
=
0
.
0
,
lat
inc
=
0
.
0
;
double
x
first
=
0
.
0
,
x
last
=
0
.
0
;
double
y
first
=
0
.
0
,
y
last
=
0
.
0
;
double
x
inc
=
0
.
0
,
y
inc
=
0
.
0
;
lat
first
=
gridInqYval
(
gridID
,
0
);
lat
last
=
gridInqYval
(
gridID
,
ysize
-
1
);
lat
inc
=
gridInqYinc
(
gridID
);
y
first
=
gridInqYval
(
gridID
,
0
);
y
last
=
gridInqYval
(
gridID
,
ysize
-
1
);
y
inc
=
gridInqYinc
(
gridID
);
if
(
gridtype
==
GRID_GAUSSIAN_REDUCED
)
{
fprintf
(
stdout
,
"size : dim = %d nlat = %d
\n
"
,
gridsize
,
ysize
);
...
...
@@ -280,22 +286,24 @@ static void printGridInfo(int vlistID)
}
else
{
lon
first
=
gridInqXval
(
gridID
,
0
);
lon
last
=
gridInqXval
(
gridID
,
xsize
-
1
);
lon
inc
=
gridInqXinc
(
gridID
);
x
first
=
gridInqXval
(
gridID
,
0
);
x
last
=
gridInqXval
(
gridID
,
xsize
-
1
);
x
inc
=
gridInqXinc
(
gridID
);
fprintf
(
stdout
,
"size : dim = %d nlon = %d nlat = %d
\n
"
,
gridsize
,
xsize
,
ysize
);
fprintf
(
stdout
,
"%*s"
,
nbyte0
,
""
);
fprintf
(
stdout
,
"longitude : first = %.9g last = %.9g"
,
lonfirst
,
lonlast
);
if
(
!
DBL_IS_EQUAL
(
loninc
,
0
)
)
fprintf
(
stdout
,
" inc = %.9g"
,
loninc
);
fprintf
(
stdout
,
"%-9s : first = %.9g last = %.9g"
,
xname
,
xfirst
,
xlast
);
if
(
!
DBL_IS_EQUAL
(
xinc
,
0
)
)
fprintf
(
stdout
,
" inc = %.9g"
,
xinc
);
fprintf
(
stdout
,
" %s"
,
xunits
);
if
(
gridIsCircular
(
gridID
)
)
fprintf
(
stdout
,
" circular"
);
fprintf
(
stdout
,
"
\n
"
);
}
fprintf
(
stdout
,
"%*s"
,
nbyte0
,
""
);
fprintf
(
stdout
,
"latitude : first = %.9g last = %.9g"
,
latfirst
,
latlast
);
if
(
!
DBL_IS_EQUAL
(
latinc
,
0
)
&&
gridtype
==
GRID_LONLAT
)
fprintf
(
stdout
,
" inc = %.9g"
,
latinc
);
fprintf
(
stdout
,
"%-9s : first = %.9g last = %.9g"
,
yname
,
yfirst
,
ylast
);
if
(
!
DBL_IS_EQUAL
(
yinc
,
0
)
&&
(
gridtype
==
GRID_LONLAT
||
gridtype
==
GRID_SINUSOIDAL
)
)
fprintf
(
stdout
,
" inc = %.9g"
,
yinc
);
fprintf
(
stdout
,
" %s"
,
yunits
);
fprintf
(
stdout
,
"
\n
"
);
if
(
gridIsRotated
(
gridID
)
)
...
...
@@ -338,8 +346,6 @@ static void printGridInfo(int vlistID)
if
(
gridInqXvals
(
gridID
,
NULL
)
&&
gridInqYvals
(
gridID
,
NULL
)
)
{
int
i
;
char
xunits
[
256
];
char
yunits
[
256
];
double
*
xvals
,
*
yvals
;
double
xfirst
,
xlast
,
yfirst
,
ylast
;
xvals
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
...
...
@@ -347,8 +353,6 @@ static void printGridInfo(int vlistID)
gridInqXvals
(
gridID
,
xvals
);
gridInqYvals
(
gridID
,
yvals
);
gridInqXunits
(
gridID
,
xunits
);
gridInqYunits
(
gridID
,
yunits
);
xfirst
=
xvals
[
0
];
xlast
=
xvals
[
0
];
...
...
@@ -363,12 +367,12 @@ static void printGridInfo(int vlistID)
}
fprintf
(
stdout
,
"%*s"
,
nbyte0
,
""
);
fprintf
(
stdout
,
"
longitude
: min = %.9g max = %.9g %s"
,
xfirst
,
xlast
,
xunits
);
fprintf
(
stdout
,
"
%-9s
: min = %.9g max = %.9g %s"
,
xname
,
xfirst
,
xlast
,
xunits
);
if
(
gridIsCircular
(
gridID
)
)
fprintf
(
stdout
,
" circular"
);
fprintf
(
stdout
,
"
\n
"
);
fprintf
(
stdout
,
"%*s"
,
nbyte0
,
""
);
fprintf
(
stdout
,
"
latitude
: min = %.9g max = %.9g %s
\n
"
,
yfirst
,
ylast
,
yunits
);
fprintf
(
stdout
,
"
%-9s
: min = %.9g max = %.9g %s
\n
"
,
yname
,
yfirst
,
ylast
,
yunits
);
free
(
xvals
);
free
(
yvals
);
...
...
src/cdi.h
View file @
905a0f6a
...
...
@@ -109,6 +109,7 @@ extern "C" {
#define GRID_CURVILINEAR 10
#define GRID_LCC 11
/* Lambert Conformal Conic */
#define GRID_LAEA 12
/* Lambert Azimuthal Equal Area */
#define GRID_SINUSOIDAL 13
/* Sinusoidal */
/* ZAXIS types */
...
...
src/grid.c
View file @
905a0f6a
This diff is collapsed.
Click to expand it.
src/grid.h
View file @
905a0f6a
...
...
@@ -48,7 +48,7 @@ typedef struct {
char
xunits
[
256
];
char
yunits
[
256
];
}
GRID
;
grid_t
;
const
double
*
gridInqXvalsPtr
(
int
gridID
);
...
...
@@ -58,8 +58,8 @@ double *gridInqXboundsPtr(int gridID);
double
*
gridInqYboundsPtr
(
int
gridID
);
const
double
*
gridInqAreaPtr
(
int
gridID
);
int
gridCompare
(
int
gridID
,
GRID
grid
);
int
gridGenerate
(
GRID
grid
);
int
gridCompare
(
int
gridID
,
grid_t
grid
);
int
gridGenerate
(
grid_t
grid
);
/* GME grid */
void
gme_grid
(
int
gridsize
,
double
*
rlon
,
double
*
rlat
,
...
...
src/stream_cdf.c
View file @
905a0f6a
...
...
@@ -2227,6 +2227,38 @@ void cdfDefPole(int streamID, int gridID)
}
void
cdfDefMapping
(
int
streamID
,
int
gridID
)
{
#if defined (HAVE_LIBNETCDF)
int
fileID
;
int
ncvarid
=
UNDEFID
;
int
ncerr
;
if
(
gridInqType
(
gridID
)
==
GRID_SINUSOIDAL
)
{
char
varname
[]
=
"sinusoidal"
;
char
mapname
[]
=
"sinusoidal"
;
fileID
=
streamInqFileID
(
streamID
);
cdf_redef
(
fileID
);
ncerr
=
nc_def_var
(
fileID
,
varname
,
(
nc_type
)
NC_CHAR
,
0
,
NULL
,
&
ncvarid
);
if
(
ncerr
==
NC_NOERR
)
{
cdf_put_att_text
(
fileID
,
ncvarid
,
"grid_mapping_name"
,
strlen
(
mapname
),
mapname
);
/*
cdf_put_att_double(fileID, ncvarid, "grid_north_pole_latitude", NC_DOUBLE, 1L, &ypole);
cdf_put_att_double(fileID, ncvarid, "grid_north_pole_longitude", NC_DOUBLE, 1L, &xpole);
*/
}
cdf_enddef
(
fileID
);
}
#endif
}
void
cdfDefGrid
(
int
streamID
,
int
gridID
)
{
#if defined (HAVE_LIBNETCDF)
...
...
@@ -2286,6 +2318,13 @@ void cdfDefGrid(int streamID, int gridID)
{
cdfDefCell
(
streamID
,
gridID
);
}
else
if
(
gridtype
==
GRID_SINUSOIDAL
)
{
cdfDefXaxis
(
streamID
,
gridID
);
cdfDefYaxis
(
streamID
,
gridID
);
cdfDefMapping
(
streamID
,
gridID
);
}
/*
else if ( gridtype == GRID_LCC )
{
...
...
@@ -2485,6 +2524,12 @@ int cdfDefVar(int streamID, int varID)
cdf_put_att_text
(
fileID
,
ncvarid
,
"grid_mapping"
,
strlen
(
mapping
),
mapping
);
}
if
(
gridInqType
(
gridID
)
==
GRID_SINUSOIDAL
)
{
char
mapping
[]
=
"sinusoidal"
;
cdf_put_att_text
(
fileID
,
ncvarid
,
"grid_mapping"
,
strlen
(
mapping
),
mapping
);
}
if
(
gridInqType
(
gridID
)
==
GRID_TRAJECTORY
)
{
cdf_put_att_text
(
fileID
,
ncvarid
,
"coordinates"
,
9
,
"tlon tlat"
);
...
...
@@ -3518,7 +3563,7 @@ int cdfInqContents(int streamID)
size_t
len
;
int
nc_nvars
;
int
nvcth_id
=
UNDEFID
,
vcta_id
=
UNDEFID
,
vctb_id
=
UNDEFID
;
GRID
grid
;
grid_t
grid
;
int
gridindex
;
int
zaxisindex
;
size_t
vctsize
=
0
;
...
...
@@ -3817,6 +3862,8 @@ int cdfInqContents(int streamID)
ncvars
[
ncvarid
].
gridtype
=
GRID_CELL
;
else
if
(
strncmp
(
attstring
,
"curvilinear"
,
attlen
)
==
0
)
ncvars
[
ncvarid
].
gridtype
=
GRID_CURVILINEAR
;
else
if
(
strncmp
(
attstring
,
"sinusoidal"
,
attlen
)
==
0
)
/* ncvars[ncvarid].gridtype = GRID_CURVILINEAR */
;
else
{
static
int
warn
=
TRUE
;
...
...
@@ -4596,7 +4643,7 @@ int cdfInqContents(int streamID)
if
(
ncvars
[
ncvarid
].
gridtype
==
UNDEFID
||
ncvars
[
ncvarid
].
gridtype
==
GRID_GENERIC
)
if
(
ydimid
==
xdimid
)
ncvars
[
ncvarid
].
gridtype
=
GRID_CELL
;
memset
(
&
grid
,
0
,
sizeof
(
GRID
));
memset
(
&
grid
,
0
,
sizeof
(
grid_t
));
grid
.
prec
=
DATATYPE_FLT64
;
grid
.
trunc
=
ncvars
[
ncvarid
].
truncation
;
...
...
@@ -4872,6 +4919,8 @@ int cdfInqContents(int streamID)
if
(
strcmp
(
attstring
,
"rotated_latitude_longitude"
)
==
0
)
grid
.
isRotated
=
TRUE
;
else
if
(
strcmp
(
attstring
,
"sinusoidal"
)
==
0
)
grid
.
type
=
GRID_SINUSOIDAL
;
}
else
if
(
strcmp
(
attname
,
"grid_north_pole_latitude"
)
==
0
)
{
...
...
src/stream_ext.c
View file @
905a0f6a
...
...
@@ -260,7 +260,7 @@ void extAddRecord(int streamID, int code, int level, int xysize,
int
tsID
,
recID
,
varID
;
int
datatype
;
RECORD
*
record
;
GRID
grid
;
grid_t
grid
;
int
vlistID
;
STREAM
*
streamptr
;
...
...
@@ -276,7 +276,7 @@ void extAddRecord(int streamID, int code, int level, int xysize,
(
*
record
).
code
=
code
;
(
*
record
).
ilevel
=
level
;
memset
(
&
grid
,
0
,
sizeof
(
GRID
));
memset
(
&
grid
,
0
,
sizeof
(
grid_t
));
grid
.
type
=
GRID_GENERIC
;
grid
.
size
=
xysize
;
grid
.
xsize
=
xysize
;
...
...
src/stream_grb.c
View file @
905a0f6a
...
...
@@ -715,7 +715,7 @@ void grbAddRecord(int streamID, int code, int *isec1, int *isec2, double *fsec2,
int
numavg
;
int
lbounds
=
0
;
RECORD
*
record
;
GRID
grid
;
grid_t
grid
;
int
vlistID
;
STREAM
*
streamptr
;
...
...
@@ -750,7 +750,7 @@ void grbAddRecord(int streamID, int code, int *isec1, int *isec2, double *fsec2,
ISEC4_NumValues
=
ISEC2_NumLon
*
ISEC2_NumLat
;
}
memset
(
&
grid
,
0
,
sizeof
(
GRID
));
memset
(
&
grid
,
0
,
sizeof
(
grid_t
));
switch
(
gridtype
)
{
case
GRID_LONLAT
:
...
...
src/stream_ieg.c
View file @
905a0f6a
...
...
@@ -610,7 +610,7 @@ void iegAddRecord(int streamID, int code, int *pdb, int *gdb, double *vct,
int
gridtype
;
int
lbounds
=
0
;
RECORD
*
record
;
GRID
grid
;
grid_t
grid
;
int
vlistID
;
STREAM
*
streamptr
;
...
...
@@ -648,7 +648,7 @@ void iegAddRecord(int streamID, int code, int *pdb, int *gdb, double *vct,
else
gridtype
=
GRID_GENERIC
;
memset
(
&
grid
,
0
,
sizeof
(
GRID
));
memset
(
&
grid
,
0
,
sizeof
(
grid_t
));
grid
.
type
=
gridtype
;
grid
.
size
=
IEG_G_NumLon
(
gdb
)
*
IEG_G_NumLat
(
gdb
);
grid
.
xsize
=
IEG_G_NumLon
(
gdb
);
...
...
src/stream_srv.c
View file @
905a0f6a
...
...
@@ -278,7 +278,7 @@ void srvAddRecord(int streamID, int code, int level, int xsize, int ysize,
int
tsID
,
recID
,
varID
;
int
datatype
;
RECORD
*
record
;
GRID
grid
;
grid_t
grid
;
int
vlistID
;
STREAM
*
streamptr
;
...
...
@@ -294,7 +294,7 @@ void srvAddRecord(int streamID, int code, int level, int xsize, int ysize,
(
*
record
).
code
=
code
;
(
*
record
).
ilevel
=
level
;
memset
(
&
grid
,
0
,
sizeof
(
GRID
));
memset
(
&
grid
,
0
,
sizeof
(
grid_t
));
grid
.
type
=
GRID_GENERIC
;
grid
.
size
=
xsize
*
ysize
;
grid
.
xsize
=
xsize
;
...
...
src/varscan.c
View file @
905a0f6a
...
...
@@ -513,7 +513,7 @@ void varDefVCT(size_t vctsize, double *vctptr)
}
int
varDefGrid
(
int
vlistID
,
GRID
grid
,
int
mode
)
int
varDefGrid
(
int
vlistID
,
grid_t
grid
,
int
mode
)
{
/*
mode: 0 search in vlist and grid table
...
...
src/varscan.h
View file @
905a0f6a
...
...
@@ -12,7 +12,7 @@ void varAddRecord(int recID, int code, int gridID, int zaxistype, int lbounds,
void
varDefVCT
(
size_t
vctsize
,
double
*
vctptr
);
int
varDefGrid
(
int
vlistID
,
GRID
grid
,
int
mode
);
int
varDefGrid
(
int
vlistID
,
grid_t
grid
,
int
mode
);
int
varDefZaxis
(
int
vlistID
,
int
zaxistype
,
int
nlevels
,
double
*
levels
,
int
lbounds
,
double
*
levels1
,
double
*
levels2
,
int
vctsize
,
double
*
vct
,
char
*
name
,
char
*
longname
,
char
*
units
,
int
prec
,
int
mode
,
int
ltype
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment