{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Tri-Polar Grid Projected Plotting\n\nThis example demonstrates cell plots of data on the semi-structured ORCA2 model\ngrid.\n\nFirst, the data is projected into the PlateCarree coordinate reference system.\n\nSecond four pcolormesh plots are created from this projected dataset,\nusing different projections for the output image.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import cartopy.crs as ccrs\nimport matplotlib.pyplot as plt\n\nimport iris\nimport iris.analysis.cartography\nimport iris.plot as iplt\nimport iris.quickplot as qplt\n\n\ndef main():\n    # Load data\n    filepath = iris.sample_data_path(\"orca2_votemper.nc\")\n    cube = iris.load_cube(filepath)\n\n    # Choose plot projections\n    projections = {}\n    projections[\"Mollweide\"] = ccrs.Mollweide()\n    projections[\"PlateCarree\"] = ccrs.PlateCarree()\n    projections[\"NorthPolarStereo\"] = ccrs.NorthPolarStereo()\n    projections[\"Orthographic\"] = ccrs.Orthographic(\n        central_longitude=-90, central_latitude=45\n    )\n\n    pcarree = projections[\"PlateCarree\"]\n    # Transform cube to target projection\n    new_cube, extent = iris.analysis.cartography.project(\n        cube, pcarree, nx=400, ny=200\n    )\n\n    # Plot data in each projection\n    for name in sorted(projections):\n        fig = plt.figure()\n        fig.suptitle(\"ORCA2 Data Projected to {}\".format(name))\n        # Set up axes and title\n        ax = plt.subplot(projection=projections[name])\n        # Set limits\n        ax.set_global()\n        # plot with Iris quickplot pcolormesh\n        qplt.pcolormesh(new_cube)\n        # Draw coastlines\n        ax.coastlines()\n\n        iplt.show()\n\n\nif __name__ == \"__main__\":\n    main()"
      ]
    }
  ],
  "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.10.8"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}