1
- import numpy as np
1
+ import warnings
2
+
2
3
from healpy import projaxes as PA
3
- import matplotlib .pyplot as plt
4
4
5
5
6
6
def get_gnomonic_projection (figure , hpx_map , ** kwargs ):
@@ -16,23 +16,23 @@ def get_gnomonic_projection(figure, hpx_map, **kwargs):
16
16
:return: the array containing the projection.
17
17
"""
18
18
19
- defaults = {'coord' : 'C' ,
20
- 'rot' : None ,
21
- 'format' : '%g' ,
22
- 'flip' : 'astro' ,
23
- 'xsize' : 200 ,
24
- 'ysize' : None ,
25
- 'reso' : 1.5 ,
26
- 'nest' : False ,
27
- 'min' : None ,
28
- 'max' : None ,
29
- 'cmap' : None ,
30
- 'norm' : None }
19
+ defaults = {
20
+ "coord" : "C" ,
21
+ "rot" : None ,
22
+ "format" : "%g" ,
23
+ "flip" : "astro" ,
24
+ "xsize" : 200 ,
25
+ "ysize" : None ,
26
+ "reso" : 1.5 ,
27
+ "nest" : False ,
28
+ "min" : None ,
29
+ "max" : None ,
30
+ "cmap" : None ,
31
+ "norm" : None ,
32
+ }
31
33
32
34
for key , default_value in list (defaults .items ()):
33
-
34
35
if key not in kwargs :
35
-
36
36
kwargs [key ] = default_value
37
37
38
38
## Colas, 2018-07-11: The following fails for really tall figures,
@@ -47,26 +47,35 @@ def get_gnomonic_projection(figure, hpx_map, **kwargs):
47
47
# extent[3] - margins[3] - margins[1])
48
48
extent = (0.05 , 0.05 , 0.9 , 0.9 )
49
49
50
- ax = PA .HpxGnomonicAxes (figure , extent ,
51
- coord = kwargs ['coord' ],
52
- rot = kwargs ['rot' ],
53
- format = kwargs ['format' ],
54
- flipconv = kwargs ['flip' ])
50
+ ax = PA .HpxGnomonicAxes (
51
+ figure ,
52
+ extent ,
53
+ coord = kwargs ["coord" ],
54
+ rot = kwargs ["rot" ],
55
+ format = kwargs ["format" ],
56
+ flipconv = kwargs ["flip" ],
57
+ )
55
58
56
59
# Suppress warnings about nans
57
- with np .warnings .catch_warnings ():
58
-
59
- np .warnings .filterwarnings ('ignore' )
60
+ # ! numpy does not contain the warnings module as of v1.24.3
61
+ # TODO: remove this when numpy is updated
62
+ # with np.warnings.catch_warnings():
63
+ #
64
+ # np.warnings.filterwarnings('ignore')
60
65
61
- img = ax .projmap (hpx_map ,
62
- nest = kwargs ['nest' ],
63
- coord = kwargs ['coord' ],
64
- vmin = kwargs ['min' ],
65
- vmax = kwargs ['max' ],
66
- xsize = kwargs ['xsize' ],
67
- ysize = kwargs ['ysize' ],
68
- reso = kwargs ['reso' ],
69
- cmap = kwargs ['cmap' ],
70
- norm = kwargs ['norm' ])
66
+ with warnings .catch_warnings ():
67
+ warnings .filterwarnings ("ignore" )
68
+ img = ax .projmap (
69
+ hpx_map ,
70
+ nest = kwargs ["nest" ],
71
+ coord = kwargs ["coord" ],
72
+ vmin = kwargs ["min" ],
73
+ vmax = kwargs ["max" ],
74
+ xsize = kwargs ["xsize" ],
75
+ ysize = kwargs ["ysize" ],
76
+ reso = kwargs ["reso" ],
77
+ cmap = kwargs ["cmap" ],
78
+ norm = kwargs ["norm" ],
79
+ )
71
80
72
81
return img
0 commit comments