plotastrodata 1.9.11__tar.gz → 1.9.12__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.11/plotastrodata.egg-info → plotastrodata-1.9.12}/PKG-INFO +1 -1
  2. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/fft_utils.py +67 -23
  4. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/noise_utils.py +1 -1
  5. {plotastrodata-1.9.11 → plotastrodata-1.9.12/plotastrodata.egg-info}/PKG-INFO +1 -1
  6. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/LICENSE +0 -0
  7. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/MANIFEST.in +0 -0
  8. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/README.md +0 -0
  9. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/analysis_utils.py +0 -0
  10. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/const_utils.py +0 -0
  11. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/coord_utils.py +0 -0
  12. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/ext_utils.py +0 -0
  13. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/fits_utils.py +0 -0
  14. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/fitting_utils.py +0 -0
  15. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/los_utils.py +0 -0
  16. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/matrix_utils.py +0 -0
  17. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/other_utils.py +0 -0
  18. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata/plot_utils.py +0 -0
  19. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata.egg-info/SOURCES.txt +0 -0
  20. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata.egg-info/dependency_links.txt +0 -0
  21. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata.egg-info/not-zip-safe +0 -0
  22. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata.egg-info/requires.txt +0 -0
  23. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/plotastrodata.egg-info/top_level.txt +0 -0
  24. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/setup.cfg +0 -0
  25. {plotastrodata-1.9.11 → plotastrodata-1.9.12}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.9.11
3
+ Version: 1.9.12
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.11'
4
+ __version__ = '1.9.12'
@@ -11,7 +11,7 @@ def shiftphase(F: np.ndarray, u: np.ndarray,
11
11
 
12
12
  Args:
13
13
  F (np.ndarray): 1D FFT.
14
- u (np.ndarray): 1D array. The first frequency coordinate.
14
+ u (np.ndarray): 1D array. The frequency coordinate.
15
15
  xoff (float): From old to new center. Defaults to 0.
16
16
 
17
17
  Returns:
@@ -27,7 +27,7 @@ def shiftphase2(F: np.ndarray, u: np.ndarray, v: np.ndarray,
27
27
  Args:
28
28
  F (np.ndarray): 2D FFT.
29
29
  u (np.ndarray): 1D or 2D array. The first frequency coordinate.
30
- v (np.ndarray): 1D or 2D array. The second frequency coordinate. Defaults to None.
30
+ v (np.ndarray): 1D or 2D array. The second frequency coordinate.
31
31
  xoff (float): From old to new center. Defaults to 0.
32
32
  yoff (float): From old to new center. Defaults to 0.
33
33
 
@@ -39,7 +39,7 @@ def shiftphase2(F: np.ndarray, u: np.ndarray, v: np.ndarray,
39
39
 
40
40
 
41
41
  def fftcentering(f: np.ndarray, x: np.ndarray | None = None,
42
- xcenter: float = 0
42
+ xcenter: float = 0, rfft: bool = False
43
43
  ) -> tuple[np.ndarray, np.ndarray]:
44
44
  """FFT with the phase referring to a specific point.
45
45
 
@@ -47,6 +47,7 @@ def fftcentering(f: np.ndarray, x: np.ndarray | None = None,
47
47
  f (np.ndarray): 1D array for FFT.
48
48
  x (np.ndarray, optional): 1D array. The spatial coordinate. Defaults to None.
49
49
  xcenter (float, optional): x of phase reference. Defaults to 0.
50
+ rfft (bool, optional): True means using rFFT. Defaults to False.
50
51
 
51
52
  Returns:
52
53
  tuple: (F, u). F is FFT of f. u is a 1D array of the frequency coordinate.
@@ -56,15 +57,19 @@ def fftcentering(f: np.ndarray, x: np.ndarray | None = None,
56
57
  x = np.arange(nx)
57
58
  X = x[0, :] if np.ndim(x) == 2 else x
58
59
  dx = X[1] - X[0]
59
- u = np.fft.fftshift(np.fft.fftfreq(nx, d=dx))
60
- F = np.fft.fftshift(np.fft.fft(f))
60
+ if rfft:
61
+ u = np.fft.rfftfreq(nx, d=dx)
62
+ F = np.fft.rfft(f)
63
+ else:
64
+ u = np.fft.fftshift(np.fft.fftfreq(nx, d=dx))
65
+ F = np.fft.fftshift(np.fft.fft(f))
61
66
  F = shiftphase(F, u=u, xoff=xcenter - X[0])
62
67
  return F, u
63
68
 
64
69
 
65
70
  def fftcentering2(f: np.ndarray,
66
71
  x: np.ndarray | None = None, y: np.ndarray | None = None,
67
- xcenter: float = 0, ycenter: float = 0
72
+ xcenter: float = 0, ycenter: float = 0, rfft: bool = False
68
73
  ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
69
74
  """FFT with the phase referring to a specific point.
70
75
 
@@ -74,6 +79,7 @@ def fftcentering2(f: np.ndarray,
74
79
  y (np.ndarray, optional): 1D or 2D array. The second spatial coordinate. Defaults to None.
75
80
  xcenter (float, optional): x of phase reference. Defaults to 0.
76
81
  ycenter (float, optional): y of phase reference. Defaults to 0.
82
+ rfft (bool, optional): True means using rFFT. Defaults to False.
77
83
 
78
84
  Returns:
79
85
  tuple: (F, u, v). F is FFT of f. u and v are 1D arrays of the frequency coordinates.
@@ -85,39 +91,60 @@ def fftcentering2(f: np.ndarray,
85
91
  y = np.arange(ny)
86
92
  X = x[0, :] if np.ndim(x) == 2 else x
87
93
  Y = y[:, 0] if np.ndim(y) == 2 else y
88
- dx, dy = X[1] - X[0], Y[1] - Y[0]
89
- u = np.fft.fftshift(np.fft.fftfreq(nx, d=dx))
90
- v = np.fft.fftshift(np.fft.fftfreq(ny, d=dy))
91
- F = np.fft.fftshift(np.fft.fft2(f))
94
+ dx = X[1] - X[0]
95
+ dy = Y[1] - Y[0]
96
+ if rfft:
97
+ u = np.fft.rfftfreq(nx, d=dx)
98
+ v = np.fft.fftshift(np.fft.fftfreq(ny, d=dy))
99
+ F = np.fft.fftshift(np.fft.rfft2(f), axes=0)
100
+ else:
101
+ u = np.fft.fftshift(np.fft.fftfreq(nx, d=dx))
102
+ v = np.fft.fftshift(np.fft.fftfreq(ny, d=dy))
103
+ F = np.fft.fftshift(np.fft.fft2(f))
92
104
  F = shiftphase2(F, u, v, xcenter - X[0], ycenter - Y[0])
93
105
  return F, u, v
94
106
 
95
107
 
96
108
  def ifftcentering(F: np.ndarray, u: np.ndarray | None = None,
97
- xcenter: float = 0,
98
- x0: float = None,
99
- outreal: bool = True
109
+ xcenter: float = 0, x0: float = None,
110
+ dx: float = 1,
111
+ outreal: bool = False, rfft: bool = False
100
112
  ) -> tuple[np.ndarray, np.ndarray]:
101
113
  """inverse FFT with the phase referring to a specific point.
102
114
 
103
115
  Args:
104
- F (np.ndarray): 1D array. A result of FFT.
116
+ F (np.ndarray): 1D array. An FFT result in the frequency domain.
105
117
  u (np.ndarray, optional): 1D array. The frequency coordinate. Defaults to None.
106
118
  xcenter (float, optional): x of phase reference (used in fftcentering). Defaults to 0.
107
119
  x0 (float, optional): spatial coordinate of x[0]. Defaults to None.
108
- outreal (bool, optional): whether output only the real part. Defaults to True.
120
+ dx (float, optional): spatial interval. Defaults to 1.
121
+ outreal (bool, optional): whether output only the real part. Defaults to False.
122
+ rfft (bool, optional): True means using rFFT. Defaults to False.
109
123
 
110
124
  Returns:
111
125
  tuple: (f, x). f is iFFT of F. x is a 1D array of the spatial coordinate.
112
126
  """
113
127
  nx = np.shape(F)[0]
114
128
  if u is None:
115
- u = np.fft.fftshift(np.fft.fftfreq(nx, d=1))
129
+ if rfft:
130
+ nx = 2 * (nx - 1) # Follow numpy.fft.irfft behavior.
131
+ u = np.fft.rfftfreq(nx, d=dx)
132
+ else:
133
+ u = np.fft.fftshift(np.fft.fftfreq(nx, d=dx))
134
+ else:
135
+ if rfft:
136
+ if np.isclose(u[-1], 1 / (2 * dx)):
137
+ nx = 2 * (nx - 1)
138
+ else:
139
+ nx = 2 * (nx - 1) + 1
116
140
  x = (np.arange(nx) - (nx-1)/2.) / (u[1]-u[0]) / nx + xcenter
117
141
  if x0 is not None:
118
142
  x = x - x[0] + x0
119
143
  F = shiftphase(F, u=u, xoff=x[0] - xcenter)
120
- f = np.fft.ifft(np.fft.ifftshift(F))
144
+ if rfft:
145
+ f = np.fft.irfft(F, n=nx)
146
+ else:
147
+ f = np.fft.ifft(np.fft.ifftshift(F))
121
148
  if outreal:
122
149
  f = np.real(f)
123
150
  return f, x
@@ -127,28 +154,42 @@ def ifftcentering2(F: np.ndarray,
127
154
  u: np.ndarray | None = None, v: np.ndarray | None = None,
128
155
  xcenter: float = 0, ycenter: float = 0,
129
156
  x0: float | None = None, y0: float | None = None,
130
- outreal: bool = True
157
+ dx: float = 1, dy: float = 1,
158
+ outreal: bool = False, rfft: bool = False
131
159
  ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
132
160
  """inverse FFT with the phase referring to a specific point.
133
161
 
134
162
  Args:
135
- F (np.ndarray): 2D array. A result of FFT.
163
+ F (np.ndarray): 2D array. An FFT result in the frequency domain.
136
164
  u (np.ndarray, optional): 1D or 2D array. The first frequency coordinate. Defaults to None.
137
165
  v (np.ndarray, optional): 1D or 2D array. The second frequency cooridnate. Defaults to None.
138
166
  xcenter (float, optional): x of phase reference (used in fftcentering2). Defaults to 0.
139
167
  ycenter (float, optional): y of phase reference (used in fftcentering2). Defaults to 0.
140
168
  x0 (float, optional): spatial coordinate of x[0]. Defaults to None.
141
169
  y0 (float, optional): spatial coordinate of y[0]. Defaults to None.
142
- outreal (bool, optional): whether output only the real part. Defaults to True.
170
+ dx (float, optional): spatial interval. Defaults to 1.
171
+ dy (float, optional): spatial interval. Defaults to 1.
172
+ outreal (bool, optional): whether output only the real part. Defaults to False.
173
+ rfft (bool, optional): True means using rFFT. Defaults to False.
143
174
 
144
175
  Returns:
145
176
  tuple: (f, x, y). f is iFFT of F. x and y are 1D arrays of the spatial coordinates.
146
177
  """
147
178
  ny, nx = np.shape(F)
148
179
  if u is None:
149
- u = np.fft.fftshift(np.fft.fftfreq(nx, d=1))
180
+ if rfft:
181
+ nx = 2 * (nx - 1) # Follow numpy.fft.irfft behavior.
182
+ u = np.fft.rfftfreq(nx, d=dx)
183
+ else:
184
+ u = np.fft.fftshift(np.fft.fftfreq(nx, d=dy))
185
+ else:
186
+ if rfft:
187
+ if np.isclose(u[-1], 1 / (2 * dx)):
188
+ nx = 2 * (nx - 1)
189
+ else:
190
+ nx = 2 * (nx - 1) + 1
150
191
  if v is None:
151
- v = np.fft.fftshift(np.fft.fftfreq(ny, d=1))
192
+ v = np.fft.fftshift(np.fft.fftfreq(ny, d=dy))
152
193
  x = (np.arange(nx) - (nx-1)/2.) / (u[1]-u[0]) / nx + xcenter
153
194
  y = (np.arange(ny) - (ny-1)/2.) / (v[1]-v[0]) / ny + ycenter
154
195
  if x0 is not None:
@@ -156,7 +197,10 @@ def ifftcentering2(F: np.ndarray,
156
197
  if y0 is not None:
157
198
  y = y - y[0] + y0
158
199
  F = shiftphase2(F, u, v, x[0] - xcenter, y[0] - ycenter)
159
- f = np.fft.ifft2(np.fft.ifftshift(F))
200
+ if rfft:
201
+ f = np.fft.irfft2(np.fft.ifftshift(F, axes=0), s=(ny, nx))
202
+ else:
203
+ f = np.fft.ifft2(np.fft.ifftshift(F))
160
204
  if outreal:
161
205
  f = np.real(f)
162
206
  return f, x, y
@@ -215,6 +215,6 @@ def estimate_rms(data: np.ndarray,
215
215
  ave = n.m0
216
216
  noise = n.s0
217
217
  if np.abs(ave) > 0.2 * noise:
218
- s = 'Mean > 0.2 x standard deviation.'
218
+ s = '|mean| > 0.2sigma.'
219
219
  warnings.warn(s, UserWarning)
220
220
  return noise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.9.11
3
+ Version: 1.9.12
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