cfdm.DomainTopology.to_edge¶
- DomainTopology.to_edge(sort=False, face_nodes=None)[source]¶
Create a new domain topology of edges.
The edges are defined from the original domain topology, either as sides of faces, or the links between nodes, or copied from the existing edges.
Added in version (cfdm): 1.13.1.0
- Parameters:
- sort:
bool If True then sort output edges. This is equivalent to, but faster than, setting sort to False and sorting the returned
DomainTopologywith itssortmethod.- face_nodes:
Noneor sequence ofint, optional The unique node ids for ‘face’ cells. If
None(the default) then the node ids will be inferred from the data, at some computational expense. The order of the nodes is immaterial. Providing face_nodes is an optimisation in the case that these are known externally.Warning
No checks are carried out to ensure that the given face_nodes match the actual node ids stored in the data, and a mis-match will result in an exception or, worse, an incorrect result.
- sort:
- Returns:
DomainTopologyThe domain topology construct of unique edges.
Examples
>>> f = cfdm.example_field(8) >>> print(f) Field: air_temperature (ncvar%ta) --------------------------------- Data : air_temperature(time(2), ncdim%nMesh2_face(3)) K Cell methods : time(2): point (interval: 3600 s) Dimension coords: time(2) = [2016-01-02 01:00:00, 2016-01-02 11:00:00] gregorian Auxiliary coords: longitude(ncdim%nMesh2_face(3)) = [-44.0, -44.0, -42.0] degrees_east : latitude(ncdim%nMesh2_face(3)) = [34.0, 32.0, 34.0] degrees_north Topologies : cell:face(ncdim%nMesh2_face(3), 4) = [[2, ..., --]] Connectivities : connectivity:edge(ncdim%nMesh2_face(3), 5) = [[0, ..., --]] >>> dt = f[0].domain_topology() >>> print(dt.array) [[2 3 1 0] [4 5 3 2] [6 1 3 --]] >>> edge = dt.to_edge() >>> edge <DomainTopology: cell:edge(9, 2) > >>> print(edge.array) [[0 1] [2 4] [2 3] [0 2] [4 5] [3 6] [1 6] [1 3] [3 5]] >>> print(dt.to_edge(sort=True).array) [[0 1] [0 2] [1 3] [1 6] [2 3] [2 4] [3 5] [3 6] [4 5]]
>>> f = cfdm.example_field(10) >>> print(f) Field: air_pressure (ncvar%pa) ------------------------------ Data : air_pressure(time(2), ncdim%nMesh2_node(7)) hPa Cell methods : time(2): point (interval: 3600 s) Dimension coords: time(2) = [2016-01-02 01:00:00, 2016-01-02 11:00:00] gregorian Auxiliary coords: longitude(ncdim%nMesh2_node(7)) = [-45.0, ..., -40.0] degrees_east : latitude(ncdim%nMesh2_node(7)) = [35.0, ..., 34.0] degrees_north Topologies : cell:point(ncdim%nMesh2_node(7), 5) = [[0, ..., --]] >>> dt = f[0].domain_topology() >>> print(dt.array) [[0 1 2 -- --] [1 6 0 3 --] [2 0 3 4 --] [3 2 1 5 6] [4 2 5 -- --] [5 4 3 -- --] [6 3 1 -- --]] >>> dt.to_edge() <DomainTopology: cell:edge(9, 2) > >>> print(dt.to_edge(sort=True).array) [[0 1] [0 2] [1 3] [1 6] [2 3] [2 4] [3 5] [3 6] [4 5]]