Merge "Issue #2874 RTOFS temperature unit correction and style enhancements" into development

Former-commit-id: f4a5c3ac93 [formerly de9e3602df90b1a90c352b356a8880103e61acaf]
Former-commit-id: 05756d272c
This commit is contained in:
Richard Peter 2014-04-03 16:52:46 -05:00 committed by Gerrit Code Review
commit 3c5d3fe932
8 changed files with 305 additions and 62 deletions

View file

@ -139,5 +139,5 @@
<field key="PAdv" volumePlaneType="K"/>
<field key="DpDt" volumePlaneType="K"/>
<field key="OGRD" displayTypes="ARROW,STREAMLINE"/>
<field key="SPBARO" displayTypes="ARROW,STREAMLINE"/>
<field key="BARO" displayTypes="ARROW,STREAMLINE"/>
</fieldDisplayTypesFile>

View file

@ -1,61 +1,52 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.plugin.grib.decoderpostprocessors;
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;
/**
*
* Adjusts data values on Lifted Index to match the units. Lifted index should
* always be centered around 0 however some sources go through a Celsius to
* Kelvin conversion which results in data centered around 273.15, this attempts
* to detect and revert this conversion.
* @deprecated Only exists for backwards compatibility in localization files,
* use TemperatureCorrectionPostProcessor directly in the future.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* ------------- -------- ----------- --------------------------
* Nov 18, 2010 bsteffen Initial creation
* Mar 28, 2010 2874 bsteffen Deprecated
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class LiftedIndexPostProcessor implements IDecoderPostProcessor {
@Deprecated
public class LiftedIndexPostProcessor extends
TemperatureCorrectionPostProcessor {
private static final List<String> 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 };
public LiftedIndexPostProcessor() throws GribException {
super();
}
}

View file

@ -0,0 +1,221 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.plugin.grib.decoderpostprocessors;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.SI;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.edex.plugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.localization.FileUpdatedMessage;
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.parameter.Parameter;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
*
* Adjusts temperature values that are mislabled as Celsius or Kelvin when they
* actually represent the other one. Loads a list of parameters and thresholds
* from a localization file. Assumes that all values above the threshold for a
* parameter 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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Mar 28, 2010 2874 bsteffen Initial creation
*
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class TemperatureCorrectionPostProcessor implements
IDecoderPostProcessor, ILocalizationFileObserver {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(TemperatureCorrectionPostProcessor.class);
private static final String LOCALIZATON_LOCATION = "grib"
+ IPathManager.SEPARATOR + "temperatureCorrectionParameters.xml";
private static final UnitConverter k2c = SI.KELVIN
.getConverterTo(SI.CELSIUS);
private static final UnitConverter c2k = SI.CELSIUS
.getConverterTo(SI.KELVIN);
private Map<String, Double> paramThresholdMap;
public TemperatureCorrectionPostProcessor() throws GribException {
LocalizationFile file = readConfiguration();
if (file != null) {
file.addFileUpdatedObserver(this);
}
}
protected LocalizationFile readConfiguration() throws GribException {
LocalizationFile file = PathManagerFactory.getPathManager()
.getStaticLocalizationFile(LOCALIZATON_LOCATION);
Map<String, Double> paramThresholdMap = new HashMap<String, Double>(8);
if (file != null && file.exists()) {
JAXBManager manager = null;
try {
manager = new JAXBManager(TemperatureCorrectionParameters.class);
} catch (JAXBException e) {
/* No hope of recovering */
throw new GribException(
"Error occured preparing to load temperate correction parameters.",
e);
}
TemperatureCorrectionParameters params = null;
try {
params = file.jaxbUnmarshal(
TemperatureCorrectionParameters.class, manager);
} catch (LocalizationException e) {
/* Some hope of recovering with a better file. */
statusHandler
.error("Error occured loading temperate correction parameters, verify the file is formatted correctly.",
e);
}
if (params != null) {
for (TemperatureCorrectionParameter param : params
.getParameters()) {
paramThresholdMap.put(param.getAbbreviation(),
param.getThreshold());
}
}
}
this.paramThresholdMap = paramThresholdMap;
return file;
}
@Override
public void fileUpdated(FileUpdatedMessage message) {
try {
readConfiguration();
} catch (GribException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
@Override
public GridRecord[] process(GridRecord record) throws GribException {
Parameter parameter = record.getParameter();
Double thresholdObject = paramThresholdMap.get(parameter
.getAbbreviation());
if (thresholdObject != null) {
Object messageData = record.getMessageData();
if (messageData instanceof float[]) {
double threshold = thresholdObject.doubleValue();
if (parameter.getUnit().equals(SI.CELSIUS)) {
float[] data = (float[]) record.getMessageData();
for (int i = 0; i < data.length; i++) {
if (data[i] > threshold) {
data[i] = (float) k2c.convert(data[i]);
}
}
} else if (parameter.getUnit().equals(SI.KELVIN)) {
float[] data = (float[]) record.getMessageData();
for (int i = 0; i < data.length; i++) {
if (data[i] < threshold && data[i] > -273.15) {
data[i] = (float) c2k.convert(data[i]);
}
}
}
} else {
statusHandler.warn(this.getClass().getSimpleName()
+ " is not checking " + record
+ " because the messageData is " + messageData);
}
}
return new GridRecord[] { record };
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public static class TemperatureCorrectionParameters {
@XmlElement(name = "parameter")
private List<TemperatureCorrectionParameter> parameters;
public List<TemperatureCorrectionParameter> getParameters() {
return parameters;
}
public void setParameters(
List<TemperatureCorrectionParameter> parameters) {
this.parameters = parameters;
}
}
@XmlAccessorType(XmlAccessType.NONE)
public static class TemperatureCorrectionParameter {
@XmlAttribute
private String abbreviation;
@XmlAttribute
private double threshold;
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public double getThreshold() {
return threshold;
}
public void setThreshold(double threshold) {
this.threshold = threshold;
}
}
}

View file

@ -40,26 +40,12 @@
<processorName>FFGGribPostProcessor</processorName>
</postProcessedModel>
<!-- Post processor definitions for models using the lifted index post processor -->
<!-- Post processor definitions for models using the temperature correction
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 -->
<postProcessedModel>
<modelName>ETA218</modelName>
<processorName>LiftedIndexPostProcessor</processorName>
</postProcessedModel>
<postProcessedModel>
<modelName>GFS212</modelName>
<processorName>LiftedIndexPostProcessor</processorName>
</postProcessedModel>
<postProcessedModel>
<modelName>GFS213</modelName>
<processorName>GFSProcessor</processorName>
<processorName>LiftedIndexPostProcessor</processorName>
</postProcessedModel>
<postProcessedModel>
<modelName>ETA242</modelName>
<processorName>LiftedIndexPostProcessor</processorName>
<modelName>ETA218|GFS212|GFS213|ETA242|RTOFS-.*</modelName>
<processorName>TemperatureCorrectionPostProcessor</processorName>
</postProcessedModel>
<!-- Post processor definition for the RTMA model -->

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- This_software_was_developed_and_/_or_modified_by_Raytheon_Company, pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization. Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340 ________________________Mail_Stop_B8
________________________Omaha,_NE_68106 ________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for further_licensing_information. -->
<temperatureCorrectionParameters>
<!-- This file is used by the TemperatureCorrectionPostProcessor to determine
which parameters need to be checked to verify the units match the data. The
post processor assumes that all values above the threshold for a parameter
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 -->
<parameter abbreviation="BLI" threshold="150" />
<parameter abbreviation="SLI" threshold="150" />
<parameter abbreviation="PLI" threshold="150" />
<parameter abbreviation="TEMPWTR" threshold="150" />
</temperatureCorrectionParameters>

View file

@ -132,4 +132,13 @@
<displayUnits label="gm/kgs">g*m/(kg*s)</displayUnits>
</arrowStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>OGRD</parameter>
<parameter>BARO</parameter>
</paramLevelMatches>
<arrowStyle>
<displayUnits>m/min</displayUnits>
</arrowStyle>
</styleRule>
</styleRuleset>

View file

@ -4158,5 +4158,13 @@ in | .03937 | 0 | 4 | | |..|8000F0FF| | 16 | \
<values>-15 -5 0</values>
</contourLabeling>
</contourStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>TEMPWTR</parameter>
</paramLevelMatches>
<contourStyle>
<displayUnits>C</displayUnits>
</contourStyle>
</styleRule>
</styleRuleset>

View file

@ -4892,4 +4892,12 @@
</imageStyle>
</styleRule>
<!-- </sourceTag>ER-sportsst -->
<styleRule>
<paramLevelMatches>
<parameter>TEMPWTR</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
</imageStyle>
</styleRule>
</styleRuleset>