Issue #1919 - Fix VGBs in FFMP
Former-commit-id:f887a41875
[formerlyf887a41875
[formerly f5ab8a230b2c63bd025d32a2364a52b3536536d4]] Former-commit-id:7874521269
Former-commit-id:d262dc63f0
This commit is contained in:
parent
65e64221d5
commit
83304c3e4c
3 changed files with 63 additions and 61 deletions
|
@ -43,6 +43,7 @@ import com.raytheon.uf.common.monitor.xml.SourceXML;
|
||||||
* Jul 20, 2011 mpduff Initial creation
|
* Jul 20, 2011 mpduff Initial creation
|
||||||
* 01/14/13 1569 dhladky changed arraylist to list
|
* 01/14/13 1569 dhladky changed arraylist to list
|
||||||
* 04/15/13 1890 dhladky Changed COUNTY to use constant
|
* 04/15/13 1890 dhladky Changed COUNTY to use constant
|
||||||
|
* 05/10/13 1919 mpduff If there are forced pfafs then the aggregate is forced.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -57,7 +58,7 @@ public class FFFGForceUtil {
|
||||||
|
|
||||||
private List<Long> pfafList = new ArrayList<Long>();
|
private List<Long> pfafList = new ArrayList<Long>();
|
||||||
|
|
||||||
private FFMPResource resource;
|
private final FFMPResource resource;
|
||||||
|
|
||||||
private String domain = "NA";
|
private String domain = "NA";
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ public class FFFGForceUtil {
|
||||||
|
|
||||||
private SourceXML sourceXML2 = null;
|
private SourceXML sourceXML2 = null;
|
||||||
|
|
||||||
private FFMPGuidanceInterpolation interp;
|
private final FFMPGuidanceInterpolation interp;
|
||||||
|
|
||||||
private double src1Hr = -999;
|
private double src1Hr = -999;
|
||||||
|
|
||||||
|
@ -151,7 +152,7 @@ public class FFFGForceUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||||
|
|
||||||
if ((sliderTime >= src1Hr) && (sliderTime <= src2Hr)) {
|
if ((sliderTime >= src1Hr) && (sliderTime <= src2Hr)) {
|
||||||
// Slider falls between the source times
|
// Slider falls between the source times
|
||||||
if (sliderTime == src1Hr) {
|
if (sliderTime == src1Hr) {
|
||||||
|
@ -212,6 +213,8 @@ public class FFFGForceUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (!forcedPfafList.isEmpty()) {
|
||||||
|
forced = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +230,7 @@ public class FFFGForceUtil {
|
||||||
}
|
}
|
||||||
long pfaf = pfafList2.get(i);
|
long pfaf = pfafList2.get(i);
|
||||||
long countyFips = ft.getCountyFipsByPfaf(pfaf);
|
long countyFips = ft.getCountyFipsByPfaf(pfaf);
|
||||||
|
|
||||||
if (countyFips != prevCtyFips) {
|
if (countyFips != prevCtyFips) {
|
||||||
if (fdm.isBasinForced(source, countyFips)) {
|
if (fdm.isBasinForced(source, countyFips)) {
|
||||||
forcedList.add(pfaf);
|
forcedList.add(pfaf);
|
||||||
|
@ -243,29 +246,28 @@ public class FFFGForceUtil {
|
||||||
|
|
||||||
return forcedList;
|
return forcedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAvgForcedValue(List<Long> pfafList,
|
public float getAvgForcedValue(List<Long> pfafList, List<Long> forcedPfafs,
|
||||||
List<Long> forcedPfafs,
|
FFMPGuidanceInterpolation interpolation, long expiration,
|
||||||
FFMPGuidanceInterpolation interpolation,
|
FFMPTemplates templates) {
|
||||||
long expiration, FFMPTemplates templates) {
|
|
||||||
float tvalue = 0.0f;
|
float tvalue = 0.0f;
|
||||||
float value;
|
float value;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (interpolation.isInterpolate() == false) {
|
if (interpolation.isInterpolate() == false) {
|
||||||
FFFGDataMgr dman = FFFGDataMgr.getInstance();
|
FFFGDataMgr dman = FFFGDataMgr.getInstance();
|
||||||
for (long pfaf: forcedPfafs) {
|
for (long pfaf : forcedPfafs) {
|
||||||
long countyFips = templates.getCountyFipsByPfaf(pfaf);
|
long countyFips = templates.getCountyFipsByPfaf(pfaf);
|
||||||
templates.getCountyFipsByPfaf(pfaf);
|
templates.getCountyFipsByPfaf(pfaf);
|
||||||
value = dman.adjustValue(Float.NaN, interpolation.getStandardSource(), pfaf,
|
value = dman.adjustValue(Float.NaN,
|
||||||
countyFips);
|
interpolation.getStandardSource(), pfaf, countyFips);
|
||||||
|
|
||||||
tvalue += value;
|
tvalue += value;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tvalue/i;
|
return tvalue / i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +309,8 @@ public class FFFGForceUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sliderTime the sliderTime to set
|
* @param sliderTime
|
||||||
|
* the sliderTime to set
|
||||||
*/
|
*/
|
||||||
public void setSliderTime(double sliderTime) {
|
public void setSliderTime(double sliderTime) {
|
||||||
this.sliderTime = sliderTime;
|
this.sliderTime = sliderTime;
|
||||||
|
|
|
@ -73,11 +73,12 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FfmpTableConfigData;
|
||||||
* feb 20, 2013 1635 dhladky Fixed multi guidance displays
|
* feb 20, 2013 1635 dhladky Fixed multi guidance displays
|
||||||
* Feb 28, 2013 1729 dhladky General enhancements for speed.
|
* Feb 28, 2013 1729 dhladky General enhancements for speed.
|
||||||
* Apr 12, 2013 1902 mpduff Code Cleanup.
|
* Apr 12, 2013 1902 mpduff Code Cleanup.
|
||||||
* Apr 15, 2013 1890 dhladky Added another constant fix.
|
* Apr 15, 2013 1890 dhladky Added another constant fix.
|
||||||
* Apr 15, 2013 1911 dhladky Fixed forced FFG for centered aggregates.
|
* Apr 15, 2013 1911 dhladky Fixed forced FFG for centered aggregates.
|
||||||
* Apr 24, 2013 1946 mpduff Fixed FFFG value for ALL when an aggregate is forced
|
* Apr 24, 2013 1946 mpduff Fixed FFFG value for ALL when an aggregate is forced
|
||||||
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
|
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
|
||||||
* May 7, 2013 1986 njensen Removed unnecessary sort
|
* May 07, 2013 1986 njensen Removed unnecessary sort
|
||||||
|
* May 10, 2013 1919 mpduff Fixed problem with VGBs
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -352,7 +353,6 @@ public class FFMPDataGenerator {
|
||||||
String lid = vgBasin.getLid();
|
String lid = vgBasin.getLid();
|
||||||
|
|
||||||
if (lid != null) {
|
if (lid != null) {
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder(lid);
|
StringBuilder sb = new StringBuilder(lid);
|
||||||
// in this special case it is actually the LID
|
// in this special case it is actually the LID
|
||||||
trd.setPfaf(lid);
|
trd.setPfaf(lid);
|
||||||
|
@ -409,21 +409,18 @@ public class FFMPDataGenerator {
|
||||||
for (String guidType : guidBasins.keySet()) {
|
for (String guidType : guidBasins.keySet()) {
|
||||||
guidance = Float.NaN;
|
guidance = Float.NaN;
|
||||||
|
|
||||||
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
|
||||||
forceUtil.setSliderTime(sliderTime);
|
|
||||||
|
|
||||||
FFMPTableCellData guidCellData = getGuidanceCellData(
|
FFMPTableCellData guidCellData = getGuidanceCellData(
|
||||||
cBasin, domain, guidType, parentBasinPfaf);
|
cBasin, domain, guidType, parentBasinPfaf);
|
||||||
if (guidCellData == null) {
|
if (guidCellData == null) {
|
||||||
guidCellData = new FFMPTableCellData(
|
// check for forcing even if no data are available
|
||||||
FIELDS.GUIDANCE, Float.NaN);
|
guidance = getForcedAvg(domain, cBasin, guidType);
|
||||||
} else {
|
|
||||||
guidance = guidCellData.getValueAsFloat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trd.setTableCellData(i + 4, guidCellData);
|
trd.setTableCellData(i + 4, guidCellData);
|
||||||
|
|
||||||
float ratioValue = Float.NaN;
|
float ratioValue = Float.NaN;
|
||||||
float diffValue = Float.NaN;
|
float diffValue = Float.NaN;
|
||||||
|
|
||||||
// If guidance is NaN then it cannot be > 0
|
// If guidance is NaN then it cannot be > 0
|
||||||
if (!qpe.isNaN() && (guidance > 0.0f)) {
|
if (!qpe.isNaN() && (guidance > 0.0f)) {
|
||||||
ratioValue = FFMPUtils.getRatioValue(qpe, guidance);
|
ratioValue = FFMPUtils.getRatioValue(qpe, guidance);
|
||||||
|
@ -433,7 +430,6 @@ public class FFMPDataGenerator {
|
||||||
FIELDS.RATIO, ratioValue));
|
FIELDS.RATIO, ratioValue));
|
||||||
trd.setTableCellData(i + 6, new FFMPTableCellData(
|
trd.setTableCellData(i + 6, new FFMPTableCellData(
|
||||||
FIELDS.DIFF, diffValue));
|
FIELDS.DIFF, diffValue));
|
||||||
|
|
||||||
i += 3;
|
i += 3;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -441,7 +437,6 @@ public class FFMPDataGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
tData.addDataRow(trd);
|
tData.addDataRow(trd);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayName = getDisplayName(cBasin);
|
displayName = getDisplayName(cBasin);
|
||||||
|
@ -497,15 +492,12 @@ public class FFMPDataGenerator {
|
||||||
guidance = Float.NaN;
|
guidance = Float.NaN;
|
||||||
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
||||||
forceUtil.setSliderTime(sliderTime);
|
forceUtil.setSliderTime(sliderTime);
|
||||||
|
|
||||||
FFMPTableCellData guidCellData = getGuidanceCellData(
|
FFMPTableCellData guidCellData = getGuidanceCellData(
|
||||||
cBasin, domain, guidType, cBasinPfaf);
|
cBasin, domain, guidType, cBasinPfaf);
|
||||||
if (guidCellData == null) {
|
if (guidCellData == null) {
|
||||||
// check for forcing even if no data are available
|
// check for forcing even if no data are available
|
||||||
guidance = getForcedAvg(forceUtil, domain, cBasin,
|
guidance = getForcedAvg(domain, cBasin, guidType);
|
||||||
guidType);
|
|
||||||
boolean forced = !guidance.isNaN();
|
|
||||||
guidCellData = new FFMPTableCellData(
|
|
||||||
FIELDS.GUIDANCE, guidance, forced);
|
|
||||||
} else {
|
} else {
|
||||||
guidance = guidCellData.getValueAsFloat();
|
guidance = guidCellData.getValueAsFloat();
|
||||||
}
|
}
|
||||||
|
@ -554,6 +546,7 @@ public class FFMPDataGenerator {
|
||||||
boolean forced = false;
|
boolean forced = false;
|
||||||
Float guidance = Float.NaN;
|
Float guidance = Float.NaN;
|
||||||
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
||||||
|
forceUtil.setSliderTime(sliderTime);
|
||||||
|
|
||||||
// If aggregate, get basins within the aggregate
|
// If aggregate, get basins within the aggregate
|
||||||
if (cBasin.getAggregated()) {
|
if (cBasin.getAggregated()) {
|
||||||
|
@ -569,6 +562,9 @@ public class FFMPDataGenerator {
|
||||||
siteKey, domain, huc);
|
siteKey, domain, huc);
|
||||||
pfafList.add(ft.getAggregatedPfaf(cBasinPfaf, siteKey, huc));
|
pfafList.add(ft.getAggregatedPfaf(cBasinPfaf, siteKey, huc));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pfafList = new ArrayList<Long>();
|
||||||
|
pfafList.add(cBasinPfaf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FFFGDataMgr.getInstance().isForcingConfigured()) {
|
if (FFFGDataMgr.getInstance().isForcingConfigured()) {
|
||||||
|
@ -581,17 +577,19 @@ public class FFMPDataGenerator {
|
||||||
forced = forceUtil.isForced();
|
forced = forceUtil.isForced();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!forcedPfafs.isEmpty() || !pfafList.isEmpty()
|
if (!forcedPfafs.isEmpty() || forced || !pfafList.isEmpty()) {
|
||||||
&& centeredAggregationKey == null) {
|
// Recalculate guidance using the forced value(s)
|
||||||
FFMPBasinData basinData = guidRecords.get(guidType).getBasinData(
|
guidance = guidRecords
|
||||||
ALL);
|
.get(guidType)
|
||||||
guidance = basinData.getAverageGuidanceValue(pfafList, resource
|
.getBasinData(ALL)
|
||||||
.getGuidanceInterpolators().get(guidType), guidance,
|
.getAverageGuidanceValue(pfafList,
|
||||||
forcedPfafs, resource.getGuidSourceExpiration(guidType));
|
resource.getGuidanceInterpolators().get(guidType),
|
||||||
forced = !forcedPfafs.isEmpty();
|
guidance, forcedPfafs,
|
||||||
|
resource.getGuidSourceExpiration(guidType));
|
||||||
} else {
|
} else {
|
||||||
guidance = resource.getGuidanceValue(ffmpGuidBasin, paintRefTime,
|
guidance = resource.getGuidanceValue(ffmpGuidBasin, paintRefTime,
|
||||||
guidType);
|
guidType);
|
||||||
|
|
||||||
if (guidance < 0.0f) {
|
if (guidance < 0.0f) {
|
||||||
guidance = Float.NaN;
|
guidance = Float.NaN;
|
||||||
}
|
}
|
||||||
|
@ -600,8 +598,9 @@ public class FFMPDataGenerator {
|
||||||
return new FFMPTableCellData(FIELDS.GUIDANCE, guidance, forced);
|
return new FFMPTableCellData(FIELDS.GUIDANCE, guidance, forced);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getForcedAvg(FFFGForceUtil forceUtil, String domain,
|
private float getForcedAvg(String domain, FFMPBasin cBasin, String guidType) {
|
||||||
FFMPBasin cBasin, String guidType) {
|
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
||||||
|
forceUtil.setSliderTime(sliderTime);
|
||||||
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||||
List<Long> forcedPfafs;
|
List<Long> forcedPfafs;
|
||||||
List<Long> pfafList = new ArrayList<Long>();
|
List<Long> pfafList = new ArrayList<Long>();
|
||||||
|
@ -641,12 +640,6 @@ public class FFMPDataGenerator {
|
||||||
guidance = forceUtil.getAvgForcedValue(pfafList, forcedPfafs,
|
guidance = forceUtil.getAvgForcedValue(pfafList, forcedPfafs,
|
||||||
resource.getGuidanceInterpolators().get(guidType),
|
resource.getGuidanceInterpolators().get(guidType),
|
||||||
resource.getGuidSourceExpiration(guidType), ft);
|
resource.getGuidSourceExpiration(guidType), ft);
|
||||||
// } else if (forcedPfafs.size() > 1) {
|
|
||||||
// guidance = forceUtil.getAvgForcedValue(pfafList,
|
|
||||||
// forcedPfafs,
|
|
||||||
// resource.getGuidanceInterpolators().get(guidType),
|
|
||||||
// resource.getGuidSourceExpiration(), ft);
|
|
||||||
// forced = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO Calculate a max value
|
// TODO Calculate a max value
|
||||||
|
|
|
@ -49,7 +49,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||||
* 06/22/09 2152 D. Hladky Initial release
|
* 06/22/09 2152 D. Hladky Initial release
|
||||||
* 01/27/13 1478 D. Hladky Added support for write of aggregate record cache
|
* 01/27/13 1478 D. Hladky Added support for write of aggregate record cache
|
||||||
* 01/27/13 1569 D. Hladky Added support for write of aggregate record cache
|
* 01/27/13 1569 D. Hladky Added support for write of aggregate record cache
|
||||||
* Apr 16, 2013 1912 bsteffen Initial bulk hdf5 access for ffmp
|
* 04/16/13 1912 bsteffen Initial bulk hdf5 access for ffmp
|
||||||
|
* 05/09/13 1919 mpduff Use parent pfaf instead of lookupId.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -58,10 +59,6 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||||
*/
|
*/
|
||||||
@DynamicSerialize
|
@DynamicSerialize
|
||||||
public class FFMPBasinData implements ISerializableObject {
|
public class FFMPBasinData implements ISerializableObject {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 8162247989509750715L;
|
private static final long serialVersionUID = 8162247989509750715L;
|
||||||
|
|
||||||
public static final double GUIDANCE_MISSING = -999999.0;
|
public static final double GUIDANCE_MISSING = -999999.0;
|
||||||
|
@ -76,12 +73,12 @@ public class FFMPBasinData implements ISerializableObject {
|
||||||
/**
|
/**
|
||||||
* Pending load tasks that need to be run to fully populate basins
|
* Pending load tasks that need to be run to fully populate basins
|
||||||
*/
|
*/
|
||||||
private List<LoadTask> tasks = new ArrayList<LoadTask>();
|
private final List<LoadTask> tasks = new ArrayList<LoadTask>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache of basins in order for easy population from Load Tasks.
|
* Cache of basins in order for easy population from Load Tasks.
|
||||||
*/
|
*/
|
||||||
private Map<String, FFMPBasin[]> orderedBasinsCache = new HashMap<String, FFMPBasin[]>();
|
private final Map<String, FFMPBasin[]> orderedBasinsCache = new HashMap<String, FFMPBasin[]>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public one arg constructor
|
* Public one arg constructor
|
||||||
|
@ -690,7 +687,7 @@ public class FFMPBasinData implements ISerializableObject {
|
||||||
FFMPBasin basin = this.basins.get(fvgbmd.getLookupId());
|
FFMPBasin basin = this.basins.get(fvgbmd.getLookupId());
|
||||||
if (basin == null) {
|
if (basin == null) {
|
||||||
basin = new FFMPVirtualGageBasin(fvgbmd.getLid(),
|
basin = new FFMPVirtualGageBasin(fvgbmd.getLid(),
|
||||||
fvgbmd.getLookupId(), false);
|
fvgbmd.getParentPfaf(), false);
|
||||||
this.basins.put(fvgbmd.getLookupId(), basin);
|
this.basins.put(fvgbmd.getLookupId(), basin);
|
||||||
}
|
}
|
||||||
basins[j++] = basin;
|
basins[j++] = basin;
|
||||||
|
@ -702,6 +699,9 @@ public class FFMPBasinData implements ISerializableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load now.
|
||||||
|
*/
|
||||||
public void loadNow() {
|
public void loadNow() {
|
||||||
synchronized (tasks) {
|
synchronized (tasks) {
|
||||||
if (!tasks.isEmpty()) {
|
if (!tasks.isEmpty()) {
|
||||||
|
@ -728,6 +728,9 @@ public class FFMPBasinData implements ISerializableObject {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void process(FloatDataRecord record) {
|
public void process(FloatDataRecord record) {
|
||||||
float[] values = record.getFloatData();
|
float[] values = record.getFloatData();
|
||||||
|
@ -736,6 +739,9 @@ public class FFMPBasinData implements ISerializableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply the value to the basin/
|
||||||
|
*/
|
||||||
protected void applyValue(FFMPBasin basin, float value) {
|
protected void applyValue(FFMPBasin basin, float value) {
|
||||||
if (basin.contains(date)) {
|
if (basin.contains(date)) {
|
||||||
float curval = basin.getValue(date);
|
float curval = basin.getValue(date);
|
||||||
|
|
Loading…
Add table
Reference in a new issue