plotastrodata 1.4.13__tar.gz → 1.4.15__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 (23) hide show
  1. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/PKG-INFO +1 -1
  2. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/analysis_utils.py +20 -22
  4. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/plot_utils.py +2 -1
  5. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata.egg-info/PKG-INFO +1 -1
  6. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/LICENSE +0 -0
  7. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/README.md +0 -0
  8. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/const_utils.py +0 -0
  9. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/coord_utils.py +0 -0
  10. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/ext_utils.py +0 -0
  11. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/fft_utils.py +0 -0
  12. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/fits_utils.py +0 -0
  13. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/fitting_utils.py +0 -0
  14. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/los_utils.py +0 -0
  15. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/matrix_utils.py +0 -0
  16. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata/other_utils.py +0 -0
  17. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata.egg-info/SOURCES.txt +0 -0
  18. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata.egg-info/dependency_links.txt +0 -0
  19. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata.egg-info/not-zip-safe +0 -0
  20. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata.egg-info/requires.txt +0 -0
  21. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/plotastrodata.egg-info/top_level.txt +0 -0
  22. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/setup.cfg +0 -0
  23. {plotastrodata-1.4.13 → plotastrodata-1.4.15}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.4.13
3
+ Version: 1.4.15
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', UserWarning)
4
- __version__ = '1.4.13'
4
+ __version__ = '1.4.15'
@@ -97,6 +97,7 @@ class AstroData():
97
97
  restfreq: float | None = None
98
98
  cfactor: float = 1
99
99
  pvpa: float | None = None
100
+ pv: bool = False
100
101
 
101
102
  def __post_init__(self):
102
103
  n = 0
@@ -124,7 +125,6 @@ class AstroData():
124
125
  self.sigma_org = None
125
126
  self.beam_org = None
126
127
  self.fitsheader = None
127
- self.pv = False
128
128
 
129
129
  def binning(self, width: list[int, int, int] = [1, 1, 1]):
130
130
  """Binning up neighboring pixels in the v, y, and x domain.
@@ -204,7 +204,9 @@ class AstroData():
204
204
  g1 /= np.sqrt(np.pi/4/np.log(2) * bmin * np.sqrt(1 - bmin**2/bmaj**2))
205
205
  g = np.zeros((ny, nx))
206
206
  g[:, (nx - 1) // 2] = g1
207
- d = to4dim(self.data)
207
+ d = self.data.copy()
208
+ d[np.isnan(d)] = 0
209
+ d = to4dim(d)
208
210
  d = [[convolve(c, g, mode='same') for c in cc] for cc in d]
209
211
  self.data = np.squeeze(d)
210
212
  self.rotate(bpa)
@@ -461,7 +463,7 @@ class AstroData():
461
463
  d = {'data': self.data, 'x': self.x, 'y': self.y, 'v': self.v,
462
464
  'fitsimage': self.fitsimage, 'beam': self.beam, 'Tb': self.Tb,
463
465
  'restfreq': self.restfreq, 'cfactor': self.cfactor,
464
- 'sigma': self.sigma, 'center': self.center}
466
+ 'sigma': self.sigma, 'center': self.center, 'pv': self.pv}
465
467
  return d
466
468
 
467
469
  def writetofits(self, fitsimage: str = 'out.fits', header: dict = {}):
@@ -473,7 +475,8 @@ class AstroData():
473
475
  """
474
476
  fhd = self.fitsheader
475
477
  h = {}
476
- cx, cy = (0, 0) if self.pv or self.center is None else coord2xy(self.center)
478
+ nocent = self.pv or self.center is None
479
+ cx, cy = (0, 0) if nocent else coord2xy(self.center)
477
480
  h['NAXIS1'] = len(self.x)
478
481
  h['CRPIX1'] = np.argmin(np.abs(self.x)) + 1
479
482
  h['CRVAL1'] = cx
@@ -673,21 +676,19 @@ class AstroFrame():
673
676
  d.beam[i] = fd.get_beam(dist=self.dist)
674
677
  d.bunit[i] = fd.get_header('BUNIT')
675
678
  if d.data[i] is not None:
676
- d.pv[i] = self.pv
677
679
  d.sigma_org[i] = d.sigma[i]
678
680
  d.sigma[i] = estimate_rms(d.data[i], d.sigma[i])
679
681
  d.data[i], grid = trim(data=d.data[i],
680
682
  x=grid[0], y=grid[1], v=grid[2],
681
683
  xlim=self.xlim, ylim=self.ylim,
682
684
  vlim=self.vlim, pv=self.pv)
683
- if grid[2] is not None and len(grid[2]) > 1 and grid[2][1] < grid[2][0]:
684
- d.data[i], grid[2] = d.data[i][::-1], grid[2][::-1]
685
+ v = grid[2]
686
+ has_v = v is not None and len(v) > 1
687
+ if has_v and v[1] < v[0]:
688
+ d.data[i], v = d.data[i][::-1], v[::-1]
685
689
  print('Velocity has been inverted.')
686
- d.v = grid[2]
687
- if d.v is not None and len(d.v) > 1:
688
- d.dv = d.v[1] - d.v[0]
689
- else:
690
- d.dv = None
690
+ d.v = v
691
+ d.dv = v[1] - v[0] if has_v else None
691
692
  grid = grid[:3:2] if self.pv else grid[:2]
692
693
  if self.swapxy:
693
694
  grid = [grid[1], grid[0]]
@@ -699,15 +700,11 @@ class AstroFrame():
699
700
  a = a[::yskip, ::xskip]
700
701
  a = np.moveaxis(a, [0, 1], [-2, -1])
701
702
  d.data[i] = a
702
- d.x, d.y = grid
703
- if d.x is not None and len(d.x) > 1:
704
- d.dx = d.x[1] - d.x[0]
705
- else:
706
- d.dx = None
707
- if d.y is not None and len(d.y) > 1:
708
- d.dy = d.y[1] - d.y[0]
709
- else:
710
- d.dy = None
703
+ x, y = d.x, d.y = grid
704
+ has_x = x is not None and len(x) > 1
705
+ d.dx = x[1] - x[0] if has_x else None
706
+ has_y = y is not None and len(y) > 1
707
+ d.dy = y[1] - y[0] if has_y else None
711
708
  if self.quadrants is not None:
712
709
  d.data[i], d.x, d.y \
713
710
  = quadrantmean(d.data[i], d.x, d.y, self.quadrants)
@@ -724,7 +721,7 @@ class AstroFrame():
724
721
  header['BMIN'] = d.beam[i][1] / 3600 / self.dist
725
722
  d.data[i] = d.data[i] * Jy2K(header=header)
726
723
  d.sigma[i] = d.sigma[i] * Jy2K(header=header)
727
- if self.pv and None not in d.beam[i]:
724
+ if self.pv and not d.pv[i] and None not in d.beam[i]:
728
725
  bmaj, bmin, bpa = d.beam_org[i] = d.beam[i]
729
726
  if d.pvpa[i] is None:
730
727
  d.pvpa[i] = bpa
@@ -732,6 +729,7 @@ class AstroFrame():
732
729
  p = np.radians(bpa - d.pvpa[i])
733
730
  b = 1 / np.hypot(np.cos(p) / bmaj, np.sin(p) / bmin)
734
731
  d.beam[i] = np.array([np.abs(d.dv), b, 0])
732
+ d.pv[i] = self.pv
735
733
  d.Tb[i] = False
736
734
  d.cfactor[i] = 1
737
735
  if d.fitsimage[i] is not None:
@@ -686,7 +686,8 @@ class PlotAstroData(AstroFrame):
686
686
  cbticklabels (list, optional): Ticklabels of colorbar. Defaults to None.
687
687
  cblocation (str, optional): 'left', 'top', 'left', 'right'. Only for 2D images. Defaults to 'right'.
688
688
  """
689
- _kw = {'cmap': 'cubehelix', 'alpha': 1, 'edgecolors': 'none', 'zorder': 1}
689
+ _kw = {'cmap': 'cubehelix', 'alpha': 1,
690
+ 'edgecolors': 'none', 'zorder': 1}
690
691
  beam_kwargs = kwargs2beamargs(kwargs)
691
692
  _kw.update(kwargs)
692
693
  d = kwargs2AstroData(_kw)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.4.13
3
+ Version: 1.4.15
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