Velocity#
Example#
from ipyleaflet import Map, TileLayer, basemaps
from ipyleaflet.velocity import Velocity
import xarray as xr
import os
if not os.path.exists('wind-global.nc'):
url = 'https://github.com/benbovy/xvelmap/raw/master/notebooks/wind-global.nc'
import requests
r = requests.get(url)
wind_data = r.content
with open('wind-global.nc', 'wb') as f:
f.write(wind_data)
center = [0, 0]
zoom = 1
m = Map(center=center, zoom=zoom, interpolation='nearest', basemap=basemaps.CartoDB.DarkMatter)
ds = xr.open_dataset('wind-global.nc')
display_options = {
'velocityType': 'Global Wind',
'displayPosition': 'bottomleft',
'displayEmptyString': 'No wind data'
}
wind = Velocity(data=ds,
zonal_speed='u_wind',
meridional_speed='v_wind',
latitude_dimension='lat',
longitude_dimension='lon',
velocity_scale=0.01,
max_velocity=20,
display_options=display_options)
m.add_layer(wind)
m
Attributes#
- class ipyleaflet.velocity.Velocity(**kwargs)[source]#
Velocity class, with Layer as parent class
To visualize the direction and intensity of arbitrary velocities
- data#
Underlying dataset
- Type
dataset, default Empty dataset
- zonal_speed#
Variable name in underlying dataset for the zonal speed.
- Type
string, default ‘’
- meridional_speed#
Variable name in underlying dataset for the meridional speed.
- Type
string, default ‘’
- latitude_dimension#
Name of the latitude dimension in underlying dataset.
- Type
string, default Empty dataset.
- longitude_dimension#
Name of the longitude dimension in underlying dataset.
- Type
string, default True
- units#
Whether to show imperial units.
- Type
string, default None
- display_values#
Display velocity data on mouse hover.
- Type
bool, default True
- display_options#
Display options.
- Type
dict, default {}
- min_velocity#
Used to align color scale
- Type
float, default 0
- max_velocity#
Used to align color scale.
- Type
float, default 10.0
- velocity_scale#
To be modified for particle animations.
- Type
float, 0.005
- color_scale#
Array of hex/rgb colors for user-specified color scale.
- Type
array, default []