Commit 9c324920 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added support for level type ZAXIS_TOA, ZAXIS_SEA_BOTTOM, ZAXIS_ATMOSPHERE (netCDF)

parent 6b6cbbb3
2011-10-06 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added level type ZAXIS_NOMINAL_TOP, ZAXIS_SEA_BOTTOM, ZAXIS_ATMOSPHERE [request: Drte Liermann]
* added level type ZAXIS_TOA, ZAXIS_SEA_BOTTOM, ZAXIS_ATMOSPHERE [request: Drte Liermann]
2011-10-05 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
......@@ -4,7 +4,7 @@ CDI NEWS
Version 1.5.3 (?? October 2011):
New features:
* Added support for level type ZAXIS_NOMINAL_TOP, ZAXIS_SEA_BOTTOM, ZAXIS_ATMOSPHERE
* Added support for level type ZAXIS_TOA, ZAXIS_SEA_BOTTOM, ZAXIS_ATMOSPHERE
Fixed bugs:
* deflate compression with netCDF4 doesn't work
......
......@@ -147,7 +147,7 @@ extern "C" {
#define ZAXIS_ALTITUDE 10 /* Altitude above mean sea level in meters */
#define ZAXIS_SIGMA 11 /* Sigma level */
#define ZAXIS_MEANSEA 12 /* Mean sea level */
#define ZAXIS_NOMINAL_TOP 13 /* Norminal top of atmosphere */
#define ZAXIS_TOA 13 /* Norminal top of atmosphere */
#define ZAXIS_SEA_BOTTOM 14 /* Sea bottom */
#define ZAXIS_ATMOSPHERE 15 /* Entire atmosphere */
......
......@@ -8,7 +8,7 @@
/* GRIB1 Level Types */
#define GRIB1_LTYPE_SURFACE 1
#define GRIB1_LTYPE_NOMINAL_TOP 8
#define GRIB1_LTYPE_TOA 8
#define GRIB1_LTYPE_SEA_BOTTOM 9
#define GRIB1_LTYPE_ATMOSPHERE 10
#define GRIB1_LTYPE_99 99
......
......@@ -5,7 +5,7 @@
/* GRIB2 Level Types */
#define GRIB2_LTYPE_SURFACE 1
#define GRIB2_LTYPE_NOMINAL_TOP 8
#define GRIB2_LTYPE_TOA 8
#define GRIB2_LTYPE_SEA_BOTTOM 9
#define GRIB2_LTYPE_ATMOSPHERE 10
#define GRIB2_LTYPE_ISOBARIC 100
......
......@@ -2217,8 +2217,11 @@ void cdfDefZaxis(int streamID, int zaxisID)
dimlen = zaxisInqSize(zaxisID);
type = zaxisInqType(zaxisID);
if ( dimlen == 1 && type == ZAXIS_SURFACE ) return;
if ( dimlen == 1 && type == ZAXIS_MEANSEA ) return;
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;
zaxisInqName(zaxisID, axisname);
/*
......@@ -2328,7 +2331,7 @@ void cdfDefZaxis(int streamID, int zaxisID)
cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
strcpy(tmpname, "ap: hyai b: hybi ps: aps");
cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
cdf_enddef(fileID);
streamptr->ncmode = 2;
......@@ -2377,8 +2380,8 @@ void cdfDefZaxis(int streamID, int zaxisID)
}
cdf_put_att_text(fileID, ncvarid, "axis", 1, "Z");
if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
{
if ( nc_inq_dimid(fileID, "nb2", &nvdimID) != NC_NOERR )
cdf_def_dim(fileID, "nb2", nvertex, &nvdimID);
......@@ -2397,7 +2400,7 @@ void cdfDefZaxis(int streamID, int zaxisID)
streamptr->ncmode = 2;
cdf_put_var_double(fileID, ncvarid, zaxisInqLevelsPtr(zaxisID));
if ( ncbvarid != UNDEFID )
{
int i;
......@@ -3049,6 +3052,17 @@ int cdfDefVar(int streamID, int varID)
if ( vlistInqVarMissvalUsed(vlistID, varID) )
cdfDefVarMissval(streamID, varID, vlistInqVarDatatype(vlistID, varID), 0);
if ( zid == -1 )
{
if ( zaxisInqType(zaxisID) == ZAXIS_TOA ||
zaxisInqType(zaxisID) == ZAXIS_SEA_BOTTOM ||
zaxisInqType(zaxisID) == ZAXIS_ATMOSPHERE )
{
zaxisInqName(zaxisID, varname);
cdf_put_att_text(fileID, ncvarid, "level_type", strlen(varname), varname);
}
}
/* Attributes */
defineAttributes(vlistID, varID, fileID, ncvarid);
......@@ -4385,7 +4399,30 @@ void scanVarAttributes(int fileID, int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
if ( warn )
{
warn = FALSE;
Warning("Gridtype %s unsupported!", attstring);
Warning("Grid type %s unsupported!", attstring);
}
}
cdfSetVar(ncvars, ncvarid, TRUE);
}
else if ( strcmp(attname, "level_type") == 0 && atttype == NC_CHAR )
{
cdfGetAttText(fileID, ncvarid, attname, attstringlen-1, attstring);
strtolower(attstring);
if ( strcmp(attstring, "toa") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_TOA;
else if ( strcmp(attstring, "seabottom") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_SEA_BOTTOM;
else if ( strcmp(attstring, "atmosphere") == 0 )
ncvars[ncvarid].zaxistype = ZAXIS_ATMOSPHERE;
else
{
static int warn = TRUE;
if ( warn )
{
warn = FALSE;
Warning("Grid type %s unsupported!", attstring);
}
}
......@@ -5636,7 +5673,11 @@ void define_all_zaxes(stream_t *streamptr, int fileID, int vlistID, ncdim_t *ncd
if ( zsize == 1 )
{
zaxisType = ZAXIS_SURFACE;
if ( ncvars[ncvarid].zaxistype != UNDEFID )
zaxisType = ncvars[ncvarid].zaxistype;
else
zaxisType = ZAXIS_SURFACE;
zvar[0] = 0;
/*
if ( zdimid == UNDEFID )
......
......@@ -1919,9 +1919,9 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
ISEC1_Level2 = 0;
break;
}
case ZAXIS_NOMINAL_TOP:
case ZAXIS_TOA:
{
ISEC1_LevelType = GRIB1_LTYPE_NOMINAL_TOP;
ISEC1_LevelType = GRIB1_LTYPE_TOA;
ISEC1_Level1 = 0;
ISEC1_Level2 = 0;
break;
......
......@@ -23,7 +23,7 @@ int grib1ltypeToZaxisType(int grib_ltype)
switch ( grib_ltype )
{
case GRIB1_LTYPE_SURFACE: { zaxistype = ZAXIS_SURFACE; break; }
case GRIB1_LTYPE_NOMINAL_TOP: { zaxistype = ZAXIS_NOMINAL_TOP; 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; }
......@@ -51,7 +51,7 @@ int grib2ltypeToZaxisType(int grib_ltype)
switch ( grib_ltype )
{
case GRIB2_LTYPE_SURFACE: { zaxistype = ZAXIS_SURFACE; break; }
case GRIB2_LTYPE_NOMINAL_TOP: { zaxistype = ZAXIS_NOMINAL_TOP; 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; }
......
......@@ -2344,12 +2344,12 @@ void gribapiDefLevel(grib_handle *gh, int param, int zaxisID, int levelID)
GRIB_CHECK(grib_set_long(gh, "level", (long) zaxisInqLevel(zaxisID, levelID)), 0);
break;
}
case ZAXIS_NOMINAL_TOP:
case ZAXIS_TOA:
{
if ( editionNumber <= 1 )
GRIB_CHECK(grib_set_long(gh, "indicatorOfTypeOfLevel", GRIB1_LTYPE_NOMINAL_TOP), 0);
GRIB_CHECK(grib_set_long(gh, "indicatorOfTypeOfLevel", GRIB1_LTYPE_TOA), 0);
else
GRIB_CHECK(grib_set_long(gh, "typeOfFirstFixedSurface", GRIB2_LTYPE_NOMINAL_TOP), 0);
GRIB_CHECK(grib_set_long(gh, "typeOfFirstFixedSurface", GRIB2_LTYPE_TOA), 0);
break;
}
case ZAXIS_SEA_BOTTOM:
......
......@@ -37,7 +37,7 @@ ZaxistypeEntry[] = {
{ /* 10 */ 1, "alt", "altitude", "", "m"},
{ /* 11 */ 0, "lev", "sigma", "", "level"},
{ /* 12 */ 0, "lev", "meansea", "", "level"},
{ /* 13 */ 0, "toa", "nominal_top", "", ""},
{ /* 13 */ 0, "toa", "top_of_atmosphere", "", ""},
{ /* 14 */ 0, "seabottom", "sea_bottom", "", ""},
{ /* 15 */ 0, "atmosphere", "atmosphere", "", ""},
};
......
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