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:
parent
1bef5a39a1
commit
169cd93aee
3 changed files with 225 additions and 95 deletions
|
@ -20,3 +20,4 @@ tpg = 3.1.2 [3.2.1]
|
||||||
ufpy = RAYTHEON-OWNED (AWIPS II)
|
ufpy = RAYTHEON-OWNED (AWIPS II)
|
||||||
werkzeug = 0.6.2 [0.8.3]
|
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)
|
||||||
|
|
50
pythonPackages/msaslaps/acars/a2acars.csh
Normal file → Executable file
50
pythonPackages/msaslaps/acars/a2acars.csh
Normal file → Executable file
|
@ -1,4 +1,25 @@
|
||||||
#!/bin/csh
|
#!/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
|
# 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.
|
# 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 literal p flag is optional. The p flag means preserve
|
||||||
# the final version of the python submitted to the UEngine instead of
|
# 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
|
# 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:
|
# This outputs the following set of variables for each line:
|
||||||
#
|
#
|
||||||
|
@ -22,6 +44,18 @@
|
||||||
# pressure,flightPhase,rollQuality,temperature,windDir,windSpeed,
|
# pressure,flightPhase,rollQuality,temperature,windDir,windSpeed,
|
||||||
# relHumidity,mixRatio
|
# 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
|
set rmpy = yes
|
||||||
if ( "$1" == "p" ) then
|
if ( "$1" == "p" ) then
|
||||||
set rmpy = no
|
set rmpy = no
|
||||||
|
@ -60,7 +94,7 @@ endif
|
||||||
#
|
#
|
||||||
grep DataAccessLayer $stubpy >& /dev/null
|
grep DataAccessLayer $stubpy >& /dev/null
|
||||||
if ( $status == 0 ) then
|
if ( $status == 0 ) then
|
||||||
set method = "daf"
|
/awips2/python/bin/python $stubpy -b "$1 $2" -e "$3 $4"
|
||||||
else
|
else
|
||||||
#
|
#
|
||||||
# Set up the environment we need to run the UEngine.
|
# Set up the environment we need to run the UEngine.
|
||||||
|
@ -79,18 +113,16 @@ else
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
source $ueenv
|
source $ueenv
|
||||||
endif
|
|
||||||
#
|
|
||||||
set specpy = /tmp/a2acars${$}.py
|
set specpy = /tmp/a2acars${$}.py
|
||||||
rm -rf $specpy >& /dev/null
|
rm -rf $specpy >& /dev/null
|
||||||
touch $specpy
|
touch $specpy
|
||||||
chmod 775 $specpy
|
chmod 775 $specpy
|
||||||
cat $stubpy | sed "s/BBBBB/$1 $2/g" | sed "s/EEEEE/$3 $4/g" > $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
|
|
||||||
cd $UE_BIN_PATH
|
cd $UE_BIN_PATH
|
||||||
( uengine -r python < $specpy ) | grep -v '<' | grep -v Response
|
( uengine -r python < $specpy ) | grep -v '<' | grep -v Response
|
||||||
endif
|
|
||||||
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
|
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
|
||||||
#
|
endif
|
||||||
|
|
||||||
|
|
|
@ -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()
|
# Gets all available acars data in the A-II database over a specified range of
|
||||||
nnn = alrmg.size()
|
# times. The data is output to stdout as ASCII. Each line is one time/platform
|
||||||
if nnn == 0 :
|
# combination. The individual data items are comma delimited.
|
||||||
return ResponseMessageGeneric("No data available.")
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# SOFTWARE HISTORY
|
||||||
|
#
|
||||||
|
# Date Ticket# Engineer Description
|
||||||
|
# ------------ ---------- ----------- --------------------------
|
||||||
|
# 07/23/2014 3392 nanbowle Initial modification. Replaces UEngine with DAF.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# ResponseMessageGeneric payload is ACARSRecord
|
|
||||||
msg = ""
|
import argparse
|
||||||
i = 0
|
import sys
|
||||||
while i < nnn :
|
|
||||||
oneRec = alrmg.get(i).getContents()
|
from datetime import datetime
|
||||||
i += 1
|
from ufpy.dataaccess import DataAccessLayer
|
||||||
mytime = oneRec.getDataURI().split('/',4)[2].split('.',2)[0]
|
from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
|
||||||
if mytime == "" or mytime == "None" :
|
|
||||||
|
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
|
continue
|
||||||
mytail = str(oneRec.getTailNumber()).split(' ',2)[0]
|
#2014-07-16 00:00:00 (0) => 2014-07-16_00:00:00
|
||||||
myloc = str(oneRec.getLocation().getLocation()).split(' ',4)
|
mytime = str(mytime)[0:19].replace(" ","_")
|
||||||
mylat = myloc[2].split(')',2)[0]
|
|
||||||
mylon = myloc[1].split('(',2)[1]
|
geo = geoData.getGeometry()
|
||||||
if mylat == "" or mylon == "" or mylat == "None" or mylon == "None" :
|
if geo == None:
|
||||||
|
continue
|
||||||
|
mylon = geo.x
|
||||||
|
mylat = geo.y
|
||||||
|
if (mylat in NO_DATA or mylon in NO_DATA):
|
||||||
continue
|
continue
|
||||||
mylat = "%.4f"%float(mylat)
|
mylat = "%.4f"%float(mylat)
|
||||||
mylon = "%.4f"%float(mylon)
|
mylon = "%.4f"%float(mylon)
|
||||||
myrec = str(oneRec.getReceiver()).split(' ',2)[0]
|
|
||||||
if myrec == "None" :
|
myrec = geoData.getString("receiver")
|
||||||
|
if myrec in NO_DATA:
|
||||||
myrec = ""
|
myrec = ""
|
||||||
mypres = str(oneRec.getPressure())
|
|
||||||
if mypres == "" or mypres == "None" :
|
mypres = geoData.getNumber("pressure")
|
||||||
|
if mypres in NO_DATA:
|
||||||
mypres = "1e37"
|
mypres = "1e37"
|
||||||
else :
|
else :
|
||||||
mypres = "%.0f"%(float(mypres))
|
mypres = "%.0f"%mypres
|
||||||
myphs = str(oneRec.getFlightPhase())
|
|
||||||
if myphs == "" or myphs == "None" :
|
myphs = geoData.getString("flightPhase")
|
||||||
|
if myphs in NO_DATA:
|
||||||
myphs = "7"
|
myphs = "7"
|
||||||
else :
|
else :
|
||||||
myphs = "%d"%int(myphs)
|
myphs = "%d"%int(myphs)
|
||||||
myrol = str(oneRec.getRollAngleQuality())
|
|
||||||
if myrol == "" or myrol == "None" :
|
myrol = geoData.getString("rollAngleQuality")
|
||||||
|
if myrol in NO_DATA:
|
||||||
myrol = "3"
|
myrol = "3"
|
||||||
else :
|
else :
|
||||||
myrol = "%d"%int(myrol)
|
myrol = "%d"%int(myrol)
|
||||||
mytemp = str(oneRec.getTemp())
|
|
||||||
if mytemp == "" or mytemp == "None" :
|
mytemp = geoData.getNumber("temp")
|
||||||
|
if mytemp in NO_DATA:
|
||||||
mytemp = "1e37"
|
mytemp = "1e37"
|
||||||
else :
|
else :
|
||||||
mytemp = "%.1f"%float(mytemp)
|
mytemp = "%.1f"%mytemp
|
||||||
mydir = str(oneRec.getWindDirection())
|
|
||||||
if mydir == "" or mydir == "None" :
|
mydir = geoData.getString("windDirection")
|
||||||
|
if mydir in NO_DATA:
|
||||||
mydir = "1e37"
|
mydir = "1e37"
|
||||||
else :
|
else :
|
||||||
mydir = "%d"%int(mydir)
|
mydir = "%d"%int(mydir)
|
||||||
myspd = str(oneRec.getWindSpeed())
|
|
||||||
if myspd == "" or myspd == "None" :
|
myspd = geoData.getNumber("windSpeed")
|
||||||
|
if myspd in NO_DATA:
|
||||||
myspd = "1e37"
|
myspd = "1e37"
|
||||||
else :
|
else :
|
||||||
myspd = "%.1f"%float(myspd)
|
myspd = "%.1f"%myspd
|
||||||
myhum = str(oneRec.getHumidity())
|
|
||||||
if myhum == "" or myhum == "None" :
|
myhum = geoData.getNumber("humidity")
|
||||||
|
if myhum in NO_DATA:
|
||||||
myhum = "1e37"
|
myhum = "1e37"
|
||||||
else :
|
else :
|
||||||
myhum = "%.0f"%float(myhum)
|
myhum = "%.0f"%myhum
|
||||||
mymix = str(oneRec.getMixingRatio())
|
|
||||||
if mymix == "" or mymix == "None" :
|
mymix = geoData.getNumber("mixingRatio")
|
||||||
|
if mymix in NO_DATA:
|
||||||
mymix = "1e37"
|
mymix = "1e37"
|
||||||
else :
|
else :
|
||||||
mymix = "%.2f"%float(mymix)
|
mymix = "%.2f"%mymix
|
||||||
# myicg = str(oneRec.getIcing())
|
|
||||||
# if myicg == "" or myicg == "None" :
|
# Icing was commented out of the uengine version
|
||||||
|
# myicg = geoData.getString("icing")
|
||||||
|
# if myicg in NO_DATA:
|
||||||
# myicg = "1e37"
|
# myicg = "1e37"
|
||||||
# else :
|
# else :
|
||||||
# myicg = "%d"%int(myicg)
|
# 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.
|
msg = mytail + "," + mytime + "," + mylat + "," + mylon + "," + \
|
||||||
return ResponseMessageGeneric(msg)
|
myrec + "," + mypres + "," + myphs + "," + myrol + "," + \
|
||||||
|
mytemp + "," + mydir + "," + myspd + "," + myhum + "," + mymix
|
||||||
|
print msg
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue