Open
Description
openedon May 9, 2019
import numpy as np
import cartopy.crs as ccrs
import xarray as xr
import hvplot.xarray
def sample_data(shape=(73, 145)):
"""Returns ``lons``, ``lats`` and ``data`` of some fake data."""
nlats, nlons = shape
ys = np.linspace(-np.pi / 2, np.pi / 2, nlats)
xs = np.linspace(0, 2*np.pi, nlons)
lons, lats = np.meshgrid(xs, ys)
wave = 0.75 * (np.sin(2 * lats) ** 8) * np.cos(4 * lons)
mean = 0.5 * np.cos(2 * lats) * ((np.sin(2 * lats)) ** 2 + 2)
lats = np.rad2deg(ys)
lons = np.rad2deg(xs)
data = wave + mean
return lons, lats, data
lons, lats, data = sample_data()
ds = xr.DataArray(data, coords={'lat': lats, 'lon': lons}, dims=('lat', 'lon'))
ds.hvplot('lon', 'lat', crs=ccrs.PlateCarree()) * gv.feature.coastline()
ds.hvplot('lon', 'lat', crs=ccrs.PlateCarree(), projection=ccrs.PlateCarree(central_longitude=180)) * gv.feature.coastline()
Activity