plotastrodata 1.8.9__tar.gz → 1.8.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {plotastrodata-1.8.9/plotastrodata.egg-info → plotastrodata-1.8.11}/PKG-INFO +1 -1
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/__init__.py +1 -1
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/plot_utils.py +50 -83
- {plotastrodata-1.8.9 → plotastrodata-1.8.11/plotastrodata.egg-info}/PKG-INFO +1 -1
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/LICENSE +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/MANIFEST.in +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/README.md +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/analysis_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/const_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/coord_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/ext_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/fft_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/fits_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/fitting_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/los_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/matrix_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/noise_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata/other_utils.py +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata.egg-info/SOURCES.txt +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata.egg-info/dependency_links.txt +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata.egg-info/not-zip-safe +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata.egg-info/requires.txt +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/plotastrodata.egg-info/top_level.txt +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/setup.cfg +0 -0
- {plotastrodata-1.8.9 → plotastrodata-1.8.11}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.11
|
|
4
4
|
Summary: plotastrodata is a tool for astronomers to create figures from FITS files and perform fundamental data analyses with ease.
|
|
5
5
|
Home-page: https://github.com/yusukeaso-astron/plotastrodata
|
|
6
6
|
Download-URL: https://github.com/yusukeaso-astron/plotastrodata
|
|
@@ -65,20 +65,22 @@ def logticks(ticks: list[float], lim: list[float, float]
|
|
|
65
65
|
return newticks, newlabels
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
def logcbticks(vmin: float = -3
|
|
68
|
+
def logcbticks(vmin: float = 1e-3, vmax: float = 1e3
|
|
69
69
|
) -> tuple[np.ndarray, np.ndarray]:
|
|
70
70
|
"""Make nice ticks for a log color bar.
|
|
71
71
|
|
|
72
72
|
Args:
|
|
73
|
-
vmin (float, optional): Minimum value. Defaults to -3.
|
|
74
|
-
vmax (float, optional): Maximum value. Defaults to
|
|
73
|
+
vmin (float, optional): Minimum value. Defaults to 1e-3.
|
|
74
|
+
vmax (float, optional): Maximum value. Defaults to 1e3.
|
|
75
75
|
|
|
76
76
|
Returns:
|
|
77
77
|
tuple: (ticks, ticklabels).
|
|
78
78
|
"""
|
|
79
|
-
|
|
79
|
+
i0 = int(np.floor(np.log10(vmin)))
|
|
80
|
+
i1 = int(np.ceil(np.log10(vmax)))
|
|
81
|
+
ticks = np.outer(np.logspace(i0, i1, i1 - i0 + 1), np.arange(1, 10))
|
|
80
82
|
ticklabels = []
|
|
81
|
-
for i in range(
|
|
83
|
+
for i in range(i0, i1 + 1):
|
|
82
84
|
ii = np.abs(min(i, 0))
|
|
83
85
|
ii = f'{ii:d}'
|
|
84
86
|
for j in range(1, 10):
|
|
@@ -88,41 +90,10 @@ def logcbticks(vmin: float = -3.01, vmax: float = 3.01
|
|
|
88
90
|
else:
|
|
89
91
|
s = ''
|
|
90
92
|
ticklabels.append(s)
|
|
91
|
-
ticks = np.
|
|
93
|
+
ticks = np.ravel(ticks)
|
|
92
94
|
ticklabels = np.ravel(ticklabels)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return ticks, ticklabels
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def pow10(x: np.ndarray, stretchpower: float) -> np.ndarray:
|
|
99
|
-
"""A power-law function scaled by xmin. This function is used for the case of stretch='power' in PlotAstroData.add_color().
|
|
100
|
-
|
|
101
|
-
Args:
|
|
102
|
-
x (np.ndarray): Input in the linear scale.
|
|
103
|
-
stretchpower (float, optional): The output is (data**stretchpower - 1) / stretchpower / ln(10). 1 means the linear scale, while 0 means the logarithmic scale.
|
|
104
|
-
|
|
105
|
-
Returns:
|
|
106
|
-
np.ndarray: Output values.
|
|
107
|
-
"""
|
|
108
|
-
p = 1e-6 if stretchpower == 0 else stretchpower
|
|
109
|
-
y = (x**p - 1) / p / np.log(10)
|
|
110
|
-
return y
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def ipow10(x: np.ndarray, stretchpower: float) -> np.ndarray:
|
|
114
|
-
"""The inverse function of pow10. This function is used for the case of stretch='power' in PlotAstroData.add_color().
|
|
115
|
-
|
|
116
|
-
Args:
|
|
117
|
-
x (np.ndarray): Input values.
|
|
118
|
-
stretchpower (float, optional): The input is (data**stretchpower - 1) / stretchpower / ln(10). 1 means the linear scale, while 0 means the logarithmic scale.
|
|
119
|
-
|
|
120
|
-
Returns:
|
|
121
|
-
np.ndarray: Output values in the linear scale.
|
|
122
|
-
"""
|
|
123
|
-
p = 1e-6 if stretchpower == 0 else stretchpower
|
|
124
|
-
y = (1 + p * np.log(10) * x)**(1 / p)
|
|
125
|
-
return y
|
|
95
|
+
cond = (vmin <= ticks) * (ticks <= vmax)
|
|
96
|
+
return ticks[cond], ticklabels[cond]
|
|
126
97
|
|
|
127
98
|
|
|
128
99
|
def do_stretch(x: list | np.ndarray,
|
|
@@ -133,8 +104,8 @@ def do_stretch(x: list | np.ndarray,
|
|
|
133
104
|
Args:
|
|
134
105
|
x (list | np.ndarray): Input array in the linear scale.
|
|
135
106
|
stretch (str): 'log', 'asinh', 'power', or 'linear'. Any other means 'linear'. 'log' means the mapped data are logarithmic. 'asinh' means the mapped data are arc sin hyperbolic. 'power' means the mapped data are power-law (see also stretchpower). Defaults to 'linear'.
|
|
136
|
-
stretchscale (float
|
|
137
|
-
stretchpower (float
|
|
107
|
+
stretchscale (float): The output is asinh(data / stretchscale).
|
|
108
|
+
stretchpower (float): The output is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale.
|
|
138
109
|
|
|
139
110
|
Returns:
|
|
140
111
|
np.ndarray: Output stretched array.
|
|
@@ -142,11 +113,12 @@ def do_stretch(x: list | np.ndarray,
|
|
|
142
113
|
t = np.array(x)
|
|
143
114
|
match stretch:
|
|
144
115
|
case 'log':
|
|
145
|
-
t = np.log10(t)
|
|
116
|
+
t = np.log10(t) # To be consistent with logcbticks().
|
|
146
117
|
case 'asinh':
|
|
147
118
|
t = np.arcsinh(t / stretchscale)
|
|
148
119
|
case 'power':
|
|
149
|
-
|
|
120
|
+
p = 1e-6 if stretchpower == 0 else stretchpower
|
|
121
|
+
t = t**p / p
|
|
150
122
|
return t
|
|
151
123
|
|
|
152
124
|
|
|
@@ -158,8 +130,8 @@ def undo_stretch(x: list | np.ndarray,
|
|
|
158
130
|
Args:
|
|
159
131
|
x (list | np.ndarray): Input stretched array.
|
|
160
132
|
stretch (str): 'log', 'asinh', 'power', or 'linear'. Any other means 'linear'. 'log' means the mapped data are logarithmic. 'asinh' means the mapped data are arc sin hyperbolic. 'power' means the mapped data are power-law (see also stretchpower). Defaults to 'linear'.
|
|
161
|
-
stretchscale (float
|
|
162
|
-
stretchpower (float
|
|
133
|
+
stretchscale (float): The input is asinh(data / stretchscale).
|
|
134
|
+
stretchpower (float): The input is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale.
|
|
163
135
|
|
|
164
136
|
Returns:
|
|
165
137
|
np.ndarray: Output array in the linear scale.
|
|
@@ -167,11 +139,12 @@ def undo_stretch(x: list | np.ndarray,
|
|
|
167
139
|
t = np.array(x)
|
|
168
140
|
match stretch:
|
|
169
141
|
case 'log':
|
|
170
|
-
t = 10**t
|
|
142
|
+
t = 10**t # To be consistent with logcbticks().
|
|
171
143
|
case 'asinh':
|
|
172
144
|
t = np.sinh(t) * stretchscale
|
|
173
145
|
case 'power':
|
|
174
|
-
|
|
146
|
+
p = 1e-6 if stretchpower == 0 else stretchpower
|
|
147
|
+
t = (t * p)**(1 / p)
|
|
175
148
|
return t
|
|
176
149
|
|
|
177
150
|
|
|
@@ -285,9 +258,9 @@ def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
|
|
|
285
258
|
|
|
286
259
|
Args:
|
|
287
260
|
data (np.ndarray): Plotted data.
|
|
288
|
-
stretch (str): 'log', 'asinh', 'power'. Any other means linear.
|
|
289
|
-
stretchscale (float):
|
|
290
|
-
stretchpower (float):
|
|
261
|
+
stretch (str): 'log', 'asinh', 'power', or 'linear'. Any other means 'linear'. 'log' means the mapped data are logarithmic. 'asinh' means the mapped data are arc sin hyperbolic. 'power' means the mapped data are power-law (see also stretchpower). Defaults to 'linear'.
|
|
262
|
+
stretchscale (float): The input is asinh(data / stretchscale).
|
|
263
|
+
stretchpower (float): The input is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale.
|
|
291
264
|
sigma (float): Noise level.
|
|
292
265
|
kw (dict): Probably like {'vmin':0, 'vmax':1}.
|
|
293
266
|
|
|
@@ -346,8 +319,7 @@ def kwargs2AstroData(kw: dict) -> AstroData:
|
|
|
346
319
|
d = AstroData(data=np.zeros((2, 2)))
|
|
347
320
|
for k in vars(d):
|
|
348
321
|
if k in kw:
|
|
349
|
-
tmp[k] = kw
|
|
350
|
-
del kw[k]
|
|
322
|
+
tmp[k] = kw.pop(k)
|
|
351
323
|
if tmp == {}:
|
|
352
324
|
print('No argument given.')
|
|
353
325
|
return None
|
|
@@ -389,8 +361,7 @@ def kwargs2PlotAxes2D(kw: dict) -> PlotAxes2D:
|
|
|
389
361
|
d = PlotAxes2D()
|
|
390
362
|
for k in vars(d):
|
|
391
363
|
if k in kw:
|
|
392
|
-
tmp[k] = kw
|
|
393
|
-
del kw[k]
|
|
364
|
+
tmp[k] = kw.pop(k)
|
|
394
365
|
d = PlotAxes2D(**tmp)
|
|
395
366
|
return d
|
|
396
367
|
|
|
@@ -407,11 +378,8 @@ def kwargs2beamargs(kw: dict) -> dict:
|
|
|
407
378
|
tmp = {}
|
|
408
379
|
for k in ['show_beam', 'beamcolor', 'beampos']:
|
|
409
380
|
if k in kw:
|
|
410
|
-
tmp[k] = kw
|
|
411
|
-
|
|
412
|
-
if 'beam_kwargs' in kw:
|
|
413
|
-
tmp.update(kw['beam_kwargs'])
|
|
414
|
-
del kw['beam_kwargs']
|
|
381
|
+
tmp[k] = kw.pop(k)
|
|
382
|
+
tmp.update(kw.pop('beam_kwargs', {}))
|
|
415
383
|
return tmp
|
|
416
384
|
|
|
417
385
|
|
|
@@ -598,16 +566,8 @@ class PlotAstroData(AstroFrame):
|
|
|
598
566
|
"""
|
|
599
567
|
beam_kwargs = kwargs2beamargs(kw)
|
|
600
568
|
self._kw.update(kw)
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
del self._kw['xskip']
|
|
604
|
-
else:
|
|
605
|
-
xskip = 1
|
|
606
|
-
if 'yskip' in self._kw:
|
|
607
|
-
yskip = self._kw['yskip']
|
|
608
|
-
del self._kw['yskip']
|
|
609
|
-
else:
|
|
610
|
-
yskip = 1
|
|
569
|
+
xskip = self._kw.pop('xskip', 1)
|
|
570
|
+
yskip = self._kw.pop('yskip', 1)
|
|
611
571
|
d = kwargs2AstroData(self._kw)
|
|
612
572
|
self.read(d, xskip, yskip)
|
|
613
573
|
self.beam = d.beam
|
|
@@ -736,6 +696,11 @@ class PlotAstroData(AstroFrame):
|
|
|
736
696
|
"""
|
|
737
697
|
_kw = {'color': 'gray', 'fontsize': 15, 'ha': 'center',
|
|
738
698
|
'va': 'center', 'zorder': 10}
|
|
699
|
+
subkeys = {'ha': 'horizontalalignment',
|
|
700
|
+
'va': 'verticalalignment'}
|
|
701
|
+
for short, long in subkeys.items():
|
|
702
|
+
if long in kwargs:
|
|
703
|
+
kwargs[short] = kwargs.pop(long)
|
|
739
704
|
_kw.update(kwargs)
|
|
740
705
|
if include_chan is None:
|
|
741
706
|
include_chan = self.allchan
|
|
@@ -820,7 +785,7 @@ class PlotAstroData(AstroFrame):
|
|
|
820
785
|
linewidth (float, optional): Width of the bar. Defaults to 3.
|
|
821
786
|
"""
|
|
822
787
|
if length == 0:
|
|
823
|
-
print('
|
|
788
|
+
print('No length is given. Skip add_scalebar().')
|
|
824
789
|
return
|
|
825
790
|
if fontsize is None:
|
|
826
791
|
fontsize = 20 if len(self.ax) == 1 else 15
|
|
@@ -859,20 +824,21 @@ class PlotAstroData(AstroFrame):
|
|
|
859
824
|
font = mpl.font_manager.FontProperties(size=16)
|
|
860
825
|
cb.ax.yaxis.label.set_font_properties(font)
|
|
861
826
|
stretch_args = (stretch, stretchscale, stretchpower)
|
|
862
|
-
if cbticks is not None and ch // self.rowcol == 0:
|
|
863
|
-
cbticks = do_stretch(cbticks, *stretch_args)
|
|
864
827
|
if cbticks is None and stretch == 'log':
|
|
865
|
-
cbticks, cbticklabels = logcbticks()
|
|
866
|
-
if cbticks is None:
|
|
828
|
+
cbticks, cbticklabels = logcbticks(10**vmin, 10**vmax)
|
|
829
|
+
if cbticks is not None:
|
|
830
|
+
cbticks = do_stretch(cbticks, *stretch_args)
|
|
831
|
+
else:
|
|
867
832
|
cbticks = cb.get_ticks()
|
|
868
|
-
cond = (vmin
|
|
869
|
-
|
|
833
|
+
cond = (vmin <= cbticks) * (cbticks <= vmax)
|
|
834
|
+
cbticks = cbticks[cond]
|
|
835
|
+
cb.set_ticks(cbticks)
|
|
870
836
|
if cbticklabels is not None:
|
|
871
|
-
|
|
837
|
+
cbticklabels = np.array(cbticklabels)[cond]
|
|
872
838
|
else:
|
|
873
|
-
t = undo_stretch(
|
|
874
|
-
|
|
875
|
-
cb.set_ticklabels(
|
|
839
|
+
t = undo_stretch(cbticks, *stretch_args)
|
|
840
|
+
cbticklabels = [f'{d:{cbformat[1:]}}' for d in t]
|
|
841
|
+
cb.set_ticklabels(cbticklabels)
|
|
876
842
|
|
|
877
843
|
def add_color(self,
|
|
878
844
|
stretch: str = 'linear',
|
|
@@ -890,7 +856,7 @@ class PlotAstroData(AstroFrame):
|
|
|
890
856
|
Args:
|
|
891
857
|
stretch (str, optional): 'log', 'asinh', 'power', or 'linear'. Any other means 'linear'. 'log' means the mapped data are logarithmic. 'asinh' means the mapped data are arc sin hyperbolic. 'power' means the mapped data are power-law (see also stretchpower). Defaults to 'linear'.
|
|
892
858
|
stretchscale (float, optional): Color scale is asinh(data / stretchscale). Defaults to None.
|
|
893
|
-
stretchpower (float, optional): Color scale is
|
|
859
|
+
stretchpower (float, optional): Color scale is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale. Defaults to 0.5.
|
|
894
860
|
show_cbar (bool, optional): Show color bar. Defaults to True.
|
|
895
861
|
cblabel (str, optional): Colorbar label. Defaults to None.
|
|
896
862
|
cbformat (float, optional): Format for ticklabels of colorbar. Defaults to '%.1e'.
|
|
@@ -1023,7 +989,7 @@ class PlotAstroData(AstroFrame):
|
|
|
1023
989
|
Args:
|
|
1024
990
|
stretch (str, optional): 'log', 'asinh', 'power', or 'linear'. Any other means 'linear'. 'log' means the mapped data are logarithmic. 'asinh' means the mapped data are arc sin hyperbolic. 'power' means the mapped data are power-law (see also stretchpower). Defaults to 'linear'.
|
|
1025
991
|
stretchscale (float, optional): Color scale is asinh(data / stretchscale). Defaults to None.
|
|
1026
|
-
stretchpower (float, optional): Color scale is
|
|
992
|
+
stretchpower (float, optional): Color scale is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale. Defaults to 1.
|
|
1027
993
|
"""
|
|
1028
994
|
from PIL import Image
|
|
1029
995
|
|
|
@@ -1253,7 +1219,8 @@ class PlotAstroData(AstroFrame):
|
|
|
1253
1219
|
tuple: (fig, ax)
|
|
1254
1220
|
"""
|
|
1255
1221
|
if len(self.ax) > 1:
|
|
1256
|
-
print('get_figax is not supported
|
|
1222
|
+
print('PlotAstroData.get_figax() is not supported'
|
|
1223
|
+
+ ' with channel maps')
|
|
1257
1224
|
return
|
|
1258
1225
|
|
|
1259
1226
|
fig = plt.figure(0) if self.fig is None else self.fig
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.11
|
|
4
4
|
Summary: plotastrodata is a tool for astronomers to create figures from FITS files and perform fundamental data analyses with ease.
|
|
5
5
|
Home-page: https://github.com/yusukeaso-astron/plotastrodata
|
|
6
6
|
Download-URL: https://github.com/yusukeaso-astron/plotastrodata
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|