This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Jamie, I'm glad you found us very helpful last time. I took a look at your code, and modified it a bit to run my own. I've attached this file to the email. You should be able to open it in any text editor. The problem you're running into, is now that you're requesting more than one parameter (both timeObs and turbInten), when you go to run the for loop at the end of the code, it is trying to access the 'turbInten' parameter on each piece of data returned. This was fine previously, because our request was only using turbInten to get your data results in the first place, so every piece of data returned had to have the turbInten parameter (although sometimes it could be blank, and that's why we look at that as well). In this case, now it is possible to have a piece of data that has a timeObs value but not a turbInten value, so when you go to print out the values and it's asking the data for it's turbInten param, the data doesn't recognize that parameter and it's throwing an exception. What you need to do, is check the piece of data first before trying to print out it's parameter values. Also, you can create your request to contain all of the parameters you talked about: params = ['timeObs', 'longitude', 'latitude', 'flightLevel', 'turbInten', 'turbTopHeight', 'turbBaseHeight'] Since you said you were interested in all those values anyway. When you get the data you have to look at each piece and see what parameters it has by running d.getParameters() and then you can print out the ones it has. In the example code I'm sending you, I'm checking for all the variables you're interested in and then printing them out. Interestingly, it seems that the timeObs, lat and lon information is never available on the same object as the turbulence info... I'm not sure why that is exactly. But I assume there's a way to link them (maybe time or something else). Let me know if this helps. Thanks! --Shay Carter Software Engineer II UCAR - Unidata Ticket Details =================== Ticket ID: QVN-243999 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.
#!/Users/scarter/miniconda2/envs/python3-awips/bin/python from awips.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(sorted(param)) #set the parameter to turbulence intensity params = ['timeObs', 'longitude', 'latitude', 'flightLevel', 'turbInten', 'turbTopHeight', 'turbBaseHeight'] param = 'turbInten' req.setParameters(*params) 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") print (len(data)) #print(data[0]) #print(data[0].getParameters()) #print(data[0].getString("turbInten")) #print(data[1]) #print(data[1].getParameters()) #print(data[1].getString("turbInten")) #cycle through all the objects and print out their turbulence intensities for d in data: turb = "" timeObs = "" flightLvl = "" turbTop = "" turbBase = "" lat = "" lon = "" # print(d) params = d.getParameters() if "turbInten" in params: turb = d.getString("turbInten") if "timeObs" in params: timeObs = d.getString("timeObs") if "flightLvl" in params: flightLvl = d.getString("flightLevel") if "turbTopHeight" in params: turbTop = d.getString("turbTopHeight") if "turbBase" in params: turbBase = d.getString("turbBaseHeight") if "longitude" in params: lon = d.getString("longitude") if "latitude" in params: lat = d.getString("latitude") # if(timeObs != "" and turb != ""): # print("timeObs: ", timeObs, "turbInten: ", turb) #if(turbTop != "" and turbTop != "-9999"): print("timeObs: ", timeObs, "turbInten: ", turb, "turbTop: ", turbTop, "turbBase: ", turbBase, "lon: ", lon, "lat: ", lat)