plotastrodata 1.8.3__tar.gz → 1.8.4__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.8.3/plotastrodata.egg-info → plotastrodata-1.8.4}/PKG-INFO +1 -1
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/__init__.py +1 -1
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/analysis_utils.py +7 -7
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/coord_utils.py +1 -1
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/fft_utils.py +24 -27
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/fits_utils.py +3 -3
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/fitting_utils.py +23 -36
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/matrix_utils.py +1 -1
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/noise_utils.py +3 -4
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/other_utils.py +6 -5
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/plot_utils.py +5 -5
- {plotastrodata-1.8.3 → plotastrodata-1.8.4/plotastrodata.egg-info}/PKG-INFO +1 -1
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/LICENSE +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/MANIFEST.in +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/README.md +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/const_utils.py +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/ext_utils.py +2 -2
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata/los_utils.py +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata.egg-info/SOURCES.txt +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata.egg-info/dependency_links.txt +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata.egg-info/not-zip-safe +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata.egg-info/requires.txt +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/plotastrodata.egg-info/top_level.txt +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/setup.cfg +0 -0
- {plotastrodata-1.8.3 → plotastrodata-1.8.4}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.4
|
|
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
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import warnings
|
|
2
1
|
import numpy as np
|
|
2
|
+
import warnings
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from scipy.interpolate import RegularGridInterpolator as RGI
|
|
5
5
|
from scipy.optimize import curve_fit
|
|
6
6
|
from scipy.signal import convolve
|
|
7
7
|
|
|
8
|
-
from plotastrodata.coord_utils import coord2xy, xy2coord, rel2abs
|
|
9
|
-
from plotastrodata.matrix_utils import Mfac, Mrot, dot2d
|
|
10
|
-
from plotastrodata.noise_utils import estimate_rms
|
|
11
|
-
from plotastrodata.other_utils import (trim, gaussian2d, isdeg,
|
|
12
|
-
RGIxy, RGIxyv, to4dim)
|
|
13
|
-
from plotastrodata.fits_utils import FitsData, data2fits, Jy2K
|
|
14
8
|
from plotastrodata import const_utils as cu
|
|
9
|
+
from plotastrodata.coord_utils import coord2xy, rel2abs, xy2coord
|
|
10
|
+
from plotastrodata.fits_utils import data2fits, FitsData, Jy2K
|
|
15
11
|
from plotastrodata.fitting_utils import EmceeCorner
|
|
12
|
+
from plotastrodata.matrix_utils import dot2d, Mfac, Mrot
|
|
13
|
+
from plotastrodata.noise_utils import estimate_rms
|
|
14
|
+
from plotastrodata.other_utils import (gaussian2d, isdeg,
|
|
15
|
+
RGIxy, RGIxyv, to4dim, trim)
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def quadrantmean(data: np.ndarray, x: np.ndarray, y: np.ndarray,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import numpy as np
|
|
2
1
|
import matplotlib.pyplot as plt
|
|
2
|
+
import numpy as np
|
|
3
3
|
|
|
4
4
|
from plotastrodata.fits_utils import fits2data
|
|
5
|
-
from plotastrodata.
|
|
5
|
+
from plotastrodata.other_utils import close_figure
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def shiftphase(F: np.ndarray, u: np.ndarray,
|
|
@@ -198,7 +198,9 @@ def zeropadding(f: np.ndarray, x: np.ndarray, y: np.ndarray,
|
|
|
198
198
|
|
|
199
199
|
def fftfits(fitsimage: str, center: str | None = None, lam: float = 1,
|
|
200
200
|
xlim: list | None = None, ylim: list | None = None,
|
|
201
|
-
|
|
201
|
+
savefig: dict | str | None = None,
|
|
202
|
+
show: bool = False,
|
|
203
|
+
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
202
204
|
"""FFT a fits image with the phase referring to a specific point.
|
|
203
205
|
|
|
204
206
|
Args:
|
|
@@ -207,7 +209,8 @@ def fftfits(fitsimage: str, center: str | None = None, lam: float = 1,
|
|
|
207
209
|
lam (float, optional): Return u * lam and v * lam. Defaults to 1.
|
|
208
210
|
xlim (list, optional): Range of x for zero padding in arcsec.
|
|
209
211
|
ylim (list, optional): Range of y for zero padding in arcsec.
|
|
210
|
-
|
|
212
|
+
savefig (dict or str, optional): For plt.figure().savefig(). Defaults to None.
|
|
213
|
+
show (bool, optional): True means doing plt.show(). Defaults to False.
|
|
211
214
|
|
|
212
215
|
Returns:
|
|
213
216
|
tuple: (F, u, v). F is FFT of f in the unit of Jy. u and v are 1D arrays in the unit of lambda or meter if lam it not unity.
|
|
@@ -215,32 +218,26 @@ def fftfits(fitsimage: str, center: str | None = None, lam: float = 1,
|
|
|
215
218
|
f, (x, y, v), _, _, _ = fits2data(fitsimage, center=center)
|
|
216
219
|
if xlim is not None and ylim is not None:
|
|
217
220
|
f, x, y = zeropadding(f, x, y, xlim, ylim)
|
|
221
|
+
f[np.isnan(f)] = 0
|
|
218
222
|
arcsec = np.radians(1) / 3600.
|
|
219
223
|
F, u, v = fftcentering2(f, x * arcsec, y * arcsec)
|
|
220
224
|
u, v = u * lam, v * lam
|
|
221
|
-
if
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
m =
|
|
230
|
-
|
|
231
|
-
ax
|
|
232
|
-
m = ax.pcolormesh(u, v, np.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
ax.
|
|
236
|
-
|
|
237
|
-
m = ax.pcolormesh(u, v, np.angle(F) * np.degrees(1),
|
|
238
|
-
shading='nearest', cmap='jet')
|
|
239
|
-
fig.colorbar(m, ax=ax, label='Phase (deg)', format='%.0f')
|
|
240
|
-
ax.set_xlabel(r'u ($\lambda$)')
|
|
241
|
-
fig.tight_layout()
|
|
242
|
-
plt.show()
|
|
243
|
-
plt.close()
|
|
225
|
+
if savefig is not None or show:
|
|
226
|
+
fig, ax = plt.subplots(2, 2, figsize=(10, 8))
|
|
227
|
+
m = ax[0, 0].pcolormesh(u, v, np.real(F), cmap='jet')
|
|
228
|
+
fig.colorbar(m, ax=ax[0, 0], label='Real', format='%.1e')
|
|
229
|
+
ax[0, 0].set_ylabel(r'v ($\lambda$)')
|
|
230
|
+
m = ax[0, 1].pcolormesh(u, v, np.imag(F), cmap='jet')
|
|
231
|
+
fig.colorbar(m, ax=ax[0, 1], label='Imaginary', format='%.1e')
|
|
232
|
+
m = ax[1, 0].pcolormesh(u, v, np.abs(F), cmap='jet')
|
|
233
|
+
fig.colorbar(m, ax=ax[1, 0], label='Amplitude', format='%.1e')
|
|
234
|
+
ax[1, 0].set_xlabel(r'u ($\lambda$)')
|
|
235
|
+
ax[1, 0].set_ylabel(r'v ($\lambda$)')
|
|
236
|
+
m = ax[1, 1].pcolormesh(u, v, np.angle(F) * np.degrees(1),
|
|
237
|
+
cmap='jet')
|
|
238
|
+
fig.colorbar(m, ax=ax[1, 1], label='Phase (deg)', format='%.0f')
|
|
239
|
+
ax[1, 1].set_xlabel(r'u ($\lambda$)')
|
|
240
|
+
close_figure(fig, savefig, show)
|
|
244
241
|
return F, u, v
|
|
245
242
|
|
|
246
243
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
from astropy.io import fits
|
|
3
2
|
from astropy import units, wcs
|
|
3
|
+
from astropy.io import fits
|
|
4
4
|
|
|
5
|
+
from plotastrodata import const_utils as cu
|
|
5
6
|
from plotastrodata.coord_utils import coord2xy, xy2coord
|
|
6
7
|
from plotastrodata.matrix_utils import dot2d
|
|
7
8
|
from plotastrodata.noise_utils import estimate_rms
|
|
8
|
-
from plotastrodata.other_utils import
|
|
9
|
-
from plotastrodata import const_utils as cu
|
|
9
|
+
from plotastrodata.other_utils import isdeg, RGIxy, trim
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def Jy2K(header=None, bmaj: float | None = None, bmin: float | None = None,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import matplotlib.pyplot as plt
|
|
1
|
+
import corner
|
|
3
2
|
import emcee
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import numpy as np
|
|
4
5
|
import ptemcee
|
|
5
|
-
import corner
|
|
6
|
-
from dynesty import DynamicNestedSampler as DNS
|
|
7
6
|
import warnings
|
|
8
|
-
from
|
|
7
|
+
from dynesty import DynamicNestedSampler as DNS
|
|
9
8
|
from multiprocessing import Pool
|
|
9
|
+
from tqdm import tqdm
|
|
10
|
+
|
|
11
|
+
from plotastrodata.other_utils import close_figure
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
global_bounds = None
|
|
@@ -109,9 +111,9 @@ class EmceeCorner():
|
|
|
109
111
|
while np.max(GR) > 1.25 and i < ntry:
|
|
110
112
|
i += 1
|
|
111
113
|
if pos0 is None:
|
|
112
|
-
pos0 = np.random.rand(ntemps, nwalkers, self.dim)
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
pos0 = np.random.rand(ntemps, nwalkers, self.dim)
|
|
115
|
+
pos0 = pos0 * (self.bounds[:, 1] - self.bounds[:, 0])
|
|
116
|
+
pos0 = pos0 + self.bounds[:, 0]
|
|
115
117
|
if not pt:
|
|
116
118
|
pos0 = pos0[0]
|
|
117
119
|
if pt:
|
|
@@ -176,17 +178,17 @@ class EmceeCorner():
|
|
|
176
178
|
if global_progressbar:
|
|
177
179
|
print('')
|
|
178
180
|
|
|
179
|
-
def plotcorner(self,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
def plotcorner(self, labels: list[str] | None = None,
|
|
182
|
+
cornerrange: list[float] | None = None,
|
|
183
|
+
savefig: dict | str | None = None,
|
|
184
|
+
show: bool = False) -> None:
|
|
183
185
|
"""Make the corner plot from self.samples.
|
|
184
186
|
|
|
185
187
|
Args:
|
|
186
|
-
show (bool, optional): Whether to show the corner plot. Defaults to False.
|
|
187
|
-
savefig (str, optional): File name of the corner plot. Defaults to None.
|
|
188
188
|
labels (list, optional): Labels for the corner plot. Defaults to None.
|
|
189
189
|
cornerrange (list, optional): Range for the corner plot. Defaults to None.
|
|
190
|
+
savefig (dict or str, optional): For plt.figure().savefig(). Defaults to None.
|
|
191
|
+
show (bool, optional): True means doing plt.show(). Defaults to False.
|
|
190
192
|
"""
|
|
191
193
|
if labels is None:
|
|
192
194
|
labels = [f'Par {i:d}' for i in range(self.dim)]
|
|
@@ -198,21 +200,17 @@ class EmceeCorner():
|
|
|
198
200
|
0.5,
|
|
199
201
|
self.percent[1] / 100],
|
|
200
202
|
show_titles=True, labels=labels, range=cornerrange)
|
|
201
|
-
|
|
202
|
-
plt.savefig(savefig)
|
|
203
|
-
if show:
|
|
204
|
-
plt.show()
|
|
205
|
-
plt.close()
|
|
203
|
+
close_figure(plt, savefig, show, tight=False)
|
|
206
204
|
|
|
207
|
-
def plotchain(self,
|
|
208
|
-
|
|
205
|
+
def plotchain(self, labels: list = None, ylim: list = None,
|
|
206
|
+
savefig: dict | str = None, show: bool = False):
|
|
209
207
|
"""Plot parameters as a function of steps using self.samples. This method plots nine lines: percent[0], 50%, percent[1] percentiles (over the steps by 1% binning) of percent[0], 50%, percent[1] percentiles (over the walkers).
|
|
210
208
|
|
|
211
209
|
Args:
|
|
212
|
-
show (bool, optional): Whether to show the chain plot. Defaults to False.
|
|
213
|
-
savefig (str, optional): File name of the chain plot. Defaults to None.
|
|
214
210
|
labels (list, optional): Labels for the chain plot. Defaults to None.
|
|
215
211
|
ylim (list, optional): Y-range for the chain plot. Defaults to None.
|
|
212
|
+
savefig (dict or str, optional): For plt.figure().savefig(). Defaults to None.
|
|
213
|
+
show (bool, optional): True means doing plt.show(). Defaults to False.
|
|
216
214
|
"""
|
|
217
215
|
if labels is None:
|
|
218
216
|
labels = [f'Par {i:d}' for i in range(self.dim)]
|
|
@@ -239,12 +237,7 @@ class EmceeCorner():
|
|
|
239
237
|
ax.set_xticks([])
|
|
240
238
|
else:
|
|
241
239
|
ax.set_xlabel('Step')
|
|
242
|
-
fig
|
|
243
|
-
if savefig is not None:
|
|
244
|
-
plt.savefig(savefig)
|
|
245
|
-
if show:
|
|
246
|
-
plt.show()
|
|
247
|
-
plt.close()
|
|
240
|
+
close_figure(fig, savefig, show)
|
|
248
241
|
|
|
249
242
|
def posteriorongrid(self, ngrid: list[int] | int = 100,
|
|
250
243
|
log: list[bool] | bool = False, pcut: float = 0):
|
|
@@ -381,13 +374,7 @@ class EmceeCorner():
|
|
|
381
374
|
plt.setp(ax[k].get_xticklabels(), rotation=45)
|
|
382
375
|
else:
|
|
383
376
|
plt.setp(ax[k].get_xticklabels(), visible=False)
|
|
384
|
-
|
|
385
|
-
if savefig is not None:
|
|
386
|
-
plt.savefig(savefig)
|
|
387
|
-
if show:
|
|
388
|
-
plt.show()
|
|
389
|
-
else:
|
|
390
|
-
plt.close()
|
|
377
|
+
close_figure(fig, savefig, show, tight=False)
|
|
391
378
|
|
|
392
379
|
def getDNSevidence(self, **kwargs):
|
|
393
380
|
"""Calculate the Bayesian evidence for a model using dynamic nested sampling through dynesty.
|
|
@@ -24,7 +24,7 @@ def Mrot(pa: float = 0) -> np.ndarray:
|
|
|
24
24
|
np.ndarray: Matrix for the rotation.
|
|
25
25
|
"""
|
|
26
26
|
p = np.radians(pa)
|
|
27
|
-
return np.array([[np.cos(p), -np.sin(p)], [np.sin(p),
|
|
27
|
+
return np.array([[np.cos(p), -np.sin(p)], [np.sin(p), np.cos(p)]])
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def dot2d(M: np.ndarray = [[1, 0], [0, 1]],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
import numpy as np
|
|
3
1
|
import matplotlib.pyplot as plt
|
|
2
|
+
import numpy as np
|
|
3
|
+
import warnings
|
|
4
4
|
from scipy.special import erf
|
|
5
5
|
|
|
6
6
|
from plotastrodata.fitting_utils import EmceeCorner
|
|
@@ -167,8 +167,7 @@ class Noise:
|
|
|
167
167
|
savefig (dict or str, optional): For plt.figure().savefig(). Defaults to None.
|
|
168
168
|
show (bool, optional): True means doing plt.show(). Defaults to False.
|
|
169
169
|
"""
|
|
170
|
-
fig = plt.
|
|
171
|
-
ax = fig.add_subplot(1, 1, 1)
|
|
170
|
+
fig, ax = plt.subplots()
|
|
172
171
|
ax.plot(self.hbin, self.hist, drawstyle='steps-mid')
|
|
173
172
|
ax.plot(self.hbin, self.model, '-')
|
|
174
173
|
ax.set_xlabel('(noise - m0) / s0')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import numpy as np
|
|
2
1
|
import matplotlib.pyplot as plt
|
|
2
|
+
import numpy as np
|
|
3
3
|
from scipy.interpolate import RegularGridInterpolator as RGI
|
|
4
4
|
|
|
5
5
|
from plotastrodata.matrix_utils import Mrot, dot2d
|
|
@@ -209,18 +209,19 @@ def gaussian2d(xy: np.ndarray,
|
|
|
209
209
|
return g
|
|
210
210
|
|
|
211
211
|
|
|
212
|
-
def close_figure(fig: object,
|
|
213
|
-
|
|
214
|
-
show: bool = False) -> None:
|
|
212
|
+
def close_figure(fig: object, savefig: dict | str | None = None,
|
|
213
|
+
show: bool = False, tight: bool = True) -> None:
|
|
215
214
|
"""Save, show, and close the figure.
|
|
216
215
|
|
|
217
216
|
Args:
|
|
218
217
|
fig (object): External plt.figure(). Defaults to None.
|
|
219
218
|
savefig (dict or str, optional): For plt.figure().savefig(). Defaults to None.
|
|
220
219
|
show (bool, optional): True means doing plt.show(). Defaults to False.
|
|
220
|
+
tight (bool, optional): True means doing fig.tight_layout(). Defaults to False.
|
|
221
221
|
"""
|
|
222
222
|
savefig0 = {'bbox_inches': 'tight', 'transparent': True}
|
|
223
|
-
|
|
223
|
+
if tight:
|
|
224
|
+
fig.tight_layout()
|
|
224
225
|
if savefig is not None:
|
|
225
226
|
s = {'fname': savefig} if type(savefig) is str else savefig
|
|
226
227
|
savefig0.update(s)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
import numpy as np
|
|
3
1
|
import matplotlib as mpl
|
|
4
2
|
import matplotlib.pyplot as plt
|
|
5
|
-
|
|
3
|
+
import numpy as np
|
|
4
|
+
import warnings
|
|
6
5
|
from dataclasses import dataclass
|
|
6
|
+
from matplotlib.patches import Ellipse, Rectangle
|
|
7
7
|
|
|
8
|
+
from plotastrodata.analysis_utils import AstroData, AstroFrame
|
|
8
9
|
from plotastrodata.coord_utils import coord2xy, xy2coord
|
|
9
10
|
from plotastrodata.noise_utils import estimate_rms
|
|
10
|
-
from plotastrodata.other_utils import
|
|
11
|
-
from plotastrodata.analysis_utils import AstroData, AstroFrame
|
|
11
|
+
from plotastrodata.other_utils import close_figure, listing
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
plt.ioff() # force to turn off interactive mode
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.4
|
|
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
|