plotastrodata 1.2.4__tar.gz → 1.2.6__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.2.4 → plotastrodata-1.2.6}/PKG-INFO +1 -1
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/__init__.py +1 -1
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/analysis_utils.py +29 -19
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/fits_utils.py +7 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/plot_utils.py +8 -6
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata.egg-info/PKG-INFO +1 -1
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/LICENSE +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/README.md +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/const_utils.py +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/fft_utils.py +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/fitting_utils.py +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/los_utils.py +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata/other_utils.py +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata.egg-info/SOURCES.txt +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata.egg-info/dependency_links.txt +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata.egg-info/not-zip-safe +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata.egg-info/requires.txt +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/plotastrodata.egg-info/top_level.txt +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/setup.cfg +0 -0
- {plotastrodata-1.2.4 → plotastrodata-1.2.6}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.6
|
|
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,8 +65,8 @@ def quadrantmean(data: np.ndarray, x: np.ndarray, y: np.ndarray,
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
def RGIxy(y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
68
|
-
yxnew: tuple[np.ndarray, np.ndarray] | None = None
|
|
69
|
-
) -> object | np.ndarray:
|
|
68
|
+
yxnew: tuple[np.ndarray, np.ndarray] | None = None,
|
|
69
|
+
**kwargs) -> object | np.ndarray:
|
|
70
70
|
"""RGI for x and y at each channel.
|
|
71
71
|
|
|
72
72
|
Args:
|
|
@@ -82,9 +82,12 @@ def RGIxy(y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
|
82
82
|
print('data must be 2D, 3D, or 4D.')
|
|
83
83
|
return
|
|
84
84
|
|
|
85
|
+
_kw = {'bounds_error': False, 'fill_value': np.nan,
|
|
86
|
+
'method': 'linear'}
|
|
87
|
+
_kw.update(kwargs)
|
|
85
88
|
c4d = to4dim(data)
|
|
86
89
|
c4d[np.isnan(c4d)] = 0
|
|
87
|
-
f = [[RGI((y, x), c2d,
|
|
90
|
+
f = [[RGI((y, x), c2d, **_kw)
|
|
88
91
|
for c2d in c3d] for c3d in c4d]
|
|
89
92
|
if yxnew is None:
|
|
90
93
|
if len(f) == 1:
|
|
@@ -97,8 +100,8 @@ def RGIxy(y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
|
97
100
|
|
|
98
101
|
|
|
99
102
|
def RGIxyv(v: np.ndarray, y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
100
|
-
vyxnew: tuple[np.ndarray, np.ndarray, np.ndarray] | None = None
|
|
101
|
-
) -> object | np.ndarray:
|
|
103
|
+
vyxnew: tuple[np.ndarray, np.ndarray, np.ndarray] | None = None,
|
|
104
|
+
**kwargs) -> object | np.ndarray:
|
|
102
105
|
"""RGI in the x-y-v space.
|
|
103
106
|
|
|
104
107
|
Args:
|
|
@@ -115,9 +118,12 @@ def RGIxyv(v: np.ndarray, y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
|
115
118
|
print('data must be 3D or 4D.')
|
|
116
119
|
return
|
|
117
120
|
|
|
121
|
+
_kw = {'bounds_error': False, 'fill_value': np.nan,
|
|
122
|
+
'method': 'linear'}
|
|
123
|
+
_kw.update(kwargs)
|
|
118
124
|
c4d = to4dim(data)
|
|
119
125
|
c4d[np.isnan(c4d)] = 0
|
|
120
|
-
f = [RGI((v, y, x), c3d,
|
|
126
|
+
f = [RGI((v, y, x), c3d, **_kw) for c3d in c4d]
|
|
121
127
|
if vyxnew is None:
|
|
122
128
|
if len(f) == 1:
|
|
123
129
|
f = f[0]
|
|
@@ -126,8 +132,8 @@ def RGIxyv(v: np.ndarray, y: np.ndarray, x: np.ndarray, data: np.ndarray,
|
|
|
126
132
|
return np.squeeze([f3d(tuple(vyxnew)) for f3d in f])
|
|
127
133
|
|
|
128
134
|
|
|
129
|
-
def filled2d(data: np.ndarray, x: np.ndarray, y: np.ndarray, n: int = 1
|
|
130
|
-
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
135
|
+
def filled2d(data: np.ndarray, x: np.ndarray, y: np.ndarray, n: int = 1,
|
|
136
|
+
**kwargs) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
131
137
|
"""Fill 2D data, 1D x, and 1D y by a factor of n using RGI.
|
|
132
138
|
|
|
133
139
|
Args:
|
|
@@ -141,7 +147,8 @@ def filled2d(data: np.ndarray, x: np.ndarray, y: np.ndarray, n: int = 1
|
|
|
141
147
|
"""
|
|
142
148
|
xnew = np.linspace(x[0], x[-1], n * (len(x) - 1) + 1)
|
|
143
149
|
ynew = np.linspace(y[0], y[-1], n * (len(y) - 1) + 1)
|
|
144
|
-
d = RGIxy(y, x, data, np.meshgrid(ynew, xnew, indexing='ij')
|
|
150
|
+
d = RGIxy(y, x, data, np.meshgrid(ynew, xnew, indexing='ij'),
|
|
151
|
+
**kwargs)
|
|
145
152
|
return d, xnew, ynew
|
|
146
153
|
|
|
147
154
|
|
|
@@ -230,7 +237,8 @@ class AstroData():
|
|
|
230
237
|
self.data = np.squeeze(d)
|
|
231
238
|
_, self.v, self.y, self.x = grid
|
|
232
239
|
|
|
233
|
-
def centering(self, includexy: bool = True, includev: bool = False
|
|
240
|
+
def centering(self, includexy: bool = True, includev: bool = False,
|
|
241
|
+
**kwargs):
|
|
234
242
|
"""Spatial regridding to set the center at (x,y,v)=(0,0,0).
|
|
235
243
|
|
|
236
244
|
Args:
|
|
@@ -244,11 +252,13 @@ class AstroData():
|
|
|
244
252
|
vnew = self.v - self.v[np.argmin(np.abs(self.v))]
|
|
245
253
|
if includexy and includev:
|
|
246
254
|
self.data = RGIxyv(self.v, self.y, self.x, self.data,
|
|
247
|
-
np.meshgrid(vnew, ynew, xnew, indexing='ij')
|
|
255
|
+
np.meshgrid(vnew, ynew, xnew, indexing='ij'),
|
|
256
|
+
**kwargs)
|
|
248
257
|
self.v, self.y, self.x = vnew, ynew, xnew
|
|
249
258
|
elif includexy:
|
|
250
259
|
self.data = RGIxy(self.y, self.x, self.data,
|
|
251
|
-
np.meshgrid(ynew, xnew, indexing='ij')
|
|
260
|
+
np.meshgrid(ynew, xnew, indexing='ij'),
|
|
261
|
+
**kwargs)
|
|
252
262
|
self.y, self.x = ynew, xnew
|
|
253
263
|
elif includev:
|
|
254
264
|
nx, ny, nv = len(self.x), len(self.y), len(self.v)
|
|
@@ -286,7 +296,7 @@ class AstroData():
|
|
|
286
296
|
self.beam[1] = self.beam[0]
|
|
287
297
|
self.beam[2] = 0
|
|
288
298
|
|
|
289
|
-
def deproject(self, pa: float = 0, incl: float = 0):
|
|
299
|
+
def deproject(self, pa: float = 0, incl: float = 0, **kwargs):
|
|
290
300
|
"""Exapnd by a factor of 1/cos(incl) in the direction of pa+90 deg.
|
|
291
301
|
|
|
292
302
|
Args:
|
|
@@ -296,7 +306,7 @@ class AstroData():
|
|
|
296
306
|
ci = np.cos(np.radians(incl))
|
|
297
307
|
A = np.linalg.multi_dot([Mrot(pa), Mfac(1, ci), Mrot(-pa)])
|
|
298
308
|
yxnew = dot2d(A, np.meshgrid(self.y, self.x, indexing='ij'))
|
|
299
|
-
self.data = RGIxy(self.y, self.x, self.data, yxnew)
|
|
309
|
+
self.data = RGIxy(self.y, self.x, self.data, yxnew, **kwargs)
|
|
300
310
|
if None not in self.beam:
|
|
301
311
|
bmaj, bmin, bpa = self.beam
|
|
302
312
|
a, b = np.linalg.multi_dot([Mfac(1/bmaj, 1/bmin), Mrot(pa-bpa),
|
|
@@ -494,19 +504,19 @@ class AstroData():
|
|
|
494
504
|
gfitres = {'best': best, 'error': error}
|
|
495
505
|
return v, prof, gfitres
|
|
496
506
|
|
|
497
|
-
def rotate(self, pa: float = 0):
|
|
507
|
+
def rotate(self, pa: float = 0, **kwargs):
|
|
498
508
|
"""Counter clockwise rotation with respect to the center.
|
|
499
509
|
|
|
500
510
|
Args:
|
|
501
511
|
pa (float, optional): Position angle in the unit of degree. Defaults to 0.
|
|
502
512
|
"""
|
|
503
513
|
yxnew = dot2d(Mrot(-pa), np.meshgrid(self.y, self.x, indexing='ij'))
|
|
504
|
-
self.data = RGIxy(self.y, self.x, self.data, yxnew)
|
|
514
|
+
self.data = RGIxy(self.y, self.x, self.data, yxnew, **kwargs)
|
|
505
515
|
if self.beam[2] is not None:
|
|
506
516
|
self.beam[2] = self.beam[2] + pa
|
|
507
517
|
|
|
508
518
|
def slice(self, length: float = 0, pa: float = 0,
|
|
509
|
-
dx: float | None = None) -> np.ndarray:
|
|
519
|
+
dx: float | None = None, **kwargs) -> np.ndarray:
|
|
510
520
|
"""Get 1D slice with given a length and a position-angle.
|
|
511
521
|
|
|
512
522
|
Args:
|
|
@@ -523,7 +533,7 @@ class AstroData():
|
|
|
523
533
|
r = np.linspace(-n, n, 2 * n + 1) * dx
|
|
524
534
|
pa_rad = np.radians(pa)
|
|
525
535
|
yg, xg = r * np.cos(pa_rad), r * np.sin(pa_rad)
|
|
526
|
-
z = RGIxy(self.y, self.x, self.data, (yg, xg))
|
|
536
|
+
z = RGIxy(self.y, self.x, self.data, (yg, xg), **kwargs)
|
|
527
537
|
return np.array([r, z])
|
|
528
538
|
|
|
529
539
|
def todict(self) -> dict:
|
|
@@ -738,7 +748,7 @@ class AstroFrame():
|
|
|
738
748
|
restfreq=d.restfreq[i], vsys=self.vsys,
|
|
739
749
|
pv=self.pv)
|
|
740
750
|
d.beam[i] = fd.get_beam(dist=self.dist)
|
|
741
|
-
d.bunit[i] =
|
|
751
|
+
d.bunit[i] = fd.get_header('BUNIT')
|
|
742
752
|
if d.data[i] is not None:
|
|
743
753
|
d.pv[i] = self.pv
|
|
744
754
|
d.sigma_org[i] = d.sigma[i]
|
|
@@ -128,6 +128,13 @@ class FitsData:
|
|
|
128
128
|
Returns:
|
|
129
129
|
str: The central coordinates.
|
|
130
130
|
"""
|
|
131
|
+
cunit1 = self.get_header('CUNIT1').strip()
|
|
132
|
+
cunit2 = self.get_header('CUNIT2').strip()
|
|
133
|
+
good = (cunit1 in ['deg', 'DEG', 'degree', 'DEGREE']
|
|
134
|
+
and cunit2 in ['deg', 'DEG', 'degree', 'DEGREE'])
|
|
135
|
+
if not good:
|
|
136
|
+
print(f'CUNIT1=\'{cunit1}\' and CUNIT2=\'{cunit2}\'. \'center\' is ignored.')
|
|
137
|
+
return None
|
|
131
138
|
ra_deg = self.get_header('CRVAL1')
|
|
132
139
|
dec_deg = self.get_header('CRVAL2')
|
|
133
140
|
radesys = self.get_header('RADESYS')
|
|
@@ -80,9 +80,9 @@ class PlotAxes2D():
|
|
|
80
80
|
xticklabels (list, optional): Defaults to None.
|
|
81
81
|
yticklabels (list, optional): Defaults to None.
|
|
82
82
|
xticksminor (list or int, optional): If int, int times more than xticks. Defaults to None.
|
|
83
|
-
yticksminor (list
|
|
83
|
+
yticksminor (list or int, optional): Defaults to None. If int, int times more than xticks. Defaults to None.
|
|
84
84
|
grid (dict, optional): True means merely grid(). Defaults to None.
|
|
85
|
-
aspect (float, optional): Defaults to None.
|
|
85
|
+
aspect (dict or float, optional): Defaults to None.
|
|
86
86
|
"""
|
|
87
87
|
samexy: bool = True
|
|
88
88
|
loglog: bool | None = None
|
|
@@ -99,7 +99,7 @@ class PlotAxes2D():
|
|
|
99
99
|
xticksminor: list | int = None
|
|
100
100
|
yticksminor: list | int = None
|
|
101
101
|
grid: dict | None = None
|
|
102
|
-
aspect: float | None = None
|
|
102
|
+
aspect: dict | float | None = None
|
|
103
103
|
|
|
104
104
|
def set_xyaxes(self, ax):
|
|
105
105
|
if self.loglog is not None:
|
|
@@ -159,7 +159,10 @@ class PlotAxes2D():
|
|
|
159
159
|
if self.grid is not None:
|
|
160
160
|
ax.grid(**({} if self.grid is True else self.grid))
|
|
161
161
|
if self.aspect is not None:
|
|
162
|
-
|
|
162
|
+
if type(self.aspect) is dict:
|
|
163
|
+
ax.set_aspect(**self.aspect)
|
|
164
|
+
else:
|
|
165
|
+
ax.set_aspect(self.aspect)
|
|
163
166
|
|
|
164
167
|
|
|
165
168
|
def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
|
|
@@ -500,8 +503,7 @@ class PlotAstroData(AstroFrame):
|
|
|
500
503
|
bp = [a, 0.1 if self.pv else a]
|
|
501
504
|
if self.swapxy:
|
|
502
505
|
bp = np.transpose(bp)
|
|
503
|
-
|
|
504
|
-
bmaj, bmin = bmin, bmaj
|
|
506
|
+
bpa = 90 - bpa
|
|
505
507
|
self.add_region(patch=patch, poslist=bp,
|
|
506
508
|
majlist=bmaj, minlist=bmin, palist=bpa,
|
|
507
509
|
include_chan=include_chan,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.6
|
|
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
|