Omaha #3393 Original, unmodified a2-rad scripts
Change-Id: I7f064472341a62baf4ced5365d295c299c25911f Former-commit-id:1ef2c72cc4
[formerly1ef2c72cc4
[formerly 5ec651f777eebeb707eb19e45a0410482b367aea]] Former-commit-id:b4130011eb
Former-commit-id:6e3a9819eb
This commit is contained in:
parent
fabc057a53
commit
1779f0af02
7 changed files with 1096 additions and 0 deletions
BIN
pythonPackages/msaslaps/common/gtasUtil
Normal file
BIN
pythonPackages/msaslaps/common/gtasUtil
Normal file
Binary file not shown.
108
pythonPackages/msaslaps/common/msgCodeSeds.txt
Normal file
108
pythonPackages/msaslaps/common/msgCodeSeds.txt
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# 35 36 37 38 41 50 51 57 65 66 67 81 85 86 90
|
||||||
|
s/^0 *$/0|STImotion/g
|
||||||
|
s/^2 *$/2|GSM/g
|
||||||
|
s/^3 *$/3|PRR/g
|
||||||
|
s/^6 *$/6|AAP/g
|
||||||
|
s/^8 *$/8|PTL/g
|
||||||
|
s/^9 *$/9|AM/g
|
||||||
|
s/^16 *$/16|Z 1km 3bit/g
|
||||||
|
s/^17 *$/17|Z 2km 3bit/g
|
||||||
|
s/^18 *$/18|Z 4km 3bit/g
|
||||||
|
s/^19 *$/19|Z 1km 4bit/g
|
||||||
|
s/^20 *$/20|Z 2km 4bit/g
|
||||||
|
s/^21 *$/21|Z 4km 4bit/g
|
||||||
|
s/^22 *$/22|V 0.25km 3bit/g
|
||||||
|
s/^23 *$/23|V 0.5km 3bit/g
|
||||||
|
s/^24 *$/24|V 1km 3bit/g
|
||||||
|
s/^25 *$/25|V 0.25km 4bit/g
|
||||||
|
s/^26 *$/26|V 0.5km 4bit/g
|
||||||
|
s/^27 *$/27|V 1km 4bit/g
|
||||||
|
s/^28 *$/28|SW 0.25km 3bit/g
|
||||||
|
s/^29 *$/29|SW 0.5km 3bit/g
|
||||||
|
s/^30 *$/30|SW 1km 3bit/g
|
||||||
|
s/^31 *$/31|USP 2km 4bit/g
|
||||||
|
s/^32 *$/32|DHR 1km 8bit/g
|
||||||
|
s/^33 *$/33|HSR 1km 4bit/g
|
||||||
|
s/^34 *$/34|CFC 1km 3bit/g
|
||||||
|
s/^35 *$/35|CZ 1km 3bit/g
|
||||||
|
s/^36 *$/36|CZ 4km 3bit/g
|
||||||
|
s/^37 *$/37|CZ 1km 4bit/g
|
||||||
|
s/^38 *$/38|CZ 4km 4bit/g
|
||||||
|
s/^41 *$/41|ET 4km 4bit/g
|
||||||
|
s/^48 *$/48|VWP/g
|
||||||
|
s/^50 *$/50|RCS 1km 4bit/g
|
||||||
|
s/^51 *$/51|VCS 0.5km 4bit/g
|
||||||
|
s/^55 *$/55|SRR 0.5km 4bit/g
|
||||||
|
s/^56 *$/56|SRM 1km 4bit/g
|
||||||
|
s/^57 *$/57|VIL 4km 4bit/g
|
||||||
|
s/^58 *$/58|STI/g
|
||||||
|
s/^59 *$/59|HI/g
|
||||||
|
s/^60 *$/60|M/g
|
||||||
|
s/^61 *$/61|TVS/g
|
||||||
|
s/^62 *$/62|SS/g
|
||||||
|
s/^65 *$/65|LRM 4km 3bit/g
|
||||||
|
s/^66 *$/66|LRM 4km 3bit/g
|
||||||
|
s/^67 *$/67|APR 4km 3bit/g
|
||||||
|
s/^73 *$/73|UAM/g
|
||||||
|
s/^74 *$/74|RCM/g
|
||||||
|
s/^75 *$/75|FTM/g
|
||||||
|
s/^78 *$/78|OHP 2km 4bit/g
|
||||||
|
s/^79 *$/79|THP 2km 4bit/g
|
||||||
|
s/^80 *$/80|STP 2km 4bit/g
|
||||||
|
s/^81 *$/81|DPA 4km 8bit/g
|
||||||
|
s/^82 *$/82|SPD 40km 3bit/g
|
||||||
|
s/^84 *$/84|VAD/g
|
||||||
|
s/^85 *$/85|RCS 1km 3bit/g
|
||||||
|
s/^86 *$/86|VCS 0.5km 3bit/g
|
||||||
|
s/^90 *$/90|LRM 4km 3bit/g
|
||||||
|
s/^93 *$/93|DBV 1km 8bit/g
|
||||||
|
s/^94 *$/94|Z 1km 8bit/g
|
||||||
|
s/^99 *$/99|V 0.25km 8bit/g
|
||||||
|
s/^100 *$/100|VSDT/g
|
||||||
|
s/^101 *$/101|STIT/g
|
||||||
|
s/^102 *$/102|HIT/g
|
||||||
|
s/^103 *$/103|MT/g
|
||||||
|
s/^104 *$/104|TVST/g
|
||||||
|
s/^107 *$/107|OHPT/g
|
||||||
|
s/^108 *$/108|THPT/g
|
||||||
|
s/^109 *$/109|STPT/g
|
||||||
|
s/^132 *$/132|CLR 1km 4bit/g
|
||||||
|
s/^133 *$/133|CLD 1km 4bit/g
|
||||||
|
s/^134 *$/134|DVL 1km 8bit/g
|
||||||
|
s/^135 *$/135|EET 1km 8bit/g
|
||||||
|
s/^136 *$/136|SO/g
|
||||||
|
s/^137 *$/137|ULR 1km 4bit/g
|
||||||
|
s/^138 *$/138|STP 2km 8bit/g
|
||||||
|
s/^139 *$/139|MRU/g
|
||||||
|
s/^140 *$/140|GFM/g
|
||||||
|
s/^141 *$/141|MD/g
|
||||||
|
s/^143 *$/143|TRU/g
|
||||||
|
s/^144 *$/144|OSW 2km 4bit/g
|
||||||
|
s/^145 *$/145|OSD 2km 4bit/g
|
||||||
|
s/^146 *$/146|SSW 2km 4bit/g
|
||||||
|
s/^147 *$/147|SSD 2km 4bit/g
|
||||||
|
s/^149 *$/149|DMD/g
|
||||||
|
s/^150 *$/150|USW 2km 4bit/g
|
||||||
|
s/^151 *$/151|USD 2km 4bit/g
|
||||||
|
s/^152 *$/152|RSS/g
|
||||||
|
s/^153 *$/153|Z 0.25km 0.5Deg 8bit/g
|
||||||
|
s/^154 *$/154|V 0.25km 0.5Deg 8bit/g
|
||||||
|
s/^155 *$/155|SW 0.25km 0.5Deg 8bit/g
|
||||||
|
s/^158 *$/158|ZDR 1km 4bit/g
|
||||||
|
s/^159 *$/159|ZDR 0.25km 8bit/g
|
||||||
|
s/^160 *$/160|CC 1km 4bit/g
|
||||||
|
s/^161 *$/161|CC 0.25km 8bit/g
|
||||||
|
s/^162 *$/162|KDP 1km 4bit/g
|
||||||
|
s/^163 *$/163|KDP 0.25km 8bit/g
|
||||||
|
s/^164 *$/164|HC 1km 4bit/g
|
||||||
|
s/^165 *$/165|HC 0.25km 8bit/g
|
||||||
|
s/^166 *$/166|ML/g
|
||||||
|
s/^169 *$/169|OHA 2km 4bit/g
|
||||||
|
s/^170 *$/170|DAA 0.25km 8bit/g
|
||||||
|
s/^171 *$/171|STA 2km 4bit/g
|
||||||
|
s/^172 *$/172|STA 0.25km 8bit/g
|
||||||
|
s/^173 *$/173|DUA 0.25km 8bit/g
|
||||||
|
s/^174 *$/174|DOD 0.25km 8bit/g
|
||||||
|
s/^175 *$/175|DSD 0.25km 8bit/g
|
||||||
|
s/^176 *$/176|DPR 0.25km gen/g
|
||||||
|
s/^177 *$/177|HHC 0.25km 8bit/g
|
172
pythonPackages/msaslaps/radar/a2advrad.csh
Normal file
172
pythonPackages/msaslaps/radar/a2advrad.csh
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
#!/bin/csh
|
||||||
|
#
|
||||||
|
# A script wrapper that is meant to get data for a single radar product
|
||||||
|
# from the A-II database. The result is output to stdout as ASCII.
|
||||||
|
# The first line has the dimensions of the data, the volume scan time,
|
||||||
|
# 'radial' or 'raster', elevation number, a product description, the tilt
|
||||||
|
# angle or layer, and the VCP. The second line contains the level labels,
|
||||||
|
# and the third line has a partial list of the product dependent parameters.
|
||||||
|
# If the product is radial, the fourth line contains a list of the
|
||||||
|
# radial angles. Otherwise each line after that has data for one
|
||||||
|
# radial/row, as a sequence of space delimited plain decimal integers.
|
||||||
|
#
|
||||||
|
# The product description includes the mnemonic, the resolution, and
|
||||||
|
# the bit depth. If the azimuthal resolution is finer than 1 degree,
|
||||||
|
# the product description will additionally include a note of that.
|
||||||
|
# The product dependent parameters as defined in an 88D RPG product
|
||||||
|
# are 28 signed two byte integers. The list here includes those
|
||||||
|
# with indices from 17 to 26 (C indexing).
|
||||||
|
#
|
||||||
|
# Note that for now, this is only designed to return data for image
|
||||||
|
# products.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# a2gtrad.csh {p} {x} radar msgcode {elev} date time {slop}
|
||||||
|
#
|
||||||
|
# p - A literal p. (optional)
|
||||||
|
# x - A literal x. (optional) Expanded set of header information.
|
||||||
|
# radar - four character radar id
|
||||||
|
# msgcode - RPG message code
|
||||||
|
# elev - tilt angle/layer value. defaults to 0.
|
||||||
|
# date - yyyy-mm-dd
|
||||||
|
# time - hh:mm
|
||||||
|
# slop - seconds of slop either side, defaults to 60
|
||||||
|
#
|
||||||
|
# The tilt angles specified are primary tilt angles for a range of tilts.
|
||||||
|
#
|
||||||
|
# The literal p option 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/a2gtradNNNNN.py where NNNNN is a unix process id.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
set rmpy = yes
|
||||||
|
set fff = ""
|
||||||
|
if ( "$1" == "p" ) then
|
||||||
|
set rmpy = no
|
||||||
|
shift
|
||||||
|
endif
|
||||||
|
if ( "$1" == "x" ) then
|
||||||
|
set fff = "x"
|
||||||
|
shift
|
||||||
|
endif
|
||||||
|
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
|
||||||
|
set fxa_home = $FXA_HOME
|
||||||
|
if ( $?STAGING ) then
|
||||||
|
set fxa_home = $STAGING/D-2D
|
||||||
|
endif
|
||||||
|
#
|
||||||
|
# Set up the environment we need to run the 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
|
||||||
|
#
|
||||||
|
# Locate python stub that we will modify to create the final UEngine script
|
||||||
|
#
|
||||||
|
if ( -e ./a2gtradStub.py ) then
|
||||||
|
set stubpy = ./a2gtradStub.py
|
||||||
|
else if ( -e $mydir/a2gtradStub.py ) then
|
||||||
|
set stubpy = $mydir/a2gtradStub.py
|
||||||
|
else if ( -e $fxa_home/src/dm/radar/a2gtradStub.py ) then
|
||||||
|
set stubpy = $fxa_home/src/dm/radar/a2gtradStub.py
|
||||||
|
else if ( -e $FXA_HOME/bin/a2gtradStub.py ) then
|
||||||
|
set stubpy = $FXA_HOME/bin/a2gtradStub.py
|
||||||
|
else
|
||||||
|
bash -c "echo could not find a2gtradStub.py 1>&2"
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
#
|
||||||
|
# Locate file that lets us provide a description of the data set.
|
||||||
|
#
|
||||||
|
if ( -e ./msgCodeSeds.txt ) then
|
||||||
|
set mctrans = $PWD/msgCodeSeds.txt
|
||||||
|
else if ( -e $mydir/msgCodeSeds.txt ) then
|
||||||
|
set mctrans = $mydir/msgCodeSeds.txt
|
||||||
|
else if ( -e $fxa_home/src/dm/radar/msgCodeSeds.txt ) then
|
||||||
|
set mctrans = $fxa_home/src/dm/radar/msgCodeSeds.txt
|
||||||
|
else if ( -e $FXA_HOME/data/msgCodeSeds.txt ) then
|
||||||
|
set mctrans = $FXA_HOME/data/msgCodeSeds.txt
|
||||||
|
else
|
||||||
|
bash -c "echo could not find msgCodeSeds.txt 1>&2"
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
#
|
||||||
|
#
|
||||||
|
set rrr = $1
|
||||||
|
set mmm = $2
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
set ddd = `echo $mmm | sed -f $mctrans | cut '-d|' -f2 `
|
||||||
|
#
|
||||||
|
# Get program that can do math with ascii time string, then use this to
|
||||||
|
# properly encode range of times for which we look for data.
|
||||||
|
#
|
||||||
|
if ( -x ./gtasUtil ) then
|
||||||
|
set gtasUtil = ./gtasUtil
|
||||||
|
else if ( -x $mydir/gtasUtil ) then
|
||||||
|
set gtasUtil = $mydir/gtasUtil
|
||||||
|
else if ( -x $fxa_home/src/dm/point/gtasUtil ) then
|
||||||
|
set gtasUtil = $fxa_home/src/dm/point/gtasUtil
|
||||||
|
else if ( -x $FXA_HOME/bin/gtasUtil ) then
|
||||||
|
set gtasUtil = $FXA_HOME/bin/gtasUtil
|
||||||
|
else
|
||||||
|
bash -c "echo could not find gtasUtil executable 1>&2"
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
set eee = `echo $1 | grep -v '.*-'`
|
||||||
|
if ( "$eee" != "" ) shift
|
||||||
|
set slop = `echo $3 | grep '[0-9]'`
|
||||||
|
if ( "$slop" == "" ) set slop = 60
|
||||||
|
set aaa = `$gtasUtil = $1 $2 -$slop`
|
||||||
|
set bbb = `$gtasUtil = $1 $2 $slop`
|
||||||
|
#
|
||||||
|
# Modify the text of special tags in stub to create finalized script.
|
||||||
|
#
|
||||||
|
set specpy = /tmp/a2gtrad${$}.py
|
||||||
|
rm -rf $specpy >& /dev/null
|
||||||
|
touch $specpy
|
||||||
|
chmod 775 $specpy
|
||||||
|
if ( "$eee" == "" ) then
|
||||||
|
cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \
|
||||||
|
sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \
|
||||||
|
sed "s/DDDDD/$ddd/g" | sed 's/^.*EEEE.*$//g' >> $specpy
|
||||||
|
else
|
||||||
|
cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \
|
||||||
|
sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \
|
||||||
|
sed "s/DDDDD/$ddd/g" | sed "s/EEEE/$eee/g" >> $specpy
|
||||||
|
endif
|
||||||
|
#
|
||||||
|
# Submit the temporary python script stripping xml stuff, then remove it
|
||||||
|
#
|
||||||
|
cd $UE_BIN_PATH
|
||||||
|
( uengine -r python < $specpy ) | grep -v '<' | sed 's/>/>/g' | \
|
||||||
|
sed 's/</</g' | grep -v Response
|
||||||
|
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
|
||||||
|
#
|
177
pythonPackages/msaslaps/radar/a2advradStub.py
Normal file
177
pythonPackages/msaslaps/radar/a2advradStub.py
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
import BaseRequest
|
||||||
|
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
|
||||||
|
from com.raytheon.edex.plugin.radar.dao import RadarDao
|
||||||
|
|
||||||
|
# Perform a radar request for data of interest
|
||||||
|
rr = BaseRequest.BaseRequest("radar")
|
||||||
|
rr.addParameter("icao","KKKK","=")
|
||||||
|
rr.addParameter("productCode","MMMM","=")
|
||||||
|
rr.addParameter("primaryElevationAngle","EEEE","=")
|
||||||
|
rr.addParameter("dataTime","AAAAA",">=")
|
||||||
|
rr.addParameter("dataTime","BBBBB","<=")
|
||||||
|
hedfmt = "FFF"
|
||||||
|
|
||||||
|
result = rr.execute()
|
||||||
|
size = result.size()
|
||||||
|
if size == 0:
|
||||||
|
return ResponseMessageGeneric("Data not available")
|
||||||
|
|
||||||
|
# ResponseMessageGeneric. Payload is RadarRecord
|
||||||
|
rmg = result.get(0)
|
||||||
|
# return rmg
|
||||||
|
|
||||||
|
# RadarRecord
|
||||||
|
rrec = rmg.getContents()
|
||||||
|
|
||||||
|
#
|
||||||
|
# From here to the end is the part we know how to do for radar but not
|
||||||
|
# for radar.
|
||||||
|
#
|
||||||
|
mytime = rrec.getDataURI().split('/',4)[2]
|
||||||
|
|
||||||
|
# RadarDao. Inherits from PluginDao, which has a getHDF5Data method,
|
||||||
|
# which takes a PluginDataObject as an arg.
|
||||||
|
raddao = RadarDao("radar")
|
||||||
|
|
||||||
|
# returns IDataRecord[]. IDataRecord is implemented by only one class --
|
||||||
|
# AbstractStorageRecord. ASR is extended by a few *DataRecord classes; one
|
||||||
|
# of them is ByteDataRecord
|
||||||
|
idra = raddao.getHDF5Data(rrec,-1)
|
||||||
|
|
||||||
|
msg = "No data."
|
||||||
|
if len(idra) > 0:
|
||||||
|
# pick radar Data record
|
||||||
|
# record 0 contains Angles getFloatData
|
||||||
|
# record 1 contains Data getByteData
|
||||||
|
# record 2 contains DependentValues getShortData
|
||||||
|
# record 3 contains ProductVals getByteData
|
||||||
|
# record 4 contains RecordVals getByteData
|
||||||
|
# record 5 contains StormIds getByteData
|
||||||
|
# record 6 contains Symbology getByteData
|
||||||
|
# record 7 contains SymbologyData getByteData
|
||||||
|
# record 8 contains Thresholds getShortData
|
||||||
|
dattyp = "raster"
|
||||||
|
for ii in range(len(idra)):
|
||||||
|
if idra[ii].getName() == "Data":
|
||||||
|
rdat = idra[ii]
|
||||||
|
elif idra[ii].getName() == "Angles":
|
||||||
|
azdat = idra[ii]
|
||||||
|
dattyp = "radial"
|
||||||
|
elif idra[ii].getName() == "DependentValues":
|
||||||
|
depVals = idra[ii].getShortData()
|
||||||
|
# elif idra[ii].getName() == "ProductVals":
|
||||||
|
# prodVals = idra[ii].getByteData()
|
||||||
|
# elif idra[ii].getName() == "RecordVals":
|
||||||
|
# recVals = idra[ii].getByteData()
|
||||||
|
# elif idra[ii].getName() == "StormIds":
|
||||||
|
# stormVals = idra[ii].getByteData()
|
||||||
|
# elif idra[ii].getName() == "Symbology":
|
||||||
|
# symVals = idra[ii].getByteData()
|
||||||
|
# elif idra[ii].getName() == "SymbologyData":
|
||||||
|
# symData = idra[ii].getByteData()
|
||||||
|
elif idra[ii].getName() == "Thresholds":
|
||||||
|
threshVals = idra[ii].getShortData()
|
||||||
|
|
||||||
|
# this hints at the IDR's concrete class: ByteDataRecord
|
||||||
|
#print "true type of IDataRecord:", idr.getDataObject().toString()
|
||||||
|
|
||||||
|
dim = rdat.getDimension()
|
||||||
|
if dim != 2:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
||||||
|
yLen = rdat.getSizes()[0]
|
||||||
|
xLen = rdat.getSizes()[1]
|
||||||
|
|
||||||
|
# byte[] -- the raw data
|
||||||
|
array = rdat.getByteData()
|
||||||
|
arraySize = len(array)
|
||||||
|
if xLen * yLen != arraySize:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
||||||
|
# get data for azimuth angles if we have them.
|
||||||
|
if dattyp == "radial" :
|
||||||
|
azVals = azdat.getFloatData()
|
||||||
|
azValsLen = len(azVals)
|
||||||
|
if yLen != azValsLen:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
description = "DDDDD"
|
||||||
|
|
||||||
|
# Encode dimensions, time, mapping, description, tilt, and VCP
|
||||||
|
if hedfmt == "x" :
|
||||||
|
msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
||||||
|
dattyp + " " + str(rrec.getLatitude()) + " " + \
|
||||||
|
str(rrec.getLongitude()) + " " + \
|
||||||
|
str(rrec.getElevation()) + " " + \
|
||||||
|
str(rrec.getElevationNumber()) + " " + \
|
||||||
|
description + " " + str(rrec.getTrueElevationAngle()) + " " + \
|
||||||
|
str(rrec.getVolumeCoveragePattern()) + "\n"
|
||||||
|
else :
|
||||||
|
msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
||||||
|
dattyp + " " + description + " " + \
|
||||||
|
str(rrec.getTrueElevationAngle()) + " " + \
|
||||||
|
str(rrec.getVolumeCoveragePattern()) + "\n"
|
||||||
|
|
||||||
|
# Encode level labels
|
||||||
|
spec = [".", "TH", "ND", "RF", "BI", "GC", "IC", "GR", "WS", "DS",
|
||||||
|
"RA", "HR", "BD", "HA", "UK"]
|
||||||
|
nnn = len(threshVals)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
lo = threshVals[j] % 256
|
||||||
|
hi = threshVals[j] / 256
|
||||||
|
msg += " "
|
||||||
|
j += 1
|
||||||
|
if hi < 0 :
|
||||||
|
if lo > 14 :
|
||||||
|
msg += "."
|
||||||
|
else :
|
||||||
|
msg += spec[lo]
|
||||||
|
continue
|
||||||
|
if hi % 16 >= 8 :
|
||||||
|
msg += ">"
|
||||||
|
elif hi % 8 >= 4 :
|
||||||
|
msg += "<"
|
||||||
|
if hi % 4 >= 2 :
|
||||||
|
msg += "+"
|
||||||
|
elif hi % 2 >= 1 :
|
||||||
|
msg += "-"
|
||||||
|
if hi >= 64 :
|
||||||
|
msg += "%.2f"%(lo*0.01)
|
||||||
|
elif hi % 64 >= 32 :
|
||||||
|
msg += "%.2f"%(lo*0.05)
|
||||||
|
elif hi % 32 >= 16 :
|
||||||
|
msg += "%.1f"%(lo*0.1)
|
||||||
|
else :
|
||||||
|
msg += str(lo)
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
# Encode product dependent parameters 17 through 26
|
||||||
|
nnn = len(depVals)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
msg += " " + str(depVals[j])
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
if dattyp == "radial" :
|
||||||
|
j = 0
|
||||||
|
while j<azValsLen :
|
||||||
|
msg += "%.1f"%azVals[j] + " "
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
nxy = yLen*xLen
|
||||||
|
j = 0
|
||||||
|
while j<nxy :
|
||||||
|
i = 0
|
||||||
|
while i<xLen :
|
||||||
|
if array[i+j]<0 :
|
||||||
|
msg += str(256+array[i+j]) + " "
|
||||||
|
else :
|
||||||
|
msg += str(array[i+j]) + " "
|
||||||
|
i += 1
|
||||||
|
msg += "\n"
|
||||||
|
j += xLen
|
||||||
|
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
205
pythonPackages/msaslaps/radar/a2gtrad.csh
Normal file
205
pythonPackages/msaslaps/radar/a2gtrad.csh
Normal file
|
@ -0,0 +1,205 @@
|
||||||
|
#!/bin/csh
|
||||||
|
#
|
||||||
|
# A script wrapper that is meant to get data for a single radar product
|
||||||
|
# from the A-II database. The result is output to stdout as ASCII.
|
||||||
|
# The first line has the dimensions of the data, the volume scan time,
|
||||||
|
# 'radial' or 'raster', elevation number, a product description, the tilt
|
||||||
|
# angle or layer, and the VCP. The second line contains the level labels,
|
||||||
|
# and the third line has a partial list of the product dependent parameters.
|
||||||
|
# If the product is radial, the fourth line contains a list of the radial
|
||||||
|
# angles. Otherwise each line after that has data for one radial/row.
|
||||||
|
# The data for each radial/row undergoes second order compression.
|
||||||
|
# Each pixel value of 0 or 255 is encoded as @ or #, respectively. Otherwise
|
||||||
|
# the first pixel on the row and any pixel that is more than 20 counts
|
||||||
|
# different than the previous one is encoded as two hex digits. Pixels the
|
||||||
|
# same as the previous are encoded as a period, pixels from 1 to 20 counts less
|
||||||
|
# than the previous are encoded as G through Z, and pixels from 1 to 20 counts
|
||||||
|
# more than the previous are encoded as g through z. There are no delimeters
|
||||||
|
# between the encoding for each pixel.
|
||||||
|
#
|
||||||
|
# The product description includes the mnemonic, the resolution, and
|
||||||
|
# the bit depth. If the azimuthal resolution is finer than 1 degree,
|
||||||
|
# the product description will additionally include a note of that.
|
||||||
|
# The product dependent parameters as defined in an 88D RPG product
|
||||||
|
# are 28 signed two byte integers. The list here includes those
|
||||||
|
# with indices from 17 to 26 (C indexing).
|
||||||
|
#
|
||||||
|
# This version can adapt to use a python stub that calls the
|
||||||
|
# data access framework.
|
||||||
|
#
|
||||||
|
# Note that for now, this is only designed to return data for image
|
||||||
|
# products.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# a2gtrad.csh {p} {x} {h|i} radar msgcode {elev} date time {slop}
|
||||||
|
#
|
||||||
|
# p - A literal p. (optional)
|
||||||
|
# x - A literal x. (optional) Expanded set of header information.
|
||||||
|
# h|i - (optional) A literal h or literal i.
|
||||||
|
# Output pure undelimited hex or delimited integer values.
|
||||||
|
# radar - four character radar id
|
||||||
|
# msgcode - RPG message code
|
||||||
|
# elev - tilt angle/layer value. defaults to 0.
|
||||||
|
# date - yyyy-mm-dd
|
||||||
|
# time - hh:mm
|
||||||
|
# slop - seconds of slop either side, defaults to 60
|
||||||
|
#
|
||||||
|
# The tilt angles specified are primary tilt angles for a range of tilts.
|
||||||
|
#
|
||||||
|
# The literal p option 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/a2gtradNNNNN.py where NNNNN is a unix process id.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
set rmpy = yes
|
||||||
|
set fff = ""
|
||||||
|
set encoding = 2
|
||||||
|
while (1)
|
||||||
|
if ( "$1" == "p" ) then
|
||||||
|
set rmpy = no
|
||||||
|
shift
|
||||||
|
else if ( "$1" == "x" ) then
|
||||||
|
set fff = "x"
|
||||||
|
shift
|
||||||
|
else if ( "$1" == "h" ) then
|
||||||
|
set encoding = 1
|
||||||
|
shift
|
||||||
|
else if ( "$1" == "i" ) then
|
||||||
|
set encoding = 0
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
end
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
set fxa_home = $FXA_HOME
|
||||||
|
if ( $?STAGING ) then
|
||||||
|
set fxa_home = $STAGING/D-2D
|
||||||
|
endif
|
||||||
|
#
|
||||||
|
# Locate python stub that we will modify to create the final python logic.
|
||||||
|
#
|
||||||
|
if ( -e ./a2gtradStub.py ) then
|
||||||
|
set stubpy = ./a2gtradStub.py
|
||||||
|
else if ( -e $mydir/a2gtradStub.py ) then
|
||||||
|
set stubpy = $mydir/a2gtradStub.py
|
||||||
|
else if ( -e $fxa_home/src/dm/radar/a2gtradStub.py ) then
|
||||||
|
set stubpy = $fxa_home/src/dm/radar/a2gtradStub.py
|
||||||
|
else if ( -e $FXA_HOME/bin/a2gtradStub.py ) then
|
||||||
|
set stubpy = $FXA_HOME/bin/a2gtradStub.py
|
||||||
|
else
|
||||||
|
bash -c "echo could not find a2gtradStub.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
|
||||||
|
#
|
||||||
|
# Locate file that lets us provide a description of the data set.
|
||||||
|
#
|
||||||
|
if ( -e ./msgCodeSeds.txt ) then
|
||||||
|
set mctrans = $PWD/msgCodeSeds.txt
|
||||||
|
else if ( -e $mydir/msgCodeSeds.txt ) then
|
||||||
|
set mctrans = $mydir/msgCodeSeds.txt
|
||||||
|
else if ( -e $fxa_home/src/dm/radar/msgCodeSeds.txt ) then
|
||||||
|
set mctrans = $fxa_home/src/dm/radar/msgCodeSeds.txt
|
||||||
|
else if ( -e $FXA_HOME/data/msgCodeSeds.txt ) then
|
||||||
|
set mctrans = $FXA_HOME/data/msgCodeSeds.txt
|
||||||
|
else
|
||||||
|
bash -c "echo could not find msgCodeSeds.txt 1>&2"
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
#
|
||||||
|
#
|
||||||
|
set rrr = $1
|
||||||
|
set mmm = $2
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
set ddd = `echo $mmm | sed -f $mctrans | cut '-d|' -f2 `
|
||||||
|
#
|
||||||
|
# Get program that can do math with ascii time string, then use this to
|
||||||
|
# properly encode range of times for which we look for data.
|
||||||
|
#
|
||||||
|
if ( -x ./gtasUtil ) then
|
||||||
|
set gtasUtil = ./gtasUtil
|
||||||
|
else if ( -x $mydir/gtasUtil ) then
|
||||||
|
set gtasUtil = $mydir/gtasUtil
|
||||||
|
else if ( -x $fxa_home/src/dm/point/gtasUtil ) then
|
||||||
|
set gtasUtil = $fxa_home/src/dm/point/gtasUtil
|
||||||
|
else if ( -x $FXA_HOME/bin/gtasUtil ) then
|
||||||
|
set gtasUtil = $FXA_HOME/bin/gtasUtil
|
||||||
|
else
|
||||||
|
bash -c "echo could not find gtasUtil executable 1>&2"
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
set eee = `echo $1 | grep -v '.*-'`
|
||||||
|
if ( "$eee" != "" ) shift
|
||||||
|
set slop = `echo $3 | grep '[0-9]'`
|
||||||
|
if ( "$slop" == "" ) set slop = 60
|
||||||
|
set aaa = `$gtasUtil = $1 $2 -$slop`
|
||||||
|
set bbb = `$gtasUtil = $1 $2 $slop`
|
||||||
|
#
|
||||||
|
# Modify the text of special tags in stub to create finalized script.
|
||||||
|
#
|
||||||
|
set specpy = /tmp/a2gtrad${$}.py
|
||||||
|
rm -rf $specpy >& /dev/null
|
||||||
|
touch $specpy
|
||||||
|
chmod 775 $specpy
|
||||||
|
if ( "$eee" == "" ) then
|
||||||
|
cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \
|
||||||
|
sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \
|
||||||
|
sed "s/DDDDD/$ddd/g" | sed 's/^.*EEEE.*$//g' | \
|
||||||
|
sed "s/XXXXX/$encoding/g" >> $specpy
|
||||||
|
else
|
||||||
|
cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \
|
||||||
|
sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \
|
||||||
|
sed "s/DDDDD/$ddd/g" | sed "s/EEEE/$eee/g" | \
|
||||||
|
sed "s/XXXXX/$encoding/g" >> $specpy
|
||||||
|
endif
|
||||||
|
#
|
||||||
|
# Submit the temporary python script stripping xml stuff, then remove it
|
||||||
|
#
|
||||||
|
if ( "$method" == "daf" ) then
|
||||||
|
/awips2/python/bin/python $specpy
|
||||||
|
else
|
||||||
|
cd $UE_BIN_PATH
|
||||||
|
( uengine -r python < $specpy ) | grep -v '<' | sed 's/>/>/g' | \
|
||||||
|
sed 's/</</g' | grep -v Response
|
||||||
|
endif
|
||||||
|
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
|
||||||
|
#
|
208
pythonPackages/msaslaps/radar/a2gtradStub.py
Normal file
208
pythonPackages/msaslaps/radar/a2gtradStub.py
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
import BaseRequest
|
||||||
|
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
|
||||||
|
from com.raytheon.edex.plugin.radar.dao import RadarDao
|
||||||
|
|
||||||
|
# Perform a radar request for data of interest
|
||||||
|
rr = BaseRequest.BaseRequest("radar")
|
||||||
|
rr.addParameter("icao","KKKK","=")
|
||||||
|
rr.addParameter("productCode","MMMM","=")
|
||||||
|
rr.addParameter("primaryElevationAngle","EEEE","=")
|
||||||
|
rr.addParameter("dataTime","AAAAA",">=")
|
||||||
|
rr.addParameter("dataTime","BBBBB","<=")
|
||||||
|
hedfmt = "FFF"
|
||||||
|
encoding = XXXXX
|
||||||
|
|
||||||
|
result = rr.execute()
|
||||||
|
size = result.size()
|
||||||
|
if size == 0:
|
||||||
|
return ResponseMessageGeneric("Data not available")
|
||||||
|
|
||||||
|
# ResponseMessageGeneric. Payload is RadarRecord
|
||||||
|
rmg = result.get(0)
|
||||||
|
# return rmg
|
||||||
|
|
||||||
|
# RadarRecord
|
||||||
|
rrec = rmg.getContents()
|
||||||
|
|
||||||
|
#
|
||||||
|
# From here to the end is the part we know how to do for radar but not
|
||||||
|
# for radar.
|
||||||
|
#
|
||||||
|
mytime = rrec.getDataURI().split('/',4)[2]
|
||||||
|
|
||||||
|
# RadarDao. Inherits from PluginDao, which has a getHDF5Data method,
|
||||||
|
# which takes a PluginDataObject as an arg.
|
||||||
|
raddao = RadarDao("radar")
|
||||||
|
|
||||||
|
# returns IDataRecord[]. IDataRecord is implemented by only one class --
|
||||||
|
# AbstractStorageRecord. ASR is extended by a few *DataRecord classes; one
|
||||||
|
# of them is ByteDataRecord
|
||||||
|
idra = raddao.getHDF5Data(rrec,-1)
|
||||||
|
|
||||||
|
msg = "No data."
|
||||||
|
if len(idra) > 0:
|
||||||
|
# pick radar Data record
|
||||||
|
# record 0 contains Angles getFloatData
|
||||||
|
# record 1 contains Data getByteData
|
||||||
|
# record 2 contains DependentValues getShortData
|
||||||
|
# record 3 contains ProductVals getByteData
|
||||||
|
# record 4 contains RecordVals getByteData
|
||||||
|
# record 5 contains StormIds getByteData
|
||||||
|
# record 6 contains Symbology getByteData
|
||||||
|
# record 7 contains SymbologyData getByteData
|
||||||
|
# record 8 contains Thresholds getShortData
|
||||||
|
dattyp = "raster"
|
||||||
|
for ii in range(len(idra)):
|
||||||
|
if idra[ii].getName() == "Data":
|
||||||
|
rdat = idra[ii]
|
||||||
|
elif idra[ii].getName() == "Angles":
|
||||||
|
azdat = idra[ii]
|
||||||
|
dattyp = "radial"
|
||||||
|
elif idra[ii].getName() == "DependentValues":
|
||||||
|
depVals = idra[ii].getShortData()
|
||||||
|
# elif idra[ii].getName() == "ProductVals":
|
||||||
|
# prodVals = idra[ii].getByteData()
|
||||||
|
# elif idra[ii].getName() == "RecordVals":
|
||||||
|
# recVals = idra[ii].getByteData()
|
||||||
|
# elif idra[ii].getName() == "StormIds":
|
||||||
|
# stormVals = idra[ii].getByteData()
|
||||||
|
# elif idra[ii].getName() == "Symbology":
|
||||||
|
# symVals = idra[ii].getByteData()
|
||||||
|
# elif idra[ii].getName() == "SymbologyData":
|
||||||
|
# symData = idra[ii].getByteData()
|
||||||
|
elif idra[ii].getName() == "Thresholds":
|
||||||
|
threshVals = idra[ii].getShortData()
|
||||||
|
|
||||||
|
# this hints at the IDR's concrete class: ByteDataRecord
|
||||||
|
#print "true type of IDataRecord:", idr.getDataObject().toString()
|
||||||
|
|
||||||
|
dim = rdat.getDimension()
|
||||||
|
if dim != 2:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
||||||
|
yLen = rdat.getSizes()[0]
|
||||||
|
xLen = rdat.getSizes()[1]
|
||||||
|
|
||||||
|
# byte[] -- the raw data
|
||||||
|
array = rdat.getByteData()
|
||||||
|
arraySize = len(array)
|
||||||
|
if xLen * yLen != arraySize:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
||||||
|
# get data for azimuth angles if we have them.
|
||||||
|
if dattyp == "radial" :
|
||||||
|
azVals = azdat.getFloatData()
|
||||||
|
azValsLen = len(azVals)
|
||||||
|
if yLen != azValsLen:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
description = "DDDDD"
|
||||||
|
|
||||||
|
# Encode dimensions, time, mapping, description, tilt, and VCP
|
||||||
|
if hedfmt == "x" :
|
||||||
|
msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
||||||
|
dattyp + " " + str(rrec.getLatitude()) + " " + \
|
||||||
|
str(rrec.getLongitude()) + " " + \
|
||||||
|
str(rrec.getElevation()) + " " + \
|
||||||
|
str(rrec.getElevationNumber()) + " " + \
|
||||||
|
description + " " + str(rrec.getTrueElevationAngle()) + " " + \
|
||||||
|
str(rrec.getVolumeCoveragePattern()) + "\n"
|
||||||
|
else :
|
||||||
|
msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
||||||
|
dattyp + " " + description + " " + \
|
||||||
|
str(rrec.getTrueElevationAngle()) + " " + \
|
||||||
|
str(rrec.getVolumeCoveragePattern()) + "\n"
|
||||||
|
|
||||||
|
# Encode level labels
|
||||||
|
spec = [".", "TH", "ND", "RF", "BI", "GC", "IC", "GR", "WS", "DS",
|
||||||
|
"RA", "HR", "BD", "HA", "UK"]
|
||||||
|
nnn = len(threshVals)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
lo = threshVals[j] % 256
|
||||||
|
hi = threshVals[j] / 256
|
||||||
|
msg += " "
|
||||||
|
j += 1
|
||||||
|
if hi < 0 :
|
||||||
|
if lo > 14 :
|
||||||
|
msg += "."
|
||||||
|
else :
|
||||||
|
msg += spec[lo]
|
||||||
|
continue
|
||||||
|
if hi % 16 >= 8 :
|
||||||
|
msg += ">"
|
||||||
|
elif hi % 8 >= 4 :
|
||||||
|
msg += "<"
|
||||||
|
if hi % 4 >= 2 :
|
||||||
|
msg += "+"
|
||||||
|
elif hi % 2 >= 1 :
|
||||||
|
msg += "-"
|
||||||
|
if hi >= 64 :
|
||||||
|
msg += "%.2f"%(lo*0.01)
|
||||||
|
elif hi % 64 >= 32 :
|
||||||
|
msg += "%.2f"%(lo*0.05)
|
||||||
|
elif hi % 32 >= 16 :
|
||||||
|
msg += "%.1f"%(lo*0.1)
|
||||||
|
else :
|
||||||
|
msg += str(lo)
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
# Encode product dependent parameters 17 through 26
|
||||||
|
nnn = len(depVals)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
msg += " " + str(depVals[j])
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
if dattyp == "radial" :
|
||||||
|
j = 0
|
||||||
|
while j<azValsLen :
|
||||||
|
msg += "%.1f"%azVals[j] + " "
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
plus = " ghijklmnopqrstuvwxyz"
|
||||||
|
minus = " GHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
nxy = yLen*xLen
|
||||||
|
j = 0
|
||||||
|
while j<nxy :
|
||||||
|
i = 0
|
||||||
|
kk = array[i+j]
|
||||||
|
if kk<0 : kk += 256
|
||||||
|
if encoding == 0 :
|
||||||
|
msg += str(kk)
|
||||||
|
elif encoding == 1 :
|
||||||
|
msg += "%2.2x"%kk
|
||||||
|
elif kk == 0 :
|
||||||
|
msg += "@"
|
||||||
|
elif kk == 255 :
|
||||||
|
msg += "#"
|
||||||
|
else :
|
||||||
|
msg += "%2.2x"%kk
|
||||||
|
i += 1
|
||||||
|
while i<xLen :
|
||||||
|
k = array[i+j]
|
||||||
|
if k<0 : kk += 256
|
||||||
|
if encoding == 0 :
|
||||||
|
msg += " "+str(k)
|
||||||
|
elif encoding == 1 :
|
||||||
|
msg += "%2.2x"%k
|
||||||
|
elif k==0 :
|
||||||
|
msg += "@"
|
||||||
|
elif k == 255 :
|
||||||
|
msg += "#"
|
||||||
|
elif k==kk :
|
||||||
|
msg += "."
|
||||||
|
elif k>kk+20 or k<kk-20 :
|
||||||
|
msg += "%2.2x"%k
|
||||||
|
elif k>kk :
|
||||||
|
msg += plus[k-kk]
|
||||||
|
else :
|
||||||
|
msg += minus[kk-k]
|
||||||
|
kk = k
|
||||||
|
i += 1
|
||||||
|
msg += "\n"
|
||||||
|
j += xLen
|
||||||
|
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
226
pythonPackages/msaslaps/radar/a2gtradStubAll.py
Normal file
226
pythonPackages/msaslaps/radar/a2gtradStubAll.py
Normal file
|
@ -0,0 +1,226 @@
|
||||||
|
import BaseRequest
|
||||||
|
import RadarRequest
|
||||||
|
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
|
||||||
|
from com.raytheon.edex.plugin.radar.dao import RadarDao
|
||||||
|
import numpy
|
||||||
|
|
||||||
|
# Perform a radar request for data of interest
|
||||||
|
rr = BaseRequest.BaseRequest("radar")
|
||||||
|
rr.addParameter("icao","KKKK","=")
|
||||||
|
rr.addParameter("productCode","MMMM","=")
|
||||||
|
rr.addParameter("primaryElevationAngle","EEEE","=")
|
||||||
|
rr.addParameter("dataTime","AAAAA",">=")
|
||||||
|
rr.addParameter("dataTime","BBBBB","<=")
|
||||||
|
|
||||||
|
result = rr.execute()
|
||||||
|
size = result.size()
|
||||||
|
if size == 0:
|
||||||
|
return ResponseMessageGeneric("Data not available")
|
||||||
|
|
||||||
|
# ResponseMessageGeneric. Payload is RadarRecord
|
||||||
|
rmg = result.get(0)
|
||||||
|
# return rmg
|
||||||
|
|
||||||
|
# RadarRecord
|
||||||
|
rrec = rmg.getContents()
|
||||||
|
|
||||||
|
#
|
||||||
|
# From here to the end is the part we know how to do for radar but not
|
||||||
|
# for radar.
|
||||||
|
#
|
||||||
|
mytime = rrec.getDataURI().split('/',4)[2]
|
||||||
|
|
||||||
|
# RadarDao. Inherits from PluginDao, which has a getHDF5Data method,
|
||||||
|
# which takes a PluginDataObject as an arg.
|
||||||
|
raddao = RadarDao("radar")
|
||||||
|
|
||||||
|
# returns IDataRecord[]. IDataRecord is implemented by only one class --
|
||||||
|
# AbstractStorageRecord. ASR is extended by a few *DataRecord classes; one
|
||||||
|
# of them is ByteDataRecord
|
||||||
|
idra = raddao.getHDF5Data(rrec,-1)
|
||||||
|
|
||||||
|
msg = "No data."
|
||||||
|
if len(idra) > 0:
|
||||||
|
# pick radar Data record
|
||||||
|
# record 0 contains Angles getFloatData
|
||||||
|
# record 1 contains Data getByteData
|
||||||
|
# record 2 contains DependentValues getShortData
|
||||||
|
# record 3 contains ProductVals getByteData
|
||||||
|
# record 4 contains RecordVals getByteData
|
||||||
|
# record 5 contains StormIds getByteData
|
||||||
|
# record 6 contains Symbology getByteData
|
||||||
|
# record 7 contains SymbologyData getByteData
|
||||||
|
# record 8 contains Thresholds getShortData
|
||||||
|
dattyp = "raster"
|
||||||
|
for ii in range(len(idra)):
|
||||||
|
if idra[ii].getName() == "Data":
|
||||||
|
rdat = idra[ii]
|
||||||
|
elif idra[ii].getName() == "Angles":
|
||||||
|
azdat = idra[ii]
|
||||||
|
dattyp = "radial"
|
||||||
|
elif idra[ii].getName() == "DependentValues":
|
||||||
|
depVals = idra[ii].getShortData()
|
||||||
|
elif idra[ii].getName() == "ProductVals":
|
||||||
|
prodVals = idra[ii].getByteData()
|
||||||
|
elif idra[ii].getName() == "RecordVals":
|
||||||
|
recVals = idra[ii].getByteData()
|
||||||
|
elif idra[ii].getName() == "StormIds":
|
||||||
|
stormVals = idra[ii].getByteData()
|
||||||
|
elif idra[ii].getName() == "Symbology":
|
||||||
|
symVals = idra[ii].getByteData()
|
||||||
|
elif idra[ii].getName() == "SymbologyData":
|
||||||
|
symData = idra[ii].getByteData()
|
||||||
|
elif idra[ii].getName() == "Thresholds":
|
||||||
|
threshVals = idra[ii].getShortData()
|
||||||
|
|
||||||
|
# this hints at the IDR's concrete class: ByteDataRecord
|
||||||
|
#print "true type of IDataRecord:", idr.getDataObject().toString()
|
||||||
|
|
||||||
|
dim = rdat.getDimension()
|
||||||
|
if dim != 2:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
||||||
|
yLen = rdat.getSizes()[0]
|
||||||
|
xLen = rdat.getSizes()[1]
|
||||||
|
|
||||||
|
# byte[] -- the raw data
|
||||||
|
array = rdat.getByteData()
|
||||||
|
arraySize = len(array)
|
||||||
|
if xLen * yLen != arraySize:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
||||||
|
# get data for azimuth angles if we have them.
|
||||||
|
if dattyp == "radial" :
|
||||||
|
azVals = azdat.getFloatData()
|
||||||
|
azValsLen = len(azVals)
|
||||||
|
if yLen != azValsLen:
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
description = "DDDDD"
|
||||||
|
|
||||||
|
msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + dattyp + \
|
||||||
|
" " + description + "\n"
|
||||||
|
msg += str(rrec.getTrueElevationAngle()) + " " + \
|
||||||
|
str(rrec.getVolumeCoveragePattern()) + "\n"
|
||||||
|
|
||||||
|
nnn = len(depVals)
|
||||||
|
msg += str(nnn)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
if depVals[j]<0 :
|
||||||
|
msg += " " + "%4.4X"%(65536+depVals[j])
|
||||||
|
else :
|
||||||
|
msg += " " + "%4.4X"%depVals[j]
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
nnn = len(prodVals)
|
||||||
|
msg += str(nnn)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
if prodVals[j]<0 :
|
||||||
|
msg += " " + "%2.2X"%(255+prodVals[j])
|
||||||
|
else :
|
||||||
|
msg += " " + "%2.2X"%prodVals[j]
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
nnn = len(recVals)
|
||||||
|
msg += str(nnn)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
if recVals[j]<0 :
|
||||||
|
msg += " " + "%2.2X"%(255+recVals[j])
|
||||||
|
else :
|
||||||
|
msg += " " + "%2.2X"%recVals[j]
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
nnn = len(stormVals)
|
||||||
|
msg += str(nnn)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
if stormVals[j]<0 :
|
||||||
|
msg += " " + "%2.2X"%(255+stormVals[j])
|
||||||
|
else :
|
||||||
|
msg += " " + "%2.2X"%stormVals[j]
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
nnn = len(symVals)
|
||||||
|
msg += str(nnn)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
if symVals[j]<0 :
|
||||||
|
msg += " " + "%2.2X"%(255+symVals[j])
|
||||||
|
else :
|
||||||
|
msg += " " + "%2.2X"%symVals[j]
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
nnn = len(symData)
|
||||||
|
msg += str(nnn)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
if symData[j]<0 :
|
||||||
|
msg += " " + "%2.2X"%(255+symData[j])
|
||||||
|
else :
|
||||||
|
msg += " " + "%2.2X"%symData[j]
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
spec = [".", "TH", "ND", "RF", "BI", "GC", "IC", "GR", "WS", "DS",
|
||||||
|
"RA", "HR", "BD", "HA", "UK"]
|
||||||
|
nnn = len(threshVals)
|
||||||
|
msg += str(nnn)
|
||||||
|
j = 0
|
||||||
|
while j<nnn :
|
||||||
|
lo = threshVals[j] % 256
|
||||||
|
hi = threshVals[j] / 256
|
||||||
|
msg += " "
|
||||||
|
j += 1
|
||||||
|
if hi < 0 :
|
||||||
|
if lo > 14 :
|
||||||
|
msg += "."
|
||||||
|
else :
|
||||||
|
msg += spec[lo]
|
||||||
|
continue
|
||||||
|
if hi % 16 >= 8 :
|
||||||
|
msg += ">"
|
||||||
|
elif hi % 8 >= 4 :
|
||||||
|
msg += "<"
|
||||||
|
if hi % 4 >= 2 :
|
||||||
|
msg += "+"
|
||||||
|
elif hi % 2 >= 1 :
|
||||||
|
msg += "-"
|
||||||
|
if hi >= 64 :
|
||||||
|
msg += "%.2f"%(lo*0.01)
|
||||||
|
elif hi % 64 >= 32 :
|
||||||
|
msg += "%.2f"%(lo*0.05)
|
||||||
|
elif hi % 32 >= 16 :
|
||||||
|
msg += "%.1f"%(lo*0.1)
|
||||||
|
else :
|
||||||
|
msg += str(lo)
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
if dattyp == "radial" :
|
||||||
|
j = 0
|
||||||
|
while j<azValsLen :
|
||||||
|
msg += "%.1f"%azVals[j] + " "
|
||||||
|
j += 1
|
||||||
|
msg += "\n"
|
||||||
|
|
||||||
|
nxy = yLen*xLen
|
||||||
|
j = 0
|
||||||
|
while j<nxy :
|
||||||
|
i = 0
|
||||||
|
while i<xLen :
|
||||||
|
if array[i+j]<0 :
|
||||||
|
msg += str(256+array[i+j]) + " "
|
||||||
|
else :
|
||||||
|
msg += str(array[i+j]) + " "
|
||||||
|
i += 1
|
||||||
|
msg += "\n"
|
||||||
|
j += xLen
|
||||||
|
|
||||||
|
return ResponseMessageGeneric(msg)
|
||||||
|
|
Loading…
Add table
Reference in a new issue