{ "cells": [ { "cell_type": "markdown", "source": [ "# Grid Metrics\n", "Most modern circulation models discretize the partial differential equations needed to simulate the earth system on a logically rectangular grid. This means the grid for a single time step can be represented as a 3-dimensional array of cells. Even for more complex grid geometries like [here](https://xgcm.readthedocs.io/en/latest/grid_topology.html), subdomains are usually organized in this manner. A noteable exception are models with unstructured grids [example](https://en.wikipedia.org/wiki/Unstructured_grid), which currently cannot be processed with the datamodel of xarray and xgcm.\n", "\n", "Our grid operators work on the logically rectangular grid of an ocean model, meaning that e.g. differences are evaluated on the 'neighboring' cells in either direction, but even though these cells are adjacent, cells can have different size and geometry.\n", "\n", "In order to convert operators acting on the logically rectangular grid to physically meaningful output models need 'metrics' - information about the grid cell geometry in physical space.\n", "In the case of a perfectly [rectangular cuboid](https://en.wikipedia.org/wiki/Cuboid), the only metrics needed would be three of the edge distances. All other distances can be reconstructed exactly. Most ocean models have however slightly distorted cells, due to the curvature of the earth. To accurately represent the volume of the cell we require more metrics. \n", "\n", "Each grid point has three kinds of fundamental metrics associated with it which differ in the number of described axes:\n", "\n", "1. **Distances**: A distance is associated with a single axis (e.g. `('X',)`,`('Y',)` or `('Z',)`). Each distance describes the distance from the point to either face of the cell associated with the grid point. \n", "2. **Areas**: An area is associated with a pair of axes (e.g. `('X', 'Y')`, `('Y', 'Z')` and `('X', 'Z')`). Each grid point intersects three areas.\n", "3. **Volume**: The cell volume is unique for each cell and associated with all three axes (`('X', 'Y', 'Z')`).\n", "\n", "## Using metrics with xgcm\n", "Once the user assigns the metrics (given as coordinates in most model output) to the `grid` object, xgcm is able to automatically select and apply these to calculate e.g. derivatives and integrals from model data. \n", "\n", "