Merge "Issue #2336 Switch grib logging to use UFStatusHandler." into development

Former-commit-id: 6a83ba8cc0 [formerly 3981531a8076c818967c6d8f4233c0766631d95e]
Former-commit-id: c3802f2175
This commit is contained in:
Richard Peter 2013-09-06 14:07:49 -05:00 committed by Gerrit Code Review
commit 6bb201cae8
2 changed files with 34 additions and 33 deletions

View file

@ -22,7 +22,8 @@ import grib2
import numpy
from math import pow
import time, os, sys, math
import LogStream
import logging
import UFStatusHandler
import tempfile
from matplotlib.mlab import griddata
@ -122,14 +123,16 @@ THINNED_GRID_VALUES = THINNED_GRID_PT_MAP.values()
# library to access the NCEP grib decoder for extracting data
#
#
# SOFTWARE HISTORY
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 04/7/09 #1994 bphillip Initial Creation.
# Mar 25, 2013 1821 bsteffen Reshape grib data arrays in
# place to improve performance.
# Sep 04, 2013 2298 rjpeter Removed setPluginName call
# Date Ticket# Engineer Description
# ------------- -------- ----------- --------------------------
# Apr 07, 2009 1994 bphillip Initial Creation.
# Mar 25, 2013 1821 bsteffen Reshape grib data arrays in place to
# improve performance.
# Sep 04, 2013 2298 rjpeter Removed setPluginName call
# Sep 06, 2013 2336 bsteffen Switch from logstream to logging with
# UFStatusHandler.
class GribDecoder():
##
@ -141,7 +144,10 @@ class GribDecoder():
def __init__(self, text=None, filePath=None):
# Assign public file name
self.fileName = filePath
self.log = logging.getLogger("GribDecoder")
self.log.addHandler(UFStatusHandler.UFStatusHandler("com.raytheon.edex.plugin.grib", "EDEX"))
##
# Decodes the grib file
@ -166,7 +172,7 @@ class GribDecoder():
else:
decodeFile = self.fileName
if decodeFile == None:
LogStream.logProblem("Could not get final filename to decode: [", self.fileName, "]")
self.log.error("Could not get final filename to decode: [" + self.fileName + "]")
return records
gribFile = open(decodeFile, "rb")
@ -193,7 +199,7 @@ class GribDecoder():
recordIndex = recordIndex + 1
fieldIndex = 0
except:
LogStream.logProblem("Error processing file [", self.fileName, "]: ", LogStream.exc())
self.log.exception("Error processing file [" + self.fileName + "]: ")
finally:
gribFile.close()
@ -526,7 +532,7 @@ class GribDecoder():
parameterAbbreviation = parameter.getAbbreviation()
parameterUnit = parameter.getUnit()
else:
LogStream.logEvent("No parameter information for center[" + str(centerID) + "], subcenter[" +
self.log.info("No parameter information for center[" + str(centerID) + "], subcenter[" +
str(subcenterID) + "], tableName[" + tableName +
"], parameter value[" + str(pdsTemplate[1]) + "]");
parameterName = MISSING
@ -543,7 +549,7 @@ class GribDecoder():
levelName = gribLevel.getAbbreviation();
levelUnit = gribLevel.getUnit()
else:
LogStream.logEvent("No level information for center[" + str(centerID) + "], subcenter[" +
self.log.info("No level information for center[" + str(centerID) + "], subcenter[" +
str(subcenterID) + "], tableName[" + LEVELS_TABLE + "], level value[" +
str(pdsTemplate[9]) + "]");
@ -1130,7 +1136,7 @@ class GribDecoder():
minorAxis = self._convertScaledValue(gdsTemplate[2], gdsTemplate[1])
majorAxis = minorAxis
if majorAxis < 6000000.0 or minorAxis < 6000000.0:
LogStream.logEvent("Invalid earth shape majorAxis,minorAxis = " + str(majorAxis) + "," + str(minorAxis) + " defaulting to 6367470.0,6367470.0")
self.log.info("Invalid earth shape majorAxis,minorAxis = " + str(majorAxis) + "," + str(minorAxis) + " defaulting to 6367470.0,6367470.0")
minorAxis = majorAxis = 6367470.0
# Earth assumed oblate spheriod with size as determined by IAU in 1965
@ -1143,12 +1149,12 @@ class GribDecoder():
elif number == 3:
minorAxis = self._convertScaledValue(gdsTemplate[4], gdsTemplate[3]) * 1000
if minorAxis < 6000000.0:
LogStream.logEvent("Invalid earth shape minorAxis = " + str(minorAxis) + " defaulting to " + MINOR_AXIS_DEFAULT)
self.log.info("Invalid earth shape minorAxis = " + str(minorAxis) + " defaulting to " + MINOR_AXIS_DEFAULT)
minorAxis = MINOR_AXIS_DEFAULT
majorAxis = self._convertScaledValue(gdsTemplate[6], gdsTemplate[5]) * 1000
if majorAxis < 6000000.0:
LogStream.logEvent("Invalid earth shape majorAxis = " + str(majorAxis) + " defaulting to " + MAJOR_AXIS_DEFAULT)
self.log.info("Invalid earth shape majorAxis = " + str(majorAxis) + " defaulting to " + MAJOR_AXIS_DEFAULT)
majorAxis = MAJOR_AXIS_DEFAULT
# Earth assumed oblate spheriod as defined in IAG-GRS80 model
@ -1171,12 +1177,12 @@ class GribDecoder():
elif number == 7:
minorAxis = self._convertScaledValue(gdsTemplate[4], gdsTemplate[3])
if minorAxis < 6000000.0:
LogStream.logEvent("Invalid earth shape minorAxis = " + str(minorAxis) + " defaulting to " + MINOR_AXIS_DEFAULT)
self.log.info("Invalid earth shape minorAxis = " + str(minorAxis) + " defaulting to " + MINOR_AXIS_DEFAULT)
minorAxis = MINOR_AXIS_DEFAULT
majorAxis = self._convertScaledValue(gdsTemplate[6], gdsTemplate[5])
if majorAxis < 6000000.0:
LogStream.logEvent("Invalid earth shape majorAxis = " + str(majorAxis) + " defaulting to " + MAJOR_AXIS_DEFAULT)
self.log.info("Invalid earth shape majorAxis = " + str(majorAxis) + " defaulting to " + MAJOR_AXIS_DEFAULT)
majorAxis = MAJOR_AXIS_DEFAULT
# Earth model assumed spherical with radius 6,371,200 m,

View file

@ -13,24 +13,19 @@ Require-Bundle: javax.measure,
org.apache.commons.configuration,
com.raytheon.uf.common.localization,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.edex.python.decoder;bundle-version="1.11.26",
com.raytheon.uf.edex.awipstools;bundle-version="1.12.1174",
com.raytheon.uf.common.awipstools;bundle-version="1.12.1174",
ucar.nc2;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0",
com.raytheon.uf.common.status,
com.raytheon.uf.edex.python.decoder,
com.raytheon.uf.edex.awipstools,
com.raytheon.uf.common.awipstools,
ucar.nc2,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.grid,
com.raytheon.uf.common.parameter;bundle-version="1.0.0"
com.raytheon.uf.common.dataplugin.grid,
com.raytheon.uf.common.parameter,
com.raytheon.uf.edex.plugin.grid,
com.raytheon.uf.common.dataplugin.grib
Import-Package: com.raytheon.edex.exception,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.request,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.gridcoverage.exception,
com.raytheon.uf.common.gridcoverage.lookup,
com.raytheon.uf.common.gridcoverage.subgrid,
com.raytheon.uf.common.status,
com.raytheon.uf.edex.plugin.grid.dao,
org.apache.camel,
org.apache.commons.logging
Export-Package: com.raytheon.edex.objects.hibernate.grib,