plotastrodata 1.8.8__tar.gz → 1.8.10__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.8/plotastrodata.egg-info → plotastrodata-1.8.10}/PKG-INFO +1 -1
  2. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/plot_utils.py +45 -75
  4. {plotastrodata-1.8.8 → plotastrodata-1.8.10/plotastrodata.egg-info}/PKG-INFO +1 -1
  5. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/LICENSE +0 -0
  6. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/MANIFEST.in +0 -0
  7. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/README.md +0 -0
  8. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/analysis_utils.py +0 -0
  9. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/const_utils.py +0 -0
  10. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/coord_utils.py +0 -0
  11. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/ext_utils.py +0 -0
  12. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/fft_utils.py +0 -0
  13. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/fits_utils.py +0 -0
  14. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/fitting_utils.py +0 -0
  15. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/los_utils.py +0 -0
  16. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/matrix_utils.py +0 -0
  17. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/noise_utils.py +0 -0
  18. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata/other_utils.py +0 -0
  19. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata.egg-info/SOURCES.txt +0 -0
  20. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata.egg-info/dependency_links.txt +0 -0
  21. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata.egg-info/not-zip-safe +0 -0
  22. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata.egg-info/requires.txt +0 -0
  23. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/plotastrodata.egg-info/top_level.txt +0 -0
  24. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/setup.cfg +0 -0
  25. {plotastrodata-1.8.8 → plotastrodata-1.8.10}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.8.8
3
+ Version: 1.8.10
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.8'
4
+ __version__ = '1.8.10'
@@ -95,36 +95,6 @@ def logcbticks(vmin: float = -3.01, vmax: float = 3.01
95
95
  return ticks, ticklabels
96
96
 
97
97
 
98
- def pow10(x: np.ndarray, stretchpower: float) -> np.ndarray:
99
- """A power-law function scaled by xmin. This function is used for the case of stretch='power' in PlotAstroData.add_color().
100
-
101
- Args:
102
- x (np.ndarray): Input in the linear scale.
103
- stretchpower (float, optional): The output is (data**stretchpower - 1) / stretchpower / ln(10). 1 means the linear scale, while 0 means the logarithmic scale.
104
-
105
- Returns:
106
- np.ndarray: Output values.
107
- """
108
- p = 1e-6 if stretchpower == 0 else stretchpower
109
- y = (x**p - 1) / p / np.log(10)
110
- return y
111
-
112
-
113
- def ipow10(x: np.ndarray, stretchpower: float) -> np.ndarray:
114
- """The inverse function of pow10. This function is used for the case of stretch='power' in PlotAstroData.add_color().
115
-
116
- Args:
117
- x (np.ndarray): Input values.
118
- stretchpower (float, optional): The input is (data**stretchpower - 1) / stretchpower / ln(10). 1 means the linear scale, while 0 means the logarithmic scale.
119
-
120
- Returns:
121
- np.ndarray: Output values in the linear scale.
122
- """
123
- p = 1e-6 if stretchpower == 0 else stretchpower
124
- y = (1 + p * np.log(10) * x)**(1 / p)
125
- return y
126
-
127
-
128
98
  def do_stretch(x: list | np.ndarray,
129
99
  stretch: str, stretchscale: float,
130
100
  stretchpower: float) -> np.ndarray:
@@ -133,8 +103,8 @@ def do_stretch(x: list | np.ndarray,
133
103
  Args:
134
104
  x (list | np.ndarray): Input array in the linear scale.
135
105
  stretch (str): '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'.
136
- stretchscale (float, optional): The output is asinh(data / stretchscale). Defaults to None.
137
- stretchpower (float, optional): The output is ((data / stretchscale)**stretchpower - 1) / stretchpower / ln(10). 1 means the linear scale, while 0 means the logarithmic scale.
106
+ stretchscale (float): The output is asinh(data / stretchscale).
107
+ stretchpower (float): The output is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale.
138
108
 
139
109
  Returns:
140
110
  np.ndarray: Output stretched array.
@@ -146,7 +116,8 @@ def do_stretch(x: list | np.ndarray,
146
116
  case 'asinh':
147
117
  t = np.arcsinh(t / stretchscale)
148
118
  case 'power':
149
- t = pow10(t / stretchscale, stretchpower)
119
+ p = 1e-6 if stretchpower == 0 else stretchpower
120
+ t = t**p / p
150
121
  return t
151
122
 
152
123
 
@@ -158,8 +129,8 @@ def undo_stretch(x: list | np.ndarray,
158
129
  Args:
159
130
  x (list | np.ndarray): Input stretched array.
160
131
  stretch (str): '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'.
161
- stretchscale (float, optional): The input is asinh(data / stretchscale). Defaults to None.
162
- stretchpower (float, optional): The input is ((data / stretchscale)**stretchpower - 1) / stretchpower / ln(10). 1 means the linear scale, while 0 means the logarithmic scale.
132
+ stretchscale (float): The input is asinh(data / stretchscale).
133
+ stretchpower (float): The input is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale.
163
134
 
164
135
  Returns:
165
136
  np.ndarray: Output array in the linear scale.
@@ -171,7 +142,8 @@ def undo_stretch(x: list | np.ndarray,
171
142
  case 'asinh':
172
143
  t = np.sinh(t) * stretchscale
173
144
  case 'power':
174
- t = ipow10(t, stretchpower) * stretchscale
145
+ p = 1e-6 if stretchpower == 0 else stretchpower
146
+ t = (t * p)**(1 / p)
175
147
  return t
176
148
 
177
149
 
@@ -285,9 +257,9 @@ def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
285
257
 
286
258
  Args:
287
259
  data (np.ndarray): Plotted data.
288
- stretch (str): 'log', 'asinh', 'power'. Any other means linear.
289
- stretchscale (float): For the arcsinh strech and the power stretch.
290
- stretchpower (float): For the power strech.
260
+ stretch (str): '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'.
261
+ stretchscale (float): The input is asinh(data / stretchscale).
262
+ stretchpower (float): The input is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale.
291
263
  sigma (float): Noise level.
292
264
  kw (dict): Probably like {'vmin':0, 'vmax':1}.
293
265
 
@@ -308,8 +280,10 @@ def set_minmax(data: np.ndarray, stretch: str, stretchscale: float,
308
280
  for k in ['vmin', 'vmax']:
309
281
  if k not in kw:
310
282
  kw[k] = [None] * n
311
- stretch = np.where(np.equal(stretch, None), sigma, stretch)
312
- cmin = np.where(np.equal(kw['vmin'], None), sigma, kw['vmin'])
283
+ isnan = np.equal(stretchscale, None)
284
+ stretchscale = np.where(isnan, sigma, stretchscale)
285
+ isnan = np.equal(kw['vmin'], None)
286
+ cmin = np.where(isnan, sigma, kw['vmin'])
313
287
 
314
288
  argslist = (stretch, stretchscale, stretchpower)
315
289
  for i, stretch_args in enumerate(zip(*argslist)):
@@ -344,8 +318,7 @@ def kwargs2AstroData(kw: dict) -> AstroData:
344
318
  d = AstroData(data=np.zeros((2, 2)))
345
319
  for k in vars(d):
346
320
  if k in kw:
347
- tmp[k] = kw[k]
348
- del kw[k]
321
+ tmp[k] = kw.pop(k)
349
322
  if tmp == {}:
350
323
  print('No argument given.')
351
324
  return None
@@ -387,8 +360,7 @@ def kwargs2PlotAxes2D(kw: dict) -> PlotAxes2D:
387
360
  d = PlotAxes2D()
388
361
  for k in vars(d):
389
362
  if k in kw:
390
- tmp[k] = kw[k]
391
- del kw[k]
363
+ tmp[k] = kw.pop(k)
392
364
  d = PlotAxes2D(**tmp)
393
365
  return d
394
366
 
@@ -405,11 +377,8 @@ def kwargs2beamargs(kw: dict) -> dict:
405
377
  tmp = {}
406
378
  for k in ['show_beam', 'beamcolor', 'beampos']:
407
379
  if k in kw:
408
- tmp[k] = kw[k]
409
- del kw[k]
410
- if 'beam_kwargs' in kw:
411
- tmp.update(kw['beam_kwargs'])
412
- del kw['beam_kwargs']
380
+ tmp[k] = kw.pop(k)
381
+ tmp.update(kw.pop('beam_kwargs', {}))
413
382
  return tmp
414
383
 
415
384
 
@@ -596,16 +565,8 @@ class PlotAstroData(AstroFrame):
596
565
  """
597
566
  beam_kwargs = kwargs2beamargs(kw)
598
567
  self._kw.update(kw)
599
- if 'xskip' in self._kw:
600
- xskip = self._kw['xskip']
601
- del self._kw['xskip']
602
- else:
603
- xskip = 1
604
- if 'yskip' in self._kw:
605
- yskip = self._kw['yskip']
606
- del self._kw['yskip']
607
- else:
608
- yskip = 1
568
+ xskip = self._kw.pop('xskip', 1)
569
+ yskip = self._kw.pop('yskip', 1)
609
570
  d = kwargs2AstroData(self._kw)
610
571
  self.read(d, xskip, yskip)
611
572
  self.beam = d.beam
@@ -734,6 +695,11 @@ class PlotAstroData(AstroFrame):
734
695
  """
735
696
  _kw = {'color': 'gray', 'fontsize': 15, 'ha': 'center',
736
697
  'va': 'center', 'zorder': 10}
698
+ subkeys = {'ha': 'horizontalalignment',
699
+ 'va': 'verticalalignment'}
700
+ for short, long in subkeys.items():
701
+ if long in kwargs:
702
+ kwargs[short] = kwargs.pop(long)
737
703
  _kw.update(kwargs)
738
704
  if include_chan is None:
739
705
  include_chan = self.allchan
@@ -818,7 +784,7 @@ class PlotAstroData(AstroFrame):
818
784
  linewidth (float, optional): Width of the bar. Defaults to 3.
819
785
  """
820
786
  if length == 0:
821
- print('Please input length to add_scalebar().')
787
+ print('No length is given. Skip add_scalebar().')
822
788
  return
823
789
  if fontsize is None:
824
790
  fontsize = 20 if len(self.ax) == 1 else 15
@@ -861,20 +827,21 @@ class PlotAstroData(AstroFrame):
861
827
  cbticks = do_stretch(cbticks, *stretch_args)
862
828
  if cbticks is None and stretch == 'log':
863
829
  cbticks, cbticklabels = logcbticks()
864
- if cbticks is not None:
865
- cond = (vmin < cbticks) * (cbticks < vmax)
866
- cb.set_ticks(cbticks[cond])
867
- if cbticklabels is not None:
868
- tl = np.array(cbticklabels)[cond]
869
- else:
870
- t = undo_stretch(cb.get_ticks(), *stretch_args)
871
- tl = [f'{d:{cbformat[1:]}}' for d in t]
872
- cb.set_ticklabels(tl)
830
+ if cbticks is None:
831
+ cbticks = cb.get_ticks()
832
+ cond = (vmin < cbticks) * (cbticks < vmax)
833
+ cb.set_ticks(cbticks[cond])
834
+ if cbticklabels is not None:
835
+ tl = np.array(cbticklabels)[cond]
836
+ else:
837
+ t = undo_stretch(cb.get_ticks(), *stretch_args)
838
+ tl = [f'{d:{cbformat[1:]}}' for d in t]
839
+ cb.set_ticklabels(tl)
873
840
 
874
841
  def add_color(self,
875
842
  stretch: str = 'linear',
876
843
  stretchscale: float | None = None,
877
- stretchpower: float = 1,
844
+ stretchpower: float = 0.5,
878
845
  show_cbar: bool = True,
879
846
  cblabel: str | None = None,
880
847
  cbformat: float = '%.1e',
@@ -887,7 +854,7 @@ class PlotAstroData(AstroFrame):
887
854
  Args:
888
855
  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'.
889
856
  stretchscale (float, optional): Color scale is asinh(data / stretchscale). Defaults to None.
890
- stretchpower (float, optional): Color scale is ((data / stretchscale)**stretchpower - 1) / stretchpower / ln(10). 1 means the linear scale, while 0 means the logarithmic scale. Defaults to 1.
857
+ stretchpower (float, optional): Color scale is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale. Defaults to 0.5.
891
858
  show_cbar (bool, optional): Show color bar. Defaults to True.
892
859
  cblabel (str, optional): Colorbar label. Defaults to None.
893
860
  cbformat (float, optional): Format for ticklabels of colorbar. Defaults to '%.1e'.
@@ -905,7 +872,9 @@ class PlotAstroData(AstroFrame):
905
872
 
906
873
  if cblabel is None:
907
874
  cblabel = bunit
908
-
875
+ if stretchscale is None:
876
+ stretchscale = sigma
877
+
909
878
  stretch_args = (stretch, stretchscale, stretchpower)
910
879
  c = set_minmax(c, *stretch_args, sigma, _kw)
911
880
  c = self.vskipfill(c, v)
@@ -1018,7 +987,7 @@ class PlotAstroData(AstroFrame):
1018
987
  Args:
1019
988
  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'.
1020
989
  stretchscale (float, optional): Color scale is asinh(data / stretchscale). Defaults to None.
1021
- stretchpower (float, optional): Color scale is ((data / stretchscale)**stretchpower - 1) / stretchpower / ln(10). 1 means the linear scale, while 0 means the logarithmic scale. Defaults to 1.
990
+ stretchpower (float, optional): Color scale is data**stretchpower / stretchpower. 1 means the linear scale, while 0 means the logarithmic scale. Defaults to 1.
1022
991
  """
1023
992
  from PIL import Image
1024
993
 
@@ -1248,7 +1217,8 @@ class PlotAstroData(AstroFrame):
1248
1217
  tuple: (fig, ax)
1249
1218
  """
1250
1219
  if len(self.ax) > 1:
1251
- print('get_figax is not supported with channel maps')
1220
+ print('PlotAstroData.get_figax() is not supported'
1221
+ + ' with channel maps')
1252
1222
  return
1253
1223
 
1254
1224
  fig = plt.figure(0) if self.fig is None else self.fig
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.8.8
3
+ Version: 1.8.10
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