-
Notifications
You must be signed in to change notification settings - Fork 0
Infrastructure improvements for power spectrum fitting #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… tau and k_parallel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Albin! There are just a few minor cleanups we should do before merging these updates
print(f"Directory {d} does not match expected format, rejecting") | ||
continue | ||
|
||
key = mo.group(1) | ||
print(f"Processing directory: {d}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(f"Processing directory: {d}") | |
logger.debug(f"Processing directory: {d}") |
Let's move to using logger
instead of print
. (There's a mix of logger
and print
throughout fitstack
, and we should eventually change all the other print
statements to use logger
for consistency.)
nu21: float = 1420.40575177, # MHz | ||
z_eff: Optional[float] = None, # effective redshift | ||
cs: float = 299792.458, # speed of light in km/s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nu21: float = 1420.40575177, # MHz | |
z_eff: Optional[float] = None, # effective redshift | |
cs: float = 299792.458, # speed of light in km/s | |
z_eff: Optional[float] = None, # effective redshift |
nu21
and the speed of light are defined in cora.util.units
, so we should use those definitions.
|
||
# Set default z_eff if None | ||
self.z_eff = z_eff if z_eff is not None else 1.0 | ||
cosmo_cora = cosmology.Cosmology() | ||
self.H_z = cosmo_cora.H(self.z_eff) * u.mega_parsec / 1000. # In km/s/Mpc | ||
self.nu21 = nu21 | ||
self.cs = cs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Set default z_eff if None | |
self.z_eff = z_eff if z_eff is not None else 1.0 | |
cosmo_cora = cosmology.Cosmology() | |
self.H_z = cosmo_cora.H(self.z_eff) * u.mega_parsec / 1000. # In km/s/Mpc | |
self.nu21 = nu21 | |
self.cs = cs | |
# Set default z_eff if None | |
self.z_eff = z_eff if z_eff is not None else 1.0 | |
cosmo_cora = cosmology.Cosmology() | |
self.H_z = cosmo_cora.H(self.z_eff) * u.mega_parsec / 1000. # In km/s/Mpc |
Remove local values of nu21
and cs
Conversion factor | ||
""" | ||
|
||
C = (-1.0 / (2 * np.pi * self.nu21)) * (self.cs / self.H_z) * (1 + self.z_eff)**2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C = (-1.0 / (2 * np.pi * self.nu21)) * (self.cs / self.H_z) * (1 + self.z_eff)**2 | |
C = (-1.0 / (2 * np.pi * u.nu21)) * ((u.c / u.kilo) / self.H_z) * (1 + self.z_eff)**2 |
Use cora
's nu21
and speed of light.
Also, let's add a comment about the assumed units of k_parallel
and tau
that this factor is converting between.
@@ -1101,7 +1140,9 @@ def multiply_pre_noncomp(self, signal: np.ndarray, **kwargs) -> np.ndarray: | |||
signal : np.ndarray[npol, nkpar, nkperp] | |||
The 2d power spectrum after multiplication with the relative FoG kernel. | |||
""" | |||
|
|||
# Calculate the conversion factor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Calculate the conversion factor | |
# Calculate the conversion factor that converts from k_parallel to tau |
signal *= (1.0 + (scale0 * C * self.kpar[np.newaxis, :, np.newaxis]) ** 2) / ( | ||
1.0 + (scale * C * self.kpar[np.newaxis, :, np.newaxis]) ** 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be useful to have a comment here about the units of kpar
and scale0
@@ -424,7 +424,16 @@ def average_data(cnt, pol=None, combine=True, sort=True): | |||
distributed=False, | |||
) | |||
avg.ps2D[:] = np.mean(darr, axis=0) | |||
avg.ps2D_weight[:] = tools.invert_no_zero(np.var(darr, axis=0)) | |||
#avg.ps2D_weight[:] = tools.invert_no_zero(np.var(darr, axis=0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#avg.ps2D_weight[:] = tools.invert_no_zero(np.var(darr, axis=0)) |
Remove unneeded comment
No description provided.