<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 CSIRO Water Quality Analysis using Turbidity
Maintainer
Step1:  First, we make a query to the datacube to find out what datasets we have.
Step2:  Landsat Ecosystem Disturbance Adaptive Processing System (LEDAPS) is a NASA-funded project to map North American forest disturbance since 1975. We have datasets in the same format for Australia.
Let's find out what kind of datasets we have for Landsat 5.
Step3:  For Landsat 5, Band 1-3 are Blue, Green, and Red visible light spectrum bands.
To set up the Engine, we first need to instantiate the modules and setup query parameters. 
create_array sets up the platform and product we are interested in querying, as well as the bands (variables) of the satellite data set. We also limit the amount of data processed by a long-lat boundary and time.
apply_expression binds the variables into a generic string to execute, in this case an average of two bands.
execute_plan is when the computation is actually run and returned.
Step4:  Now we have created references to the green and blue bands, we can do simple band maths.
Step5:  geo_xarray.reproject reprojects northings and eastings to longitude and latitude units.
Let's reproject the file into the common longitude-latitude projection, and save it to a picture.
Step6:  The boundaries in long-lat are as follows
<ASSISTANT_TASK:>
Python Code:
from pprint import pprint
from datetime import datetime
import xarray as xr
import matplotlib
import matplotlib.image
%matplotlib inline
import datacube
from datacube.api import API, geo_xarray
from datacube.analytics.analytics_engine import AnalyticsEngine
from datacube.execution.execution_engine import ExecutionEngine
from datacube.analytics.utils.analytics_utils import plot
print('This example runs on Data Cube v2/{}.'.format(datacube.__version__))
Explanation: CSIRO Water Quality Analysis using Turbidity
Maintainer: Xavier Ho &#120;&#97;&#118;&#105;&#101;&#114;&#46;&#104;&#111;&#64;&#99;&#115;&#105;&#114;&#111;&#46;&#97;&#117;
Please contact Xavier for any queries about this example.
This example uses the Analytics Execution Engine of AGDC v2 to query Landsat imagery. Two bands are combined to calculate an average, and the result is saved to an image.
End of explanation
dc_a = AnalyticsEngine()
dc_e = ExecutionEngine()
dc_api = API()
print(dc_api.list_field_values('product')) # 'LEDAPS' should be in the list
print(dc_api.list_field_values('platform')) # 'LANDSAT_5' should be in the list
Explanation: First, we make a query to the datacube to find out what datasets we have.
End of explanation
query = {
    'product': 'LEDAPS',
    'platform': 'LANDSAT_5',
}
descriptor = dc_api.get_descriptor(query, include_storage_units=False)
pprint(descriptor)
Explanation: Landsat Ecosystem Disturbance Adaptive Processing System (LEDAPS) is a NASA-funded project to map North American forest disturbance since 1975. We have datasets in the same format for Australia.
Let's find out what kind of datasets we have for Landsat 5.
End of explanation
dimensions = {
    'x': {
        'range': (140, 141)
    },
    'y': {
        'range': (-35.5, -36.5)
    },
    'time': {
        'range': (datetime(2011, 10, 17), datetime(2011, 10, 18))
    }
}
red = dc_a.create_array(('LANDSAT_5', 'LEDAPS'), ['band3'], dimensions, 'red')
green = dc_a.create_array(('LANDSAT_5', 'LEDAPS'), ['band2'], dimensions, 'green')
blue = dc_a.create_array(('LANDSAT_5', 'LEDAPS'), ['band1'], dimensions, 'blue')
Explanation: For Landsat 5, Band 1-3 are Blue, Green, and Red visible light spectrum bands.
To set up the Engine, we first need to instantiate the modules and setup query parameters. 
create_array sets up the platform and product we are interested in querying, as well as the bands (variables) of the satellite data set. We also limit the amount of data processed by a long-lat boundary and time.
apply_expression binds the variables into a generic string to execute, in this case an average of two bands.
execute_plan is when the computation is actually run and returned.
End of explanation
blue_result = dc_a.apply_expression([blue], 'array1', 'blue')
dc_e.execute_plan(dc_a.plan)
plot(dc_e.cache['blue'])
turbidity = dc_a.apply_expression([blue, green, red], '(array1 + array2 - array3) / 2', 'turbidity')
dc_e.execute_plan(dc_a.plan)
plot(dc_e.cache['turbidity'])
Explanation: Now we have created references to the green and blue bands, we can do simple band maths.
End of explanation
result = dc_e.cache['turbidity']['array_result']['turbidity']
reprojected = datacube.api.geo_xarray.reproject(result.isel(time=0), 'EPSG:3577', 'WGS84')
pprint(reprojected)
reprojected.plot.imshow()
matplotlib.image.imsave('turbidity.png', reprojected)
Explanation: geo_xarray.reproject reprojects northings and eastings to longitude and latitude units.
Let's reproject the file into the common longitude-latitude projection, and save it to a picture.
End of explanation
map(float, (reprojected.x[0], reprojected.x[-1], reprojected.y[0], reprojected.y[-1]))
Explanation: The boundaries in long-lat are as follows:
End of explanation
<END_TASK>