plotastrodata 1.8.6__tar.gz → 1.8.7__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.6/plotastrodata.egg-info → plotastrodata-1.8.7}/PKG-INFO +1 -1
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/__init__.py +1 -1
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/plot_utils.py +106 -72
- {plotastrodata-1.8.6 → plotastrodata-1.8.7/plotastrodata.egg-info}/PKG-INFO +1 -1
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/LICENSE +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/MANIFEST.in +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/README.md +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/analysis_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/const_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/coord_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/ext_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/fft_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/fits_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/fitting_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/los_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/matrix_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/noise_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata/other_utils.py +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata.egg-info/SOURCES.txt +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata.egg-info/dependency_links.txt +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata.egg-info/not-zip-safe +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata.egg-info/requires.txt +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/plotastrodata.egg-info/top_level.txt +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/setup.cfg +0 -0
- {plotastrodata-1.8.6 → plotastrodata-1.8.7}/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.7
|
|
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
|
|
@@ -95,6 +95,68 @@ def logcbticks(vmin: float = -3.01, vmax: float = 3.01
|
|
|
95
95
|
return ticks, ticklabels
|
|
96
96
|
|
|
97
97
|
|
|
98
|
+
def pow10(x: np.ndarray, stretchpower: float, xmin: float
|
|
99
|
+
) -> np.ndarray:
|
|
100
|
+
"""A power-law function scaled by xmin. This function is used for the case of stretch='power' in PlotAstroData.add_color().
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
x (np.ndarray): Input in the linear scale.
|
|
104
|
+
stretchpower (float): Power-law index between 0 and 1. 0 means the linear scale, while 1 means the logarithmic scale.
|
|
105
|
+
stretchscale (float): The minimum value of x. xmin must be positive.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
np.ndarray: Output values.
|
|
109
|
+
"""
|
|
110
|
+
p = 1 - stretchpower
|
|
111
|
+
y = ((x / xmin)**p - 1) / p / np.log(10)
|
|
112
|
+
return y
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def ipow10(x: np.ndarray, stretchpower: float, xmin: float
|
|
116
|
+
) -> np.ndarray:
|
|
117
|
+
"""The inverse function of pow10. This function is used for the case of stretch='power' in PlotAstroData.add_color().
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
x (np.ndarray): Input values.
|
|
121
|
+
stretchpower (float): Power-law index between 0 and 1. 0 means the linear scale, while 1 means the logarithmic scale.
|
|
122
|
+
xmin (float): The minimum value of x. xmin must be positive.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
np.ndarray: Output values in the linear scale.
|
|
126
|
+
"""
|
|
127
|
+
p = 1 - stretchpower
|
|
128
|
+
y = xmin * (1 + p * np.log(10) * x)**(1 / p)
|
|
129
|
+
return y
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _func_stretch(x: list | np.ndarray,
|
|
133
|
+
stretch: str, stretchscale: float,
|
|
134
|
+
stretchpower: float, minlinear: float):
|
|
135
|
+
t = np.array(x)
|
|
136
|
+
match stretch:
|
|
137
|
+
case 'log':
|
|
138
|
+
t = np.log10(t)
|
|
139
|
+
case 'asinh':
|
|
140
|
+
t = np.arcsinh(t / stretchscale)
|
|
141
|
+
case 'power':
|
|
142
|
+
t = pow10(t, stretchpower, minlinear)
|
|
143
|
+
return t
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _ifunc_stretch(x: object,
|
|
147
|
+
stretch: str, stretchscale: float,
|
|
148
|
+
stretchpower: float, minlinear: float):
|
|
149
|
+
t = np.array(x)
|
|
150
|
+
match stretch:
|
|
151
|
+
case 'log':
|
|
152
|
+
t = 10**t
|
|
153
|
+
case 'asinh':
|
|
154
|
+
t = np.sinh(t) * stretchscale
|
|
155
|
+
case 'power':
|
|
156
|
+
t = ipow10(t, stretchpower, minlinear)
|
|
157
|
+
return t
|
|
158
|
+
|
|
159
|
+
|
|
98
160
|
@dataclass
|
|
99
161
|
class PlotAxes2D():
|
|
100
162
|
"""Use Axes.set_* to adjust x and y axes.
|
|
@@ -199,7 +261,7 @@ class PlotAxes2D():
|
|
|
199
261
|
|
|
200
262
|
|
|
201
263
|
def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
|
|
202
|
-
stretchpower: float,
|
|
264
|
+
stretchpower: float, sigma: float, kw: dict
|
|
203
265
|
) -> np.ndarray:
|
|
204
266
|
"""Set vmin and vmax for color pcolormesh and RGB maps.
|
|
205
267
|
|
|
@@ -208,7 +270,7 @@ def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
|
|
|
208
270
|
stretch (str): 'log', 'asinh', 'power'. Any other means linear.
|
|
209
271
|
stretchscale (float): For the arcsinh strech.
|
|
210
272
|
stretchpower (float): For the power strech.
|
|
211
|
-
|
|
273
|
+
sigma (float): Noise level.
|
|
212
274
|
kw (dict): Probably like {'vmin':0, 'vmax':1}.
|
|
213
275
|
|
|
214
276
|
Returns:
|
|
@@ -216,46 +278,38 @@ def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
|
|
|
216
278
|
"""
|
|
217
279
|
if type(stretch) is str:
|
|
218
280
|
data = [data]
|
|
219
|
-
|
|
281
|
+
sigma = [sigma]
|
|
220
282
|
stretch = [stretch]
|
|
221
283
|
stretchscale = [stretchscale]
|
|
284
|
+
stretchpower = [stretchpower]
|
|
222
285
|
if 'vmin' in kw:
|
|
223
286
|
kw['vmin'] = [kw['vmin']]
|
|
224
287
|
if 'vmax' in kw:
|
|
225
288
|
kw['vmax'] = [kw['vmax']]
|
|
226
|
-
|
|
227
|
-
for i, (c, st, stsc, r) in enumerate(zip(*z)):
|
|
228
|
-
if stsc is None:
|
|
229
|
-
stsc = r
|
|
230
|
-
if st == 'log':
|
|
231
|
-
if np.any(c > 0):
|
|
232
|
-
c = np.log10(c.clip(np.nanmin(c[c > 0]), None))
|
|
233
|
-
elif st == 'asinh':
|
|
234
|
-
c = np.arcsinh(c / stsc)
|
|
235
|
-
elif st == 'power':
|
|
236
|
-
cmin = kw['min'][i] if 'vmin' in kw else r
|
|
237
|
-
c = c.clip(cmin, None)
|
|
238
|
-
p = 1 - stretchpower
|
|
239
|
-
c = ((c / cmin)**p - 1) / p / np.log(10)
|
|
240
|
-
data[i] = c
|
|
289
|
+
|
|
241
290
|
n = len(data)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
291
|
+
if 'vmin' not in kw:
|
|
292
|
+
kw['vmin'] = [None] * n
|
|
293
|
+
if 'vmax' not in kw:
|
|
294
|
+
kw['vmax'] = [None] * n
|
|
295
|
+
stretch = np.where(np.equal(stretch, None), sigma, stretch)
|
|
296
|
+
minlinear = np.where(np.equal(kw['vmin'], None), sigma, kw['vmin'])
|
|
297
|
+
|
|
298
|
+
z = (stretch, stretchscale, stretchpower, minlinear)
|
|
299
|
+
for i, args in enumerate(zip(*z)):
|
|
300
|
+
st, _, _, ml = args
|
|
301
|
+
c = data[i]
|
|
302
|
+
if st in ['log', 'power']:
|
|
303
|
+
c = c.clip(ml, None)
|
|
304
|
+
c = _func_stretch(c, *args)
|
|
305
|
+
data[i] = c
|
|
306
|
+
cmin = np.nanmin(c)
|
|
307
|
+
cmax = np.nanmax(c)
|
|
308
|
+
for k in ['vmin', 'vmax']:
|
|
309
|
+
if kw[k][i] is None:
|
|
310
|
+
kw[k][i] = cmin if k == 'vmin' else cmax
|
|
311
|
+
else:
|
|
312
|
+
kw[k][i] = _func_stretch(kw[k][i], *args)
|
|
259
313
|
data = [c.clip(a, b) for c, a, b in zip(data, kw['vmin'], kw['vmax'])]
|
|
260
314
|
if n == 1:
|
|
261
315
|
data = data[0]
|
|
@@ -797,11 +851,11 @@ class PlotAstroData(AstroFrame):
|
|
|
797
851
|
print('No pixel size. Skip add_color.')
|
|
798
852
|
return
|
|
799
853
|
|
|
800
|
-
if
|
|
801
|
-
|
|
802
|
-
|
|
854
|
+
minlinear = _kw['vmin'] if 'vmin' in _kw else sigma
|
|
855
|
+
if cblabel is None:
|
|
856
|
+
cblabel = bunit
|
|
857
|
+
|
|
803
858
|
c = set_minmax(c, stretch, stretchscale, stretchpower, sigma, _kw)
|
|
804
|
-
cmin, cmax = np.nanmin(c), np.nanmax(c)
|
|
805
859
|
c = self.vskipfill(c, v)
|
|
806
860
|
if type(self.channelnumber) is int:
|
|
807
861
|
c = [c[self.channelnumber]]
|
|
@@ -813,8 +867,6 @@ class PlotAstroData(AstroFrame):
|
|
|
813
867
|
for ch in self.bottomleft:
|
|
814
868
|
if not show_cbar:
|
|
815
869
|
break
|
|
816
|
-
if cblabel is None:
|
|
817
|
-
cblabel = bunit
|
|
818
870
|
if self.fig is None:
|
|
819
871
|
fig = plt.figure(ch // self.rowcol)
|
|
820
872
|
else:
|
|
@@ -830,35 +882,20 @@ class PlotAstroData(AstroFrame):
|
|
|
830
882
|
cb.ax.tick_params(labelsize=14)
|
|
831
883
|
font = mpl.font_manager.FontProperties(size=16)
|
|
832
884
|
cb.ax.yaxis.label.set_font_properties(font)
|
|
885
|
+
args = [stretch, stretchscale, stretchpower, minlinear]
|
|
833
886
|
if cbticks is not None and ch // self.rowcol == 0:
|
|
834
|
-
cbticks =
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
cbticks = np.log10(cbticks)
|
|
838
|
-
case 'asinh':
|
|
839
|
-
cbticks = np.arcsinh(cbticks / stretchscale)
|
|
840
|
-
case 'power':
|
|
841
|
-
p = 1 - stretchpower
|
|
842
|
-
cbticks = (cbticks / cmin_org)**p - 1
|
|
843
|
-
cbticks = cbticks / p / np.log(10)
|
|
844
|
-
if stretch == 'log' and cbticks is None:
|
|
845
|
-
cbticks, cbticklabels = logcbticks(cmin, cmax)
|
|
887
|
+
cbticks = _func_stretch(cbticks, *args)
|
|
888
|
+
if cbticks is None and stretch == 'log':
|
|
889
|
+
cbticks, cbticklabels = logcbticks()
|
|
846
890
|
if cbticks is not None:
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
ticklin = 10**t
|
|
856
|
-
elif stretch == 'asinh':
|
|
857
|
-
ticklin = np.sinh(t) * stretchscale
|
|
858
|
-
elif stretch == 'power':
|
|
859
|
-
p = 1 - stretchpower
|
|
860
|
-
ticklin = cmin_org * (1 + p * np.log(10) * t)**(1 / p)
|
|
861
|
-
cb.set_ticklabels([f'{d:{cbformat[1:]}}' for d in ticklin])
|
|
891
|
+
cond = (_kw['vmin'] < cbticks) * (cbticks < _kw['vmax'])
|
|
892
|
+
cb.set_ticks(cbticks[cond])
|
|
893
|
+
if cbticklabels is not None:
|
|
894
|
+
tl = np.array(cbticklabels)[cond]
|
|
895
|
+
else:
|
|
896
|
+
t = _ifunc_stretch(cb.get_ticks(), *args)
|
|
897
|
+
tl = [f'{d:{cbformat[1:]}}' for d in t]
|
|
898
|
+
cb.set_ticklabels(tl)
|
|
862
899
|
self.add_beam(beam=beam, **beam_kwargs)
|
|
863
900
|
|
|
864
901
|
def add_contour(self,
|
|
@@ -950,7 +987,7 @@ class PlotAstroData(AstroFrame):
|
|
|
950
987
|
def add_rgb(self,
|
|
951
988
|
stretch: list[str, str, str] = ['linear'] * 3,
|
|
952
989
|
stretchscale: list[float | None, float | None, float | None] = [None] * 3,
|
|
953
|
-
stretchpower: float = 0,
|
|
990
|
+
stretchpower: list[float, float, float] = [0, 0, 0],
|
|
954
991
|
**kwargs) -> None:
|
|
955
992
|
"""Use PIL.Image and imshow of matplotlib. kwargs must include the arguments of AstroData to specify the data to be plotted. A three-element array ([red, green, blue]) is supposed for all arguments, except for xskip, yskip and show_beam, including vmax and vmin. kwargs may include arguments for add_beam() and a dict of beam_kwargs to specify the beam patch in more detail. kwargs may include xskiip and yskip.
|
|
956
993
|
|
|
@@ -968,9 +1005,6 @@ class PlotAstroData(AstroFrame):
|
|
|
968
1005
|
print('No pixel size. Skip add_rgb.')
|
|
969
1006
|
return
|
|
970
1007
|
|
|
971
|
-
for i in range(len(stretchscale)):
|
|
972
|
-
if stretchscale[i] is None:
|
|
973
|
-
stretchscale[i] = sigma[i]
|
|
974
1008
|
c = set_minmax(c, stretch, stretchscale, stretchpower, sigma, _kw)
|
|
975
1009
|
if not (np.shape(c[0]) == np.shape(c[1]) == np.shape(c[2])):
|
|
976
1010
|
print('RGB shapes mismatch. Skip add_rgb.')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.7
|
|
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
|