Issue #1902 - fix to forced guidance
Peer review comments Change-Id: I5c42fad454e42e5697d32e183702de535ecc3e5e Former-commit-id:2a733fa5f8
[formerly11423a7465
[formerly ebd633109a62e7a2d8a0b8e3083aaf5680766739]] Former-commit-id:11423a7465
Former-commit-id:b331a68a08
This commit is contained in:
parent
df612396fb
commit
44ef119c41
3 changed files with 159 additions and 55 deletions
|
@ -24,7 +24,6 @@ import java.util.List;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPGuidanceInterpolation;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPTemplates;
|
||||
import com.raytheon.uf.common.monitor.config.FFFGDataMgr;
|
||||
import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager;
|
||||
|
@ -44,6 +43,7 @@ import com.raytheon.uf.common.monitor.xml.SourceXML;
|
|||
* 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.
|
||||
* 05/22/13 1902 mpduff Added methods to get forced values.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -135,10 +135,8 @@ public class FFFGForceUtil {
|
|||
pfafList = ft.getAggregatePfafs(cBasin.getPfaf(),
|
||||
resource.getSiteKey(), resource.getHuc());
|
||||
} else if (!domain.equals("NA")) {
|
||||
if (!resource.getHuc().equals(FFMPRecord.ALL)) {
|
||||
pfafList = ft.getAggregatePfafsByDomain(cBasin.getPfaf(),
|
||||
resource.getSiteKey(), domain, resource.getHuc());
|
||||
}
|
||||
} // else use the existing pfaf list
|
||||
|
||||
// Add current pfaf to the list
|
||||
|
@ -253,7 +251,7 @@ public class FFFGForceUtil {
|
|||
float tvalue = 0.0f;
|
||||
float value;
|
||||
int i = 0;
|
||||
if (interpolation.isInterpolate() == false) {
|
||||
if (!interpolation.isInterpolate()) {
|
||||
FFFGDataMgr dman = FFFGDataMgr.getInstance();
|
||||
for (long pfaf : forcedPfafs) {
|
||||
long countyFips = templates.getCountyFipsByPfaf(pfaf);
|
||||
|
@ -266,6 +264,49 @@ public class FFFGForceUtil {
|
|||
}
|
||||
|
||||
return tvalue / i;
|
||||
} else {
|
||||
// TODO interpolated code under new ticket
|
||||
}
|
||||
|
||||
return Float.NaN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max forced value (max is smallest number for FFG)
|
||||
*
|
||||
* @param pfafList
|
||||
* list of pfaf ids
|
||||
* @param forcedPfafs
|
||||
* list of forced pfaf ids
|
||||
* @param interpolation
|
||||
* FFMPGuidanceInterpolation object
|
||||
* @param expiration
|
||||
* force expiration
|
||||
* @param templates
|
||||
* ffmp templates
|
||||
* @return max forced value
|
||||
*/
|
||||
public float getMaxForcedValue(List<Long> pfafList, List<Long> forcedPfafs,
|
||||
FFMPGuidanceInterpolation interpolation, long expiration,
|
||||
FFMPTemplates templates) {
|
||||
float tvalue = 0.0f;
|
||||
float value;
|
||||
if (!interpolation.isInterpolate()) {
|
||||
FFFGDataMgr dman = FFFGDataMgr.getInstance();
|
||||
for (long pfaf : forcedPfafs) {
|
||||
long countyFips = templates.getCountyFipsByPfaf(pfaf);
|
||||
templates.getCountyFipsByPfaf(pfaf);
|
||||
value = dman.adjustValue(Float.NaN,
|
||||
interpolation.getStandardSource(), pfaf, countyFips);
|
||||
|
||||
if (value < tvalue) {
|
||||
tvalue = value;
|
||||
}
|
||||
}
|
||||
|
||||
return tvalue;
|
||||
} else {
|
||||
// TODO interpolated code
|
||||
}
|
||||
|
||||
return Float.NaN;
|
||||
|
@ -315,4 +356,40 @@ public class FFFGForceUtil {
|
|||
public void setSliderTime(double sliderTime) {
|
||||
this.sliderTime = sliderTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the forced values for the pfaf list.
|
||||
*
|
||||
* @param pfafList
|
||||
* list of pfaf ids
|
||||
* @param forcedPfafs
|
||||
* list of forced pfafs
|
||||
* @param ffmpGuidanceInterpolation
|
||||
* FFMPGuidanceInterpolation object
|
||||
* @param guidSourceExpiration
|
||||
* expiration time
|
||||
* @param ft
|
||||
* ffmp templates
|
||||
* @return list of forced guidance values
|
||||
*/
|
||||
public List<Float> getForcedGuidValues(List<Long> pfafList,
|
||||
List<Long> forcedPfafs,
|
||||
FFMPGuidanceInterpolation ffmpGuidanceInterpolation,
|
||||
long guidSourceExpiration, FFMPTemplates ft) {
|
||||
List<Float> guidList = new ArrayList<Float>();
|
||||
if (pfafList != null) {
|
||||
for (Long pfaf : pfafList) {
|
||||
if (pfaf == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Long> pl = new ArrayList<Long>();
|
||||
pl.add(pfaf);
|
||||
float val = getAvgForcedValue(pl, forcedPfafs,
|
||||
ffmpGuidanceInterpolation, guidSourceExpiration, ft);
|
||||
guidList.add(val);
|
||||
}
|
||||
}
|
||||
return guidList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FfmpTableConfigData;
|
|||
* 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
|
||||
* May 22, 2013 1902 mpduff Code cleanup.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -207,10 +208,8 @@ public class FFMPDataGenerator {
|
|||
setFFMPRow(fbd.get(key), tData, false,
|
||||
cwa);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Couldn't create table row"
|
||||
+ e);
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Couldn't create table row", e);
|
||||
}
|
||||
if (virtualBasin != null) {
|
||||
for (Long id : ft
|
||||
|
@ -257,10 +256,8 @@ public class FFMPDataGenerator {
|
|||
setFFMPRow(fbd.get(key), tData, isVGB,
|
||||
null);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Couldn't create table row"
|
||||
+ e);
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Couldn't create table row", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,10 +290,10 @@ public class FFMPDataGenerator {
|
|||
virtualBasin.get(id),
|
||||
tData, true, null);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Couldn't create table row"
|
||||
+ e);
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Couldn't create table row",
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -414,6 +411,11 @@ public class FFMPDataGenerator {
|
|||
if (guidCellData == null) {
|
||||
// check for forcing even if no data are available
|
||||
guidance = getForcedAvg(domain, cBasin, guidType);
|
||||
boolean forced = !guidance.isNaN();
|
||||
guidCellData = new FFMPTableCellData(
|
||||
FIELDS.GUIDANCE, guidance, forced);
|
||||
} else {
|
||||
guidance = guidCellData.getValueAsFloat();
|
||||
}
|
||||
|
||||
trd.setTableCellData(i + 4, guidCellData);
|
||||
|
@ -440,7 +442,6 @@ public class FFMPDataGenerator {
|
|||
}
|
||||
} else {
|
||||
displayName = getDisplayName(cBasin);
|
||||
|
||||
if (displayName != null) {
|
||||
long cBasinPfaf = cBasin.getPfaf();
|
||||
String cBasinPfafStr = Long.toString(cBasinPfaf);
|
||||
|
@ -498,6 +499,9 @@ public class FFMPDataGenerator {
|
|||
if (guidCellData == null) {
|
||||
// check for forcing even if no data are available
|
||||
guidance = getForcedAvg(domain, cBasin, guidType);
|
||||
boolean forced = !guidance.isNaN();
|
||||
guidCellData = new FFMPTableCellData(
|
||||
FIELDS.GUIDANCE, guidance, forced);
|
||||
} else {
|
||||
guidance = guidCellData.getValueAsFloat();
|
||||
}
|
||||
|
@ -587,13 +591,15 @@ public class FFMPDataGenerator {
|
|||
guidance, forcedPfafs,
|
||||
resource.getGuidSourceExpiration(guidType));
|
||||
} else {
|
||||
guidance = resource.getGuidanceValue(ffmpGuidBasin, paintRefTime,
|
||||
guidType);
|
||||
if (ffmpGuidBasin != null) {
|
||||
guidance = resource.getGuidanceValue(ffmpGuidBasin,
|
||||
paintRefTime, guidType);
|
||||
|
||||
if (guidance < 0.0f) {
|
||||
guidance = Float.NaN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new FFMPTableCellData(FIELDS.GUIDANCE, guidance, forced);
|
||||
}
|
||||
|
@ -783,8 +789,6 @@ public class FFMPDataGenerator {
|
|||
FFMPBasinData guidBasin = guidBasins.get(guidType);
|
||||
|
||||
List<Long> pfafList = new ArrayList<Long>();
|
||||
if ((guidBasin != null)
|
||||
&& (!guidBasin.getBasins().isEmpty())) {
|
||||
if (cBasin.getAggregated()) {
|
||||
pfafList = ft.getAggregatePfafs(cBasin.getPfaf(),
|
||||
siteKey, huc);
|
||||
|
@ -803,11 +807,12 @@ public class FFMPDataGenerator {
|
|||
}
|
||||
|
||||
if (!forced) {
|
||||
if ((forcedPfafs != null)
|
||||
&& (!forcedPfafs.isEmpty())) {
|
||||
if ((forcedPfafs != null) && (!forcedPfafs.isEmpty())) {
|
||||
forced = true;
|
||||
}
|
||||
}
|
||||
if ((guidBasin != null)
|
||||
&& (!guidBasin.getBasins().isEmpty())) {
|
||||
|
||||
if (isWorstCase) {
|
||||
guidance = guidRecords
|
||||
|
@ -830,8 +835,19 @@ public class FFMPDataGenerator {
|
|||
trd.setTableCellData(i + 4, new FFMPTableCellData(
|
||||
FIELDS.GUIDANCE, guidance, forced));
|
||||
} else {
|
||||
if (forced) {
|
||||
// Recalculate guidance using the forced value(s)
|
||||
guidance = forceUtil.getMaxForcedValue(
|
||||
pfafList,
|
||||
forcedPfafs,
|
||||
resource.getGuidanceInterpolators().get(
|
||||
guidType), resource
|
||||
.getGuidSourceExpiration(guidType),
|
||||
ft);
|
||||
}
|
||||
|
||||
trd.setTableCellData(i + 4, new FFMPTableCellData(
|
||||
FIELDS.GUIDANCE, Float.NaN));
|
||||
FIELDS.GUIDANCE, guidance, forced));
|
||||
}
|
||||
|
||||
// If guidance is NaN then it cannot be > 0
|
||||
|
@ -846,6 +862,14 @@ public class FFMPDataGenerator {
|
|||
guids = guidBasin.getGuidanceValues(pfafs, resource
|
||||
.getGuidanceInterpolators().get(guidType),
|
||||
resource.getGuidSourceExpiration(guidType));
|
||||
} else if (forced) {
|
||||
guids = forceUtil.getForcedGuidValues(
|
||||
pfafList,
|
||||
forcedPfafs,
|
||||
resource.getGuidanceInterpolators().get(
|
||||
guidType), resource
|
||||
.getGuidSourceExpiration(guidType),
|
||||
ft);
|
||||
}
|
||||
|
||||
if ((!qpes.isEmpty())
|
||||
|
|
|
@ -72,6 +72,7 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.listeners.FFMPLoaderEvent;
|
|||
* Apr 9, 2013 1890 dhladky removed loading of phantom Virtual template and cache file processing.
|
||||
* Apr 18, 2013 1912 bsteffen Increase bulk requests to pypies.
|
||||
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
|
||||
* May 22, 2013 1902 mpduff Check for null times.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -105,9 +106,9 @@ public class FFMPDataLoader extends Thread {
|
|||
|
||||
private FFMPConfig config = null;
|
||||
|
||||
private ArrayList<FFMPLoadListener> loadListeners = new ArrayList<FFMPLoadListener>();
|
||||
private final ArrayList<FFMPLoadListener> loadListeners = new ArrayList<FFMPLoadListener>();
|
||||
|
||||
private CountDownLatch latch;
|
||||
private final CountDownLatch latch;
|
||||
|
||||
public FFMPDataLoader(FFMPResourceData resourceData, Date timeBack,
|
||||
Date mostRecentTime, LOADER_TYPE loadType, List<String> hucsToLoad) {
|
||||
|
@ -195,9 +196,8 @@ public class FFMPDataLoader extends Thread {
|
|||
}
|
||||
if ((loadType == LOADER_TYPE.INITIAL || loadType == LOADER_TYPE.GENERAL)
|
||||
&& !product.getRate().equals(product.getQpe())) {
|
||||
Map<Date, List<String>> rateURIs = monitor
|
||||
.getAvailableUris(siteKey, dataKey, product.getRate(),
|
||||
mostRecentTime);
|
||||
Map<Date, List<String>> rateURIs = monitor.getAvailableUris(
|
||||
siteKey, dataKey, product.getRate(), mostRecentTime);
|
||||
if (rateURIs.containsKey(mostRecentTime)) {
|
||||
rateURI = rateURIs.get(mostRecentTime).get(0);
|
||||
}
|
||||
|
@ -243,11 +243,13 @@ public class FFMPDataLoader extends Thread {
|
|||
|
||||
NavigableMap<Date, List<String>> iguidURIs = null;
|
||||
Date guidTime = timeBack;
|
||||
|
||||
if (loadType == LOADER_TYPE.GENERAL) {
|
||||
guidTime = monitor.getPreviousQueryTime(siteKey,
|
||||
guidSource.getSourceName());
|
||||
}
|
||||
if (guidTime == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
iguidURIs = monitor.getAvailableUris(siteKey, dataKey,
|
||||
guidSource.getSourceName(), guidTime);
|
||||
|
@ -295,7 +297,8 @@ public class FFMPDataLoader extends Thread {
|
|||
qpeCache = readAggregateRecord(source, dataKey, wfo);
|
||||
|
||||
if (qpeCache != null) {
|
||||
monitor.insertFFMPData(qpeCache, qpeURIs, siteKey, product.getQpe());
|
||||
monitor.insertFFMPData(qpeCache, qpeURIs, siteKey,
|
||||
product.getQpe());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue