Omaha #3392 Adding unmodified, existing a2acars scripts in order to maintain history.

Change-Id: Ifd853cec4a97d7008e58e6beee40a90731d16e12

Former-commit-id: 5211975c0c [formerly 22f8746715] [formerly 43d9e401af] [formerly 5211975c0c [formerly 22f8746715] [formerly 43d9e401af] [formerly 97d38c86cf [formerly 43d9e401af [formerly 86d82d1942f6c8c85eda7ba5fb16b75740a2d972]]]]
Former-commit-id: 97d38c86cf
Former-commit-id: 17a3d3e55d [formerly ee2a991810] [formerly f3c0a57d01ecc3e3e8f5d665be9f72cb8122bac7 [formerly 104fecf1f2]]
Former-commit-id: 0c9e9aba294ce3172352c1d1c23199fd08544d78 [formerly 9a920a79c6]
Former-commit-id: f96ec1d2d9
This commit is contained in:
Nathan Bowler 2014-07-23 08:11:12 -04:00
parent 8ff798ccfb
commit 8f6b77410b
3 changed files with 208 additions and 0 deletions

View file

@ -0,0 +1,96 @@
#!/bin/csh
#
# 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.
# The data is output to stdout as ASCII. Each line is one time/platform
# combination. The individual data items are comma delimited.
# This version can adapt to use a python stub that calls the
# data access framework.
#
# Usage:
#
# a2acars.csh {p} yyyy-mm-dd hh:mm yyyy-mm-dd hh:mm
#
# 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.
#
# This outputs the following set of variables for each line:
#
# tailNumber,asciitime,latitude,longitude,acarsReceivingStation,
# pressure,flightPhase,rollQuality,temperature,windDir,windSpeed,
# relHumidity,mixRatio
#
set rmpy = yes
if ( "$1" == "p" ) then
set rmpy = no
shift
endif
#
# Identify directory this script is in, will be one of the directories we
# search for other files in.
#
set mydir = `dirname $0`
set d1 = `echo $mydir | cut -c1`
if ( "$mydir" == '.' ) then
set mydir = $PWD
else if ( "$d1" != "/" ) then
set mydir = $PWD/$mydir
endif
set mydir = `(cd $mydir ; pwd)`
if ( ! $?FXA_HOME ) set FXA_HOME = xxxx
#
# Locate python stub that we will modify to create the final python logic.
#
if ( -e ./a2acarsStub.py ) then
set stubpy = ./a2acarsStub.py
else if ( -e $mydir/a2acarsStub.py ) then
set stubpy = $mydir/a2acarsStub.py
else if ( -e $FXA_HOME/src/dm/bufr/acars/a2acarsStub.py ) then
set stubpy = $FXA_HOME/src/dm/bufr/acars/a2acarsStub.py
else if ( -e $FXA_HOME/bin/a2acarsStub.py ) then
set stubpy = $FXA_HOME/bin/a2acarsStub.py
else
bash -c "echo could not find a2acarsStub.py 1>&2"
exit
endif
#
# Determine if we are using the data access framework or the uEngine.
#
grep DataAccessLayer $stubpy >& /dev/null
if ( $status == 0 ) then
set method = "daf"
else
#
# Set up the environment we need to run the UEngine.
#
set method = "uengine"
if ( -e ./UEngine.cshsrc ) then
set ueenv = ./UEngine.cshsrc
else if ( -e $mydir/UEngine.cshsrc ) then
set ueenv = $mydir/UEngine.cshsrc
else if ( -e $FXA_HOME/src/dm/point/UEngine.cshsrc ) then
set ueenv = $FXA_HOME/src/dm/point/UEngine.cshsrc
else if ( -e $FXA_HOME/bin/UEngine.cshsrc ) then
set ueenv = $FXA_HOME/bin/UEngine.cshsrc
else
bash -c "echo could not find UEngine.cshsrc 1>&2"
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
cd $UE_BIN_PATH
( uengine -r python < $specpy ) | grep -v '<' | grep -v Response
endif
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
#

View file

@ -0,0 +1,84 @@
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
import BaseRequest
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.")
# 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)

View file

@ -0,0 +1,28 @@
#
# Set up the environment we need to run the UEngine.
#
#set release = ""
#if ( -e /awips2/edex/conf/banner.txt ) then
# set release = `grep Version /awips2/edex/conf/banner.txt | tr '*' ' ' | \
# sed 's/ *$//g' | sed 's/^.* //g'`
#endif
#
while (1)
if ( $?INSTALL_BASE ) then
if ( -d $INSTALL_BASE/python ) break
endif
setenv INSTALL_BASE /awips2
break
end
if ( -e $INSTALL_BASE/bin/uengine ) then
setenv UE_BIN_PATH $INSTALL_BASE/bin
else
setenv UE_BIN_PATH $INSTALL_BASE/fxa/bin
endif
if ( ! $?PRE_ADE_PATH ) then
setenv PRE_ADE_PATH ${PATH}
endif
setenv JAVA_HOME $INSTALL_BASE/java
setenv LD_LIBRARY_PATH /usr/lib
setenv PYTHONPATH .:$INSTALL_BASE/bin/src
setenv PATH ${JAVA_HOME}/bin:${UE_BIN_PATH}:${PRE_ADE_PATH}