Merge "Omaha #3593 Adding original, unaltered scripts." into omaha_14.4.1

Former-commit-id: 141f3b8e92 [formerly 98ba1abb57 [formerly 90992e67d53421c336956f79883593af8ad99c1a]]
Former-commit-id: 98ba1abb57
Former-commit-id: b2ef9ffe81
This commit is contained in:
Nate Jensen 2014-09-16 11:13:45 -05:00 committed by Gerrit Code Review
commit d9395bea3e
3 changed files with 350 additions and 0 deletions

View file

@ -0,0 +1,128 @@
# pointDataQuery.stationName_lat_lon.py
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
import PointDataQuery
# 1.
pdq = PointDataQuery.PointDataQuery("obs")
# 3. the stuff we want returned to us in PointDataContainer
reqPar = "stationName,timeObs"
reqPar += ",latitude,longitude,elevation,wmoId"
reqPar += ",autoStationType,reportType"
reqPar += ",presWeather,visibility,skyCover,skyLayerBase"
reqPar += ",altimeter,seaLevelPress,pressChange3Hour,pressChangeChar"
reqPar += ",temperature,tempFromTenths,dewpoint,dpFromTenths"
reqPar += ",windDir,windSpeed,windGust,maxTemp24Hour,minTemp24Hour"
reqPar += ",precip1Hour,precip3Hour,precip6Hour,precip24Hour"
pdq.setRequestedParameters(reqPar)
# 2. some constraints
pdq.addConstraint("dataTime","BBBBB:00.0",">=")
pdq.addConstraint("dataTime","EEEEE:00.0","<=")
pdq.addConstraint("location.longitude","LNMN",">=")
pdq.addConstraint("location.longitude","LNMX","<=")
pdq.addConstraint("location.latitude","LTMN",">=")
pdq.addConstraint("location.latitude","LTMX","<=")
# 5.1 execute() returns a ResponseMessageGeneric
pdq.requestAllLevels()
rmg = pdq.execute()
# 5.1, cont'd. RMG's payload is a PointDataContainer
pdc = rmg.getContents()
#return ResponseMessageGeneric(pdc)
# Get the data for each requested parameter.
sName = pdc.getPointDataTypes().get("stationName").getStringData()
tobs = pdc.getPointDataTypes().get("timeObs").getLongData()
lat = pdc.getPointDataTypes().get("latitude").getFloatData()
lon = pdc.getPointDataTypes().get("longitude").getFloatData()
elev = pdc.getPointDataTypes().get("elevation").getFloatData()
ista = pdc.getPointDataTypes().get("wmoId").getIntData()
atype = pdc.getPointDataTypes().get("autoStationType").getStringData()
repTyp = pdc.getPointDataTypes().get("reportType").getStringData()
wx = pdc.getPointDataTypes().get("presWeather").getStringData()
vis = pdc.getPointDataTypes().get("visibility").getFloatData()
cvr = pdc.getPointDataTypes().get("skyCover").getStringData()
bas = pdc.getPointDataTypes().get("skyLayerBase").getFloatData()
alt = pdc.getPointDataTypes().get("altimeter").getFloatData()
msl = pdc.getPointDataTypes().get("seaLevelPress").getFloatData()
pchg = pdc.getPointDataTypes().get("pressChange3Hour").getFloatData()
pchr = pdc.getPointDataTypes().get("pressChangeChar").getStringData()
temp = pdc.getPointDataTypes().get("temperature").getFloatData()
t10 = pdc.getPointDataTypes().get("tempFromTenths").getFloatData()
dpt = pdc.getPointDataTypes().get("dewpoint").getFloatData()
td10 = pdc.getPointDataTypes().get("dpFromTenths").getFloatData()
dir = pdc.getPointDataTypes().get("windDir").getFloatData()
spd = pdc.getPointDataTypes().get("windSpeed").getFloatData()
gust = pdc.getPointDataTypes().get("windGust").getFloatData()
tmx = pdc.getPointDataTypes().get("maxTemp24Hour").getFloatData()
tmn = pdc.getPointDataTypes().get("minTemp24Hour").getFloatData()
pr1 = pdc.getPointDataTypes().get("precip1Hour").getFloatData()
pr3 = pdc.getPointDataTypes().get("precip3Hour").getFloatData()
pr6 = pdc.getPointDataTypes().get("precip6Hour").getFloatData()
pr24 = pdc.getPointDataTypes().get("precip24Hour").getFloatData()
# 5.2 and 5.3
if len(tobs) == 0 :
msg = "couldn't get data"
return ResponseMessageGeneric(msg)
msg = "\n"
i = i6 = 0
while i < len(tobs) :
msg += sName[i] + ","
msg += str(tobs[i]/1000) + ","
msg += "%.4f"%lat[i] + ","
msg += "%.4f"%lon[i] + ","
msg += "%.0f"%elev[i] + ","
if ista[i] < 0 :
msg += "-99,"
else :
msg += str(ista[i]) + ","
msg += atype[i] + " ,"
msg += repTyp[i] + " ,"
msg += wx[i] + " ,"
msg += "%.3f"%vis[i] + ","
i6 += 6;
msg += cvr[i6];
kk = 5
while kk > 0 and cvr[i6+kk] == "" :
kk -= 1
k = 1
while k <= kk :
msg += "|" + cvr[i6+k];
k += 1
msg += " ,"
msg += "%.1f"%bas[i6];
kk = 5
while kk > 0 and bas[i6+kk] < -9998 :
kk -= 1
k = 1
while k <= kk :
msg += "|" + "%.1f"%bas[i6+k];
k += 1
msg += ","
msg += "%.2f"%alt[i] + ","
msg += "%.2f"%msl[i] + ","
msg += "%.0f"%pchg[i] + ","
msg += pchr[i] + " ,"
msg += "%.1f"%temp[i] + ","
msg += "%.1f"%t10[i] + ","
msg += "%.1f"%dpt[i] + ","
msg += "%.1f"%td10[i] + ","
msg += "%.0f"%dir[i] + ","
msg += "%.1f"%spd[i] + ","
msg += "%.1f"%gust[i] + ","
msg += "%.1f"%tmx[i] + ","
msg += "%.1f"%tmn[i] + ","
msg += "%.2f"%pr1[i] + ","
msg += "%.2f"%pr3[i] + ","
msg += "%.2f"%pr6[i] + ","
msg += "%.2f"%pr24[i] + "\n"
i += 1
return ResponseMessageGeneric(msg)

View file

@ -0,0 +1,154 @@
#!/bin/csh
#
# A script wrapper around a UEngine call that is meant to get all available
# metar 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/station combination.
# The individual data items are comma delimited. This version can adapt to
# use apython stub that calls the data access framework.
#
# Usage:
#
# a2gtmtr.csh {p} {c} yyyy-mm-dd hh:mm yyyy-mm-dd hh:mm
#
# The literal p and c flags are 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/a2gtmtrNNNNN.py
# where NNNNN is a unix process id. The c flag means to retreive the
# Laps set of variables, instead of the default MSAS set.
#
# Not using the 'c' format, the MSAS set of variables, outputs the following
# variables for each line:
#
# stationName,timeObs,latitude,longitude,elevation,wmoId,autoStationType
# seaLevelPress,temperature,dewpoint,windDir,windSpeed,altimeter
#
# Using the 'c' format, the Laps set of variables, outputs the following
# variables for each line:
#
# stationName,timeObs,latitude,longitude,elevation,wmoId,autoStationType
# reportType,presWeather,visibility,skyCover,skyLayerBase,altimeter
# seaLevelPress,pressChange3Hour,pressChangeChar,temperature,tempFromTenths
# dewpoint,dpFromTenths,windDir,windSpeed,windGust,maxTemp24Hour,
# minTemp24Hour,precip1Hour,precip3Hour,precip6Hour,precip24Hour
#
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
if ( ! $?FXA_LOCAL_SITE ) set FXA_LOCAL_SITE = xxxx
if ( ! $?FXA_INGEST_SITE ) set FXA_INGEST_SITE = $FXA_LOCAL_SITE
#
set stubbase = a2gtmtrStub.py
if ( "$1" == "c" ) then
shift
set stubbase = a2cvmtrStub.py
endif
#
# Locate python stub that we will modify to create the final python logic.
#
if ( -e ./$stubbase ) then
set stubpy = ./$stubbase
else if ( -e $mydir/$stubbase ) then
set stubpy = $mydir/$stubbase
else if ( -e $FXA_HOME/src/dm/metar/$stubbase ) then
set stubpy = $FXA_HOME/src/dm/metar/$stubbase
else if ( -e $FXA_HOME/bin/$stubbase ) then
set stubpy = $FXA_HOME/bin/$stubbase
else
bash -c "echo could not find $stubbase 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
#
# Attempt to use current D-2D localization to determine lat/lon bounds.
#
set ltmn = 0
set ltmx = 90
set lnmn = -180
set lnmx = 180
set locDir = $FXA_HOME/data/localizationDataSets/$FXA_INGEST_SITE
while ( -e $locDir/CenterPoint.dat )
grep conusScale $locDir/scaleInfo.txt >& /dev/null
if ( $status == 0 ) then
set ltmn = 15
set ltmx = 60
set lnmn = -145
set lnmx = -55
break
endif
set cenLoc = `cat $locDir/CenterPoint.dat`
if ( $#cenLoc != 2 ) break
set cenlat = `echo $cenLoc[1] | cut '-d.' -f1`
set cenlat = `( @ x = $cenlat + 0 >& /dev/null ; echo $x )`
if ( "$cenlat" == "" ) break
set cenlon = `echo $cenLoc[2] | cut '-d.' -f1`
set cenlon = `( @ x = $cenlon + 0 >& /dev/null ; echo $x )`
if ( "$cenlon" == "" ) break
if ( $cenlat > 75 ) then
set ltmn = 55
break
endif
if ( $cenlat > 50 ) then
@ ltmn = $cenlat - 20
break
endif
@ ltmn = $cenlat - 20
@ ltmx = $cenlat + 20
@ lnmn = $cenlon - 20
@ lnmx = $cenlon + 20
break
end
#
set specpy = /tmp/a2gtmtr${$}.py
rm -rf $specpy >& /dev/null
touch $specpy
chmod 775 $specpy
cat $stubpy | sed "s/LTMN/$ltmn/g" | sed "s/LTMX/$ltmx/g" | \
sed "s/LNMN/$lnmn/g" | sed "s/LNMX/$lnmx/g" | \
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 '<' | sed -n '3,$p'
endif
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
#

View file

@ -0,0 +1,68 @@
# pointDataQuery.stationName_lat_lon.py
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
import PointDataQuery
# 1.
pdq = PointDataQuery.PointDataQuery("obs")
# 3. the stuff we want returned to us in PointDataContainer
reqPar = "stationName,timeObs"
reqPar += ",latitude,longitude,elevation,wmoId,autoStationType"
reqPar += ",seaLevelPress,temperature,dewpoint,windDir,windSpeed,altimeter"
pdq.setRequestedParameters(reqPar)
# 2. some constraints
pdq.addConstraint("dataTime","BBBBB:00.0",">=")
pdq.addConstraint("dataTime","EEEEE:00.0","<=")
pdq.addConstraint("location.longitude","LNMN",">=")
pdq.addConstraint("location.longitude","LNMX","<=")
pdq.addConstraint("location.latitude","LTMN",">=")
pdq.addConstraint("location.latitude","LTMX","<=")
# 5.1 execute() returns a ResponseMessageGeneric
rmg = pdq.execute()
# 5.1, cont'd. RMG's payload is a PointDataContainer
pdc = rmg.getContents()
#return ResponseMessageGeneric(pdc)
# Get the data for each requested parameter.
sName = pdc.getPointDataTypes().get("stationName").getStringData()
tobs = pdc.getPointDataTypes().get("timeObs").getLongData()
lat = pdc.getPointDataTypes().get("latitude").getFloatData()
lon = pdc.getPointDataTypes().get("longitude").getFloatData()
elev = pdc.getPointDataTypes().get("elevation").getFloatData()
ista = pdc.getPointDataTypes().get("wmoId").getIntData()
atype = pdc.getPointDataTypes().get("autoStationType").getStringData()
msl = pdc.getPointDataTypes().get("seaLevelPress").getFloatData()
temp = pdc.getPointDataTypes().get("temperature").getFloatData()
dpt = pdc.getPointDataTypes().get("dewpoint").getFloatData()
dir = pdc.getPointDataTypes().get("windDir").getFloatData()
spd = pdc.getPointDataTypes().get("windSpeed").getFloatData()
alt = pdc.getPointDataTypes().get("altimeter").getFloatData()
# 5.2 and 5.3
if len(tobs) == 0 :
msg = "couldn't get data"
return ResponseMessageGeneric(msg)
msg = "\n"
i = 0
while i < len(tobs) :
msg += sName[i] + ","
msg += str(tobs[i]/1000) + ","
msg += "%.4f"%lat[i] + ","
msg += "%.4f"%lon[i] + ","
msg += "%.0f"%elev[i] + ","
msg += str(ista[i]) + ","
msg += atype[i] + " ,"
msg += "%.2f"%msl[i] + ","
msg += "%.1f"%temp[i] + ","
msg += "%.1f"%dpt[i] + ","
msg += "%.0f"%dir[i] + ","
msg += "%.1f"%spd[i] + ","
msg += "%.2f"%alt[i] + "\n"
i += 1
return ResponseMessageGeneric(msg)