Commit bb7499b3 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added support for level type CLOUD_BASE, CLOUD_TOP and ISOTHERM_ZERO

parent 2347c51a
......@@ -5,6 +5,7 @@
2013-03-12 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Added support for level type CLOUD_BASE, CLOUD_TOP and ISOTHERM_ZERO [Feature #3247]
* stream_gribapi: changed units for level type GRIB2_LTYPE_LANDDEPTH to m (internally mm) [Bug #3287]
* gribapiGetGrid: get gridDescriptionFile with grib_get_string() instead of grib_get_bytes() (bug fix)
......
......@@ -155,7 +155,10 @@ extern "C" {
#define ZAXIS_TOA 13 /* Norminal top of atmosphere */
#define ZAXIS_SEA_BOTTOM 14 /* Sea bottom */
#define ZAXIS_ATMOSPHERE 15 /* Entire atmosphere */
#define ZAXIS_REFERENCE 16 /* zaxis reference number */
#define ZAXIS_CLOUD_BASE 16 /* */
#define ZAXIS_CLOUD_TOP 17 /* */
#define ZAXIS_ISOTHERM_ZERO 18 /* */
#define ZAXIS_REFERENCE 19 /* zaxis reference number */
/* TIME types */
......
......@@ -8,6 +8,9 @@
/* GRIB1 Level Types */
#define GRIB1_LTYPE_SURFACE 1
#define GRIB1_LTYPE_CLOUDBASE 2
#define GRIB1_LTYPE_CLOUDTOP 3
#define GRIB1_LTYPE_ISOTHERM0 4
#define GRIB1_LTYPE_TOA 8
#define GRIB1_LTYPE_SEA_BOTTOM 9
#define GRIB1_LTYPE_ATMOSPHERE 10
......
......@@ -5,6 +5,9 @@
/* GRIB2 Level Types */
#define GRIB2_LTYPE_SURFACE 1
#define GRIB2_LTYPE_CLOUDBASE 2
#define GRIB2_LTYPE_CLOUDTOP 3
#define GRIB2_LTYPE_ISOTHERM0 4
#define GRIB2_LTYPE_TOA 8
#define GRIB2_LTYPE_SEA_BOTTOM 9
#define GRIB2_LTYPE_ATMOSPHERE 10
......
......@@ -2177,11 +2177,14 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
dimlen = zaxisInqSize(zaxisID);
type = zaxisInqType(zaxisID);
if ( dimlen == 1 && type == ZAXIS_SURFACE ) return;
if ( dimlen == 1 && type == ZAXIS_TOA ) return;
if ( dimlen == 1 && type == ZAXIS_SEA_BOTTOM ) return;
if ( dimlen == 1 && type == ZAXIS_ATMOSPHERE ) return;
if ( dimlen == 1 && type == ZAXIS_MEANSEA ) return;
if ( dimlen == 1 && type == ZAXIS_SURFACE ) return;
if ( dimlen == 1 && type == ZAXIS_CLOUD_BASE ) return;
if ( dimlen == 1 && type == ZAXIS_CLOUD_TOP ) return;
if ( dimlen == 1 && type == ZAXIS_ISOTHERM_ZERO ) return;
if ( dimlen == 1 && type == ZAXIS_TOA ) return;
if ( dimlen == 1 && type == ZAXIS_SEA_BOTTOM ) return;
if ( dimlen == 1 && type == ZAXIS_ATMOSPHERE ) return;
if ( dimlen == 1 && type == ZAXIS_MEANSEA ) return;
zaxisInqName(zaxisID, axisname);
/*
......@@ -3062,8 +3065,11 @@ int cdfDefVar(stream_t *streamptr, int varID)
if ( zid == -1 )
{
if ( zaxisInqType(zaxisID) == ZAXIS_TOA ||
zaxisInqType(zaxisID) == ZAXIS_SEA_BOTTOM ||
if ( zaxisInqType(zaxisID) == ZAXIS_CLOUD_BASE ||
zaxisInqType(zaxisID) == ZAXIS_CLOUD_TOP ||
zaxisInqType(zaxisID) == ZAXIS_ISOTHERM_ZERO ||
zaxisInqType(zaxisID) == ZAXIS_TOA ||
zaxisInqType(zaxisID) == ZAXIS_SEA_BOTTOM ||
zaxisInqType(zaxisID) == ZAXIS_ATMOSPHERE )
{
zaxisInqName(zaxisID, varname);
......@@ -3071,12 +3077,11 @@ int cdfDefVar(stream_t *streamptr, int varID)
}
}
if( vlistInqVarEnsemble( vlistID, varID, &ensID, &ensCount, &forecast_type ) )
if ( vlistInqVarEnsemble( vlistID, varID, &ensID, &ensCount, &forecast_type ) )
{
/* void cdf_put_att_int( int ncid, int varid, const char *name, nc_type xtype,
size_t len, const int *ip )
*/
cdf_put_att_int(fileID, ncvarid, "realization", NC_INT, 1, &ensID);
cdf_put_att_int(fileID, ncvarid, "ensemble_members", NC_INT, 1, &ensCount);
cdf_put_att_int(fileID, ncvarid, "forecast_init_type", NC_INT, 1, &forecast_type);
......@@ -4542,6 +4547,12 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
if ( strcmp(attstring, "toa") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_TOA;
else if ( strcmp(attstring, "cloudbase") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_CLOUD_BASE;
else if ( strcmp(attstring, "cloudtop") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_CLOUD_TOP;
else if ( strcmp(attstring, "isotherm0") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_ISOTHERM_ZERO;
else if ( strcmp(attstring, "seabottom") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_SEA_BOTTOM;
else if ( strcmp(attstring, "atmosphere") == 0 )
......@@ -5966,7 +5977,7 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
Message("zaxisID %d %d %s", ncvars[ncvarid].zaxisID, ncvarid, ncvars[ncvarid].name);
for ( ncvarid2 = ncvarid+1; ncvarid2 < nvars; ncvarid2++ )
if ( ncvars[ncvarid2].isvar == TRUE && ncvars[ncvarid2].zaxisID == UNDEFID )
if ( ncvars[ncvarid2].isvar == TRUE && ncvars[ncvarid2].zaxisID == UNDEFID && ncvars[ncvarid2].zaxistype == UNDEFID )
{
int zdimid2 = -1;
ndims = ncvars[ncvarid2].ndims;
......
......@@ -26,23 +26,26 @@ int grib1ltypeToZaxisType(int grib_ltype)
switch ( grib_ltype )
{
case GRIB1_LTYPE_SURFACE: { zaxistype = ZAXIS_SURFACE; 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_CLOUDBASE: { zaxistype = ZAXIS_CLOUD_BASE; break; }
case GRIB1_LTYPE_CLOUDTOP: { 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_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; }
}
return (zaxistype);
......@@ -56,6 +59,9 @@ int grib2ltypeToZaxisType(int grib_ltype)
switch ( grib_ltype )
{
case GRIB2_LTYPE_SURFACE: { zaxistype = ZAXIS_SURFACE; break; }
case GRIB2_LTYPE_CLOUDBASE: { zaxistype = ZAXIS_CLOUD_BASE; break; }
case GRIB2_LTYPE_CLOUDTOP: { 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; }
......
......@@ -2568,8 +2568,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
if ( zaxistype == ZAXIS_GENERIC && ltype == 0 )
{
Message("Changed zaxis type from %s to %s",
zaxisNamePtr(zaxistype),
zaxisNamePtr(ZAXIS_PRESSURE));
zaxisNamePtr(zaxistype), zaxisNamePtr(ZAXIS_PRESSURE));
zaxistype = ZAXIS_PRESSURE;
zaxisChangeType(zaxisID, zaxistype);
zaxisDefUnits(zaxisID, "Pa");
......@@ -2592,6 +2591,45 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
break;
}
case ZAXIS_CLOUD_BASE:
{
if ( editionNumber <= 1 )
{
if ( !gcinit ) GRIB_CHECK(grib_set_long(gh, "indicatorOfTypeOfLevel", GRIB1_LTYPE_CLOUDBASE), 0);
}
else
{
if ( !gcinit ) GRIB_CHECK(grib_set_long(gh, "typeOfFirstFixedSurface", GRIB2_LTYPE_CLOUDBASE), 0);
}
break;
}
case ZAXIS_CLOUD_TOP:
{
if ( editionNumber <= 1 )
{
if ( !gcinit ) GRIB_CHECK(grib_set_long(gh, "indicatorOfTypeOfLevel", GRIB1_LTYPE_CLOUDTOP), 0);
}
else
{
if ( !gcinit ) GRIB_CHECK(grib_set_long(gh, "typeOfFirstFixedSurface", GRIB2_LTYPE_CLOUDTOP), 0);
}
break;
}
case ZAXIS_ISOTHERM_ZERO:
{
if ( editionNumber <= 1 )
{
if ( !gcinit ) GRIB_CHECK(grib_set_long(gh, "indicatorOfTypeOfLevel", GRIB1_LTYPE_ISOTHERM0), 0);
}
else
{
if ( !gcinit ) GRIB_CHECK(grib_set_long(gh, "typeOfFirstFixedSurface", GRIB2_LTYPE_ISOTHERM0), 0);
}
break;
}
case ZAXIS_TOA:
{
if ( editionNumber <= 1 )
......
......@@ -44,7 +44,10 @@ ZaxistypeEntry[] = {
{ /* 13 */ 0, "toa", "top_of_atmosphere", "", ""},
{ /* 14 */ 0, "seabottom", "sea_bottom", "", ""},
{ /* 15 */ 0, "atmosphere", "atmosphere", "", ""},
{ /* 16 */ 0, "height", "generalized height","height", "m"},
{ /* 16 */ 0, "cloudbase", "cloud_base", "", ""},
{ /* 17 */ 0, "cloudtop", "cloud_top", "", ""},
{ /* 18 */ 0, "isotherm0", "isotherm_zero", "", ""},
{ /* 19 */ 0, "height", "generalized height","height", "m"},
};
static int CDI_MaxZaxistype = sizeof(ZaxistypeEntry) / sizeof(ZaxistypeEntry[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