{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Grid Index Ordering\n", "\n", "Cell indices in ICON global grids are ordered in a specific manner which simplifies a bunch of operations an which is interesting to know about. Here, we'll look at a few aspects of this particular ordering." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pylab as plt\n", "import numpy as np\n", "import xarray as xr\n", "import cartopy.crs as ccrs\n", "import cartopy.feature as cfeature" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We'll start using a relatively coarse (R02B03) grid in order to make the plots less crowded and our live easier." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (cell: 5120, nv: 3, vertex: 2562, ne: 6, edge: 7680, no: 4, nc: 2, max_stored_decompositions: 4, two_grf: 2, cell_grf: 14, max_chdom: 1, edge_grf: 24, vert_grf: 13)\n", "Coordinates:\n", " clon (cell) float64 1.274 1.34 ... 1.437 1.329\n", " clat (cell) float64 0.9184 0.9398 ... -0.8052\n", " vlon (vertex) float64 1.274 1.213 ... 1.274 1.325\n", " vlat (vertex) float64 0.9625 0.8955 ... -0.7609\n", " elon (edge) float64 1.306 1.242 ... 1.407 1.354\n", " elat (edge) float64 0.9292 0.9292 ... -0.7939\n", "Dimensions without coordinates: cell, nv, vertex, ne, edge, no, nc, max_stored_decompositions, two_grf, cell_grf, max_chdom, edge_grf, vert_grf\n", "Data variables: (12/91)\n", " clon_vertices (cell, nv) float64 1.274 1.213 ... 1.325\n", " clat_vertices (cell, nv) float64 0.9625 0.8955 ... -0.7609\n", " vlon_vertices (vertex, ne) float64 9.969e+36 ... 9.969e+36\n", " vlat_vertices (vertex, ne) float64 9.969e+36 ... 9.969e+36\n", " elon_vertices (edge, no) float64 1.335 1.34 ... 1.385\n", " elat_vertices (edge, no) float64 0.8955 0.9398 ... -0.8265\n", " ... ...\n", " edge_dual_normal_cartesian_x (edge) float64 -0.2769 -0.6793 ... 0.6559\n", " edge_dual_normal_cartesian_y (edge) float64 0.8043 -0.512 ... 0.4705\n", " edge_dual_normal_cartesian_z (edge) float64 -0.5257 0.5257 ... 0.5902\n", " cell_circumcenter_cartesian_x (cell) float64 0.1775 0.1351 ... 0.1662\n", " cell_circumcenter_cartesian_y (cell) float64 0.5805 0.5743 ... 0.6727\n", " cell_circumcenter_cartesian_z (cell) float64 0.7947 0.8074 ... -0.721\n", "Attributes: (12/43)\n", " title: ICON grid description\n", " institution: Max Planck Institute for Meteorology/Deutscher ...\n", " source: git@git.mpimet.mpg.de:GridGenerator.git\n", " revision: 2cdf99bec403902989148ebb4bd38c218a64a1b3\n", " date: 20190405 at 141502\n", " user_name: Rene Redler (m300083)\n", " ... ...\n", " topography: modified SRTM30\n", " symmetry: along equator\n", " subcentre: 1\n", " number_of_grid_used: 30\n", " ICON_grid_file_uri: http://icon-downloads.mpimet.mpg.de/grids/publi...\n", " NCO: netCDF Operators version 4.7.5 (Homepage = http...
array([1.27409 , 1.339784, 1.208396, ..., 1.37425 , 1.436983, 1.328586])
array([ 0.918432, 0.93978 , 0.93978 , ..., -0.734887, -0.79992 , -0.805211])
array([1.27409 , 1.213028, 1.335153, ..., 1.222891, 1.27409 , 1.32529 ])
array([ 0.9625 , 0.895474, 0.895474, ..., -0.760894, -0.692827, -0.760894])
array([1.305992, 1.242189, 1.27409 , ..., 1.376351, 1.407033, 1.354338])
array([ 0.92921 , 0.92921 , 0.896384, ..., -0.759171, -0.79145 , -0.793938])
array([[1.27409 , 1.213028, 1.335153],\n", " [1.335153, 1.408679, 1.27409 ],\n", " [1.27409 , 1.139502, 1.213028],\n", " ...,\n", " [1.32529 , 1.368626, 1.427183],\n", " [1.427183, 1.49535 , 1.385393],\n", " [1.385393, 1.27409 , 1.32529 ]])
array([[ 0.9625 , 0.895474, 0.895474],\n", " [ 0.895474, 0.958823, 0.9625 ],\n", " [ 0.9625 , 0.958823, 0.895474],\n", " ...,\n", " [-0.760894, -0.69077 , -0.756151],\n", " [-0.756151, -0.818425, -0.826531],\n", " [-0.826531, -0.829283, -0.760894]])
array([[9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " ...,\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36]])
array([[9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " ...,\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36],\n", " [9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36]])
array([[1.335153, 1.339784, 1.27409 , 1.27409 ],\n", " [1.27409 , 1.208396, 1.213028, 1.27409 ],\n", " [1.213028, 1.27409 , 1.335153, 1.27409 ],\n", " ...,\n", " [1.378493, 1.427183, 1.37425 , 1.32529 ],\n", " [1.378493, 1.385393, 1.436983, 1.427183],\n", " [1.378493, 1.32529 , 1.328586, 1.385393]])
array([[ 0.895474, 0.93978 , 0.9625 , 0.918432],\n", " [ 0.9625 , 0.93978 , 0.895474, 0.918432],\n", " [ 0.895474, 0.873682, 0.895474, 0.918432],\n", " ...,\n", " [-0.782817, -0.756151, -0.734887, -0.760894],\n", " [-0.782817, -0.826531, -0.79992 , -0.756151],\n", " [-0.782817, -0.760894, -0.805211, -0.826531]])
array([9.96921e+36, 9.96921e+36, 9.96921e+36, ..., 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36])
array([9.96921e+36, 9.96921e+36, 9.96921e+36, ..., 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36])
array([9.96921e+36, 9.96921e+36, 9.96921e+36, ..., 9.96921e+36, 9.96921e+36,\n", " 9.96921e+36])
array([1.024614e+11, 1.039760e+11, 1.039760e+11, ..., 1.032592e+11,\n", " 1.034199e+11, 1.037767e+11])
array([2.061924e+11, 2.062077e+11, 2.062077e+11, ..., 2.051674e+11,\n", " 2.042820e+11, 2.051674e+11])
array([1, 1, 1, ..., 1, 1, 1], dtype=int32)
array([1, 1, 1, ..., 1, 1, 1], dtype=int32)
array([1.27409 , 1.339784, 1.208396, ..., 1.37425 , 1.436983, 1.328586])
array([ 0.918432, 0.93978 , 0.93978 , ..., -0.734887, -0.79992 , -0.805211])
array([ 0.91843 , 0.939636, 0.939636, ..., -0.736368, -0.800875, -0.806078])
array([1.27409 , 1.339296, 1.208884, ..., 1.37367 , 1.435929, 1.328242])
array([1.27409 , 1.213028, 1.335153, ..., 1.222891, 1.27409 , 1.32529 ])
array([ 0.9625 , 0.895474, 0.895474, ..., -0.760894, -0.692827, -0.760894])
array([1.305992, 1.242189, 1.27409 , ..., 1.376351, 1.407033, 1.354338])
array([ 0.92921 , 0.92921 , 0.896384, ..., -0.759171, -0.79145 , -0.793938])
array([[ 1, 5, 6, ..., 7669, 7363, 7623],\n", " [ 2, 4, 7, ..., 7364, 7624, 7671],\n", " [ 3, 1, 2, ..., 7678, 7679, 7680]], dtype=int32)
array([[ 1, 3, 1, ..., 2562, 2475, 2552],\n", " [ 2, 4, 5, ..., 2474, 2470, 2547],\n", " [ 3, 1, 2, ..., 2475, 2552, 2562]], dtype=int32)
array([[ 1, 1, 1, ..., 5117, 5117, 5117],\n", " [ 2, 3, 4, ..., 5118, 5119, 5120]], dtype=int32)
array([[ 3, 1, 2, ..., 2562, 2475, 2552],\n", " [ 1, 2, 3, ..., 2475, 2552, 2562]], dtype=int32)
array([[ 1, 1, 1, ..., 5105, 5105, 5105],\n", " [ 2, 3, 2, ..., 5106, 5106, 5107],\n", " [ 3, 4, 4, ..., 5108, 5107, 5108],\n", " [ 5, 9, 13, ..., 5109, 5113, 5117],\n", " [ 6, 10, 14, ..., 5110, 5114, 5118],\n", " [ 8, 12, 16, ..., 5112, 5116, 5120]], dtype=int32)
array([[ 1, 2, 1, ..., 7663, 7663, 7664],\n", " [ 2, 3, 3, ..., 7665, 7664, 7665],\n", " [ 4, 7, 5, ..., 7666, 7667, 7669],\n", " [ 6, 8, 9, ..., 7670, 7668, 7671],\n", " [ 10, 17, 24, ..., 7672, 7675, 7678],\n", " [ 12, 19, 26, ..., 7674, 7677, 7680]], dtype=int32)
array([[ 3, 1, 1, ..., 2561, 2560, 2561],\n", " [ 2, 3, 2, ..., 2562, 2562, 2560],\n", " [ 4, 5, 4, ..., 2511, 2511, 2474],\n", " [ 5, 6, 6, ..., 2547, 2474, 2547],\n", " [ 7, 10, 13, ..., 2551, 2512, 2475],\n", " [ 8, 11, 14, ..., 2513, 2476, 2552]], dtype=int32)
array([1.024614e+11, 1.039760e+11, 1.039760e+11, ..., 1.032592e+11,\n", " 1.034199e+11, 1.037767e+11])
array([0., 0., 0., ..., 0., 0., 0.])
array([0, 0, 0, ..., 0, 0, 0], dtype=int32)
array([[-1, -1, -1, -1],\n", " [-1, -1, -1, -1],\n", " [-1, -1, -1, -1],\n", " ...,\n", " [-1, -1, -1, -1],\n", " [-1, -1, -1, -1],\n", " [-1, -1, -1, -1]], dtype=int32)
array([0, 0, 0, 0], dtype=int32)
array([2.061924e+11, 2.062077e+11, 2.062077e+11, ..., 2.051674e+11,\n", " 2.042820e+11, 2.051674e+11])
array([486276.989186, 486276.989186, 486236.548474, ..., 472083.45348 ,\n", " 485826.624142, 496849.001131])
array([[140440.067587, 140440.067587, 140475.07982 , ..., 150968.997 ,\n", " 139640.532359, 129578.870499],\n", " [144572.866883, 144572.866883, 144639.495821, ..., 155033.252937,\n", " 144023.003658, 135041.419206]])
array([285012.93447 , 285012.93447 , 285114.575641, ..., 306002.249937,\n", " 283663.536017, 264620.289705])
array([0.001707, 0.001707, 0.001708, ..., 0.001779, 0.001697, 0.001619])
array([0., 0., 0., ..., 0., 0., 0.])
array([0, 0, 0, ..., 0, 0, 0], dtype=int32)
array([[243138.494593, 243138.494593, 243118.274237, ..., 236041.72674 ,\n", " 242913.312071, 248424.500565],\n", " [243138.494593, 243138.494593, 243118.274237, ..., 236041.72674 ,\n", " 242913.312071, 248424.500565]])
array([ 8.784942e-01, -8.784942e-01, -7.187471e-16, ..., -6.406706e-02,\n", " 9.231028e-01, -8.419251e-01])
array([ 0.477753, 0.477753, -1. , ..., 0.997946, -0.384553, -0.539594])
array([ 0.477753, 0.477753, -1. , ..., 0.997946, -0.384553, -0.539594])
array([-8.784942e-01, 8.784942e-01, 7.187471e-16, ..., 6.406706e-02,\n", " -9.231028e-01, 8.419251e-01])
array([[ 1, 1, 1, ..., -1, -1, -1],\n", " [ 1, 1, 1, ..., -1, -1, -1],\n", " [ 1, -1, -1, ..., -1, -1, -1]], dtype=int32)
array([ 1, 2, 3, ..., 5118, 5119, 5120], dtype=int32)
array([ 1, 1, 1, ..., 1280, 1280, 1280], dtype=int32)
array([200, 203, 201, ..., 203, 201, 202], dtype=int32)
array([[ 2, 16, 8, ..., 5107, 4887, 5070],\n", " [ 3, 6, 10, ..., 4888, 5071, 5108],\n", " [ 4, 1, 1, ..., 5117, 5117, 5117]], dtype=int32)
array([[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]], dtype=int32)
array([0, 0, 0, ..., 0, 0, 0], dtype=int32)
array([ 1, 2, 3, ..., 7678, 7679, 7680], dtype=int32)
array([202, 203, 201, ..., 202, 203, 201], dtype=int32)
array([ 1, 2, 3, ..., 2560, 2561, 2562], dtype=int32)
array([[ 1, 1, -1, ..., 1, -1, -1],\n", " [-1, -1, 1, ..., -1, 1, 1],\n", " [ 1, 1, -1, ..., 1, -1, -1],\n", " [-1, -1, 1, ..., -1, 1, 1],\n", " [-1, -1, -1, ..., 1, 1, 1],\n", " [ 1, 1, 1, ..., -1, -1, -1]], dtype=int32)
array([-1, -1, -1, ..., 1, 1, 1], dtype=int32)
array([-4, -4, -4, ..., -4, -4, -4], dtype=int32)
array([[-2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647],\n", " [-2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647]], dtype=int32)
array([[5121, 5121, 5121, 5121, 5121, 5121, 5121, 5121, 5121, 1, 1,\n", " 1, 1, 1]], dtype=int32)
array([[5120, 5120, 5120, 5120, 5120, 5120, 5120, 5120, 5120, 0, 0,\n", " 0, 0, 0]], dtype=int32)
array([-8, -8, -8, ..., -8, -8, -8], dtype=int32)
array([[-2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647],\n", " [-2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647]], dtype=int32)
array([[7681, 7681, 7681, 7681, 7681, 7681, 7681, 7681, 7681, 7681, 7681,\n", " 7681, 7681, 7681, 1, 1, 1, 1, 1, 1, 1, 1,\n", " 1, 1]], dtype=int32)
array([[7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680,\n", " 7680, 7680, 7680, 0, 0, 0, 0, 0, 0, 0, 0,\n", " 0, 0]], dtype=int32)
array([0, 0, 0, ..., 0, 0, 0], dtype=int32)
array([[-2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647],\n", " [-2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647, -2147483647, -2147483647,\n", " -2147483647, -2147483647, -2147483647]], dtype=int32)
array([[2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 1, 1, 1,\n", " 1, 1]], dtype=int32)
array([[2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 0, 0, 0,\n", " 0, 0]], dtype=int32)
array([ 2, 3, 1, ..., 1911, 1920, 1849], dtype=int32)
array([[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]], dtype=int32)
array([0, 0, 0, ..., 0, 0, 0], dtype=int32)
array([ -1, -2, -3, ..., -1918, -1919, -1920], dtype=int32)
array([0.167082, 0.218918, 0.145953, ..., 0.246908, 0.224963, 0.17602 ])
array([0.5465 , 0.585565, 0.607873, ..., 0.680831, 0.735822, 0.702503])
array([ 0.820623, 0.780505, 0.780505, ..., -0.689569, -0.638715, -0.689569])
array([0.156631, 0.19314 , 0.182568, ..., 0.140165, 0.114582, 0.150564])
array([0.577607, 0.566445, 0.597154, ..., 0.711737, 0.693411, 0.684683])
array([ 0.801147, 0.801147, 0.781074, ..., -0.68832 , -0.711373, -0.71312 ])
array([0.156324, 0.19337 , 0.182643, ..., 0.140227, 0.114253, 0.150881])
array([0.577561, 0.566235, 0.597398, ..., 0.711948, 0.69337 , 0.684444])
array([ 0.80124 , 0.80124 , 0.78087 , ..., -0.688089, -0.711466, -0.713282])
array([-0.948047, 0.707965, 0.228364, ..., 0.195585, -0.955352, 0.739635])
array([-0.139489, -0.645783, 0.746945, ..., 0.661582, -0.119405, -0.556637])
array([ 0.285919, 0.285919, -0.624439, ..., 0.723917, -0.27027 , -0.378279])
array([-0.2769 , -0.679325, 0.956305, ..., -0.970619, 0.27235 , 0.65595 ])
array([ 0.804309, -0.511962, -0.292372, ..., 0.236093, -0.710579, 0.470493])
array([-0.52575 , 0.52575 , -0. , ..., 0.046475, -0.64877 , 0.590225])
array([0.177489, 0.13508 , 0.209154, ..., 0.144882, 0.092958, 0.166206])
array([0.580541, 0.574293, 0.551646, ..., 0.727623, 0.690535, 0.672732])
array([ 0.794651, 0.807429, 0.807429, ..., -0.670503, -0.7173 , -0.720977])