[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AWIPS #FTX-514016]: Python-awips



Hi Jamie,

I have some good news to report to you.  I've been able to successfully 
implement the downloading and processing
of pirep data on our backup edex server.  Tomorrow I plan to make these changes 
on our production edex (the one
you're pointing to) and then you should see the same results.  One thing to 
note is that once I start it
tomorrow, it can only gather data from that point on, so don't expect to see 
any data from today or earlier.

The next thing I wanted to mention quickly was how to access the data through 
python.
If you haven't already, you'll need to install the awips python package, this 
can be done with a pip install:
pip install python-awips

Then you should have the proper python libraries for the DAF.
I wrote a small program which I've attached (pirepAccess.py) that should help 
you get started with what you
want to do.  I added some comments about what I tried to do and you can comment 
out lines if they're not
necessary to you.  Basically the program connects to the edex and prints out 
which data sets are available,
and then uses pireps as its data set.  I eventually print out all the 
turbulence intensity values that are
returned from the pireps objects.

Please let me know if this helps.  Like I said, the production database won't 
be updated until tomorrow 
morning, so this script won't work until that's been done, but I wanted to 
respond to you sooner rather than
later so you knew that progress has been made.  Not all is lost.

Thanks.
--Shay Carter

Software Engineer II
UCAR - Unidata

Ticket Details
===================
Ticket ID: FTX-514016
Department: Support AWIPS
Priority: Normal
Status: Open
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.
#!/awips2/python/bin/python

from ufpy.dataaccess import DataAccessLayer

#connect to unidata edex
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")

#get a list of supported data types from the edex
types = DataAccessLayer.getSupportedDatatypes()
print(types)

#create a request and set the data type
req = DataAccessLayer.newDataRequest()
req.setDatatype("pirep")

#print out required identifiers
#required = DataAccessLayer.getRequiredIdentifiers(req)
#print(required)

#print out optional identifiers
#optional = DataAccessLayer.getOptionalIdentifiers(req)
#print(optional)

#print out available parameters
param = DataAccessLayer.getAvailableParameters(req)
print(param)

#set the parameter to turbulence intensity
req.setParameters("turbInten")
print(req)

#print out available location names
locations = DataAccessLayer.getAvailableLocationNames(req)
print locations

#actually get the data for the request -- this returns an array
data = DataAccessLayer.getGeometryData(req)
#print out the turbulence intensity for one of the data objects in the array
#print data[3].getString("turbInten")

#cycle through all the objects and print out their turbulence intensities
for d in data:
        print d.getString("turbInten")