Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
ac4f804a
Commit
ac4f804a
authored
Aug 01, 2016
by
Uwe Schulzweida
Browse files
Set default mapping name to Projection.
parent
22f46e00
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/cdf_write.c
View file @
ac4f804a
...
...
@@ -299,10 +299,7 @@ void cdf_get_gmapvarname(int gridID, char *gmapvarname)
}
if
(
mapping
[
0
]
)
{
cdiGridInqKeyStr
(
pgridID
,
CDI_KEY_MAPNAME
,
CDI_MAX_NAME
,
gmapvarname
);
if
(
!
gmapvarname
[
0
]
)
strcpy
(
gmapvarname
,
"dummy"
);
}
cdiGridInqKeyStr
(
pgridID
,
CDI_KEY_MAPNAME
,
CDI_MAX_NAME
,
gmapvarname
);
}
static
...
...
src/cdi.h
View file @
ac4f804a
...
...
@@ -142,9 +142,9 @@ extern "C" {
#define GRID_SINUSOIDAL 14
/* Sinusoidal */
#define GRID_PROJECTION 15
/* Projected coordinates */
#define CDI_PROJ_RLL
1
1
/* Rotated Latitude Longitude */
#define CDI_PROJ_LCC
1
2
/* Lambert Conformal Conic */
#define CDI_PROJ_LAEA
1
3
/* Lambert Azimuthal Equal Area */
#define CDI_PROJ_RLL
2
1
/* Rotated Latitude Longitude */
#define CDI_PROJ_LCC
2
2
/* Lambert Conformal Conic */
#define CDI_PROJ_LAEA
2
3
/* Lambert Azimuthal Equal Area */
/* ZAXIS types */
...
...
src/grid.c
View file @
ac4f804a
...
...
@@ -339,11 +339,15 @@ cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
break
;
}
case
GRID_GENERIC
:
case
GRID_PROJECTION
:
{
/* gridptr->x.size = size; */
if
(
gridptr
->
x
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
x
.
name
,
"x"
);
if
(
gridptr
->
y
.
name
[
0
]
==
0
)
gridSetName
(
gridptr
->
y
.
name
,
"y"
);
if
(
gridtype
==
GRID_PROJECTION
)
{
gridSetName
(
gridptr
->
mapname
,
"Projection"
);
}
/*
strcpy(gridptr->x.stdname, "grid_longitude");
strcpy(gridptr->y.stdname, "grid_latitude");
...
...
@@ -1829,10 +1833,17 @@ void gridInqProjParamRLL(int gridID, double *xpole, double *ypole, double *angle
void
gridDefProjParamRLL
(
int
gridID
,
double
xpole
,
double
ypole
,
double
angle
)
{
cdiGridDefKeyStr
(
gridID
,
CDI_KEY_MAPPING
,
CDI_MAX_NAME
,
"rotated_latitude_longitude"
);
cdiGridDefKeyStr
(
gridID
,
CDI_KEY_MAPNAME
,
CDI_MAX_NAME
,
"rotated_pole"
);
const
char
*
mapping
=
"rotated_latitude_longitude"
;
cdiGridDefKeyStr
(
gridID
,
CDI_KEY_MAPPING
,
CDI_MAX_NAME
,
mapping
);
vlistDefAttTxt
(
gridID
,
CDI_GLOBAL
,
"grid_mapping_name"
,
strlen
(
mapping
)
+
1
,
mapping
);
vlistDefAttFlt
(
gridID
,
CDI_GLOBAL
,
"grid_north_pole_longitude"
,
DATATYPE_FLT64
,
1
,
&
xpole
);
vlistDefAttFlt
(
gridID
,
CDI_GLOBAL
,
"grid_north_pole_latitude"
,
DATATYPE_FLT64
,
1
,
&
ypole
);
if
(
IS_NOT_EQUAL
(
angle
,
0
)
)
vlistDefAttFlt
(
gridID
,
CDI_GLOBAL
,
"north_pole_grid_longitude"
,
DATATYPE_FLT64
,
1
,
&
angle
);
grid_t
*
gridptr
=
gridID2Ptr
(
gridID
);
gridptr
->
projtype
=
CDI_PROJ_RLL
;
}
/*
...
...
@@ -2689,10 +2700,10 @@ void gridComplete(grid_t *grid)
*/
}
if
(
grid
->
isRotated
)
if
(
grid
->
isRotated
||
grid
->
projtype
==
CDI_PROJ_RLL
)
{
if
(
grid
->
x
.
name
[
0
]
==
0
)
gridDefXname
(
gridID
,
"rlon"
);
if
(
grid
->
y
.
name
[
0
]
==
0
)
gridDefYname
(
gridID
,
"rlat"
);
if
(
grid
->
x
.
name
[
0
]
==
0
||
grid
->
x
.
name
[
0
]
==
'x'
)
gridDefXname
(
gridID
,
"rlon"
);
if
(
grid
->
y
.
name
[
0
]
==
0
||
grid
->
y
.
name
[
0
]
==
'y'
)
gridDefYname
(
gridID
,
"rlat"
);
if
(
grid
->
x
.
longname
[
0
]
==
0
)
gridDefXlongname
(
gridID
,
"longitude in rotated pole grid"
);
if
(
grid
->
y
.
longname
[
0
]
==
0
)
gridDefYlongname
(
gridID
,
"latitude in rotated pole grid"
);
grid
->
x
.
stdname
=
xystdname_tab
[
grid_xystdname_grid_latlon
][
0
];
...
...
@@ -2700,9 +2711,12 @@ void gridComplete(grid_t *grid)
if
(
grid
->
x
.
units
[
0
]
==
0
)
gridDefXunits
(
gridID
,
"degrees"
);
if
(
grid
->
y
.
units
[
0
]
==
0
)
gridDefYunits
(
gridID
,
"degrees"
);
gridDefXpole
(
gridID
,
grid
->
rll
.
xpole
);
gridDefYpole
(
gridID
,
grid
->
rll
.
ypole
);
gridDefAngle
(
gridID
,
grid
->
rll
.
angle
);
if
(
grid
->
isRotated
)
{
gridDefXpole
(
gridID
,
grid
->
rll
.
xpole
);
gridDefYpole
(
gridID
,
grid
->
rll
.
ypole
);
gridDefAngle
(
gridID
,
grid
->
rll
.
angle
);
}
}
switch
(
gridtype
)
...
...
src/stream_cdf_o.c
View file @
ac4f804a
...
...
@@ -811,8 +811,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
ncgrid
[
gridindex
].
ydimID
=
dimID
;
}
static
void
finishCyclicXBounds
(
double
*
pbounds
,
size_t
dimlen
,
const
double
*
pvals
)
static
void
finishCyclicXBounds
(
double
*
pbounds
,
size_t
dimlen
,
const
double
*
pvals
)
{
pbounds
[
0
]
=
(
pvals
[
0
]
+
pvals
[
dimlen
-
1
]
-
360
)
*
0
.
5
;
pbounds
[
2
*
dimlen
-
1
]
=
(
pvals
[
dimlen
-
1
]
+
pvals
[
0
]
+
360
)
*
0
.
5
;
...
...
@@ -825,8 +825,8 @@ void cdfDefXaxis(stream_t *streamptr, int gridID, int gridindex, int ndims)
CDI_KEY_XDIMNAME
,
'X'
,
finishCyclicXBounds
);
}
static
void
finishCyclicYBounds
(
double
*
pbounds
,
size_t
dimlen
,
const
double
*
pvals
)
static
void
finishCyclicYBounds
(
double
*
pbounds
,
size_t
dimlen
,
const
double
*
pvals
)
{
pbounds
[
0
]
=
copysign
(
90
.
0
,
pvals
[
0
]);
pbounds
[
2
*
dimlen
-
1
]
=
copysign
(
90
.
0
,
pvals
[
dimlen
-
1
]);
...
...
@@ -1940,13 +1940,12 @@ void cdf_def_mapping(stream_t *streamptr, int gridID)
{
char
gmapvarname
[
CDI_MAX_NAME
];
gmapvarname
[
0
]
=
0
;
cdiGridInqKeyStr
(
gridID
,
CDI_KEY_MAPNAME
,
CDI_MAX_NAME
,
gmapvarname
);
if
(
!
gmapvarname
[
0
]
)
strcpy
(
gmapvarname
,
"dummy"
);
int
fileID
=
streamptr
->
fileID
;
cdf_redef
(
fileID
);
int
ncvarid
;
int
ncerrcode
=
nc_def_var
(
fileID
,
gmapvarname
,
(
nc_type
)
NC_
CHAR
,
0
,
NULL
,
&
ncvarid
);
int
ncerrcode
=
nc_def_var
(
fileID
,
gmapvarname
,
(
nc_type
)
NC_
INT
,
0
,
NULL
,
&
ncvarid
);
if
(
ncerrcode
==
NC_NOERR
)
cdfDefineAttributes
(
gridID
,
CDI_GLOBAL
,
fileID
,
ncvarid
);
...
...
src/stream_ieg.c
View file @
ac4f804a
...
...
@@ -665,6 +665,8 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
grid
->
rll
.
ypole
=
ypole
;
grid
->
rll
.
angle
=
0
;
}
else
grid
->
projtype
=
CDI_PROJ_RLL
;
}
struct
addIfNewRes
gridAdded
=
cdiVlistAddGridIfNew
(
vlistID
,
grid
,
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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