-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyFirstDataCube.py
87 lines (55 loc) · 1.9 KB
/
MyFirstDataCube.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# coding: utf-8
# # My First Data Cube
#
# A small notebook showing how to initialise connection and access the Data Cube a display a small section of data
# In[1]:
#get_ipython().magic(u'pylab')
#%pylab inline
#import mpld3; mpld3.enable_notebook()
# In[2]:
from datetime import datetime, date, timedelta
from gdf import GDF
from pprint import pprint
import matplotlib.pyplot as plt
# In[3]:
def plotImages(arrays):
img = arrays
num_t = img.shape[0]
num_rowcol = math.ceil(math.sqrt(num_t))
fig = plt.figure()
fig.clf()
plot_count = 1
for i in range(img.shape[0]):
data = img[i]
ax = fig.add_subplot(num_rowcol,num_rowcol,plot_count)
plt.setp(ax, xticks=[], yticks=[])
#cax = ax.imshow(data, interpolation='nearest', aspect = 'equal')
cax = ax.pcolormesh(data) #, interpolation='nearest', aspect = 'equal')
#fig.colorbar(cax)
plot_count += 1
fig.tight_layout()
plt.show()
# In[4]:
g = GDF()
#g.debug = True
# In[5]:
data_request_descriptor = {'storage_type': 'LS7ETM',
'variables': ('B30', 'B40'),
'dimensions': {'X': {'range': (140.0, 140.125)},
'Y': {'range': (-35.0, -35.0+0.125)},
#'T': {'range': (0, 6325376000),
# 'array_range': (0, 4)
#'crs': 'SSE', # Seconds since epoch
#'grouping_function': g.null_grouping
# }
}
}
# In[6]:
d = g.get_data(data_request_descriptor)
pprint(d)
print(d['arrays']['B30'].shape)
# In[7]:
plotImages(d['arrays']['B30'])
# In[ ]:
type(d['arrays']['B30'])
# In[ ]: