{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "statutory-bargain",
   "metadata": {},
   "source": [
    "# Magics 4.11.0 ( Released 03/03/2022)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "subjective-shark",
   "metadata": {},
   "outputs": [],
   "source": [
    "from Magics import macro as magics"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "quarterly-spending",
   "metadata": {},
   "source": [
    "## Implementation of EPSG:3035\n",
    "\n",
    "[ETRS89-extended / LAEA Europe](https://epsg.io/3035)\n",
    "\n",
    "\n",
    "**Proj code:** *+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs*  \n",
    "\n",
    "**Projected bounds:**  \n",
    "1896628.62 1507846.05  \n",
    "4662111.45 6829874.45  \n",
    "\n",
    "**WGS84 bounds:**   \n",
    "-16.1 32.88  \n",
    "40.18 84.17  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "grateful-soccer",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 283728 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "\n",
    "map = magics.mmap(\n",
    "subpage_map_projection = 'EPSG:3035',\n",
    ")\n",
    "\n",
    "\n",
    "data = magics.mgrib(grib_input_file_name = \"release-4.12.0/2t.grib\")\n",
    "\n",
    "contour = magics.mcont(contour_automatic_setting=\"ecmwf\")\n",
    "\n",
    "coast = magics.mcoast(\n",
    "    map_coastline_resolution=\"medium\",\n",
    ")\n",
    "\n",
    "magics.plot(map, data, contour, coast)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "postal-establishment",
   "metadata": {},
   "source": [
    "## With a zoom over Europe "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "interstate-cloud",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 290588 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map = magics.mmap(\n",
    "    subpage_map_projection = 'EPSG:3035',\n",
    "    subpage_lower_left_longitude = -20.,\n",
    "    subpage_lower_left_latitude = 30., \n",
    "    subpage_upper_right_longitude = 100.,\n",
    "    subpage_upper_right_latitude = 50.,\n",
    "    subpage_map_area_definition = 'corners'\n",
    "    \n",
    ")\n",
    "\n",
    "\n",
    "data = magics.mgrib(grib_input_file_name = \"release-4.12.0/2t.grib\")\n",
    "\n",
    "contour = magics.mcont(contour_automatic_setting=\"ecmwf\")\n",
    "\n",
    "coast = magics.mcoast(\n",
    "    map_coastline_resolution=\"medium\",\n",
    ")\n",
    "\n",
    "magics.plot(map, data, contour, coast)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "surprised-hydrogen",
   "metadata": {},
   "source": [
    "## Automatic adjustement of the geographical area according to the extend of the data "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "elegant-victorian",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 227772 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from Magics import macro as magics\n",
    "map = magics.mmap(\n",
    "subpage_map_projection = 'automatic',\n",
    ")\n",
    "\n",
    "\n",
    "\n",
    "data = magics.mgrib(grib_input_file_name = \"release-4.12.0/2t-automatic.grib\")\n",
    "\n",
    "contour = magics.mcont(contour_automatic_setting=\"ecmwf\")\n",
    "\n",
    "coast = magics.mcoast(\n",
    "    map_coastline_resolution=\"medium\",\n",
    ")\n",
    "\n",
    "magics.plot(map, data, contour, coast)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "speaking-polls",
   "metadata": {},
   "source": [
    "## Selecting polar sterographic projection if the minimum latitude is over 45 &deg;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "abroad-breakfast",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 216056 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from Magics import macro as magics\n",
    "map = magics.mmap(\n",
    "   subpage_map_projection = 'automatic',\n",
    ")\n",
    "\n",
    "data = magics.mgrib(grib_input_file_name = \"release-4.12.0/2t-automatic-polar.grib\")\n",
    "\n",
    "contour = magics.mcont(contour_automatic_setting=\"ecmwf\")\n",
    "\n",
    "coast = magics.mcoast(\n",
    "    map_coastline_resolution=\"medium\",\n",
    ")\n",
    "\n",
    "magics.plot(map, data, contour, coast)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21c86a40-a3b4-44b8-9ddc-e01059b5a160",
   "metadata": {},
   "source": [
    "## Selecting polar sterographic projection if the minimum latitude is over 45 °, and rotating towards west"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "renewable-exception",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 274704 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = magics.mgrib(grib_input_file_name = \"release-4.12.0/2t-automatic-polar-states.grib\")\n",
    "magics.plot(map, data, contour, coast)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d71e9cf2-9d98-4ed4-8611-2b9d7bd71071",
   "metadata": {},
   "source": [
    "## Selecting polar sterographic projection if the minimum latitude is over 45 °, and rotating towards west ( Larger area )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f6cd3677-02b0-4659-814a-fbc106cdb3d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 318612 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = magics.mgrib(grib_input_file_name = \"release-4.12.0/2t-automatic-polar-states2.grib\")\n",
    "magics.plot(map, data, contour, coast)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d383863f-9135-4307-aa3e-10e75bd00ea6",
   "metadata": {},
   "source": [
    "## Selecting polar sterographic projection if the minimum latitude is over 45 °, and rotating towards east"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "9131c32c-cd26-45c0-aa10-f287099535f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 289640 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = magics.mgrib(grib_input_file_name = \"release-4.12.0/2t-automatic-polar-east.grib\")\n",
    "magics.plot(map, data, contour, coast)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a6d45a8f-2c3a-47eb-a0ed-531906f8c4d4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f70c54ce-8d09-4d22-8e0a-8da45613e565",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "334a2276-0b88-4b81-b8f0-865321d323a7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b561e2b2-a209-4f3c-ac5d-1d7b0e479003",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
