plotastrodata 1.5.1__tar.gz → 1.6.1__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.5.1 → plotastrodata-1.6.1}/PKG-INFO +1 -1
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/__init__.py +1 -1
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/analysis_utils.py +15 -9
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/other_utils.py +2 -2
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/plot_utils.py +105 -70
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata.egg-info/PKG-INFO +1 -1
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/LICENSE +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/README.md +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/const_utils.py +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/coord_utils.py +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/ext_utils.py +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/fft_utils.py +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/fits_utils.py +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/fitting_utils.py +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/los_utils.py +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata/matrix_utils.py +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata.egg-info/SOURCES.txt +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata.egg-info/dependency_links.txt +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata.egg-info/not-zip-safe +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata.egg-info/requires.txt +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/plotastrodata.egg-info/top_level.txt +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/setup.cfg +0 -0
- {plotastrodata-1.5.1 → plotastrodata-1.6.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.1
|
|
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
|
|
@@ -68,7 +68,7 @@ def filled2d(data: np.ndarray, x: np.ndarray, y: np.ndarray, n: int = 1,
|
|
|
68
68
|
return d, xnew, ynew
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
def
|
|
71
|
+
def _need_multipixels(method):
|
|
72
72
|
def wrapper(self, *args, **kwargs):
|
|
73
73
|
singlepixel = self.dx is None or self.dy is None
|
|
74
74
|
if singlepixel:
|
|
@@ -153,9 +153,14 @@ class AstroData():
|
|
|
153
153
|
print(f'width was changed to [{ws}].')
|
|
154
154
|
newsize = size // w
|
|
155
155
|
grid = [None, self.v, self.y, self.x]
|
|
156
|
-
|
|
156
|
+
dgrid = [None, self.dv, self.dy, self.dx]
|
|
157
|
+
for n in range(1, 4):
|
|
157
158
|
if w[n] == 1 or grid[n] is None:
|
|
158
159
|
continue
|
|
160
|
+
if dgrid[n] is None:
|
|
161
|
+
s = ['v', 'y', 'x'][n - 1]
|
|
162
|
+
print(f'Skip binning in the {s}-axis because d{s} is None.')
|
|
163
|
+
continue
|
|
159
164
|
size[n] = newsize[n]
|
|
160
165
|
olddata = np.moveaxis(d, n, 0)
|
|
161
166
|
newdata = np.moveaxis(np.zeros(size), n, 0)
|
|
@@ -166,9 +171,11 @@ class AstroData():
|
|
|
166
171
|
t += grid[n][i:i_stop:i_step]
|
|
167
172
|
newdata += olddata[i:i_stop:i_step]
|
|
168
173
|
grid[n] = t / w[n]
|
|
174
|
+
dgrid[n] = dgrid[n] * w[n]
|
|
169
175
|
d = np.moveaxis(newdata, 0, n) / w[n]
|
|
170
176
|
self.data = np.squeeze(d)
|
|
171
177
|
_, self.v, self.y, self.x = grid
|
|
178
|
+
_, self.dv, self.dy, self.dx = dgrid
|
|
172
179
|
|
|
173
180
|
def centering(self, includexy: bool = True, includev: bool = False,
|
|
174
181
|
**kwargs):
|
|
@@ -206,7 +213,7 @@ class AstroData():
|
|
|
206
213
|
else:
|
|
207
214
|
print('No change because includexy=False and includev=False.')
|
|
208
215
|
|
|
209
|
-
@
|
|
216
|
+
@_need_multipixels
|
|
210
217
|
def circularbeam(self):
|
|
211
218
|
"""Make the beam circular by convolving with 1D Gaussian
|
|
212
219
|
"""
|
|
@@ -259,7 +266,7 @@ class AstroData():
|
|
|
259
266
|
bmin_new = 1 / np.sqrt(alpha + Det)
|
|
260
267
|
self.beam = np.array([bmaj_new, bmin_new, bpa_new])
|
|
261
268
|
|
|
262
|
-
@
|
|
269
|
+
@_need_multipixels
|
|
263
270
|
def fit2d(self, model: object, bounds: np.ndarray,
|
|
264
271
|
progressbar: bool = False,
|
|
265
272
|
kwargs_fit: dict = {}, kwargs_plotcorner: dict = {},
|
|
@@ -307,7 +314,7 @@ class AstroData():
|
|
|
307
314
|
return {'popt': popt, 'plow': plow, 'pmid': pmid, 'phigh': phigh,
|
|
308
315
|
'model': modelopt, 'residual': residual}
|
|
309
316
|
|
|
310
|
-
@
|
|
317
|
+
@_need_multipixels
|
|
311
318
|
def gaussfit2d(self, chan: int | None = None):
|
|
312
319
|
"""Fit a 2D Gaussian function to self.data.
|
|
313
320
|
|
|
@@ -495,7 +502,7 @@ class AstroData():
|
|
|
495
502
|
'sigma': self.sigma, 'center': self.center, 'pv': self.pv}
|
|
496
503
|
return d
|
|
497
504
|
|
|
498
|
-
@
|
|
505
|
+
@_need_multipixels
|
|
499
506
|
def writetofits(self, fitsimage: str = 'out.fits', header: dict = {}):
|
|
500
507
|
"""Write out the AstroData to a FITS file.
|
|
501
508
|
|
|
@@ -629,9 +636,8 @@ class AstroFrame():
|
|
|
629
636
|
Returns:
|
|
630
637
|
np.ndarray: absolute coordinates.
|
|
631
638
|
"""
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
and type(poslist[0]) is not str):
|
|
639
|
+
onexy = np.shape(poslist) == (2,) and type(poslist[0]) is not str
|
|
640
|
+
if np.shape(poslist) == () or onexy:
|
|
635
641
|
poslist = [poslist]
|
|
636
642
|
x, y = [None] * len(poslist), [None] * len(poslist)
|
|
637
643
|
for i, p in enumerate(poslist):
|
|
@@ -12,10 +12,10 @@ def listing(*args) -> list:
|
|
|
12
12
|
Returns:
|
|
13
13
|
list: With a single non-list input, the output is a list like ['a'], rather than [['a']].
|
|
14
14
|
"""
|
|
15
|
-
|
|
15
|
+
strnum = [str, float, int, np.float64, np.int64, np.float32, np.int32]
|
|
16
16
|
b = [None] * len(args)
|
|
17
17
|
for i, a in enumerate(args):
|
|
18
|
-
b[i] = [a] if type(a) in
|
|
18
|
+
b[i] = [a] if type(a) in strnum else a
|
|
19
19
|
if len(args) == 1:
|
|
20
20
|
b = b[0]
|
|
21
21
|
return b
|
|
@@ -203,8 +203,8 @@ def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
|
|
|
203
203
|
elif st == 'power':
|
|
204
204
|
cmin = kw['min'][i] if 'vmin' in kw else r
|
|
205
205
|
c = c.clip(cmin, None)
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
p = 1 - stretchpower
|
|
207
|
+
c = ((c / cmin)**p - 1) / p / np.log(10)
|
|
208
208
|
data[i] = c
|
|
209
209
|
n = len(data)
|
|
210
210
|
for m in ['vmin', 'vmax']:
|
|
@@ -215,13 +215,12 @@ def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
|
|
|
215
215
|
elif st == 'asinh':
|
|
216
216
|
kw[m][i] = np.arcsinh(kw[m][i] / stsc)
|
|
217
217
|
elif st == 'power':
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
p = 1 - stretchpower
|
|
219
|
+
kw[m][i] = ((kw[m][i]/c.min())**p - 1) / p / np.log(10)
|
|
220
220
|
else:
|
|
221
221
|
kw[m] = [None] * n
|
|
222
222
|
for i, (c, st, _, r) in enumerate(zip(*z)):
|
|
223
223
|
if m == 'vmin':
|
|
224
|
-
|
|
225
224
|
kw[m][i] = np.log10(r) if st == 'log' else np.nanmin(c)
|
|
226
225
|
else:
|
|
227
226
|
kw[m][i] = np.nanmax(c)
|
|
@@ -344,7 +343,8 @@ class PlotAstroData(AstroFrame):
|
|
|
344
343
|
fig (optional): External plt.figure(). Defaults to None.
|
|
345
344
|
ax (optional): External fig.add_subplot(). Defaults to None.
|
|
346
345
|
"""
|
|
347
|
-
def __init__(self,
|
|
346
|
+
def __init__(self,
|
|
347
|
+
v: np.ndarray = np.array([0]), vskip: int = 1,
|
|
348
348
|
veldigit: int = 2, restfreq: float | None = None,
|
|
349
349
|
channelnumber: int | None = None,
|
|
350
350
|
nrows: int = 4, ncols: int = 6,
|
|
@@ -458,6 +458,37 @@ class PlotAstroData(AstroFrame):
|
|
|
458
458
|
return np.concatenate((d, dnan), axis=0)
|
|
459
459
|
self.vskipfill = vskipfill
|
|
460
460
|
|
|
461
|
+
def _map_init(self, kw: dict) -> tuple:
|
|
462
|
+
"""
|
|
463
|
+
Common process for add_color, add_contour, add_segment, and add_rgb.
|
|
464
|
+
xskip and yskip (int) mean spatial pixel skips, which defaults to 1.
|
|
465
|
+
|
|
466
|
+
Args:
|
|
467
|
+
kw (dict): kwargs input for each method.
|
|
468
|
+
|
|
469
|
+
Returns:
|
|
470
|
+
tuple: Data and parameters used in each method.
|
|
471
|
+
"""
|
|
472
|
+
beam_kwargs = kwargs2beamargs(kw)
|
|
473
|
+
self._kw.update(kw)
|
|
474
|
+
if 'xskip' in self._kw:
|
|
475
|
+
xskip = self._kw['xskip']
|
|
476
|
+
del self._kw['xskip']
|
|
477
|
+
else:
|
|
478
|
+
xskip = 1
|
|
479
|
+
if 'yskip' in self._kw:
|
|
480
|
+
yskip = self._kw['yskip']
|
|
481
|
+
del self._kw['yskip']
|
|
482
|
+
else:
|
|
483
|
+
yskip = 1
|
|
484
|
+
d = kwargs2AstroData(self._kw)
|
|
485
|
+
self.read(d, xskip, yskip)
|
|
486
|
+
self.beam = d.beam
|
|
487
|
+
self.sigma = d.sigma
|
|
488
|
+
singlepix = d.dx is None or d.dy is None
|
|
489
|
+
return (d.data, d.x, d.y, d.v, d.beam, d.sigma, d.bunit,
|
|
490
|
+
self._kw, beam_kwargs, singlepix)
|
|
491
|
+
|
|
461
492
|
def add_region(self, patch: str = 'ellipse',
|
|
462
493
|
poslist: list[str | list[float, float]] = [],
|
|
463
494
|
majlist: list[float] = [], minlist: list[float] = [],
|
|
@@ -482,8 +513,9 @@ class PlotAstroData(AstroFrame):
|
|
|
482
513
|
if patch not in ['rectangle', 'ellipse']:
|
|
483
514
|
print('Only patch=\'rectangle\' or \'ellipse\' supported. ')
|
|
484
515
|
return
|
|
485
|
-
|
|
486
|
-
|
|
516
|
+
|
|
517
|
+
z = listing(*self.pos2xy(poslist), minlist, majlist, palist)
|
|
518
|
+
for x, y, width, height, angle in zip(*z):
|
|
487
519
|
for ch, axnow in enumerate(self.ax):
|
|
488
520
|
if type(self.channelnumber) is int:
|
|
489
521
|
ch = self.channelnumber
|
|
@@ -518,12 +550,15 @@ class PlotAstroData(AstroFrame):
|
|
|
518
550
|
"""
|
|
519
551
|
if not show_beam:
|
|
520
552
|
return
|
|
521
|
-
|
|
553
|
+
|
|
554
|
+
animation = self.channelnumber is not None
|
|
555
|
+
include_chan = self.allchan if animation else self.bottomleft
|
|
522
556
|
patch = 'rectangle' if self.pv else 'ellipse'
|
|
523
557
|
blist = [beam] if np.ndim(beam) == 1 else beam
|
|
524
558
|
n = len(blist)
|
|
525
559
|
bclist = beamcolor if type(beamcolor) is list else [beamcolor] * n
|
|
526
|
-
|
|
560
|
+
islist = beampos == [None] * 3 or np.ndim(beampos) == 2
|
|
561
|
+
bplist = beampos if islist else [beampos] * n
|
|
527
562
|
for (bmaj, bmin, bpa), bc, bp in zip(blist, bclist, bplist):
|
|
528
563
|
if None in [bmaj, bmin, bpa]:
|
|
529
564
|
print('No beam to plot.')
|
|
@@ -582,7 +617,8 @@ class PlotAstroData(AstroFrame):
|
|
|
582
617
|
ch = self.channelnumber
|
|
583
618
|
if ch not in include_chan:
|
|
584
619
|
continue
|
|
585
|
-
|
|
620
|
+
z = listing(*self.pos2xy(poslist), slist)
|
|
621
|
+
for x, y, s in zip(*z):
|
|
586
622
|
axnow.text(x=x, y=y, s=s, **_kw)
|
|
587
623
|
|
|
588
624
|
def add_line(self, poslist: list[str | list[float, float]] = [],
|
|
@@ -608,7 +644,8 @@ class PlotAstroData(AstroFrame):
|
|
|
608
644
|
if ch not in include_chan:
|
|
609
645
|
continue
|
|
610
646
|
alist = np.radians(anglelist)
|
|
611
|
-
|
|
647
|
+
z = listing(*self.pos2xy(poslist), alist, rlist)
|
|
648
|
+
for x, y, a, r in zip(*z):
|
|
612
649
|
axnow.plot([x, x + r * np.sin(a)],
|
|
613
650
|
[y, y + r * np.cos(a)], **_kw)
|
|
614
651
|
|
|
@@ -635,7 +672,8 @@ class PlotAstroData(AstroFrame):
|
|
|
635
672
|
if ch not in include_chan:
|
|
636
673
|
continue
|
|
637
674
|
alist = np.radians(anglelist)
|
|
638
|
-
|
|
675
|
+
z = listing(*self.pos2xy(poslist), alist, rlist)
|
|
676
|
+
for x, y, a, r in zip(*z):
|
|
639
677
|
axnow.quiver(x, y, r * np.sin(a), r * np.cos(a),
|
|
640
678
|
angles='xy', scale_units='xy', scale=1,
|
|
641
679
|
**_kw)
|
|
@@ -669,18 +707,20 @@ class PlotAstroData(AstroFrame):
|
|
|
669
707
|
axnow.plot([x[0] - length/2., x[0] + length/2.], [y[0], y[0]],
|
|
670
708
|
'-', linewidth=linewidth, color=color)
|
|
671
709
|
|
|
672
|
-
def add_color(self,
|
|
710
|
+
def add_color(self,
|
|
673
711
|
stretch: str = 'linear',
|
|
674
712
|
stretchscale: float | None = None,
|
|
675
713
|
stretchpower: float = 0,
|
|
676
|
-
show_cbar: bool = True,
|
|
677
|
-
|
|
678
|
-
|
|
714
|
+
show_cbar: bool = True,
|
|
715
|
+
cblabel: str | None = None,
|
|
716
|
+
cbformat: float = '%.1e',
|
|
717
|
+
cbticks: list[float] | None = None,
|
|
718
|
+
cbticklabels: list[str] | None = None,
|
|
719
|
+
cblocation: str = 'right',
|
|
679
720
|
**kwargs) -> None:
|
|
680
|
-
"""Use Axes.pcolormesh of matplotlib. kwargs must include the arguments of AstroData to specify the data to be plotted. kwargs may include arguments for add_beam() and a dict of beam_kwargs to specify the beam patch in more detail.
|
|
721
|
+
"""Use Axes.pcolormesh of matplotlib. kwargs must include the arguments of AstroData to specify the data to be plotted. 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.
|
|
681
722
|
|
|
682
723
|
Args:
|
|
683
|
-
xskip, yskip (int, optional): Spatial pixel skip. Defaults to 1.
|
|
684
724
|
stretch (str, optional): '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'.
|
|
685
725
|
stretchscale (float, optional): color scale is asinh(data / stretchscale). Defaults to None.
|
|
686
726
|
stretchpower (float, optional): color scale is ((data / vmin)**(1 - stretchpower) - 1) / (1 - stretchpower) / ln(10). 0 means the linear scale. 1 means the logarithmic scale. Defaults to 0.
|
|
@@ -691,16 +731,14 @@ class PlotAstroData(AstroFrame):
|
|
|
691
731
|
cbticklabels (list, optional): Ticklabels of colorbar. Defaults to None.
|
|
692
732
|
cblocation (str, optional): 'left', 'top', 'left', 'right'. Only for 2D images. Defaults to 'right'.
|
|
693
733
|
"""
|
|
694
|
-
_kw = {'cmap': 'cubehelix', 'alpha': 1,
|
|
695
|
-
|
|
696
|
-
beam_kwargs
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
self.beam = beam
|
|
703
|
-
self.sigma = sigma
|
|
734
|
+
self._kw = {'cmap': 'cubehelix', 'alpha': 1,
|
|
735
|
+
'edgecolors': 'none', 'zorder': 1}
|
|
736
|
+
c, x, y, v, beam, sigma, bunit, _kw, beam_kwargs, singlepix \
|
|
737
|
+
= self._map_init(kwargs)
|
|
738
|
+
if singlepix:
|
|
739
|
+
print('No pixel size. Skip add_color.')
|
|
740
|
+
return
|
|
741
|
+
|
|
704
742
|
if stretchscale is None:
|
|
705
743
|
stretchscale = sigma
|
|
706
744
|
cmin_org = _kw['vmin'] if 'vmin' in _kw else sigma
|
|
@@ -735,8 +773,9 @@ class PlotAstroData(AstroFrame):
|
|
|
735
773
|
elif stretch == 'asinh':
|
|
736
774
|
cbticks = np.arcsinh(np.array(cbticks) / stretchscale)
|
|
737
775
|
elif stretch == 'power':
|
|
738
|
-
cbticks =
|
|
739
|
-
|
|
776
|
+
cbticks = np.array(cbticks)
|
|
777
|
+
p = 1 - stretchpower
|
|
778
|
+
cbticks = ((cbticks / cmin_org)**p - 1) / p / np.log(10)
|
|
740
779
|
cb.set_ticks(cbticks)
|
|
741
780
|
if cbticklabels is not None:
|
|
742
781
|
cb.set_ticklabels(cbticklabels)
|
|
@@ -749,28 +788,26 @@ class PlotAstroData(AstroFrame):
|
|
|
749
788
|
elif stretch == 'asinh':
|
|
750
789
|
ticklin = np.sinh(t) * stretchscale
|
|
751
790
|
elif stretch == 'power':
|
|
752
|
-
|
|
753
|
-
ticklin = cmin_org *
|
|
791
|
+
p = 1 - stretchpower
|
|
792
|
+
ticklin = cmin_org * (1 + p * np.log(10) * t)**(1 / p)
|
|
754
793
|
cb.set_ticklabels([f'{d:{cbformat[1:]}}' for d in ticklin])
|
|
755
794
|
self.add_beam(beam=beam, **beam_kwargs)
|
|
756
795
|
|
|
757
|
-
def add_contour(self,
|
|
796
|
+
def add_contour(self,
|
|
758
797
|
levels: list[float] = [-12, -6, -3, 3, 6, 12, 24, 48, 96, 192, 384],
|
|
759
798
|
**kwargs) -> None:
|
|
760
|
-
"""Use Axes.contour of matplotlib. kwargs must include the arguments of AstroData to specify the data to be plotted. kwargs may include arguments for add_beam() and a dict of beam_kwargs to specify the beam patch in more detail.
|
|
799
|
+
"""Use Axes.contour of matplotlib. kwargs must include the arguments of AstroData to specify the data to be plotted. 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.
|
|
761
800
|
|
|
762
801
|
Args:
|
|
763
|
-
xskip, yskip (int, optional): Spatial pixel skip. Defaults to 1.
|
|
764
802
|
levels (list, optional): Contour levels in the unit of sigma. Defaults to [-12,-6,-3,3,6,12,24,48,96,192,384].
|
|
765
803
|
"""
|
|
766
|
-
_kw = {'colors': 'gray', 'linewidths': 1.0, 'zorder': 2}
|
|
767
|
-
beam_kwargs
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
self.sigma = sigma
|
|
804
|
+
self._kw = {'colors': 'gray', 'linewidths': 1.0, 'zorder': 2}
|
|
805
|
+
c, x, y, v, beam, sigma, _, _kw, beam_kwargs, singlepix \
|
|
806
|
+
= self._map_init(kwargs)
|
|
807
|
+
if singlepix:
|
|
808
|
+
print('No pixel size. Skip add_contour.')
|
|
809
|
+
return
|
|
810
|
+
|
|
774
811
|
c = self.vskipfill(c, v)
|
|
775
812
|
if type(self.channelnumber) is int:
|
|
776
813
|
c = [c[self.channelnumber]]
|
|
@@ -778,9 +815,9 @@ class PlotAstroData(AstroFrame):
|
|
|
778
815
|
axnow.contour(x, y, cnow, np.sort(levels) * sigma, **_kw)
|
|
779
816
|
self.add_beam(beam=beam, **beam_kwargs)
|
|
780
817
|
|
|
781
|
-
def add_segment(self,
|
|
818
|
+
def add_segment(self,
|
|
819
|
+
ampfits: str = None, angfits: str = None,
|
|
782
820
|
Ufits: str = None, Qfits: str = None,
|
|
783
|
-
xskip: int = 1, yskip: int = 1,
|
|
784
821
|
amp: list[np.ndarray] | None = None,
|
|
785
822
|
ang: list[np.ndarray] | None = None,
|
|
786
823
|
stU: list[np.ndarray] | None = None,
|
|
@@ -789,14 +826,13 @@ class PlotAstroData(AstroFrame):
|
|
|
789
826
|
rotation: float = 0.,
|
|
790
827
|
cutoff: float = 3.,
|
|
791
828
|
**kwargs) -> None:
|
|
792
|
-
"""Use Axes.quiver of matplotlib. kwargs must include the arguments of AstroData to specify the data to be plotted. fitsimage = [ampfits, angfits, Ufits, Qfits]. data = [amp, ang, stU, stQ]. kwargs may include arguments for add_beam() and a dict of beam_kwargs to specify the beam patch in more detail.
|
|
829
|
+
"""Use Axes.quiver of matplotlib. kwargs must include the arguments of AstroData to specify the data to be plotted. fitsimage = [ampfits, angfits, Ufits, Qfits]. data = [amp, ang, stU, stQ]. 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.
|
|
793
830
|
|
|
794
831
|
Args:
|
|
795
832
|
ampfits (str, optional): In put fits name. Length of segment. Defaults to None.
|
|
796
833
|
angfits (str, optional): In put fits name. North to east. Defaults to None.
|
|
797
834
|
Ufits (str, optional): In put fits name. Stokes U. Defaults to None.
|
|
798
835
|
Qfits (str, optional): In put fits name. Stokes Q. Defaults to None.
|
|
799
|
-
xskip, yskip (int, optional): Spatial pixel skip. Defaults to 1.
|
|
800
836
|
amp (list, optional): Length of segment. Defaults to None.
|
|
801
837
|
ang (list, optional): North to east. Defaults to None.
|
|
802
838
|
stU (list, optional): Stokes U. Defaults to None.
|
|
@@ -806,16 +842,17 @@ class PlotAstroData(AstroFrame):
|
|
|
806
842
|
rotation (float, optional): Segment angle is ang + rotation. Defaults to 0..
|
|
807
843
|
cutoff (float, optional): Used when amp and ang are calculated from Stokes U and Q. In the unit of sigma. Defaults to 3..
|
|
808
844
|
"""
|
|
809
|
-
_kw = {'angles': 'xy', 'scale_units': 'xy', 'color': 'gray',
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
845
|
+
self._kw = {'angles': 'xy', 'scale_units': 'xy', 'color': 'gray',
|
|
846
|
+
'pivot': 'mid', 'headwidth': 0, 'headlength': 0,
|
|
847
|
+
'headaxislength': 0, 'width': 0.007, 'zorder': 3,
|
|
848
|
+
'fitsimage': [ampfits, angfits, Ufits, Qfits],
|
|
849
|
+
'data': [amp, ang, stU, stQ]}
|
|
850
|
+
c, x, y, v, beam, sigma, _, _kw, beam_kwargs, singlepix \
|
|
851
|
+
= self._map_init(kwargs)
|
|
852
|
+
if singlepix:
|
|
853
|
+
print('No pixel size. Skip add_segment.')
|
|
854
|
+
return
|
|
855
|
+
|
|
819
856
|
amp, ang, stU, stQ = c
|
|
820
857
|
sigmaU, sigmaQ = sigma[2:]
|
|
821
858
|
beam = [beam[i] for i in range(4) if beam[i][0] is not None][0]
|
|
@@ -837,34 +874,32 @@ class PlotAstroData(AstroFrame):
|
|
|
837
874
|
if type(self.channelnumber) is int:
|
|
838
875
|
U = [U[self.channelnumber]]
|
|
839
876
|
V = [V[self.channelnumber]]
|
|
840
|
-
_kw['scale'] = 1
|
|
877
|
+
_kw['scale'] = 1. / np.abs(x[1] - x[0])
|
|
841
878
|
for axnow, unow, vnow in zip(self.ax, U, V):
|
|
842
879
|
axnow.quiver(x, y, unow, vnow, **_kw)
|
|
843
880
|
self.add_beam(beam=beam, **beam_kwargs)
|
|
844
881
|
|
|
845
|
-
def add_rgb(self,
|
|
882
|
+
def add_rgb(self,
|
|
846
883
|
stretch: list[str, str, str] = ['linear'] * 3,
|
|
847
884
|
stretchscale: list[float | None, float | None, float | None] = [None] * 3,
|
|
848
885
|
stretchpower: float = 0,
|
|
849
886
|
**kwargs) -> None:
|
|
850
|
-
"""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.
|
|
887
|
+
"""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.
|
|
851
888
|
|
|
852
889
|
Args:
|
|
853
|
-
xskip, yskip (int, optional): Spatial pixel skip. Defaults to 1.
|
|
854
890
|
stretch (str, optional): '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'.
|
|
855
891
|
stretchscale (float, optional): color scale is asinh(data / stretchscale). Defaults to None.
|
|
856
892
|
stretchpower (float, optional): color scale is ((data / vmin)**(1 - stretchpower) - 1) / (1 - stretchpower) / ln(10). 0 means the linear scale. 1 means the logarithmic scale. Defaults to 0.
|
|
857
893
|
"""
|
|
858
894
|
from PIL import Image
|
|
859
895
|
|
|
860
|
-
_kw = {}
|
|
861
|
-
beam_kwargs
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
self.sigma = sigma
|
|
896
|
+
self._kw = {}
|
|
897
|
+
c, x, y, v, beam, sigma, _, _kw, beam_kwargs, singlepix \
|
|
898
|
+
= self._map_init(kwargs)
|
|
899
|
+
if singlepix:
|
|
900
|
+
print('No pixel size. Skip add_rgb.')
|
|
901
|
+
return
|
|
902
|
+
|
|
868
903
|
for i in range(len(stretchscale)):
|
|
869
904
|
if stretchscale[i] is None:
|
|
870
905
|
stretchscale[i] = sigma[i]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.1
|
|
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
|