plotastrodata 1.9.19.post1__tar.gz → 1.9.20__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.19.post1/plotastrodata.egg-info → plotastrodata-1.9.20}/PKG-INFO +2 -2
  2. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/README.md +1 -1
  3. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/__init__.py +1 -1
  4. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/fitting_utils.py +15 -14
  5. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20/plotastrodata.egg-info}/PKG-INFO +2 -2
  6. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/LICENSE +0 -0
  7. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/MANIFEST.in +0 -0
  8. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/analysis_utils.py +0 -0
  9. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/const_utils.py +0 -0
  10. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/coord_utils.py +0 -0
  11. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/ext_utils.py +0 -0
  12. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/fft_utils.py +0 -0
  13. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/fits_utils.py +0 -0
  14. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/los_utils.py +0 -0
  15. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/matrix_utils.py +0 -0
  16. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/noise_utils.py +0 -0
  17. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/other_utils.py +0 -0
  18. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata/plot_utils.py +0 -0
  19. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata.egg-info/SOURCES.txt +0 -0
  20. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata.egg-info/dependency_links.txt +0 -0
  21. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata.egg-info/not-zip-safe +0 -0
  22. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata.egg-info/requires.txt +0 -0
  23. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/plotastrodata.egg-info/top_level.txt +0 -0
  24. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/setup.cfg +0 -0
  25. {plotastrodata-1.9.19.post1 → plotastrodata-1.9.20}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.9.19.post1
3
+ Version: 1.9.20
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
@@ -84,7 +84,7 @@ plotastrodata can do the following things.
84
84
  * astropy >= 7.2
85
85
  * corner (only for fitting)
86
86
  * dynesty (only for fitting)
87
- * emcee (only for fitting)
87
+ * emcee >= 3.0 (only for fitting)
88
88
  * ffmpeg (only for movie)
89
89
  * matplotlib
90
90
  * numpy >= 2.0
@@ -56,7 +56,7 @@ plotastrodata can do the following things.
56
56
  * astropy >= 7.2
57
57
  * corner (only for fitting)
58
58
  * dynesty (only for fitting)
59
- * emcee (only for fitting)
59
+ * emcee >= 3.0 (only for fitting)
60
60
  * ffmpeg (only for movie)
61
61
  * matplotlib
62
62
  * numpy >= 2.0
@@ -1,4 +1,4 @@
1
1
  import warnings
2
2
 
3
3
  warnings.simplefilter('ignore', FutureWarning)
4
- __version__ = '1.9.19-1'
4
+ __version__ = '1.9.20'
@@ -38,9 +38,9 @@ def logp(x: np.ndarray) -> float:
38
38
  def _get_GR(samples: np.ndarray, nwalkers: int, ndata: int, dim: int
39
39
  ) -> np.ndarray:
40
40
  """Calculate the Gelman-Rubin statistics."""
41
- B = np.std(np.mean(samples, axis=1), axis=0)
42
- W = np.mean(np.std(samples, axis=1), axis=0)
43
- V = (len(samples[0]) - 1) / len(samples[0]) * W \
41
+ B = np.std(np.mean(samples, axis=0), axis=0)
42
+ W = np.mean(np.std(samples, axis=0), axis=0)
43
+ V = (len(samples) - 1) / len(samples) * W \
44
44
  + (nwalkers + 1) / (nwalkers - 1) * B
45
45
  d = ndata - dim - 1
46
46
  GR = np.sqrt((d + 3) / (d + 1) * V / W)
@@ -66,7 +66,7 @@ class EmceeCorner():
66
66
 
67
67
  This class wraps ``emcee`` and ``ptemcee`` for simple bounded-parameter fitting. The likelihood can be supplied directly through ``logl``, or it can be constructed from ``model``, ``xdata``, ``ydata``, and ``sigma``. Parameters are sampled with a uniform prior inside ``bounds`` and zero prior probability outside them.
68
68
 
69
- After calling :meth:`fit`, the main results are stored as attributes:``samples`` for the post-burn-in chain, ``popt`` for the maximum-likelihood parameter set, and ``plow``, ``pmid``, and ``phigh`` for posterior percentiles. The samples can be visualized with :meth:`plotcorner` and :meth:`plotchain`.
69
+ After calling :meth:`fit`, the main results are stored as attributes:``samples`` for the post-burn-in chain, ``popt`` for the maximum-likelihood parameter set, and ``plow``, ``pmid``, and ``phigh`` for posterior percentiles. ``samples`` has the shape ``(steps, walkers, dimensions)``. The samples can be visualized with :meth:`plotcorner` and :meth:`plotchain`.
70
70
 
71
71
  Args:
72
72
  bounds (np.ndarray): Parameter bounds with shape ``(dim, 2)``. logl (Callable, optional): Log-likelihood function. Defaults to None.
@@ -146,22 +146,23 @@ class EmceeCorner():
146
146
  pt: bool) -> np.ndarray:
147
147
  """Extract post-burn-in samples from sampler chain."""
148
148
  if pt:
149
- return sampler.chain[0, :, nburnin:, :] # temperatures, walkers, steps, dim
149
+ chain = sampler.chain[0] # walkers, steps, dim
150
+ return np.swapaxes(chain, 0, 1)[nburnin:, :, :] # steps, walkers, dim
150
151
  else:
151
- return sampler.chain[:, nburnin:, :] # walkers, steps, dim
152
+ return sampler.get_chain(discard=nburnin) # steps, walkers, dim
152
153
 
153
154
  def _get_lnp_popt(self, sampler: Any, pt: bool, nburnin: int,
154
155
  ) -> tuple[np.ndarray, np.ndarray]:
155
156
  """Get log probabilities and best-fit parameters from sampler."""
156
157
  if pt:
157
- lnp = sampler.logprobability[0] # 0th temperature chain
158
- chain = sampler.chain[0]
158
+ lnp = np.swapaxes(sampler.logprobability[0], 0, 1)
159
+ chain = np.swapaxes(sampler.chain[0], 0, 1)
159
160
  else:
160
- lnp = sampler.lnprobability
161
- chain = sampler.chain
161
+ lnp = sampler.get_log_prob() # steps, walkers
162
+ chain = sampler.get_chain() # steps, walkers, dim
162
163
  idx_best = np.unravel_index(np.argmax(lnp), lnp.shape)
163
164
  popt = chain[idx_best]
164
- lnp = lnp[:, nburnin:]
165
+ lnp = lnp[nburnin:, :]
165
166
  return lnp, popt
166
167
 
167
168
  def _get_percentiles(self, samples: np.ndarray
@@ -266,14 +267,14 @@ class EmceeCorner():
266
267
  if ylim is None:
267
268
  ylim = self.bounds
268
269
  fig = plt.figure(figsize=(4, 2 * self.dim))
269
- x = np.arange(np.shape(self.samples)[1])
270
+ x = np.arange(np.shape(self.samples)[0])
270
271
  naverage = max(1, len(x) // 100)
271
272
  nend = len(x) - len(x) % 100 if naverage > 1 else len(x)
272
273
  x = x[:nend:naverage]
273
274
  for i in range(self.dim):
274
- y = self.samples[:, :, i] # walkers, steps, dim
275
+ y = self.samples[:, :, i] # steps, walkers, dim
275
276
  plist = [self.percent[0], 50, self.percent[1]]
276
- y = [np.percentile(y, p, axis=0) for p in plist] # percent over the walkers, steps
277
+ y = [np.percentile(y, p, axis=1) for p in plist] # percent over the walkers, steps
277
278
  y = [[np.percentile(np.reshape(yy[:nend], (naverage, -1)), p, axis=0)
278
279
  for p in plist] for yy in y] # percent over the walkers, percent over the steps
279
280
  ax = fig.add_subplot(self.dim, 1, i + 1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.9.19.post1
3
+ Version: 1.9.20
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
@@ -84,7 +84,7 @@ plotastrodata can do the following things.
84
84
  * astropy >= 7.2
85
85
  * corner (only for fitting)
86
86
  * dynesty (only for fitting)
87
- * emcee (only for fitting)
87
+ * emcee >= 3.0 (only for fitting)
88
88
  * ffmpeg (only for movie)
89
89
  * matplotlib
90
90
  * numpy >= 2.0