{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Cartopy: Use Cartopy Features\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pygeode as pyg, numpy as np, pylab as pyl\nfrom cartopy import crs as ccrs\nimport cartopy\nfrom cartopy.feature.nightshade import Nightshade\nfrom datetime import datetime as dt\n\nlat = pyg.gausslat(60)\nlon = pyg.regularlon(120)\n\nx = pyg.sin(2*np.pi * lon / 180.) * pyg.exp(-(lat - 30)**2 / (2*10**2))\ny = pyg.sin(2*np.pi * lon / 180.) * pyg.exp(-(lat + 40)**2 / (2*10**2))\n\npyl.ioff()\nprj_args = dict(central_longitude = 60)\n\nmap = dict(projection = 'NearsidePerspective', prj_args = prj_args)\n\ncl = pyg.cldict(0.1, nozero=True)\nax = pyg.vcontour(x, map = map, mapdecor = False, **cl)\n\n# Addd an ocean and a day/night mask \nax.add_feature(cartopy.feature.OCEAN)\nax.add_feature(Nightshade(dt.utcnow()))\nax.setp(title = '')\n\npyl.ion()\nax.render(2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once the plot has been rendered, there is a Cartopy :class:`cartopy.mpl.geoaxes.GeoAxes` one\ncan call additional methods on.\n\n%%\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ax.ax.tissot(facecolor='orange', alpha=0.8)" ] } ], "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 }