Commit 5e26274b authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

ZAXIS_HEIGHT: added support for units cm, dm and km

parent 8da5c8e5
......@@ -3,6 +3,10 @@
* Version 1.7.1 released
* using CGRIBEX library version 1.7.4
2015-12-23 Uwe Schulzweida
* ZAXIS_HEIGHT: added support for units cm, dm and km
2015-12-19 Uwe Schulzweida
* gribapiDecode internal problem when processing 1x1 GRIB2 data with JPEG compression [Bug #6402]
......
......@@ -149,7 +149,7 @@ extern "C" {
#define ZAXIS_HYBRID 2 /* Hybrid level */
#define ZAXIS_HYBRID_HALF 3 /* Hybrid half level */
#define ZAXIS_PRESSURE 4 /* Isobaric pressure level in Pascal */
#define ZAXIS_HEIGHT 5 /* Height above ground in meters */
#define ZAXIS_HEIGHT 5 /* Height above ground */
#define ZAXIS_DEPTH_BELOW_SEA 6 /* Depth below sea level in meters */
#define ZAXIS_DEPTH_BELOW_LAND 7 /* Depth below land surface in centimeters */
#define ZAXIS_ISENTROPIC 8 /* Isentropic */
......
......@@ -2001,6 +2001,15 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
{
level = zaxisInqLevel(zaxisID, levelID);
char units[128];
zaxisInqUnits(zaxisID, units);
if ( units[1] == 'm' && !units[2] )
{
if ( units[0] == 'c' ) level *= 0.01;
else if ( units[0] == 'd' ) level *= 0.1;
else if ( units[0] == 'k' ) level *= 1000;
}
ilevel = (int) level;
ISEC1_LevelType = GRIB1_LTYPE_HEIGHT;
ISEC1_Level1 = ilevel;
......
......@@ -18,31 +18,31 @@ int grib1ltypeToZaxisType(int grib_ltype)
switch ( grib_ltype )
{
case GRIB1_LTYPE_SURFACE: { zaxistype = ZAXIS_SURFACE; break; }
case GRIB1_LTYPE_CLOUD_BASE: { zaxistype = ZAXIS_CLOUD_BASE; break; }
case GRIB1_LTYPE_CLOUD_TOP: { zaxistype = ZAXIS_CLOUD_TOP; break; }
case GRIB1_LTYPE_ISOTHERM0: { zaxistype = ZAXIS_ISOTHERM_ZERO; break; }
case GRIB1_LTYPE_TOA: { zaxistype = ZAXIS_TOA; break; }
case GRIB1_LTYPE_SEA_BOTTOM: { zaxistype = ZAXIS_SEA_BOTTOM; break; }
case GRIB1_LTYPE_ATMOSPHERE: { zaxistype = ZAXIS_ATMOSPHERE; break; }
case GRIB1_LTYPE_MEANSEA: { zaxistype = ZAXIS_MEANSEA; break; }
case GRIB1_LTYPE_SURFACE: zaxistype = ZAXIS_SURFACE; break;
case GRIB1_LTYPE_CLOUD_BASE: zaxistype = ZAXIS_CLOUD_BASE; break;
case GRIB1_LTYPE_CLOUD_TOP: zaxistype = ZAXIS_CLOUD_TOP; break;
case GRIB1_LTYPE_ISOTHERM0: zaxistype = ZAXIS_ISOTHERM_ZERO; break;
case GRIB1_LTYPE_TOA: zaxistype = ZAXIS_TOA; break;
case GRIB1_LTYPE_SEA_BOTTOM: zaxistype = ZAXIS_SEA_BOTTOM; break;
case GRIB1_LTYPE_ATMOSPHERE: zaxistype = ZAXIS_ATMOSPHERE; break;
case GRIB1_LTYPE_MEANSEA: zaxistype = ZAXIS_MEANSEA; break;
case GRIB1_LTYPE_99:
case GRIB1_LTYPE_ISOBARIC: { zaxistype = ZAXIS_PRESSURE; break; }
case GRIB1_LTYPE_HEIGHT: { zaxistype = ZAXIS_HEIGHT; break; }
case GRIB1_LTYPE_ALTITUDE: { zaxistype = ZAXIS_ALTITUDE; break; }
case GRIB1_LTYPE_ISOBARIC: zaxistype = ZAXIS_PRESSURE; break;
case GRIB1_LTYPE_HEIGHT: zaxistype = ZAXIS_HEIGHT; break;
case GRIB1_LTYPE_ALTITUDE: zaxistype = ZAXIS_ALTITUDE; break;
case GRIB1_LTYPE_SIGMA:
case GRIB1_LTYPE_SIGMA_LAYER: { zaxistype = ZAXIS_SIGMA; break; }
case GRIB1_LTYPE_SIGMA_LAYER: zaxistype = ZAXIS_SIGMA; break;
case GRIB1_LTYPE_HYBRID:
case GRIB1_LTYPE_HYBRID_LAYER: { zaxistype = ZAXIS_HYBRID; break; }
case GRIB1_LTYPE_HYBRID_LAYER: zaxistype = ZAXIS_HYBRID; break;
case GRIB1_LTYPE_LANDDEPTH:
case GRIB1_LTYPE_LANDDEPTH_LAYER: { zaxistype = ZAXIS_DEPTH_BELOW_LAND; break; }
case GRIB1_LTYPE_ISENTROPIC: { zaxistype = ZAXIS_ISENTROPIC; break; }
case GRIB1_LTYPE_SEADEPTH: { zaxistype = ZAXIS_DEPTH_BELOW_SEA; break; }
case GRIB1_LTYPE_LAKE_BOTTOM: { zaxistype = ZAXIS_LAKE_BOTTOM; break; }
case GRIB1_LTYPE_SEDIMENT_BOTTOM: { zaxistype = ZAXIS_SEDIMENT_BOTTOM; break; }
case GRIB1_LTYPE_SEDIMENT_BOTTOM_TA: { zaxistype = ZAXIS_SEDIMENT_BOTTOM_TA; break; }
case GRIB1_LTYPE_SEDIMENT_BOTTOM_TW: { zaxistype = ZAXIS_SEDIMENT_BOTTOM_TW; break; }
case GRIB1_LTYPE_MIX_LAYER: { zaxistype = ZAXIS_MIX_LAYER; break; }
case GRIB1_LTYPE_LANDDEPTH_LAYER: zaxistype = ZAXIS_DEPTH_BELOW_LAND; break;
case GRIB1_LTYPE_ISENTROPIC: zaxistype = ZAXIS_ISENTROPIC; break;
case GRIB1_LTYPE_SEADEPTH: zaxistype = ZAXIS_DEPTH_BELOW_SEA; break;
case GRIB1_LTYPE_LAKE_BOTTOM: zaxistype = ZAXIS_LAKE_BOTTOM; break;
case GRIB1_LTYPE_SEDIMENT_BOTTOM: zaxistype = ZAXIS_SEDIMENT_BOTTOM; break;
case GRIB1_LTYPE_SEDIMENT_BOTTOM_TA: zaxistype = ZAXIS_SEDIMENT_BOTTOM_TA; break;
case GRIB1_LTYPE_SEDIMENT_BOTTOM_TW: zaxistype = ZAXIS_SEDIMENT_BOTTOM_TW; break;
case GRIB1_LTYPE_MIX_LAYER: zaxistype = ZAXIS_MIX_LAYER; break;
}
return zaxistype;
......@@ -55,31 +55,31 @@ int grib2ltypeToZaxisType(int grib_ltype)
switch ( grib_ltype )
{
case GRIB2_LTYPE_SURFACE: { zaxistype = ZAXIS_SURFACE; break; }
case GRIB2_LTYPE_CLOUD_BASE: { zaxistype = ZAXIS_CLOUD_BASE; break; }
case GRIB2_LTYPE_CLOUD_TOP: { zaxistype = ZAXIS_CLOUD_TOP; break; }
case GRIB2_LTYPE_ISOTHERM0: { zaxistype = ZAXIS_ISOTHERM_ZERO; break; }
case GRIB2_LTYPE_TOA: { zaxistype = ZAXIS_TOA; break; }
case GRIB2_LTYPE_SEA_BOTTOM: { zaxistype = ZAXIS_SEA_BOTTOM; break; }
case GRIB2_LTYPE_ATMOSPHERE: { zaxistype = ZAXIS_ATMOSPHERE; break; }
case GRIB2_LTYPE_MEANSEA: { zaxistype = ZAXIS_MEANSEA; break; }
case GRIB2_LTYPE_ISOBARIC: { zaxistype = ZAXIS_PRESSURE; break; }
case GRIB2_LTYPE_HEIGHT: { zaxistype = ZAXIS_HEIGHT; break; }
case GRIB2_LTYPE_ALTITUDE: { zaxistype = ZAXIS_ALTITUDE; break; }
case GRIB2_LTYPE_SIGMA: { zaxistype = ZAXIS_SIGMA; break; }
case GRIB2_LTYPE_SURFACE: zaxistype = ZAXIS_SURFACE; break;
case GRIB2_LTYPE_CLOUD_BASE: zaxistype = ZAXIS_CLOUD_BASE; break;
case GRIB2_LTYPE_CLOUD_TOP: zaxistype = ZAXIS_CLOUD_TOP; break;
case GRIB2_LTYPE_ISOTHERM0: zaxistype = ZAXIS_ISOTHERM_ZERO; break;
case GRIB2_LTYPE_TOA: zaxistype = ZAXIS_TOA; break;
case GRIB2_LTYPE_SEA_BOTTOM: zaxistype = ZAXIS_SEA_BOTTOM; break;
case GRIB2_LTYPE_ATMOSPHERE: zaxistype = ZAXIS_ATMOSPHERE; break;
case GRIB2_LTYPE_MEANSEA: zaxistype = ZAXIS_MEANSEA; break;
case GRIB2_LTYPE_ISOBARIC: zaxistype = ZAXIS_PRESSURE; break;
case GRIB2_LTYPE_HEIGHT: zaxistype = ZAXIS_HEIGHT; break;
case GRIB2_LTYPE_ALTITUDE: zaxistype = ZAXIS_ALTITUDE; break;
case GRIB2_LTYPE_SIGMA: zaxistype = ZAXIS_SIGMA; break;
case GRIB2_LTYPE_HYBRID:
/* case GRIB2_LTYPE_HYBRID_LAYER: */ { zaxistype = ZAXIS_HYBRID; break; }
/* case GRIB2_LTYPE_HYBRID_LAYER: */ zaxistype = ZAXIS_HYBRID; break;
case GRIB2_LTYPE_LANDDEPTH:
/* case GRIB2_LTYPE_LANDDEPTH_LAYER: */ { zaxistype = ZAXIS_DEPTH_BELOW_LAND; break; }
case GRIB2_LTYPE_ISENTROPIC: { zaxistype = ZAXIS_ISENTROPIC; break; }
case GRIB2_LTYPE_SNOW: { zaxistype = ZAXIS_SNOW; break; }
case GRIB2_LTYPE_SEADEPTH: { zaxistype = ZAXIS_DEPTH_BELOW_SEA; break; }
case GRIB2_LTYPE_LAKE_BOTTOM: { zaxistype = ZAXIS_LAKE_BOTTOM; break; }
case GRIB2_LTYPE_SEDIMENT_BOTTOM: { zaxistype = ZAXIS_SEDIMENT_BOTTOM; break; }
case GRIB2_LTYPE_SEDIMENT_BOTTOM_TA: { zaxistype = ZAXIS_SEDIMENT_BOTTOM_TA; break; }
case GRIB2_LTYPE_SEDIMENT_BOTTOM_TW: { zaxistype = ZAXIS_SEDIMENT_BOTTOM_TW; break; }
case GRIB2_LTYPE_MIX_LAYER: { zaxistype = ZAXIS_MIX_LAYER; break; }
case GRIB2_LTYPE_REFERENCE: { zaxistype = ZAXIS_REFERENCE; break; }
/* case GRIB2_LTYPE_LANDDEPTH_LAYER: */ zaxistype = ZAXIS_DEPTH_BELOW_LAND; break;
case GRIB2_LTYPE_ISENTROPIC: zaxistype = ZAXIS_ISENTROPIC; break;
case GRIB2_LTYPE_SNOW: zaxistype = ZAXIS_SNOW; break;
case GRIB2_LTYPE_SEADEPTH: zaxistype = ZAXIS_DEPTH_BELOW_SEA; break;
case GRIB2_LTYPE_LAKE_BOTTOM: zaxistype = ZAXIS_LAKE_BOTTOM; break;
case GRIB2_LTYPE_SEDIMENT_BOTTOM: zaxistype = ZAXIS_SEDIMENT_BOTTOM; break;
case GRIB2_LTYPE_SEDIMENT_BOTTOM_TA: zaxistype = ZAXIS_SEDIMENT_BOTTOM_TA; break;
case GRIB2_LTYPE_SEDIMENT_BOTTOM_TW: zaxistype = ZAXIS_SEDIMENT_BOTTOM_TW; break;
case GRIB2_LTYPE_MIX_LAYER: zaxistype = ZAXIS_MIX_LAYER; break;
case GRIB2_LTYPE_REFERENCE: zaxistype = ZAXIS_REFERENCE; break;
}
return zaxistype;
......@@ -92,27 +92,27 @@ int zaxisTypeToGrib1ltype(int zaxistype)
switch (zaxistype)
{
case ZAXIS_SURFACE: { grib_ltype = GRIB1_LTYPE_SURFACE; break; }
case ZAXIS_MEANSEA: { grib_ltype = GRIB1_LTYPE_MEANSEA; break; }
case ZAXIS_HEIGHT: { grib_ltype = GRIB1_LTYPE_HEIGHT; break; }
case ZAXIS_ALTITUDE: { grib_ltype = GRIB1_LTYPE_ALTITUDE; break; }
case ZAXIS_SIGMA: { grib_ltype = GRIB1_LTYPE_SIGMA; break; }
case ZAXIS_DEPTH_BELOW_SEA: { grib_ltype = GRIB1_LTYPE_SEADEPTH; break; }
case ZAXIS_ISENTROPIC: { grib_ltype = GRIB1_LTYPE_ISENTROPIC; break; }
case ZAXIS_CLOUD_BASE: { grib_ltype = GRIB1_LTYPE_CLOUD_BASE; break; }
case ZAXIS_CLOUD_TOP: { grib_ltype = GRIB1_LTYPE_CLOUD_TOP; break; }
case ZAXIS_ISOTHERM_ZERO: { grib_ltype = GRIB1_LTYPE_ISOTHERM0; break; }
case ZAXIS_TOA: { grib_ltype = GRIB1_LTYPE_TOA; break; }
case ZAXIS_SEA_BOTTOM: { grib_ltype = GRIB1_LTYPE_SEA_BOTTOM; break; }
case ZAXIS_LAKE_BOTTOM: { grib_ltype = GRIB1_LTYPE_LAKE_BOTTOM; break; }
case ZAXIS_SEDIMENT_BOTTOM: { grib_ltype = GRIB1_LTYPE_SEDIMENT_BOTTOM; break; }
case ZAXIS_SEDIMENT_BOTTOM_TA: { grib_ltype = GRIB1_LTYPE_SEDIMENT_BOTTOM_TA; break; }
case ZAXIS_SEDIMENT_BOTTOM_TW: { grib_ltype = GRIB1_LTYPE_SEDIMENT_BOTTOM_TW; break; }
case ZAXIS_MIX_LAYER: { grib_ltype = GRIB1_LTYPE_MIX_LAYER; break; }
case ZAXIS_ATMOSPHERE: { grib_ltype = GRIB1_LTYPE_ATMOSPHERE; break; }
case ZAXIS_SURFACE: grib_ltype = GRIB1_LTYPE_SURFACE; break;
case ZAXIS_MEANSEA: grib_ltype = GRIB1_LTYPE_MEANSEA; break;
case ZAXIS_HEIGHT: grib_ltype = GRIB1_LTYPE_HEIGHT; break;
case ZAXIS_ALTITUDE: grib_ltype = GRIB1_LTYPE_ALTITUDE; break;
case ZAXIS_SIGMA: grib_ltype = GRIB1_LTYPE_SIGMA; break;
case ZAXIS_DEPTH_BELOW_SEA: grib_ltype = GRIB1_LTYPE_SEADEPTH; break;
case ZAXIS_ISENTROPIC: grib_ltype = GRIB1_LTYPE_ISENTROPIC; break;
case ZAXIS_CLOUD_BASE: grib_ltype = GRIB1_LTYPE_CLOUD_BASE; break;
case ZAXIS_CLOUD_TOP: grib_ltype = GRIB1_LTYPE_CLOUD_TOP; break;
case ZAXIS_ISOTHERM_ZERO: grib_ltype = GRIB1_LTYPE_ISOTHERM0; break;
case ZAXIS_TOA: grib_ltype = GRIB1_LTYPE_TOA; break;
case ZAXIS_SEA_BOTTOM: grib_ltype = GRIB1_LTYPE_SEA_BOTTOM; break;
case ZAXIS_LAKE_BOTTOM: grib_ltype = GRIB1_LTYPE_LAKE_BOTTOM; break;
case ZAXIS_SEDIMENT_BOTTOM: grib_ltype = GRIB1_LTYPE_SEDIMENT_BOTTOM; break;
case ZAXIS_SEDIMENT_BOTTOM_TA: grib_ltype = GRIB1_LTYPE_SEDIMENT_BOTTOM_TA; break;
case ZAXIS_SEDIMENT_BOTTOM_TW: grib_ltype = GRIB1_LTYPE_SEDIMENT_BOTTOM_TW; break;
case ZAXIS_MIX_LAYER: grib_ltype = GRIB1_LTYPE_MIX_LAYER; break;
case ZAXIS_ATMOSPHERE: grib_ltype = GRIB1_LTYPE_ATMOSPHERE; break;
}
return (grib_ltype);
return grib_ltype;
}
......@@ -122,24 +122,24 @@ int zaxisTypeToGrib2ltype(int zaxistype)
switch (zaxistype)
{
case ZAXIS_SURFACE: { grib_ltype = GRIB2_LTYPE_SURFACE; break; }
case ZAXIS_MEANSEA: { grib_ltype = GRIB2_LTYPE_MEANSEA; break; }
case ZAXIS_HEIGHT: { grib_ltype = GRIB2_LTYPE_HEIGHT; break; }
case ZAXIS_ALTITUDE: { grib_ltype = GRIB2_LTYPE_ALTITUDE; break; }
case ZAXIS_SIGMA: { grib_ltype = GRIB2_LTYPE_SIGMA; break; }
case ZAXIS_DEPTH_BELOW_SEA: { grib_ltype = GRIB2_LTYPE_SEADEPTH; break; }
case ZAXIS_ISENTROPIC: { grib_ltype = GRIB2_LTYPE_ISENTROPIC; break; }
case ZAXIS_CLOUD_BASE: { grib_ltype = GRIB2_LTYPE_CLOUD_BASE; break; }
case ZAXIS_CLOUD_TOP: { grib_ltype = GRIB2_LTYPE_CLOUD_TOP; break; }
case ZAXIS_ISOTHERM_ZERO: { grib_ltype = GRIB2_LTYPE_ISOTHERM0; break; }
case ZAXIS_TOA: { grib_ltype = GRIB2_LTYPE_TOA; break; }
case ZAXIS_SEA_BOTTOM: { grib_ltype = GRIB2_LTYPE_SEA_BOTTOM; break; }
case ZAXIS_LAKE_BOTTOM: { grib_ltype = GRIB2_LTYPE_LAKE_BOTTOM; break; }
case ZAXIS_SEDIMENT_BOTTOM: { grib_ltype = GRIB2_LTYPE_SEDIMENT_BOTTOM; break; }
case ZAXIS_SEDIMENT_BOTTOM_TA: { grib_ltype = GRIB2_LTYPE_SEDIMENT_BOTTOM_TA; break; }
case ZAXIS_SEDIMENT_BOTTOM_TW: { grib_ltype = GRIB2_LTYPE_SEDIMENT_BOTTOM_TW; break; }
case ZAXIS_MIX_LAYER: { grib_ltype = GRIB2_LTYPE_MIX_LAYER; break; }
case ZAXIS_ATMOSPHERE: { grib_ltype = GRIB2_LTYPE_ATMOSPHERE; break; }
case ZAXIS_SURFACE: grib_ltype = GRIB2_LTYPE_SURFACE; break;
case ZAXIS_MEANSEA: grib_ltype = GRIB2_LTYPE_MEANSEA; break;
case ZAXIS_HEIGHT: grib_ltype = GRIB2_LTYPE_HEIGHT; break;
case ZAXIS_ALTITUDE: grib_ltype = GRIB2_LTYPE_ALTITUDE; break;
case ZAXIS_SIGMA: grib_ltype = GRIB2_LTYPE_SIGMA; break;
case ZAXIS_DEPTH_BELOW_SEA: grib_ltype = GRIB2_LTYPE_SEADEPTH; break;
case ZAXIS_ISENTROPIC: grib_ltype = GRIB2_LTYPE_ISENTROPIC; break;
case ZAXIS_CLOUD_BASE: grib_ltype = GRIB2_LTYPE_CLOUD_BASE; break;
case ZAXIS_CLOUD_TOP: grib_ltype = GRIB2_LTYPE_CLOUD_TOP; break;
case ZAXIS_ISOTHERM_ZERO: grib_ltype = GRIB2_LTYPE_ISOTHERM0; break;
case ZAXIS_TOA: grib_ltype = GRIB2_LTYPE_TOA; break;
case ZAXIS_SEA_BOTTOM: grib_ltype = GRIB2_LTYPE_SEA_BOTTOM; break;
case ZAXIS_LAKE_BOTTOM: grib_ltype = GRIB2_LTYPE_LAKE_BOTTOM; break;
case ZAXIS_SEDIMENT_BOTTOM: grib_ltype = GRIB2_LTYPE_SEDIMENT_BOTTOM; break;
case ZAXIS_SEDIMENT_BOTTOM_TA: grib_ltype = GRIB2_LTYPE_SEDIMENT_BOTTOM_TA; break;
case ZAXIS_SEDIMENT_BOTTOM_TW: grib_ltype = GRIB2_LTYPE_SEDIMENT_BOTTOM_TW; break;
case ZAXIS_MIX_LAYER: grib_ltype = GRIB2_LTYPE_MIX_LAYER; break;
case ZAXIS_ATMOSPHERE: grib_ltype = GRIB2_LTYPE_ATMOSPHERE; break;
}
return grib_ltype;
......
......@@ -2289,7 +2289,26 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
case ZAXIS_DEPTH_BELOW_SEA:
case ZAXIS_ISENTROPIC:
{
if ( editionNumber <= 1 )
if ( zaxistype == ZAXIS_HEIGHT )
{
double sf = 1;
char units[128];
zaxisInqUnits(zaxisID, units);
if ( units[1] == 'm' && !units[2] )
{
if ( units[0] == 'c' ) sf = 0.01;
else if ( units[0] == 'd' ) sf = 0.1;
else if ( units[0] == 'k' ) sf = 1000;
}
if ( IS_NOT_EQUAL(sf, 1) )
{
level *= sf;
dlevel1 *= sf;
dlevel2 *= sf;
}
}
if ( editionNumber <= 1 )
{
gribapiDefLevelType(gh, gcinit, "indicatorOfTypeOfLevel", zaxisTypeToGrib1ltype(zaxistype));
GRIB_CHECK(my_grib_set_long(gh, "level", (long)level), 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment