-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Throughout the codebase we often perform calculations using a value for the radius of a sphere. This can usually be assumed to be the Earth's because the relevant calculations concern the Earth's surface - but there may also be applications to extra-planetary atmospheres and oceans etc. so when referencing/naming the radius generally we should keep that wider scope in mind so as to not to possibly put off those wanting to do calculations for other planets.
During code review for #910 we decided to have a think about how best to handle the Earth radius default as a value that has a default to sensible precision (we use 6371229.0 meters generally), including as hard-coded at present as:
- in
mixin/fielddomain.pyas a float constant (potnetially not ideal as a float as technically that can vary very slightly by floating point precision, as a separate concern); - a
radiuskwarg value default forcf.relative_vorticity.
See thread in #910 (comment) for original discussion points.
Suggestion
I suggest that:
-
we add
earth_radius[_value]to theconstantsmodule as an integer value6371229and import there where necessary. The canonical units for it are already defined there:Line 18 in 8c760f8
"earth_radius": Units("m"), so it is nice to have it close to those as an additional benefit;
-
we change any
radiusreference to make sure it doesn't reference the 'Earth' in the name explicitly, but take our default Earth radius as default (the average user will be considering the Earth and surely in most cases not need to tweak the value from default precision); -
for any functions that use the default Earth radius, consult that constant - notably where there's a corresponding keyword argument
radiustake 'earth' as a string default to mean 'use the default earth value', as we presently do for many methods such asField.cell_area.