예제 #1
0
 def test(self):
     """ Test normal operation.
     
     """
     query = {"params": self._DATA.params, "result": self._DATA.result}
     result = StnDataResult(query)
     array = result_array(result)
     for expected, actual in zip(result, array):
         self.assertSequenceEqual(expected, actual)
     return
예제 #2
0
"""
The result_array function converts a StnDataResult or MultiStnDataResult to a
numpy record array (numpy library required). This result will retrieve the
max temperature for multiple sites and multiple dates and sort the output by
date.

"""
print "EXAMPLE 12\n"
request = acis.MultiStnDataRequest()
request.location(sids="OKC,TUL,LAW,MLC,GAG")
request.dates("2012-08-01", "2012-08-03")
request.metadata("name")
request.add_element("maxt")
result = acis.MultiStnDataResult(request.submit())
array = acis.result_array(result)
array.sort(order="date")
for record in array:
    name = result.meta[record["uid"]]["name"]
    print "The high temperature for {0:s} on {1:s} was {2:s}F.".format(
       name, record["date"], record["maxt"])
print "-"*40


"""
*** Using AreaMetaRequest ***

An AreaMetaRequest will retrieve area (county, river basin, etc.) metadata.
This example will retrieve all the climate divisions in Oklahoma.

"""