Example #1
0
def get_test_query_results():
    """
    Convenience function to quickly get a testing result set.
    This is useful when demonstrating via an interactive IPython shell, etc.
    """
    gbdx = get_session()
    qry = GBDXQuery(TEST_AOI)
    res = qry(gbdx)
    return res
Example #2
0
def main():
    #get gbdx session object
    session = gbdx.get_session()

    #construct a query object, to search the catalog for
    # images that intersect a given AOI and were created
    # between start and end dates.
    date_range = ('2013-01-15', '2015-01-01')
    qry = gbdx.GBDXQuery(gbdx.TEST_AOI, date_range=date_range,
                         platform_name=gbdx.DG_SENSOR_WV2,
                         max_cloud_cover=5, max_off_nadir_angle=15)

    #execute the query. The results will be a GBDXQueryResult object
    print("-"*40)
    time1 = time.time()
    res = qry(session)
    time2 = time.time()
    print("Query executed in {} seconds".format(time2-time1))

    #note that query results are cached for (default) 300 sec,
    # so if I call this query again immediately, it should use
    # the remembered results.
    time1 = time.time()
    _res2 = qry(session)  #no reason to do this here, other than show caching behavior
    time2 = time.time()
    print("On 2nd attempt, query returned cached results in {} seconds".format(time2-time1))

    print("-"*40)
    print res
    print("-"*40)

    #the list of all catalog ids in result set
    cat_ids = res.list_IDs()

    #get the pan resolution for the first few cat_ids
    resolutions = [ (cid,res.get_property_from_id(cid,"panResolution")) for
                    cid in cat_ids[0:5]]
    for (cid,pan_res) in resolutions:
        print("Image: {}, Pan resolution: {}".format(cid, pan_res))

    print("-"*40)
    print("The 3rd record is:")
    pprint.pprint(res[2])
    print("-"*40)
 def test_2_expired_token(self):
     print("\nTesting getting gbdx session with saved expired token")
     #TODO: We need to get a 'valid' already-expired token, and save
     # the token data into TEST_CFG_FILE in order for this test to do
     # anything...
     sess = get_session(TEST_CFG_FILE)
 def test_1_get_session(self):
     print("\nTesting getting gbdx session object.")
     sess = get_session()
     self.assertIsNotNone(sess, "Unable to get a gbdx session object.")
Example #5
0
 def setUp(self):
     self.sess = gbdx.get_session()