Skip to content

Commit

Permalink
Merge pull request #205 from MPoL-dev/cmap_norm_for_residual_images
Browse files Browse the repository at this point in the history
get_image_cmap_norm: option for residual images
  • Loading branch information
jeffjennings authored Nov 27, 2023
2 parents b13f752 + 94c57d9 commit 6c6fd68
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/mpol/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from mpol.utils import loglinspace, torch2npy, packed_cube_to_sky_cube

def get_image_cmap_norm(image, stretch='power', gamma=1.0, asinh_a=0.02):
def get_image_cmap_norm(image, stretch='power', gamma=1.0, asinh_a=0.02, symmetric=False):
"""
Get a colormap normalization to apply to an image.
Expand All @@ -20,15 +20,25 @@ def get_image_cmap_norm(image, stretch='power', gamma=1.0, asinh_a=0.02):
gamma=1.0 yields a linear colormap.
asinh_a : float, default = 0.02
Scale parameter for an asinh stretch.
symmetric : bool, default=False
Whether the colormap is symmetric about 0
"""
vmax = image.max()
if symmetric is True:
vmax = max(abs(image.min()), image.max())
vmin = -vmax

else:
vmax = image.max()

if stretch == 'power':
vmin = 0
elif stretch == 'asinh':
vmin = max(0, image.min())

if stretch == 'power':
vmin = 0
norm = mco.PowerNorm(gamma, vmin, vmax)

elif stretch == 'asinh':
vmin = max(0, image.min())
norm = simple_norm(image, stretch='asinh', asinh_a=asinh_a,
min_cut=vmin, max_cut=vmax)

Expand Down

0 comments on commit 6c6fd68

Please sign in to comment.