{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Cartopy: Quiver plot on a regional projection\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pygeode as pyg\nimport numpy as np, pylab as pyl\nfrom cartopy import crs as ccrs\nimport cartopy\n\n# Construct latitude and longitude coordinate system\nlat = pyg.gausslat(40)\nlon = pyg.regularlon(80, origin=-180)\n\n# Generate x and y components of a vector field on this coordinate system\nx = pyg.sin(2*np.pi * lon / 180.) * pyg.exp(-(lat - 30)**2 / (2*10**2))\ny = pyg.cos(4*np.pi * lon / 180.) * pyg.exp(-(lat - 40)**2 / (4*10**2))\n\n# Turn off interactivity\npyl.ioff()\n\n# Build CartopyAxis for a Lambert Conformal projection\nprj = dict(central_longitude=-90., central_latitude = 39.)\nax = pyg.plot.CartopyAxes(projection = 'LambertConformal', prj_args = prj)\nax.size = [6., 5.1]\n\n# Add ocean\nax.add_feature(cartopy.feature.OCEAN)\n\n# Add quiver plot\npyg.vquiver(x, y, axes=ax, width = 0.005)\n\n# Set plot title\nax.setp(title = 'Lambert Conformal')\n\n# Set map extent to region over North America\nax.set_extent([-140, -50, 10, 75], crs = ccrs.PlateCarree())\n\n# Turn on matplotlib interactivity\npyl.ion()\n\n# Produce plot\nax.render(2)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.12" } }, "nbformat": 4, "nbformat_minor": 0 }