plotastrodata 1.6.5__tar.gz → 1.7.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.6.5 → plotastrodata-1.7.1}/PKG-INFO +2 -2
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/__init__.py +1 -1
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/analysis_utils.py +7 -6
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/other_utils.py +17 -12
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/plot_utils.py +36 -17
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata.egg-info/PKG-INFO +2 -2
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/setup.cfg +1 -1
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/LICENSE +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/README.md +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/const_utils.py +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/coord_utils.py +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/ext_utils.py +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/fft_utils.py +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/fits_utils.py +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/fitting_utils.py +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/los_utils.py +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata/matrix_utils.py +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata.egg-info/SOURCES.txt +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata.egg-info/dependency_links.txt +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata.egg-info/not-zip-safe +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata.egg-info/requires.txt +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.1}/plotastrodata.egg-info/top_level.txt +0 -0
- {plotastrodata-1.6.5 → plotastrodata-1.7.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.7.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
|
|
@@ -8,7 +8,7 @@ Author: yusukeaso-astron
|
|
|
8
8
|
License: GNU General Public License Version 3
|
|
9
9
|
Keywords: astronomy,FITS,plot
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: astropy>=7.2
|
|
@@ -527,12 +527,13 @@ class AstroData():
|
|
|
527
527
|
h['CDELT1'] = self.dx
|
|
528
528
|
if fhd is not None and isdeg(fhd['CUNIT1']):
|
|
529
529
|
h['CDELT1'] = h['CDELT1'] / 3600
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
530
|
+
if self.dv is not None:
|
|
531
|
+
vaxis = '2' if self.pv else '3'
|
|
532
|
+
h[f'NAXIS{vaxis}'] = len(self.v)
|
|
533
|
+
k_vmin = np.argmin(np.abs(self.v))
|
|
534
|
+
h[f'CRPIX{vaxis}'] = k_vmin + 1
|
|
535
|
+
h[f'CRVAL{vaxis}'] = (1 - self.v[k_vmin]/cu.c_kms) * self.restfreq
|
|
536
|
+
h[f'CDELT{vaxis}'] = -self.dv / cu.c_kms * self.restfreq
|
|
536
537
|
if not self.pv:
|
|
537
538
|
h['NAXIS2'] = len(self.y)
|
|
538
539
|
h['CRPIX2'] = np.argmin(np.abs(self.y)) + 1
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
import numpy as np
|
|
2
|
-
from scipy.optimize import curve_fit
|
|
3
|
+
from scipy.optimize import curve_fit, OptimizeWarning
|
|
3
4
|
from scipy.special import erf
|
|
4
5
|
from scipy.interpolate import RegularGridInterpolator as RGI
|
|
5
6
|
|
|
@@ -59,6 +60,11 @@ def estimate_rms(data: np.ndarray, sigma: float | str | None = 'hist'
|
|
|
59
60
|
if sigma is None:
|
|
60
61
|
return None
|
|
61
62
|
|
|
63
|
+
def warning_offset(ave, noise):
|
|
64
|
+
if np.abs(ave) > 0.2 * noise:
|
|
65
|
+
s = 'The intensity offset is larger than 0.2 sigma.'
|
|
66
|
+
warnings.warn(s, UserWarning)
|
|
67
|
+
|
|
62
68
|
nums = [float, int, np.float64, np.int64, np.float32, np.int32]
|
|
63
69
|
if type(sigma) in nums:
|
|
64
70
|
noise = sigma
|
|
@@ -68,8 +74,7 @@ def estimate_rms(data: np.ndarray, sigma: float | str | None = 'hist'
|
|
|
68
74
|
elif sigma == 'edge':
|
|
69
75
|
ave = np.nanmean(data[::len(data) - 1])
|
|
70
76
|
noise = np.nanstd(data[::len(data) - 1])
|
|
71
|
-
|
|
72
|
-
print('Warning: The intensity offset is larger than 0.2 sigma.')
|
|
77
|
+
warning_offset(ave, noise)
|
|
73
78
|
elif sigma == 'neg':
|
|
74
79
|
noise = np.sqrt(np.nanmean(data[data < 0]**2))
|
|
75
80
|
elif sigma == 'med':
|
|
@@ -82,8 +87,7 @@ def estimate_rms(data: np.ndarray, sigma: float | str | None = 'hist'
|
|
|
82
87
|
n = n[np.abs(n) < 3.5 * sig]
|
|
83
88
|
ave = np.nanmean(n)
|
|
84
89
|
noise = np.nanstd(n)
|
|
85
|
-
|
|
86
|
-
print('Warning: The intensity offset is larger than 0.2 sigma.')
|
|
90
|
+
warning_offset(ave, noise)
|
|
87
91
|
elif sigma == 'out':
|
|
88
92
|
n, n0, n1 = data.copy(), len(data), len(data[0])
|
|
89
93
|
n = np.moveaxis(n, [-2, -1], [0, 1])
|
|
@@ -95,8 +99,7 @@ def estimate_rms(data: np.ndarray, sigma: float | str | None = 'hist'
|
|
|
95
99
|
else:
|
|
96
100
|
ave = np.nanmean(n)
|
|
97
101
|
noise = np.nanstd(n)
|
|
98
|
-
|
|
99
|
-
print('Warning: The intensity offset is larger than 0.2 sigma.')
|
|
102
|
+
warning_offset(ave, noise)
|
|
100
103
|
elif sigma[:4] == 'hist':
|
|
101
104
|
m0, s0 = np.nanmean(data), np.nanstd(data)
|
|
102
105
|
hist, hbin = np.histogram(data[~np.isnan(data)],
|
|
@@ -108,13 +111,15 @@ def estimate_rms(data: np.ndarray, sigma: float | str | None = 'hist'
|
|
|
108
111
|
xn = (x - c) / np.sqrt(2) / s
|
|
109
112
|
return (erf(xn) - erf(xn * np.exp(-R**2))) / (2 * (x-c) * R**2)
|
|
110
113
|
else:
|
|
111
|
-
def g(x, s, c,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
def g(x, s, c, _):
|
|
115
|
+
xn = (x - c) / np.sqrt(2) / s
|
|
116
|
+
return np.exp(-xn**2) / np.sqrt(2 * np.pi) / s
|
|
117
|
+
with warnings.catch_warnings():
|
|
118
|
+
warnings.simplefilter('ignore', OptimizeWarning)
|
|
119
|
+
popt, _ = curve_fit(g, hbin, hist, p0=[1, 0, 1])
|
|
114
120
|
ave = popt[1]
|
|
115
121
|
noise = popt[0]
|
|
116
|
-
|
|
117
|
-
print('Warning: The intensity offset is larger than 0.2 sigma.')
|
|
122
|
+
warning_offset(ave, noise)
|
|
118
123
|
noise = noise * s0
|
|
119
124
|
return noise
|
|
120
125
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
import numpy as np
|
|
2
3
|
import matplotlib as mpl
|
|
3
4
|
import matplotlib.pyplot as plt
|
|
@@ -433,7 +434,8 @@ class PlotAstroData(AstroFrame):
|
|
|
433
434
|
self.channelnumber = channelnumber
|
|
434
435
|
self.v = v
|
|
435
436
|
|
|
436
|
-
def vskipfill(c: np.ndarray,
|
|
437
|
+
def vskipfill(c: np.ndarray,
|
|
438
|
+
v_in: np.ndarray | None = None
|
|
437
439
|
) -> np.ndarray:
|
|
438
440
|
"""Skip and fill channels with nan.
|
|
439
441
|
|
|
@@ -444,23 +446,36 @@ class PlotAstroData(AstroFrame):
|
|
|
444
446
|
Returns:
|
|
445
447
|
np.ndarray: 3D arrays skipped and filled with nan.
|
|
446
448
|
"""
|
|
447
|
-
if np.ndim(c) ==
|
|
449
|
+
if np.ndim(c) == 2:
|
|
450
|
+
d = np.full((nv, *np.shape(c)), c)
|
|
451
|
+
elif np.ndim(c) == 3:
|
|
448
452
|
if v_in is not None:
|
|
449
453
|
dv_org = self.v[1] - self.v[0]
|
|
450
|
-
dv_in = v_in[1] - v_in[0]
|
|
451
|
-
if np.abs(dv_in - dv_org) / dv_org > 0.01:
|
|
452
|
-
print('Velocity resolution mismatch (>1%).',
|
|
453
|
-
'The cube needs to be regridded',
|
|
454
|
-
'outside plotastrodata.')
|
|
454
|
+
dv_in = (v_in[1] - v_in[0]) * vskip
|
|
455
455
|
k0 = np.argmin(np.abs(self.v - v_in[0]))
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
d = np.append(prenan, c, axis=0)
|
|
459
|
-
else:
|
|
456
|
+
k1 = np.argmin(np.abs(self.v - v_in[-1]))
|
|
457
|
+
if np.abs(dv_in - dv_org) / dv_org < 0.01:
|
|
460
458
|
d = c
|
|
459
|
+
else:
|
|
460
|
+
s = 'Velocity resolution mismatch (>1%).' \
|
|
461
|
+
+ ' The cube needs to be regridded' \
|
|
462
|
+
+ ' outside plotastrodata.'
|
|
463
|
+
warnings.warn(s, UserWarning)
|
|
464
|
+
n_valid = k1 - k0
|
|
465
|
+
d = [None] * n_valid
|
|
466
|
+
for k in range(n_valid):
|
|
467
|
+
k_tmp = np.argmin(np.abs(v_in - self.v[k]))
|
|
468
|
+
diffvel = np.abs(v_in[k_tmp] - self.v[k])
|
|
469
|
+
nearby = diffvel < dv_org * 0.5
|
|
470
|
+
d[k] = c[k_tmp] if nearby else c[0] * np.nan
|
|
471
|
+
d = np.array(d)
|
|
472
|
+
if k0 > 0:
|
|
473
|
+
prenan = np.full((k0, *np.shape(d)[1:]), np.nan)
|
|
474
|
+
d = np.append(prenan, d, axis=0)
|
|
461
475
|
d = d[::vskip]
|
|
462
476
|
else:
|
|
463
|
-
|
|
477
|
+
print('c must be 2D or 3D.')
|
|
478
|
+
return
|
|
464
479
|
n = nchan if channelnumber is None else nv
|
|
465
480
|
shape = (n - len(d), len(d[0]), len(d[0, 0]))
|
|
466
481
|
postnan = np.full(shape, d[0] * np.nan)
|
|
@@ -756,8 +771,11 @@ class PlotAstroData(AstroFrame):
|
|
|
756
771
|
c = self.vskipfill(c, v)
|
|
757
772
|
if type(self.channelnumber) is int:
|
|
758
773
|
c = [c[self.channelnumber]]
|
|
759
|
-
|
|
760
|
-
|
|
774
|
+
p = [None] * len(self.ax)
|
|
775
|
+
for ch, (axnow, cnow) in enumerate(zip(self.ax, c)):
|
|
776
|
+
pnow = axnow.pcolormesh(x, y, cnow, **_kw)
|
|
777
|
+
if ch in self.bottomleft:
|
|
778
|
+
p[ch] = pnow
|
|
761
779
|
for ch in self.bottomleft:
|
|
762
780
|
if not show_cbar:
|
|
763
781
|
break
|
|
@@ -768,12 +786,13 @@ class PlotAstroData(AstroFrame):
|
|
|
768
786
|
else:
|
|
769
787
|
fig = self.fig
|
|
770
788
|
if len(self.ax) == 1:
|
|
771
|
-
ax = self.ax[
|
|
772
|
-
cb = fig.colorbar(p, ax=ax, label=cblabel,
|
|
789
|
+
ax = self.ax[ch]
|
|
790
|
+
cb = fig.colorbar(p[ch], ax=ax, label=cblabel,
|
|
773
791
|
format=cbformat, location=cblocation)
|
|
774
792
|
else:
|
|
775
793
|
cax = plt.axes([0.88, 0.105, 0.015, 0.77])
|
|
776
|
-
cb = fig.colorbar(p, cax=cax, label=cblabel,
|
|
794
|
+
cb = fig.colorbar(p[ch], cax=cax, label=cblabel,
|
|
795
|
+
format=cbformat)
|
|
777
796
|
cb.ax.tick_params(labelsize=14)
|
|
778
797
|
font = mpl.font_manager.FontProperties(size=16)
|
|
779
798
|
cb.ax.yaxis.label.set_font_properties(font)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.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
|
|
@@ -8,7 +8,7 @@ Author: yusukeaso-astron
|
|
|
8
8
|
License: GNU General Public License Version 3
|
|
9
9
|
Keywords: astronomy,FITS,plot
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: astropy>=7.2
|
|
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
|