plotastrodata 1.9.4__tar.gz → 1.9.6__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.9.4/plotastrodata.egg-info → plotastrodata-1.9.6}/PKG-INFO +1 -1
  2. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/fits_utils.py +8 -0
  4. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/plot_utils.py +60 -48
  5. {plotastrodata-1.9.4 → plotastrodata-1.9.6/plotastrodata.egg-info}/PKG-INFO +1 -1
  6. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/LICENSE +0 -0
  7. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/MANIFEST.in +0 -0
  8. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/README.md +0 -0
  9. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/analysis_utils.py +0 -0
  10. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/const_utils.py +0 -0
  11. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/coord_utils.py +0 -0
  12. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/ext_utils.py +0 -0
  13. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/fft_utils.py +0 -0
  14. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/fitting_utils.py +0 -0
  15. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/los_utils.py +0 -0
  16. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/matrix_utils.py +0 -0
  17. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/noise_utils.py +0 -0
  18. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata/other_utils.py +0 -0
  19. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata.egg-info/SOURCES.txt +0 -0
  20. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata.egg-info/dependency_links.txt +0 -0
  21. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata.egg-info/not-zip-safe +0 -0
  22. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata.egg-info/requires.txt +0 -0
  23. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/plotastrodata.egg-info/top_level.txt +0 -0
  24. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/setup.cfg +0 -0
  25. {plotastrodata-1.9.4 → plotastrodata-1.9.6}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.9.4
3
+ Version: 1.9.6
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.9.4'
4
+ __version__ = '1.9.6'
@@ -422,6 +422,14 @@ def data2fits(d: np.ndarray, h: dict = {},
422
422
  for k, v in defaults.items():
423
423
  for i in range(naxis):
424
424
  _h.setdefault(f'{k}{i+1:d}', v[i])
425
+ othernames = {'deg': ['DEG', 'Deg'], 'Hz': ['HZ', 'hz']}
426
+ for i in range(naxis):
427
+ key = f'CUNIT{i+1}'
428
+ old = _h[key].strip()
429
+ for standard, NGlist in othernames.items():
430
+ if old in NGlist:
431
+ _h[key] = standard
432
+ print(f'{key}={old} has been changed to {key}={standard}.')
425
433
  w.wcs.ctype = [_h[f'CTYPE{i+1}'] for i in range(naxis)]
426
434
  w.wcs.cunit = [_h[f'CUNIT{i+1}'] for i in range(naxis)]
427
435
  _h.setdefault('BUNIT', 'Jy/beam')
@@ -366,65 +366,77 @@ class PlotAxes2D():
366
366
  grid: dict | None = None
367
367
  aspect: dict | float | None = None
368
368
 
369
- def set_xyaxes(self, ax):
369
+ def _set_scale(self):
370
+ ax = self.ax
370
371
  if self.loglog is not None:
371
- self.xscale = 'log'
372
- self.yscale = 'log'
372
+ self.xscale = self.yscale = 'log'
373
373
  self.samexy = True
374
- if self.xlim is not None:
375
- self.xlim[0] = self.xlim[1] / self.loglog
376
- if self.ylim is not None:
377
- self.ylim[0] = self.ylim[1] / self.loglog
374
+ for axis in ["x", "y"]:
375
+ attr = f"{axis}lim"
376
+ lim = getattr(self, attr)
377
+ if lim is not None:
378
+ lim[0] = lim[1] / self.loglog
379
+ setattr(self, attr, lim)
378
380
  ax.set_xscale(self.xscale)
379
381
  ax.set_yscale(self.yscale)
382
+
383
+ def _init_ticks(self, axis):
384
+ ax = self.ax
385
+ ticks_attr = f"{axis}ticks"
386
+ ticklabels_attr = f"{axis}ticklabels"
387
+ scale = getattr(self, f"{axis}scale")
388
+ lim = getattr(self, f"{axis}lim")
389
+ ticks = getattr(self, ticks_attr)
390
+ if ticks is None:
391
+ ticks = getattr(ax, f"get_{axis}ticks")()
392
+ if scale == "log":
393
+ ticks, ticklabels = logticks(ticks, lim)
394
+ setattr(self, ticklabels_attr, ticklabels)
395
+ setattr(self, ticks_attr, ticks)
396
+
397
+ def _make_ticks(self, ticks, ticksminor):
398
+ dt = ticks[1] - ticks[0]
399
+ t = np.r_[ticks[0] - dt, ticks, ticks[-1] + dt]
400
+ num = ticksminor * (len(t) - 1) + 1
401
+ return np.linspace(t[0], t[-1], num)
402
+
403
+ def _set_ticks(self, axis):
404
+ ax = self.ax
405
+ attr = f"{axis}ticks"
406
+ ticks = getattr(self, attr)
407
+ getattr(ax, f"set_{attr}")(ticks)
408
+ ticksminor = getattr(self, f"{attr}minor")
409
+ if ticksminor is not None:
410
+ if isinstance(ticksminor, int):
411
+ ticksminor = self._make_ticks(ticks, ticksminor)
412
+ getattr(ax, f"set_{attr}")(ticksminor, minor=True)
413
+
414
+ def _apply_if_not_none(self, axis, attr):
415
+ ax = self.ax
416
+ method = getattr(ax, f"set_{axis}{attr}")
417
+ value = getattr(self, f"{axis}{attr}")
418
+ if value is not None:
419
+ if attr == "lim":
420
+ method(*value)
421
+ else:
422
+ method(value)
423
+
424
+ def set_xyaxes(self, ax):
425
+ self.ax = ax
426
+ self._set_scale()
380
427
  if self.samexy:
381
428
  ax.set_xticks(ax.get_yticks())
382
429
  ax.set_yticks(ax.get_xticks())
383
430
  ax.set_aspect(1)
384
- if self.xticks is None:
385
- self.xticks = ax.get_xticks()
386
- if self.xscale == 'log':
387
- self.xticks, self.xticklabels \
388
- = logticks(self.xticks, self.xlim)
389
- if self.yticks is None:
390
- self.yticks = ax.get_yticks()
391
- if self.yscale == 'log':
392
- self.yticks, self.yticklabels \
393
- = logticks(self.yticks, self.ylim)
394
- ax.set_xticks(self.xticks)
395
- ax.set_yticks(self.yticks)
396
- if self.xticksminor is not None:
397
- if type(self.xticksminor) is int:
398
- t = ax.get_xticks()
399
- dt = t[1] - t[0]
400
- t = np.r_[t[0] - dt, t, t[-1] + dt]
401
- num = self.xticksminor * (len(t) - 1) + 1
402
- self.xticksminor = np.linspace(t[0], t[-1], num)
403
- ax.set_xticks(self.xticksminor, minor=True)
404
- if self.yticksminor is not None:
405
- if type(self.yticksminor) is int:
406
- t = ax.get_yticks()
407
- dt = t[1] - t[0]
408
- t = np.r_[t[0] - dt, t, t[-1] + dt]
409
- num = self.yticksminor * (len(t) - 1) + 1
410
- self.yticksminor = np.linspace(t[0], t[-1], num)
411
- ax.set_yticks(self.yticksminor, minor=True)
412
- if self.xticklabels is not None:
413
- ax.set_xticklabels(self.xticklabels)
414
- if self.yticklabels is not None:
415
- ax.set_yticklabels(self.yticklabels)
416
- if self.xlabel is not None:
417
- ax.set_xlabel(self.xlabel)
418
- if self.ylabel is not None:
419
- ax.set_ylabel(self.ylabel)
420
- if self.xlim is not None:
421
- ax.set_xlim(*self.xlim)
422
- if self.ylim is not None:
423
- ax.set_ylim(*self.ylim)
431
+ for axis in ["x", "y"]:
432
+ self._init_ticks(axis)
433
+ self._set_ticks(axis)
434
+ for attr in ["ticklabels", "label", "lim"]:
435
+ self._apply_if_not_none(axis, attr)
424
436
  if self.grid is not None:
425
437
  ax.grid(**({} if self.grid is True else self.grid))
426
438
  if self.aspect is not None:
427
- if type(self.aspect) is dict:
439
+ if isinstance(self.aspect, dict):
428
440
  ax.set_aspect(**self.aspect)
429
441
  else:
430
442
  ax.set_aspect(self.aspect)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.9.4
3
+ Version: 1.9.6
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
File without changes