Skip to content
Snippets Groups Projects
Commit 55515986 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

setctomiss: added inf branch

parent 95d8ef7a
No related branches found
No related tags found
1 merge request!256M214003/develop
......@@ -54,7 +54,7 @@ set_const_to_miss(size_t gridsize, Varray<T> &array, double _missval, double _rc
T missval = _missval;
T rconst = _rconst;
size_t numMissVals = 0;
if (std::isnan(rconst))
if (std::isnan(_rconst))
{
for (size_t i = 0; i < gridsize; ++i)
if (std::isnan(array[i]))
......@@ -63,6 +63,15 @@ set_const_to_miss(size_t gridsize, Varray<T> &array, double _missval, double _rc
numMissVals++;
}
}
else if (std::isinf(_rconst))
{
for (size_t i = 0; i < gridsize; ++i)
if (std::isinf(array[i]))
{
array[i] = missval;
numMissVals++;
}
}
else
{
for (size_t i = 0; i < gridsize; ++i)
......@@ -181,7 +190,7 @@ public:
double rconst = 0.0;
double rmin = 0.0;
double rmax = 0.0;
double new_missval = 0.0;
double newMissval = 0.0;
public:
void
......@@ -198,7 +207,7 @@ public:
if (operatorID == SETMISSVAL)
{
operator_check_argc(1);
new_missval = parameter_to_double(cdo_operator_argv(0));
newMissval = parameter_to_double(cdo_operator_argv(0));
}
else if (operatorID == SETCTOMISS || operatorID == SETMISSTOC)
{
......@@ -226,7 +235,7 @@ public:
if (operatorID == SETMISSVAL)
{
auto nvars = vlistNvars(vlistID2);
for (int varID = 0; varID < nvars; ++varID) vlistDefVarMissval(vlistID2, varID, new_missval);
for (int varID = 0; varID < nvars; ++varID) vlistDefVarMissval(vlistID2, varID, newMissval);
}
else if (operatorID == SETMISSTOC)
{
......@@ -280,7 +289,7 @@ public:
cdo_read_record(streamID1, field);
// clang-format off
if (operatorID == SETMISSVAL) set_missval(field, new_missval);
if (operatorID == SETMISSVAL) set_missval(field, newMissval);
else if (operatorID == SETCTOMISS) set_const_to_miss(field, rconst);
else if (operatorID == SETMISSTOC) set_miss_to_const(field, rconst);
else if (operatorID == SETRTOMISS) set_range_to_miss(field, rmin, rmax);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment