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
bcba91e4
Commit
bcba91e4
authored
Jul 30, 2016
by
Uwe Schulzweida
Browse files
ieg write: added support for projection CDI_PROJ_RLL.
parent
954d3800
Changes
6
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
bcba91e4
2016-07-30 Uwe Schulzweida
* ieg write: added support for projection CDI_PROJ_RLL
2016-07-28 Uwe Schulzweida
* iegWriteVarSliceDP: does not work (bug fix)
...
...
src/cdi.h
View file @
bcba91e4
...
...
@@ -142,6 +142,10 @@ extern "C" {
#define GRID_SINUSOIDAL 14
/* Sinusoidal */
#define GRID_PROJECTION 15
/* Projected coordinates */
#define CDI_PROJ_RLL 11
/* Rotated Latitude Longitude */
#define CDI_PROJ_LCC 12
/* Lambert Conformal Conic */
#define CDI_PROJ_LAEA 13
/* Lambert Azimuthal Equal Area */
/* ZAXIS types */
#define ZAXIS_SURFACE 0
/* Surface level */
...
...
@@ -723,6 +727,9 @@ int gridDuplicate(int gridID);
/* gridInqProj: Get the projection ID of a Grid */
int
gridInqProj
(
int
gridID
);
/* gridInqProjType: Get the projection type */
int
gridInqProjType
(
int
gridID
);
/* gridInqType: Get the type of a Grid */
int
gridInqType
(
int
gridID
);
...
...
src/grid.c
View file @
bcba91e4
...
...
@@ -94,15 +94,17 @@ void grid_init(grid_t *gridptr)
gridptr
->
self
=
CDI_UNDEFID
;
gridptr
->
type
=
CDI_UNDEFID
;
gridptr
->
proj
=
CDI_UNDEFID
;
gridptr
->
projtype
=
CDI_UNDEFID
;
gridptr
->
mask
=
NULL
;
gridptr
->
mask_gme
=
NULL
;
gridptr
->
x
.
vals
=
NULL
;
gridptr
->
y
.
vals
=
NULL
;
gridptr
->
area
=
NULL
;
gridptr
->
x
.
bounds
=
NULL
;
gridptr
->
y
.
bounds
=
NULL
;
gridptr
->
area
=
NULL
;
gridptr
->
rowlon
=
NULL
;
gridptr
->
nrowlon
=
0
;
gridptr
->
x
.
first
=
0
.
0
;
gridptr
->
x
.
last
=
0
.
0
;
gridptr
->
x
.
inc
=
0
.
0
;
...
...
@@ -979,6 +981,7 @@ void gridInqYunits(int gridID, char *yunits)
(
void
)
cdiGridInqKeyStr
(
gridID
,
CDI_KEY_YUNITS
,
CDI_MAX_NAME
,
yunits
);
}
void
gridInqYstdname
(
int
gridID
,
char
*
ystdname
)
{
grid_t
*
gridptr
=
gridID2Ptr
(
gridID
);
...
...
@@ -988,6 +991,7 @@ void gridInqYstdname(int gridID, char *ystdname)
ystdname
[
0
]
=
0
;
}
int
gridInqProj
(
int
gridID
)
{
grid_t
*
gridptr
=
gridID2Ptr
(
gridID
);
...
...
@@ -995,6 +999,27 @@ int gridInqProj(int gridID)
return
gridptr
->
proj
;
}
int
gridInqProjType
(
int
gridID
)
{
grid_t
*
gridptr
=
gridID2Ptr
(
gridID
);
int
projtype
=
gridptr
->
projtype
;
if
(
projtype
==
-
1
)
{
char
mapping
[
CDI_MAX_NAME
];
mapping
[
0
]
=
0
;
cdiGridInqKeyStr
(
gridID
,
CDI_KEY_MAPPING
,
CDI_MAX_NAME
,
mapping
);
if
(
mapping
[
0
]
)
{
if
(
strcmp
(
mapping
,
"rotated_latitude_longitude"
)
==
0
)
projtype
=
CDI_PROJ_RLL
;
gridptr
->
projtype
=
projtype
;
}
}
return
projtype
;
}
/*
@Function gridInqType
@Title Get the type of a Grid
...
...
src/grid.h
View file @
bcba91e4
...
...
@@ -105,6 +105,7 @@ struct grid_t {
int
type
;
/* grid type */
int
prec
;
/* grid precision */
int
proj
;
/* grid projection */
int
projtype
;
/* grid projection type */
mask_t
*
mask
;
mask_t
*
mask_gme
;
double
*
area
;
...
...
src/stream_cgribex.c
View file @
bcba91e4
...
...
@@ -1613,7 +1613,7 @@ static
void
cgribexDefGrid
(
int
*
isec1
,
int
*
isec2
,
double
*
fsec2
,
int
*
isec4
,
int
gridID
)
{
static
bool
lwarning
=
true
;
bool
lrotated
ll
=
false
;
bool
lrotated
=
false
;
bool
lcurvi
=
false
;
memset
(
isec2
,
0
,
16
*
sizeof
(
int
));
...
...
@@ -1661,15 +1661,10 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
lcurvi
=
true
;
}
if
(
gridtype
==
GRID_PROJECTION
)
if
(
gridtype
==
GRID_PROJECTION
&&
gridInqProjType
(
gridID
)
==
CDI_PROJ_RLL
)
{
char
mapping
[
CDI_MAX_NAME
];
mapping
[
0
]
=
0
;
cdiGridInqKeyStr
(
gridID
,
CDI_KEY_MAPPING
,
CDI_MAX_NAME
,
mapping
);
if
(
mapping
[
0
]
&&
strcmp
(
mapping
,
"rotated_latitude_longitude"
)
==
0
)
{
gridtype
=
GRID_LONLAT
;
lrotatedll
=
true
;
}
gridtype
=
GRID_LONLAT
;
lrotated
=
true
;
}
ISEC2_Reduced
=
FALSE
;
...
...
@@ -1688,7 +1683,7 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_GAUSSIAN_REDUCED
)
ISEC2_GridType
=
GRIB1_GTYPE_GAUSSIAN
;
else
if
(
gridtype
==
GRID_LONLAT
&&
(
isRotated
||
lrotated
ll
)
)
else
if
(
gridtype
==
GRID_LONLAT
&&
(
isRotated
||
lrotated
)
)
ISEC2_GridType
=
GRIB1_GTYPE_LATLON_ROT
;
else
ISEC2_GridType
=
GRIB1_GTYPE_LATLON
;
...
...
@@ -1764,7 +1759,7 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
ISEC2_ResFlag
=
(
ISEC2_LatIncr
==
0
||
ISEC2_LonIncr
==
0
)
?
0
:
128
;
if
(
isRotated
||
lrotated
ll
)
if
(
isRotated
||
lrotated
)
{
double
xpole
=
0
,
ypole
=
0
,
angle
=
0
;
if
(
isRotated
)
...
...
src/stream_ieg.c
View file @
bcba91e4
...
...
@@ -246,13 +246,19 @@ calc_resfac(double xfirst, double xlast, double xinc, double yfirst, double ylas
static
void
iegDefGrid
(
int
*
gdb
,
int
gridID
)
{
int
projID
=
gridInqProj
(
gridID
);
if
(
projID
!=
CDI_UNDEFID
&&
gridInqProjType
(
projID
)
==
CDI_PROJ_RLL
)
gridID
=
projID
;
int
gridtype
=
gridInqType
(
gridID
);
int
projtype
=
CDI_UNDEFID
;
if
(
gridtype
==
GRID_PROJECTION
&&
gridInqProjType
(
gridID
)
==
CDI_PROJ_RLL
)
projtype
=
CDI_PROJ_RLL
;
int
xsize
=
gridInqXsize
(
gridID
);
int
ysize
=
gridInqYsize
(
gridID
);
if
(
gridtype
==
GRID_GENERIC
)
{
int
xsize
=
gridInqXsize
(
gridID
);
int
ysize
=
gridInqYsize
(
gridID
);
if
(
(
ysize
==
32
||
ysize
==
48
||
ysize
==
64
||
ysize
==
96
||
ysize
==
160
)
&&
(
xsize
==
2
*
ysize
||
xsize
==
1
)
)
...
...
@@ -276,39 +282,32 @@ void iegDefGrid(int *gdb, int gridID)
gridtype
=
GRID_LONLAT
;
}
if
(
gridtype
==
GRID_LONLAT
||
gridtype
==
GRID_GAUSSIAN
)
bool
lrotated
=
((
gridtype
==
GRID_LONLAT
&&
gridIsRotated
(
gridID
))
||
projtype
==
CDI_PROJ_RLL
);
if
(
gridtype
==
GRID_LONLAT
||
gridtype
==
GRID_GAUSSIAN
||
projtype
==
CDI_PROJ_RLL
)
{
double
xfirst
=
0
,
xlast
=
0
,
xinc
=
0
;
double
yfirst
=
0
,
ylast
=
0
,
yinc
=
0
;
int
nlon
=
gridInqXsize
(
gridID
),
nlat
=
gridInqYsize
(
gridID
);
if
(
nlon
==
0
)
{
nlon
=
1
;
}
if
(
xsize
==
0
)
xsize
=
1
;
else
{
xfirst
=
gridInqXval
(
gridID
,
0
);
xlast
=
gridInqXval
(
gridID
,
nlon
-
1
);
xfirst
=
gridInqXval
(
gridID
,
0
);
xlast
=
gridInqXval
(
gridID
,
xsize
-
1
);
xinc
=
gridInqXinc
(
gridID
);
}
if
(
nlat
==
0
)
{
nlat
=
1
;
}
if
(
ysize
==
0
)
ysize
=
1
;
else
{
yfirst
=
gridInqYval
(
gridID
,
0
);
ylast
=
gridInqYval
(
gridID
,
nlat
-
1
);
yfirst
=
gridInqYval
(
gridID
,
0
);
ylast
=
gridInqYval
(
gridID
,
ysize
-
1
);
yinc
=
gridInqYinc
(
gridID
);
}
if
(
gridtype
==
GRID_GAUSSIAN
)
IEG_G_GridType
(
gdb
)
=
4
;
else
if
(
gridtype
==
GRID_LONLAT
&&
gridIsRotated
(
gridID
)
)
else
if
(
lrotated
)
IEG_G_GridType
(
gdb
)
=
10
;
else
IEG_G_GridType
(
gdb
)
=
0
;
...
...
@@ -319,8 +318,8 @@ void iegDefGrid(int *gdb, int gridID)
IEG_G_ResFac
(
gdb
)
=
iresfac
;
IEG_G_NumLon
(
gdb
)
=
nlon
;
IEG_G_NumLat
(
gdb
)
=
nlat
;
IEG_G_NumLon
(
gdb
)
=
xsize
;
IEG_G_NumLat
(
gdb
)
=
ysize
;
IEG_G_FirstLat
(
gdb
)
=
(
int
)
lround
(
yfirst
*
resfac
);
IEG_G_LastLat
(
gdb
)
=
(
int
)
lround
(
ylast
*
resfac
);
IEG_G_FirstLon
(
gdb
)
=
(
int
)
lround
(
xfirst
*
resfac
);
...
...
@@ -330,7 +329,7 @@ void iegDefGrid(int *gdb, int gridID)
IEG_G_LonIncr
(
gdb
)
=
0
;
if
(
gridtype
==
GRID_GAUSSIAN
)
IEG_G_LatIncr
(
gdb
)
=
nlat
/
2
;
IEG_G_LatIncr
(
gdb
)
=
ysize
/
2
;
else
{
IEG_G_LatIncr
(
gdb
)
=
(
int
)
lround
(
yinc
*
resfac
);
...
...
@@ -346,15 +345,22 @@ void iegDefGrid(int *gdb, int gridID)
if
(
IEG_G_NumLon
(
gdb
)
==
1
&&
IEG_G_NumLat
(
gdb
)
>
1
)
if
(
IEG_G_LonIncr
(
gdb
)
==
0
&&
IEG_G_LatIncr
(
gdb
)
!=
0
)
IEG_G_LonIncr
(
gdb
)
=
IEG_G_LatIncr
(
gdb
);
if
(
IEG_G_LatIncr
(
gdb
)
==
0
||
IEG_G_LonIncr
(
gdb
)
==
0
)
IEG_G_ResFlag
(
gdb
)
=
0
;
else
IEG_G_ResFlag
(
gdb
)
=
128
;
IEG_G_ResFlag
(
gdb
)
=
(
IEG_G_LatIncr
(
gdb
)
==
0
||
IEG_G_LonIncr
(
gdb
)
==
0
)
?
0
:
128
;
if
(
gridIsRotated
(
gridID
)
)
if
(
lrotated
)
{
IEG_G_LatSP
(
gdb
)
=
-
(
int
)
lround
(
gridInqYpole
(
gridID
)
*
resfac
);
IEG_G_LonSP
(
gdb
)
=
(
int
)
lround
((
gridInqXpole
(
gridID
)
+
180
)
*
resfac
);
double
xpole
=
0
,
ypole
=
0
,
angle
=
0
;
if
(
projtype
==
CDI_PROJ_RLL
)
gridInqProjParamRLL
(
gridID
,
&
xpole
,
&
ypole
,
&
angle
);
else
{
xpole
=
gridInqXpole
(
gridID
);
ypole
=
gridInqYpole
(
gridID
);
angle
=
gridInqAngle
(
gridID
);
}
IEG_G_LatSP
(
gdb
)
=
-
(
int
)
lround
(
ypole
*
resfac
);
IEG_G_LonSP
(
gdb
)
=
(
int
)
lround
((
xpole
+
180
)
*
resfac
);
IEG_G_Size
(
gdb
)
=
42
;
}
else
...
...
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