Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maps with 8-bit unsigned integer data should probably not set norm to None #7259

Open
ayshih opened this issue Oct 25, 2023 · 0 comments
Open
Labels
Bug Probably a bug Effort Low Requires a small time investment map Affects the map submodule Package Intermediate Requires some knowledge of the internal structure of SunPy Priority Medium Non-urgent action required

Comments

@ayshih
Copy link
Member

ayshih commented Oct 25, 2023

There is very old code (from #1432) that sets the norm to None for maps with 8-bit unsigned integer data (uint8, i.e., 0 to 255):

sunpy/sunpy/map/mapbase.py

Lines 236 to 237 in 5bffcc2

if self.dtype == np.uint8:
norm = None

Presumably this is done because 8-bit unsigned integer data maps directly to the 8-bit color scale for matplotlib. However, this causes later code (written much later) to fail because it assumes that the norm keyword exists only if it is actually a normalizer, e.g., in plot():

sunpy/sunpy/map/mapbase.py

Lines 2529 to 2532 in 5bffcc2

if 'norm' in imshow_args:
norm = imshow_args['norm']
if 'vmin' in imshow_args:
if norm.vmin is not None:

So, possible solutions include:

  • Don't special-case the setting of norm for uint8 data (i.e., treat it the same as any other data type)
  • Don't set norm at all for uint8 data (i.e., norm will not be set in plot_settings)
  • Add special code in plot() specific to uint8 data

Choosing between the options depends on exactly how we would like uint8 data to be visualized.

@ayshih ayshih added Bug Probably a bug map Affects the map submodule Priority Medium Non-urgent action required Effort Low Requires a small time investment Package Intermediate Requires some knowledge of the internal structure of SunPy labels Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Probably a bug Effort Low Requires a small time investment map Affects the map submodule Package Intermediate Requires some knowledge of the internal structure of SunPy Priority Medium Non-urgent action required
Projects
None yet
Development

No branches or pull requests

1 participant