Omaha #3601 Update satellite inventory scripts to DAF

Change-Id: If12bae7fff302e3da02552fd8d6393db9cd75a9f

Former-commit-id: 9942aebf17 [formerly 35ea6bb51d [formerly 9ce30740a7] [formerly 9942aebf17 [formerly 33b0fd4d0bc62e9dff1256edfe3f55a080b9efb9]]]
Former-commit-id: 35ea6bb51d [formerly 9ce30740a7]
Former-commit-id: 35ea6bb51d
Former-commit-id: 19fddca23c
This commit is contained in:
Nathan Bowler 2014-11-03 13:28:31 -05:00
parent 9e0606227e
commit 7b3c56bb95
2 changed files with 163 additions and 60 deletions

View file

@ -1,4 +1,23 @@
#!/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 that is meant to get inventories of satellite data
# from the A-II database. The data is output to stdout as ASCII.
@ -27,6 +46,13 @@
# finalized python is /tmp/a2invsatNNNNN.py where NNNNN is a unix process id.
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 2014-10-23 3601 nabowle Initial modification. Properly calls DAF. Make a2satInfo.txt optional.
#
set rmpy = yes
if ( "$1" == "p" ) then
set rmpy = no
@ -60,31 +86,7 @@ else
bash -c "echo could not find a2invsatStub.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 containing mapping between D-2D interger ids and AWIPS-II ascii
# ids for sectors, channels, and satellites.
@ -98,41 +100,75 @@ else if ( -e $FXA_HOME/src/dm/sat/a2satInfo.txt ) then
else if ( -e $FXA_HOME/data/a2satInfo.txt ) then
set satInf = $FXA_HOME/data/a2satInfo.txt
else
bash -c "echo could not find a2satInfo.txt 1>&2"
exit
set satInf = ""
set sss = "$1"
set ccc = "$2"
if ( "$3" == "" ) then
set eee = ""
else
set eee = "$3"
endif
endif
#
#
set sss = `grep "^ *$1|.*sectorID" $satInf | cut '-d|' -f3`
if ( "$sss" == "" ) set sss = "$1"
set ccc = `grep "^ *$2|.*physicalElement" $satInf | cut '-d|' -f3`
if ( "$ccc" == "" ) set ccc = "$2"
shift
shift
#
# Modify the text of special tags in stub to create finalized script.
#
set specpy = /tmp/a2invsat${$}.py
rm -rf $specpy >& /dev/null
touch $specpy
chmod 775 $specpy
if ( "$1" == "" ) then
cat $stubpy | sed "s/SSSSS/$sss/g" | sed "s/CCCCC/$ccc/g" | \
sed 's/^.*EEEEE.*$//g' >> $specpy
else
set eee = `grep "^ *$1|.*creatingEntity" $satInf | cut '-d|' -f3`
if ( "$eee" == "" ) set eee = "$1"
cat $stubpy | sed "s/SSSSS/$sss/g" | sed "s/CCCCC/$ccc/g" | \
sed "s/EEEEE/$eee/g" >> $specpy
if ( $satInf != "" ) then
set sss = `grep "^ *$1|.*sectorID" $satInf | cut '-d|' -f3`
if ( "$sss" == "" ) set sss = "$1"
set ccc = `grep "^ *$2|.*physicalElement" $satInf | cut '-d|' -f3`
if ( "$ccc" == "" ) set ccc = "$2"
if ( "$3" == "" ) then
set eee = ""
else
set eee = `grep "^ *$3|.*creatingEntity" $satInf | cut '-d|' -f3`
if ( "$eee" == "" ) set eee = "$3"
endif
endif
#
# Submit the temporary python script stripping xml stuff, then remove it
# Determine if we are using the data access framework or the uEngine.
#
if ( "$method" == "daf" ) then
/awips2/python/bin/python $specpy
grep DataAccessLayer $stubpy >& /dev/null
if ( $status == 0 ) then
if ( "$eee" == "" ) then
/awips2/python/bin/python $stubpy --sectorID "$sss" --physicalElement "$ccc"
else
/awips2/python/bin/python $stubpy --sectorID "$sss" --physicalElement "$ccc" --creatingEntity "$eee"
endif
else
#
# 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
#
# Modify the text of special tags in stub to create finalized script.
#
set specpy = /tmp/a2invsat${$}.py
rm -rf $specpy >& /dev/null
touch $specpy
chmod 775 $specpy
if ( "$eee" == "" ) then
cat $stubpy | sed "s/SSSSS/$sss/g" | sed "s/CCCCC/$ccc/g" | \
sed 's/^.*EEEEE.*$//g' >> $specpy
else
cat $stubpy | sed "s/SSSSS/$sss/g" | sed "s/CCCCC/$ccc/g" | \
sed "s/EEEEE/$eee/g" >> $specpy
endif
cd $UE_BIN_PATH
( uengine -r python < $specpy ) |& grep attributes | cut '-d"' -f4
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
endif
if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null
#

View file

@ -1,9 +1,76 @@
import CatalogQuery
##
# 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.
##
query = CatalogQuery.CatalogQuery("satellite")
query.addConstraint("creatingEntity","EEEEE","=")
query.addConstraint("sectorID","SSSSS","=")
query.addConstraint("physicalElement","CCCCC","=")
query.setDistinctField("dataTime")
# Gets inventories of satellite data from the A-II database. The data is output
# to stdout as ASCII.
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 2014-10-23 3601 nabowle Initial modification. Convert to DAF.
#
return query.executeWrapped()
import argparse
import numpy
import sys
from ufpy.dataaccess import DataAccessLayer
def get_args():
parser = argparse.ArgumentParser(conflict_handler="resolve")
parser.add_argument("-h", action="store", dest="host",
help="EDEX server hostname (optional)", metavar="hostname")
parser.add_argument("--sectorID", action="store", dest="sectorID",
help="The sector ID.", metavar="sectorID")
parser.add_argument("--physicalElement", action="store", dest="physicalElement",
help="The physical element.", metavar="physicalElement")
parser.add_argument("--creatingEntity", action="store", dest="creatingEntity",
help="(optional) The creating entity", metavar="creatingEntity")
return parser.parse_args()
def main():
user_args = get_args()
if user_args.host:
DataAccessLayer.changeEDEXHost(user_args.host)
req = DataAccessLayer.newDataRequest("satellite")
if not user_args.sectorID or not user_args.physicalElement:
print >> sys.stderr, "sectorID or physicalElement not provided"
return
req.setParameters(user_args.physicalElement)
req.addIdentifier("sectorID", user_args.sectorID)
if user_args.creatingEntity:
req.addIdentifier("creatingEntity", user_args.creatingEntity)
msg = "";
times = DataAccessLayer.getAvailableTimes(req)
for time in times:
timeStr = str(time)
msg += timeStr[0:19] + ".0" + timeStr[19:] + "\n"
print msg.strip()
if __name__ == '__main__':
main()