Issue #1260 Fix non-overlapping grids

Change-Id: I27bc2a2d4db33abb81c1733046e8eef5729a4384

Former-commit-id: bce2713c31 [formerly b31e52cbd0 [formerly 6b05875f6bd24d027bb5817eee9b412bb83f9b3a]]
Former-commit-id: b31e52cbd0
Former-commit-id: 25ddccf57a
This commit is contained in:
Ron Anderson 2012-10-15 17:53:31 -05:00
parent ed62e597e9
commit bc348506c7
2 changed files with 61 additions and 28 deletions

View file

@ -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");

View file

@ -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;