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
|
||||
* 01/14/13 1569 dhladky changed arraylist to list
|
||||
* 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>
|
||||
*
|
||||
|
@ -57,7 +58,7 @@ public class FFFGForceUtil {
|
|||
|
||||
private List<Long> pfafList = new ArrayList<Long>();
|
||||
|
||||
private FFMPResource resource;
|
||||
private final FFMPResource resource;
|
||||
|
||||
private String domain = "NA";
|
||||
|
||||
|
@ -65,7 +66,7 @@ public class FFFGForceUtil {
|
|||
|
||||
private SourceXML sourceXML2 = null;
|
||||
|
||||
private FFMPGuidanceInterpolation interp;
|
||||
private final FFMPGuidanceInterpolation interp;
|
||||
|
||||
private double src1Hr = -999;
|
||||
|
||||
|
@ -151,7 +152,7 @@ public class FFFGForceUtil {
|
|||
}
|
||||
|
||||
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||
|
||||
|
||||
if ((sliderTime >= src1Hr) && (sliderTime <= src2Hr)) {
|
||||
// Slider falls between the source times
|
||||
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 countyFips = ft.getCountyFipsByPfaf(pfaf);
|
||||
|
||||
|
||||
if (countyFips != prevCtyFips) {
|
||||
if (fdm.isBasinForced(source, countyFips)) {
|
||||
forcedList.add(pfaf);
|
||||
|
@ -243,29 +246,28 @@ public class FFFGForceUtil {
|
|||
|
||||
return forcedList;
|
||||
}
|
||||
|
||||
public float getAvgForcedValue(List<Long> pfafList,
|
||||
List<Long> forcedPfafs,
|
||||
FFMPGuidanceInterpolation interpolation,
|
||||
long expiration, FFMPTemplates templates) {
|
||||
|
||||
public float getAvgForcedValue(List<Long> pfafList, List<Long> forcedPfafs,
|
||||
FFMPGuidanceInterpolation interpolation, long expiration,
|
||||
FFMPTemplates templates) {
|
||||
float tvalue = 0.0f;
|
||||
float value;
|
||||
int i = 0;
|
||||
if (interpolation.isInterpolate() == false) {
|
||||
FFFGDataMgr dman = FFFGDataMgr.getInstance();
|
||||
for (long pfaf: forcedPfafs) {
|
||||
for (long pfaf : forcedPfafs) {
|
||||
long countyFips = templates.getCountyFipsByPfaf(pfaf);
|
||||
templates.getCountyFipsByPfaf(pfaf);
|
||||
value = dman.adjustValue(Float.NaN, interpolation.getStandardSource(), pfaf,
|
||||
countyFips);
|
||||
|
||||
value = dman.adjustValue(Float.NaN,
|
||||
interpolation.getStandardSource(), pfaf, countyFips);
|
||||
|
||||
tvalue += value;
|
||||
i++;
|
||||
}
|
||||
|
||||
return tvalue/i;
|
||||
|
||||
return tvalue / i;
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
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 28, 2013 1729 dhladky General enhancements for speed.
|
||||
* Apr 12, 2013 1902 mpduff Code Cleanup.
|
||||
* Apr 15, 2013 1890 dhladky Added another constant fix.
|
||||
* 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 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
|
||||
* May 7, 2013 1986 njensen Removed unnecessary sort
|
||||
* Apr 15, 2013 1890 dhladky Added another constant fix.
|
||||
* 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 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
|
||||
* May 07, 2013 1986 njensen Removed unnecessary sort
|
||||
* May 10, 2013 1919 mpduff Fixed problem with VGBs
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -352,7 +353,6 @@ public class FFMPDataGenerator {
|
|||
String lid = vgBasin.getLid();
|
||||
|
||||
if (lid != null) {
|
||||
|
||||
StringBuilder sb = new StringBuilder(lid);
|
||||
// in this special case it is actually the LID
|
||||
trd.setPfaf(lid);
|
||||
|
@ -409,21 +409,18 @@ public class FFMPDataGenerator {
|
|||
for (String guidType : guidBasins.keySet()) {
|
||||
guidance = Float.NaN;
|
||||
|
||||
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
||||
forceUtil.setSliderTime(sliderTime);
|
||||
|
||||
FFMPTableCellData guidCellData = getGuidanceCellData(
|
||||
cBasin, domain, guidType, parentBasinPfaf);
|
||||
if (guidCellData == null) {
|
||||
guidCellData = new FFMPTableCellData(
|
||||
FIELDS.GUIDANCE, Float.NaN);
|
||||
} else {
|
||||
guidance = guidCellData.getValueAsFloat();
|
||||
// check for forcing even if no data are available
|
||||
guidance = getForcedAvg(domain, cBasin, guidType);
|
||||
}
|
||||
|
||||
trd.setTableCellData(i + 4, guidCellData);
|
||||
|
||||
float ratioValue = Float.NaN;
|
||||
float diffValue = Float.NaN;
|
||||
|
||||
// If guidance is NaN then it cannot be > 0
|
||||
if (!qpe.isNaN() && (guidance > 0.0f)) {
|
||||
ratioValue = FFMPUtils.getRatioValue(qpe, guidance);
|
||||
|
@ -433,7 +430,6 @@ public class FFMPDataGenerator {
|
|||
FIELDS.RATIO, ratioValue));
|
||||
trd.setTableCellData(i + 6, new FFMPTableCellData(
|
||||
FIELDS.DIFF, diffValue));
|
||||
|
||||
i += 3;
|
||||
}
|
||||
} else {
|
||||
|
@ -441,7 +437,6 @@ public class FFMPDataGenerator {
|
|||
}
|
||||
|
||||
tData.addDataRow(trd);
|
||||
|
||||
}
|
||||
} else {
|
||||
displayName = getDisplayName(cBasin);
|
||||
|
@ -497,15 +492,12 @@ public class FFMPDataGenerator {
|
|||
guidance = Float.NaN;
|
||||
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
||||
forceUtil.setSliderTime(sliderTime);
|
||||
|
||||
FFMPTableCellData guidCellData = getGuidanceCellData(
|
||||
cBasin, domain, guidType, cBasinPfaf);
|
||||
if (guidCellData == null) {
|
||||
// check for forcing even if no data are available
|
||||
guidance = getForcedAvg(forceUtil, domain, cBasin,
|
||||
guidType);
|
||||
boolean forced = !guidance.isNaN();
|
||||
guidCellData = new FFMPTableCellData(
|
||||
FIELDS.GUIDANCE, guidance, forced);
|
||||
guidance = getForcedAvg(domain, cBasin, guidType);
|
||||
} else {
|
||||
guidance = guidCellData.getValueAsFloat();
|
||||
}
|
||||
|
@ -554,6 +546,7 @@ public class FFMPDataGenerator {
|
|||
boolean forced = false;
|
||||
Float guidance = Float.NaN;
|
||||
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
||||
forceUtil.setSliderTime(sliderTime);
|
||||
|
||||
// If aggregate, get basins within the aggregate
|
||||
if (cBasin.getAggregated()) {
|
||||
|
@ -569,6 +562,9 @@ public class FFMPDataGenerator {
|
|||
siteKey, domain, huc);
|
||||
pfafList.add(ft.getAggregatedPfaf(cBasinPfaf, siteKey, huc));
|
||||
}
|
||||
} else {
|
||||
pfafList = new ArrayList<Long>();
|
||||
pfafList.add(cBasinPfaf);
|
||||
}
|
||||
|
||||
if (FFFGDataMgr.getInstance().isForcingConfigured()) {
|
||||
|
@ -581,17 +577,19 @@ public class FFMPDataGenerator {
|
|||
forced = forceUtil.isForced();
|
||||
}
|
||||
|
||||
if (!forcedPfafs.isEmpty() || !pfafList.isEmpty()
|
||||
&& centeredAggregationKey == null) {
|
||||
FFMPBasinData basinData = guidRecords.get(guidType).getBasinData(
|
||||
ALL);
|
||||
guidance = basinData.getAverageGuidanceValue(pfafList, resource
|
||||
.getGuidanceInterpolators().get(guidType), guidance,
|
||||
forcedPfafs, resource.getGuidSourceExpiration(guidType));
|
||||
forced = !forcedPfafs.isEmpty();
|
||||
if (!forcedPfafs.isEmpty() || forced || !pfafList.isEmpty()) {
|
||||
// Recalculate guidance using the forced value(s)
|
||||
guidance = guidRecords
|
||||
.get(guidType)
|
||||
.getBasinData(ALL)
|
||||
.getAverageGuidanceValue(pfafList,
|
||||
resource.getGuidanceInterpolators().get(guidType),
|
||||
guidance, forcedPfafs,
|
||||
resource.getGuidSourceExpiration(guidType));
|
||||
} else {
|
||||
guidance = resource.getGuidanceValue(ffmpGuidBasin, paintRefTime,
|
||||
guidType);
|
||||
|
||||
if (guidance < 0.0f) {
|
||||
guidance = Float.NaN;
|
||||
}
|
||||
|
@ -600,8 +598,9 @@ public class FFMPDataGenerator {
|
|||
return new FFMPTableCellData(FIELDS.GUIDANCE, guidance, forced);
|
||||
}
|
||||
|
||||
private float getForcedAvg(FFFGForceUtil forceUtil, String domain,
|
||||
FFMPBasin cBasin, String guidType) {
|
||||
private float getForcedAvg(String domain, FFMPBasin cBasin, String guidType) {
|
||||
FFFGForceUtil forceUtil = forceUtils.get(guidType);
|
||||
forceUtil.setSliderTime(sliderTime);
|
||||
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
|
||||
List<Long> forcedPfafs;
|
||||
List<Long> pfafList = new ArrayList<Long>();
|
||||
|
@ -641,12 +640,6 @@ public class FFMPDataGenerator {
|
|||
guidance = forceUtil.getAvgForcedValue(pfafList, forcedPfafs,
|
||||
resource.getGuidanceInterpolators().get(guidType),
|
||||
resource.getGuidSourceExpiration(guidType), ft);
|
||||
// } else if (forcedPfafs.size() > 1) {
|
||||
// guidance = forceUtil.getAvgForcedValue(pfafList,
|
||||
// forcedPfafs,
|
||||
// resource.getGuidanceInterpolators().get(guidType),
|
||||
// resource.getGuidSourceExpiration(), ft);
|
||||
// forced = true;
|
||||
}
|
||||
} else {
|
||||
// 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
|
||||
* 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
|
||||
* 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>
|
||||
*
|
||||
|
@ -58,10 +59,6 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*/
|
||||
@DynamicSerialize
|
||||
public class FFMPBasinData implements ISerializableObject {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8162247989509750715L;
|
||||
|
||||
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
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
private Map<String, FFMPBasin[]> orderedBasinsCache = new HashMap<String, FFMPBasin[]>();
|
||||
private final Map<String, FFMPBasin[]> orderedBasinsCache = new HashMap<String, FFMPBasin[]>();
|
||||
|
||||
/**
|
||||
* Public one arg constructor
|
||||
|
@ -690,7 +687,7 @@ public class FFMPBasinData implements ISerializableObject {
|
|||
FFMPBasin basin = this.basins.get(fvgbmd.getLookupId());
|
||||
if (basin == null) {
|
||||
basin = new FFMPVirtualGageBasin(fvgbmd.getLid(),
|
||||
fvgbmd.getLookupId(), false);
|
||||
fvgbmd.getParentPfaf(), false);
|
||||
this.basins.put(fvgbmd.getLookupId(), basin);
|
||||
}
|
||||
basins[j++] = basin;
|
||||
|
@ -702,6 +699,9 @@ public class FFMPBasinData implements ISerializableObject {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load now.
|
||||
*/
|
||||
public void loadNow() {
|
||||
synchronized (tasks) {
|
||||
if (!tasks.isEmpty()) {
|
||||
|
@ -728,6 +728,9 @@ public class FFMPBasinData implements ISerializableObject {
|
|||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void process(FloatDataRecord record) {
|
||||
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) {
|
||||
if (basin.contains(date)) {
|
||||
float curval = basin.getValue(date);
|
||||
|
|
Loading…
Add table
Reference in a new issue