Omaha #3405 Adding unaltered, original airep and pirep scripts
Change-Id: I9daefa1c0c905b2022d7ad891a9983fb831c5ac3 Former-commit-id: 4a47a2053311ebc5ae4a5ad540c985c7a24ea4f3
This commit is contained in:
parent
1fd0ed2de6
commit
0a6cd0db2d
3 changed files with 483 additions and 0 deletions
186
pythonPackages/msaslaps/aireppirep/a2aircraft.csh
Normal file
186
pythonPackages/msaslaps/aireppirep/a2aircraft.csh
Normal file
|
@ -0,0 +1,186 @@
|
|||
#!/bin/csh
|
||||
#
|
||||
# A script wrapper around a UEngine call that is meant to get all available
|
||||
# maritime 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:
|
||||
#
|
||||
# a2aircraft.csh {p} {t} 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/a2aircraftNNNNN.py
|
||||
# where NNNNN is a unix process id.
|
||||
#
|
||||
# The optional literal t mean change some of the ascii phenomena descriptions
|
||||
# for pireps into codes suitable for D-2D format aircraft data files.
|
||||
#
|
||||
# This outputs the following set of variables for each line:
|
||||
#
|
||||
# lat|lon,asciitime,flightLevel,reportType,aircraftType,
|
||||
# temperature,windDir,windSpeed,visibility,
|
||||
# FlightWeather*,FlightHazard*,FlightConditions*,WeatherGroup*,
|
||||
# numCloudLayers,cloudBaseHeight,cloudTopHeight,cloudAmount,
|
||||
# numIcingLayers,heightBaseIcing,heightTopIcing,typeIcing,intensityOfIcing,
|
||||
# numTurbulenceLayers,heightBaseTurb,heightTopTurb,
|
||||
# typeTurbulence,intensityOfTurbulence
|
||||
#
|
||||
# Asterisk (*) means variable that does not directly correspond to a
|
||||
# variable in the D-2D format aircraft data files.
|
||||
#
|
||||
set rmpy = yes
|
||||
set typcod = qwertyuiop
|
||||
if ( "$1" == "t" ) then
|
||||
set typcod = "typecode = 'no'"
|
||||
shift
|
||||
endif
|
||||
if ( "$1" == "p" ) then
|
||||
set rmpy = no
|
||||
shift
|
||||
endif
|
||||
set repType = ""
|
||||
set rt = `echo $1 | tr 'a-z' 'A-Z' | grep '^.IREP$'`
|
||||
if ( "$rt" != "" ) then
|
||||
set repType = $rt
|
||||
shift
|
||||
endif
|
||||
if ( "$1" == "p" ) then
|
||||
set rmpy = no
|
||||
shift
|
||||
endif
|
||||
if ( "$1" == "t" ) then
|
||||
set typcod = "typecode = '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 ./a2airepStub.py ) then
|
||||
set stubpy = ./a2airepStub.py
|
||||
else if ( -e $mydir/a2airepStub.py ) then
|
||||
set stubpy = $mydir/a2airepStub.py
|
||||
else if ( -e $FXA_HOME/src/dm/bufr/acars/a2airepStub.py ) then
|
||||
set stubpy = $FXA_HOME/src/dm/bufr/acars/a2airepStub.py
|
||||
else if ( -e $FXA_HOME/bin/a2airepStub.py ) then
|
||||
set stubpy = $FXA_HOME/bin/a2airepStub.py
|
||||
else
|
||||
bash -c "echo could not find a2airepStub.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/a2airep${$}.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 ( "$repType" != "PIREP" ) then
|
||||
if ( "$method" == "daf" ) then
|
||||
/awips2/python/bin/python $specpy
|
||||
else
|
||||
set here = `pwd`
|
||||
cd $UE_BIN_PATH
|
||||
( uengine -r python < $specpy ) | grep -v '<' | grep -v Response
|
||||
cd $here
|
||||
endif
|
||||
endif
|
||||
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
|
||||
#
|
||||
# Locate python stub that we will modify to create the final python logic.
|
||||
#
|
||||
if ( -e ./a2pirepStub.py ) then
|
||||
set stubpy = ./a2pirepStub.py
|
||||
else if ( -e $mydir/a2pirepStub.py ) then
|
||||
set stubpy = $mydir/a2pirepStub.py
|
||||
else if ( -e $FXA_HOME/src/dm/bufr/acars/a2pirepStub.py ) then
|
||||
set stubpy = $FXA_HOME/src/dm/bufr/acars/a2pirepStub.py
|
||||
else if ( -e $FXA_HOME/bin/a2pirepStub.py ) then
|
||||
set stubpy = $FXA_HOME/bin/a2pirepStub.py
|
||||
else
|
||||
bash -c "echo could not find a2pirepStub.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 if ( "$method" == "daf" ) then
|
||||
#
|
||||
# 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/a2pirep${$}.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" | \
|
||||
grep -v "$typcod" > $specpy
|
||||
cd $UE_BIN_PATH
|
||||
if ( "$repType" != "AIREP" ) then
|
||||
if ( "$method" == "daf" ) then
|
||||
/awips2/python/bin/python $specpy
|
||||
else
|
||||
cd $UE_BIN_PATH
|
||||
( uengine -r python < $specpy ) | grep -v '<' | grep -v Response
|
||||
endif
|
||||
endif
|
||||
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
|
||||
#
|
78
pythonPackages/msaslaps/aireppirep/a2airepStub.py
Normal file
78
pythonPackages/msaslaps/aireppirep/a2airepStub.py
Normal file
|
@ -0,0 +1,78 @@
|
|||
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
|
||||
import BaseRequest
|
||||
|
||||
br = BaseRequest.BaseRequest( "airep" )
|
||||
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
|
||||
msg = "\n"
|
||||
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
|
||||
myloc = str(oneRec.getLocation().getLocation()).split(' ',4)
|
||||
mylat = myloc[2].split(')',2)[0]
|
||||
if mylat == "" or mylat == "None" :
|
||||
continue
|
||||
try:
|
||||
mylat = "%.4f"%float(mylat)
|
||||
except:
|
||||
continue
|
||||
mylon = myloc[1].split('(',2)[1]
|
||||
if mylon == "" or mylon == "None" :
|
||||
continue
|
||||
try:
|
||||
mylon = "%.4f"%float(mylon)
|
||||
except:
|
||||
continue
|
||||
myflvl = str(oneRec.getFlightLevel())
|
||||
if myflvl == "" or myflvl == "None" :
|
||||
myflvl = "1e37"
|
||||
else :
|
||||
myflvl = "%d"%int(myflvl)
|
||||
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)
|
||||
myfwx = str(oneRec.getFlightWeather())
|
||||
if myfwx == "" or myfwx == "None" :
|
||||
myfwx = "-1"
|
||||
else :
|
||||
myfwx = "%d"%int(myfwx)
|
||||
myhaz = str(oneRec.getFlightHazard())
|
||||
if myhaz == "" or myhaz == "None" :
|
||||
myhaz = "-1"
|
||||
else :
|
||||
myhaz = "%d"%int(myhaz)
|
||||
mycond = str(oneRec.getFlightConditions())
|
||||
if mycond == "" or mycond == "None" :
|
||||
mycond = "-1"
|
||||
else :
|
||||
mycond = "%d"%int(mycond)
|
||||
msg += mylat + "|" + mylon + "," + mytime + "," + myflvl + ",AIREP,," + \
|
||||
mytemp + "," + mydir + "," + myspd + ",1e37," + \
|
||||
myfwx + "," + myhaz + "," + mycond + ",,0,,,,0,,,,,0,,,,\n"
|
||||
|
||||
# pass single RMG back to the uengine.
|
||||
return ResponseMessageGeneric(msg)
|
219
pythonPackages/msaslaps/aireppirep/a2pirepStub.py
Normal file
219
pythonPackages/msaslaps/aireppirep/a2pirepStub.py
Normal file
|
@ -0,0 +1,219 @@
|
|||
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
|
||||
import BaseRequest
|
||||
|
||||
br = BaseRequest.BaseRequest( "pirep" )
|
||||
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.")
|
||||
typecode = 'yes'
|
||||
typecode = 'no'
|
||||
|
||||
# ResponseMessageGeneric payload
|
||||
msg = "\n"
|
||||
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
|
||||
myloc = str(oneRec.getLocation().getLocation()).split(' ',4)
|
||||
mylat = myloc[2].split(')',2)[0]
|
||||
if mylat == "" or mylat == "None" :
|
||||
continue
|
||||
try:
|
||||
mylat = "%.4f"%float(mylat)
|
||||
except:
|
||||
continue
|
||||
mylon = myloc[1].split('(',2)[1]
|
||||
if mylon == "" or mylon == "None" :
|
||||
continue
|
||||
try:
|
||||
mylon = "%.4f"%float(mylon)
|
||||
except:
|
||||
continue
|
||||
myflvl = str(oneRec.getFlightLevel())
|
||||
if myflvl == "" or myflvl == "None" :
|
||||
myflvl = "1e37"
|
||||
else :
|
||||
myflvl = "%d"%int(myflvl)
|
||||
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)
|
||||
myvis = str(oneRec.getHorzVisibility())
|
||||
if myvis == "" or myvis == "None" :
|
||||
myvis = "1e37"
|
||||
else :
|
||||
myvis = "%.1f"%float(myvis)
|
||||
mycraft = str(oneRec.getAircraftType())
|
||||
if mycraft == "None" :
|
||||
mycraft = ""
|
||||
mywx = str(oneRec.getWeatherGroup())
|
||||
if mywx == "None" :
|
||||
mywx = ""
|
||||
cc = 0
|
||||
cldBas = ""
|
||||
cldTop = ""
|
||||
cldVal = ""
|
||||
ii = 0
|
||||
icgBas = ""
|
||||
icgTop = ""
|
||||
icgTyp = ""
|
||||
icgVal = ""
|
||||
tt = 0
|
||||
trbBas = ""
|
||||
trbTop = ""
|
||||
trbTyp = ""
|
||||
trbVal = ""
|
||||
for pld in oneRec.getAncPirepData().toArray():
|
||||
sep = ""
|
||||
ltyp = pld.getLayerType()
|
||||
if ltyp == "" or ltyp == "None" :
|
||||
continue
|
||||
base = str(pld.getBaseLayerHeight())
|
||||
if base == "" or base == "None" or base == "99999" :
|
||||
base = "1e37"
|
||||
else :
|
||||
base = "%.0f"%float(base)
|
||||
top = str(pld.getTopLayerHeight())
|
||||
if top == "" or top == "None" or top == "99999" :
|
||||
top = "1e37"
|
||||
else :
|
||||
top = "%.0f"%float(top)
|
||||
dtyp = str(pld.getDataType())
|
||||
if dtyp == "None" :
|
||||
dtyp = ""
|
||||
fval = str(pld.getFirstValue())
|
||||
if fval == "None" :
|
||||
fval = ""
|
||||
sval = str(pld.getSecondValue())
|
||||
if sval == "None" :
|
||||
sval = ""
|
||||
if ltyp == "CLOUD" :
|
||||
if fval == "TOP" :
|
||||
fval = ""
|
||||
if sval == "TOP" :
|
||||
sval = ""
|
||||
if sval != "" :
|
||||
fval += "-"+sval
|
||||
if typecode == 'yes' :
|
||||
if fval == "CLR" :
|
||||
fval = "0"
|
||||
elif fval == "OVC" :
|
||||
fval = "8"
|
||||
elif fval == "SCT" :
|
||||
fval = "11"
|
||||
elif fval == "BKN" :
|
||||
fval = "12"
|
||||
elif fval == "FEW" :
|
||||
fval = "13"
|
||||
else :
|
||||
continue
|
||||
if cldBas != "" :
|
||||
sep = "|"
|
||||
cldBas += sep+base
|
||||
cldTop += sep+top
|
||||
cldVal += sep+fval
|
||||
cc += 1
|
||||
elif ltyp == "ICING" :
|
||||
if sval != "" :
|
||||
fval += "-"+sval
|
||||
if icgBas != "" :
|
||||
sep = "|"
|
||||
if typecode == 'yes' :
|
||||
if dtyp == "RIME" :
|
||||
dtyp = "1"
|
||||
elif dtyp == "CLR" :
|
||||
dtyp = "2"
|
||||
elif dtyp == "MXD" :
|
||||
dtyp = "3"
|
||||
else :
|
||||
dtyp = "-9999"
|
||||
if fval == "NEG" :
|
||||
fval = "0";
|
||||
elif fval == "TRACE" :
|
||||
fval = "1"
|
||||
elif fval == "TRACE-LGT" :
|
||||
fval = "2"
|
||||
elif fval == "LGT" :
|
||||
fval = "3"
|
||||
elif fval == "LGT-MOD" :
|
||||
fval = "4"
|
||||
elif fval == "MOD" :
|
||||
fval = "5"
|
||||
elif fval == "MOD-SEV" :
|
||||
fval = "7"
|
||||
elif fval == "SEV" :
|
||||
fval = "8"
|
||||
else :
|
||||
fval = "-9999"
|
||||
if fval == "-9999" and dtyp == "-9999" :
|
||||
continue
|
||||
icgBas += sep+base
|
||||
icgTop += sep+top
|
||||
icgTyp += sep+dtyp
|
||||
icgVal += sep+fval
|
||||
ii += 1
|
||||
elif ltyp == "TURBC" :
|
||||
if sval != "" :
|
||||
fval += "-"+sval
|
||||
if typecode == 'yes' :
|
||||
if dtyp == "CAT" :
|
||||
dtyp = "1"
|
||||
elif dtyp == "CHOP" :
|
||||
dtyp = "2"
|
||||
else :
|
||||
dtyp = "-9999"
|
||||
if fval == "NEG" :
|
||||
fval = "0";
|
||||
elif fval == "LGT" :
|
||||
fval = "2"
|
||||
elif fval == "LGT-MOD" :
|
||||
fval = "3"
|
||||
elif fval == "MOD" :
|
||||
fval = "4"
|
||||
elif fval == "MOD-SEV" :
|
||||
fval = "5"
|
||||
elif fval == "SEV" :
|
||||
fval = "6"
|
||||
elif fval == "EXTRM" :
|
||||
fval = "8"
|
||||
else :
|
||||
fval = "-9999"
|
||||
if fval == "-9999" and dtyp == "-9999" :
|
||||
continue
|
||||
if trbBas != "" :
|
||||
sep = "|"
|
||||
trbBas += sep+base
|
||||
trbTop += sep+top
|
||||
trbTyp += sep+dtyp
|
||||
trbVal += sep+fval
|
||||
tt += 1
|
||||
msg += mylat + "|" + mylon + "," + mytime + "," + myflvl + ",PIREP," + \
|
||||
mycraft + "," + mytemp + "," + mydir + "," + myspd + "," + \
|
||||
myvis + ",-1,-1,-1," + mywx + "," + \
|
||||
str(cc) + "," + cldBas + "," + cldTop + "," + cldVal + "," + \
|
||||
str(ii) + "," + icgBas + "," + icgTop + "," + \
|
||||
icgTyp + "," + icgVal + "," + \
|
||||
str(tt) + "," + trbBas + "," + trbTop + "," + \
|
||||
trbTyp + "," + trbVal + "\n"
|
||||
|
||||
# pass single RMG back to the uengine.
|
||||
return ResponseMessageGeneric(msg)
|
Loading…
Add table
Reference in a new issue