From bc348506c7ac129255b7394cd866d108e8e66f5c Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Mon, 15 Oct 2012 17:53:31 -0500 Subject: [PATCH] Issue #1260 Fix non-overlapping grids Change-Id: I27bc2a2d4db33abb81c1733046e8eef5729a4384 Former-commit-id: bce2713c310600df682320729ddf054d639e435c [formerly b31e52cbd0dc8a743532e292b76473375a0eb7d5 [formerly 6b05875f6bd24d027bb5817eee9b412bb83f9b3a]] Former-commit-id: b31e52cbd0dc8a743532e292b76473375a0eb7d5 Former-commit-id: 25ddccf57af14ec1446b77aa85d20f252b31da21 --- .../gfe/server/database/D2DGridDatabase.java | 33 ++++++++--- .../server/database/NetCDFGridDatabase.java | 56 ++++++++++++------- 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/D2DGridDatabase.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/D2DGridDatabase.java index c830a34bad..6b9d00a565 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/D2DGridDatabase.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/D2DGridDatabase.java @@ -173,14 +173,15 @@ public class D2DGridDatabase extends VGridDatabase { - subdomain.height; if (subdomain.isEmpty()) { - valid = false; - throw new GfeException("Unable to create " + this.dbId - + ". GFE domain does not overlap dataset domain."); + statusHandler.warn(this.dbId + + ": GFE domain does not overlap dataset domain."); + this.remap = null; + } else { + this.remap = new RemapGrid(NetCDFUtils.subGridGL( + dbId.toString(), this.inputLoc, subdomain), + this.outputLoc); } - this.remap = new RemapGrid(NetCDFUtils.subGridGL(dbId.toString(), - this.inputLoc, subdomain), this.outputLoc); - } } @@ -475,7 +476,14 @@ public class D2DGridDatabase extends VGridDatabase { switch (gpi.getGridType()) { case SCALAR: - Grid2DFloat data = getGrid(parmId, time, gpi, convertUnit); + Grid2DFloat data = null; + if (this.remap == null) { + // GFE domain does not overlap D2D grid, return default grid + data = new Grid2DFloat(gpi.getGridLoc().getNx(), gpi + .getGridLoc().getNy(), gpi.getMinValue()); + } else { + data = getGrid(parmId, time, gpi, convertUnit); + } gs = new ScalarGridSlice(time, gpi, gdh, data); break; case VECTOR: @@ -483,7 +491,14 @@ public class D2DGridDatabase extends VGridDatabase { .getGridLoc().getNy()); Grid2DFloat dir = new Grid2DFloat(gpi.getGridLoc().getNx(), gpi .getGridLoc().getNy()); - getWindGrid(parmId, time, gpi, mag, dir); + + if (this.remap == null) { + // GFE domain does not overlap D2D grid, return default grid + mag.setAllValues(gpi.getMinValue()); + dir.setAllValues(0.0f); + } else { + getWindGrid(parmId, time, gpi, mag, dir); + } gs = new VectorGridSlice(time, gpi, gdh, mag, dir); break; default: @@ -511,6 +526,7 @@ public class D2DGridDatabase extends VGridDatabase { */ private Grid2DFloat getGrid(ParmID parmId, TimeRange time, GridParmInfo gpi, boolean convertUnit) throws GfeException { + Grid2DFloat bdata = null; GribRecord d2dRecord = null; @@ -628,6 +644,7 @@ public class D2DGridDatabase extends VGridDatabase { */ private void getWindGrid(ParmID parmId, TimeRange time, GridParmInfo gpi, Grid2DFloat mag, Grid2DFloat dir) throws GfeException { + GFEDao dao = null; try { dao = (GFEDao) PluginFactory.getInstance().getPluginDao("gfe"); diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/NetCDFGridDatabase.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/NetCDFGridDatabase.java index c455567523..21f05b500f 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/NetCDFGridDatabase.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/NetCDFGridDatabase.java @@ -201,14 +201,14 @@ public class NetCDFGridDatabase extends VGridDatabase { this.outputGloc); if (this.subdomain.isEmpty()) { - valid = false; - throw new GfeException("Unable to create " + this.dbId - + ". GFE domain does not overlap dataset domain."); + statusHandler.warn(this.dbId + + ": GFE domain does not overlap dataset domain."); + this.remap = null; + } else { + this.remap = new RemapGrid(NetCDFUtils.subGridGL( + this.dbId.toString(), this.inputGloc, this.subdomain), + this.outputGloc); } - - this.remap = new RemapGrid(NetCDFUtils.subGridGL( - this.dbId.toString(), this.inputGloc, this.subdomain), - this.outputGloc); loadParms(); } } @@ -584,35 +584,51 @@ public class NetCDFGridDatabase extends VGridDatabase { GridDataHistory gdh = new GridDataHistory(OriginType.INITIALIZED, p.getPid(), p.getInv().get(index)); - switch (p.getGpi().getGridType()) { + GridParmInfo gpi = p.getGpi(); + GridLocation gloc = gpi.getGridLoc(); + + switch (gpi.getGridType()) { case SCALAR: { - Grid2DFloat data = new Grid2DFloat(getGrid(p.getVarName(), - p.getIndices()[index], p.getLevel(), p.getGpi() - .getMinValue(), p.getGpi().getMaxValue())); + Grid2DFloat data = null; + if (this.remap == null) { + // GFE domain does not overlap D2D grid, return default grid + data = new Grid2DFloat(gloc.getNx(), gloc.getNy(), + gpi.getMinValue()); + + } else { + data = new Grid2DFloat(getGrid(p.getVarName(), + p.getIndices()[index], p.getLevel(), gpi.getMinValue(), + gpi.getMaxValue())); + } if (!data.isValid()) { return null; } - gs = new ScalarGridSlice(p.getInv().get(index), p.getGpi(), + gs = new ScalarGridSlice(p.getInv().get(index), gpi, Arrays.asList(gdh), data); break; } case VECTOR: { - Grid2DFloat mag = new Grid2DFloat(p.getGpi().getGridLoc().getNx(), - p.getGpi().getGridLoc().getNy()); - Grid2DFloat dir = new Grid2DFloat(p.getGpi().getGridLoc().getNx(), - p.getGpi().getGridLoc().getNy()); - getWindGrid(p.getIndices()[index], p.getLevel(), p.getGpi() - .getMinValue(), p.getGpi().getMaxValue(), mag, dir); + Grid2DFloat mag = new Grid2DFloat(gloc.getNx(), gloc.getNy()); + Grid2DFloat dir = new Grid2DFloat(gloc.getNx(), gloc.getNy()); + + if (this.remap == null) { + // GFE domain does not overlap D2D grid, return default grid + mag.setAllValues(gpi.getMinValue()); + dir.setAllValues(0.0f); + } else { + getWindGrid(p.getIndices()[index], p.getLevel(), + gpi.getMinValue(), gpi.getMaxValue(), mag, dir); + } if (!mag.isValid() || !dir.isValid()) { return null; } - gs = new VectorGridSlice(p.getInv().get(index), p.getGpi(), + gs = new VectorGridSlice(p.getInv().get(index), gpi, Arrays.asList(gdh), mag, dir); break; } default: statusHandler.handle(Priority.PROBLEM, - "unsupported parm type for: " + p.getGpi()); + "unsupported parm type for: " + gpi); } return gs;