plotastrodata 1.8.13__tar.gz → 1.8.14__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.8.13/plotastrodata.egg-info → plotastrodata-1.8.14}/PKG-INFO +1 -1
  2. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/plot_utils.py +45 -35
  4. {plotastrodata-1.8.13 → plotastrodata-1.8.14/plotastrodata.egg-info}/PKG-INFO +1 -1
  5. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/LICENSE +0 -0
  6. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/MANIFEST.in +0 -0
  7. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/README.md +0 -0
  8. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/analysis_utils.py +0 -0
  9. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/const_utils.py +0 -0
  10. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/coord_utils.py +0 -0
  11. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/ext_utils.py +0 -0
  12. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/fft_utils.py +0 -0
  13. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/fits_utils.py +0 -0
  14. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/fitting_utils.py +0 -0
  15. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/los_utils.py +0 -0
  16. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/matrix_utils.py +0 -0
  17. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/noise_utils.py +0 -0
  18. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata/other_utils.py +0 -0
  19. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata.egg-info/SOURCES.txt +0 -0
  20. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata.egg-info/dependency_links.txt +0 -0
  21. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata.egg-info/not-zip-safe +0 -0
  22. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata.egg-info/requires.txt +0 -0
  23. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/plotastrodata.egg-info/top_level.txt +0 -0
  24. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/setup.cfg +0 -0
  25. {plotastrodata-1.8.13 → plotastrodata-1.8.14}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.8.13
3
+ Version: 1.8.14
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.8.13'
4
+ __version__ = '1.8.14'
@@ -101,7 +101,7 @@ def logcbticks(vmin: float = 1e-3, vmax: float = 1e3
101
101
 
102
102
  @dataclass
103
103
  class Stretcher():
104
- """Get the stretched values.
104
+ """Arguments and methods related to the stretch in PlotAstroData.add_color() and add_rgb().
105
105
 
106
106
  Args:
107
107
  stretch (str, optional): 'log', 'asinh', 'power', or 'linear'. Any other means 'linear'. 'log' means the mapped data are logarithmic. 'asinh' means the mapped data are arc sin hyperbolic. 'power' means the mapped data are power-law (see also stretchpower). Defaults to 'linear'.
@@ -205,6 +205,37 @@ class Stretcher():
205
205
  return dataout, vminout, vmaxout
206
206
 
207
207
 
208
+ class Beam():
209
+ """Arguments for PlotAstroData.add_beam().
210
+
211
+ Args:
212
+ show_beam (bool, optional): Defaults to True.
213
+ beam (list, optional): [bmaj, bmin, bpa]. This may be a list of list. Defaults to [None, None, None].
214
+ beamcolor (str, optional): matplotlib color. This may be a list of str. Defaults to 'gray'.
215
+ beampos (list, optional): Relative position. This may be a list of list or a list of None. Defaults to None.
216
+ beam_kwargs (dict, optional): Additional arguments for matplotlib.patches. Defaults to {}.
217
+ """
218
+ def __init__(self,
219
+ show_beam: bool = True,
220
+ beam: list[float | None] = [None] * 3,
221
+ beamcolor: str = 'gray',
222
+ beampos: list[float] | None = None,
223
+ beam_kwargs: dict = {}):
224
+ self.show_beam = show_beam
225
+ self.beam = beam
226
+ self.beamcolor = beamcolor
227
+ self.beampos = beampos
228
+ self.beam_kwargs = beam_kwargs
229
+
230
+ def todict(self):
231
+ tmp = {'show_beam': self.show_beam,
232
+ 'beam': self.beam,
233
+ 'beamcolor': self.beamcolor,
234
+ 'beampos': self.beampos}
235
+ tmp.update(self.beam_kwargs)
236
+ return tmp
237
+
238
+
208
239
  @dataclass
209
240
  class PlotAxes2D():
210
241
  """Use Axes.set_* to adjust x and y axes.
@@ -333,21 +364,6 @@ def kwargs2instance(cls: type[T], kw: dict) -> T:
333
364
  return cls(**tmp)
334
365
 
335
366
 
336
- def kwargs2beamargs(kw: dict) -> dict:
337
- """Get arguments for add_beam() from kwargs.
338
-
339
- Args:
340
- kw (dict): Parameters to make and plot a beam. Particularly, the dict 'beam_kwargs' is for matplotlib.patches.
341
-
342
- Returns:
343
- dict: Arguments for add_beam().
344
- """
345
- keys = ('show_beam', 'beamcolor', 'beampos')
346
- tmp = {k: kw.pop(k) for k in keys if k in kw}
347
- tmp.update(kw.pop('beam_kwargs', {}))
348
- return tmp
349
-
350
-
351
367
  class PlotAstroData(AstroFrame):
352
368
  """Make a figure from 2D/3D FITS files or 2D/3D arrays.
353
369
 
@@ -529,17 +545,21 @@ class PlotAstroData(AstroFrame):
529
545
  Returns:
530
546
  tuple: Data and parameters used in each method.
531
547
  """
532
- beam_kwargs = kwargs2beamargs(kw)
548
+ b = kwargs2instance(Beam, kw)
533
549
  self._kw.update(kw)
534
550
  xskip = self._kw.pop('xskip', 1)
535
551
  yskip = self._kw.pop('yskip', 1)
536
552
  d = kwargs2instance(AstroData, self._kw)
537
553
  self.read(d, xskip, yskip)
538
- self.beam = d.beam
539
554
  self.sigma = d.sigma
540
555
  singlepix = d.dx is None or d.dy is None
541
- return (d.data, d.x, d.y, d.v, d.beam, d.sigma, d.bunit,
542
- self._kw, beam_kwargs, singlepix)
556
+ if len(d.beam) == 4:
557
+ b.beam = self.beam = next(b for b in d.beam if None not in b)
558
+ else:
559
+ b.beam = self.beam = d.beam
560
+ self.add_beam(**b.todict())
561
+ return (d.data, d.x, d.y, d.v, d.sigma, d.bunit,
562
+ self._kw, singlepix)
543
563
 
544
564
  def add_region(self, patch: str = 'ellipse',
545
565
  poslist: list[str | list[float, float]] = [],
@@ -588,7 +608,7 @@ class PlotAstroData(AstroFrame):
588
608
  axnow.add_patch(p)
589
609
 
590
610
  def add_beam(self, show_beam: bool = True,
591
- beam: list[float | None, float | None, float | None] = [None, None, None],
611
+ beam: list[float | None] = [None] * 3,
592
612
  beamcolor: str = 'gray',
593
613
  beampos: list[float, float] | None = None,
594
614
  **kwargs) -> None:
@@ -819,8 +839,7 @@ class PlotAstroData(AstroFrame):
819
839
  self._kw = {'cmap': 'cubehelix', 'alpha': 1,
820
840
  'edgecolors': 'none', 'zorder': 1,
821
841
  'vmin': None, 'vmax': None}
822
- c, x, y, v, beam, sigma, bunit, _kw, beam_kwargs, singlepix \
823
- = self._map_init(kwargs)
842
+ c, x, y, v, sigma, bunit, _kw, singlepix = self._map_init(kwargs)
824
843
  if singlepix:
825
844
  print('No pixel size. Skip add_color.')
826
845
  return
@@ -843,7 +862,6 @@ class PlotAstroData(AstroFrame):
843
862
  for ch in self.bottomleft:
844
863
  self._set_colorbar(p, ch, show_cbar, cblabel, cbformat,
845
864
  cbticks, cbticklabels, cblocation, st)
846
- self.add_beam(beam=beam, **beam_kwargs)
847
865
 
848
866
  def add_contour(self,
849
867
  levels: list[float] = [-12, -6, -3, 3, 6, 12, 24, 48, 96, 192, 384],
@@ -854,8 +872,7 @@ class PlotAstroData(AstroFrame):
854
872
  levels (list, optional): Contour levels in the unit of sigma. Defaults to [-12,-6,-3,3,6,12,24,48,96,192,384].
855
873
  """
856
874
  self._kw = {'colors': 'gray', 'linewidths': 1.0, 'zorder': 2}
857
- c, x, y, v, beam, sigma, _, _kw, beam_kwargs, singlepix \
858
- = self._map_init(kwargs)
875
+ c, x, y, v, sigma, _, _kw, singlepix = self._map_init(kwargs)
859
876
  if singlepix:
860
877
  print('No pixel size. Skip add_contour.')
861
878
  return
@@ -865,7 +882,6 @@ class PlotAstroData(AstroFrame):
865
882
  c = [c[self.channelnumber]]
866
883
  for axnow, cnow in zip(self.ax, c):
867
884
  axnow.contour(x, y, cnow, np.sort(levels) * sigma, **_kw)
868
- self.add_beam(beam=beam, **beam_kwargs)
869
885
 
870
886
  def add_segment(self,
871
887
  ampfits: str = None, angfits: str = None,
@@ -899,16 +915,13 @@ class PlotAstroData(AstroFrame):
899
915
  'headaxislength': 0, 'width': 0.007, 'zorder': 3,
900
916
  'fitsimage': [ampfits, angfits, Ufits, Qfits],
901
917
  'data': [amp, ang, stU, stQ]}
902
- c, x, y, v, beam, sigma, _, _kw, beam_kwargs, singlepix \
903
- = self._map_init(kwargs)
918
+ c, x, y, v, sigma, _, _kw, singlepix = self._map_init(kwargs)
904
919
  if singlepix:
905
920
  print('No pixel size. Skip add_segment.')
906
921
  return
907
922
 
908
923
  amp, ang, stU, stQ = c
909
924
  sigmaU, sigmaQ = sigma[2:]
910
- beam = [beam[i] for i in range(4) if beam[i][0] is not None][0]
911
- self.beam = beam
912
925
  if stU is not None and stQ is not None:
913
926
  self.sigma = sigma = (sigmaU + sigmaQ) / 2.
914
927
  ang = np.degrees(np.arctan2(stU, stQ) / 2.)
@@ -929,7 +942,6 @@ class PlotAstroData(AstroFrame):
929
942
  _kw['scale'] = 1. / np.abs(x[1] - x[0])
930
943
  for axnow, unow, vnow in zip(self.ax, U, V):
931
944
  axnow.quiver(x, y, unow, vnow, **_kw)
932
- self.add_beam(beam=beam, **beam_kwargs)
933
945
 
934
946
  def add_rgb(self,
935
947
  stretch: list[str] = ['linear'] * 3,
@@ -948,8 +960,7 @@ class PlotAstroData(AstroFrame):
948
960
  self._kw = {'vmin': [None] * 3, 'vmax': [None] * 3,
949
961
  'stretch': stretch, 'stretchscale': stretchscale,
950
962
  'stretchpower': stretchpower}
951
- c, x, y, v, beam, sigma, _, _kw, beam_kwargs, singlepix \
952
- = self._map_init(kwargs)
963
+ c, x, y, v, _, _, _kw, singlepix = self._map_init(kwargs)
953
964
  if singlepix:
954
965
  print('No pixel size. Skip add_rgb.')
955
966
  return
@@ -974,7 +985,6 @@ class PlotAstroData(AstroFrame):
974
985
  im.putpixel((i, j), value)
975
986
  axnow.imshow(im, extent=[x[0], x[-1], y[0], y[-1]])
976
987
  axnow.set_aspect(np.abs((x[-1]-x[0]) / (y[-1]-y[0])))
977
- self.add_beam(beam=beam, **beam_kwargs)
978
988
 
979
989
  def _set_axis_shared(self, pa2: PlotAxes2D, title: dict | str | None):
980
990
  """Internal method used in set_axis() and set_axis_radec().
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.8.13
3
+ Version: 1.8.14
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