Commit a98a16d5 authored by Marc R.'s avatar Marc R.

improved error output in NetCDF climateforecast reader; added units to...

improved error output in NetCDF climateforecast reader; added units to recognize vertical geometric height coordinate
parent aa6baac9
This diff is collapsed.
......@@ -428,11 +428,45 @@ NcVar NcCFVar::getVerticalCoordinateGeometricHeight()
{
// The vertical z coordinate is identifyable by units of geometric height,
// cf. http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html#vertical-coordinate
vector<string> units = {"m", "metre"};
vector<string> units = {"m", "metre", "metres", "meter", "meters"};
return getCFCoordinateVar(units, {""}, true);
}
QSet<QString> NcCFVar::validUnitsVerticalCoordinate(
NcCFVar::NcVariableGridType gridType)
{
switch (gridType)
{
case LAT_LON_P:
return QSet<QString>() << "Pa" << "hPa";
break;
case LAT_LON_PVU:
return QSet<QString>() << "10-6Km2/kgs";
break;
case LAT_LON_Z:
return QSet<QString>() << "m" << "metre" << "metres" << "meter"
<< "meters";
break;
default:
return QSet<QString>();
break;
}
}
QString NcCFVar::validUnitsVerticalCoordinateAsString(
NcCFVar::NcVariableGridType gridType)
{
QString str = "";
for (QString unit : validUnitsVerticalCoordinate(gridType))
{
str += QString("%1/").arg(unit);
}
return str;
}
bool NcCFVar::hasEnsembleDimension()
{
try
......@@ -947,6 +981,32 @@ bool NcCFVar::getRotatedNorthPoleCoordinates(const NcVar& gridMappingVar,
}
QString NcCFVar::ncVariableGridTypeToString(NcCFVar::NcVariableGridType type)
{
switch (type)
{
case UNDEFINED:
return QString("WARNING: undefined, grid type could not be detected");
case ALL:
return QString("generic grid");
case LAT_LON:
return QString("regular 2D lat/lon grid");
case LAT_LON_P:
return QString("regular lat/lon grid with pressure levels");
case LAT_LON_HYBRID:
return QString("regular lat/lon grid with hybrid model levels");
case LAT_LON_PVU:
return QString("regular lat/lon grid with PV levels");
case LAT_LON_Z:
return QString("regular lat/lon grid with geometric height levels");
case LAT_LON_AUXP3D:
return QString("regular lat/lon grid with auxiliary 3D pressure field");
default:
return QString("ERROR: no valid grid type");
}
}
/******************************************************************************
*** PRIVATE METHODS ***
*******************************************************************************/
......
......@@ -196,6 +196,10 @@ public:
*/
NcVar getVerticalCoordinateGeometricHeight();
static QSet<QString> validUnitsVerticalCoordinate(NcVariableGridType gridType);
static QString validUnitsVerticalCoordinateAsString(NcVariableGridType gridType);
/**
Returns TRUE if this CF variable has an ensemble dimension.
*/
......@@ -311,6 +315,12 @@ public:
float *rotatedNorthPoleLon,
float *rotatedNorthPoleLat);
/**
Static function that converts an @ref NcVariableGridType enum to
a string.
*/
static QString ncVariableGridTypeToString(NcVariableGridType type);
private:
/**
Parses the CF time units string @p units and extracts the encoded base
......
......@@ -77,8 +77,18 @@ MStructuredGrid* MWeatherPredictionReader::produceData(MDataRequest request)
levtype = SURFACE_2D;
}
MStructuredGrid* result = readGrid(levtype, variable, initTime,
validTime, member);
MStructuredGrid* result = nullptr;
try
{
result = readGrid(levtype, variable, initTime, validTime, member);
}
catch (const std::exception& e)
{
LOG4CPLUS_ERROR(mlog, "ERROR: failed to read variable data from file "
"-- " << e.what());
result = nullptr;
}
if (result == nullptr)
{
// For some reason (invalid datafield requested, file corrupt) no
......
......@@ -1388,7 +1388,7 @@ QString MNWPActorVariable::debugOutputAsString()
str += QString("Entries in the queue of pending requests:\n");
for (int i = 0; i < pendingRequestsQueue.size(); i++)
{
str += QString(" ++ entry #%1: available=%2, request=%2").arg(i)
str += QString(" ++ entry #%1: available=%2, request=%3\n").arg(i)
.arg(pendingRequestsQueue[i].available)
.arg(pendingRequestsQueue[i].request);
}
......@@ -1704,6 +1704,15 @@ void MNWPActorVariable::asynchronousDataAvailable(MDataRequest request)
// Acquire the new ones.
grid = dataSource->getData(processRequest);
if (grid == nullptr)
{
//TODO (29Aug2018, mr) -- how should we handle errors in the pipeline that
// lead to a nullptr instead of a valid grid being returned?
LOG4CPLUS_ERROR(mlog, "FATAL ERROR: something went wrong "
"in the data pipeline -- no grid data available "
"... don't know what to do.");
}
textureDataField = grid->getTexture();
textureLonLatLevAxes = grid->getLonLatLevTexture();
......
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