'dimensions': {'X': {'range': (149.0699, 149.152)},
                                              'Y': {'range': (-35.3117, -35.2842)},
                                              #'T': {'range': (start_date, end_date),
                                              #      'array_range': (0, 4)
                                                    #'crs': 'SSE', # Seconds since epoch
                                                    #'grouping_function': g.null_grouping
                                              #     }
                                            }
                           }


# In[]:
arrays = a.createArray('LS5TM', ['B20', 'B30'], data_request_descriptor['dimensions'], 'get_data')
ndvi = a.applyBandMath(arrays, '((array1 + array2)/2.0)', 'ndvi')
pq_data = a.createArray('LS5TMPQ', ['PQ'], data_request_descriptor['dimensions'], 'pq_data')
mask = a.applyCloudMask(ndvi, pq_data, 'mask')
result = e.executePlan(a.plan)


# In[6]:
#d = g.get_data(data_request_descriptor)
#print "d shape: " , d['arrays']['B40'].shape
#plotContourf(d, 'B30')
#plotImages(d['arrays']['B30'])

# In[ ]:


# In[ ]:
my_data1 = Data(label='LS5TM')
#my_data1.add_component(d['arrays']['B20'], label='B20')
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 14 15:28:43 2015

@author: 
"""

from pprint import pprint
from datetime import datetime
from analytics import Analytics
from execution_engine import ExecutionEngine
from analytics_utils import plot

a = Analytics()
e = ExecutionEngine()

dimensions = {'X': {'range': (147.968, 148.032)}, 'Y': {'range': (-36.032, -35.968)}, 'T': {'range': (1262304000.0, 1325375999.999999)}, }
arrays = a.createArray('LS5TM', ['B40', 'B30'], dimensions, 'get_data')
ndvi = a.applyBandMath(arrays, '((array1 - array2) / (array1 + array2))', 'ndvi')
arrays2 = a.createArray('LS5TM', ['B40', 'B30'], dimensions, 'get_data2')
ndvi2 = a.applyBandMath(arrays2, '((array1 - 2.0*array2) / (array2))', 'ndvi2')
average = a.applyBandMath([ndvi, ndvi2], '((array1 + array2) / 2)', 'average')
pq_data = a.createArray('LS5TMPQ', ['PQ'], dimensions, 'pq_data')
mask = a.applyCloudMask(average, pq_data, 'mask')
median_t = a.applyGenericReduction(mask, ['T'], 'median(array1)', 'medianT')
result = e.executePlan(a.plan)

plot(e.cache['medianT'])
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 14 15:11:59 2015

@author: woo409
"""

from pprint import pprint
from datetime import datetime
from analytics import Analytics
from execution_engine import ExecutionEngine
from analytics_utils import plot

a = Analytics()
e = ExecutionEngine()

dimensions = {'X': {'range': (147.968, 148.032)}, 'Y': {'range': (-36.032, -35.968)}, 'T': {'range': (1262304000.0, 1325375999.999999)}, }
arrays = a.createArray('LS5TM', ['B40'], dimensions, 'get_data')
pq_data = a.createArray('LS5TMPQ', ['PQ'], dimensions, 'pq_data')
mask = a.applyCloudMask(arrays, pq_data, 'mask')

result = e.executePlan(a.plan)

plot(e.cache['mask'])