Commit 3f760564 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

proj_inv_xyvals: check result for NaNs.

parent fcc7af99
Pipeline #5661 passed with stages
in 14 minutes and 43 seconds
......@@ -5,6 +5,8 @@ Improvement
Version 1.9.10 (29 January 2021):
New features:
* Added option --ignore_time_bounds to ignore time bounds for time range statistics
Fixed bugs:
* timselmean: failed with variables on different grids [Bug #9978]
* Ymonarith: failed with variables on different grids
......
......@@ -73,29 +73,36 @@ gen_param(const char *fmt, ...)
static void
proj_fwd_xyvals(PJ *proj, size_t nvals, double *xvals, double *yvals)
{
size_t num_nans = 0;
PJ_COORD p;
for (size_t i = 0; i < nvals; i++)
{
p.uv.u = proj_torad(xvals[i]);
p.uv.v = proj_torad(yvals[i]);
p = proj_trans(proj, PJ_FWD, p);
if (std::isnan(p.uv.u) || std::isnan(p.uv.v)) num_nans++;
xvals[i] = p.uv.u;
yvals[i] = p.uv.v;
}
if (num_nans) cdoWarning("%s: %zu of %zu projection coodinates are NaN!", __func__, num_nans, 2*nvals);
}
static void
proj_inv_xyvals(PJ *proj, size_t nvals, double *xvals, double *yvals)
{
size_t num_nans = 0;
PJ_COORD p;
for (size_t i = 0; i < nvals; i++)
{
p.uv.u = xvals[i];
p.uv.v = yvals[i];
p = proj_trans(proj, PJ_INV, p);
if (std::isnan(p.uv.u) || std::isnan(p.uv.v)) num_nans++;
xvals[i] = proj_todeg(p.uv.u);
yvals[i] = proj_todeg(p.uv.v);
}
if (num_nans) cdoWarning("%s: %zu of %zu projection coodinates are NaN!", __func__, num_nans, 2*nvals);
}
static int
......
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