plotastrodata 1.2.9__tar.gz → 1.3.0__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.9 → plotastrodata-1.3.0}/PKG-INFO +1 -1
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/__init__.py +1 -1
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/analysis_utils.py +26 -19
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/fits_utils.py +7 -8
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/other_utils.py +15 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/plot_utils.py +12 -12
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata.egg-info/PKG-INFO +1 -1
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/LICENSE +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/README.md +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/const_utils.py +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/fft_utils.py +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/fitting_utils.py +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata/los_utils.py +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata.egg-info/SOURCES.txt +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata.egg-info/dependency_links.txt +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata.egg-info/not-zip-safe +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata.egg-info/requires.txt +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/plotastrodata.egg-info/top_level.txt +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/setup.cfg +0 -0
- {plotastrodata-1.2.9 → plotastrodata-1.3.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
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
|
|
@@ -5,7 +5,7 @@ from scipy.optimize import curve_fit
|
|
|
5
5
|
from scipy.signal import convolve
|
|
6
6
|
|
|
7
7
|
from plotastrodata.other_utils import (coord2xy, rel2abs, estimate_rms, trim,
|
|
8
|
-
Mfac, Mrot, dot2d, gaussian2d)
|
|
8
|
+
isdeg, Mfac, Mrot, dot2d, gaussian2d)
|
|
9
9
|
from plotastrodata.fits_utils import FitsData, data2fits, Jy2K
|
|
10
10
|
from plotastrodata import const_utils as cu
|
|
11
11
|
from plotastrodata.fitting_utils import EmceeCorner
|
|
@@ -553,29 +553,36 @@ class AstroData():
|
|
|
553
553
|
fitsimage (str, optional): Output FITS file name. Defaults to 'out.fits'.
|
|
554
554
|
header (dict, optional): Header dictionary. Defaults to {}.
|
|
555
555
|
"""
|
|
556
|
-
|
|
557
|
-
print('writetofits does not support PV diagram yet.')
|
|
558
|
-
return
|
|
559
|
-
|
|
556
|
+
fhd = self.fitsheader
|
|
560
557
|
h = {}
|
|
561
|
-
cx, cy = (0, 0) if self.center is None else coord2xy(self.center)
|
|
558
|
+
cx, cy = (0, 0) if self.pv or self.center is None else coord2xy(self.center)
|
|
562
559
|
h['NAXIS1'] = len(self.x)
|
|
563
560
|
h['CRPIX1'] = np.argmin(np.abs(self.x)) + 1
|
|
564
561
|
h['CRVAL1'] = cx
|
|
565
|
-
h['CDELT1'] =
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
h['
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
h['
|
|
562
|
+
h['CDELT1'] = self.x[1] - self.x[0]
|
|
563
|
+
if fhd is not None and isdeg(fhd['CUNIT1']):
|
|
564
|
+
h['CDELT1'] = h['CDELT1'] / 3600
|
|
565
|
+
vaxis = '2' if self.pv else '3'
|
|
566
|
+
h[f'NAXIS{vaxis}'] = len(self.v)
|
|
567
|
+
h[f'CRPIX{vaxis}'] = i = np.argmin(np.abs(self.v)) + 1
|
|
568
|
+
h[f'CRVAL{vaxis}'] = (1 - self.v[i]/cu.c_kms) * self.restfreq
|
|
569
|
+
h[f'CDELT{vaxis}'] = (self.v[0]-self.v[1]) / cu.c_kms * self.restfreq
|
|
570
|
+
if not self.pv:
|
|
571
|
+
h['NAXIS2'] = len(self.y)
|
|
572
|
+
h['CRPIX2'] = np.argmin(np.abs(self.y)) + 1
|
|
573
|
+
h['CRVAL2'] = cy
|
|
574
|
+
h['CDELT2'] = self.y[1] - self.y[0]
|
|
575
|
+
if fhd is not None and isdeg(fhd['CUNIT2']):
|
|
576
|
+
h['CDELT2'] = h['CDELT2'] / 3600
|
|
575
577
|
if None not in self.beam:
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
578
|
+
if self.pv:
|
|
579
|
+
h['BMAJ'] = self.beam_org[0] / 3600
|
|
580
|
+
h['BMIN'] = self.beam_org[1] / 3600
|
|
581
|
+
h['BPA'] = self.beam_org[2]
|
|
582
|
+
else:
|
|
583
|
+
h['BMAJ'] = self.beam[0] / 3600
|
|
584
|
+
h['BMIN'] = self.beam[1] / 3600
|
|
585
|
+
h['BPA'] = self.beam[2]
|
|
579
586
|
h0 = header
|
|
580
587
|
for k in h:
|
|
581
588
|
if k not in h0:
|
|
@@ -2,7 +2,8 @@ import numpy as np
|
|
|
2
2
|
from astropy.io import fits
|
|
3
3
|
from astropy import units, wcs
|
|
4
4
|
|
|
5
|
-
from plotastrodata.other_utils import coord2xy, xy2coord,
|
|
5
|
+
from plotastrodata.other_utils import (coord2xy, xy2coord,
|
|
6
|
+
estimate_rms, trim, isdeg)
|
|
6
7
|
from plotastrodata import const_utils as cu
|
|
7
8
|
|
|
8
9
|
|
|
@@ -128,11 +129,9 @@ class FitsData:
|
|
|
128
129
|
Returns:
|
|
129
130
|
str: The central coordinates.
|
|
130
131
|
"""
|
|
131
|
-
cunit1 = self.get_header('CUNIT1')
|
|
132
|
-
cunit2 = self.get_header('CUNIT2')
|
|
133
|
-
|
|
134
|
-
and cunit2 in ['deg', 'DEG', 'degree', 'DEGREE'])
|
|
135
|
-
if not good:
|
|
132
|
+
cunit1 = self.get_header('CUNIT1')
|
|
133
|
+
cunit2 = self.get_header('CUNIT2')
|
|
134
|
+
if not (isdeg(cunit1) and isdeg(cunit2)):
|
|
136
135
|
print(f'CUNIT1=\'{cunit1}\' and CUNIT2=\'{cunit2}\'. \'center\' is ignored.')
|
|
137
136
|
return None
|
|
138
137
|
ra_deg = self.get_header('CRVAL1')
|
|
@@ -215,13 +214,13 @@ class FitsData:
|
|
|
215
214
|
|
|
216
215
|
def gen_x(s: np.ndarray) -> None:
|
|
217
216
|
s = (s - cx) * dist
|
|
218
|
-
if h['CUNIT1']
|
|
217
|
+
if isdeg(h['CUNIT1']):
|
|
219
218
|
s *= 3600.
|
|
220
219
|
self.x, self.dx = s, s[1] - s[0]
|
|
221
220
|
|
|
222
221
|
def gen_y(s: np.ndarray) -> None:
|
|
223
222
|
s = (s - cy) * dist
|
|
224
|
-
if h['CUNIT2']
|
|
223
|
+
if isdeg(h['CUNIT2']):
|
|
225
224
|
s *= 3600.
|
|
226
225
|
self.y, self.dy = s, s[1] - s[0]
|
|
227
226
|
|
|
@@ -42,6 +42,21 @@ def listing(*args) -> list:
|
|
|
42
42
|
return b
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
def isdeg(s: str) -> bool:
|
|
46
|
+
"""Whether the given string means degree.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
s (str): The string to be checked.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
bool: Whether the given string means degree.
|
|
53
|
+
"""
|
|
54
|
+
if type(s) is str:
|
|
55
|
+
return s.strip() in ['deg', 'DEG', 'degree', 'DEGREE']
|
|
56
|
+
else:
|
|
57
|
+
return False
|
|
58
|
+
|
|
59
|
+
|
|
45
60
|
def _getframe(coord: str, s: str = '') -> tuple:
|
|
46
61
|
"""Internal function to pick up the frame name from the coordinates.
|
|
47
62
|
|
|
@@ -610,7 +610,7 @@ class PlotAstroData(AstroFrame):
|
|
|
610
610
|
|
|
611
611
|
def add_scalebar(self, length: float = 0, label: str = '',
|
|
612
612
|
color: str = 'gray', barpos: tuple[float, float] = (0.8, 0.12),
|
|
613
|
-
fontsize: float = None, linewidth: float = 3,
|
|
613
|
+
fontsize: float | None = None, linewidth: float = 3,
|
|
614
614
|
bbox: dict = {'alpha': 0}) -> None:
|
|
615
615
|
"""Use Axes.text and Axes.plot of matplotlib.
|
|
616
616
|
|
|
@@ -622,8 +622,8 @@ class PlotAstroData(AstroFrame):
|
|
|
622
622
|
fontsize (float, optional): None means 15 if one channel else 20. Defaults to None.
|
|
623
623
|
linewidth (float, optional): Width of the bar. Defaults to 3.
|
|
624
624
|
"""
|
|
625
|
-
if length == 0
|
|
626
|
-
print('Please input length
|
|
625
|
+
if length == 0:
|
|
626
|
+
print('Please input length to add_scalebar().')
|
|
627
627
|
return
|
|
628
628
|
if fontsize is None:
|
|
629
629
|
fontsize = 20 if len(self.ax) == 1 else 15
|
|
@@ -857,16 +857,16 @@ class PlotAstroData(AstroFrame):
|
|
|
857
857
|
print('RGB shapes mismatch. Skip add_rgb.')
|
|
858
858
|
return
|
|
859
859
|
|
|
860
|
-
for i in
|
|
861
|
-
|
|
862
|
-
|
|
860
|
+
for i, (cmin, cmax) in enumerate(zip(_kw['vmin'], _kw['vmax'])):
|
|
861
|
+
if cmax > cmin:
|
|
862
|
+
c[i] = (c[i] - cmin) / (cmax - cmin) * 255
|
|
863
863
|
c[i] = self.vskipfill(c[i], v)
|
|
864
|
-
size = np.shape(c[0][0])
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
for j in range(size[
|
|
869
|
-
for i in range(size[
|
|
864
|
+
size = np.shape(c[0][0])[::-1]
|
|
865
|
+
c = np.moveaxis(c, 1, 0)[:, :, ::-self.ydir, ::-self.xdir]
|
|
866
|
+
for axnow, rgb in zip(self.ax, c):
|
|
867
|
+
im = Image.new('RGB', size, (128, 128, 128))
|
|
868
|
+
for j in range(size[1]):
|
|
869
|
+
for i in range(size[0]):
|
|
870
870
|
value = tuple(int(a[j, i]) for a in rgb)
|
|
871
871
|
im.putpixel((i, j), value)
|
|
872
872
|
axnow.imshow(im, extent=[x[0], x[-1], y[0], y[-1]])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
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
|