diff --git a/hawc_hal/healpix_handling/gnomonic_projection.py b/hawc_hal/healpix_handling/gnomonic_projection.py index c4a0fca..e2584f6 100644 --- a/hawc_hal/healpix_handling/gnomonic_projection.py +++ b/hawc_hal/healpix_handling/gnomonic_projection.py @@ -1,6 +1,6 @@ -import numpy as np +import warnings + from healpy import projaxes as PA -import matplotlib.pyplot as plt def get_gnomonic_projection(figure, hpx_map, **kwargs): @@ -16,23 +16,23 @@ def get_gnomonic_projection(figure, hpx_map, **kwargs): :return: the array containing the projection. """ - defaults = {'coord': 'C', - 'rot': None, - 'format': '%g', - 'flip': 'astro', - 'xsize': 200, - 'ysize': None, - 'reso': 1.5, - 'nest': False, - 'min': None, - 'max': None, - 'cmap': None, - 'norm': None} + defaults = { + "coord": "C", + "rot": None, + "format": "%g", + "flip": "astro", + "xsize": 200, + "ysize": None, + "reso": 1.5, + "nest": False, + "min": None, + "max": None, + "cmap": None, + "norm": None, + } for key, default_value in list(defaults.items()): - if key not in kwargs: - kwargs[key] = default_value ## Colas, 2018-07-11: The following fails for really tall figures, @@ -47,26 +47,35 @@ def get_gnomonic_projection(figure, hpx_map, **kwargs): # extent[3] - margins[3] - margins[1]) extent = (0.05, 0.05, 0.9, 0.9) - ax = PA.HpxGnomonicAxes(figure, extent, - coord=kwargs['coord'], - rot=kwargs['rot'], - format=kwargs['format'], - flipconv=kwargs['flip']) + ax = PA.HpxGnomonicAxes( + figure, + extent, + coord=kwargs["coord"], + rot=kwargs["rot"], + format=kwargs["format"], + flipconv=kwargs["flip"], + ) # Suppress warnings about nans - with np.warnings.catch_warnings(): - - np.warnings.filterwarnings('ignore') + # ! numpy does not contain the warnings module as of v1.24.3 + # TODO: remove this when numpy is updated + # with np.warnings.catch_warnings(): + # + # np.warnings.filterwarnings('ignore') - img = ax.projmap(hpx_map, - nest=kwargs['nest'], - coord=kwargs['coord'], - vmin=kwargs['min'], - vmax=kwargs['max'], - xsize=kwargs['xsize'], - ysize=kwargs['ysize'], - reso=kwargs['reso'], - cmap=kwargs['cmap'], - norm=kwargs['norm']) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + img = ax.projmap( + hpx_map, + nest=kwargs["nest"], + coord=kwargs["coord"], + vmin=kwargs["min"], + vmax=kwargs["max"], + xsize=kwargs["xsize"], + ysize=kwargs["ysize"], + reso=kwargs["reso"], + cmap=kwargs["cmap"], + norm=kwargs["norm"], + ) return img