-
Notifications
You must be signed in to change notification settings - Fork 0
/
acube_functions.py
38 lines (32 loc) · 1.05 KB
/
acube_functions.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
from bokeh.plotting import figure, show, output_notebook
from bokeh.tile_providers import CARTODBPOSITRON, get_provider
import xarray
import datacube
def interactive_map():
output_notebook()
# range bounds supplied in web mercator coordinates
p = figure(x_range=(1035200, 1933200), y_range=(5750600, 6376100),
x_axis_type="mercator", y_axis_type="mercator", tools='pan, wheel_zoom, reset', active_scroll='wheel_zoom')
tile_provider = get_provider(CARTODBPOSITRON)
p.add_tile(tile_provider)
show(p)
def plot(data, **kwargs):
if 'cmap' in kwargs:
cmap = kwargs['cmap']
else:
cmap = 'viridis'
if isinstance(data, xarray.Dataset):
data_plot = data.to_array()
data_plot.plot.imshow(x='x',
y='y',
col='time',
size=10,
col_wrap=3,
cmap=cmap)
if isinstance(data, xarray.DataArray):
data.plot.imshow(x='x',
y='y',
col='time',
size=10,
col_wrap=3,
cmap=cmap)