{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Testing shading"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Import Magics and define non Contour paramters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "import Magics.macro as magics\n",
    "\n",
    "projection = magics.mmap(\n",
    "    subpage_map_library_area = \"on\",\n",
    "    subpage_map_area_name    = \"europe\",\n",
    "    page_id_line             = \"off\"\n",
    ")\n",
    "\n",
    "zoomed_projection = magics.mmap(\n",
    "    subpage_map_library_area = \"on\",\n",
    "    subpage_map_area_name    = \"south_west_europe\",\n",
    "    page_id_line             = \"off\"\n",
    ")\n",
    "\n",
    "coast = magics.mcoast()\n",
    "\n",
    "black_coast = magics.mcoast(\n",
    "    map_coastline_colour            = \"grey\",\n",
    "    map_coastline_resolution        = \"medium\",\n",
    "    map_coastline_thickness         = 2,\n",
    "    map_coastline_land_shade        = \"on\",\n",
    "    map_coastline_land_shade_colour = \"RGB(0.25,0.25,0.25)\",\n",
    "    map_coastline_sea_shade         = \"on\",\n",
    "    map_coastline_sea_shade_colour  = \"black\",\n",
    "    map_grid_line_style             = \"dash\",\n",
    "    map_grid_colour                 = \"grey\",\n",
    ")\n",
    "\n",
    "\n",
    "legend = magics.mlegend(legend_display_type   = 'continuous')\n",
    "\n",
    "# Different meteorological parameter we will plot in this notebook\n",
    "temperature   = magics.mgrib(grib_input_file_name   = \"t850.grib\")\n",
    "geopotential  = magics.mgrib(grib_input_file_name   = \"z500.grib\")\n",
    "precipitation = magics.mgrib(grib_input_file_name   = \"total_precipitation.grib\")\n",
    "sat_ir        = magics.mgrib(grib_input_file_name   = \"ssd.grib\",\n",
    "                             grib_automatic_scaling = \"off\")\n",
    "ptype         = magics.mgrib(grib_input_file_name   = \"ptype.grib\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Default shade"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 120820 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont(\n",
    "    contour       = \"off\",\n",
    "    contour_shade = \"on\"\n",
    ")\n",
    "\n",
    "magics.plot(projection, temperature, t_cont, coast)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Simple shading "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 171748 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont( \n",
    "    contour                        = \"off\",\n",
    "    contour_level_selection_type   = \"interval\",\n",
    "    contour_interval               = 2.00,\n",
    "    contour_shade                  = \"on\",\n",
    "    contour_shade_method           = \"area_fill\",\n",
    "    contour_shade_min_level        = -28,\n",
    "    contour_shade_max_level        = 24,\n",
    "    contour_shade_colour_method    = \"calculate\",\n",
    "    contour_shade_colour_direction = \"clockwise\",\n",
    "    contour_label                  = \"off\",\n",
    "    contour_shade_max_level_colour = \"red\",\n",
    "    contour_shade_min_level_colour = \"blue\",\n",
    "    legend                         = \"on\"\n",
    ")\n",
    "       \n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Simple shading \n",
    "anti_clockwise, label = on"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 129792 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont( \n",
    "    contour                        = \"off\",\n",
    "    contour_level_selection_type   = \"interval\",\n",
    "    contour_interval               = 4.00,\n",
    "    contour_shade                  = \"on\",\n",
    "    contour_shade_method           = \"area_fill\",\n",
    "    contour_shade_min_level        = -28,\n",
    "    contour_shade_max_level        = 24,\n",
    "    contour_shade_colour_method    = \"calculate\",\n",
    "    contour_shade_colour_direction = \"anti_clockwise\",\n",
    "    contour_label                  = \"on\",\n",
    "    contour_shade_max_level_colour = \"red\",\n",
    "    contour_shade_min_level_colour = \"blue\",\n",
    "    legend                         = \"on\"\n",
    ")\n",
    "       \n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 147868 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont( \n",
    "    contour                        = \"off\",\n",
    "    contour_level_selection_type   = \"interval\",\n",
    "    contour_interval               = 3.00,\n",
    "    contour_shade                  = \"on\",\n",
    "    contour_shade_method           = \"area_fill\",\n",
    "    contour_shade_min_level        = -28,\n",
    "    contour_shade_max_level        = 24,\n",
    "    contour_shade_colour_method    = \"calculate\",\n",
    "    contour_shade_colour_direction = \"anti_clockwise\",\n",
    "    contour_label                  = \"on\",\n",
    "    contour_shade_max_level_colour = \"orange\",\n",
    "    contour_shade_min_level_colour = \"cyan\",\n",
    "    contour_interpolation_floor    = -28,\n",
    "    contour_interpolation_ceiling  = 23.9,\n",
    "    legend                         = \"on\"\n",
    ")\n",
    "       \n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 147868 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont( \n",
    "    contour                        = \"off\",\n",
    "    contour_level_selection_type   = \"interval\",\n",
    "    contour_interval               = 3.00,\n",
    "    contour_shade                  = \"on\",\n",
    "    contour_shade_method           = \"area_fill\",\n",
    "    contour_shade_min_level        = -28,\n",
    "    contour_shade_max_level        = 24,\n",
    "    contour_shade_colour_method    = \"calculate\",\n",
    "    contour_shade_colour_direction = \"anti_clockwise\",\n",
    "    contour_label                  = \"on\",\n",
    "    contour_shade_max_level_colour = \"orange\",\n",
    "    contour_shade_min_level_colour = \"cyan\",\n",
    "    contour_interpolation_floor    = -28,\n",
    "    contour_interpolation_ceiling  = 23.9,\n",
    "    legend                         = \"on\"\n",
    ")\n",
    "       \n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Gradients, contour_level_selection_type = level_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 171128 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont(\n",
    "    legend                            = \"on\",\n",
    "    contour                           = \"off\",\n",
    "    contour_level_selection_type      = \"level_list\",\n",
    "    contour_level_list                = [-30.,-20.,0.,20.,30.],\n",
    "    contour_gradients_step_list       = [5,10,10,5],\n",
    "    contour_label                     = \"off\",\n",
    "    contour_shade                     = \"on\",\n",
    "    contour_shade_colour_method       = \"gradients\",\n",
    "    contour_gradients_technique       = \"rgb\",\n",
    "    contour_shade_method              = \"area_fill\",\n",
    "    contour_gradients_colour_list     = [\"RGB(0.01961,0.251,0.4157)\",\"greenish_blue\",\"white\",\n",
    "                                         \"orangish_red\",\"RGB(0.3756,0.06648,0.05582)\"],\n",
    "    contour_gradients_waypoint_method = \"both\")\n",
    "\n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Gradients, contour_level_selection_type = interval"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 186636 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont(\n",
    "    legend                            = \"on\",\n",
    "    contour                           = \"off\",\n",
    "    contour_level_selection_type      = \"interval\",\n",
    "    contour_interval                  = 10,\n",
    "    contour_gradients_step_list       = [5],\n",
    "    contour_shade_min_level           = -20,\n",
    "    contour_shade_max_level           = 20,\n",
    "    contour_label                     = \"off\",\n",
    "    contour_shade                     = \"on\",\n",
    "    contour_shade_colour_method       = \"gradients\",\n",
    "    contour_gradients_technique       = \"rgb\",\n",
    "    contour_shade_method              = \"area_fill\",\n",
    "    contour_gradients_colour_list     = [\"RGB(0.01961,0.251,0.4157)\",\"greenish_blue\",\"white\",\n",
    "                                         \"orangish_red\",\"RGB(0.3756,0.06648,0.05582)\"],\n",
    "    contour_gradients_waypoint_method = \"right\")\n",
    "\n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Gradients, contour_level_selection_type = interval, contour_gradients_technique       = \"hcl\","
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 205620 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont(\n",
    "    legend                            = \"on\",\n",
    "    contour                           = \"off\",\n",
    "    contour_level_selection_type      = \"interval\",\n",
    "    contour_interval                  = 10,\n",
    "    contour_gradients_step_list       = [5],\n",
    "    contour_shade_min_level           = -20,\n",
    "    contour_shade_max_level           = 20,\n",
    "    contour_label                     = \"off\",\n",
    "    contour_shade                     = \"on\",\n",
    "    contour_shade_colour_method       = \"gradients\",\n",
    "    contour_gradients_technique       = \"hcl\",\n",
    "    contour_shade_method              = \"area_fill\",\n",
    "    contour_gradients_colour_list     = [\"RGB(0.01961,0.251,0.4157)\",\"greenish_blue\",\"white\",\n",
    "                                         \"orangish_red\",\"RGB(0.3756,0.06648,0.05582)\"],\n",
    "    contour_gradients_waypoint_method = \"ignore\")\n",
    "\n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Gradients, contour_level_selection_type = interval, contour_gradients_technique = \"hsl\",  \n",
    "contour_gradients_technique_direction = 'anti_clockwise'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 266596 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont(\n",
    "    legend                            = \"on\",\n",
    "    contour                           = \"off\",\n",
    "    contour_level_selection_type      = \"count\",\n",
    "    contour_level_count               = 6,\n",
    "    contour_gradients_step_list       = [10],\n",
    "    contour_shade_min_level           = -28,\n",
    "    contour_shade_max_level           = 26,\n",
    "    contour_label                     = \"off\",\n",
    "    contour_shade                     = \"on\",\n",
    "    contour_shade_colour_method       = \"gradients\",\n",
    "    CONTOUR_GRADIENTS_TECHNIQUE_DIRECTION = \"anti_CLOCKWISE\",\n",
    "    contour_gradients_technique       = \"hsl\",\n",
    "    contour_shade_method              = \"area_fill\",\n",
    "    contour_gradients_colour_list     = [\"RGB(0.01961,0.251,0.4157)\",\"greenish_blue\",\"white\",\n",
    "                                         \"red\",\"RGB(0.3756,0.06648,0.05582)\"],\n",
    "    contour_gradients_waypoint_method = \"left\")\n",
    "\n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "contour_shade_colour_methd = list, contour_level_selection_type = interval"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 203024 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont(\n",
    "    contour_level_selection_type = \"interval\",\n",
    "    contour_interval             = 2.00,\n",
    "    contour_shade_method         = \"area_fill\",\n",
    "    contour_shade                = \"on\",\n",
    "    contour_shade_max_level      = 42.00,\n",
    "    contour_shade_min_level      = -32.00,\n",
    "    contour_label                = \"off\",\n",
    "    legend                       = \"on\",\n",
    "    contour                      = \"off\",\n",
    "    contour_shade_colour_method  = \"list\",\n",
    "    contour_shade_colour_list    = [\"rgb(0.3,0.3,0.3)\", \"rgb(0.4,0.4,0.4)\", \"rgb(0.5,0.5,0.5)\", \n",
    "                                    \"rgb(0.6,0.6,0.6)\", \"rgb(0.7,0.7,0.7)\",\"rgb(0.8,0.8,0.8)\", \n",
    "                                    \"rgb(0.35,0,0.6)\", \"rgb(0.5,0,0.9)\", \"rgb(0.6,0.2,1)\", \n",
    "                                    \"rgb(0.75,0.4,1)\", \"rgb(0.85,0.6,1)\", \"rgb(0,0,0.75)\", \n",
    "                                    \"rgb(0,0,1)\", \"rgb(0.2,0.4,1)\", \"rgb(0.4,0.7,1)\", \n",
    "                                    \"rgb(0.6,0.9,1)\", \"rgb(0,0.55,0.19)\", \"rgb(0.15,0.75,0.1)\", \n",
    "                                    \"rgb(0.5,0.85,0)\", \"rgb(0.65,0.95,0)\", \"rgb(0.8,1,0.2)\", \n",
    "                                    \"rgb(0.65,0.65,0)\", \"rgb(0.8,0.8,0)\", \"rgb(0.92,0.92,0)\", \n",
    "                                    \"rgb(1,1,0)\", \"rgb(1,1,0.6)\", \"rgb(0.85,0.45,0)\", \n",
    "                                    \"rgb(1,0.5,0)\", \"rgb(1,0.62,0)\", \"rgb(1,0.74,0)\", \n",
    "                                    \"rgb(1,0.85,0)\", \"rgb(0.6,0,0)\", \"rgb(0.8,0,0)\", \"rgb(1,0,0)\", \n",
    "                                    \"rgb(1,0.4,0.4)\", \"rgb(1,0.6,0.6)\", \"rgb(1,0.75,0.75)\"])\n",
    "\n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Colour list given, not enough colours"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 198440 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_cont = magics.mcont(\n",
    "    contour_level_selection_type = \"interval\",\n",
    "    contour_interval             = 2.00,\n",
    "    contour_shade_method         = \"area_fill\",\n",
    "    contour_shade                = \"on\",\n",
    "    contour_shade_max_level      = 24.00,\n",
    "    contour_shade_min_level      = -28.00,\n",
    "    contour_label                = \"off\",\n",
    "    legend                       = \"on\",\n",
    "    contour                      = \"off\",\n",
    "    contour_shade_colour_method  = \"list\",\n",
    "    contour_shade_colour_list    = [\"rgb(0.35,0,0.6)\", \"rgb(0.5,0,0.9)\", \"rgb(0.6,0.2,1)\", \n",
    "                                    \"rgb(0.75,0.4,1)\", \"rgb(0.85,0.6,1)\", \"rgb(0,0,0.75)\", \n",
    "                                    \"rgb(0,0,1)\", \"rgb(0.2,0.4,1)\", \"rgb(0.4,0.7,1)\", \n",
    "                                    \"rgb(0.6,0.9,1)\", \"rgb(0,0.55,0.19)\", \"rgb(0.15,0.75,0.1)\", \n",
    "                                    \"rgb(0.5,0.85,0)\", \"rgb(0.65,0.95,0)\", \"rgb(0.8,1,0.2)\", \n",
    "                                    \"rgb(0.65,0.65,0)\", \"rgb(0.8,0.8,0)\", \"rgb(0.92,0.92,0)\", \n",
    "                                    \"rgb(1,1,0)\", \"rgb(1,1,0.6)\", \"rgb(0.85,0.45,0)\", \n",
    "                                    \"rgb(1,0.5,0)\", \"rgb(1,0.62,0)\", \"rgb(1,0.74,0)\"])\n",
    "\n",
    "magics.plot(projection, temperature, t_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Supplying the list of levels and colours"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 185920 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tp_cont = magics.mcont(\n",
    "    contour_level_selection_type   = \"level_list\",\n",
    "    contour_level_list             = [0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500],\n",
    "    contour_shade                  = \"on\",\n",
    "    contour_shade_method           = \"area_fill\",\n",
    "    contour_shade_colour_method    = \"list\",\n",
    "    contour_shade_colour_list      = ['#ffffd9','#edf8b1','#c7e9b4',\n",
    "                                      '#7fcdbb','#41b6c4','#1d91c0',\n",
    "                                      '#225ea8','#253494','#081d58'],\n",
    "    contour                        = \"off\",\n",
    "    legend                         = \"on\"\n",
    ")\n",
    "\n",
    "magics.plot(projection, precipitation, tp_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Level list, colour list, contours on, shade on,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 258116 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tp_cont = magics.mcont(\n",
    "    contour_level_selection_type   = \"level_list\",\n",
    "    contour_level_list             = [0.5, 1.,1.5, 2, 5, 10, 15, 20, 25, 30, 35, 40, 50],\n",
    "    contour_shade                  = \"on\",\n",
    "    contour_shade_min_level        = 2,\n",
    "    contour_shade_method           = \"area_fill\",\n",
    "    contour_shade_colour_method    = \"list\",\n",
    "    contour_shade_colour_list      = ['#ffffd9','#edf8b1','#c7e9b4',\n",
    "                                      '#7fcdbb','#41b6c4','#1d91c0',\n",
    "                                      '#225ea8','#253494','#081d58'],\n",
    "    contour                        = \"on\",\n",
    "    contour_line_colour            = '#7fcdbb',\n",
    "    contour_highlight              = \"on\", \n",
    "    contour_highlight_frequency    = 3,\n",
    "    contour_highlight_colour       = '#7fcdbb',\n",
    "    contour_min_level              = 0,\n",
    "    legend                         = \"on\",\n",
    "    contour_label = 'off'\n",
    ")\n",
    "\n",
    "magics.plot(projection, precipitation, tp_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Grid shading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 208336 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grid_shading = magics.mcont(\n",
    "    contour_shade_technique      = \"grid_shading\",\n",
    "    contour_shade_colour_method  = \"list\",\n",
    "    contour                      = \"off\",\n",
    "    contour_level_selection_type = \"level_list\",\n",
    "    contour_level_list           = [0.5,1.5,3.5,5.5,6.5,7.5,8.5],\n",
    "    contour_shade                = \"on\",\n",
    "    contour_shade_min_level      = 0.5,\n",
    "    contour_shade_max_level      = 8.5,\n",
    "    contour_shade_colour_list    = [\"green\",\"red\",\"sky\",\"navy\",\"cyan\",\"orange\"],\n",
    "    legend                       = \"on\"\n",
    ")  \n",
    "\n",
    "magics.plot(projection, black_coast, ptype, grid_shading, legend)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Grid_shading + gradients"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 123608 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tp_cont = magics.mcont(\n",
    "    contour_level_selection_type     = \"level_list\",\n",
    "    contour_level_list               = [0., 10, 30, 60, 90],\n",
    "    contour_shade                    = \"on\",\n",
    "    contour_gradients_step_list       = [5,4,5,3],\n",
    "    contour_shade_technique           = \"grid_shading\",\n",
    "    contour_shade_colour_method       = \"gradients\",\n",
    "    contour_gradients_technique       = \"hcl\",\n",
    "    contour_shade_method              = \"area_fill\",\n",
    "    CONTOUR_GRADIENTS_TECHNIQUE_DIRECTION = \"ANTI_CLOCKWISE\",\n",
    "    contour_gradients_colour_list     = [\"white\",\"greenish_blue\",\n",
    "                                         \"orangish_red\",\"RGB(0.3756,0.06648,0.05582)\",\"blue_purple\"],\n",
    "    contour_gradients_waypoint_method = \"left\",\n",
    "    contour                        = \"on\",\n",
    "    contour_line_colour            = 'black',\n",
    "    contour_highlight              = \"on\", \n",
    "    contour_highlight_frequency    = 3,\n",
    "    contour_highlight_colour       = '#7fcdbb',\n",
    "    contour_min_level              = 0,\n",
    "    legend                         = \"on\"\n",
    ")\n",
    "\n",
    "magics.plot(zoomed_projection, precipitation, tp_cont, coast, legend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 144688 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grid_shading = magics.mcont(\n",
    "    contour_shade_technique      = \"grid_shading\",\n",
    "    contour_shade_colour_method  = \"list\",\n",
    "    contour                      = \"off\",\n",
    "    contour_level_selection_type = \"level_list\",\n",
    "    contour_level_list           = [0.5,1.5,3.5,5.5,6.5,7.5,8.5],\n",
    "    contour_shade                = \"on\",\n",
    "    contour_shade_min_level      = 0.5,\n",
    "    contour_shade_max_level      = 8.5,\n",
    "    contour_shade_colour_list    = [\"green\",\"red\",\"sky\",\"navy\",\"cyan\",\"orange\"],\n",
    "    legend                       = \"on\"\n",
    ")  \n",
    "\n",
    "\n",
    "\n",
    "legend_grid = magics.mlegend(\n",
    "    legend_user_lines         =  [\"Rain\",\"Freezing rain\", \"Snow\", \"Wet snow\", \"Sleet\", \"Ice pellets\"],\n",
    "    legend_box_mode           = \"automatic\",\n",
    "    legend_automatic_position = \"right\",\n",
    "    legend_text_composition   = \"user_text_only\",\n",
    "    legend_text_colour        = \"charcoal\",   \n",
    "    legend_text_font_size     = 0.5)\n",
    "\n",
    "magics.plot(zoomed_projection, black_coast, ptype, grid_shading, legend_grid)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Marker shading\n",
    "\n",
    "Since we are already plotting precipitation type, we might want appropriate symbol for each precipitation type. Magics has built in collection of meteorological symbols and all you have to do is give it WMO code. Full list of WMO codes and descriptions for present/past weather, sky cover, pressure tendency and clouds you can find [on Wikipedia](https://commons.wikimedia.org/wiki/Weather_map \"Weather map symbols\").\n",
    "\n",
    "|**marker type** | names |\n",
    "|-----------------|\n",
    "| present weather | ww_00,.., ww_99  |  \n",
    "| past weather | W_0,.., W_9 |\n",
    "| low clouds | CL_1,.., CL_9 |\n",
    "| medium clouds | CM_1,.., CM_9 |\n",
    "| high clouds | CH_1,.., CH_9 |\n",
    "| type of cloud| C_0,.., C_9|\n",
    "| total amount all clouds | N_0,..,N9 |\n",
    "| atmospheric pressure tendency | a_0,..,a_9 |\n",
    "\n",
    "Let's also zoom map a little bit so we can see markers better."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 178872 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "marker_shading = magics.mcont(\n",
    "        contour                         = \"off\",\n",
    "        legend                          = \"off\",\n",
    "        contour_level_list              = [1.00,3.00,5.00,6.00,7.00,8.00,9.00],\n",
    "        contour_level_selection_type    = \"level_list\",\n",
    "        contour_shade                   = \"on\",\n",
    "        contour_shade_colour_table      = [\"green\",\"red\",\"blue\",\"navy\",\"turquoise\",\"orange\"],\n",
    "        contour_shade_height_table      = [1.0],\n",
    "        contour_shade_marker_table_type = \"name\",\n",
    "        contour_shade_marker_name_table = [\"ww_60\",\"ww_67\",\"ww_70\",\"ww_68\",\"ww_69\",\"ww_79\"],\n",
    "        contour_shade_technique         = \"marker\") \n",
    "\n",
    "zoomed_projection = magics.mmap(\n",
    "    subpage_clipping  = 'on',\n",
    "    subpage_lower_left_latitude    = 47.,\n",
    "    subpage_lower_left_longitude   = 25.0,\n",
    "    subpage_map_projection         = 'polar_stereographic',\n",
    "    subpage_upper_right_latitude   = 52.,\n",
    "    subpage_upper_right_longitude  = 33.5,\n",
    "    subpage_map_vertical_longitude = 29.0,\n",
    "    subpage_map_area_definition    = 'corners',\n",
    "    page_id_line             = \"off\"\n",
    "\n",
    ")\n",
    "\n",
    "magics.plot(zoomed_projection, black_coast, ptype, marker_shading)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 418444 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "marker_shading = magics.mcont(\n",
    "        contour                         = \"off\",\n",
    "        legend                          = \"off\",\n",
    "        contour_level_list              = [1.00,2.00,3.00,4.00,5.00,6.00,7.00,8.00,9.00],\n",
    "        contour_level_selection_type    = \"level_list\",\n",
    "        contour_shade                   = \"on\",\n",
    "        contour_shade_colour_table      = [\"white\",\"cyan\",\"orange\",\"rose\",\"turquoise\",\"pink\",\"green\",\"yellow\"],\n",
    "        contour_shade_height_table      = [0.3,0.4,0.4,0.5,0.6,0.8],\n",
    "        contour_shade_marker_table_type = \"name\",\n",
    "        contour_shade_marker_name_table = [\"N_1\",\"N_2\",\"N_3\",\"N_4\",\"N_5\",\"N_6\",\"N_7\",\"N_8\"],\n",
    "        contour_shade_technique         = \"marker\") \n",
    "\n",
    "zoomed_projection = magics.mmap(\n",
    "    subpage_clipping  = 'on',\n",
    "    subpage_lower_left_latitude    = 47.,\n",
    "    subpage_lower_left_longitude   = 23.0,\n",
    "    subpage_map_projection         = 'polar_stereographic',\n",
    "    subpage_upper_right_latitude   = 55.,\n",
    "    subpage_upper_right_longitude  = 40,\n",
    "    subpage_map_vertical_longitude = 29.0,\n",
    "    subpage_map_area_definition    = 'corners',\n",
    "    page_id_line             = \"off\"\n",
    "\n",
    ")\n",
    "\n",
    "magics.plot(zoomed_projection, black_coast, ptype, marker_shading)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cell shading\n",
    "\n",
    "Cell shading is another contour_shade_technique. If we don't want to do full grid shading, but to group them in cells, we can use cell_shading technique."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 206900 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ir_clouds = magics.mcont(\n",
    "    contour_shade_colour_direction   = \"clockwise\",\n",
    "    contour_shade_min_level_colour   = \"white\",\n",
    "    contour_shade_max_level_colour   = \"black\",\n",
    "    contour_shade_colour_method      = \"calculate\",\n",
    "    legend                           = \"off\",\n",
    "    contour                          = \"off\",\n",
    "    contour_level_selection_type     = \"level_list\",\n",
    "    contour_level_list               = [170.,199.,201.,203.,205.,207,208,209,210,\n",
    "                                        211,212,213,214,215,216,217,218,219,220,\n",
    "                                        221,222,223,224,225,226,227,228,229,230,\n",
    "                                        231,232,233,234,235,236,237,238,239,240,\n",
    "                                        241,242,243,244,245,246,247,249,251,253,\n",
    "                                        255,257,259,261,263,265,267,269,271,273,\n",
    "                                        275,277,279,281,283,285,287,289,291,293,\n",
    "                                        295,297,299,301,303,305,307,310,315,320,350],\n",
    "    contour_shade                    = \"on\",\n",
    "    contour_shade_technique          = \"cell_shading\",\n",
    "    contour_shade_cell_resolution    = 80\n",
    "    )\n",
    "\n",
    "magics.plot(projection, sat_ir, ir_clouds, coast)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 160340 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ir_clouds = magics.mcont(\n",
    "    contour_shade_colour_direction   = \"anti_clockwise\",\n",
    "    contour_shade_min_level_colour   = \"evergreen\",\n",
    "    contour_shade_max_level_colour   = \"white\",\n",
    "    contour_shade_min_level          = 200,\n",
    "    contour_shade_max_level          = 300,\n",
    "    contour_shade_colour_method      = \"calculate\",\n",
    "    legend                           = \"on\",\n",
    "    contour                          = \"off\",\n",
    "    contour_level_selection_type     = \"count\",\n",
    "    contour_level_count              = 20,\n",
    "    contour_shade                    = \"on\",\n",
    "    contour_shade_technique          = \"cell_shading\",\n",
    "    contour_shade_cell_resolution    = 20\n",
    "    )\n",
    "\n",
    "magics.plot(projection, sat_ir, ir_clouds, coast, legend)"
   ]
  }
 ],
 "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.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
