Skip to content

A fix for the default naming of dimensions such as "nX"

Fraser William Goldsworth requested to merge m301014/pyicon:n-fixing into master

At the moment, the default dimension names for some dimensions in ICON are nc, nv and ne, presumably referring to the numbers of cells, vertices and edges of different grid elements. See for example the below image:

Screenshot_2023-03-06_at_18.13.17

The naming isn't particularly consistent though --- variables such as vertices_of_vertex have dims nc despite the fact that the vertices of a vertex have nothing to do with cells. This commit changes the behaviour of convert_tgrid to give appropriate names to these dimensions based on the context. For instance, vertices_of_vertex gets the new dimension name nv_v, meaning number of vertices per vertex. The full list of new dimension names is at the end of this commit message.

I have combed through the pyicon xarray functions to make sure the updated variable names work, and I think I've found them all. This commit may, however, introduce breaking changes into other people's code. I have added a DeprecationWarning which warns of this behaviour when calling convert_tgrid. There is an option to either use the old behaviour (no renaming) and to silence the warning. Using the old behaviour means the resulting ds_IcD is not compatible with other pyicon functions, but I could change this if needed?

    dim_name_remappings = {
    # Format of <<variable name>>: {<<original dim name>>: <<new dim name>}
        "vertex_of_cell": {"nv": "nv_c"},
        "edge_vertices": {"nc": "nv_e"},
        "vertices_of_vertex": {"ne": "nv_v"},
        "edge_of_cell": {"nv": "ne_c"},
        "edges_of_vertex": {"ne": "ne_v"},
        "adjacent_cell_of_edge": {"nc": "nc_e"},
        "cells_of_vertex": {"ne": "nc_v"},
        "edge_cell_distance": {"nc": "nc_e"},
        "orientation_of_normal": {"nv": "ne_c"},
        "edge_orientation": {"ne": "ne_v"}    
    }

Merge request reports