Omaha #3392 Update a2acarsStub.py to use the DataAccessFramework. Add to msaslaps to VERSIONS file.

Change-Id: I3f6af9d46a4110b0bdcd6ed9bf8f7003bbe476e7

Former-commit-id: 50e6994fd3 [formerly bdb9ec6d229b21fa0fa9031f137ae2d6d9ea62c7]
Former-commit-id: a5288d2882
This commit is contained in:
Nathan Bowler 2014-07-23 09:51:06 -04:00
parent 1bef5a39a1
commit 169cd93aee
3 changed files with 225 additions and 95 deletions

View file

@ -19,4 +19,5 @@ thrift = 20080411p1 [0.9.0]
tpg = 3.1.2 [3.2.1]
ufpy = RAYTHEON-OWNED (AWIPS II)
werkzeug = 0.6.2 [0.8.3]
shapely = 1.2.16 [1.2.16]
shapely = 1.2.16 [1.2.16]
msaslaps = RAYTHEON-OWNED (AWIPS II)

60
pythonPackages/msaslaps/acars/a2acars.csh Normal file → Executable file
View file

@ -1,4 +1,25 @@
#!/bin/csh
##
# 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.
##
#
# A script wrapper around a UEngine call that is meant to get all available
# acars data in the A-II database over a specified range of times.
@ -14,7 +35,8 @@
# The literal p flag is optional. The p flag means preserve
# the final version of the python submitted to the UEngine instead of
# cleaning it up. The path to the finalized python is /tmp/a2acarsNNNNN.py
# where NNNNN is a unix process id.
# where NNNNN is a unix process id. This flag does nothing when using the
# DataAccessFramework.
#
# This outputs the following set of variables for each line:
#
@ -22,6 +44,18 @@
# pressure,flightPhase,rollQuality,temperature,windDir,windSpeed,
# relHumidity,mixRatio
#
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 07/23/2014 3392 nanbowle Initial modification. Passes parameters straight to DAF script instead of using sed.
#
#
#
set rmpy = yes
if ( "$1" == "p" ) then
set rmpy = no
@ -60,7 +94,7 @@ endif
#
grep DataAccessLayer $stubpy >& /dev/null
if ( $status == 0 ) then
set method = "daf"
/awips2/python/bin/python $stubpy -b "$1 $2" -e "$3 $4"
else
#
# Set up the environment we need to run the UEngine.
@ -79,18 +113,16 @@ else
exit
endif
source $ueenv
endif
#
set specpy = /tmp/a2acars${$}.py
rm -rf $specpy >& /dev/null
touch $specpy
chmod 775 $specpy
cat $stubpy | sed "s/BBBBB/$1 $2/g" | sed "s/EEEEE/$3 $4/g" > $specpy
if ( "$method" == "daf" ) then
/awips2/python/bin/python $specpy
else
set specpy = /tmp/a2acars${$}.py
rm -rf $specpy >& /dev/null
touch $specpy
chmod 775 $specpy
cat $stubpy | sed "s/BBBBB/$1 $2/g" | sed "s/EEEEE/$3 $4/g" > $specpy
cd $UE_BIN_PATH
( uengine -r python < $specpy ) | grep -v '<' | grep -v Response
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
endif
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
#

View file

@ -1,84 +1,181 @@
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
import BaseRequest
##
# 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.
##
br = BaseRequest.BaseRequest( "acars" )
br.addParameter("dataTime","BBBBB:00.0",">=")
br.addParameter("dataTime","EEEEE:59.9","<=")
# ArrayList of ResponseMessageGeneric
alrmg = br.execute()
nnn = alrmg.size()
if nnn == 0 :
return ResponseMessageGeneric("No data available.")
#
# Gets all available acars data in the A-II database over a specified range of
# times. The data is output to stdout as ASCII. Each line is one time/platform
# combination. The individual data items are comma delimited.
#
#
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 07/23/2014 3392 nanbowle Initial modification. Replaces UEngine with DAF.
#
#
#
# ResponseMessageGeneric payload is ACARSRecord
msg = ""
i = 0
while i < nnn :
oneRec = alrmg.get(i).getContents()
i += 1
mytime = oneRec.getDataURI().split('/',4)[2].split('.',2)[0]
if mytime == "" or mytime == "None" :
continue
mytail = str(oneRec.getTailNumber()).split(' ',2)[0]
myloc = str(oneRec.getLocation().getLocation()).split(' ',4)
mylat = myloc[2].split(')',2)[0]
mylon = myloc[1].split('(',2)[1]
if mylat == "" or mylon == "" or mylat == "None" or mylon == "None" :
continue
mylat = "%.4f"%float(mylat)
mylon = "%.4f"%float(mylon)
myrec = str(oneRec.getReceiver()).split(' ',2)[0]
if myrec == "None" :
myrec = ""
mypres = str(oneRec.getPressure())
if mypres == "" or mypres == "None" :
mypres = "1e37"
else :
mypres = "%.0f"%(float(mypres))
myphs = str(oneRec.getFlightPhase())
if myphs == "" or myphs == "None" :
myphs = "7"
else :
myphs = "%d"%int(myphs)
myrol = str(oneRec.getRollAngleQuality())
if myrol == "" or myrol == "None" :
myrol = "3"
else :
myrol = "%d"%int(myrol)
mytemp = str(oneRec.getTemp())
if mytemp == "" or mytemp == "None" :
mytemp = "1e37"
else :
mytemp = "%.1f"%float(mytemp)
mydir = str(oneRec.getWindDirection())
if mydir == "" or mydir == "None" :
mydir = "1e37"
else :
mydir = "%d"%int(mydir)
myspd = str(oneRec.getWindSpeed())
if myspd == "" or myspd == "None" :
myspd = "1e37"
else :
myspd = "%.1f"%float(myspd)
myhum = str(oneRec.getHumidity())
if myhum == "" or myhum == "None" :
myhum = "1e37"
else :
myhum = "%.0f"%float(myhum)
mymix = str(oneRec.getMixingRatio())
if mymix == "" or mymix == "None" :
mymix = "1e37"
else :
mymix = "%.2f"%float(mymix)
# myicg = str(oneRec.getIcing())
# if myicg == "" or myicg == "None" :
# myicg = "1e37"
# else :
# myicg = "%d"%int(myicg)
msg += mytail + "," + mytime + "," + mylat + "," + mylon + "," + \
myrec + "," + mypres + "," + myphs + "," + myrol + "," + \
mytemp + "," + mydir + "," + myspd + "," + myhum + "," + mymix + "\n"
# pass single RMG back to the uengine.
return ResponseMessageGeneric(msg)
import argparse
import sys
from datetime import datetime
from ufpy.dataaccess import DataAccessLayer
from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
def get_args():
parser = argparse.ArgumentParser(conflict_handler="resolve")
parser.add_argument("-h", action="store", dest="host",
help="EDEX server hostname (optional)",
metavar="hostname")
parser.add_argument("-b", action="store", dest="start",
help="The start of the time range in YYYY-MM-DD HH:MM",
metavar="start")
parser.add_argument("-e", action="store", dest="end",
help="The end of the time range in YYYY-MM-DD HH:MM",
metavar="end")
return parser.parse_args()
def main():
# Values used to indicate no data.
NO_DATA = [None, "None", -9999, -9999.0, "-9999", "-9999.0", ""]
user_args = get_args()
# Set the host in the DataAcessLayer if supplied
if user_args.host:
DataAccessLayer.changeEDEXHost(user_args.host)
start = user_args.start
end = user_args.end
if not start or not end:
print >> sys.stderr, "Start or End date not provided"
return
req = DataAccessLayer.newDataRequest("acars")
req.setParameters("tailNumber", "receiver", "pressure", "flightPhase",
"rollAngleQuality", "temp", "windDirection", "windSpeed",
"humidity", "mixingRatio", "icing")
beginRange = datetime.strptime( start + ":00.0", "%Y-%m-%d %H:%M:%S.%f")
endRange = datetime.strptime( end + ":59.9", "%Y-%m-%d %H:%M:%S.%f")
timerange = TimeRange(beginRange, endRange)
geometries = DataAccessLayer.getGeometryData(req, timerange)
if len(geometries) == 0:
# print("No data available.")
return
for geoData in geometries:
mytail = geoData.getString("tailNumber")
if mytail in NO_DATA:
mytail = ""
mytime = geoData.getDataTime()
if mytime == None:
continue
#2014-07-16 00:00:00 (0) => 2014-07-16_00:00:00
mytime = str(mytime)[0:19].replace(" ","_")
geo = geoData.getGeometry()
if geo == None:
continue
mylon = geo.x
mylat = geo.y
if (mylat in NO_DATA or mylon in NO_DATA):
continue
mylat = "%.4f"%float(mylat)
mylon = "%.4f"%float(mylon)
myrec = geoData.getString("receiver")
if myrec in NO_DATA:
myrec = ""
mypres = geoData.getNumber("pressure")
if mypres in NO_DATA:
mypres = "1e37"
else :
mypres = "%.0f"%mypres
myphs = geoData.getString("flightPhase")
if myphs in NO_DATA:
myphs = "7"
else :
myphs = "%d"%int(myphs)
myrol = geoData.getString("rollAngleQuality")
if myrol in NO_DATA:
myrol = "3"
else :
myrol = "%d"%int(myrol)
mytemp = geoData.getNumber("temp")
if mytemp in NO_DATA:
mytemp = "1e37"
else :
mytemp = "%.1f"%mytemp
mydir = geoData.getString("windDirection")
if mydir in NO_DATA:
mydir = "1e37"
else :
mydir = "%d"%int(mydir)
myspd = geoData.getNumber("windSpeed")
if myspd in NO_DATA:
myspd = "1e37"
else :
myspd = "%.1f"%myspd
myhum = geoData.getNumber("humidity")
if myhum in NO_DATA:
myhum = "1e37"
else :
myhum = "%.0f"%myhum
mymix = geoData.getNumber("mixingRatio")
if mymix in NO_DATA:
mymix = "1e37"
else :
mymix = "%.2f"%mymix
# Icing was commented out of the uengine version
# myicg = geoData.getString("icing")
# if myicg in NO_DATA:
# myicg = "1e37"
# else :
# myicg = "%d"%int(myicg)
msg = mytail + "," + mytime + "," + mylat + "," + mylon + "," + \
myrec + "," + mypres + "," + myphs + "," + myrol + "," + \
mytemp + "," + mydir + "," + myspd + "," + myhum + "," + mymix
print msg
if __name__ == '__main__':
main()