{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "\n", "def sample_data(shape=(73, 145)):\n", " nlats, nlons = shape\n", " lats = np.linspace(-np.pi / 2, np.pi / 2, nlats)\n", " lons = np.linspace(0, 2 * np.pi, nlons)\n", " lons, lats = np.meshgrid(lons, lats)\n", " wave = 0.75 * (np.sin(2 * lats) ** 8) * np.cos(4 * lons)\n", " mean = 0.5 * np.cos(2 * lats) * ((np.sin(2 * lats)) ** 2 + 2)\n", "\n", " lats = np.rad2deg(lats)\n", " lons = np.rad2deg(lons)\n", " data = wave + mean\n", "\n", " return lons, lats, data\n", "\n", "\n", "lon, lat, data = sample_data(shape=(73, 145))\n", "lon -= 180" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import matplotlib\n", "\n", "cm = matplotlib.cm.get_cmap(\"cubehelix\")\n", "\n", "normed_data = (data - data.min()) / (data.max() - data.min())\n", "colored_data = cm(normed_data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Bad" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "