Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhassell committed Sep 26, 2023
1 parent 075dba9 commit 2ebe7b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
10 changes: 5 additions & 5 deletions cf/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -3507,7 +3507,7 @@ def weights(
domain_axes = self.domain_axes(todict=True)

for da_key in domain_axes:
if Weights.geometry_area(
if Weights.polygon_area(
self,
da_key,
comp,
Expand All @@ -3520,7 +3520,7 @@ def weights(
):
# Found area weights from polygon geometries
pass
elif Weights.geometry_line(
elif Weights.line_length(
self,
da_key,
comp,
Expand Down Expand Up @@ -3690,7 +3690,7 @@ def weights(
pass
else:
# Found area weights from UGRID/geometry cells
Weights.geometry_area(
Weights.polygon_area(
self,
None,
comp,
Expand All @@ -3710,7 +3710,7 @@ def weights(
f"{axis!r}"
)

if Weights.geometry_area(
if Weights.polygon_area(
self,
da_key,
comp,
Expand All @@ -3723,7 +3723,7 @@ def weights(
):
# Found area weights from polygon geometries
pass
elif Weights.geometry_line(
elif Weights.line_length(
self,
da_key,
comp,
Expand Down
24 changes: 14 additions & 10 deletions cf/weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def field_scalar(cls, f, methods=False):
return f

@classmethod
def geometry_area(
def polygon_area(
cls,
f,
domain_axis,
Expand Down Expand Up @@ -478,7 +478,7 @@ def geometry_area(

from .units import Units

axis, aux_X, aux_Y, aux_Z = cls.yyy(
axis, aux_X, aux_Y, aux_Z = cls._geometry_cells(
f, domain_axis, "polygon", methods=methods, auto=auto
)

Expand Down Expand Up @@ -585,7 +585,7 @@ def geometry_area(

col0 = cols.item(0)
equal_nodes = (cols == col0).all()
if equal_nodes:
if equal_nodes:
# All polygons have the same number of nodes, so we can
# use an integer and a slice in place of two integer
# arrays, which is much faster.
Expand Down Expand Up @@ -756,7 +756,7 @@ def geometry_area(
return True

@classmethod
def geometry_line(
def line_length(
cls,
f,
domain_axis,
Expand Down Expand Up @@ -807,7 +807,7 @@ def geometry_line(
"""
from .units import Units

axis, aux_X, aux_Y, aux_Z = cls.yyy(
axis, aux_X, aux_Y, aux_Z = cls._geometry_cells(
f, domain_axis, "line", methods=methods, auto=auto
)

Expand Down Expand Up @@ -945,7 +945,7 @@ def geometry_volume(
"""
from .units import Units

axis, aux_X, aux_Y, aux_Z = cls.yyy(
axis, aux_X, aux_Y, aux_Z = cls._geometry_cells(
f, "polygon", methods=methods, auto=auto
)

Expand Down Expand Up @@ -979,7 +979,7 @@ def geometry_volume(

if not methods:
# Initialise cell volumes as the cell areas
areas = cls.geometry_area(
areas = cls.polygon_area(
f,
weights,
weights_axes,
Expand Down Expand Up @@ -1431,7 +1431,9 @@ def scale(cls, w, scale):
return w

@classmethod
def yyy(cls, f, domain_axis, geometry_type, methods=False, auto=False):
def _geometry_cells(
cls, f, domain_axis, geometry_type, methods=False, auto=False
):
"""Checks whether weights can be created for given coordinates.
.. versionadded:: UGRIDVER
Expand Down Expand Up @@ -1463,8 +1465,10 @@ def yyy(cls, f, domain_axis, geometry_type, methods=False, auto=False):

for key, aux in auxiliary_coordinates_1d.items():
aux_axis = f.get_data_axes(key)[0]
dt = f.domain_topology(default=None, filter_by_axis=(aux_axis,))
if dt is None and aux.get_geometry(None) != geometry_type:
topology = f.domain_topology(
default=None, filter_by_axis=(aux_axis,)
)
if topology is None and aux.get_geometry(None) != geometry_type:
continue

# Still here? Then this auxiliary coordinate has either UGRID
Expand Down

0 comments on commit 2ebe7b8

Please sign in to comment.