plotastrodata 1.8.18__tar.gz → 1.9.0__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.18/plotastrodata.egg-info → plotastrodata-1.9.0}/PKG-INFO +1 -1
  2. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/plot_utils.py +36 -19
  4. {plotastrodata-1.8.18 → plotastrodata-1.9.0/plotastrodata.egg-info}/PKG-INFO +1 -1
  5. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/LICENSE +0 -0
  6. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/MANIFEST.in +0 -0
  7. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/README.md +0 -0
  8. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/analysis_utils.py +0 -0
  9. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/const_utils.py +0 -0
  10. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/coord_utils.py +0 -0
  11. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/ext_utils.py +0 -0
  12. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/fft_utils.py +0 -0
  13. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/fits_utils.py +0 -0
  14. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/fitting_utils.py +0 -0
  15. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/los_utils.py +0 -0
  16. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/matrix_utils.py +0 -0
  17. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/noise_utils.py +0 -0
  18. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata/other_utils.py +0 -0
  19. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata.egg-info/SOURCES.txt +0 -0
  20. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata.egg-info/dependency_links.txt +0 -0
  21. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata.egg-info/not-zip-safe +0 -0
  22. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata.egg-info/requires.txt +0 -0
  23. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/plotastrodata.egg-info/top_level.txt +0 -0
  24. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/setup.cfg +0 -0
  25. {plotastrodata-1.8.18 → plotastrodata-1.9.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.8.18
3
+ Version: 1.9.0
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.18'
4
+ __version__ = '1.9.0'
@@ -132,9 +132,9 @@ def get_figsize(xmin: float, xmax: float, ymin: float, ymax: float,
132
132
 
133
133
 
134
134
  def _get_gridwidth(mode: str, rmax: float) -> tuple[float, int]:
135
- # 10^1.5 / 15 ~ 2 grids for R.A.
136
- # 10^0.5 ~ 3 grids for Dec.
137
- scale = 1.5 if mode == 'ra' else 0.5
135
+ # 10^1.45 / 15 ~ 2 grids for R.A.
136
+ # 10^0.45 ~ 3 grids for Dec.
137
+ scale = 1.45 if mode == 'ra' else 0.45
138
138
  x = np.log10(2. * rmax) - scale
139
139
  order = np.floor(x)
140
140
  frac = x - order
@@ -222,43 +222,51 @@ class Stretcher():
222
222
  getsigma = (islog + ispower) * novmin
223
223
  self.vmin = np.where(getsigma, sigma, vmin)
224
224
 
225
- def do(self, x: list | np.ndarray) -> np.ndarray:
225
+ def do(self, x: list | np.ndarray, i: int = 0) -> np.ndarray:
226
226
  """Get the stretched values.
227
227
 
228
228
  Args:
229
229
  x (list | np.ndarray): Input array in the linear scale.
230
+ i (int): Which element is used in the case where the stretch parameters are lists.
230
231
 
231
232
  Returns:
232
233
  np.ndarray: Output stretched array.
233
234
  """
235
+ st = self.stretch[i] if self.n > 1 else self.stretch
236
+ stsc = self.stretchscale[i] if self.n > 1 else self.stretchscale
237
+ stpw = self.stretchpower[i] if self.n > 1 else self.stretchpower
234
238
  t = np.array(x)
235
- match self.stretch:
239
+ match st:
236
240
  case 'log':
237
241
  t = np.log10(t) # To be consistent with logcbticks().
238
242
  case 'asinh':
239
- t = np.arcsinh(t / self.stretchscale)
243
+ t = np.arcsinh(t / stsc)
240
244
  case 'power':
241
- p = 1e-6 if self.stretchpower == 0 else self.stretchpower
245
+ p = 1e-6 if stpw == 0 else stpw
242
246
  t = t**p / p
243
247
  return t
244
248
 
245
- def undo(self, x: list | np.ndarray) -> np.ndarray:
249
+ def undo(self, x: list | np.ndarray, i: int = 0) -> np.ndarray:
246
250
  """Get the linear values from the stretched values.
247
251
 
248
252
  Args:
249
253
  x (list | np.ndarray): Input stretched array.
254
+ i (int): Which element is used in the case where the stretch parameters are lists.
250
255
 
251
256
  Returns:
252
257
  np.ndarray: Output array in the linear scale.
253
258
  """
259
+ st = self.stretch[i] if self.n > 1 else self.stretch
260
+ stsc = self.stretchscale[i] if self.n > 1 else self.stretchscale
261
+ stpw = self.stretchpower[i] if self.n > 1 else self.stretchpower
254
262
  t = np.array(x)
255
- match self.stretch:
263
+ match st:
256
264
  case 'log':
257
265
  t = 10**t # To be consistent with logcbticks().
258
266
  case 'asinh':
259
- t = np.sinh(t) * self.stretchscale
267
+ t = np.sinh(t) * stsc
260
268
  case 'power':
261
- p = 1e-6 if self.stretchpower == 0 else self.stretchpower
269
+ p = 1e-6 if stpw == 0 else stpw
262
270
  t = (t * p)**(1 / p)
263
271
  return t
264
272
 
@@ -277,7 +285,7 @@ class Stretcher():
277
285
  vmaxout = [self.vmax] if single else self.vmax
278
286
  dataout = [data] if single else data
279
287
  for i, (c, v0, v1) in enumerate(zip(dataout, vminout, vmaxout)):
280
- dataout[i] = cout = self.do(c.clip(v0, v1))
288
+ dataout[i] = cout = self.do(c.clip(v0, v1), i)
281
289
  vminout[i] = np.nanmin(cout)
282
290
  vmaxout[i] = np.nanmax(cout)
283
291
  if single:
@@ -428,7 +436,7 @@ def kwargs2instance(cls: type[T], kw: dict) -> T:
428
436
 
429
437
  Args:
430
438
  cls (class): Class to make the instance.
431
- kw (dict): Parameters to make Stretcher.
439
+ kw (dict): Parameters to make the instance.
432
440
 
433
441
  Returns:
434
442
  instance: an instance of cls made from the parameters in kwargs.
@@ -787,7 +795,9 @@ class PlotAstroData(AstroFrame):
787
795
  def _set_colorbar(self, mappable, ch: int, show_cbar: bool,
788
796
  cblabel: str, cbformat: str,
789
797
  cbticks: list | None, cbticklabels: list | None,
790
- cblocation: str, st: Stretcher):
798
+ cblocation: str,
799
+ cblabelfontsize: int, cbtickfontsize: int,
800
+ st: Stretcher):
791
801
  if not show_cbar:
792
802
  return
793
803
 
@@ -803,8 +813,8 @@ class PlotAstroData(AstroFrame):
803
813
  cax = plt.axes([0.88, 0.105, 0.015, 0.77])
804
814
  cb = fig.colorbar(mappable[ch], cax=cax, label=cblabel,
805
815
  format=cbformat)
806
- cb.ax.tick_params(labelsize=14)
807
- font = mpl.font_manager.FontProperties(size=16)
816
+ cb.ax.tick_params(labelsize=cbtickfontsize)
817
+ font = mpl.font_manager.FontProperties(size=cblabelfontsize)
808
818
  cb.ax.yaxis.label.set_font_properties(font)
809
819
  if cbticks is None and st.stretch == 'log':
810
820
  cbticks, cbticklabels = logcbticks(10**st.vmin, 10**st.vmax)
@@ -825,6 +835,8 @@ class PlotAstroData(AstroFrame):
825
835
  cbticks: list[float] | None = None,
826
836
  cbticklabels: list[str] | None = None,
827
837
  cblocation: str = 'right',
838
+ cblabelfontsize: int = 16,
839
+ cbtickfontsize: int = 14,
828
840
  **kwargs) -> None:
829
841
  """Use Axes.pcolormesh of matplotlib. kwargs must include the arguments of AstroData to specify the data to be plotted. kwargs may include the arguments for Stretcher (stretch, stretchscale, and stretchpower) to specify the stretch parameters. kwargs may include arguments of Beam; a dict of beam_kwargs specifies the beam patch in more detail. kwargs may include xskiip and yskip.
830
842
 
@@ -835,6 +847,8 @@ class PlotAstroData(AstroFrame):
835
847
  cbticks (list, optional): Ticks of colorbar. Defaults to None.
836
848
  cbticklabels (list, optional): Ticklabels of colorbar. Defaults to None.
837
849
  cblocation (str, optional): 'left', 'top', 'left', 'right'. Only for 2D images. Defaults to 'right'.
850
+ cblabelfontsize (int, optional): Fontsize for the colorbar label. This is independent of set_rcparams().
851
+ cbtickfontsize (int, optional): Fontsize for the colorbar ticks. This is independent of set_rcparams().
838
852
  """
839
853
  self._kw = {'cmap': 'cubehelix', 'alpha': 1,
840
854
  'edgecolors': 'none', 'zorder': 1,
@@ -861,7 +875,8 @@ class PlotAstroData(AstroFrame):
861
875
  p[ch] = pnow
862
876
  for ch in self.bottomleft:
863
877
  self._set_colorbar(p, ch, show_cbar, cblabel, cbformat,
864
- cbticks, cbticklabels, cblocation, st)
878
+ cbticks, cbticklabels, cblocation,
879
+ cblabelfontsize, cbtickfontsize, st)
865
880
 
866
881
  def add_contour(self,
867
882
  levels: list[float] = [-12, -6, -3, 3, 6, 12, 24, 48, 96, 192, 384],
@@ -1088,7 +1103,9 @@ class PlotAstroData(AstroFrame):
1088
1103
  'dec': {'d': r'$^{\circ}$',
1089
1104
  'm': r'$^{\prime}$',
1090
1105
  's': r'.$\hspace{-0.4}^{\prime\prime}$'}}
1091
- cos_dec = np.cos(np.radians(coord2xy(center)[1]))
1106
+ dec_center = coord2xy(center)[1]
1107
+ sign_dec = np.sign(dec_center)
1108
+ cos_dec = np.cos(np.radians(dec_center))
1092
1109
  intgrid = np.array([-3, -2, -1, 0, 1, 2, 3])
1093
1110
  i_mid = (len(intgrid) - 1) // 2
1094
1111
 
@@ -1102,7 +1119,7 @@ class PlotAstroData(AstroFrame):
1102
1119
  rounded = round(second, ndigits=max(-order, -1))
1103
1120
  # Get a grid point closest to the input second.
1104
1121
  rounded = round(rounded / gridwidth) * gridwidth
1105
- factor = 15 * cos_dec if mode == 'ra' else 1
1122
+ factor = 15 * cos_dec if mode == 'ra' else sign_dec
1106
1123
  ticks = (intgrid * gridwidth - second + rounded) * factor
1107
1124
  ticksminor = np.linspace(ticks[0], ticks[-1], 6*nticksminor + 1)
1108
1125
  tickvalues = get_tickvalues(ticks, mode, no_sec)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.8.18
3
+ Version: 1.9.0
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