Omaha #4756 Create postprocessors and metadata for ARI FFG grids

Change-Id: I0777f0352efe91d9e67cba4e82087308fbbead97

Former-commit-id: 1dc1898268e7b6d0eefc3fdb8e2f5aee561fd368
This commit is contained in:
Dave Hladky 2015-09-22 15:53:27 -05:00 committed by Gerrit Code Review
parent 2e4c044ae0
commit 09b7694c18
6 changed files with 234 additions and 3 deletions

View file

@ -397,6 +397,10 @@ class GribDecoder():
record.addExtraAttribute("backGenprocess", Integer(gribDict['backGenprocess']))
record.addExtraAttribute("pdsTemplate", Integer(gribDict['ipdtnum']))
record.addExtraAttribute("gridid", gridCoverage.getName())
if "forecastInterval" in gribDict:
record.addExtraAttribute("forecastInterval", gribDict['forecastInterval'])
if "forecastIntervalUnit" in gribDict:
record.addExtraAttribute("forecastIntervalUnit", gribDict['forecastIntervalUnit'])
if "numForecasts" in gribDict:
record.addExtraAttribute("numForecasts", gribDict['numForecasts'])
@ -477,9 +481,12 @@ class GribDecoder():
if levelName is None or len(levelName) == 0:
levelName = LevelFactory.UNKNOWN_LEVEL
# Convert the forecast time to seconds
gribDict['forecastTime'] = self._convertToSeconds(pdsTemplate[8], pdsTemplate[7])
# harvest forecast interval for longer term models to post process
gribDict['forecastInterval'] = Integer(int(pdsTemplate[8]))
gribDict['forecastIntervalUnit'] = Integer(int(pdsTemplate[7]))
# Scale the level one value if necessary
if pdsTemplate[10] == 0 or pdsTemplate[11] == 0:
@ -1150,7 +1157,7 @@ class GribDecoder():
# @param value: The value to convert to seconds
# @param fromUnit: The value from Table 4.4 to convert from
# @return: The number of seconds of the provided value
# @rtype: long
# @rtype: int
##
def _convertToSeconds(self, value, fromUnit):
@ -1201,7 +1208,7 @@ class GribDecoder():
retVal = value * 12 * SECONDS_PER_HOUR
return int(retVal)
def _getGridModel(self, gribDict, grid):
center = gribDict['center']
subcenter = gribDict['subcenter']

View file

@ -0,0 +1,145 @@
/**
* 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 com.raytheon.edex.plugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
/**
* The ARIPostProcessor is a grib post processor implementation to update
* parameter and time definitions that come for the Archival Recurrence Interval
* FFG grids.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Sep 21, 2015 4756 dhladky Initial Creation
*
* </pre>
*
* @author dhladky
* @version 1
* */
public class ARIPostProcessor implements IDecoderPostProcessor {
/** name of extraAttribute variable from GribDecoder.py */
private static final String FORECAST_INTERVAL = "forecastInterval";
/** name of extraAttribute variable from GribDecoder.py */
private static final String FORECAST_INTERVAL_UNIT = "forecastIntervalUnit";
/** 30 minute record identifier **/
private static final String REFZC = "REFZC";
/** 1 hr record identifier **/
private static final String REFZI = "REFZI";
/** Year **/
private static final String YR = "YR";
/** ARI (Archival Recurrence Interval **/
private static final String ARI = "ARI";
/** 30 min comparison time **/
private static final String MIN30 = "30";
/** 1 hour comparison time **/
private static final String HOUR1 = "1";
/** ARI is precip in mm **/
private static final String UNIT = "mm";
@Override
public GridRecord[] process(GridRecord record) throws GribException {
// With ARI we assume the FORECAST_INTERVAL is in years.
if (record.getExtraAttribute(FORECAST_INTERVAL) != null
&& record.getExtraAttribute(FORECAST_INTERVAL_UNIT) != null) {
// just to be certain about year encoding
int forecast_unit = (Integer) record
.getExtraAttribute(FORECAST_INTERVAL_UNIT);
if (forecast_unit == 4) {
int forecastYear = (Integer) record
.getExtraAttribute(FORECAST_INTERVAL);
record = setParameterIdentifier(record, forecastYear);
// Alter the forecast time in the record to 0 so pypies can
// handle
// it.
record.getDataTime().setFcstTime(0);
} else {
throw new IllegalArgumentException(
"Forecast_Interval_Unit encoded for years should == 4, value: "
+ forecast_unit);
}
} else {
throw new IllegalArgumentException(
"No Forecast_Interval available for this grid: "
+ record.getDataURI());
}
return new GridRecord[] { record };
}
/**
* Create a new parameter abbreviation based on the forecast year and
* interval period.
*
* @param record
* @param forecastYear
* @return
*/
private GridRecord setParameterIdentifier(GridRecord record,
int forecastYear) {
String paramAbbrev = record.getInfo().getParameter().getAbbreviation();
StringBuilder sb = new StringBuilder(64);
StringBuilder sb2 = new StringBuilder(256);
sb.append(ARI);
sb.append(Integer.toString(forecastYear));
sb2.append(Integer.toString(forecastYear));
sb2.append(" ");
sb.append(YR);
sb2.append(YR);
sb2.append(" ");
if (REFZC.equals(paramAbbrev)) {
sb.append(MIN30);
sb2.append("30 minute precip");
} else if (REFZI.equals(paramAbbrev)) {
sb.append(HOUR1);
sb2.append("1 hour precip");
} else {
throw new IllegalArgumentException("ARI paramName " + paramAbbrev
+ " is not a valid param for ARI postprocessing");
}
// Give it a new name/description/unit
record.getParameter().setAbbreviation(sb.toString());
record.getParameter().setName(sb2.toString());
record.getParameter().setUnitString(UNIT);
return record;
}
}

View file

@ -0,0 +1,32 @@
<?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.
-->
<latLonGridCoverage>
<name>ARI</name>
<description>Archival Recurrence Interval Grids (1-1000yr FFG)</description>
<la1>55.005</la1>
<lo1>229.994994</lo1>
<firstGridPointCorner>UpperLeft</firstGridPointCorner>
<nx>7001</nx>
<ny>3501</ny>
<dx>0.01</dx>
<dy>0.01</dy>
<spacingUnit>degree</spacingUnit>
</latLonGridCoverage>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<gribModelSet>
<model>
<name>ARI</name>
<center>161</center>
<subcenter>1</subcenter>
<grids>
<id>ARI</id>
</grids>
<process>
<id>100</id>
</process>
</model>
</gribModelSet>

View file

@ -137,5 +137,11 @@
</postProcessedModel>
-->
<!-- Post Processor for ARI grids (FFG source for FFMP) -->
<postProcessedModel>
<modelName>ARI</modelName>
<processorName>ARIPostProcessor</processorName>
</postProcessedModel>
</postProcessedModels>

View file

@ -0,0 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?>
<subGridDef>
<modelNames>ARI</modelNames>
<referenceGrid>ARI</referenceGrid>
<shiftWest>false</shiftWest>
<nx>1000</nx>
<ny>1000</ny>
</subGridDef>