From 4b9bca7a2ec0005a0996ab348d8de9542f88c769 Mon Sep 17 00:00:00 2001 From: Tom Gurney Date: Fri, 8 Jul 2016 09:56:10 -0500 Subject: [PATCH] Omaha #5733 Fix display of sea level pressure for DAT products Values from metar are in Pa; convert to hPa before storing in fssobs. Change-Id: I39e245a65001fc197737ffa5b6bfe7eca1891219 --- .../DR5733/_update_fssobs_slp_values.py | 35 +++++++++++++++++++ .../16.2.2/DR5733/update_fssobs_slp_values.sh | 22 ++++++++++++ .../plugin/fssobs/FSSObsDataTransform.java | 6 +++- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100755 deltaScripts/16.2.2/DR5733/_update_fssobs_slp_values.py create mode 100755 deltaScripts/16.2.2/DR5733/update_fssobs_slp_values.sh diff --git a/deltaScripts/16.2.2/DR5733/_update_fssobs_slp_values.py b/deltaScripts/16.2.2/DR5733/_update_fssobs_slp_values.py new file mode 100755 index 0000000000..4ae421499e --- /dev/null +++ b/deltaScripts/16.2.2/DR5733/_update_fssobs_slp_values.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python2 + +# #5733 +# Convert sea level pressure from Pa to hPa in an hdf5 file +# Do nothing if all values are already in hPa +# Author: tom.gurney@raytheon.com + +import sys +import h5py + +def main(): + if len(sys.argv) != 2: + print "usage: {} filename.h5".format(sys.argv[0]) + sys.exit(1) + + didstuff = False + try: + with h5py.File(sys.argv[1], 'r+') as f: + if 'seaLevelPress' in f: + for i, data in enumerate(f['seaLevelPress']): + if data > 10000: + f['seaLevelPress'][i] = data / 100.0 + didstuff = True + except Exception as e: + print "ERROR: " + str(sys.exc_info()[0]) + ": " + str(e) + sys.exit(1) + + if didstuff: + print "INFO: {}: updated".format(sys.argv[1]) + else: + print "INFO: {}: no update needed".format(sys.argv[1]) + + +if __name__ == "__main__": + main() diff --git a/deltaScripts/16.2.2/DR5733/update_fssobs_slp_values.sh b/deltaScripts/16.2.2/DR5733/update_fssobs_slp_values.sh new file mode 100755 index 0000000000..2856274694 --- /dev/null +++ b/deltaScripts/16.2.2/DR5733/update_fssobs_slp_values.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# #5733 +# Convert sea level pressure from Pa to hPa in all fssobs h5 files +# Author: tom.gurney@raytheon.com + +TARGET=/awips2/edex/data/hdf5/fssobs +THIS_LOCATION=$(dirname $0) +success=0 + +for item in $(find $TARGET -type f -name "*.h5"); do + $THIS_LOCATION/_update_fssobs_slp_values.py $item + if [[ $? -ne 0 ]]; then + success=1 + fi +done + +if [[ success -eq 0 ]]; then + echo INFO: No errors reported. +else + echo "ERROR: There was a problem with one or more updates; see above." +fi diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsDataTransform.java b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsDataTransform.java index 2ee96fb01f..d7f682f58d 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsDataTransform.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsDataTransform.java @@ -46,6 +46,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools; * Jul 23, 2014 3410 bclement location changed to floats * Sep 18, 2015 3873 skorolev Fixed assigning timeObs for maritime record. * Dec 02, 2015 3873 dhladky Added missing point data params. + * Jul 08, 2016 5733 tgurney Convert metar sea level pressure to mbar * * * @@ -343,7 +344,10 @@ public class FSSObsDataTransform { fssr.setTimeObs(pdv.getCalendar(TIME_OBS)); fssr.setRefHour(TimeTools.roundToNearestHour(fssr.getTimeObs())); // in mbar - fssr.setSeaLevelPress(pdv.getNumber(SEA_LEVEL_PRESS).floatValue()); + float seaLevelPress = pdv.getNumber(SEA_LEVEL_PRESS).floatValue(); + if (seaLevelPress != MISSING) { + fssr.setSeaLevelPress(seaLevelPress / 100.0f); + } // in mmHg fssr.setPressureAltimeter(pdv.getNumber(ALTIMETER).floatValue()); fssr.setPressChange3Hour(pdv.getNumber(PRESS_CHANGE3_HOUR).floatValue());