Skip to content

Commit

Permalink
c_kms in const_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukeaso-astron committed Dec 17, 2024
1 parent bded5d0 commit b4fcf6d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plotastrodata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import warnings

warnings.simplefilter('ignore', UserWarning)
__version__ = '1.0.5-2'
__version__ = '1.0.6'
7 changes: 3 additions & 4 deletions plotastrodata/analysis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from scipy.interpolate import RegularGridInterpolator as RGI
from scipy.optimize import curve_fit
from scipy.signal import convolve
from astropy import constants

from plotastrodata.other_utils import (coord2xy, rel2abs, estimate_rms, trim,
Mfac, Mrot, dot2d, gaussian2d)
from plotastrodata.fits_utils import FitsData, data2fits, Jy2K
from plotastrodata import const_utils as cu


def to4dim(data: np.ndarray) -> np.ndarray:
Expand Down Expand Up @@ -510,11 +510,10 @@ def writetofits(self, fitsimage: str = 'out.fits', header: dict = {}):
h['CRVAL2'] = cy
h['CDELT2'] = (self.y[1] - self.y[0]) / 3600
if self.v is not None:
clight = constants.c.to('km*s**(-1)').value
h['NAXIS3'] = len(self.v)
h['CRPIX3'] = i = np.argmin(np.abs(self.v)) + 1
h['CRVAL3'] = (1 - self.v[i]/clight) * self.restfreq
h['CDELT3'] = (self.v[0]-self.v[1]) / clight * self.restfreq
h['CRVAL3'] = (1 - self.v[i]/cu.c_kms) * self.restfreq
h['CDELT3'] = (self.v[0]-self.v[1]) / cu.c_kms * self.restfreq
if None not in self.beam:
h['BMAJ'] = self.beam[0] / 3600
h['BMIN'] = self.beam[1] / 3600
Expand Down
1 change: 1 addition & 0 deletions plotastrodata/const_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@
# Others
mumol = 2.37 * m_p # kg; Kauffmann et al. 2008, for sound speed
muH2 = 2.8 * m_p # kg; Kauffmann et al. 2008, for mass-H2 conversion
c_kms = constants.c.to('km*s**(-1)').value
5 changes: 3 additions & 2 deletions plotastrodata/fits_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
from astropy.io import fits
from astropy import constants, units, wcs
from astropy import units, wcs

from plotastrodata.other_utils import coord2xy, xy2coord, estimate_rms, trim
from plotastrodata import const_utils as cu


def Jy2K(header=None, bmaj: float | None = None, bmin: float | None = None,
Expand Down Expand Up @@ -219,7 +220,7 @@ def gen_v(s: np.ndarray) -> None:
if freq == 0:
print('v is frequency because restfreq=0.')
else:
s = (1 - s / freq) * constants.c.to('km*s**(-1)').value - vsys
s = (1 - s / freq) * cu.c_kms - vsys
self.v, self.dv = s, s[1] - s[0]

if h['NAXIS'] > 0 and h['NAXIS1'] > 1:
Expand Down

0 comments on commit b4fcf6d

Please sign in to comment.