Skip to content

Commit

Permalink
Removed all references to holocube and deleted interface
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 20, 2016
1 parent 02dbf4b commit 7e39014
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 331 deletions.
21 changes: 11 additions & 10 deletions doc/Homepage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"HoloCube is a [Python](http://python.org) library that makes it easy to explore and visualize geographical, meterological, oceanographic, and other multidimensional gridded datasets. HoloCube interfaces between the [HoloViews](http://holoviews.org) library for flexible visualizations of multidimensional data, the [Iris](http://scitools.org.uk/iris) library for storing and processing climate and weather data, and the [Cartopy](http://scitools.org.uk/cartopy) library for working with cartographic projections and visualizations in [Matplotlib](http://matplotlib.org/). Specifically, HoloCube:\n",
"GeoViews is a [Python](http://python.org) library that makes it easy to explore and visualize geographical, meterological, oceanographic, and other multidimensional gridded datasets. GeoViews interfaces between the [HoloViews](http://holoviews.org) library for flexible visualizations of multidimensional data, the [Iris](http://scitools.org.uk/iris) library for storing and processing climate and weather data, and the [Cartopy](http://scitools.org.uk/cartopy) library for working with cartographic projections and visualizations in [Matplotlib](http://matplotlib.org/). Specifically, GeoViews:\n",
"\n",
"1. Extends HoloViews objects to allow them to use data stored in [Iris](http://scitools.org.uk/iris) [cubes](http://scitools.org.uk/iris/docs/latest/userguide/iris_cubes.html). 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 `Element`s, and most geographic Elements can accept data in any format.\n",
"1. Extends HoloViews objects to allow them to use data stored in [Iris](http://scitools.org.uk/iris) [cubes](http://scitools.org.uk/iris/docs/latest/userguide/iris_cubes.html). After `import geoviews`, 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 `Element`s, and most geographic Elements can accept data in any format.\n",
"\n",
"2. Adds a set of new HoloViews `Element`s that have an associated geographic projection (`GeoElement`s), 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.\n",
"2. Adds a set of new HoloViews `Element`s that have an associated geographic projection (`GeoElement`s), based on `cartopy.crs`. These currently include `Feature`, `WMTS`, `Tiles`, `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)*gv.Feature(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.\n",
"\n",
"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:"
"With GeoViews, 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:"
]
},
{
Expand All @@ -22,7 +22,7 @@
"outputs": [],
"source": [
"import holoviews as hv\n",
"import holocube as hc\n",
"import geoviews as gv\n",
"from cartopy import crs\n",
"from cartopy import feature as cf\n",
"\n",
Expand All @@ -37,11 +37,11 @@
},
"outputs": [],
"source": [
"%%opts GeoFeature [projection=crs.Geostationary()]\n",
"%%opts Feature [projection=crs.Geostationary()]\n",
"\n",
"coasts = hc.GeoFeature(cf.COASTLINE)\n",
"borders = hc.GeoFeature(cf.BORDERS)\n",
"ocean = hc.GeoFeature(cf.OCEAN)\n",
"coasts = gv.Feature(cf.COASTLINE)\n",
"borders = gv.Feature(cf.BORDERS)\n",
"ocean = gv.Feature(cf.OCEAN)\n",
"\n",
"ocean + borders + (ocean*borders).relabel(\"Overlay\")"
]
Expand Down Expand Up @@ -82,11 +82,12 @@
"outputs": [],
"source": [
"%%opts GeoImage [colorbar=True] (cmap='viridis')\n",
"(hc.HoloCube(surface_temp).groupby(['time'], group_type=hc.Image) * hc.GeoFeature(cf.COASTLINE))"
"(hv.Dataset(surface_temp).groupby(['time'], group_type=gv.Image) * gv.Feature(cf.COASTLINE))"
]
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 2",
"language": "python",
Expand Down
21 changes: 11 additions & 10 deletions doc/Introductory_Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"import iris\n",
"import numpy as np\n",
"import holoviews as hv\n",
"import holocube as hc\n",
"import geoviews as gv\n",
"from cartopy import crs\n",
"from cartopy import feature as cf\n",
"hv.notebook_extension()"
Expand Down Expand Up @@ -119,7 +119,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can wrap this Iris cube in a ``HoloCube``:"
"Now we can wrap this Iris cube in a ``Dataset``:"
]
},
{
Expand All @@ -130,7 +130,7 @@
},
"outputs": [],
"source": [
"surface_temperature = hc.HoloCube(iris_cube)\n",
"surface_temperature = hv.Dataset(iris_cube)\n",
"surface_temperature"
]
},
Expand All @@ -156,7 +156,7 @@
},
"outputs": [],
"source": [
"surface_temperature.to.image(['longitude', 'latitude'])"
"surface_temperature.to.image(['longitude', 'latitude'], datatype=['cube'])"
]
},
{
Expand Down Expand Up @@ -210,7 +210,7 @@
},
"outputs": [],
"source": [
"air_temperature = hc.HoloCube(iris.load_cube(iris.sample_data_path('pre-industrial.pp')),\n",
"air_temperature = hv.Dataset(iris.load_cube(iris.sample_data_path('pre-industrial.pp')),\n",
" group='Pre-industrial air temperature')\n",
"air_temperature.data.coord('longitude').guess_bounds()\n",
"air_temperature.data.coord('latitude').guess_bounds()\n",
Expand Down Expand Up @@ -258,7 +258,7 @@
"# Sample the surface_temperature at (0,10)\n",
"temp_curve = surface_temperature.to.curve('time', dynamic=True)[0, 10]\n",
"# Show surface_temperature and air_temperature with Point (0,10) marked\n",
"temp_maps = [cb.to.image(['longitude', 'latitude']) * hc.Points([(0,10)]) \n",
"temp_maps = [cb.to.image(['longitude', 'latitude']) * gv.Points([(0,10)]) \n",
" for cb in [surface_temperature, air_temperature]]\n",
"# Show everything in a two column layout\n",
"hv.Layout(temp_maps + [temp_curve]).cols(2).display('all')"
Expand Down Expand Up @@ -298,7 +298,7 @@
"outputs": [],
"source": [
"%%opts Image [projection=crs.Geostationary()] (cmap='Greens')\n",
"surface_temperature.to.image(['longitude', 'latitude']) * hc.GeoFeature(cf.COASTLINE)"
"surface_temperature.to.image(['longitude', 'latitude']) * gv.Feature(cf.COASTLINE)"
]
},
{
Expand Down Expand Up @@ -333,8 +333,8 @@
"%%opts Image [projection=crs.Geostationary()] (cmap='Greens')\n",
"# Declare a humidity dimension with a range from 0 to 0.01\n",
"surface_temp_dim = hv.Dimension('surface_temperature', range=(300, max_surface_temp))\n",
"# Use it to declare the value dimension of a HoloCube\n",
"(hc.HoloCube(surface_temperature, vdims=[surface_temp_dim]).to.image(['longitude', 'latitude']) * hc.GeoFeature(cf.COASTLINE))"
"# Use it to declare the value dimension of a Dataset\n",
"(hv.Dataset(surface_temperature, vdims=[surface_temp_dim]).to.image(['longitude', 'latitude']) * gv.Feature(cf.COASTLINE))"
]
},
{
Expand All @@ -360,11 +360,12 @@
"outputs": [],
"source": [
"%%opts Contours [levels=10]\n",
"(surface_temperature.to.contours(['longitude', 'latitude']) * hc.GeoFeature(cf.COASTLINE))"
"(surface_temperature.to.contours(['longitude', 'latitude']) * gv.Feature(cf.COASTLINE))"
]
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 2",
"language": "python",
Expand Down
6 changes: 3 additions & 3 deletions geoviews/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .element import (_Element, HoloCube, Feature, # noqa (API import)
Tiles, WMTS, Contours, Text,
Image, Points)
from .element import (_Element, Feature, Tiles, # noqa (API import)
WMTS, Contours, Text, Image,
Points)
from . import plotting # noqa (API import)
49 changes: 48 additions & 1 deletion geoviews/element/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
from .cube import HoloCube # noqa (API import)
import iris
from holoviews.core.data import Dataset
from holoviews.element import ElementConversion, Points as HvPoints

from .geo import (_Element, Feature, Tiles, # noqa (API import)
WMTS, Points, Image, Text, Contours)


def is_geographic(dataset, kdims):
"""
Small utility that determines whether the supplied dataset
and kdims represent a geographic coordinate system.
"""

kdims = [dataset.get_dimension(d) for d in kdims]
if (len(kdims) == 2 and
((isinstance(GeoElement) and kdims == dataset.kdims) or
(isinstance(dataset, iris.cube.Cube) and all(dataset.data.coord(
kd.name).coord_system for kd in kdims)))):
return True
return False


class GeoConversion(ElementConversion):
"""
GeoConversion is a very simple container object which can
be given an existing Dataset and provides methods to convert
the Dataset into most other Element types. If the requested
key dimensions correspond to geographical coordinates the
conversion interface will automatically use a geographical
Element type while all other plot will use regular HoloViews
Elements.
"""

def __init__(self, cube):
self._element = cube

def contours(self, kdims=None, vdims=None, mdims=None, **kwargs):
return self(Contours, kdims, vdims, mdims, **kwargs)

def image(self, kdims=None, vdims=None, mdims=None, **kwargs):
return self(Image, kdims, vdims, mdims, **kwargs)

def points(self, kdims=None, vdims=None, mdims=None, **kwargs):
if kdims is None: kdims = self._element.kdims
el_type = Points if is_geographic(self._element, kdims) else HvPoints
return self(el_type, kdims, vdims, mdims, **kwargs)


Dataset._conversion_interface = GeoConversion
Loading

0 comments on commit 7e39014

Please sign in to comment.