plotastrodata 1.9.12__tar.gz → 1.9.13__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.
Files changed (25) hide show
  1. {plotastrodata-1.9.12/plotastrodata.egg-info → plotastrodata-1.9.13}/PKG-INFO +1 -1
  2. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/analysis_utils.py +2 -1
  4. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/fft_utils.py +96 -0
  5. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/fitting_utils.py +5 -3
  6. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/other_utils.py +3 -2
  7. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/plot_utils.py +4 -4
  8. {plotastrodata-1.9.12 → plotastrodata-1.9.13/plotastrodata.egg-info}/PKG-INFO +1 -1
  9. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/LICENSE +0 -0
  10. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/MANIFEST.in +0 -0
  11. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/README.md +0 -0
  12. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/const_utils.py +0 -0
  13. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/coord_utils.py +0 -0
  14. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/ext_utils.py +0 -0
  15. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/fits_utils.py +0 -0
  16. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/los_utils.py +0 -0
  17. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/matrix_utils.py +0 -0
  18. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata/noise_utils.py +0 -0
  19. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata.egg-info/SOURCES.txt +0 -0
  20. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata.egg-info/dependency_links.txt +0 -0
  21. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata.egg-info/not-zip-safe +0 -0
  22. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata.egg-info/requires.txt +0 -0
  23. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/plotastrodata.egg-info/top_level.txt +0 -0
  24. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/setup.cfg +0 -0
  25. {plotastrodata-1.9.12 → plotastrodata-1.9.13}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.9.12
3
+ Version: 1.9.13
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,4 +1,4 @@
1
1
  import warnings
2
2
 
3
3
  warnings.simplefilter('ignore', FutureWarning)
4
- __version__ = '1.9.12'
4
+ __version__ = '1.9.13'
@@ -3,6 +3,7 @@ import warnings
3
3
  from dataclasses import dataclass
4
4
  from scipy.interpolate import RegularGridInterpolator as RGI
5
5
  from scipy.signal import convolve
6
+ from typing import Callable
6
7
 
7
8
  from plotastrodata import const_utils as cu
8
9
  from plotastrodata.coord_utils import coord2xy, rel2abs, xy2coord
@@ -290,7 +291,7 @@ class AstroData():
290
291
  self.beam = np.array([bmaj_new, bmin_new, bpa_new])
291
292
 
292
293
  @_need_multipixels
293
- def fit2d(self, model: object, bounds: np.ndarray,
294
+ def fit2d(self, model: Callable, bounds: np.ndarray,
294
295
  progressbar: bool = False,
295
296
  kwargs_fit: dict = {}, kwargs_plotcorner: dict = {},
296
297
  chan: int | None = None):
@@ -1,5 +1,6 @@
1
1
  import matplotlib.pyplot as plt
2
2
  import numpy as np
3
+ from typing import Callable
3
4
 
4
5
  from plotastrodata.fits_utils import fits2data
5
6
  from plotastrodata.other_utils import close_figure
@@ -206,6 +207,101 @@ def ifftcentering2(F: np.ndarray,
206
207
  return f, x, y
207
208
 
208
209
 
210
+ class FftCentering():
211
+ """Set FFT conditions and functions.
212
+
213
+ Args:
214
+ x (np.ndarray): 1D array.
215
+ y (np.ndarray, optional): 1D array. Defaults to None.
216
+ xcenter (float, optional): x of phase reference. Defaults to 0.
217
+ ycenter (float, optional): y of phase reference. Defaults to 0.
218
+ rfft (bool, optional): True means using rFFT. Defaults to False.
219
+ """
220
+ def __init__(self, x: np.ndarray,
221
+ y: np.ndarray | None = None,
222
+ xcenter: float = 0,
223
+ ycenter: float = 0,
224
+ rfft: bool = False):
225
+ nx = len(x)
226
+ self.x = x
227
+ self.dx = dx = x[1] - x[0]
228
+ self.xcenter = xcenter
229
+ self.ndim = 2 if isinstance(y, np.ndarray) else 1
230
+ self.rfft = rfft
231
+ if rfft:
232
+ u = np.fft.rfftfreq(nx, d=dx)
233
+ else:
234
+ u = np.fft.fftshift(np.fft.fftfreq(nx, d=dx))
235
+ self.u = u
236
+ if self.ndim == 2:
237
+ ny = len(y)
238
+ self.y = y
239
+ self.dy = dy = y[1] - y[0]
240
+ self.ycenter = ycenter
241
+ v = np.fft.fftshift(np.fft.fftfreq(ny, d=dy))
242
+ self.v = v
243
+
244
+ def fft(self, f: np.ndarray | None = None
245
+ ) -> np.ndarray | Callable:
246
+ """FFT calculation done by considering 1D/2D and fft/rfft.
247
+
248
+ Args:
249
+ f (np.ndarray | None, optional): 1D or 2D array. Defaults to None.
250
+
251
+ Returns:
252
+ np.ndarray: FFT result. When f is None, the return is the FFT function.
253
+ """
254
+ if self.ndim == 1:
255
+ def func(f: np.ndarray):
256
+ F, _ = fftcentering(f=f, x=self.x,
257
+ xcenter=self.xcenter,
258
+ rfft=self.rfft)
259
+ return F
260
+
261
+ else:
262
+ def func(f: np.ndarray):
263
+ F, _, _ = fftcentering2(f=f, x=self.x, y=self.y,
264
+ xcenter=self.xcenter,
265
+ ycenter=self.ycenter,
266
+ rfft=self.rfft)
267
+ return F
268
+
269
+ return func if f is None else func(f)
270
+
271
+ def ifft(self, F: np.ndarray | None = None, outreal: bool = False
272
+ ) -> np.ndarray | Callable:
273
+ """iFFT calculation done by considering 1D/2D and fft/rfft.
274
+
275
+ Args:
276
+ F (np.ndarray | None, optional): An FFT result. Defaults to None.
277
+
278
+ Returns:
279
+ np.ndarray: iFFT result. When F is None, the return is the iFFT function.
280
+ """
281
+ if self.ndim == 1:
282
+ def func(F: np.ndarray):
283
+ f, _ = ifftcentering(F=F, u=self.u,
284
+ xcenter=self.xcenter,
285
+ x0=self.x[0],
286
+ dx=self.dx,
287
+ outreal=outreal,
288
+ rfft=self.rfft)
289
+ return f
290
+
291
+ else:
292
+ def func(F: np.ndarray):
293
+ f, _, _ = ifftcentering2(F=F, u=self.u, v=self.v,
294
+ xcenter=self.xcenter,
295
+ ycenter=self.ycenter,
296
+ x0=self.x[0], y0=self.y[0],
297
+ dx=self.dx, dy=self.dy,
298
+ outreal=outreal,
299
+ rfft=self.rfft)
300
+ return f
301
+
302
+ return func if F is None else func(F)
303
+
304
+
209
305
  def zeropadding(f: np.ndarray, x: np.ndarray, y: np.ndarray,
210
306
  xlim: list, ylim: list
211
307
  ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
@@ -7,6 +7,7 @@ import warnings
7
7
  from dynesty import DynamicNestedSampler as DNS
8
8
  from multiprocessing import Pool
9
9
  from tqdm import tqdm
10
+ from typing import Callable
10
11
 
11
12
  from plotastrodata.matrix_utils import Mrot, dot2d
12
13
  from plotastrodata.other_utils import close_figure
@@ -63,8 +64,8 @@ def _check_GR(samples: np.ndarray, nwalkers: int, ndata: int, dim: int,
63
64
  class EmceeCorner():
64
65
  warnings.simplefilter('ignore', RuntimeWarning)
65
66
 
66
- def __init__(self, bounds: np.ndarray, logl: object | None = None,
67
- model: object | None = None,
67
+ def __init__(self, bounds: np.ndarray, logl: Callable | None = None,
68
+ model: Callable | None = None,
68
69
  xdata: np.ndarray | None = None,
69
70
  ydata: np.ndarray | None = None,
70
71
  sigma: np.ndarray = 1, progressbar: bool = False,
@@ -111,7 +112,8 @@ class EmceeCorner():
111
112
 
112
113
  def _run_sampler(self, pos0: np.ndarray, pt: bool,
113
114
  ncores: int, ntemps: int,
114
- nsteps: int, nwalkers: int) -> object:
115
+ nsteps: int, nwalkers: int
116
+ ) -> ptemcee.Sampler | emcee.EnsembleSampler:
115
117
  """Create and run the sampler, then return it."""
116
118
  if pt:
117
119
  sampler_cls = ptemcee.Sampler
@@ -3,6 +3,7 @@ import numbers
3
3
  import numpy as np
4
4
  import warnings
5
5
  from scipy.interpolate import RegularGridInterpolator as RGI
6
+ from typing import Callable
6
7
 
7
8
 
8
9
  def listing(*args) -> list:
@@ -217,7 +218,7 @@ def reform_data(c: np.ndarray, v_in: np.ndarray | None,
217
218
 
218
219
  def RGIxy(y: np.ndarray, x: np.ndarray, data: np.ndarray,
219
220
  yxnew: tuple[np.ndarray, np.ndarray] | None = None,
220
- **kwargs) -> object | np.ndarray:
221
+ **kwargs) -> Callable | np.ndarray:
221
222
  """RGI for x and y at each channel.
222
223
 
223
224
  Args:
@@ -252,7 +253,7 @@ def RGIxy(y: np.ndarray, x: np.ndarray, data: np.ndarray,
252
253
 
253
254
  def RGIxyv(v: np.ndarray, y: np.ndarray, x: np.ndarray, data: np.ndarray,
254
255
  vyxnew: tuple[np.ndarray, np.ndarray, np.ndarray] | None = None,
255
- **kwargs) -> object | np.ndarray:
256
+ **kwargs) -> Callable | np.ndarray:
256
257
  """RGI in the x-y-v space.
257
258
 
258
259
  Args:
@@ -3,7 +3,7 @@ import matplotlib.pyplot as plt
3
3
  import numpy as np
4
4
  from dataclasses import dataclass
5
5
  from matplotlib.patches import Ellipse, Rectangle
6
- from typing import TypeVar
6
+ from typing import TypeVar, Callable
7
7
 
8
8
  from plotastrodata.analysis_utils import AstroData, AstroFrame
9
9
  from plotastrodata.coord_utils import (coord2xy, xy2coord,
@@ -162,13 +162,13 @@ def _get_v(p, v: np.ndarray | None = None,
162
162
  return v
163
163
 
164
164
 
165
- def _get_nij2ch(nrows: int = 1, ncols: int = 1) -> object:
165
+ def _get_nij2ch(nrows: int = 1, ncols: int = 1) -> Callable:
166
166
  def nij2ch(n: int, i: int, j: int) -> int:
167
167
  return n*nrows*ncols + i*ncols + j
168
168
  return nij2ch
169
169
 
170
170
 
171
- def _get_ch2nij(nrows: int = 1, ncols: int = 1) -> object:
171
+ def _get_ch2nij(nrows: int = 1, ncols: int = 1) -> Callable:
172
172
  def ch2nij(ch: int) -> tuple[int, int, int]:
173
173
  n = ch // (nrows*ncols)
174
174
  i = (ch - n*nrows*ncols) // ncols
@@ -178,7 +178,7 @@ def _get_ch2nij(nrows: int = 1, ncols: int = 1) -> object:
178
178
 
179
179
 
180
180
  def _get_vskipfill(nv: float, v_org: np.ndarray, vskip: int,
181
- channelnumber: int) -> object:
181
+ channelnumber: int) -> Callable:
182
182
  def vskipfill(c: np.ndarray, v_in: np.ndarray) -> np.ndarray:
183
183
  c = reform_data(c=c, v_in=v_in, nv=nv, v_org=v_org, vskip=vskip)
184
184
  if isinstance(channelnumber, int):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.9.12
3
+ Version: 1.9.13
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