Commit 631cd2be authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gridToUnstructured: added support for GRID_GAUSSIAN_REDUCED.

parent 9cb0a2c6
......@@ -1391,75 +1391,83 @@ gridToUnstructured(int gridID1, int lbounds)
gridDefNvertex(gridID2, 4);
const size_t ny = gridInqYsize(gridID1);
std::vector<int> rowlon(ny);
const size_t nlat = gridInqYsize(gridID1);
std::vector<int> rowlon(nlat);
gridInqRowlon(gridID1, rowlon.data());
gridDefXsize(gridID2, gridsize);
gridDefYsize(gridID2, gridsize);
if (!(gridsize == gridInqXvals(gridID1, nullptr) && ny == gridInqYvals(gridID1, nullptr)))
if (!(gridsize == gridInqXvals(gridID1, nullptr) && nlat == gridInqYvals(gridID1, nullptr)))
cdoAbort("%s: grid coordinates missing!", gridNamePtr(gridtype));
std::vector<double> xvals(gridsize), yvals(ny);
std::vector<double> xvals(gridsize);
{
std::vector<double> yvals2D(gridsize);
std::vector<double> yvals2D(gridsize), yvals(nlat);
gridInqXvals(gridID1, xvals.data());
gridInqYvals(gridID1, yvals.data());
size_t ij = 0;
for (size_t j = 0; j < ny; j++)
for (size_t j = 0; j < nlat; j++)
{
const size_t nx = rowlon[j];
for (size_t i = 0; i < nx; i++) yvals2D[ij++] = yvals[j];
const size_t nlon = rowlon[j];
for (size_t i = 0; i < nlon; ++i) yvals2D[ij++] = yvals[j];
}
gridDefXvals(gridID2, xvals.data());
gridDefYvals(gridID2, yvals2D.data());
}
/*
if (lbounds)
{
size_t nvertex = (size_t) gridInqNvertex(gridID1);
std::vector<double> xbounds, ybounds;
/*
if (nvertex == 2 && gridInqXbounds(gridID1, nullptr))
{
xbounds.resize(2 * nx);
xbounds.resize(2 * nlon);
gridInqXbounds(gridID1, xbounds.data());
}
else if (nx > 1)
else if (nlon > 1)
{
xbounds.resize(2 * nx);
xbounds.resize(2 * nlon);
grid_gen_bounds(nx, xvals.data(), xbounds.data());
}
*/
if (nvertex == 2 && gridInqYbounds(gridID1, nullptr))
{
ybounds.resize(2 * ny);
ybounds.resize(2 * nlat);
gridInqYbounds(gridID1, ybounds.data());
}
else if (ny > 1)
{
ybounds.resize(2 * ny);
grid_gen_bounds(ny, yvals.data(), ybounds.data());
grid_check_lat_borders(2 * ny, ybounds.data());
}
if (xbounds.size() && ybounds.size())
if (ybounds.size())
{
std::vector<double> xbounds2D(4 * gridsize), ybounds2D(4 * gridsize);
grid_gen_xbounds2D(nx, ny, xbounds.data(), xbounds2D.data());
grid_gen_ybounds2D(nx, ny, ybounds.data(), ybounds2D.data());
size_t ij = 0;
for (size_t j = 0; j < nlat; ++j)
{
const size_t nlon = rowlon[j];
for (size_t i = 0; i < nlon; ++i)
{
xbounds2D[ij + 0] = (i+.5) * 360. / nlon;
xbounds2D[ij + 1] = (i+.5) * 360. / nlon;
xbounds2D[ij + 2] = (i-.5) * 360. / nlon;
xbounds2D[ij + 3] = (i-.5) * 360. / nlon;
ybounds2D[ij + 0] = ybounds[j*2];
ybounds2D[ij + 1] = ybounds[j*2 + 1];
ybounds2D[ij + 2] = ybounds[j*2 + 1];
ybounds2D[ij + 3] = ybounds[j*2];
ij += 4;
}
}
gridDefXbounds(gridID2, xbounds2D.data());
gridDefYbounds(gridID2, ybounds2D.data());
}
}
*/
gridCopyMask(gridID1, gridID2, gridsize);
break;
......
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