plotastrodata 1.10.1__py3-none-any.whl → 1.10.2__py3-none-any.whl
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/__init__.py +1 -1
- plotastrodata/analysis_utils.py +100 -31
- plotastrodata/fits_utils.py +12 -4
- plotastrodata/fitting_utils.py +22 -3
- plotastrodata/matrix_utils.py +2 -0
- plotastrodata/noise_utils.py +11 -2
- plotastrodata/other_utils.py +16 -12
- plotastrodata/plot_utils.py +20 -25
- plotastrodata-1.10.2.dist-info/METADATA +125 -0
- plotastrodata-1.10.2.dist-info/RECORD +18 -0
- {plotastrodata-1.10.1.dist-info → plotastrodata-1.10.2.dist-info}/WHEEL +1 -1
- plotastrodata-1.10.1.dist-info/METADATA +0 -128
- plotastrodata-1.10.1.dist-info/RECORD +0 -18
- {plotastrodata-1.10.1.dist-info → plotastrodata-1.10.2.dist-info}/licenses/LICENSE +0 -0
- {plotastrodata-1.10.1.dist-info → plotastrodata-1.10.2.dist-info}/top_level.txt +0 -0
plotastrodata/__init__.py
CHANGED
plotastrodata/analysis_utils.py
CHANGED
|
@@ -19,7 +19,7 @@ from plotastrodata.other_utils import (isdeg, nearest_index,
|
|
|
19
19
|
|
|
20
20
|
def quadrantmean(data: np.ndarray, x: np.ndarray, y: np.ndarray,
|
|
21
21
|
quadrants: str = '13'
|
|
22
|
-
) -> tuple[np.ndarray, np.ndarray, np.ndarray]
|
|
22
|
+
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
23
23
|
"""Take mean between 1st and 3rd (or 2nd and 4th) quadrants.
|
|
24
24
|
|
|
25
25
|
Args:
|
|
@@ -32,12 +32,10 @@ def quadrantmean(data: np.ndarray, x: np.ndarray, y: np.ndarray,
|
|
|
32
32
|
tuple: Averaged (data, x, y).
|
|
33
33
|
"""
|
|
34
34
|
if np.ndim(data) != 2:
|
|
35
|
-
|
|
36
|
-
return
|
|
35
|
+
raise ValueError('data must be a 2D array.')
|
|
37
36
|
|
|
38
37
|
if quadrants not in ['13', '24']:
|
|
39
|
-
|
|
40
|
-
return
|
|
38
|
+
raise ValueError("quadrants must be '13' or '24'.")
|
|
41
39
|
|
|
42
40
|
dx = x[1] - x[0]
|
|
43
41
|
dy = y[1] - y[0]
|
|
@@ -65,6 +63,8 @@ def filled2d(data: np.ndarray, x: np.ndarray, y: np.ndarray, n: int = 1,
|
|
|
65
63
|
Returns:
|
|
66
64
|
tuple: The interpolated (data, x, y).
|
|
67
65
|
"""
|
|
66
|
+
if not isinstance(n, (int, np.integer)) or n < 1:
|
|
67
|
+
raise ValueError('n must be a positive integer.')
|
|
68
68
|
xnew = np.linspace(x[0], x[-1], n * (len(x) - 1) + 1)
|
|
69
69
|
ynew = np.linspace(y[0], y[-1], n * (len(y) - 1) + 1)
|
|
70
70
|
d = RGIxy(y, x, data, np.meshgrid(ynew, xnew, indexing='ij'),
|
|
@@ -73,11 +73,11 @@ def filled2d(data: np.ndarray, x: np.ndarray, y: np.ndarray, n: int = 1,
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
def _need_multipixels(method: Callable) -> Callable:
|
|
76
|
-
def wrapper(cls: Any, *args: Any, **kwargs: Any) -> Any
|
|
76
|
+
def wrapper(cls: Any, *args: Any, **kwargs: Any) -> Any:
|
|
77
77
|
singlepixel = cls.dx is None or cls.dy is None
|
|
78
78
|
if singlepixel:
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
raise ValueError(
|
|
80
|
+
f'{method.__name__}() requires at least two x and y pixels.')
|
|
81
81
|
return method(cls, *args, **kwargs)
|
|
82
82
|
return wrapper
|
|
83
83
|
|
|
@@ -125,17 +125,26 @@ class AstroData():
|
|
|
125
125
|
bunit: str = ''
|
|
126
126
|
|
|
127
127
|
def __post_init__(self) -> None:
|
|
128
|
+
fits_values = (self.fitsimage if isinstance(self.fitsimage, list)
|
|
129
|
+
else [self.fitsimage])
|
|
130
|
+
has_fits = any(a is not None for a in fits_values)
|
|
131
|
+
if isinstance(self.data, list):
|
|
132
|
+
has_data = any(a is not None for a in self.data)
|
|
133
|
+
else:
|
|
134
|
+
has_data = self.data is not None
|
|
135
|
+
if has_fits and has_data:
|
|
136
|
+
raise ValueError('Provide either data or fitsimage, not both.')
|
|
137
|
+
if not has_fits and not has_data:
|
|
138
|
+
raise ValueError('Either data or fitsimage must be given.')
|
|
139
|
+
|
|
128
140
|
n = 0
|
|
129
|
-
if
|
|
141
|
+
if has_fits:
|
|
130
142
|
if not isinstance(self.fitsimage, list):
|
|
131
143
|
n = 1
|
|
132
|
-
elif any(a is not None for a in self.fitsimage):
|
|
133
|
-
n = len(self.fitsimage)
|
|
134
144
|
else:
|
|
135
|
-
n =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if self.data is not None:
|
|
145
|
+
n = len(self.fitsimage)
|
|
146
|
+
self.data = None
|
|
147
|
+
if has_data:
|
|
139
148
|
if _is_data_list(self.data):
|
|
140
149
|
n = len(self.data)
|
|
141
150
|
elif (isinstance(self.data, list)
|
|
@@ -144,8 +153,6 @@ class AstroData():
|
|
|
144
153
|
else:
|
|
145
154
|
self.data = np.asarray(self.data)
|
|
146
155
|
n = 1
|
|
147
|
-
if n == 0:
|
|
148
|
-
print('Either data or fitsimage must be given.')
|
|
149
156
|
self.n = n
|
|
150
157
|
self.fitsimage_org = None
|
|
151
158
|
self.sigma_org = None
|
|
@@ -154,8 +161,11 @@ class AstroData():
|
|
|
154
161
|
|
|
155
162
|
def _binning_one(self, t: str, width: float) -> None:
|
|
156
163
|
grid = getattr(self, t)
|
|
157
|
-
if width == 1
|
|
164
|
+
if width == 1:
|
|
158
165
|
return
|
|
166
|
+
if grid is None:
|
|
167
|
+
raise ValueError(
|
|
168
|
+
f'Binning in the {t}-axis requires a {t} coordinate array.')
|
|
159
169
|
|
|
160
170
|
dt = f'd{t}'
|
|
161
171
|
sep = getattr(self, dt)
|
|
@@ -184,6 +194,10 @@ class AstroData():
|
|
|
184
194
|
Args:
|
|
185
195
|
width (list, optional): Number of channels, y-pixels, and x-pixels for binning. Defaults to [1, 1, 1].
|
|
186
196
|
"""
|
|
197
|
+
if len(width) > 3 or any(not isinstance(a, (int, np.integer))
|
|
198
|
+
or a < 1 for a in width):
|
|
199
|
+
raise ValueError(
|
|
200
|
+
'width must contain one to three positive integers.')
|
|
187
201
|
w = np.array([1] * (3 - len(width)) + list(width), dtype=int)
|
|
188
202
|
if self.pv:
|
|
189
203
|
w[1] = max(w[0], w[1])
|
|
@@ -252,8 +266,7 @@ class AstroData():
|
|
|
252
266
|
"""Make the beam circular by convolving with 1D Gaussian
|
|
253
267
|
"""
|
|
254
268
|
if None in self.beam:
|
|
255
|
-
|
|
256
|
-
return
|
|
269
|
+
raise ValueError('circularbeam() requires a complete beam.')
|
|
257
270
|
|
|
258
271
|
bmaj, bmin, bpa = self.beam
|
|
259
272
|
self.rotate(-bpa)
|
|
@@ -411,14 +424,25 @@ class AstroData():
|
|
|
411
424
|
"""
|
|
412
425
|
if dataformask is None:
|
|
413
426
|
dataformask = self.data
|
|
427
|
+
if len(includepix) not in [0, 2] or len(excludepix) not in [0, 2]:
|
|
428
|
+
raise ValueError(
|
|
429
|
+
'includepix and excludepix must be empty or [min, max].')
|
|
414
430
|
if np.ndim(self.data) > np.ndim(dataformask):
|
|
415
431
|
print('The mask is broadcasted.')
|
|
416
|
-
|
|
432
|
+
try:
|
|
433
|
+
mask = np.broadcast_to(dataformask, np.shape(self.data))
|
|
434
|
+
except ValueError as exc:
|
|
435
|
+
raise ValueError(
|
|
436
|
+
'dataformask must be broadcastable to the data shape; '
|
|
437
|
+
f'got {np.shape(dataformask)} and {np.shape(self.data)}.'
|
|
438
|
+
) from exc
|
|
417
439
|
else:
|
|
418
440
|
mask = dataformask
|
|
419
441
|
if np.shape(self.data) != np.shape(mask):
|
|
420
|
-
|
|
421
|
-
|
|
442
|
+
raise ValueError(
|
|
443
|
+
'dataformask must have the same shape as data after '
|
|
444
|
+
f'broadcasting; got {np.shape(dataformask)} and '
|
|
445
|
+
f'{np.shape(self.data)}.')
|
|
422
446
|
|
|
423
447
|
if len(includepix) == 2:
|
|
424
448
|
self.data[(mask < includepix[0]) + (includepix[1] < mask)] = np.nan
|
|
@@ -445,7 +469,7 @@ class AstroData():
|
|
|
445
469
|
ellipse: list[float, float, float] | None = None,
|
|
446
470
|
ninterp: int = 1,
|
|
447
471
|
flux: bool = False, gaussfit: bool = False
|
|
448
|
-
) -> tuple[np.ndarray, np.ndarray, dict]
|
|
472
|
+
) -> tuple[np.ndarray, np.ndarray, dict]:
|
|
449
473
|
"""Get a list of line profiles at given spatial coordinates.
|
|
450
474
|
|
|
451
475
|
Args:
|
|
@@ -461,8 +485,11 @@ class AstroData():
|
|
|
461
485
|
tuple: (v, list of profiles, result of Gaussian fit)
|
|
462
486
|
"""
|
|
463
487
|
if np.ndim(self.data) != 3 or self.v is None:
|
|
464
|
-
|
|
465
|
-
|
|
488
|
+
raise ValueError('profile() requires 3D data with v, y, and x axes.')
|
|
489
|
+
if len(xlist) != len(ylist):
|
|
490
|
+
raise ValueError('xlist and ylist must have the same length.')
|
|
491
|
+
if len(coords) == 0 and len(xlist) == 0:
|
|
492
|
+
raise ValueError('Provide coords or matching xlist and ylist values.')
|
|
466
493
|
|
|
467
494
|
data, xf, yf = filled2d(self.data, self.x, self.y, ninterp)
|
|
468
495
|
x, y = np.meshgrid(xf, yf)
|
|
@@ -484,7 +511,8 @@ class AstroData():
|
|
|
484
511
|
prof[i] = [calc(d[r <= 1]) for d in data]
|
|
485
512
|
if flux:
|
|
486
513
|
if None in self.beam or None in [self.dx, self.dy]:
|
|
487
|
-
|
|
514
|
+
raise ValueError(
|
|
515
|
+
'flux=True requires a complete beam and x/y pixel sizes.')
|
|
488
516
|
else:
|
|
489
517
|
Omega = np.pi * self.beam[0] * self.beam[1] / 4. / np.log(2.)
|
|
490
518
|
prof *= np.abs(self.dx * self.dy) / Omega
|
|
@@ -503,7 +531,7 @@ class AstroData():
|
|
|
503
531
|
self.beam[2] = self.beam[2] + pa
|
|
504
532
|
|
|
505
533
|
def slice(self, length: float = 0, pa: float = 0,
|
|
506
|
-
dx: float | None = None, **kwargs: Any) -> np.ndarray
|
|
534
|
+
dx: float | None = None, **kwargs: Any) -> np.ndarray:
|
|
507
535
|
"""Get 1D slice with given a length and a position-angle.
|
|
508
536
|
|
|
509
537
|
Args:
|
|
@@ -517,8 +545,11 @@ class AstroData():
|
|
|
517
545
|
if dx is None and self.dx is not None:
|
|
518
546
|
dx = np.abs(self.dx)
|
|
519
547
|
if dx is None:
|
|
520
|
-
|
|
521
|
-
|
|
548
|
+
raise ValueError('slice() requires dx or an x grid with pixel size.')
|
|
549
|
+
if not np.isfinite(dx) or dx <= 0:
|
|
550
|
+
raise ValueError('dx must be finite and positive.')
|
|
551
|
+
if not np.isfinite(length) or length < 0:
|
|
552
|
+
raise ValueError('length must be finite and nonnegative.')
|
|
522
553
|
|
|
523
554
|
n = int(np.ceil(length / 2 / dx))
|
|
524
555
|
r = np.linspace(-n, n, 2 * n + 1) * dx
|
|
@@ -772,13 +803,41 @@ class AstroFrame():
|
|
|
772
803
|
d.v = v
|
|
773
804
|
|
|
774
805
|
def _xyskip(self, d: AstroData, i: int,
|
|
775
|
-
|
|
806
|
+
x: np.ndarray | None, y: np.ndarray | None) -> None:
|
|
776
807
|
d.x = x[::self.xskip]
|
|
777
808
|
d.y = y[::self.yskip]
|
|
778
809
|
data = np.moveaxis(d.data[i], [-2, -1], [0, 1])
|
|
779
810
|
data = data[::self.yskip, ::self.xskip]
|
|
780
811
|
d.data[i] = np.moveaxis(data, [0, 1], [-2, -1])
|
|
781
812
|
|
|
813
|
+
def _validate_data_grid(self, data: np.ndarray, grid: list,
|
|
814
|
+
dataset: int) -> None:
|
|
815
|
+
"""Validate array axes before trimming or spatial subsampling."""
|
|
816
|
+
shape = np.shape(np.squeeze(data))
|
|
817
|
+
if len(shape) not in [2, 3]:
|
|
818
|
+
raise ValueError(
|
|
819
|
+
f'Dataset {dataset} must be 2D or 3D; got shape {shape}.')
|
|
820
|
+
|
|
821
|
+
x, y, v = grid
|
|
822
|
+
required = [('x', x, shape[-1])]
|
|
823
|
+
if self.pv:
|
|
824
|
+
required.append(('v', v, shape[-2]))
|
|
825
|
+
else:
|
|
826
|
+
required.append(('y', y, shape[-2]))
|
|
827
|
+
if len(shape) == 3:
|
|
828
|
+
required.append(('v', v, shape[-3]))
|
|
829
|
+
for name, axis, expected in required:
|
|
830
|
+
if axis is None:
|
|
831
|
+
raise ValueError(
|
|
832
|
+
f'Dataset {dataset} requires a {name} coordinate array.')
|
|
833
|
+
if np.ndim(axis) != 1:
|
|
834
|
+
raise ValueError(
|
|
835
|
+
f'Dataset {dataset} {name} must be a 1D array.')
|
|
836
|
+
if len(axis) != expected:
|
|
837
|
+
raise ValueError(
|
|
838
|
+
f'Dataset {dataset} {name} has length {len(axis)}, but '
|
|
839
|
+
f'the corresponding data axis has length {expected}.')
|
|
840
|
+
|
|
782
841
|
def _trim_skip(self, d: AstroData, i: int, grid: list) -> None:
|
|
783
842
|
d.data[i], grid = trim(data=d.data[i],
|
|
784
843
|
x=grid[0], y=grid[1], v=grid[2],
|
|
@@ -831,6 +890,7 @@ class AstroFrame():
|
|
|
831
890
|
d.sigma_org[i] = d.sigma[i]
|
|
832
891
|
grid = self._read_fitsimage(d, i, grid=grid)
|
|
833
892
|
if d.data[i] is not None:
|
|
893
|
+
self._validate_data_grid(d.data[i], grid, i)
|
|
834
894
|
d.sigma[i] = estimate_rms(d.data[i], d.sigma[i])
|
|
835
895
|
grid = self._shift_center(d, i, grid)
|
|
836
896
|
self._trim_skip(d, i, grid)
|
|
@@ -857,11 +917,20 @@ class AstroFrame():
|
|
|
857
917
|
d (AstroData): Dataclass for the add_* input.
|
|
858
918
|
xskip, yskip (int): Spatial pixel skip. Defaults to 1.
|
|
859
919
|
"""
|
|
920
|
+
if (not isinstance(xskip, (int, np.integer)) or xskip < 1
|
|
921
|
+
or not isinstance(yskip, (int, np.integer)) or yskip < 1):
|
|
922
|
+
raise ValueError('xskip and yskip must be positive integers.')
|
|
860
923
|
self.xskip = xskip
|
|
861
924
|
self.yskip = yskip
|
|
862
925
|
for name in ASTRODATA_ARGS:
|
|
863
926
|
setattr(d, name, _as_list(getattr(d, name), d.n))
|
|
864
927
|
d.beam = _as_list(d.beam, d.n, isbeam=True)
|
|
928
|
+
for name in ASTRODATA_ARGS + ['beam']:
|
|
929
|
+
value = getattr(d, name)
|
|
930
|
+
if len(value) != d.n:
|
|
931
|
+
raise ValueError(
|
|
932
|
+
f'{name} must contain one value or {d.n} values; '
|
|
933
|
+
f'got {len(value)}.')
|
|
865
934
|
grid = [d.x, d.y, d.v]
|
|
866
935
|
for i in range(d.n):
|
|
867
936
|
self._read_one(d, i, grid.copy()) # .copy() not to updated d.x again ang again.
|
plotastrodata/fits_utils.py
CHANGED
|
@@ -12,7 +12,7 @@ from plotastrodata.other_utils import isdeg, RGIxy, trim
|
|
|
12
12
|
|
|
13
13
|
def Jy2K(header: Any = None, bmaj: float | None = None,
|
|
14
14
|
bmin: float | None = None,
|
|
15
|
-
restfreq: float | None = None) -> float
|
|
15
|
+
restfreq: float | None = None) -> float:
|
|
16
16
|
"""Calculate a conversion factor in the unit of K/Jy.
|
|
17
17
|
|
|
18
18
|
Args:
|
|
@@ -28,7 +28,7 @@ def Jy2K(header: Any = None, bmaj: float | None = None,
|
|
|
28
28
|
if header is not None:
|
|
29
29
|
if 'BMAJ' in header and 'BMIN' in header:
|
|
30
30
|
bmaj, bmin = header['BMAJ'] * 3600, header['BMIN'] * 3600
|
|
31
|
-
|
|
31
|
+
elif 'CDELT1' in header and 'CUNIT1' in header:
|
|
32
32
|
print('Use CDELT1^2 for Tb conversion.')
|
|
33
33
|
todiameter = np.sqrt(4 * np.log(2) / np.pi) * 3600
|
|
34
34
|
bmaj = bmin = np.abs(header['CDELT1']) * todiameter
|
|
@@ -41,8 +41,16 @@ def Jy2K(header: Any = None, bmaj: float | None = None,
|
|
|
41
41
|
if restfreq is not None:
|
|
42
42
|
freq = restfreq
|
|
43
43
|
if freq is None:
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
raise ValueError(
|
|
45
|
+
'Brightness-temperature conversion requires restfreq or a '
|
|
46
|
+
'RESTFREQ/RESTFRQ header value.')
|
|
47
|
+
if not np.isfinite(freq) or freq <= 0:
|
|
48
|
+
raise ValueError('restfreq must be finite and positive.')
|
|
49
|
+
if (bmaj is None or bmin is None or not np.isfinite(bmaj)
|
|
50
|
+
or not np.isfinite(bmin) or bmaj <= 0 or bmin <= 0):
|
|
51
|
+
raise ValueError(
|
|
52
|
+
'Brightness-temperature conversion requires finite, positive '
|
|
53
|
+
'bmaj and bmin values or equivalent FITS header metadata.')
|
|
46
54
|
omega = bmaj * bmin * units.arcsec**2 * np.pi / 4. / np.log(2.)
|
|
47
55
|
equiv = units.brightness_temperature(freq * units.Hz, beam_area=omega)
|
|
48
56
|
T = (1 * units.Jy / units.beam).to(units.K, equivalencies=equiv)
|
plotastrodata/fitting_utils.py
CHANGED
|
@@ -107,17 +107,30 @@ class EmceeCorner():
|
|
|
107
107
|
sigma: float | np.ndarray = 1, progressbar: bool = False,
|
|
108
108
|
percent: list = [16, 84]) -> None:
|
|
109
109
|
global global_bounds, global_progressbar
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
bounds_array = np.asarray(bounds, dtype=float)
|
|
111
|
+
if bounds_array.ndim != 2 or 2 not in bounds_array.shape:
|
|
112
|
+
raise ValueError('bounds must have shape (dim, 2) or (2, dim).')
|
|
113
|
+
if bounds_array.shape[1] != 2:
|
|
114
|
+
global_bounds = np.transpose(bounds_array)
|
|
112
115
|
print('bounds has been transposed because its shape is (2, dim).')
|
|
113
116
|
else:
|
|
114
|
-
global_bounds =
|
|
117
|
+
global_bounds = bounds_array
|
|
118
|
+
if (not np.all(np.isfinite(global_bounds))
|
|
119
|
+
or np.any(global_bounds[:, 0] >= global_bounds[:, 1])):
|
|
120
|
+
raise ValueError(
|
|
121
|
+
'Each parameter bound must be finite with lower < upper.')
|
|
122
|
+
if (len(percent) != 2 or not 0 <= percent[0] < percent[1] <= 100):
|
|
123
|
+
raise ValueError(
|
|
124
|
+
'percent must contain two increasing values between 0 and 100.')
|
|
115
125
|
global_progressbar = progressbar
|
|
116
126
|
if logl is None and (model is not None
|
|
117
127
|
and xdata is not None
|
|
118
128
|
and ydata is not None):
|
|
119
129
|
logl = partial(_gaussian_log_likelihood, model=model,
|
|
120
130
|
xdata=xdata, ydata=ydata, sigma=sigma)
|
|
131
|
+
if logl is None:
|
|
132
|
+
raise ValueError(
|
|
133
|
+
'Provide logl, or provide model, xdata, and ydata together.')
|
|
121
134
|
self.bounds = global_bounds
|
|
122
135
|
self.dim = len(self.bounds)
|
|
123
136
|
self.logl = logl
|
|
@@ -221,6 +234,12 @@ class EmceeCorner():
|
|
|
221
234
|
pt (bool, optional): Whether to use ptemcee; otherwise, emcee is used. Defaults to False.
|
|
222
235
|
"""
|
|
223
236
|
global bar
|
|
237
|
+
if nsteps < 1:
|
|
238
|
+
raise ValueError('nsteps must be positive.')
|
|
239
|
+
if nburnin < 0 or nburnin >= nsteps:
|
|
240
|
+
raise ValueError('nburnin must satisfy 0 <= nburnin < nsteps.')
|
|
241
|
+
if ntemps < 1 or ntry < 1 or ncores < 1:
|
|
242
|
+
raise ValueError('ntemps, ntry, and ncores must be positive.')
|
|
224
243
|
if nwalkersperdim < 2:
|
|
225
244
|
print('nwalkersperdim < 2 is not allowed.'
|
|
226
245
|
+ f' Use 2 instead of {nwalkersperdim:d}.')
|
plotastrodata/matrix_utils.py
CHANGED
|
@@ -56,6 +56,8 @@ def Mrot3d(t: float, axis: int = 3) -> np.ndarray:
|
|
|
56
56
|
Returns:
|
|
57
57
|
np.ndarray: 3x3 rotation matrix that rotates coordinates around the specified axis by t degrees.
|
|
58
58
|
"""
|
|
59
|
+
if axis not in [1, 2, 3]:
|
|
60
|
+
raise ValueError('axis must be 1, 2, or 3.')
|
|
59
61
|
cos_t = np.cos(np.radians(t))
|
|
60
62
|
sin_t = np.sin(np.radians(t))
|
|
61
63
|
match axis:
|
plotastrodata/noise_utils.py
CHANGED
|
@@ -123,9 +123,15 @@ class Noise:
|
|
|
123
123
|
"""
|
|
124
124
|
def __init__(self, data: np.ndarray, sigma: str) -> None:
|
|
125
125
|
self.data = select_noise(data, sigma)
|
|
126
|
+
if self.data.size < 2:
|
|
127
|
+
raise ValueError(
|
|
128
|
+
'Noise estimation requires at least two selected finite pixels.')
|
|
126
129
|
self.sigma = sigma
|
|
127
130
|
self.m0 = np.mean(self.data)
|
|
128
131
|
self.s0 = np.std(self.data)
|
|
132
|
+
if not np.isfinite(self.s0):
|
|
133
|
+
raise ValueError(
|
|
134
|
+
'Noise estimation requires selected pixels with finite values.')
|
|
129
135
|
|
|
130
136
|
def gen_histogram(self, **kwargs: Any) -> None:
|
|
131
137
|
"""Generate a pair of histogram and bins using numpy.histogram.
|
|
@@ -135,6 +141,10 @@ class Noise:
|
|
|
135
141
|
Default keyword values:
|
|
136
142
|
numpy.histogram: ``bins=100``, ``range=(-3.5, 3.5)``, and ``density=True``. User-supplied keyword arguments override these values.
|
|
137
143
|
"""
|
|
144
|
+
if self.s0 == 0:
|
|
145
|
+
raise ValueError(
|
|
146
|
+
'Histogram noise estimation requires selected pixels with '
|
|
147
|
+
'nonzero variance.')
|
|
138
148
|
_kw = {'bins': 100, 'range': (-3.5, 3.5), 'density': True}
|
|
139
149
|
_kw.update(kwargs)
|
|
140
150
|
self.bins = _kw['bins']
|
|
@@ -215,8 +225,7 @@ def estimate_rms(data: np.ndarray,
|
|
|
215
225
|
return sigma
|
|
216
226
|
|
|
217
227
|
if np.ndim(np.squeeze(data)) == 0:
|
|
218
|
-
|
|
219
|
-
return 0.0
|
|
228
|
+
raise ValueError('sigma cannot be estimated from only one pixel.')
|
|
220
229
|
|
|
221
230
|
n = Noise(data, sigma)
|
|
222
231
|
if 'hist' in sigma:
|
plotastrodata/other_utils.py
CHANGED
|
@@ -89,8 +89,7 @@ def trim(data: np.ndarray | None = None, x: np.ndarray | None = None,
|
|
|
89
89
|
d = np.squeeze(data)
|
|
90
90
|
|
|
91
91
|
if d.ndim == 0:
|
|
92
|
-
|
|
93
|
-
return data, [xout, yout, vout]
|
|
92
|
+
raise ValueError('data must be a 2D or 3D array, not a scalar.')
|
|
94
93
|
|
|
95
94
|
if d.ndim == 2:
|
|
96
95
|
if pv:
|
|
@@ -114,7 +113,10 @@ def to4dim(data: np.ndarray) -> np.ndarray:
|
|
|
114
113
|
Returns:
|
|
115
114
|
np.ndarray: Output 4D array.
|
|
116
115
|
"""
|
|
117
|
-
|
|
116
|
+
ndim = np.ndim(data)
|
|
117
|
+
if ndim not in [2, 3, 4]:
|
|
118
|
+
raise ValueError('data must be a 2D, 3D, or 4D array.')
|
|
119
|
+
if ndim == 2:
|
|
118
120
|
d = np.array([[data]])
|
|
119
121
|
elif np.ndim(data) == 3:
|
|
120
122
|
d = np.array([data])
|
|
@@ -164,7 +166,7 @@ def reform_grid(v: np.ndarray | None = None,
|
|
|
164
166
|
|
|
165
167
|
def reform_data(c: np.ndarray, v_in: np.ndarray | None,
|
|
166
168
|
nv: int, v_org: np.ndarray | None = None,
|
|
167
|
-
vskip: int = 1) -> np.ndarray
|
|
169
|
+
vskip: int = 1) -> np.ndarray:
|
|
168
170
|
"""Skip and fill channels with nan.
|
|
169
171
|
|
|
170
172
|
Args:
|
|
@@ -182,12 +184,14 @@ def reform_data(c: np.ndarray, v_in: np.ndarray | None,
|
|
|
182
184
|
|
|
183
185
|
ndim = np.ndim(c)
|
|
184
186
|
if ndim not in [2, 3]:
|
|
185
|
-
|
|
186
|
-
return
|
|
187
|
+
raise ValueError('c must be a 2D or 3D array.')
|
|
187
188
|
|
|
188
189
|
if ndim == 2:
|
|
189
190
|
d = np.full((nv, *np.shape(c)), c)
|
|
190
191
|
elif v_in is not None:
|
|
192
|
+
if len(v_in) < 2 or len(v_org) < 2:
|
|
193
|
+
raise ValueError(
|
|
194
|
+
'3D reform_data() requires at least two v_in and v_org values.')
|
|
191
195
|
dv_org = v_org[1] - v_org[0]
|
|
192
196
|
dv_in = (v_in[1] - v_in[0]) * vskip
|
|
193
197
|
k0 = nearest_index(v_org, v_in[0])
|
|
@@ -211,6 +215,8 @@ def reform_data(c: np.ndarray, v_in: np.ndarray | None,
|
|
|
211
215
|
prenan = np.full((k0, *np.shape(d)[1:]), np.nan)
|
|
212
216
|
d = np.concatenate((prenan, d))
|
|
213
217
|
d = d[::vskip]
|
|
218
|
+
else:
|
|
219
|
+
raise ValueError('3D reform_data() requires v_in when v_org is given.')
|
|
214
220
|
shape = np.shape(d)
|
|
215
221
|
shape = (len(v_org) - shape[0], shape[1], shape[2])
|
|
216
222
|
postnan = np.full(shape, np.nan)
|
|
@@ -220,7 +226,7 @@ def reform_data(c: np.ndarray, v_in: np.ndarray | None,
|
|
|
220
226
|
|
|
221
227
|
def RGIxy(y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
222
228
|
yxnew: tuple[np.ndarray, np.ndarray] | None = None,
|
|
223
|
-
**kwargs: Any) -> Callable | np.ndarray
|
|
229
|
+
**kwargs: Any) -> Callable | np.ndarray:
|
|
224
230
|
"""RGI for x and y at each channel.
|
|
225
231
|
|
|
226
232
|
Default keyword values:
|
|
@@ -236,8 +242,7 @@ def RGIxy(y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
|
236
242
|
np.ndarray: The RGI function or the interpolated array.
|
|
237
243
|
"""
|
|
238
244
|
if np.ndim(data) not in [2, 3, 4]:
|
|
239
|
-
|
|
240
|
-
return
|
|
245
|
+
raise ValueError('data must be a 2D, 3D, or 4D array.')
|
|
241
246
|
|
|
242
247
|
_kw = {'bounds_error': False, 'fill_value': np.nan,
|
|
243
248
|
'method': 'linear'}
|
|
@@ -258,7 +263,7 @@ def RGIxy(y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
|
258
263
|
|
|
259
264
|
def RGIxyv(v: np.ndarray, y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
260
265
|
vyxnew: tuple[np.ndarray, np.ndarray, np.ndarray] | None = None,
|
|
261
|
-
**kwargs: Any) -> Callable | np.ndarray
|
|
266
|
+
**kwargs: Any) -> Callable | np.ndarray:
|
|
262
267
|
"""RGI in the x-y-v space.
|
|
263
268
|
|
|
264
269
|
Default keyword values:
|
|
@@ -275,8 +280,7 @@ def RGIxyv(v: np.ndarray, y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
|
275
280
|
np.ndarray: The RGI function or the interpolated array.
|
|
276
281
|
"""
|
|
277
282
|
if np.ndim(data) not in [3, 4]:
|
|
278
|
-
|
|
279
|
-
return
|
|
283
|
+
raise ValueError('data must be a 3D or 4D array.')
|
|
280
284
|
|
|
281
285
|
_kw = {'bounds_error': False, 'fill_value': np.nan,
|
|
282
286
|
'method': 'linear'}
|
plotastrodata/plot_utils.py
CHANGED
|
@@ -727,8 +727,7 @@ class PlotAstroData(AstroFrame):
|
|
|
727
727
|
'linewidth': 1.5, 'zorder': 10}
|
|
728
728
|
_kw.update(kwargs)
|
|
729
729
|
if patch not in ['rectangle', 'ellipse']:
|
|
730
|
-
|
|
731
|
-
return
|
|
730
|
+
raise ValueError("patch must be 'rectangle' or 'ellipse'.")
|
|
732
731
|
|
|
733
732
|
z = listing(*self.pos2xy(poslist), minlist, majlist, palist)
|
|
734
733
|
for x, y, width, height, angle in zip(*z):
|
|
@@ -911,8 +910,7 @@ class PlotAstroData(AstroFrame):
|
|
|
911
910
|
bbox (dict, optional): Keyword arguments for the text bounding box. Defaults to {'alpha': 0}.
|
|
912
911
|
"""
|
|
913
912
|
if length == 0:
|
|
914
|
-
|
|
915
|
-
return
|
|
913
|
+
raise ValueError('length must be nonzero.')
|
|
916
914
|
if fontsize is None:
|
|
917
915
|
fontsize = 20 if len(self.ax) == 1 else 15
|
|
918
916
|
for ch, axnow in enumerate(self.ax):
|
|
@@ -995,8 +993,8 @@ class PlotAstroData(AstroFrame):
|
|
|
995
993
|
'vmin': None, 'vmax': None}
|
|
996
994
|
c, x, y, v, sigma, bunit, _kw, singlepix = self._map_init(kwargs)
|
|
997
995
|
if singlepix:
|
|
998
|
-
|
|
999
|
-
|
|
996
|
+
raise ValueError(
|
|
997
|
+
'add_color() requires at least two x and y pixels.')
|
|
1000
998
|
|
|
1001
999
|
cblabel = bunit if cblabel is None else cblabel
|
|
1002
1000
|
|
|
@@ -1036,8 +1034,8 @@ class PlotAstroData(AstroFrame):
|
|
|
1036
1034
|
self._kw = {'colors': 'gray', 'linewidths': 1.0, 'zorder': 2}
|
|
1037
1035
|
c, x, y, v, sigma, _, _kw, singlepix = self._map_init(kwargs)
|
|
1038
1036
|
if singlepix:
|
|
1039
|
-
|
|
1040
|
-
|
|
1037
|
+
raise ValueError(
|
|
1038
|
+
'add_contour() requires at least two x and y pixels.')
|
|
1041
1039
|
|
|
1042
1040
|
c = self.vskipfill(c, v)
|
|
1043
1041
|
for axnow, cnow in zip(self.ax, c):
|
|
@@ -1088,8 +1086,8 @@ class PlotAstroData(AstroFrame):
|
|
|
1088
1086
|
'data': [amp, ang, stU, stQ]}
|
|
1089
1087
|
c, x, y, v, sigma, _, _kw, singlepix = self._map_init(kwargs)
|
|
1090
1088
|
if singlepix:
|
|
1091
|
-
|
|
1092
|
-
|
|
1089
|
+
raise ValueError(
|
|
1090
|
+
'add_segment() requires at least two x and y pixels.')
|
|
1093
1091
|
|
|
1094
1092
|
amp, ang, stU, stQ = c
|
|
1095
1093
|
sigmaU, sigmaQ = sigma[2:]
|
|
@@ -1135,12 +1133,12 @@ class PlotAstroData(AstroFrame):
|
|
|
1135
1133
|
'stretchpower': [0.5] * 3}
|
|
1136
1134
|
c, x, y, v, _, _, _kw, singlepix = self._map_init(kwargs)
|
|
1137
1135
|
if singlepix:
|
|
1138
|
-
|
|
1139
|
-
return
|
|
1136
|
+
raise ValueError('add_rgb() requires at least two x and y pixels.')
|
|
1140
1137
|
|
|
1141
1138
|
if not (np.shape(c[0]) == np.shape(c[1]) == np.shape(c[2])):
|
|
1142
|
-
|
|
1143
|
-
|
|
1139
|
+
raise ValueError(
|
|
1140
|
+
'add_rgb() requires red, green, and blue data with matching '
|
|
1141
|
+
'shapes.')
|
|
1144
1142
|
|
|
1145
1143
|
st = kwargs2instance(Stretcher, _kw)
|
|
1146
1144
|
c, cmin, cmax = st.set_minmax(c)
|
|
@@ -1348,16 +1346,15 @@ class PlotAstroData(AstroFrame):
|
|
|
1348
1346
|
for fig in self.figs:
|
|
1349
1347
|
plt.close(fig)
|
|
1350
1348
|
|
|
1351
|
-
def get_figax(self) -> tuple[object, object]
|
|
1349
|
+
def get_figax(self) -> tuple[object, object]:
|
|
1352
1350
|
"""Output the external fig and ax after plotting.
|
|
1353
1351
|
|
|
1354
1352
|
Returns:
|
|
1355
1353
|
tuple: (fig, ax)
|
|
1356
1354
|
"""
|
|
1357
1355
|
if len(self.ax) > 1:
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
return
|
|
1356
|
+
raise ValueError(
|
|
1357
|
+
'PlotAstroData.get_figax() does not support channel maps.')
|
|
1361
1358
|
|
|
1362
1359
|
return self.figs[0], self.ax[0]
|
|
1363
1360
|
|
|
@@ -1403,8 +1400,7 @@ def _set_figax_plotprofile(fig: object | None, ax: object | None,
|
|
|
1403
1400
|
if fig is None:
|
|
1404
1401
|
fig = plt.figure(figsize=(6 * ncols, 3 * nrows))
|
|
1405
1402
|
if nprof > 1 and ax is not None:
|
|
1406
|
-
|
|
1407
|
-
ax = None
|
|
1403
|
+
raise ValueError('An external ax is supported only for one profile.')
|
|
1408
1404
|
ax = np.empty(nprof, dtype=object) if ax is None else [ax]
|
|
1409
1405
|
for i in range(nprof):
|
|
1410
1406
|
sharex = None if i < nrows - 1 else ax[i - 1]
|
|
@@ -1531,8 +1527,7 @@ def plotslice(length: float, dx: float | None = None, pa: float = 0,
|
|
|
1531
1527
|
d = kwargs2instance(AstroData, _kw)
|
|
1532
1528
|
f.read(d)
|
|
1533
1529
|
if np.ndim(d.data) > 2:
|
|
1534
|
-
|
|
1535
|
-
return
|
|
1530
|
+
raise ValueError('plotslice() supports only a 2D map.')
|
|
1536
1531
|
|
|
1537
1532
|
r, z = d.slice(length=length, pa=pa, dx=dx)
|
|
1538
1533
|
xunit = 'arcsec' if f.dist == 1 else 'au'
|
|
@@ -1582,9 +1577,9 @@ def _plot_on_wall(d: AstroData, x: np.ndarray, y: np.ndarray, v: np.ndarray,
|
|
|
1582
1577
|
case 0:
|
|
1583
1578
|
shape = np.shape(d.data[0, :, :])
|
|
1584
1579
|
if np.shape(kwargs['data']) != shape:
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1580
|
+
raise ValueError(
|
|
1581
|
+
'The shape of the 2D wall data must match the corresponding '
|
|
1582
|
+
f'3D data plane; got {np.shape(kwargs["data"])} and {shape}.')
|
|
1588
1583
|
|
|
1589
1584
|
_kw = {'levels': [3, 6, 12, 24, 48, 96, 192, 384],
|
|
1590
1585
|
'sigma': 'hist', 'cmap': 'Jet', 'alpha': 0.3}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: plotastrodata
|
|
3
|
+
Version: 1.10.2
|
|
4
|
+
Summary: plotastrodata is a tool for astronomers to create figures from FITS files and perform fundamental data analyses with ease.
|
|
5
|
+
Home-page: https://github.com/yusukeaso-astron/plotastrodata
|
|
6
|
+
Download-URL: https://github.com/yusukeaso-astron/plotastrodata
|
|
7
|
+
Author: yusukeaso-astron
|
|
8
|
+
License: GNU General Public License Version 3
|
|
9
|
+
Keywords: astronomy,FITS,plot
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: astropy>=7.2
|
|
15
|
+
Requires-Dist: corner
|
|
16
|
+
Requires-Dist: dynesty
|
|
17
|
+
Requires-Dist: emcee>=3.1.5
|
|
18
|
+
Requires-Dist: matplotlib
|
|
19
|
+
Requires-Dist: numpy>=2.0
|
|
20
|
+
Requires-Dist: pillow
|
|
21
|
+
Requires-Dist: plotly
|
|
22
|
+
Requires-Dist: ptemcee
|
|
23
|
+
Requires-Dist: pydantic>=2
|
|
24
|
+
Requires-Dist: scikit-image
|
|
25
|
+
Requires-Dist: scipy
|
|
26
|
+
Requires-Dist: tqdm
|
|
27
|
+
Dynamic: download-url
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# plotastrodata
|
|
31
|
+
Python package to make figures from radio astronomical data by astropy and matplotlib.
|
|
32
|
+
The API, examples, and gallery are available in [readthedocs](https://plotastrodata.readthedocs.io/en/latest/).
|
|
33
|
+
The PDF manual is available [here](https://github.com/yusukeaso-astron/plotastrodata/blob/main/plotastrodata_manual.pdf).
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Highlights
|
|
37
|
+
|
|
38
|
+
* Read, write, and process astronomical FITS images, spectral cubes, position-velocity diagrams, and NumPy arrays, including WCS coordinates, spectral axes, beam information, and brightness-temperature conversion.
|
|
39
|
+
* Create 2D maps, channel maps, position-velocity diagrams, RGB composites, line profiles, spatial slices, and interactive 3D isosurface visualizations.
|
|
40
|
+
* Overlay color, contour, polarization-vector, and RGB data from different spatial grids, with astronomical coordinates, beams, scale bars, regions, markers, and other annotations.
|
|
41
|
+
* Prepare data through trimming, interpolation, binning, masking, centering, rotation, deprojection, beam circularization, and profile extraction.
|
|
42
|
+
* Estimate image noise, including support for primary-beam-corrected data.
|
|
43
|
+
* Fit Gaussian models to line profiles and two-dimensional image components.
|
|
44
|
+
* Use supporting tools for coordinate and line-of-sight transformations, centered Fourier transforms and visibility sampling, and Bayesian or grid-based parameter estimation.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
Install from conda-forge:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
conda install conda-forge::plotastrodata
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
or from PyPI:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install plotastrodata
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
To install the latest source from GitHub:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/yusukeaso-astron/plotastrodata
|
|
64
|
+
cd plotastrodata
|
|
65
|
+
python -m pip install .
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
To update a source installation, run the following commands in the cloned repository:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git pull
|
|
72
|
+
python -m pip install --upgrade .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Demo and Usage
|
|
76
|
+
|
|
77
|
+
The repository includes [`example.py`](example.py), which demonstrates the main plotting and analysis features. After cloning the repository and installing the package, run:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python example.py
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
More examples and the complete API reference are available in the [online documentation](https://plotastrodata.readthedocs.io/en/latest/).
|
|
84
|
+
|
|
85
|
+
## Requirement
|
|
86
|
+
|
|
87
|
+
* Python >= 3.11
|
|
88
|
+
* astropy >= 7.2
|
|
89
|
+
* corner (only for fitting)
|
|
90
|
+
* dynesty (only for fitting)
|
|
91
|
+
* emcee >= 3.1.5 (only for fitting)
|
|
92
|
+
* ffmpeg (only for movie)
|
|
93
|
+
* matplotlib
|
|
94
|
+
* numpy >= 2.0
|
|
95
|
+
* pillow (only for RGB figures)
|
|
96
|
+
* plotly (only for html cube)
|
|
97
|
+
* ptemcee (only for fitting)
|
|
98
|
+
* pydantic >= 2
|
|
99
|
+
* scikit-image (only for html cube)
|
|
100
|
+
* scipy
|
|
101
|
+
* tqdm (only for fitting)
|
|
102
|
+
|
|
103
|
+
## Conventions and Limitations
|
|
104
|
+
|
|
105
|
+
* Array axes are ordered as `(y, x)` for a 2D image, `(v, y, x)` for a spectral cube, and `(v, x)` for a position-velocity diagram. With NumPy-array input, supply matching one-dimensional coordinate arrays; a spectral cube requires `v` to construct channel maps. FITS input obtains these coordinates from its header.
|
|
106
|
+
* Spatial coordinates are offsets from `center`. They are expressed in arcseconds when `dist=1`. When `dist` is set to the source distance in parsecs, spatial offsets and beam sizes are expressed in au.
|
|
107
|
+
* By default, the R.A. axis increases toward the left (`xflip=True`), following the usual astronomical image convention. Use `xflip=False` to reverse this behavior.
|
|
108
|
+
* Velocity coordinates and `vsys` are in km/s, while `restfreq` is in Hz. A frequency axis read from FITS is converted to velocity relative to `vsys`.
|
|
109
|
+
* Sky positions may be given as coordinate strings, such as `'ICRS 01h23m45.6s 01d23m45.6s'`. Numeric positions supplied through `poslist`, such as `[0.2, 0.3]`, are relative plotting positions: 0 is the left or bottom edge and 1 is the right or top edge. They are not spatial offsets.
|
|
110
|
+
* Angles are in degrees unless an API explicitly states otherwise. Sky position angles are measured from north toward east. The polar-coordinate arrays `theta` and `phi` used by the line-of-sight utilities are in radians.
|
|
111
|
+
* A beam is represented by `[bmaj, bmin, bpa]`, where the first two values use the current spatial unit and `bpa` is in degrees. `Tb=True` converts data from Jy/beam to brightness temperature and requires a valid rest frequency and spatial-resolution metadata.
|
|
112
|
+
* `sigma` may be a numeric RMS value, a string selecting a noise-estimation method, or `None` to disable noise-dependent behavior. See the API documentation for the available estimation methods.
|
|
113
|
+
* Annotation methods accept a single value or a list of values. `include_chan` selects displayed channels by zero-based index; `None` applies the annotation to all channels.
|
|
114
|
+
* Position-velocity mode (`pv=True`) does not support regions, lines, arrows, or segment maps because its spatial and velocity axes use different units. Markers and text may still be placed using relative plotting positions.
|
|
115
|
+
* Constants in `const_utils` are plain numerical values in SI units, not `astropy.units.Quantity` objects.
|
|
116
|
+
|
|
117
|
+
## Author
|
|
118
|
+
|
|
119
|
+
* Name: Yusuke Aso
|
|
120
|
+
* Affiliation: Korea Astronomy and Space Science Institute
|
|
121
|
+
* E-mail: yaso@kasi.re.kr
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
"plotastrodata" is under [GNU General Public License Version 3](https://www.gnu.org/licenses/gpl-3.0.html).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
plotastrodata/__init__.py,sha256=2tJOvuIFBRyjdissM6roWx4IzryH7HNlsf0FG87AzZo,87
|
|
2
|
+
plotastrodata/analysis_utils.py,sha256=b7Lpoa8_TrLaFRTFB0nnuDzk-wZbetXD6WgOVACmxVY,40831
|
|
3
|
+
plotastrodata/const_utils.py,sha256=7clioUo-YTKq6CcXos8Ek1TY4CiNEo_V9ESA1Mu3g8g,3288
|
|
4
|
+
plotastrodata/coord_utils.py,sha256=S34puKwuiIz9HMbs5Cdew3TkWGIbmXWPirYiDCc4TRw,7077
|
|
5
|
+
plotastrodata/ext_utils.py,sha256=eVkC6-Elduj0j98bKNJUG-Z0TpxeHBZ_esCbzbwZglQ,2140
|
|
6
|
+
plotastrodata/fft_utils.py,sha256=7rl8r0hVS-bWJNO4pW2nkw_D-SBGAZ17W9TENobV6cE,17768
|
|
7
|
+
plotastrodata/fits_utils.py,sha256=wlkjXa1KF2q0L0-xHaGHlggwJi_x3ekjiMWkKuJVXGY,18771
|
|
8
|
+
plotastrodata/fitting_utils.py,sha256=FPwjSsuGdja2iZsBo-7fg7g6I71iOW7ZZ8Xh3ZpafxM,30406
|
|
9
|
+
plotastrodata/los_utils.py,sha256=uG5t1nAmcnEDZ80VD2zB6s55LCHpY57zG89cuL9M0po,6406
|
|
10
|
+
plotastrodata/matrix_utils.py,sha256=Z5R3BK3HeQuF-XQalekCpv2-t_huR80DKdLdvrbrXz4,2358
|
|
11
|
+
plotastrodata/noise_utils.py,sha256=yzLF580MFdjmOpfGz4OC8U2CzS2KOkhjbZ7UegMRMGg,9193
|
|
12
|
+
plotastrodata/other_utils.py,sha256=3PJJ8f8qNXrJtgxGmSZSdpBqceJ_Jexf4-Er_aEhSzE,11508
|
|
13
|
+
plotastrodata/plot_utils.py,sha256=e6Yl0u1w6ubTj7-d34MR3msU-vDV9sBZ-9kDDxqDj0o,80787
|
|
14
|
+
plotastrodata-1.10.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
15
|
+
plotastrodata-1.10.2.dist-info/METADATA,sha256=wdj5h-4dH6om3QP0BuU7AczMPdwg4OPmurEhgOoXJ1I,6060
|
|
16
|
+
plotastrodata-1.10.2.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
17
|
+
plotastrodata-1.10.2.dist-info/top_level.txt,sha256=mv2FRRtreGAUE_UF_Z_TYj_NZLECJqkQx7ErkA_Rttg,14
|
|
18
|
+
plotastrodata-1.10.2.dist-info/RECORD,,
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: plotastrodata
|
|
3
|
-
Version: 1.10.1
|
|
4
|
-
Summary: plotastrodata is a tool for astronomers to create figures from FITS files and perform fundamental data analyses with ease.
|
|
5
|
-
Home-page: https://github.com/yusukeaso-astron/plotastrodata
|
|
6
|
-
Download-URL: https://github.com/yusukeaso-astron/plotastrodata
|
|
7
|
-
Author: yusukeaso-astron
|
|
8
|
-
License: GNU General Public License Version 3
|
|
9
|
-
Keywords: astronomy,FITS,plot
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Requires-Python: >=3.11
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Requires-Dist: astropy>=7.2
|
|
15
|
-
Requires-Dist: corner
|
|
16
|
-
Requires-Dist: dynesty
|
|
17
|
-
Requires-Dist: emcee>=3.1.5
|
|
18
|
-
Requires-Dist: matplotlib
|
|
19
|
-
Requires-Dist: numpy>=2.0
|
|
20
|
-
Requires-Dist: pillow
|
|
21
|
-
Requires-Dist: plotly
|
|
22
|
-
Requires-Dist: ptemcee
|
|
23
|
-
Requires-Dist: pydantic>=2
|
|
24
|
-
Requires-Dist: scikit-image
|
|
25
|
-
Requires-Dist: scipy
|
|
26
|
-
Requires-Dist: tqdm
|
|
27
|
-
Dynamic: download-url
|
|
28
|
-
Dynamic: license-file
|
|
29
|
-
|
|
30
|
-
# plotastrodata
|
|
31
|
-
Python package to make figures from radio astronomical data by astropy and matplotlib.
|
|
32
|
-
The API, examples, and gallery are available in [readthedocs](https://plotastrodata.readthedocs.io/en/latest/).
|
|
33
|
-
The PDF manual is available [here](https://github.com/yusukeaso-astron/plotastrodata/blob/main/plotastrodata_manual.pdf).
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## Demo and Usage
|
|
37
|
-
For the installation, conda-forge and PyPI are available.
|
|
38
|
-
```bash
|
|
39
|
-
conda install conda-forge::plotastrodata
|
|
40
|
-
```
|
|
41
|
-
or
|
|
42
|
-
```bash
|
|
43
|
-
pip install plotastrodata
|
|
44
|
-
```
|
|
45
|
-
The following is the way to install plotastrodata manually. The file example.py will help you find out how to use this package.
|
|
46
|
-
```bash
|
|
47
|
-
git clone https://github.com/yusukeaso-astron/plotastrodata
|
|
48
|
-
cd plotastrodata
|
|
49
|
-
python example.py
|
|
50
|
-
```
|
|
51
|
-
To keep the package updated, always type the command below in the directory plotastrodata before you use it.
|
|
52
|
-
```bash
|
|
53
|
-
git pull
|
|
54
|
-
```
|
|
55
|
-
Also, setting the path in .bashrc (or .zshrc, etc.) will be useful.
|
|
56
|
-
```bash
|
|
57
|
-
export PYTHONPATH=${PYTHONPATH}:/YOUR_PATH_TO/plotastrodata
|
|
58
|
-
```
|
|
59
|
-
Or directly in your script,
|
|
60
|
-
```Python
|
|
61
|
-
import sys
|
|
62
|
-
sys.path.append( "/YOUR_PATH_TO/plotastrodata" )
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Features
|
|
66
|
-
|
|
67
|
-
plotastrodata can do the following things.
|
|
68
|
-
* Make 3D channel maps, 3D rotatable html cube, or 2D images including position-velocity diagrams.
|
|
69
|
-
* Color scale can be linear, log, and asinh.
|
|
70
|
-
* Make a figure of line profiles with Gaussian fitting.
|
|
71
|
-
* Plot images to externally given fig and ax (2D images only).
|
|
72
|
-
* Combine color, contour, segment, and RGB maps using images with different spatial grids.
|
|
73
|
-
* Input fits files or 2D/3D numpy arrays.
|
|
74
|
-
* Select the R.A.-Dec. style or the offset style as the x/y tick labels.
|
|
75
|
-
* Fill channel maps with a 2D image.
|
|
76
|
-
* Add line, arrow, ellipse, rectangle, text, and marker in specified channels.
|
|
77
|
-
* Use original arguments of matplotlib (pcolormesh, contour, quiver, plot, text, Ellipse, Rectangle).
|
|
78
|
-
* Other functions for plotting line profiles and a spatial 1D slice.
|
|
79
|
-
* example_advanced.py includes how to make a movie of channel maps.
|
|
80
|
-
* There are other utilities for Fourier transform and fitting.
|
|
81
|
-
|
|
82
|
-
## Requirement
|
|
83
|
-
|
|
84
|
-
* Python >= 3.11
|
|
85
|
-
* astropy >= 7.2
|
|
86
|
-
* corner (only for fitting)
|
|
87
|
-
* dynesty (only for fitting)
|
|
88
|
-
* emcee >= 3.1.5 (only for fitting)
|
|
89
|
-
* ffmpeg (only for movie)
|
|
90
|
-
* matplotlib
|
|
91
|
-
* numpy >= 2.0
|
|
92
|
-
* pillow (only for RGB figures)
|
|
93
|
-
* plotly (only for html cube)
|
|
94
|
-
* ptemcee (only for fitting)
|
|
95
|
-
* pydantic >= 2
|
|
96
|
-
* scikit-image (only for html cube)
|
|
97
|
-
* scipy
|
|
98
|
-
* tqdm (only for fitting)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
## Installation
|
|
102
|
-
|
|
103
|
-
Download from https://github.com/yusukeaso-astron/plotastrodata or git clone.
|
|
104
|
-
```bash
|
|
105
|
-
git clone https://github.com/yusukeaso-astron/plotastrodata
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Note
|
|
109
|
-
|
|
110
|
-
* For 3D data, a 1D velocity array or a FITS file with a velocity axis must be given to set up channels on each page.
|
|
111
|
-
* For 2D/3D data, the spatial center can be read from a FITS file or manually given.
|
|
112
|
-
* len(v)=1 (default) means to make a 2D figure.
|
|
113
|
-
* Spatial lengths are in the unit of arcsec, or au if dist (!= 1) is given.
|
|
114
|
-
* Angles are in the unit of degree.
|
|
115
|
-
* For region, line, arrow, label, and marker, a single input can be treated without a list, e.g., anglelist=60, as well as anglelist=[60].
|
|
116
|
-
* Each element of poslist supposes a text coordinate like '01h23m45.6s 01d23m45.6s' or a list of relative x and y like [0.2, 0.3] (0 is left or bottom, 1 is right or top).
|
|
117
|
-
* Parameters for original methods in matplotlib.axes.Axes can be used as kwargs; see the default kwargs0 for reference.
|
|
118
|
-
* Position-velocity diagrams (pv=True) do not yet support region, line, arrow, and segment because the units of abscissa and ordinate are different.
|
|
119
|
-
|
|
120
|
-
## Author
|
|
121
|
-
|
|
122
|
-
* Name: Yusuke Aso
|
|
123
|
-
* Affiliation: Korea Astronomy and Space Science Institute
|
|
124
|
-
* E-mail: yaso@kasi.re.kr
|
|
125
|
-
|
|
126
|
-
## License
|
|
127
|
-
|
|
128
|
-
"plotastrodata" is under [GNU General Public License Version 3](https://www.gnu.org/licenses/gpl-3.0.html).
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
plotastrodata/__init__.py,sha256=HCHSCNsgiV12_NctDWo5ZJEXAxyI8zprnKp_J5UUINM,87
|
|
2
|
-
plotastrodata/analysis_utils.py,sha256=zfjIYzYUBNNpbIZyvbIpoj0imJz8jimbblmJ2EEPe70,37127
|
|
3
|
-
plotastrodata/const_utils.py,sha256=7clioUo-YTKq6CcXos8Ek1TY4CiNEo_V9ESA1Mu3g8g,3288
|
|
4
|
-
plotastrodata/coord_utils.py,sha256=S34puKwuiIz9HMbs5Cdew3TkWGIbmXWPirYiDCc4TRw,7077
|
|
5
|
-
plotastrodata/ext_utils.py,sha256=eVkC6-Elduj0j98bKNJUG-Z0TpxeHBZ_esCbzbwZglQ,2140
|
|
6
|
-
plotastrodata/fft_utils.py,sha256=7rl8r0hVS-bWJNO4pW2nkw_D-SBGAZ17W9TENobV6cE,17768
|
|
7
|
-
plotastrodata/fits_utils.py,sha256=Q_U--KNbcYjUKnz7uwZYD1jh2aip-znePUUx0KNLC2Y,18238
|
|
8
|
-
plotastrodata/fitting_utils.py,sha256=H1rfs937qxeLL1ackBP-NRWbKUKb8RApRYXB4zZ1lKY,29326
|
|
9
|
-
plotastrodata/los_utils.py,sha256=uG5t1nAmcnEDZ80VD2zB6s55LCHpY57zG89cuL9M0po,6406
|
|
10
|
-
plotastrodata/matrix_utils.py,sha256=rnxbhxnprDpZYFmXlVaSvNJXU5hw-21luYIbHsKYFzg,2275
|
|
11
|
-
plotastrodata/noise_utils.py,sha256=29gJRj9EWn5mTlWteLUvX_3pw25IhFVH8fG5bzRIf6k,8742
|
|
12
|
-
plotastrodata/other_utils.py,sha256=S-5K-SxR4GriS6-amDnbWBnt6stKmqhTVG-VZMtQtDs,11171
|
|
13
|
-
plotastrodata/plot_utils.py,sha256=vYCmfG6HEKV_sbHFvTfx3RGrM-q_zHMhtJ1tm8AVdzI,80651
|
|
14
|
-
plotastrodata-1.10.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
15
|
-
plotastrodata-1.10.1.dist-info/METADATA,sha256=qyLEyaZBDRgH-lmi0UNkD-kF0gG_0ZpbmZk6i9MF6nU,4717
|
|
16
|
-
plotastrodata-1.10.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
17
|
-
plotastrodata-1.10.1.dist-info/top_level.txt,sha256=mv2FRRtreGAUE_UF_Z_TYj_NZLECJqkQx7ErkA_Rttg,14
|
|
18
|
-
plotastrodata-1.10.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|