The shapes module has 'moa_ratio()andnmi()` functions. They are short, and their docstrings are relevant, so I am reproducing them in their entirety here.
def moa_ratio(collection):
"""
Computes the ratio of the second moment of area (like Li et al (2013)) to
the moment of area of a circle with the same area.
"""
ga = _cast(collection)
r = shapely.length(ga) / (2 * numpy.pi)
return (numpy.pi * 0.5 * r**4) / second_areal_moment(ga)
def nmi(collection):
"""
Computes the Normalized Moment of Inertia from Li et al (2013), recognizing
that it is the relationship between the area of a shape squared divided by
its second moment of area.
"""
ga = _cast(collection)
return shapely.area(ga) ** 2 / (2 * second_areal_moment(ga) * numpy.pi)
From the cited Li, et al. (2013):
The shape index base upon MI, CMI , is calculated as the ratio of the MI of a circle of the
same area about its center, to the MI of the shape about its centroid.
This is implemented as moa_ratio(), as explained in the docstring.
However, Li, et al. (2013) go on to say:
Mathematically, it can be expressed as:
$$ C_{MI} = \frac{A^2}{2 \pi I_g}$$
This is implemented as nmi(). $I_g$ was previously defined in the article as the moment of inertia about the centroid, which is calculated in the function by second_areal_moment(ga). Substituting in, you can see that nmi() faithfully captures this equation.
The problem is that Li, et al. (2013) makes clear that these are the same thing. Only one formula is given, and that formula is correctly represented by nmi(). There is no second formula in the article that is the basis for moa_ratio(). The module should probably only have one function, but the two functions should produce the exact same, which they do not.
I recommend that moa_ratio() be removed. For now, it could be changed to merely call nmi() with a deprecation warning, and in the future it should be removed.
If this is acceptable to implement, please assign to me.
The shapes module has 'moa_ratio()
andnmi()` functions. They are short, and their docstrings are relevant, so I am reproducing them in their entirety here.From the cited Li, et al. (2013):
This is implemented as
moa_ratio(), as explained in the docstring.However, Li, et al. (2013) go on to say:
This is implemented as$I_g$ was previously defined in the article as the moment of inertia about the centroid, which is calculated in the function by
nmi().second_areal_moment(ga). Substituting in, you can see thatnmi()faithfully captures this equation.The problem is that Li, et al. (2013) makes clear that these are the same thing. Only one formula is given, and that formula is correctly represented by
nmi(). There is no second formula in the article that is the basis formoa_ratio(). The module should probably only have one function, but the two functions should produce the exact same, which they do not.I recommend that
moa_ratio()be removed. For now, it could be changed to merely callnmi()with a deprecation warning, and in the future it should be removed.If this is acceptable to implement, please assign to me.