Omaha #3594 Update profiler script to use DAF.
Change-Id: Id0553c1c8745ae4371776fcdb4ec610f8f142ab0 Former-commit-id:41fda1a53c
[formerly1c7dbefc31
] [formerly8e3ef542bf
] [formerly8e3ef542bf
[formerly1fd0ece81a
]] [formerly41fda1a53c
[formerly1c7dbefc31
] [formerly8e3ef542bf
] [formerly8e3ef542bf
[formerly1fd0ece81a
]] [formerlye7f86f19c1
[formerly8e3ef542bf
[formerly1fd0ece81a
] [formerlye7f86f19c1
[formerly 3c55fd78ca42a04ee0b0a9bbb88034c83f30e583]]]]] Former-commit-id:e7f86f19c1
Former-commit-id:52bc34c9a3
[formerlya243aa93d2
] [formerlydb1c0f21b6
] [formerly 227217af1d63c3daf49872eb3158b45eb2c4f291 [formerly 309aadf808d732273707976d97d0deeeae187624] [formerlydb1c0f21b6
[formerlya23f95abdc
]]] Former-commit-id: fad14eb8c54299884239a4be7a1bf54bc24e51ad [formerly 02f18d33b32654a6338f29a2f7c5a7710bc5f782] [formerly658f943995
[formerlyeaf614ae66
]] Former-commit-id:658f943995
Former-commit-id:a53fa83f99
This commit is contained in:
parent
281516837d
commit
8d3b951520
2 changed files with 206 additions and 144 deletions
|
@ -1,4 +1,23 @@
|
||||||
#!/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
|
||||||
# profiler data in the A-II database over a specified range of times. The
|
# profiler data in the A-II database over a specified range of times. The
|
||||||
|
@ -26,6 +45,14 @@
|
||||||
#
|
#
|
||||||
# Everything from height onward are profiles.
|
# Everything from height onward are profiles.
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# SOFTWARE HISTORY
|
||||||
|
#
|
||||||
|
# Date Ticket# Engineer Description
|
||||||
|
# ------------ ---------- ----------- --------------------------
|
||||||
|
# Oct 6, 2014 3594 nabowle Initial modification. Handle DAF version.
|
||||||
|
#
|
||||||
|
#
|
||||||
set rmpy = yes
|
set rmpy = yes
|
||||||
if ( "$1" == "p" ) then
|
if ( "$1" == "p" ) then
|
||||||
set rmpy = no
|
set rmpy = no
|
||||||
|
@ -67,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.
|
||||||
|
@ -86,19 +113,17 @@ else
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
source $ueenv
|
source $ueenv
|
||||||
endif
|
|
||||||
#
|
set specpy = /tmp/a2gtprof${$}.py
|
||||||
set specpy = /tmp/a2gtprof${$}.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
|
#uengine -r python < $specpy
|
||||||
( uengine -r python < $specpy ) | grep -v '<' | sed -n '3,$p'
|
( uengine -r python < $specpy ) | grep -v '<' | sed -n '2,$p'
|
||||||
|
|
||||||
|
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
|
||||||
endif
|
endif
|
||||||
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
|
|
||||||
#
|
|
||||||
|
|
|
@ -1,147 +1,184 @@
|
||||||
# pointDataQuery.stationName_lat_lon.py
|
##
|
||||||
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
|
# This software was developed and / or modified by Raytheon Company,
|
||||||
import PointDataQuery
|
# 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.
|
||||||
|
##
|
||||||
|
|
||||||
# 1.
|
# Gets all available profiler data in the A-II database over a specified range
|
||||||
pdq = PointDataQuery.PointDataQuery("profiler")
|
# of times. The data is output to stdout as ASCII. Each line is one
|
||||||
|
# time/station combination. The individual data variables are comma delimited,
|
||||||
|
# and when what is returned for a data item is a profile, each item in the
|
||||||
|
# profile is vertical bar delimited
|
||||||
|
#
|
||||||
|
# SOFTWARE HISTORY
|
||||||
|
#
|
||||||
|
# Date Ticket# Engineer Description
|
||||||
|
# ------------ ---------- ----------- --------------------------
|
||||||
|
# Oct 6, 2014 3594 nabowle Initial modification. Replace UEngine with DAF.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
# 3. the stuff we want returned to us in PointDataContainer
|
import argparse
|
||||||
reqPar = "profilerId,validTime"
|
import sys
|
||||||
reqPar += ",latitude,longitude,elevation"
|
|
||||||
reqPar += ",pressure,temperature,relHumidity,windDirSfc,windSpeedSfc,rainRate"
|
|
||||||
reqPar += ",submode,numProfLvls"
|
|
||||||
reqPar += ",height,levelMode,uComponent,vComponent,wComponent"
|
|
||||||
reqPar += ",peakPower,HorizSpStdDev,VertSpStdDev,uvQualityCode,consensusNum"
|
|
||||||
pdq.setRequestedParameters(reqPar)
|
|
||||||
|
|
||||||
# 2. some constraints
|
from datetime import datetime
|
||||||
pdq.addConstraint("dataTime","BBBBB:00.0",">=")
|
from ufpy.dataaccess import DataAccessLayer
|
||||||
pdq.addConstraint("dataTime","EEEEE:00.0","<=")
|
from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
|
||||||
|
|
||||||
# 5.1 execute() returns a ResponseMessageGeneric
|
def get_args():
|
||||||
pdq.requestAllLevels()
|
parser = argparse.ArgumentParser(conflict_handler="resolve")
|
||||||
rmg = pdq.execute()
|
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()
|
||||||
|
|
||||||
# 5.1, cont'd. RMG's payload is a PointDataContainer
|
def main():
|
||||||
pdc = rmg.getContents()
|
# The multi-dimensional parameters.
|
||||||
#return ResponseMessageGeneric(pdc)
|
MULTI_DIM_PARAMS = set(['vComponent', 'uComponent', 'peakPower',
|
||||||
|
'levelMode', 'uvQualityCode', 'consensusNum',
|
||||||
|
'HorizSpStdDev', 'wComponent', 'height',
|
||||||
|
'VertSpStdDev'])
|
||||||
|
|
||||||
# Get the data for each requested parameter.
|
user_args = get_args()
|
||||||
stn = pdc.getPointDataTypes().get("profilerId").getStringData()
|
|
||||||
tobs = pdc.getPointDataTypes().get("validTime").getLongData()
|
|
||||||
lat = pdc.getPointDataTypes().get("latitude").getFloatData()
|
|
||||||
lon = pdc.getPointDataTypes().get("longitude").getFloatData()
|
|
||||||
elev = pdc.getPointDataTypes().get("elevation").getFloatData()
|
|
||||||
mslp = pdc.getPointDataTypes().get("pressure").getFloatData()
|
|
||||||
t0 = pdc.getPointDataTypes().get("temperature").getFloatData()
|
|
||||||
rh0 = pdc.getPointDataTypes().get("relHumidity").getFloatData()
|
|
||||||
dd0 = pdc.getPointDataTypes().get("windDirSfc").getFloatData()
|
|
||||||
ff0 = pdc.getPointDataTypes().get("windSpeedSfc").getFloatData()
|
|
||||||
rr0 = pdc.getPointDataTypes().get("rainRate").getFloatData()
|
|
||||||
subm = pdc.getPointDataTypes().get("submode").getIntData()
|
|
||||||
nz = pdc.getPointDataTypes().get("numProfLvls").getIntData()
|
|
||||||
z = pdc.getPointDataTypes().get("height").getFloatData()
|
|
||||||
lvlm = pdc.getPointDataTypes().get("levelMode").getIntData()
|
|
||||||
u = pdc.getPointDataTypes().get("uComponent").getFloatData()
|
|
||||||
v = pdc.getPointDataTypes().get("vComponent").getFloatData()
|
|
||||||
w = pdc.getPointDataTypes().get("wComponent").getFloatData()
|
|
||||||
pp = pdc.getPointDataTypes().get("peakPower").getFloatData()
|
|
||||||
uv2 = pdc.getPointDataTypes().get("HorizSpStdDev").getFloatData()
|
|
||||||
w2 = pdc.getPointDataTypes().get("VertSpStdDev").getFloatData()
|
|
||||||
qc = pdc.getPointDataTypes().get("uvQualityCode").getIntData()
|
|
||||||
cnum = pdc.getPointDataTypes().get("consensusNum").getIntData()
|
|
||||||
|
|
||||||
# 5.2 and 5.3
|
if user_args.host:
|
||||||
if len(tobs) == 0 :
|
DataAccessLayer.changeEDEXHost(user_args.host)
|
||||||
msg = "couldn't get data"
|
|
||||||
return ResponseMessageGeneric(msg)
|
|
||||||
|
|
||||||
msg = "\n"
|
start = user_args.start
|
||||||
i = i3 = 0
|
end = user_args.end
|
||||||
while i < len(tobs) :
|
|
||||||
|
|
||||||
msg += stn[i] + ","
|
if not start or not end:
|
||||||
msg += str(tobs[i]/1000) + ","
|
print >> sys.stderr, "Start or End date not provided"
|
||||||
msg += "%.4f"%lat[i] + ","
|
return
|
||||||
msg += "%.4f"%lon[i] + ","
|
|
||||||
msg += "%.0f"%elev[i] + ","
|
|
||||||
msg += "%.1f"%mslp[i] + ","
|
|
||||||
msg += "%.1f"%t0[i] + ","
|
|
||||||
msg += "%.1f"%rh0[i] + ","
|
|
||||||
msg += "%.0f"%dd0[i] + ","
|
|
||||||
msg += "%.1f"%ff0[i] + ","
|
|
||||||
msg += "%.1f"%rr0[i] + ","
|
|
||||||
msg += str(subm[i]) + ","
|
|
||||||
|
|
||||||
# msg += str(nz[i]) + ","
|
beginRange = datetime.strptime( start + ":00.0", "%Y-%m-%d %H:%M:%S.%f")
|
||||||
kk = i3 + nz[i]
|
endRange = datetime.strptime( end + ":59.9", "%Y-%m-%d %H:%M:%S.%f")
|
||||||
|
timerange = TimeRange(beginRange, endRange)
|
||||||
|
|
||||||
if nz[i]>0 : msg += "%.0f"%(z[i3]-elev[i])
|
req = DataAccessLayer.newDataRequest("profiler")
|
||||||
k = i3 + 1
|
req.setParameters('numProfLvls', 'elevation', 'windDirSfc', 'validTime',
|
||||||
|
'windSpeedSfc', 'pressure', 'submode', 'relHumidity',
|
||||||
|
'profilerId', 'rainRate', 'temperature')
|
||||||
|
req.getParameters().extend(MULTI_DIM_PARAMS)
|
||||||
|
|
||||||
|
geometries = DataAccessLayer.getGeometryData(req, timerange)
|
||||||
|
|
||||||
|
if not geometries :
|
||||||
|
# print "couldn't get data"
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
subgeos = []
|
||||||
|
msg = ""
|
||||||
|
for geoData in geometries :
|
||||||
|
if set(geoData.getParameters()) & MULTI_DIM_PARAMS :
|
||||||
|
subgeos.append(geoData)
|
||||||
|
continue
|
||||||
|
|
||||||
|
elev = geoData.getNumber("elevation")
|
||||||
|
msg += geoData.getString("profilerId") + ","
|
||||||
|
msg += str(geoData.getNumber("validTime")/1000) + ","
|
||||||
|
msg += "%.4f"%geoData.getGeometry().y + ","
|
||||||
|
msg += "%.4f"%geoData.getGeometry().x + ","
|
||||||
|
msg += "%.0f"%elev + ","
|
||||||
|
msg += "%.1f"%geoData.getNumber("pressure") + ","
|
||||||
|
msg += "%.1f"%geoData.getNumber("temperature") + ","
|
||||||
|
msg += "%.1f"%geoData.getNumber("relHumidity") + ","
|
||||||
|
msg += "%.0f"%geoData.getNumber("windDirSfc") + ","
|
||||||
|
msg += "%.1f"%geoData.getNumber("windSpeedSfc") + ","
|
||||||
|
msg += "%.1f"%geoData.getNumber("rainRate") + ","
|
||||||
|
msg += str(geoData.getNumber("submode")) + ","
|
||||||
|
|
||||||
|
kk = len(subgeos)
|
||||||
|
# msg += str(kk) + ","
|
||||||
|
|
||||||
|
subgeos[0].getString("consensusNum")
|
||||||
|
if kk>0 : msg += "%.0f"%(subgeos[0].getNumber("height")-elev)
|
||||||
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + "%.0f"%(z[k]-elev[i])
|
msg += "|" + "%.0f"%(subgeos[k].getNumber("height")-elev)
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
if nz[i]>0 : msg += str(lvlm[i3])
|
if kk>0 : msg += str(subgeos[0].getNumber("levelMode"))
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + str(lvlm[k])
|
msg += "|" + str(subgeos[k].getNumber("levelMode"))
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
|
|
||||||
if nz[i]>0 : msg += "%.1f"%u[i3]
|
if kk>0 : msg += "%.1f"%subgeos[0].getNumber("uComponent")
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + "%.1f"%u[k]
|
msg += "|" + "%.1f"%subgeos[k].getNumber("uComponent")
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
if nz[i]>0 : msg += "%.1f"%v[i3]
|
if kk>0 : msg += "%.1f"%subgeos[0].getNumber("vComponent")
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + "%.1f"%v[k]
|
msg += "|" + "%.1f"%subgeos[k].getNumber("vComponent")
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
if nz[i]>0 : msg += "%.2f"%w[i3]
|
if kk>0 : msg += "%.2f"%subgeos[0].getNumber("wComponent")
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + "%.2f"%w[k]
|
msg += "|" + "%.2f"%subgeos[k].getNumber("wComponent")
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
|
|
||||||
if nz[i]>0 : msg += "%.1f"%pp[i3]
|
if kk>0 : msg += "%.1f"%subgeos[0].getNumber("peakPower")
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + "%.1f"%pp[k]
|
msg += "|" + "%.1f"%subgeos[k].getNumber("peakPower")
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
if nz[i]>0 : msg += "%.1f"%uv2[i3]
|
if kk>0 : msg += "%.1f"%subgeos[0].getNumber("HorizSpStdDev")
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + "%.1f"%uv2[k]
|
msg += "|" + "%.1f"%subgeos[k].getNumber("HorizSpStdDev")
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
if nz[i]>0 : msg += "%.1f"%w2[i3]
|
if kk>0 : msg += "%.1f"%subgeos[0].getNumber("VertSpStdDev")
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + "%.1f"%w2[k]
|
msg += "|" + "%.1f"%subgeos[k].getNumber("VertSpStdDev")
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
|
|
||||||
if nz[i]>0 : msg += str(qc[i3])
|
if kk>0 : msg += subgeos[0].getString("uvQualityCode")
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + str(qc[k])
|
msg += "|" + subgeos[k].getString("uvQualityCode")
|
||||||
k += 1
|
k += 1
|
||||||
msg += ","
|
msg += ","
|
||||||
if nz[i]>0 : msg += str(cnum[i3])
|
if kk>0 : msg += subgeos[0].getString("consensusNum")
|
||||||
k = i3 + 1
|
k = 1
|
||||||
while k < kk :
|
while k < kk :
|
||||||
msg += "|" + str(cnum[k])
|
msg += "|" + subgeos[k].getString("consensusNum")
|
||||||
k += 1
|
k += 1
|
||||||
msg += "\n"
|
msg += "\n"
|
||||||
|
subgeos = []
|
||||||
|
|
||||||
i += 1
|
print msg.strip()
|
||||||
i3 += 64
|
|
||||||
|
|
||||||
return ResponseMessageGeneric(msg)
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue