How to use the datacube.analytics.analytics_engine.AnalyticsEngine function in datacube

To help you get started, we’ve selected a few datacube examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opendatacube / datacube-core / tests / analytics_execution_engine / test_analyics_execution_engine.py View on Github external
def test_median_reduction_over_latlong_old_version(mock_api):
    # Test median reduction over lat/long - old version for backwards compatibility

    a = AnalyticsEngine(api=mock_api)
    e = ExecutionEngine(api=mock_api)

    # Lake Burley Griffin
    dimensions = {'x': {'range': (149.07, 149.18)},
                  'y': {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    arrays = a.create_array(('LANDSAT_5', 'NBAR'), ['band_40'], dimensions, 'get_data')

    median_xy = a.apply_generic_reduction(arrays, ['x', 'y'], 'median(array1)', 'medianXY')

    result = e.execute_plan(a.plan)
github opendatacube / datacube-core / tests / analytics_execution_engine / test_analyics_execution_engine.py View on Github external
def test_old_version_median_reduction_over_time(mock_api):
    # Test median reduction over time - old version for backwards compatibility

    a = AnalyticsEngine(api=mock_api)
    e = ExecutionEngine(api=mock_api)

    # Lake Burley Griffin
    dimensions = {'longitude': {'range': (149.07, 149.18)},
                  'latitude': {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    arrays = a.create_array(('LANDSAT_5', 'NBAR'), ['band_40'], dimensions, 'get_data')

    median_t = a.apply_generic_reduction(arrays, ['time'], 'median(array1)', 'medianT')

    result = e.execute_plan(a.plan)
github opendatacube / datacube-core / tests / analytics_execution_engine / test_analyics_execution_engine.py View on Github external
def test_bit_of_everything(mock_api):
    # Test bit of everything

    a = AnalyticsEngine(api=mock_api)
    e = ExecutionEngine(api=mock_api)

    # Lake Burley Griffin
    dimensions = {'longitude': {'range': (149.07, 149.18)},
                  'latitude': {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    b40 = a.create_array(('LANDSAT_5', 'NBAR'), ['band_40'], dimensions, 'b40')
    b30 = a.create_array(('LANDSAT_5', 'NBAR'), ['band_30'], dimensions, 'b30')
    pq = a.create_array(('LANDSAT_5', 'PQ'), ['band_pixelquality'], dimensions, 'pq')

    ndvi = a.apply_expression([b40, b30], '((array1 - array2) / (array1 + array2))', 'ndvi')
    adjusted_ndvi = a.apply_expression(ndvi, '(ndvi*0.5)', 'adjusted_ndvi')
    mask = a.apply_expression([adjusted_ndvi, pq], 'array1{array2}', 'mask')
    median_t = a.apply_expression(mask, 'median(array1, 0)', 'medianT')
github opendatacube / datacube-core / examples / analytics_execution_engine / ndvi_mask_median_expression.py View on Github external
def main():
    a = AnalyticsEngine()
    e = ExecutionEngine()

    # Lake Burley Griffin
    dimensions = {'x':    {'range': (149.07, 149.18)},
                  'y':    {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    b40 = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'b40')
    b30 = a.create_array(('LANDSAT_5', 'nbar'), ['red'], dimensions, 'b30')
    pq = a.create_array(('LANDSAT_5', 'pqa'), ['pixelquality'], dimensions, 'pq')

    ndvi = a.apply_expression([b40, b30], '((array1 - array2) / (array1 + array2))', 'ndvi')
    mask = a.apply_expression([ndvi, pq], 'array1{(array2 == 32767) | (array2 == 16383) | (array2 == 2457)}', 'mask')
    median_t = a.apply_expression(mask, 'median(array1, 0)', 'medianT')

    result = e.execute_plan(a.plan)
github opendatacube / datacube-core / examples / analytics_execution_engine / median_xy.py View on Github external
def main():
    a = AnalyticsEngine()
    e = ExecutionEngine()

    # Lake Burley Griffin
    dimensions = {'x':    {'range': (149.07, 149.18)},
                  'y':    {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'get_data')

    median_xy = a.apply_generic_reduction(arrays, ['y', 'x'], 'median(array1)', 'medianXY')

    result = e.execute_plan(a.plan)

    plot(e.cache['medianXY'])
github opendatacube / datacube-core / examples / analytics_execution_engine / create_array.py View on Github external
def main():
    a = AnalyticsEngine()
    e = ExecutionEngine()

    # Lake Burley Griffin
    dimensions = {'x':    {'range': (149.07, 149.18)},
                  'y':    {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir', 'red'], dimensions, 'get_data')

    e.execute_plan(a.plan)

    plot(e.cache['get_data'])

    b30_result = e.cache['get_data']['array_result']['red']
    b40_result = e.cache['get_data']['array_result']['nir']
github opendatacube / datacube-core / examples / analytics_execution_engine / median_xy_expression.py View on Github external
def main():
    a = AnalyticsEngine()
    e = ExecutionEngine()

    # Lake Burley Griffin
    dimensions = {'x':    {'range': (149.07, 149.18)},
                  'y':    {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'get_data')

    median = a.apply_expression(arrays, 'median(array1, 1, 2)', 'medianXY')

    e.execute_plan(a.plan)

    plot(e.cache['medianXY'])
github opendatacube / datacube-core / examples / analytics_execution_engine / ndvi.py View on Github external
def main():
    a = AnalyticsEngine()
    e = ExecutionEngine()

    # Lake Burley Griffin
    dimensions = {'x':    {'range': (149.07, 149.18)},
                  'y':    {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir', 'red'], dimensions, 'get_data')

    ndvi = a.apply_bandmath(arrays, '((array1 - array2) / (array1 + array2))', 'ndvi')

    e.execute_plan(a.plan)

    plot(e.cache['ndvi'])

    b30_result = e.cache['get_data']['array_result']['red']
github opendatacube / datacube-core / examples / analytics_execution_engine / median_t_expression.py View on Github external
def main():
    a = AnalyticsEngine()
    e = ExecutionEngine()

    # Lake Burley Griffin
    dimensions = {'x':    {'range': (149.07, 149.18)},
                  'y':    {'range': (-35.32, -35.28)},
                  'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}}

    arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'get_data')

    median = a.apply_expression(arrays, 'median(array1, 0)', 'medianT')

    e.execute_plan(a.plan)

    plot(e.cache['medianT'])

    b40_result = e.cache['get_data']['array_result']['nir']