Issue #436 merging elevation base changes into branch off of development baseline.
Former-commit-id:93c632c1ff
[formerly1321db6a99
] [formerly819b9c8e56
[formerly 9287cf98369abb8a674fd5bab99439d055218a05]] Former-commit-id:819b9c8e56
Former-commit-id:6eafdda705
This commit is contained in:
parent
d7597d8cf7
commit
e5952c1c99
15 changed files with 1087 additions and 1225 deletions
|
@ -0,0 +1,298 @@
|
|||
# ----------------------------------------------------------------------------
|
||||
# This software is in the public domain, furnished "as is", without technical
|
||||
# support, and with no warranty, express or implied, as to its usefulness for
|
||||
# any purpose.
|
||||
#
|
||||
# MakeHazard.py
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# Apr 03,2012 436 randerso Converted to Python procedure to allow some
|
||||
# level of site customization
|
||||
# Apr 09,2012 436 randerso Merged RNK's MakeHazards_Elevation procedure
|
||||
#
|
||||
# Author: randerso
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# The MenuItems list defines the GFE menu item(s) under which the
|
||||
# Procedure is to appear.
|
||||
# Possible items are: Populate, Edit, Consistency, Verify, Hazards
|
||||
MenuItems = ["Hazards"]
|
||||
|
||||
|
||||
import SmartScript
|
||||
import time, string, sys
|
||||
import HazardUtils
|
||||
import re
|
||||
import numpy
|
||||
import LogStream
|
||||
import JUtil
|
||||
|
||||
if sys.modules.has_key("MakeHazardConfig"):
|
||||
sys.modules.__delitem__("MakeHazardConfig")
|
||||
import MakeHazardConfig
|
||||
|
||||
class Procedure (SmartScript.SmartScript):
|
||||
def __init__(self, dbss):
|
||||
SmartScript.SmartScript.__init__(self, dbss)
|
||||
|
||||
self._dataManager = dbss
|
||||
self._afterInit = 0 #flag indicating init is done.
|
||||
|
||||
self._tropicalHaz = ['HU.W','HU.A','HU.S','TR.W','TR.A']
|
||||
self._natlBaseETN = 1001
|
||||
|
||||
|
||||
def setUpUI(self):
|
||||
|
||||
args = {}
|
||||
args['dataManager'] = self._dataManager
|
||||
args['selectedTimeRange'] = self.selectedTimeRange
|
||||
args['mapColor'] = MakeHazardConfig.mapColor
|
||||
args['defaultMapWidth'] = MakeHazardConfig.defaultMapWidth
|
||||
args['timeScaleEndTime'] = MakeHazardConfig.timeScaleEndTime
|
||||
args['areaThreshold'] = MakeHazardConfig.areaThreshold
|
||||
args['defaultHazardType'] = MakeHazardConfig.defaultHazardType
|
||||
args['mapNames'] = MakeHazardConfig.mapNames
|
||||
args['hazardDict'] = MakeHazardConfig.hazardDict
|
||||
args['tcmList'] = MakeHazardConfig.tcmList
|
||||
args['tropicalHaz'] = self._tropicalHaz
|
||||
args['natlBaseETN'] = self._natlBaseETN
|
||||
args['localEffectAreas'] = MakeHazardConfig.localEffectAreas
|
||||
args['localAreaData'] = MakeHazardConfig.localAreaData
|
||||
|
||||
# create the Java/SWT dialog and open it
|
||||
from com.raytheon.viz.gfe.makehazard import MakeHazardDialog
|
||||
self.__dlg = MakeHazardDialog.createFromPython(
|
||||
JUtil.pyValToJavaObj(args)
|
||||
)
|
||||
self.__dlg.openFromPython()
|
||||
|
||||
# run the Java/SWT event loop
|
||||
try:
|
||||
dismiss = False
|
||||
while not dismiss:
|
||||
args = JUtil.javaObjToPyVal(self.__dlg.runFromPython(), converter)
|
||||
dismiss = True;
|
||||
# if args is None, then Cancel was pressed
|
||||
if args is not None:
|
||||
# dismiss is True if the Run/Dismiss button is pressed,
|
||||
# false if Run is pressed
|
||||
dismiss = args["dismiss"]
|
||||
del args["dismiss"]
|
||||
|
||||
if self.makeHazardGrid(**args) != 1:
|
||||
dismiss = False
|
||||
finally:
|
||||
# close the Java/SWT dialog when Cancelled, Dismissed or exception occurs
|
||||
self.__dlg.closeFromPython()
|
||||
|
||||
# RJM modified this routine from the HazardUtility file
|
||||
# returns a Numeric mask where each zone in zoneList is set to 1
|
||||
def _makeMask(self, zoneList, hazLocalEffect):
|
||||
|
||||
# RJM had to modify this next line to point to the hazUtils
|
||||
# for the getGridSize routine.
|
||||
gridSize = self._hazUtils._getGridSize()
|
||||
mask = numpy.zeros(gridSize)
|
||||
eaList = self.editAreaList()
|
||||
|
||||
# Get the elevation from the GUI input. We'll do this by clipping
|
||||
# of any numerical digits from the local effect.
|
||||
# elevation_string = re.findall("\d+", hazLocalEffect)
|
||||
# print "re elevation=", elevation_string, "xxx"
|
||||
# try:
|
||||
# elevation = elevation_string[0]
|
||||
# except:
|
||||
# elevation = "None"
|
||||
# print "re elevation=", elevation, "xxx"
|
||||
for z in zoneList:
|
||||
print "in _makeMask processing zone ", z
|
||||
|
||||
if z in eaList:
|
||||
zoneArea = self.getEditArea(z)
|
||||
zoneMask = self.encodeEditArea(zoneArea)
|
||||
|
||||
# Code added by RJM. This checks to see if the local effect
|
||||
# area was specified and is a valid edit area. If so,
|
||||
# make a mask from it, and then do an intersection with
|
||||
# the zone mask.
|
||||
if hazLocalEffect in eaList:
|
||||
print "Masking",z,"with",hazLocalEffect
|
||||
localEffectArea = self.getEditArea(hazLocalEffect)
|
||||
localEffectMask = self.encodeEditArea(localEffectArea)
|
||||
zoneMask = numpy.logical_and(zoneMask, localEffectMask)
|
||||
|
||||
mask = numpy.logical_or(mask, zoneMask)
|
||||
# else:
|
||||
# if z in eaList:
|
||||
# zoneArea = self.getEditArea(z)
|
||||
# zoneMask = self.encodeEditArea(zoneArea)
|
||||
# mask = numpy.logical_or(mask, zoneMask)
|
||||
|
||||
return mask
|
||||
|
||||
# Creates the hazard grid based on the dialog input
|
||||
def makeHazardGrid(self, selectedHazard, timeRange, areaList, segmentNumber,
|
||||
selectedTimeRange, defaultAreaList, defaultHazard, defaultSegment,
|
||||
hazLocalEffect):
|
||||
siteID = self.getSiteID()
|
||||
usingHazLocalEffect = (hazLocalEffect != 'None')
|
||||
|
||||
if len(areaList) == 0:
|
||||
editArea = self.getActiveEditArea()
|
||||
mask = self.encodeEditArea(editArea)
|
||||
else:
|
||||
# make the mask based on the list selections
|
||||
if not usingHazLocalEffect:
|
||||
mask = self._hazUtils._makeMask(areaList)
|
||||
else:
|
||||
mask = self._makeMask(areaList, hazLocalEffect)
|
||||
|
||||
if usingHazLocalEffect:
|
||||
# get the segment number and filter for valid characters
|
||||
segNum = segmentNumber
|
||||
|
||||
# get the hazards currently defined as temporary grids
|
||||
hazParms = self.getHazardParmNames()
|
||||
|
||||
# look through the list of grids and create a list of
|
||||
# segment numbers (if any) that are already in use
|
||||
# for the current hazard
|
||||
# if len(hazParms) == 0:
|
||||
# self.statusBarMsg("No temporary grids to merge.", "S")
|
||||
# return 0
|
||||
segList = []
|
||||
print "selectedHazard=", selectedHazard
|
||||
selectedPhen = selectedHazard[0:2]
|
||||
selectedSig = selectedHazard[3]
|
||||
print "selectedPhen,selectedSig=", selectedPhen, ".", selectedSig
|
||||
for hazParm in hazParms:
|
||||
print "hazParm=", hazParm
|
||||
trList = self._hazUtils._getWEInventory(hazParm)
|
||||
for tr in trList:
|
||||
print " tr=", tr, timeRange
|
||||
intersect_hours = tr.intersection(timeRange).duration()
|
||||
print " intersect=", intersect_hours
|
||||
intersect_percent = intersect_hours / timeRange.duration() * 100.0
|
||||
print " intersect %=", intersect_percent
|
||||
phen = hazParm[3:5]
|
||||
sig = hazParm[5:6]
|
||||
print "phen,sig=", phen, ".", sig
|
||||
if len(hazParm) > 6:
|
||||
if hazParm[6:].isdigit():
|
||||
seg = int(hazParm[6:])
|
||||
print " seg=", seg
|
||||
if phen == selectedPhen and sig == selectedSig:
|
||||
segList.append(seg)
|
||||
print "appending ", seg
|
||||
else:
|
||||
seg = 0
|
||||
segList.sort()
|
||||
|
||||
# print "looping through segList"
|
||||
# for seg in segList:
|
||||
# print " seg=", seg," elev=", elevation
|
||||
# if str(elevation) == str(seg):
|
||||
# print "adding 1 to elevation"
|
||||
# elevation += 1
|
||||
#
|
||||
# if elevation > 400:
|
||||
# print "using elevation for segNum"
|
||||
# segNum = elevation
|
||||
# # replace the segmentNumber field with the elevation +/- the Above/Below indicator.
|
||||
# self.__dlg.setSegmentNumber(elevation)
|
||||
# segmentNumber = str(elevation)
|
||||
# print "*** segmentNumber=", segmentNumber
|
||||
|
||||
index = string.find(selectedHazard, " ")
|
||||
if index != -1:
|
||||
selectedHazard = selectedHazard[0:index]
|
||||
if len(segmentNumber) > 0:
|
||||
hazardKey = selectedHazard + ":" + segmentNumber
|
||||
else:
|
||||
hazardKey = selectedHazard
|
||||
|
||||
defaultHazKey = ""
|
||||
if len(defaultSegment) > 0 and defaultHazard is not None:
|
||||
defaultHazKey = defaultHazard + ":" + defaultSegment
|
||||
|
||||
weName = self._hazUtils._makeTempWEName(hazardKey)
|
||||
|
||||
# if we're modifying, remove the old grid first
|
||||
if defaultAreaList != [] and hazardKey == defaultHazKey:
|
||||
self.deleteCmd([weName], self.selectedTimeRange)
|
||||
|
||||
# if we have no selection prevent user from making an empty hazard
|
||||
if 1 not in mask:
|
||||
self.statusBarMsg("NO EDIT AREA SELECTED: \n Select area from map or load edit area in GFE!", "S")
|
||||
return 0
|
||||
|
||||
self._hazUtils._addHazard(weName, timeRange, hazardKey, mask)
|
||||
LogStream.logUse("Set: ", weName,
|
||||
self._hazUtils._printTime(timeRange.startTime().unixTime()),
|
||||
self._hazUtils._printTime(timeRange.endTime().unixTime()), hazardKey,
|
||||
self._hazUtils._printAreas(areaList))
|
||||
|
||||
return 1
|
||||
|
||||
def getHazardParmNames(self):
|
||||
# get the list of loaded temporary hazard parms
|
||||
parms = self.loadedParms()
|
||||
hazParms = []
|
||||
for weName, level, dbID in parms:
|
||||
if "haz" in weName:
|
||||
key = self._hazUtils._tempWENameToKey(weName)
|
||||
index = string.find(key, ":")
|
||||
if index != -1:
|
||||
mkey = key[0:index]
|
||||
segNum = key[index+1:]
|
||||
else:
|
||||
mkey = key
|
||||
segNum = ""
|
||||
|
||||
# append the hazard and a description
|
||||
parmName = "haz" + key
|
||||
parmName = string.replace(parmName, ".", "")
|
||||
parmName = string.replace(parmName, ":", "")
|
||||
hazParms.append(parmName)
|
||||
|
||||
return hazParms
|
||||
|
||||
def execute(self, timeRange):
|
||||
#self._hazUtils = HazardUtils.HazardUtils(self._dataManager, self.eaMgr())
|
||||
self._hazUtils = HazardUtils.HazardUtils(self._dataManager, None)
|
||||
# save the selected timeRange
|
||||
self.selectedTimeRange = timeRange
|
||||
|
||||
self.setToolType("numeric")
|
||||
|
||||
# see if the Hazards WE is loaded in the GFE, if not abort the tool
|
||||
if not self._hazUtils._hazardsLoaded():
|
||||
self.statusBarMsg("Hazards Weather Element must be loaded in " + \
|
||||
"the GFE before running MakeHazard", "S")
|
||||
self.cancel()
|
||||
|
||||
|
||||
# always separate the Hazards grid first
|
||||
self._hazUtils._separateHazardGrids()
|
||||
|
||||
self.setUpUI()
|
||||
|
||||
self._afterInit = 1 #initialization done
|
||||
|
||||
return
|
||||
|
||||
def converter(obj):
|
||||
import AbsTime
|
||||
import TimeRange
|
||||
retVal = None
|
||||
|
||||
objtype = obj.jclassname
|
||||
if objtype == "java.util.Date":
|
||||
retVal = AbsTime.AbsTime(obj)
|
||||
elif objtype == "com.raytheon.uf.common.time.TimeRange":
|
||||
retVal = TimeRange.TimeRange(obj)
|
||||
return retVal
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# AWIPS1 imports SmartScript to retrieve the site ID below, but
|
||||
# since all we need is just that site ID, it makes more sense to
|
||||
# import DataManager directly to get that rather than all of the
|
||||
# SmartScript module
|
||||
# import SmartScript
|
||||
from com.raytheon.viz.gfe.core import DataManager
|
||||
|
||||
def sortHazardList(dict):
|
||||
#sorts the entries in the menus in alphabetical order, returns sorted
|
||||
#dictionary
|
||||
import VTECTable
|
||||
for ent in dict.keys():
|
||||
values = dict[ent]
|
||||
# get the descriptive word for this phen/sig
|
||||
items = []
|
||||
for v in values:
|
||||
desc = VTECTable.VTECTable.get(v,'')
|
||||
items.append((desc, v))
|
||||
items.sort() #sorts by description
|
||||
#extract out the sorted phen/sig
|
||||
phensig = []
|
||||
for desc, v in items:
|
||||
phensig.append(v)
|
||||
dict[ent] = phensig
|
||||
return dict
|
||||
|
||||
|
||||
###########################################################
|
||||
############## ###############
|
||||
############## CONFIGURATION SECTION ###############
|
||||
############## ###############
|
||||
|
||||
# Lists of hazards organized by type in a dictionary
|
||||
# Set these to value you use for your site. To minimize scrolling,
|
||||
# change the order so that the most common values your site uses are
|
||||
# near the front of each list. The key is the menu entry on the
|
||||
# Make Hazard dialog, the values are the key values for Hazards.
|
||||
siteID = DataManager.getCurrentInstance().getSiteID()
|
||||
if siteID == "GUM":
|
||||
hazardDict = {
|
||||
'Hydrology' : ["FF.A", "FA.A"],
|
||||
'Fire Weather' : ["FW.A", "FW.W"],
|
||||
'Coastal Flood' : ["CF.S", "LS.S", "CF.Y", "CF.W", "CF.A",
|
||||
"SU.Y", "SU.W", "LS.Y", "LS.W", "LS.A", "RP.S"],
|
||||
'Non-Precipitation' : ["AF.W", "AF.Y", "AQ.Y", "AS.O", "AS.Y", "DU.Y",
|
||||
"DS.W", "EH.W", "EH.A", "EC.W", "EC.A", "FG.Y", "FZ.W", "FZ.A",
|
||||
"HZ.W", "HZ.A", "ZF.Y", "FR.Y", "HT.Y", "HW.W", "HW.A",
|
||||
"LW.Y", "SM.Y", "WI.Y"],
|
||||
'Marine' : ["MA.S", "MH.W", "MH.Y", "BW.Y", "UP.Y", "MF.Y",
|
||||
"GL.A", "GL.W", "SE.A", "SE.W", "UP.A", "UP.W", "HF.A", "HF.W", "LO.Y", "SC.Y", "SW.Y",
|
||||
"RB.Y", "SI.Y", "MS.Y", "SR.A", "SR.W"],
|
||||
'Typhoon' : ["TY.A", "TY.W", "TR.A", "TR.W", "HU.S"],
|
||||
'Tsunami' : ["TS.A", "TS.W"],
|
||||
|
||||
#'Local' : ["TEST"], #example of adding local hazards
|
||||
# you can define your own groups of hazards by adding new categories
|
||||
}
|
||||
else:
|
||||
hazardDict = {
|
||||
'Winter Weather' : ["BZ.W", "BZ.A", "ZR.Y",
|
||||
"IS.W", "LE.Y", "LE.W", "LE.A",
|
||||
"WC.Y", "WC.W", "WC.A", "WS.W", "WS.A", "WW.Y"],
|
||||
'Hydrology' : ["FF.A", "FA.A"],
|
||||
'Fire Weather' : ["FW.A", "FW.W"],
|
||||
'Convective Watches' : ["SV.A", "TO.A"],
|
||||
'Coastal Flood' : ["CF.S", "LS.S", "CF.Y", "CF.W", "CF.A",
|
||||
"SU.Y", "SU.W", "LS.Y", "LS.W", "LS.A", "RP.S"],
|
||||
'Non-Precipitation' : ["AF.W", "AF.Y", "AQ.Y", "AS.O", "AS.Y", "DU.Y",
|
||||
"DS.W", "EH.W", "EH.A", "EC.W", "EC.A", "FG.Y", "FZ.W", "FZ.A",
|
||||
"HZ.W", "HZ.A", "ZF.Y", "FR.Y", "HT.Y", "HW.W", "HW.A",
|
||||
"LW.Y", "SM.Y", "WI.Y"],
|
||||
'Marine' : ["MA.S", "MH.W", "MH.Y", "BW.Y", "UP.Y", "MF.Y",
|
||||
"GL.A", "GL.W", "SE.A", "SE.W", "UP.A", "UP.W", "HF.A", "HF.W", "LO.Y", "SC.Y", "SW.Y",
|
||||
"RB.Y", "SI.Y", "MS.Y", "SR.A", "SR.W"],
|
||||
'Tropical Cyclone' : ["HU.W", "HU.A", "HU.S", "TR.W", "TR.A"],
|
||||
'Tsunami' : ["TS.A", "TS.W"],
|
||||
|
||||
#'Local' : ["TEST"], #example of adding local hazards
|
||||
# you can define your own groups of hazards by adding new categories
|
||||
}
|
||||
|
||||
|
||||
# This function sorts the hazards in the hazardDict by description.
|
||||
# Comment it out if this is not desired.
|
||||
hazardDict = sortHazardList(hazardDict)
|
||||
|
||||
# Dictionary of map categories and the map names. The "<site>" is
|
||||
# substituted with your site name. The names of the map must match
|
||||
# those defined in the ifpServer. The keys in mapNames must match
|
||||
# the keys in hazardDict.
|
||||
|
||||
mapNames = {
|
||||
'Fire Weather' : ["FireWxZones_<site>"],
|
||||
'Hydrology' : ["Zones_<site>"],
|
||||
'Coastal Flood': ["Zones_<site>"],
|
||||
'Convective Watches' : ["Marine_Zones_<site>","FIPS_<site>"],
|
||||
'Non-Precipitation' : ["Zones_<site>"],
|
||||
'Tropical Cyclone' : ["Offshore_Marine_Zones_<site>",
|
||||
"Marine_Zones_<site>","Zones_<site>"],
|
||||
'Typhoon' : ["Offshore_Marine_Zones_<site>",
|
||||
"Marine_Zones_<site>","Zones_<site>"],
|
||||
'Tsunami' : ["Offshore_Marine_Zones_<site>",
|
||||
"Marine_Zones_<site>","Zones_<site>"],
|
||||
'Winter Weather' : ["Zones_<site>"],
|
||||
'Marine' : ["Offshore_Marine_Zones_<site>",
|
||||
"Marine_Zones_<site>"],
|
||||
#'Local' : ["Zones_<site>"], #example of adding local class
|
||||
}
|
||||
|
||||
# The hazard type chosen when MakeHazard opens
|
||||
defaultHazardType = "Non-Precipitation"
|
||||
|
||||
# this is the color for the selected areas in the map
|
||||
mapColor = "red"
|
||||
|
||||
# initial map width
|
||||
defaultMapWidth = 400;
|
||||
|
||||
# the percentage that an area must be covered to default to selected
|
||||
areaThreshold = 0.10
|
||||
|
||||
# End time in hours of the time scales
|
||||
timeScaleEndTime = 96
|
||||
|
||||
# Define the tropical product used to identify the particular storm
|
||||
tcmList = [] # Comment out for HLS sites
|
||||
|
||||
# Uncomment line below for Atlantic basin sites
|
||||
#tcmList = ["TCMAT1", "TCMAT2", "TCMAT3", "TCMAT4", "TCMAT5"]
|
||||
|
||||
# Uncomment line below for EPac basin sites
|
||||
#tcmList = ["TCMEP1", "TCMEP2", "TCMEP3", "TCMEP4", "TCMEP5"]
|
||||
|
||||
# Uncomment line below for CPac basin sites
|
||||
#self.tcmList = ["TCMCP1", "TCMCP2", "TCMCP3", "TCMCP4", "TCMCP5"]
|
||||
|
||||
#################### END CONFIGURATION SECTION #################
|
|
@ -1061,10 +1061,7 @@ class HazardUtils(SmartScript.SmartScript):
|
|||
|
||||
#print areas, from dictionary
|
||||
def _printAreas(self, areas):
|
||||
ara = []
|
||||
for a in areas.keys():
|
||||
if areas[a] == 1:
|
||||
ara.append(a)
|
||||
ara = list(areas)
|
||||
ara.sort()
|
||||
return ara
|
||||
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
# ----------------------------------------------------------------------------
|
||||
# This software is in the public domain, furnished "as is", without technical
|
||||
# support, and with no warranty, express or implied, as to its usefulness for
|
||||
# any purpose.
|
||||
#
|
||||
# MakeHazard.py
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# Jul 10,2012 436 randerso Separated configuration data from the
|
||||
# MakeHazard procedure
|
||||
#
|
||||
# Author: randerso
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
def sortHazardList(dict):
|
||||
#sorts the entries in the menus in alphabetical order, returns sorted
|
||||
#dictionary
|
||||
import VTECTable
|
||||
for ent in dict.keys():
|
||||
values = dict[ent]
|
||||
# get the descriptive word for this phen/sig
|
||||
items = []
|
||||
for v in values:
|
||||
desc = VTECTable.VTECTable.get(v,'')
|
||||
items.append((desc, v))
|
||||
items.sort() #sorts by description
|
||||
#extract out the sorted phen/sig
|
||||
phensig = []
|
||||
for desc, v in items:
|
||||
phensig.append(v)
|
||||
dict[ent] = phensig
|
||||
|
||||
return dict
|
||||
|
||||
# Lists of hazards organized by type in a dictionary
|
||||
# Set these to value you use for your site. To minimize scrolling,
|
||||
# change the order so that the most common values your site uses are
|
||||
# near the front of each list. The key is the menu entry on the
|
||||
# Make Hazard dialog, the values are the key values for Hazards.
|
||||
hazardDict = {
|
||||
'Winter Weather' : ["BZ.W", "BZ.A", "ZR.Y",
|
||||
"IS.W", "LE.Y", "LE.W", "LE.A",
|
||||
"WC.Y", "WC.W", "WC.A", "WS.W", "WS.A", "WW.Y"],
|
||||
'Hydrology' : ["FF.A", "FA.A"],
|
||||
'Fire Weather' : ["FW.A", "FW.W"],
|
||||
'Convective Watches' : ["SV.A", "TO.A"],
|
||||
'Coastal Flood' : ["CF.S", "LS.S", "CF.Y", "CF.W", "CF.A",
|
||||
"SU.Y", "SU.W", "LS.Y", "LS.W", "LS.A", "RP.S"],
|
||||
'Non-Precipitation' : ["AF.W", "AF.Y", "AQ.Y", "AS.O", "AS.Y", "DU.Y",
|
||||
"DS.W", "EH.W", "EH.A", "EC.W", "EC.A", "FG.Y", "FZ.W", "FZ.A",
|
||||
"HZ.W", "HZ.A", "ZF.Y", "FR.Y", "HT.Y", "HW.W", "HW.A",
|
||||
"LW.Y", "SM.Y", "WI.Y"],
|
||||
'Marine' : ["MA.S", "MH.W", "MH.Y", "BW.Y", "UP.Y", "MF.Y",
|
||||
"GL.A", "GL.W", "SE.A", "SE.W", "UP.A", "UP.W", "HF.A", "HF.W", "LO.Y", "SC.Y", "SW.Y",
|
||||
"RB.Y", "SI.Y", "MS.Y", "SR.A", "SR.W"],
|
||||
'Tropical Cyclone' : ["HU.W", "HU.A", "HU.S", "TR.W", "TR.A"],
|
||||
'Tsunami' : ["TS.A", "TS.W"],
|
||||
|
||||
#'Local' : ["TEST"], #example of adding local hazards
|
||||
# you can define your own groups of hazards by adding new categories
|
||||
}
|
||||
|
||||
# for GUM use comment out the above definition and uncomment the one below
|
||||
|
||||
#hazardDict = {
|
||||
# 'Hydrology' : ["FF.A", "FA.A"],
|
||||
# 'Fire Weather' : ["FW.A", "FW.W"],
|
||||
# 'Coastal Flood' : ["CF.S", "LS.S", "CF.Y", "CF.W", "CF.A",
|
||||
# "SU.Y", "SU.W", "LS.Y", "LS.W", "LS.A", "RP.S"],
|
||||
# 'Non-Precipitation' : ["AF.W", "AF.Y", "AQ.Y", "AS.O", "AS.Y", "DU.Y",
|
||||
# "DS.W", "EH.W", "EH.A", "EC.W", "EC.A", "FG.Y", "FZ.W", "FZ.A",
|
||||
# "HZ.W", "HZ.A", "ZF.Y", "FR.Y", "HT.Y", "HW.W", "HW.A",
|
||||
# "LW.Y", "SM.Y", "WI.Y"],
|
||||
# 'Marine' : ["MA.S", "MH.W", "MH.Y", "BW.Y", "UP.Y", "MF.Y",
|
||||
# "GL.A", "GL.W", "SE.A", "SE.W", "UP.A", "UP.W", "HF.A", "HF.W", "LO.Y", "SC.Y", "SW.Y",
|
||||
# "RB.Y", "SI.Y", "MS.Y", "SR.A", "SR.W"],
|
||||
# 'Typhoon' : ["TY.A", "TY.W", "TR.A", "TR.W", "HU.S"],
|
||||
# 'Tsunami' : ["TS.A", "TS.W"],
|
||||
#
|
||||
# #'Local' : ["TEST"], #example of adding local hazards
|
||||
# # you can define your own groups of hazards by adding new categories
|
||||
# }
|
||||
|
||||
|
||||
# This function sorts the hazards in the hazardDict by description.
|
||||
# Comment it out if this is not desired.
|
||||
hazardDict = sortHazardList(hazardDict)
|
||||
|
||||
# Dictionary of map categories and the map names. The "<site>" is
|
||||
# substituted with your site name. The names of the map must match
|
||||
# those defined in the ifpServer. The keys in mapNames must match
|
||||
# the keys in hazardDict.
|
||||
|
||||
mapNames = {
|
||||
'Fire Weather' : ["FireWxZones_<site>"],
|
||||
'Hydrology' : ["Zones_<site>"],
|
||||
'Coastal Flood': ["Zones_<site>"],
|
||||
'Convective Watches' : ["Marine_Zones_<site>","FIPS_<site>"],
|
||||
'Non-Precipitation' : ["Zones_<site>"],
|
||||
'Tropical Cyclone' : ["Offshore_Marine_Zones_<site>",
|
||||
"Marine_Zones_<site>","Zones_<site>"],
|
||||
'Typhoon' : ["Offshore_Marine_Zones_<site>",
|
||||
"Marine_Zones_<site>","Zones_<site>"],
|
||||
'Tsunami' : ["Offshore_Marine_Zones_<site>",
|
||||
"Marine_Zones_<site>","Zones_<site>"],
|
||||
'Winter Weather' : ["Zones_<site>"],
|
||||
'Marine' : ["Offshore_Marine_Zones_<site>",
|
||||
"Marine_Zones_<site>"],
|
||||
#'Local' : ["Zones_<site>"], #example of adding local class
|
||||
}
|
||||
|
||||
# The defaultHazardType - selected when the tool is first run. This
|
||||
# must be one of the categories (keys) in the mapNames and hazardDict.
|
||||
defaultHazardType = "Non-Precipitation"
|
||||
|
||||
# this is the color for the selected areas in the map
|
||||
mapColor = "red" # color of selected areas
|
||||
|
||||
# initial map width
|
||||
defaultMapWidth = 400;
|
||||
|
||||
# the percentage that an area must be covered to default to selected
|
||||
areaThreshold = 0.10
|
||||
|
||||
# End time in hours of the time scales
|
||||
timeScaleEndTime = 96
|
||||
|
||||
# Define the tropical product used to identify the particular storm
|
||||
tcmList = [] # Comment out for HLS sites
|
||||
|
||||
# Uncomment line below for Atlantic basin sites
|
||||
#tcmList = ["TCMAT1", "TCMAT2", "TCMAT3", "TCMAT4", "TCMAT5"]
|
||||
|
||||
# Uncomment line below for EPac basin sites
|
||||
#tcmList = ["TCMEP1", "TCMEP2", "TCMEP3", "TCMEP4", "TCMEP5"]
|
||||
|
||||
# Uncomment line below for CPac basin sites
|
||||
#tcmList = ["TCMCP1", "TCMCP2", "TCMCP3", "TCMCP4", "TCMCP5"]
|
||||
|
||||
# Dictionary mapping Hazard Types to applicable local effect areas
|
||||
# that can be intersected with the zone edit areas
|
||||
localEffectAreas = {}
|
||||
|
||||
#localEffectAreas = {
|
||||
# 'Winter Weather' : ["Below_1000","Below_1500","Below_2000","Below_2500","Below_3000","Below_3500","Below_4000",
|
||||
# "Above_1000","Above_1500","Above_2000","Above_2500","Above_3000","Above_3500"],
|
||||
# }
|
||||
|
||||
# Dictionary associating local Effect Area names with a corresponding
|
||||
# segment number, display name, and list of zones to be auto-selected
|
||||
# If you do not wish to auto-select zones you should supply an empty list
|
||||
#
|
||||
# The display name allows you to display a "pretty" string in the UI rather
|
||||
# than the edit area name. If the display name is empty ("") the edit area
|
||||
# name will be used.
|
||||
localAreaData = {}
|
||||
|
||||
#localAreaData = {
|
||||
# "Below_1000" : ( 999, "", []),
|
||||
# "Below_1500" : (1499, "", []),
|
||||
# "Below_2000" : (1999, "", []),
|
||||
# "Below_2500" : (2499, "", []),
|
||||
# "Below_3000" : (2999, "", []),
|
||||
# "Below_3500" : (3499, "", []),
|
||||
# "Below_4000" : (3999, "", []),
|
||||
# "Above_1000" : (1000, "", []),
|
||||
# "Above_1500" : (1500, "", []),
|
||||
# "Above_2000" : (2000, "", []),
|
||||
# "Above_2500" : (2500, "", []),
|
||||
# "Above_3000" : (3000, "", []),
|
||||
# "Above_3500" : (3500, "", []),
|
||||
# }
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
# ----------------------------------------------------------------------------
|
||||
# This software is in the public domain, furnished "as is", without technical
|
||||
# support, and with no warranty, express or implied, as to its usefulness for
|
||||
# any purpose.
|
||||
#
|
||||
# MakeHazard.py
|
||||
#
|
||||
# Author: wdougherty
|
||||
# ----------------------------------------------------------------------------
|
||||
import numpy
|
||||
import JUtil
|
||||
import LogStream
|
||||
import TimeRange
|
||||
from HazardUtils import HazardUtils
|
||||
from HazardUtils import ELEMENT
|
||||
from HazardUtils import MODEL
|
||||
from HazardUtils import LEVEL
|
||||
from HazardUtils import SUCCESS
|
||||
from HazardUtils import FAIL_REDUNDANT
|
||||
|
||||
def makeHazard(hazard, dbss, timeRange, zones, segment, selectedTimeRange, defaultAreaList, defaultHazard, defaultSegment):
|
||||
hazardUtils = HazardUtils(dbss, None)
|
||||
# hazard has already been validated
|
||||
# timeRange has already been validated
|
||||
|
||||
# convert zones to a Python list
|
||||
if zones is None:
|
||||
zones = []
|
||||
if defaultAreaList is None:
|
||||
defaultAreaList = []
|
||||
|
||||
if not isinstance(zones, list):
|
||||
zones = JUtil.javaStringListToPylist(zones)
|
||||
if not isinstance(defaultAreaList, list):
|
||||
defaultAreaList = JUtil.javaStringListToPylist(defaultAreaList)
|
||||
|
||||
# Find the mask that describes the area covered by the hazard
|
||||
if [] == zones:
|
||||
ea = hazardUtils.getActiveEditArea()
|
||||
if ea is None:
|
||||
mask = None
|
||||
else:
|
||||
mask = hazardUtils.encodeEditArea(ea)
|
||||
else:
|
||||
mask = hazardUtils._makeMask(zones)
|
||||
|
||||
# Hazards need to be separated for makeHazard's temp hazard grid.
|
||||
# If the user hasn't already separated them, it's up to us.
|
||||
if hazardUtils._tempWELoaded():
|
||||
pass # Hazards are already separated
|
||||
else:
|
||||
hazParm = hazardUtils.getParm(MODEL,ELEMENT,LEVEL)
|
||||
# If the inventory span is invalid, the hazards grid is empty.
|
||||
if hazParm.getInventorySpan().isValid():
|
||||
if SUCCESS != hazardUtils._separateHazardGrids():
|
||||
return False
|
||||
|
||||
# Build the hazard key
|
||||
hazardKey = hazard
|
||||
defaultHazardKey = defaultHazard
|
||||
|
||||
if segment is None:
|
||||
segment = ""
|
||||
if defaultSegment is None:
|
||||
defaultSegment = ""
|
||||
|
||||
segment = segment.strip()
|
||||
defaultSegment = defaultSegment.strip()
|
||||
|
||||
if "" != segment:
|
||||
hazardKey = hazardKey + ":" + segment
|
||||
if "" != defaultSegment and defaultHazardKey is not None:
|
||||
defaultHazardKey = defaultHazardKey + ":" + defaultSegment
|
||||
|
||||
# Create the name of the temp weather element from hazardKey
|
||||
weName = hazardUtils._makeTempWEName(hazardKey)
|
||||
|
||||
# if we're modifying, remove the old grid first
|
||||
if defaultAreaList != [] and hazardKey == defaultHazardKey:
|
||||
hazardUtils.deleteCmd([weName], selectedTimeRange)
|
||||
|
||||
# Don't allow the user to create an empty hazard grid
|
||||
if not numpy.any(mask):
|
||||
hazardUtils.statusBarMsg(
|
||||
"NO EDIT AREA SELECTED: \n Select area from map or load edit area in GFE!",
|
||||
"S", "GHG Status")
|
||||
return False
|
||||
|
||||
# Create the temporary hazard grid
|
||||
hazardUtils._addHazard(weName, timeRange, hazardKey, mask)
|
||||
|
||||
# convert timeRange to Python for logging
|
||||
timeRange = TimeRange.TimeRange(timeRange)
|
||||
# log the creation of the temp hazard
|
||||
LogStream.logEvent("Set: " + weName + " " +
|
||||
hazardUtils._printTime(timeRange.startTime().unixTime()) + " " +
|
||||
hazardUtils._printTime(timeRange.endTime().unixTime()) + " " +
|
||||
hazardKey + " " + str(zones))
|
||||
return True
|
||||
|
||||
##
|
||||
#
|
||||
def ensureSeparated(dbss):
|
||||
hazardUtils = HazardUtils(dbss, None)
|
||||
rtnCode = hazardUtils._separateHazardGrids()
|
||||
separated = rtnCode in [SUCCESS, FAIL_REDUNDANT]
|
||||
return separated
|
|
@ -1,250 +0,0 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
import string, time
|
||||
from com.raytheon.uf.common.status import UFStatus
|
||||
from com.raytheon.uf.common.status import UFStatus_Priority as Priority
|
||||
|
||||
|
||||
### New class for fetching ETN from TCM header for tropical hazards
|
||||
class TCMDecoder:
|
||||
def __init__(self):
|
||||
self.pos = 0
|
||||
# key words in TCM products from NCEP
|
||||
self.keyWordDict = {"NATIONAL HURRICANE CENTER" : self.decodeAltFilename,
|
||||
}
|
||||
|
||||
self.fcstList = [] # a place to store all of the forecasts
|
||||
|
||||
self.text = [] # the text product
|
||||
|
||||
self.currentFcst = {} # the current forecast we are docoding
|
||||
|
||||
self.baseProductTime = 0
|
||||
|
||||
self.altFilename = ""
|
||||
|
||||
self._handler = UFStatus.getHandler("GFE", 'GFE')
|
||||
|
||||
def stripText(self):
|
||||
endStr = chr(13) + chr(13) + chr(10)
|
||||
for i in range(len(self.text)):
|
||||
self.text[i] = string.replace(self.text[i], endStr, "")
|
||||
return
|
||||
|
||||
def getFcstList(self):
|
||||
return self.fcstList
|
||||
|
||||
def getBaseProductTime(self):
|
||||
return self.baseProductTime
|
||||
|
||||
def getAltInfoFilename(self):
|
||||
return self.altFilename
|
||||
|
||||
def currentLine(self):
|
||||
return self.text[self.pos]
|
||||
|
||||
def nextLine(self):
|
||||
self.pos = self.pos + 1
|
||||
if self.pos < len(self.text):
|
||||
return self.text[self.pos]
|
||||
else:
|
||||
return ""
|
||||
|
||||
def monthNum(self, monthStr):
|
||||
monthList = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN",
|
||||
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]
|
||||
|
||||
try:
|
||||
return monthList.index(monthStr) + 1
|
||||
except ValueError:
|
||||
return 0
|
||||
|
||||
def convertBaseTime(self, timeStr):
|
||||
# timeStr format: "HHMM UTC DAY MON DD YYYY"
|
||||
try:
|
||||
baseTime = time.strptime(timeStr, "%H%M UTC %a %b %d %Y")
|
||||
print "baseTime is", baseTime
|
||||
return baseTime
|
||||
except ValueError:
|
||||
return
|
||||
|
||||
|
||||
# extract time parts from the str
|
||||
# strList = string.split(timeStr)
|
||||
# if len(strList) != 6:
|
||||
# print "Invalid time string:", timeStr
|
||||
# print "Format should be of the form HHMM UTC DAY MON DD YYYY"
|
||||
# return
|
||||
#
|
||||
# hour = int(timeStr[0:2])
|
||||
# minute = int(timeStr[2:4])
|
||||
# monthStr = strList[3]
|
||||
# month = self.monthNum(monthStr)
|
||||
# day = int(strList[4])
|
||||
# year = int(strList[5])
|
||||
#
|
||||
# # time.mktime returns time in seconds but in local time
|
||||
# baseTime = time.mktime((year, month, day, hour, minute, 0, 0, 0, 0))
|
||||
# print "month is", month
|
||||
# print "baseTime is", baseTime
|
||||
|
||||
## # Adjust to UTC
|
||||
## diffTime = time.mktime(time.gmtime()) - time.mktime(time.localtime())
|
||||
## print "diffTime is", diffTime
|
||||
|
||||
## # subtract timeZone and round to the nearest hour
|
||||
## roundedTime = int((baseTime - diffTime) / 3600) * 3600
|
||||
##
|
||||
# return baseTime
|
||||
|
||||
def convert_ddhhmm(self, ddhhmmStr, baseTime):
|
||||
|
||||
# remove the slash if present
|
||||
ddhhmmStr = string.replace(ddhhmmStr, "/", "")
|
||||
|
||||
if baseTime == 0:
|
||||
baseTime = time.time()
|
||||
|
||||
# extract the time parts
|
||||
dayStr = ddhhmmStr[0:2]
|
||||
hourStr = ddhhmmStr[2:4]
|
||||
minStr = ddhhmmStr[4:6]
|
||||
day = int(dayStr)
|
||||
hour = int(hourStr)
|
||||
minute = int(minStr)
|
||||
tupleTime = time.gmtime(baseTime)
|
||||
year = tupleTime[0]
|
||||
month = tupleTime[1]
|
||||
# see if we crossed over to a new month
|
||||
if tupleTime[2] > day:
|
||||
month = month + 1
|
||||
if month > 12:
|
||||
month = 1
|
||||
year = year + 1
|
||||
|
||||
newTuple = (year, month, day, hour, minute, tupleTime[5],
|
||||
tupleTime[6], tupleTime[7], tupleTime[8])
|
||||
|
||||
secondsTime = time.mktime(newTuple)
|
||||
# Adjustment to UTC
|
||||
diffTime = time.mktime(time.gmtime()) - time.mktime(time.localtime())
|
||||
return secondsTime - diffTime # subtract timeZone
|
||||
|
||||
def decodeProductTime(self):
|
||||
# Time of the product found on the next line
|
||||
timeStr = self.nextLine()
|
||||
print "the time string is:", timeStr
|
||||
|
||||
# sanity check for the time string
|
||||
hhmm = timeStr[0:4]
|
||||
for c in hhmm:
|
||||
if not c in string.digits:
|
||||
return
|
||||
|
||||
baseTime = self.convertBaseTime(timeStr)
|
||||
self.baseProductTime = baseTime
|
||||
|
||||
return
|
||||
|
||||
def decodeAltFilename(self):
|
||||
nameStr = self.currentLine()
|
||||
parts = string.split(nameStr)
|
||||
|
||||
self.altFilename = parts[-1] # grab the last string token
|
||||
return
|
||||
|
||||
def decodeTCMProduct(self, TCMProduct):
|
||||
self.text = TCMProduct
|
||||
self.pos = 0
|
||||
self.fcstList = []
|
||||
## self.defaultEyeDiameter = eyeDiameter
|
||||
|
||||
self.stripText()
|
||||
while self.pos < len(TCMProduct):
|
||||
line = self.currentLine()
|
||||
for k in self.keyWordDict.keys():
|
||||
if string.find(line, k) > -1:
|
||||
self.keyWordDict[k]()
|
||||
break
|
||||
self.pos = self.pos + 1
|
||||
|
||||
# store the last forecast in the list of forecasts
|
||||
if self.currentFcst != {}:
|
||||
self.fcstList.append(self.currentFcst)
|
||||
self.currentFcst = {} # reset
|
||||
|
||||
return
|
||||
## End TCM decoder class
|
||||
|
||||
### New methods to pull ETN from TCM if grid is not initialized with ETN
|
||||
def tcmETNforTrop(tcmProduct):
|
||||
tcmProd = tcmProduct
|
||||
# print "chosen TCM is", tcmProd
|
||||
tcmDecoder = TCMDecoder()
|
||||
TCMProduct = getTextProductFromDB(tcmProd)
|
||||
if len(TCMProduct) < 3:
|
||||
msg = tcmProd + " could not be retrieved from the text database."
|
||||
statusBarMsg(msg, "S")
|
||||
return None # Just return if no TCM is found. Something's really wrong
|
||||
else:
|
||||
tcmDecoder.decodeTCMProduct(TCMProduct)
|
||||
altFileName = tcmDecoder.getAltInfoFilename()
|
||||
stormNum = altFileName[2:4]
|
||||
## print "storm number is", stormNum
|
||||
nationalBase = "10"
|
||||
tropicalETN = nationalBase + stormNum
|
||||
## print "Tropical ETN is: ", tropicalETN
|
||||
## print "lenth of tropical ETN is:", len(tropicalETN)
|
||||
return tropicalETN
|
||||
|
||||
def getTextProductFromDB(productID):
|
||||
from com.raytheon.viz.gfe import Activator
|
||||
from com.raytheon.viz.gfe.core import DataManager
|
||||
from com.raytheon.viz.gfe.product import TextDBUtil
|
||||
|
||||
prefStore = Activator.getDefault().getPreferenceStore()
|
||||
if prefStore.contains("TestVTECDecode"):
|
||||
testVtec = prefStore.getBoolean("TestVTECDecode")
|
||||
else:
|
||||
testVtec = False
|
||||
gfeMode = (DataManager.getCurrentInstance().getOpMode().name() == "OPERATIONAL")
|
||||
opMode = testVtec or gfeMode
|
||||
fullText = TextDBUtil.retrieveProduct(productID, opMode)
|
||||
textList = fullText.splitlines(True)
|
||||
return textList
|
||||
|
||||
def statusBarMsg(message, status, category="GFE"):
|
||||
from com.raytheon.uf.common.status import UFStatus
|
||||
from com.raytheon.uf.common.status import UFStatus_Priority as Priority
|
||||
from com.raytheon.viz.gfe import Activator
|
||||
from com.raytheon.viz.gfe.constants import StatusConstants
|
||||
|
||||
if "A" == status:
|
||||
importance = Priority.PROBLEM
|
||||
elif "R" == status:
|
||||
importance = Priority.EVENTA
|
||||
elif "U" == status:
|
||||
importance = Priority.CRITICAL
|
||||
else:
|
||||
importance = Priority.SIGNIFICANT
|
||||
|
||||
self._handler.handle(importance,message)
|
|
@ -407,9 +407,11 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
areas.add(areaName);
|
||||
}
|
||||
}
|
||||
Collections.sort(areas);
|
||||
return areas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveGroup(String groupName, List<String> areaNames) {
|
||||
statusHandler.handle(Priority.VERBOSE, "Save Edit Area Group: "
|
||||
+ groupName + " areas:" + areaNames);
|
||||
|
@ -469,6 +471,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteGroup(String groupName) {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
|
||||
|
@ -545,7 +548,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
refDataCache.remove(add.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for ReferenceSet taking a pointer to the Data Manager
|
||||
*
|
||||
|
@ -655,6 +658,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* @see
|
||||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#getActiveRefSet()
|
||||
*/
|
||||
@Override
|
||||
public ReferenceData getActiveRefSet() {
|
||||
return new ReferenceData(activeRefSet);
|
||||
}
|
||||
|
@ -666,6 +670,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#setActiveRefSet
|
||||
* (com.raytheon.edex.plugin.gfe.reference.ReferenceData)
|
||||
*/
|
||||
@Override
|
||||
public void setActiveRefSet(final ReferenceData refData) {
|
||||
refData.getGrid(); // force it to a grid
|
||||
|
||||
|
@ -706,6 +711,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#getAvailableSets
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public List<ReferenceID> getAvailableSets() {
|
||||
return Collections.unmodifiableList(availableSets);
|
||||
}
|
||||
|
@ -716,6 +722,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* @see
|
||||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#emptyRefSet()
|
||||
*/
|
||||
@Override
|
||||
public ReferenceData emptyRefSet() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
@ -725,6 +732,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
*
|
||||
* @see com.raytheon.viz.gfe.core.internal.IReferenceSetManager#fullRefSet()
|
||||
*/
|
||||
@Override
|
||||
public ReferenceData fullRefSet() {
|
||||
return FULL;
|
||||
}
|
||||
|
@ -736,6 +744,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#loadRefSet(com
|
||||
* .raytheon.edex.plugin.gfe.reference.ReferenceID)
|
||||
*/
|
||||
@Override
|
||||
public ReferenceData loadRefSet(final ReferenceID refSetID) {
|
||||
// UFStatus.handle(Priority.VERBOSE, Activator.PLUGIN_ID,
|
||||
// StatusConstants.CATEGORY_GFE, null, "LoadRefSet: " + refSetID);
|
||||
|
@ -789,6 +798,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* the referenceIDs
|
||||
* @return a List of ReferenceData
|
||||
*/
|
||||
@Override
|
||||
public List<ReferenceData> getReferenceData(List<ReferenceID> need) {
|
||||
List<ReferenceData> refData = new ArrayList<ReferenceData>();
|
||||
for (int i = 0; i < need.size(); i++) {
|
||||
|
@ -804,6 +814,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#saveActiveRefSet
|
||||
* (com.raytheon.edex.plugin.gfe.reference.ReferenceID)
|
||||
*/
|
||||
@Override
|
||||
public boolean saveActiveRefSet(final ReferenceID refID) {
|
||||
statusHandler.handle(Priority.VERBOSE, "saveActiveRefSet req=" + refID);
|
||||
|
||||
|
@ -832,6 +843,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#saveRefSet(com
|
||||
* .raytheon.edex.plugin.gfe.reference.ReferenceData)
|
||||
*/
|
||||
@Override
|
||||
public boolean saveRefSet(final ReferenceData orefData) {
|
||||
statusHandler.handle(Priority.VERBOSE,
|
||||
"SaveRefSet id=" + orefData.getId());
|
||||
|
@ -867,9 +879,9 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
"Unable to save reference set", e));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// cache it temporarily
|
||||
refDataCache.put(refData.getId().getName(), refData);
|
||||
refDataCache.put(refData.getId().getName(), refData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -881,6 +893,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#deleteRefSet(
|
||||
* com.raytheon.edex.plugin.gfe.reference.ReferenceID)
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteRefSet(final ReferenceID refID,
|
||||
boolean withVerification) {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
|
@ -911,6 +924,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
*
|
||||
* @see com.raytheon.viz.gfe.core.internal.IReferenceSetManager#undoRefSet()
|
||||
*/
|
||||
@Override
|
||||
public void undoRefSet() {
|
||||
ReferenceData newRefSet = prevRefSet;
|
||||
setActiveRefSet(newRefSet);
|
||||
|
@ -1020,6 +1034,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#taperGrid(com
|
||||
* .raytheon.edex.plugin.gfe.reference.ReferenceData, int)
|
||||
*/
|
||||
@Override
|
||||
public Grid2DFloat taperGrid(final ReferenceData refData, int taperFactor) {
|
||||
// Get some info and make a grid of zeros
|
||||
|
||||
|
@ -1106,6 +1121,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#directionTaperGrid
|
||||
* (com.raytheon.edex.plugin.gfe.reference.ReferenceData, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Grid2DFloat directionTaperGrid(final ReferenceData refData,
|
||||
final String direction) {
|
||||
|
||||
|
@ -1230,6 +1246,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#mySiteGridpoints
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public Grid2DBit mySiteGridpoints() {
|
||||
return siteGridpoints(Arrays.asList(dataManager.getSiteID()), true);
|
||||
}
|
||||
|
@ -1263,6 +1280,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
*
|
||||
* @see com.raytheon.viz.gfe.core.internal.IReferenceSetManager#getMode()
|
||||
*/
|
||||
@Override
|
||||
public RefSetMode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
@ -1274,6 +1292,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* com.raytheon.viz.gfe.core.internal.IReferenceSetManager#setMode(com.raytheon
|
||||
* .viz.gfe.core.internal.ReferenceSetManager.RefSetMode)
|
||||
*/
|
||||
@Override
|
||||
public void setMode(RefSetMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
@ -1514,6 +1533,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* @param slot
|
||||
* @return the quickset area
|
||||
*/
|
||||
@Override
|
||||
public ReferenceData getQuickSet(int slot) {
|
||||
// Return the ReferenceData contents of the given quickSet button
|
||||
ReferenceData result = emptyRefSet();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,10 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.procedures.menu;
|
||||
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.menus.CommandContributionItem;
|
||||
import org.eclipse.ui.menus.CommandContributionItemParameter;
|
||||
|
||||
/**
|
||||
* Specific contribution item for contributing procedures to the Hazards menu
|
||||
*
|
||||
|
@ -62,18 +58,4 @@ public class HazardsItems extends AbstractProcedureMenuItems {
|
|||
return "Hazards";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seecom.raytheon.viz.gfe.procedures.menu.AbstractProcedureMenuItems#
|
||||
* getAdditionalItems()
|
||||
*/
|
||||
@Override
|
||||
protected CommandContributionItemParameter[] getAdditionalItems() {
|
||||
return new CommandContributionItemParameter[] { new CommandContributionItemParameter(
|
||||
PlatformUI.getWorkbench(), getId(),
|
||||
"com.raytheon.viz.ghg.openmakehazards", null, null, null, null,
|
||||
"MakeHazard", null, null, CommandContributionItem.STYLE_PUSH,
|
||||
null, true) };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
id="com.raytheon.viz.ghg.openGhgMonitor"
|
||||
name="GHGHazardsMonnitor">
|
||||
</command>
|
||||
<command
|
||||
id="com.raytheon.viz.ghg.openmakehazards"
|
||||
name="MakeHazards">
|
||||
</command>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.handlers">
|
||||
|
@ -37,9 +33,5 @@
|
|||
class="com.raytheon.viz.ghg.GhgMonitorAction"
|
||||
commandId="com.raytheon.viz.ghg.openGhgMonitor">
|
||||
</handler>
|
||||
<handler
|
||||
class="com.raytheon.viz.ghg.MakeHazardsAction"
|
||||
commandId="com.raytheon.viz.ghg.openmakehazards">
|
||||
</handler>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
* 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.viz.ghg;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.ghg.makehazard.MakeHazardDialog;
|
||||
|
||||
/**
|
||||
* TODO Add Description MakeHazardsAction.java Jun 5, 2008
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 5, 2008 Eric Babin Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author ebabin
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MakeHazardsAction extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
DataManager dm = DataManager.getCurrentInstance();
|
||||
if (dm == null) {
|
||||
return null;
|
||||
}
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
MakeHazardDialog monitorDlg = new MakeHazardDialog(shell, dm);
|
||||
monitorDlg.open();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
scriptName=ghg/userPython/MakeHazard.py
|
||||
tcmScriptName=ghg/userPython/TCMETNDecoder.py
|
||||
hazardDict=gfe/userPython/procedures/MakeHazardConfig.py
|
||||
includePath=gfe/userPython/utilities/SmartScript.py:python/gfe/AbsTime.py:python/BaseTool.py:python/JUtil.py:gfe/userPython/textUtilities/regular:vtec/VTECTable.py
|
|
@ -129,22 +129,15 @@ def javaObjToPyVal(obj, customConverter=None):
|
|||
retVal = []
|
||||
size = obj.size()
|
||||
for i in range(size):
|
||||
retVal.append(javaObjToPyVal(obj.get(i)))
|
||||
retVal.append(javaObjToPyVal(obj.get(i), customConverter))
|
||||
elif objtype == "java.util.Collections$UnmodifiableRandomAccessList":
|
||||
tempList = []
|
||||
size = obj.size()
|
||||
for i in range(size):
|
||||
tempList.append(javaObjToPyVal(obj.get(i)))
|
||||
tempList.append(javaObjToPyVal(obj.get(i), customConverter))
|
||||
retVal = tuple(tempList)
|
||||
elif objtype == "java.util.HashMap":
|
||||
keys = obj.keySet()
|
||||
itr = keys.iterator()
|
||||
retVal = {}
|
||||
while itr.hasNext():
|
||||
key = itr.next()
|
||||
val = obj.get(key)
|
||||
fval = javaObjToPyVal(val)
|
||||
retVal[str(key)] = fval
|
||||
retVal = javaMapToPyDict(obj, customConverter)
|
||||
elif customConverter is not None:
|
||||
retVal = customConverter(obj)
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@ import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
|
@ -62,6 +66,19 @@ import com.vividsolutions.jts.operation.valid.IsValidOp;
|
|||
*/
|
||||
|
||||
public class TranslateReferenceSet {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TranslateReferenceSet.class);
|
||||
|
||||
private static JAXBManager jbm;
|
||||
static {
|
||||
try {
|
||||
jbm = new JAXBManager(ReferenceData.class);
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DefaultFilter implements FileFilter {
|
||||
|
||||
@Override
|
||||
|
@ -260,21 +277,30 @@ public class TranslateReferenceSet {
|
|||
/**
|
||||
* @param file
|
||||
* @throws SerializationException
|
||||
* @throws JAXBException
|
||||
*/
|
||||
public static void translateFile(File file) throws SerializationException,
|
||||
JAXBException {
|
||||
JAXBManager jbm = new JAXBManager(ReferenceData.class);
|
||||
public static void translateFile(File file) throws SerializationException {
|
||||
System.out.println("Translating file: " + file.getAbsoluteFile());
|
||||
if (file.isDirectory()) {
|
||||
for (File f : file.listFiles(new ExtensionFilter(".REFERENCE"))) {
|
||||
System.out.println("Translating: " + f.getAbsoluteFile());
|
||||
translateFile(f);
|
||||
}
|
||||
} else {
|
||||
ReferenceData refData = translate(file);
|
||||
if (refData != null) {
|
||||
String path = file.getAbsolutePath();
|
||||
path = path.substring(0, path.lastIndexOf('.')) + ".xml";
|
||||
String dir = file.getParentFile().getAbsolutePath();
|
||||
String fname = file.getName();
|
||||
fname = fname.replace(".REFERENCE", ".xml");
|
||||
fname = FileUtil.unmangle(fname);
|
||||
fname = fname.replace(" ", "_");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (char c : fname.toCharArray()) {
|
||||
if (FileUtil.VALID_FILENAME_CHARS.indexOf(c) == -1) {
|
||||
sb.append("-");
|
||||
} else {
|
||||
sb.append("c");
|
||||
}
|
||||
}
|
||||
String path = FileUtil.join(dir, fname);
|
||||
jbm.jaxbMarshalToXmlFile(refData, path);
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +312,7 @@ public class TranslateReferenceSet {
|
|||
File file = new File(arg);
|
||||
try {
|
||||
translateFile(file);
|
||||
} catch (Exception e) {
|
||||
} catch (SerializationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -457,7 +457,11 @@ public class LocalizationFile implements Comparable<LocalizationFile> {
|
|||
public boolean delete() throws LocalizationOpFailedException {
|
||||
if (exists()) {
|
||||
return adapter.delete(file, context, path);
|
||||
} else if (file.exists()) {
|
||||
// Local file does actually exist, delete manually
|
||||
return file.delete();
|
||||
}
|
||||
|
||||
// File doesn't exist, it is deleted, so technically success?
|
||||
return true;
|
||||
}
|
||||
|
@ -533,23 +537,30 @@ public class LocalizationFile implements Comparable<LocalizationFile> {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
LocalizationFile other = (LocalizationFile) obj;
|
||||
if (context == null) {
|
||||
if (other.context != null)
|
||||
if (other.context != null) {
|
||||
return false;
|
||||
} else if (!context.equals(other.context))
|
||||
}
|
||||
} else if (!context.equals(other.context)) {
|
||||
return false;
|
||||
}
|
||||
if (path == null) {
|
||||
if (other.path != null)
|
||||
if (other.path != null) {
|
||||
return false;
|
||||
} else if (!path.equals(other.path))
|
||||
}
|
||||
} else if (!path.equals(other.path)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue