Skip to content

Commit

Permalink
Merge pull request #89 from torresramiro350/master
Browse files Browse the repository at this point in the history
Numpy no longer includes warnings module as attribute  as of numpy v1.24.3
  • Loading branch information
xiaojieww authored Jun 7, 2023
2 parents 1c7c9b5 + bdd423b commit ce74038
Showing 1 changed file with 43 additions and 34 deletions.
77 changes: 43 additions & 34 deletions hawc_hal/healpix_handling/gnomonic_projection.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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,
Expand All @@ -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

0 comments on commit ce74038

Please sign in to comment.