plotastrodata 1.6.3.post1__tar.gz → 1.6.5__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.6.3.post1 → plotastrodata-1.6.5}/PKG-INFO +2 -2
  2. plotastrodata-1.6.5/plotastrodata/__init__.py +4 -0
  3. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/analysis_utils.py +2 -1
  4. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/coord_utils.py +9 -5
  5. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/plot_utils.py +27 -14
  6. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata.egg-info/PKG-INFO +2 -2
  7. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata.egg-info/requires.txt +1 -1
  8. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/setup.cfg +1 -1
  9. plotastrodata-1.6.3.post1/plotastrodata/__init__.py +0 -4
  10. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/LICENSE +0 -0
  11. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/README.md +0 -0
  12. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/const_utils.py +0 -0
  13. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/ext_utils.py +0 -0
  14. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/fft_utils.py +0 -0
  15. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/fits_utils.py +0 -0
  16. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/fitting_utils.py +0 -0
  17. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/los_utils.py +0 -0
  18. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/matrix_utils.py +0 -0
  19. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata/other_utils.py +0 -0
  20. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata.egg-info/SOURCES.txt +0 -0
  21. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata.egg-info/dependency_links.txt +0 -0
  22. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata.egg-info/not-zip-safe +0 -0
  23. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/plotastrodata.egg-info/top_level.txt +0 -0
  24. {plotastrodata-1.6.3.post1 → plotastrodata-1.6.5}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.6.3.post1
3
+ Version: 1.6.5
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
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: astropy
14
+ Requires-Dist: astropy>=7.2
15
15
  Requires-Dist: corner
16
16
  Requires-Dist: dynesty
17
17
  Requires-Dist: emcee
@@ -0,0 +1,4 @@
1
+ import warnings
2
+
3
+ warnings.simplefilter('ignore', FutureWarning)
4
+ __version__ = '1.6.5'
@@ -634,7 +634,8 @@ class AstroFrame():
634
634
  if self.fitsimage is not None and self.center is None:
635
635
  self.center = FitsData(self.fitsimage).get_center()
636
636
 
637
- def pos2xy(self, poslist: list[str | list[float, float]] = []) -> np.ndarray:
637
+ def pos2xy(self, poslist: list[str | list[float, float]] = []
638
+ ) -> np.ndarray:
638
639
  """Text or relative to absolute coordinates.
639
640
 
640
641
  Args:
@@ -80,12 +80,13 @@ def coord2xy(coords: str | list, coordorg: str = '00h00m00s 00d00m00s',
80
80
  c0 = c0.transform_to(frame=frame)
81
81
  clist = SkyCoord(coords, frame=frame) # frame=None means ICRS.
82
82
  xy = c0.spherical_offsets_to(clist)
83
- return np.array([xy[0].degree, xy[1].degree])
83
+ xy = np.array([xy[0].degree, xy[1].degree])
84
+ return xy
84
85
 
85
86
 
86
87
  def xy2coord(xy: list, coordorg: str = '00h00m00s 00d00m00s',
87
88
  frame: str | None = None, frameorg: str | None = None,
88
- ) -> str:
89
+ ) -> str | np.ndarray:
89
90
  """Transform relative (deg, deg) to R.A.-Dec.
90
91
 
91
92
  Args:
@@ -105,10 +106,13 @@ def xy2coord(xy: list, coordorg: str = '00h00m00s 00d00m00s',
105
106
  coords = c0.spherical_offsets_by(*xy * units.degree)
106
107
  if frame is not None:
107
108
  coords = coords.transform_to(frame=frame)
108
- s = coords.to_string('hmsdms')
109
+ coords = coords.to_string('hmsdms')
109
110
  if framename is not None:
110
- s = f'{framename} {s}'
111
- return s
111
+ if type(coords) is str:
112
+ coords = f'{framename} {coords}'
113
+ else:
114
+ coords = np.array([f'{framename} {s}' for s in coords])
115
+ return coords
112
116
 
113
117
 
114
118
  def rel2abs(xrel: float, yrel: float,
@@ -408,7 +408,7 @@ class PlotAstroData(AstroFrame):
408
408
  figsize = (ncols * 2 / sqrt_a, max(nrows*2, 3) * sqrt_a)
409
409
  for ch in range(nchan):
410
410
  n, i, j = ch2nij(ch)
411
- if internalfig:
411
+ if internalfig and n not in plt.get_fignums():
412
412
  fig = plt.figure(n, figsize=figsize)
413
413
  sharex = ax[nij2ch(n, i - 1, j)] if i > 0 else None
414
414
  sharey = ax[nij2ch(n, i, j - 1)] if j > 0 else None
@@ -431,8 +431,10 @@ class PlotAstroData(AstroFrame):
431
431
  self.allchan = np.arange(nv)
432
432
  self.bottomleft = nij2ch(np.arange(npages), nrows - 1, 0)
433
433
  self.channelnumber = channelnumber
434
+ self.v = v
434
435
 
435
- def vskipfill(c: np.ndarray, v_in: np.ndarray = None) -> np.ndarray:
436
+ def vskipfill(c: np.ndarray, v_in: np.ndarray = None
437
+ ) -> np.ndarray:
436
438
  """Skip and fill channels with nan.
437
439
 
438
440
  Args:
@@ -444,7 +446,14 @@ class PlotAstroData(AstroFrame):
444
446
  """
445
447
  if np.ndim(c) == 3:
446
448
  if v_in is not None:
447
- if (k0 := np.argmin(np.abs(v - v_in[0]))) > 0:
449
+ dv_org = self.v[1] - self.v[0]
450
+ dv_in = v_in[1] - v_in[0]
451
+ if np.abs(dv_in - dv_org) / dv_org > 0.01:
452
+ print('Velocity resolution mismatch (>1%).',
453
+ 'The cube needs to be regridded',
454
+ 'outside plotastrodata.')
455
+ k0 = np.argmin(np.abs(self.v - v_in[0]))
456
+ if k0 > 0:
448
457
  prenan = np.full((k0, *np.shape(c)[1:]), np.nan)
449
458
  d = np.append(prenan, c, axis=0)
450
459
  else:
@@ -454,8 +463,9 @@ class PlotAstroData(AstroFrame):
454
463
  d = np.full((nv, *np.shape(c)), c)
455
464
  n = nchan if channelnumber is None else nv
456
465
  shape = (n - len(d), len(d[0]), len(d[0, 0]))
457
- dnan = np.full(shape, d[0] * np.nan)
458
- return np.concatenate((d, dnan), axis=0)
466
+ postnan = np.full(shape, d[0] * np.nan)
467
+ d = np.append(d, postnan, axis=0)
468
+ return d
459
469
  self.vskipfill = vskipfill
460
470
 
461
471
  def _map_init(self, kw: dict) -> tuple:
@@ -767,15 +777,18 @@ class PlotAstroData(AstroFrame):
767
777
  cb.ax.tick_params(labelsize=14)
768
778
  font = mpl.font_manager.FontProperties(size=16)
769
779
  cb.ax.yaxis.label.set_font_properties(font)
780
+ if cbticks is not None and ch // self.rowcol == 0:
781
+ cbticks = np.array(cbticks)
782
+ match stretch:
783
+ case 'log':
784
+ cbticks = np.log10(cbticks)
785
+ case 'asinh':
786
+ cbticks = np.arcsinh(cbticks / stretchscale)
787
+ case 'power':
788
+ p = 1 - stretchpower
789
+ cbticks = (cbticks / cmin_org)**p - 1
790
+ cbticks = cbticks / p / np.log(10)
770
791
  if cbticks is not None:
771
- if stretch == 'log':
772
- cbticks = np.log10(cbticks)
773
- elif stretch == 'asinh':
774
- cbticks = np.arcsinh(np.array(cbticks) / stretchscale)
775
- elif stretch == 'power':
776
- cbticks = np.array(cbticks)
777
- p = 1 - stretchpower
778
- cbticks = ((cbticks / cmin_org)**p - 1) / p / np.log(10)
779
792
  cb.set_ticks(cbticks)
780
793
  if cbticklabels is not None:
781
794
  cb.set_ticklabels(cbticklabels)
@@ -1112,7 +1125,7 @@ class PlotAstroData(AstroFrame):
1112
1125
  fig.savefig(fname, **_kw)
1113
1126
  if show:
1114
1127
  plt.show()
1115
- plt.close()
1128
+ plt.close('all')
1116
1129
 
1117
1130
  def get_figax(self) -> tuple[object, object]:
1118
1131
  """Output the external fig and ax after plotting.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.6.3.post1
3
+ Version: 1.6.5
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
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: astropy
14
+ Requires-Dist: astropy>=7.2
15
15
  Requires-Dist: corner
16
16
  Requires-Dist: dynesty
17
17
  Requires-Dist: emcee
@@ -1,4 +1,4 @@
1
- astropy
1
+ astropy>=7.2
2
2
  corner
3
3
  dynesty
4
4
  emcee
@@ -16,7 +16,7 @@ packages = find:
16
16
  zip_safe = False
17
17
  python_requires = >=3.10
18
18
  install_requires =
19
- astropy
19
+ astropy >= 7.2
20
20
  corner
21
21
  dynesty
22
22
  emcee
@@ -1,4 +0,0 @@
1
- import warnings
2
-
3
- warnings.simplefilter('ignore', UserWarning)
4
- __version__ = '1.6.3-1'