plotastrodata 1.0.5.post2__tar.gz → 1.0.7__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 (20) hide show
  1. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/PKG-INFO +1 -1
  2. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/__init__.py +1 -1
  3. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/analysis_utils.py +3 -4
  4. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/const_utils.py +1 -0
  5. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/fits_utils.py +34 -5
  6. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata.egg-info/PKG-INFO +1 -1
  7. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/LICENSE +0 -0
  8. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/README.md +0 -0
  9. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/fft_utils.py +0 -0
  10. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/fitting_utils.py +0 -0
  11. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/los_utils.py +0 -0
  12. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/other_utils.py +0 -0
  13. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata/plot_utils.py +0 -0
  14. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata.egg-info/SOURCES.txt +0 -0
  15. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata.egg-info/dependency_links.txt +0 -0
  16. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata.egg-info/not-zip-safe +0 -0
  17. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata.egg-info/requires.txt +0 -0
  18. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/plotastrodata.egg-info/top_level.txt +0 -0
  19. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/setup.cfg +0 -0
  20. {plotastrodata-1.0.5.post2 → plotastrodata-1.0.7}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plotastrodata
3
- Version: 1.0.5.post2
3
+ Version: 1.0.7
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.0.5-2'
4
+ __version__ = '1.0.7'
@@ -3,11 +3,11 @@ from dataclasses import dataclass
3
3
  from scipy.interpolate import RegularGridInterpolator as RGI
4
4
  from scipy.optimize import curve_fit
5
5
  from scipy.signal import convolve
6
- from astropy import constants
7
6
 
8
7
  from plotastrodata.other_utils import (coord2xy, rel2abs, estimate_rms, trim,
9
8
  Mfac, Mrot, dot2d, gaussian2d)
10
9
  from plotastrodata.fits_utils import FitsData, data2fits, Jy2K
10
+ from plotastrodata import const_utils as cu
11
11
 
12
12
 
13
13
  def to4dim(data: np.ndarray) -> np.ndarray:
@@ -510,11 +510,10 @@ class AstroData():
510
510
  h['CRVAL2'] = cy
511
511
  h['CDELT2'] = (self.y[1] - self.y[0]) / 3600
512
512
  if self.v is not None:
513
- clight = constants.c.to('km*s**(-1)').value
514
513
  h['NAXIS3'] = len(self.v)
515
514
  h['CRPIX3'] = i = np.argmin(np.abs(self.v)) + 1
516
- h['CRVAL3'] = (1 - self.v[i]/clight) * self.restfreq
517
- h['CDELT3'] = (self.v[0]-self.v[1]) / clight * self.restfreq
515
+ h['CRVAL3'] = (1 - self.v[i]/cu.c_kms) * self.restfreq
516
+ h['CDELT3'] = (self.v[0]-self.v[1]) / cu.c_kms * self.restfreq
518
517
  if None not in self.beam:
519
518
  h['BMAJ'] = self.beam[0] / 3600
520
519
  h['BMIN'] = self.beam[1] / 3600
@@ -81,3 +81,4 @@ quecto = 1e-30
81
81
  # Others
82
82
  mumol = 2.37 * m_p # kg; Kauffmann et al. 2008, for sound speed
83
83
  muH2 = 2.8 * m_p # kg; Kauffmann et al. 2008, for mass-H2 conversion
84
+ c_kms = constants.c.to('km*s**(-1)').value
@@ -1,8 +1,9 @@
1
1
  import numpy as np
2
2
  from astropy.io import fits
3
- from astropy import constants, units, wcs
3
+ from astropy import units, wcs
4
4
 
5
5
  from plotastrodata.other_utils import coord2xy, xy2coord, estimate_rms, trim
6
+ from plotastrodata import const_utils as cu
6
7
 
7
8
 
8
9
  def Jy2K(header=None, bmaj: float | None = None, bmin: float | None = None,
@@ -216,10 +217,38 @@ class FitsData:
216
217
  print('restfreq is assumed to be the center.')
217
218
  else:
218
219
  freq = restfreq
219
- if freq == 0:
220
- print('v is frequency because restfreq=0.')
221
- else:
222
- s = (1 - s / freq) * constants.c.to('km*s**(-1)').value - vsys
220
+
221
+ vaxis = '2' if pv else '3'
222
+ key = f'CUNIT{vaxis}'
223
+ cunitv = h[key]
224
+ match cunitv:
225
+ case 'Hz':
226
+ if freq == 0:
227
+ print('v is frequency because restfreq=0.')
228
+ else:
229
+ s = (1 - s / freq) * cu.c_kms - vsys
230
+ case 'HZ':
231
+ if freq == 0:
232
+ print('v is frequency because restfreq=0.')
233
+ else:
234
+ s = (1 - s / freq) * cu.c_kms - vsys
235
+ case 'm/s':
236
+ print(f'{key}=\'m/s\' was found.')
237
+ s = s * 1e-3 - vsys
238
+ case 'M/S':
239
+ print(f'{key}=\'M/S\' was found.')
240
+ s = s * 1e-3 - vsys
241
+ case 'km/s':
242
+ print(f'{key}=\'km/s\' was found.')
243
+ s = s - vsys
244
+ case 'KM/S':
245
+ print(f'{key}=\'KM/S\' was found.')
246
+ s = s - vsys
247
+ case _:
248
+ print(f'Unknown CUNIT3 {cunitv} was found.'
249
+ + ' v is read as is.')
250
+ s = s - vsys
251
+
223
252
  self.v, self.dv = s, s[1] - s[0]
224
253
 
225
254
  if h['NAXIS'] > 0 and h['NAXIS1'] > 1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plotastrodata
3
- Version: 1.0.5.post2
3
+ Version: 1.0.7
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