Skip to content

[ENH]: UnitizedNorm #27706

Open
Open
@story645

Description

@story645

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:

  • maps data to numbers using {Convertor}.convert
  • labels colorbar using the formatters from {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 to NoNorm

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 around Normalize objects so that the norms can take in unitized inputs, where UnitizedNorm(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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions