Skip to content

Commit 6288643

Browse files
committed
fix get_matter_power_spectrum for cross-spectra
1 parent 727ecae commit 6288643

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

camb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
__author__ = "Antony Lewis"
88
__contact__ = "antony at cosmologist dot info"
99
__url__ = "https://camb.readthedocs.io"
10-
__version__ = "1.3.6"
10+
__version__ = "1.3.7"
1111

1212
from . import baseconfig
1313

camb/cambdll.dll

512 Bytes
Binary file not shown.

camb/correlations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ def lensed_cl_derivatives(cls, clpp, lmax=None, theta_max=np.pi / 32,
446446
:param apodize_point_width: if theta_max is set, apodize around the cut using half Gaussian of approx
447447
width apodize_point_width/lmax*pi
448448
:param sampling_factor: npoints = int(sampling_factor*lmax)+1
449-
:return: array dCL[ix, ell, L], where ix=0,1,2,3 are T, EE, BB, TE and r
450-
esult is :math:`d[D^{\rm ix}_\ell]/ d (\log C^{\phi}_L)`
449+
:return: array dCL[ix, ell, L], where ix=0,1,2,3 are T, EE, BB, TE and result
450+
is :math:`d[D^{\rm ix}_\ell]/ d (\log C^{\phi}_L)`
451451
452452
"""
453453

camb/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ def set_H0_for_theta(self, theta, cosmomc_approx=False, theta_H0_range=(10, 100)
365365
:param cosmomc_approx: if true, use approximate fitting formula for :math:`z_\star`,
366366
if false do full numerical calculation
367367
:param theta_H0_range: min, max iterval to search for H0 (in km/s/Mpc)
368-
:param est_H0: an initial guess for H0 in km/s/Mpc, used in the case comsomc_approx=False.
369-
:param iteration_threshold: differnce in H0 from est_H0 for which to iterate, used for cosmomc_approx=False
368+
:param est_H0: an initial guess for H0 in km/s/Mpc, used in the case cosmomc_approx=False.
369+
:param iteration_threshold: difference in H0 from est_H0 for which to iterate, used for cosmomc_approx=False
370370
"""
371371

372372
if not (0.001 < theta < 0.1):
@@ -425,7 +425,7 @@ def set_cosmology(self, H0: Optional[float] = None, ombh2=0.022, omch2=0.12, omk
425425
(cosmomc_theta, which is based on a fitting forumula for simple models, or thetastar, which is numerically
426426
calculated more generally). Note that you must have already set the dark energy model, you can't use
427427
set_cosmology with theta and then change the background evolution (which would change theta at the calculated
428-
H0 value).Likewise the dark energy model cannot depend explicitly on H0.
428+
H0 value). Likewise the dark energy model cannot depend explicitly on H0.
429429
430430
:param H0: Hubble parameter today in km/s/Mpc. Can leave unset and instead set thetastar or cosmomc_theta
431431
(which solves for the required H0).

fortran/config.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module config
33
use constants, only: const_twopi
44
implicit none
55

6-
character(LEN=*), parameter :: version = '1.3.6'
6+
character(LEN=*), parameter :: version = '1.3.7'
77

88
integer :: FeedbackLevel = 0 !if >0 print out useful information about the model
99

fortran/results.f90

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,9 @@ end function CAMBdata_AngularDiameterDistance2
737737

738738
subroutine CAMBdata_AngularDiameterDistance2Arr(this, arr, z1, z2, n)
739739
class(CAMBdata) :: this
740+
integer, intent(in) :: n
740741
real(dl), intent(out) :: arr(n)
741742
real(dl), intent(in) :: z1(n), z2(n)
742-
integer, intent(in) :: n
743743
integer i
744744

745745
!$OMP PARALLEL DO DEFAULT(SHARED),SCHEDULE(STATIC)
@@ -3461,7 +3461,8 @@ subroutine Transfer_GetMatterPowerD(State, MTrans, outpower, itf_PK, minkh, dlnk
34613461
real(dl) matpower(MTrans%num_q_trans), kh, kvals(MTrans%num_q_trans), ddmat(MTrans%num_q_trans)
34623462
real(dl) atransfer,xi, a0, b0, ho, logmink,k, h
34633463
integer itf
3464-
integer :: s1,s2
3464+
integer :: s1,s2, sign
3465+
logical log_interp
34653466
real(dl), allocatable :: ratio(:)
34663467

34673468
s1 = PresentDefault (transfer_power_var, var1)
@@ -3489,10 +3490,19 @@ subroutine Transfer_GetMatterPowerD(State, MTrans, outpower, itf_PK, minkh, dlnk
34893490
atransfer=MTrans%TransferData(s1,ik,itf)*MTrans%TransferData(s2,ik,itf)
34903491
if (State%CP%NonLinear/=NonLinear_none .and. State%CP%NonLinear/=NonLinear_Lens) &
34913492
atransfer = atransfer* ratio(ik)**2 !only one element, this itf
3492-
matpower(ik) = log(atransfer*k*const_pi*const_twopi*h**3)
3493+
matpower(ik) = atransfer*k*const_pi*const_twopi*h**3
34933494
!Put in power spectrum later: transfer functions should be smooth, initial power may not be
34943495
end do
3495-
3496+
sign = 1
3497+
log_interp = .true.
3498+
if (any(matpower <= 0)) then
3499+
if (all(matpower < 0)) then
3500+
sign = -1
3501+
else
3502+
log_interp = .false.
3503+
endif
3504+
endif
3505+
if (log_interp) matpower = log(sign*matpower)
34963506
call spline(kvals,matpower,MTrans%num_q_trans,cllo,clhi,ddmat)
34973507

34983508
llo=1
@@ -3527,7 +3537,9 @@ subroutine Transfer_GetMatterPowerD(State, MTrans, outpower, itf_PK, minkh, dlnk
35273537
lastix = lastix+1
35283538
end do
35293539

3530-
outpower = exp(max(-30.d0,outpower))
3540+
if (log_interp) then
3541+
outpower = sign*exp(max(-30.d0,outpower))
3542+
end if
35313543
associate(InitPower => State%CP%InitPower)
35323544
do il = 1, npoints
35333545
k = exp(logmink + dlnkh*(il-1))*h

0 commit comments

Comments
 (0)