VLab Issue #6278 - Model soundings being interpolated below the surface

for elevated sites

Change-Id: I4acf7182250ecaad1893432296069e54f62d458c

Former-commit-id: 66e8f998d8d400d3d4ba736a2826b5e22a3f174b
This commit is contained in:
Chin Chen 2015-02-03 11:03:14 -05:00
parent ddaca01b1d
commit 5d2b504d03
3 changed files with 1208 additions and 1070 deletions

View file

@ -33,6 +33,7 @@ Import-Package: com.raytheon.uf.common.dataplugin.bufrua,
com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.pointdata, com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.pointdata.spatial, com.raytheon.uf.common.pointdata.spatial,
com.raytheon.uf.common.topo,
com.raytheon.uf.edex.pointdata, com.raytheon.uf.edex.pointdata,
gov.noaa.nws.ncep.common.tools, gov.noaa.nws.ncep.common.tools,
gov.noaa.nws.ncep.edex.common.metparameters, gov.noaa.nws.ncep.edex.common.metparameters,

View file

@ -20,6 +20,7 @@ package gov.noaa.nws.ncep.edex.uengine.tasks.profile;
* 03/2014 1116 T. Lee Added DpD * 03/2014 1116 T. Lee Added DpD
* 01/2015 DR#16959 Chin Chen Added DpT support to fix DR 16959 NSHARP freezes when loading a sounding from * 01/2015 DR#16959 Chin Chen Added DpT support to fix DR 16959 NSHARP freezes when loading a sounding from
* HiRes-ARW/NMM models * HiRes-ARW/NMM models
* 02/03/2015 DR#17084 Chin Chen Model soundings being interpolated below the surface for elevated sites
* </pre> * </pre>
* *
* @author Chin Chen * @author Chin Chen
@ -53,6 +54,7 @@ import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.geospatial.ISpatialObject; import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.PointUtil; import com.raytheon.uf.common.geospatial.PointUtil;
import com.raytheon.uf.common.topo.TopoQuery;
import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.CoreDao; import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig; import com.raytheon.uf.edex.database.dao.DaoConfig;
@ -585,7 +587,7 @@ public class MdlSoundingQuery {
} }
/** /**
* Returns the value of surface pressure for a specified location, time, and * Returns the value of surface layer for a specified location, time, and
* model for grib or ncgrib data. * model for grib or ncgrib data.
* *
* @param pnt * @param pnt
@ -595,45 +597,145 @@ public class MdlSoundingQuery {
* @param modelName * @param modelName
* the name of the model * the name of the model
* @return surface pressure * @return surface pressure
*
* DR17084
*/ */
public static Float getModelSfcPressure(Point pnt, String refTime, @SuppressWarnings("unchecked")
String validTime, String pluginName, String modelName) { public static NcSoundingLayer getModelSfcLayer(Point pnt, String refTime,
String validTime, String pluginName, String modelName, Coordinate coordinate) {
if (pluginName.equalsIgnoreCase(GRID_TBL_NAME)) { if (pluginName.equalsIgnoreCase(GRID_TBL_NAME)) {
CoreDao dao = new CoreDao(DaoConfig.forClass(GridRecord.class)); NcSoundingLayer soundingLy = new NcSoundingLayer();
DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName()); TableQuery query;
query.addQueryParam(GridConstants.LEVEL_ONE, "0.0");
query.addQueryParam(GridConstants.LEVEL_TWO, "-999999.0");
query.addQueryParam(GridConstants.MASTER_LEVEL_NAME, "MSL");
query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, "PMSL");
query.addQueryParam(GridConstants.DATASET_ID, modelName);
query.addQueryParam("dataTime.refTime", refTime);
query.addQueryParam("dataTime.validPeriod.start", validTime);
GridRecord rec = null;
try { try {
List<GridRecord> recList = ((List<GridRecord>) dao query = new TableQuery("metadata", GridRecord.class.getName());
.queryByCriteria(query)); query.addParameter(GridConstants.LEVEL_ONE, "0.0");
if (recList.size() == 0) { query.addParameter(GridConstants.LEVEL_TWO, "-999999.0");
return null; query.addParameter(GridConstants.MASTER_LEVEL_NAME, "SFC");
} else { query.addList(GridConstants.PARAMETER_ABBREVIATION, "P, GH");
rec = recList.get(0); query.addParameter(GridConstants.DATASET_ID, modelName);
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
List<GridRecord> recList = (List<GridRecord>) query.execute();
boolean presureAvailable=false, heightAvailable=false;
if (recList!=null && recList.size() > 0) {
for(GridRecord rec:recList ){
PointIn pointIn = new PointIn(pluginName, rec, pnt.x, pnt.y); PointIn pointIn = new PointIn(pluginName, rec, pnt.x, pnt.y);
try { try {
float fdata = pointIn.getPointData(); float fdata = pointIn.getPointData();
return new Float(fdata); String parm = rec.getParameter().getAbbreviation();
if(parm.equals("P")){
soundingLy.setPressure(fdata/100);
presureAvailable = true;
} if(parm.equals("GH")){
soundingLy.setGeoHeight(fdata);
heightAvailable = true;
}
//System.out.println("prm="+rec.getParameter().getAbbreviation()+" value="+fdata);
} catch (PluginException e) { } catch (PluginException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
recList.clear();
}
query = new TableQuery("metadata", GridRecord.class.getName());
query.addParameter(GridConstants.LEVEL_ONE, "2.0");
query.addParameter(GridConstants.LEVEL_TWO, "-999999.0");
query.addParameter(GridConstants.MASTER_LEVEL_NAME, "FHAG");
query.addList(GridConstants.PARAMETER_ABBREVIATION, "T, RH");
query.addParameter(GridConstants.DATASET_ID, modelName);
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
recList = (List<GridRecord>) query.execute();
if (recList!=null && recList.size() > 0) {
for(GridRecord rec:recList ){
PointIn pointIn = new PointIn(pluginName, rec, pnt.x, pnt.y);
try {
float fdata = pointIn.getPointData();
String parm = rec.getParameter().getAbbreviation();
if(parm.equals("T")){
soundingLy.setTemperature((float) kelvinToCelsius
.convert(fdata));
} if(parm.equals("RH")){
soundingLy.setRelativeHumidity(fdata);
}
//System.out.println("prm="+rec.getParameter().getAbbreviation()+" value="+fdata);
} catch (PluginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
recList.clear();
}
query = new TableQuery("metadata", GridRecord.class.getName());
query.addParameter(GridConstants.LEVEL_ONE, "10.0");
query.addParameter(GridConstants.LEVEL_TWO, "-999999.0");
query.addParameter(GridConstants.MASTER_LEVEL_NAME, "FHAG");
query.addList(GridConstants.PARAMETER_ABBREVIATION, "vW, uW");
query.addParameter(GridConstants.DATASET_ID, modelName);
query.addParameter("dataTime.refTime", refTime);
query.addParameter("dataTime.validPeriod.start", validTime);
recList = (List<GridRecord>) query.execute();
if (recList!=null && recList.size() > 0) {
for(GridRecord rec:recList ){
PointIn pointIn = new PointIn(pluginName, rec, pnt.x, pnt.y);
try {
float fdata = pointIn.getPointData();
String parm = rec.getParameter().getAbbreviation();
if(parm.equals("vW")){
soundingLy.setWindV((float) metersPerSecondToKnots
.convert(fdata));
} if(parm.equals("uW")){
soundingLy.setWindU((float) metersPerSecondToKnots
.convert(fdata));
}
//System.out.println("prm="+rec.getParameter().getAbbreviation()+" value="+fdata);
} catch (PluginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
}
if (presureAvailable==false || heightAvailable==false) {
float surfaceElevation = NcSoundingProfile.MISSING;
TopoQuery topoQuery = TopoQuery.getInstance();
if (topoQuery != null) {
//System.out.println("Nsharp coordinate.x="+coordinate.x);
surfaceElevation = (float) topoQuery
.getHeight(coordinate);
if(surfaceElevation >=0)
soundingLy.setGeoHeight(surfaceElevation);
else {
if (presureAvailable==false)
//no pressure and no height, no hope to continue.
return null;
}
}
else {
if (presureAvailable==false)
//no pressure and no height, no hope to continue.
return null;
}
}
return soundingLy;
} catch (DataAccessLayerException e) { } catch (DataAccessLayerException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
return null; return null;
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} }
} }
return null; return null;
@ -770,19 +872,44 @@ public class MdlSoundingQuery {
// coord.x); // coord.x);
pf.setStationLatitude(coord.y); pf.setStationLatitude(coord.y);
pf.setStationLongitude(coord.x); pf.setStationLongitude(coord.x);
// Float sfcPressure = getModelSfcPressure(pnt, refTime, // DR17084
// validTime, NcSoundingLayer sfcLayer = getModelSfcLayer(pnt, refTime,
// pluginName, modelName); validTime,pluginName, modelName, coord);
// System.out.println("getModelSfcPressure took "+ if (sfcLayer != null) {
// (System.currentTimeMillis()-t013) + " ms"); if(sfcLayer.getPressure()== NcSoundingLayer.MISSING &&
// /if (sfcPressure == null) { sfcLayer.getGeoHeight()!= NcSoundingLayer.MISSING){
pf.setSfcPress(-9999.f); //surface layer does not have pressure, but surface height is available
// } //see if we can interpolate surface pressure from upper and lower layer pressure
// else { for (int i = 0; i < soundLyList.size(); i++) {
// pf.setSfcPress(sfcPressure/100F); if (soundLyList.get(i).getGeoHeight() > sfcLayer.getGeoHeight()) {
// } if (i > 0) {
// System.out.println("surface pressure ="+pf.getSfcPress()+ float p1 = soundLyList.get(i - 1).getPressure();
// " lat= "+lat+ " lon="+lon); float p2 = soundLyList.get(i).getPressure();
float h1 = soundLyList.get(i - 1).getGeoHeight();
float h2 = soundLyList.get(i).getGeoHeight();
float h = sfcLayer.getGeoHeight();
float p = p1 + (h - h1) * (p1 - p2) / (h1 - h2);
sfcLayer.setPressure(p);
}
break;
}
}
}
if(sfcLayer.getPressure()!= NcSoundingLayer.MISSING){
// cut sounding layer under ground, i.e. below surface layer
for(int i= soundLyList.size()-1; i>=0 ; i--){
NcSoundingLayer ly = soundLyList.get(i);
if(ly.getPressure() >= sfcLayer.getPressure()){
soundLyList.remove(i);
}
}
soundLyList.add(0, sfcLayer);
}
pf.setSfcPress(sfcLayer.getPressure());
pf.setStationElevation(sfcLayer.getGeoHeight());
}
//System.out.println("surface pressure ="+pf.getSfcPress());
//end DR17084
// calculate dew point if necessary // calculate dew point if necessary
MergeSounding ms = new MergeSounding(); MergeSounding ms = new MergeSounding();
// ms.spfhToDewpoint(layerList); // ms.spfhToDewpoint(layerList);

View file

@ -17,6 +17,7 @@ package gov.noaa.nws.ncep.ui.nsharp.display.rsc;
* 01/27/2015 DR#17006, * 01/27/2015 DR#17006,
* Task#5929 Chin Chen NSHARP freezes when loading a sounding from MDCRS products * Task#5929 Chin Chen NSHARP freezes when loading a sounding from MDCRS products
* in Volume Browser * in Volume Browser
* 02/03/2015 DR#17084 Chin Chen Model soundings being interpolated below the surface for elevated sites
* *
* </pre> * </pre>
* *
@ -38,6 +39,7 @@ import gov.noaa.nws.ncep.ui.nsharp.background.NsharpSkewTPaneBackground;
import gov.noaa.nws.ncep.ui.nsharp.background.NsharpTurbulencePaneBackground; import gov.noaa.nws.ncep.ui.nsharp.background.NsharpTurbulencePaneBackground;
import gov.noaa.nws.ncep.ui.nsharp.display.NsharpSkewTPaneDescriptor; import gov.noaa.nws.ncep.ui.nsharp.display.NsharpSkewTPaneDescriptor;
import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNative; import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNative;
import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNative.NsharpLibrary;
import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNative.NsharpLibrary._lplvalues; import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNative.NsharpLibrary._lplvalues;
import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNative.NsharpLibrary._parcel; import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNative.NsharpLibrary._parcel;
import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNativeConstants; import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNativeConstants;
@ -1256,32 +1258,40 @@ public class NsharpSkewTPaneResource extends NsharpAbstractPaneResource {
double p_mb = c.y; double p_mb = c.y;
double temp = c.x; double temp = c.x;
float htFt, htM, relh = -1; float htFt, htM, relh = -1;
String curStrFormat, curStrFormat1; String curStrFormat, curStrFormat1, htMStr, htFtStr;
String curStr, curStr1;// , curStr2,curStr3; String curStr, curStr1;// , curStr2,curStr3;
VerticalAlignment vAli; VerticalAlignment vAli;
HorizontalAlignment hAli; HorizontalAlignment hAli;
// curStr3 = rscHandler.getPickedStnInfoStr()+"\n"; // curStr3 = rscHandler.getPickedStnInfoStr()+"\n";
//Chin, DR17084
if(soundingLys.get(0).getGeoHeight() <0){
htMStr="M";
htFtStr="M";
}
else {
htM = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib htM = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib
.ihght((float) p_mb)); .ihght((float) p_mb));
htFt = nsharpNative.nsharpLib.mtof(htM); htFt = nsharpNative.nsharpLib.mtof(htM);
htMStr = Integer.toString(Math.round(htM));
htFtStr = Integer.toString(Math.round(htFt));
}
if (nsharpNative.nsharpLib.itemp((float) p_mb) > -9998.0 if (nsharpNative.nsharpLib.itemp((float) p_mb) > -9998.0
&& nsharpNative.nsharpLib.idwpt((float) p_mb) > -9998.0) { && nsharpNative.nsharpLib.idwpt((float) p_mb) > -9998.0) {
FloatByReference parm = new FloatByReference(0); FloatByReference parm = new FloatByReference(0);
relh = nsharpNative.nsharpLib.relh((float) p_mb, parm); relh = nsharpNative.nsharpLib.relh((float) p_mb, parm);
curStrFormat = "%4.0f/%.0fkt %4.0fmb %5.0fft/%.0fm agl %2.0f%%\n"; curStrFormat = "%4.0f/%.0fkt %4.0fmb %sft/%sm agl %2.0f%%\n";
curStr = String.format(curStrFormat, curStr = String.format(curStrFormat,
nsharpNative.nsharpLib.iwdir((float) p_mb), nsharpNative.nsharpLib.iwdir((float) p_mb),
nsharpNative.nsharpLib.iwspd((float) p_mb), p_mb, htFt, nsharpNative.nsharpLib.iwspd((float) p_mb), p_mb, htFtStr,
htM, relh); htMStr, relh);
} else { } else {
curStrFormat = "%4.0f/%.0fkt %4.0fmb %5.0fft/%.0fm agl\n"; curStrFormat = "%4.0f/%.0fkt %4.0fmb %sft/%sm agl\n";
curStr = String curStr = String
.format(curStrFormat, .format(curStrFormat,
nsharpNative.nsharpLib.iwdir((float) p_mb), nsharpNative.nsharpLib.iwdir((float) p_mb),
nsharpNative.nsharpLib.iwspd((float) p_mb), p_mb, nsharpNative.nsharpLib.iwspd((float) p_mb), p_mb,
htFt, htM); htFtStr, htMStr);
} }
/* /*
* curStrFormat1 = "%s/%s %4.1f/%4.1f%cC %4.0f/%.0f kt\n"; curStr1 = * curStrFormat1 = "%s/%s %4.1f/%4.1f%cC %4.0f/%.0f kt\n"; curStr1 =
@ -2695,11 +2705,11 @@ public class NsharpSkewTPaneResource extends NsharpAbstractPaneResource {
// Chin 08/04/2014, fixed surface height plotting bug // Chin 08/04/2014, fixed surface height plotting bug
// also fixed to draw height mraker based on AGL (i.e. above surface // also fixed to draw height mraker based on AGL (i.e. above surface
// level) // level)
int sfcIndex = nsharpNative.nsharpLib.sfc(); int sfcIndex = 0; ////DR#17084 nnsharpNative.nsharpLib.sfc();
int sfcAsl = 0; int sfcAsl = 0;
if (sfcIndex >= 0 if (//DR#17084 sfcIndex >= 0
&& sfcIndex < soundingLys.size() //DR#17084 && sfcIndex < soundingLys.size()
&& soundingLys.get(sfcIndex).getGeoHeight() != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) { soundingLys.get(sfcIndex).getGeoHeight() != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) {
double y = world.mapY(NsharpWxMath.getSkewTXY( double y = world.mapY(NsharpWxMath.getSkewTXY(
soundingLys.get(sfcIndex).getPressure(), 0).y); soundingLys.get(sfcIndex).getPressure(), 0).y);
try { try {