Skip to content

Commit

Permalink
Use Cosmo_Conversions functions for unit conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
philbull committed Apr 25, 2018
1 parent d89bcdc commit 81436a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions hera_pspec/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ def f2z(self, freq, ghz=False):
freq = freq * 1e9

return (units.f21 / freq - 1)

def z2f(self, z, ghz=False):

@staticmethod
def z2f(z, ghz=False):
"""
convert redshift to frequency in Hz for 21cm line
Expand Down
5 changes: 3 additions & 2 deletions hera_pspec/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import md5
from conversions import Cosmo_Conversions

def hash(w):
"""
Expand Down Expand Up @@ -178,11 +179,11 @@ def spw_range_from_redshifts(data, z_range, bounds_error=True):
z_range = [z_range,]

# Convert redshifts to frequencies (in Hz)
NU21CM = 1420405751.7667 # 21cm rest freq. in Hz
freq_range = []
for zrange in z_range:
zmin, zmax = zrange
freq_range.append( (NU21CM/(1.+zmax), NU21CM/(1.+zmin)) )
freq_range.append( Cosmo_Conversions.z2f(zmax),
Cosmo_Conversions.z2f(zmin) )

# Use freq. function to get spectral window
spw_range = spw_range_from_freqs(data=data, freq_range=freq_range,
Expand Down

0 comments on commit 81436a8

Please sign in to comment.