From 3bcda660747c0aa75a3d62ee4e41fdc4a50fd053 Mon Sep 17 00:00:00 2001 From: Melissa Porricel Date: Wed, 24 Feb 2016 13:42:59 -0500 Subject: [PATCH] ASM #17308 - Correct lifted index units Change-Id: I872a48255c137d7221b6cd2be7f70e9d2171d617 Former-commit-id: 3b5ddbed8f115eba688e0b48893a910e1f036972 --- .../LiftedIndexPostProcessor.java | 53 +++++++++++++----- .../postProcessModels/postProcessedModels.xml | 7 ++- .../grib/temperatureCorrectionParameters.xml | 3 - .../base/styleRules/d2dContourStyleRules.xml | 39 ++----------- .../base/styleRules/gridImageryStyleRules.xml | 55 ++++++------------- 5 files changed, 70 insertions(+), 87 deletions(-) diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/LiftedIndexPostProcessor.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/LiftedIndexPostProcessor.java index ffb4621576..de5a4a321e 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/LiftedIndexPostProcessor.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/LiftedIndexPostProcessor.java @@ -19,34 +19,61 @@ **/ package com.raytheon.edex.plugin.grib.decoderpostprocessors; -import com.raytheon.edex.plugin.grib.exception.GribException; +import java.util.Arrays; +import java.util.List; +import javax.measure.converter.UnitConverter; +import javax.measure.unit.SI; + +import com.raytheon.edex.plugin.grib.exception.GribException; +import com.raytheon.uf.common.dataplugin.grid.GridRecord; /** * - * @deprecated Only exists for backwards compatibility in localization files, - * use TemperatureCorrectionPostProcessor directly in the future. + * Adjusts data values on Lifted Index to store as Celcius values. * - *
+ * 
  * 
  * SOFTWARE HISTORY
  * 
- * Date          Ticket#  Engineer    Description
- * ------------- -------- ----------- --------------------------
- * Nov 18, 2010           bsteffen    Initial creation
- * Mar 28, 2010  2874     bsteffen    Deprecated
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 18, 2010            bsteffen     Initial creation
+ * Mar 28, 2010  2874      bsteffen     Deprecated
+ * Jan 07, 2016  DR17308   MPorricelli  Reinstated 
  * 
  * 
* * @author bsteffen * @version 1.0 */ -@Deprecated -public class LiftedIndexPostProcessor extends - TemperatureCorrectionPostProcessor { +public class LiftedIndexPostProcessor extends DecoderPostProcessor { - public LiftedIndexPostProcessor() throws GribException { - super(); + private static final List LIFTED_INDEX_PARAMETERS = Arrays.asList( + "SLI", "BLI", "PLI"); + + private static final String KELVIN_UNIT_STRING = "K"; + + private static final float MAX_VALID = 150; + + private static final UnitConverter k2c = SI.KELVIN + .getConverterTo(SI.CELSIUS); + + @Override + public GridRecord[] process(GridRecord record) throws GribException { + // Change units of Lifted Index to match the data + if (LIFTED_INDEX_PARAMETERS.contains(record.getParameter() + .getAbbreviation()) + && KELVIN_UNIT_STRING.equals(record.getParameter() + .getUnitString())) { + float[] data = (float[]) record.getMessageData(); + for (int i = 0; i < data.length; i++) { + if (data[i] > MAX_VALID) { + data[i] = (float) k2c.convert(data[i]); + } + } + } + return new GridRecord[] { record }; } } diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/postProcessModels/postProcessedModels.xml b/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/postProcessModels/postProcessedModels.xml index 9b7a205507..19e924a448 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/postProcessModels/postProcessedModels.xml +++ b/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/postProcessModels/postProcessedModels.xml @@ -29,10 +29,15 @@ post processor. These models may have some parameters which are incorrectly labeled Celsius vs. Kelvin. The list of parameters to correct is in temperatureCorrectionParameters.xml --> - ETA218|GFS212|GFS213|ETA242|RTOFS-.* + RTOFS-.* TemperatureCorrectionPostProcessor + + GFS.*|ETA.*|DGEX.*|HiResW.* + LiftedIndexPostProcessor + + RTMA diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/temperatureCorrectionParameters.xml b/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/temperatureCorrectionParameters.xml index 2b3456a869..43b75ae3d8 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/temperatureCorrectionParameters.xml +++ b/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/temperatureCorrectionParameters.xml @@ -13,8 +13,5 @@ are in Kelvin and will convert if the declared unit is Celsius. Values below the threshold are assumed to be in Celsius and will be converted if the declared unit is Kelvin --> - - - diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/d2dContourStyleRules.xml b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/d2dContourStyleRules.xml index d07921f6b2..6c0c5e45b5 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/d2dContourStyleRules.xml +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/d2dContourStyleRules.xml @@ -1204,33 +1204,20 @@ mb | 1 | 0.0 | 4 |2:i4|1:i4|LH|8000F0FF| | 0 | 2 - - - PLI - - - C - - 2 - - - - - + SLI + PLI + BLI - - C + + K NoPlane 2 - @@ -1247,20 +1234,6 @@ C | 1 | 0 | 4 | | |..|8000F0FF|,900| 0 | 2 - - - - BLI - - - C - - 2 - - - @@ -2796,7 +2769,7 @@ C | 1 | 0 | 4 | | |..|8000F0FF|,,,80 | 0 | 2 80 - C + K NoPlane 2 diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/gridImageryStyleRules.xml b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/gridImageryStyleRules.xml index da67696335..f97d36f94e 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/gridImageryStyleRules.xml +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/utility/common_static/base/styleRules/gridImageryStyleRules.xml @@ -1735,43 +1735,24 @@ * SLI C | 1 | 0 | -15 | 15 | | | 29 | 0 | 4 --> - - - SLI - PLI - - - C - - -15 - 15 - - Grid/gridded data - - 4 - - - - - - - BLI - - - C - - -15 - 15 - - Grid/gridded data - - 4 - - - + + + SLI + PLI + BLI + + + K + + -15 + 15 + + Grid/gridded data + + 4 + + +