plotastrodata 1.7.10.post1__tar.gz → 1.7.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 (24) hide show
  1. {plotastrodata-1.7.10.post1/plotastrodata.egg-info → plotastrodata-1.7.12}/PKG-INFO +1 -1
  2. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/other_utils.py +27 -24
  4. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12/plotastrodata.egg-info}/PKG-INFO +1 -1
  5. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/LICENSE +0 -0
  6. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/MANIFEST.in +0 -0
  7. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/README.md +0 -0
  8. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/analysis_utils.py +0 -0
  9. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/const_utils.py +0 -0
  10. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/coord_utils.py +0 -0
  11. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/ext_utils.py +0 -0
  12. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/fft_utils.py +0 -0
  13. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/fits_utils.py +0 -0
  14. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/fitting_utils.py +0 -0
  15. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/los_utils.py +0 -0
  16. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/matrix_utils.py +0 -0
  17. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata/plot_utils.py +0 -0
  18. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata.egg-info/SOURCES.txt +0 -0
  19. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata.egg-info/dependency_links.txt +0 -0
  20. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata.egg-info/not-zip-safe +0 -0
  21. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata.egg-info/requires.txt +0 -0
  22. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/plotastrodata.egg-info/top_level.txt +0 -0
  23. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/setup.cfg +0 -0
  24. {plotastrodata-1.7.10.post1 → plotastrodata-1.7.12}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.7.10.post1
3
+ Version: 1.7.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.7.10-1'
4
+ __version__ = '1.7.12'
@@ -1,7 +1,7 @@
1
1
  import warnings
2
2
  import numpy as np
3
3
  from scipy.optimize import curve_fit
4
- from scipy.special import exp1
4
+ from scipy.special import erf
5
5
  from scipy.interpolate import RegularGridInterpolator as RGI
6
6
 
7
7
  from plotastrodata.matrix_utils import Mrot, dot2d
@@ -47,15 +47,15 @@ def estimate_rms(data: np.ndarray, sigma: float | str | None = 'hist'
47
47
  'med': use the median of data^2 assuming Gaussian.
48
48
  'iter': exclude outliers.
49
49
  'out': exclude inner 60% about axes=-2 and -1.
50
- 'hist': fit histgram with Gaussian.
51
- 'hist-pbcor': fit histgram with PB-corrected Gaussian.
50
+ 'hist': fit histgram with Gaussian. This option can be combined with 'edge' and/or 'neg'.
51
+ 'hist-pbcor': fit histgram with PB-corrected Gaussian. This option can be combined with 'edge' and/or 'neg'.
52
52
 
53
53
  Args:
54
54
  data (np.ndarray): N-D array.
55
55
  sigma (float or str): One of the methods above. Defaults to 'hist'.
56
56
 
57
57
  Returns:
58
- float: the estimated root mean square of noise.
58
+ float: the estimated standard deviation of noise.
59
59
  """
60
60
  if sigma is None:
61
61
  return None
@@ -89,7 +89,7 @@ def estimate_rms(data: np.ndarray, sigma: float | str | None = 'hist'
89
89
  noise = np.nanstd(n)
90
90
  warning_offset(ave, noise)
91
91
  elif sigma == 'out':
92
- n, n0, n1 = data.copy(), len(data), len(data[0])
92
+ n, n0, n1 = data * 1, len(data), len(data[0])
93
93
  n = np.moveaxis(n, [-2, -1], [0, 1])
94
94
  n[n0//5: n0*4//5, n1//5: n1*4//5] = np.nan
95
95
  if np.all(np.isnan(n)):
@@ -100,34 +100,37 @@ def estimate_rms(data: np.ndarray, sigma: float | str | None = 'hist'
100
100
  ave = np.nanmean(n)
101
101
  noise = np.nanstd(n)
102
102
  warning_offset(ave, noise)
103
- elif sigma[:4] == 'hist':
104
- m0, s0 = np.nanmean(data), np.nanstd(data)
105
- hist, hbin = np.histogram(data[~np.isnan(data)],
106
- bins=100, density=True,
103
+ elif 'hist' in sigma:
104
+ n = data * 1
105
+ if 'edge' in sigma:
106
+ n = n[::len(n) - 1]
107
+ if 'neg' in sigma:
108
+ n = n[n < 0]
109
+ n = np.r_[n, -n]
110
+ n = n[~np.isnan(n)]
111
+ m0, s0 = np.mean(n), np.std(n)
112
+ hist, hbin = np.histogram(n, bins=100, density=True,
107
113
  range=(m0 - s0 * 3.5,
108
114
  m0 + s0 * 3.5))
109
115
  hist, hbin = hist * s0, (hbin[:-1] + hbin[1:]) / 2 / s0
110
- if sigma[4:] == '-pbcor':
111
- def g(x, s, R):
112
- xn = x / np.sqrt(2) / s
113
- pbcor = np.exp2(R**2)
114
- y1 = xn**2
115
- y2 = y1 / pbcor**2
116
- area = 2 * np.sqrt(2 * np.pi) * s * (pbcor - 1)
117
- p = (exp1(y2) - exp1(y1)) / area
116
+ if 'pbcor' in sigma:
117
+ def g(x, s, c, R):
118
+ y2 = (x - c) / np.sqrt(2) / s
119
+ y1 = (x * 2**(-R**2) - c) / np.sqrt(2) / s
120
+ p = erf(y2) - erf(y1)
121
+ p = p / (2 * np.log(2) * x * R**2)
118
122
  return p
119
- popt, _ = curve_fit(g, hbin, hist, p0=[1, 1],
120
- bounds=[[0.001, 0.001], [2, 2]])
121
- ave = 0
122
- noise = popt[0]
123
+ popt, _ = curve_fit(g, hbin, hist, p0=[1, 0, 1],
124
+ bounds=[[0.001, -2, 0.001], [2, 2, 2]])
123
125
  else:
124
126
  def g(x, s, c):
125
127
  xn = (x - c) / np.sqrt(2) / s
126
- return np.exp(-xn**2) / np.sqrt(2 * np.pi) / s
128
+ p = np.exp(-xn**2) / np.sqrt(2 * np.pi) / s
129
+ return p
127
130
  popt, _ = curve_fit(g, hbin, hist, p0=[1, 0],
128
131
  bounds=[[0.001, -2], [2, 2]])
129
- ave = popt[1]
130
- noise = popt[0]
132
+ ave = popt[1]
133
+ noise = popt[0]
131
134
  warning_offset(ave, noise)
132
135
  noise = noise * s0
133
136
  return noise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.7.10.post1
3
+ Version: 1.7.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