import holoviews as hv
import holocube as hc
from cartopy import crs
from cartopy import feature as cf

hv.notebook_extension()

%%opts GeoFeature [projection=crs.Geostationary()]

coasts  = hc.GeoFeature(cf.COASTLINE)
borders = hc.GeoFeature(cf.BORDERS)
ocean   = hc.GeoFeature(cf.OCEAN)

ocean + borders + (ocean*borders).relabel("Overlay")

"""
Explanation: HoloCube is a Python library that makes it easy to explore and visualize geographical, meterological, oceanographic, and other multidimensional gridded datasets.  HoloCube interfaces between the  HoloViews library for flexible visualizations of multidimensional data, the Iris library for storing and processing climate and weather data, and the Cartopy library for working with cartographic projections and visualizations in Matplotlib.  Specifically, HoloCube:


Extends HoloViews objects to allow them to use data stored in Iris cubes.  After import holocube, data can be provided to any Holoviews Element directly as a cube, without needing to first convert into one of the other supported formats (NumPy arrays, Pandas data frames, etc.). This support is independent of the other support below -- data from Iris cubes can be used even in non-geographic Elements, and most geographic Elements can accept data in any format.


Adds a set of new HoloViews Elements that have an associated geographic projection (GeoElements), based on cartopy.crs. These currently include GeoFeature, WMTS, GeoTiles, Points, Contours, Image, and Text objects, each of which can easily be overlaid in the same plots.  E.g. an object with temperature data can be overlaid with coastline data using an expression like Image(temp_cube)*hc.GeoFeature(cartopy.feature.COASTLINE).  Each GeoElement can also be freely combined in layouts with any other HoloViews Element, making it simple to make even complex multi-figure layours.


With HoloCube, you can now work easily and naturally with large, multidimensional datasets, instantly visualizing any subset or combination of them, while always being able to access the raw data underlying any plot.  Here's a simple example:
End of explanation
"""


import iris
surface_temp = iris.load_cube(iris.sample_data_path('GloSea4', 'ensemble_001.pp'))
print surface_temp.summary()

"""
Explanation: The following example loads a cube from iris-sample-data and displays it as follows:
End of explanation
"""


%%opts GeoImage [colorbar=True] (cmap='viridis')
(hc.HoloCube(surface_temp).groupby(['time'], group_type=hc.Image) * hc.GeoFeature(cf.COASTLINE))

"""
Explanation: With HoloViews, you can quickly view the data in the cube interactively:
End of explanation
"""


