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
2dd8356e
Commit
2dd8356e
authored
Nov 05, 2012
by
Uwe Schulzweida
Browse files
grib2: correct endStep if timeunits is not equal stepUnits (big fix)
parent
9690c6bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
2dd8356e
2012-11-05 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* grib2: correct endStep if timeunits is not equal stepUnits (big fix)
* cgribexGetGrid: bug fix for yinc for odd ysize
2012-10-30 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
...
...
src/stream_gribapi.c
View file @
2dd8356e
...
...
@@ -102,15 +102,9 @@ int gribapiGetZaxisType(long editionNumber, int grib_ltype)
}
static
int
g
ribapiG
etTime
U
nits
(
grib_handle
*
gh
)
int
getTime
u
nits
(
long
unitsOfTime
)
{
int
timeunits
=
-
1
;
long
unitsOfTime
;
// size_t len = 8;
//char stepunits[8];
//static int lprint = TRUE;
GRIB_CHECK
(
grib_get_long
(
gh
,
"indicatorOfUnitOfTimeRange"
,
&
unitsOfTime
),
0
);
switch
(
unitsOfTime
)
{
...
...
@@ -124,6 +118,63 @@ int gribapiGetTimeUnits(grib_handle *gh)
default:
timeunits
=
TUNIT_HOUR
;
break
;
}
return
(
timeunits
);
}
static
double
timeunit_factor
(
int
tu1
,
int
tu2
)
{
double
factor
=
1
;
if
(
tu2
==
TUNIT_HOUR
)
{
switch
(
tu1
)
{
case
TUNIT_SECOND
:
factor
=
3600
;
break
;
case
TUNIT_MINUTE
:
factor
=
60
;
break
;
case
TUNIT_HOUR
:
factor
=
1
;
break
;
case
TUNIT_3HOURS
:
factor
=
1
.
/
3
;
break
;
case
TUNIT_6HOURS
:
factor
=
1
.
/
6
;
break
;
case
TUNIT_12HOURS
:
factor
=
1
.
/
12
;
break
;
case
TUNIT_DAY
:
factor
=
1
.
/
24
;
break
;
}
}
return
(
factor
);
}
static
int
gribapiGetEndStep
(
grib_handle
*
gh
,
int
startStep
,
int
timeunits
)
{
int
endStep
=
startStep
;
int
timeunits2
;
long
unitsOfTime
;
long
lpar
;
GRIB_CHECK
(
grib_get_long
(
gh
,
"stepUnits"
,
&
unitsOfTime
),
0
);
timeunits2
=
getTimeunits
(
unitsOfTime
);
GRIB_CHECK
(
grib_get_long
(
gh
,
"endStep"
,
&
lpar
),
0
);
endStep
=
(
int
)
((
lpar
*
timeunit_factor
(
timeunits
,
timeunits2
))
+
0
.
5
);
return
(
endStep
);
}
static
int
gribapiGetTimeUnits
(
grib_handle
*
gh
)
{
int
timeunits
=
-
1
;
long
unitsOfTime
;
// size_t len = 8;
//char stepunits[8];
//static int lprint = TRUE;
GRIB_CHECK
(
grib_get_long
(
gh
,
"indicatorOfUnitOfTimeRange"
,
&
unitsOfTime
),
0
);
timeunits
=
getTimeunits
(
unitsOfTime
);
/*
GRIB_CHECK(grib_get_string(gh, "stepUnits", stepunits, &len), 0);
...
...
@@ -239,9 +290,8 @@ int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
rtime
=
(
int
)
lpar
*
100
;
GRIB_CHECK
(
grib_get_long
(
gh
,
"forecastTime"
,
&
lpar
),
0
);
startStep
=
(
int
)
lpar
;
GRIB_CHECK
(
grib_get_long
(
gh
,
"endStep"
,
&
lpar
),
0
);
endStep
=
(
int
)
lpar
;
timeUnits
=
gribapiGetTimeUnits
(
gh
);
endStep
=
gribapiGetEndStep
(
gh
,
startStep
,
timeUnits
);
range
=
endStep
-
startStep
;
...
...
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