[ENH]: UnitizedNorm #27706
Labels
New feature
status: needs comment/discussion
needs consensus on next step
topic: color/color & colormaps
topic: units and array ducktypes
NOTE: This is very much in the discussion nobody should actually attempt it phase. Especially since #27721 is a probably better solution to the same meta problem.
Problem
Lots of requests for colormapping unitized data, such as #7383, #25062, #23991, #19476, #17447
Proposed solution
Since the number -> number that can be colormapped conversion is done in the norm, proposing that we make an explicit Norm for handling units:
UnitizedNorm
:Create a new norm object
UnitizedNorm
:{Convertor}.convert
{Convertor}.axisinfo
The hard work here is integrating this into the existing color-mapping pipeline, particularly the interpolation pipeline. One approach may be to add a flag indicating whether the unit can participate in existing schemes or whether it provides its own interpolation methods. If this works, then
.UnitizedNorm
can be shimmed in to act as an analogue toNoNorm
UnitizedNorm(Normalize)
I don't know if this is actually possible, or remotely worth the effort given @ksunden's work, but a follow on proposal is that
UnitizedNorm
acts as a wrapper aroundNormalize
objects so that the norms can take in unitized inputs, whereUnitizedNorm(NoNorm) == UnitizedNorm()
is the default described above. The objective would be to allow support for things like`UnitizedNorm(BoundaryNorm(['2011-01-01', '2011-02-01', '2011-03-01']))' or "UnitizedNorm(Normalize(vmin=Pint(10))"
Pretty sure that if this is possible, it ends up being some sorta dynamic monkeypatching of the existing class. But also if possible then it can be written as a decorator and that would be nice to have for custom Norms.
The text was updated successfully, but these errors were encountered: