Skip to content

Commit

Permalink
fix instance unsafe get_total_cls
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Feb 18, 2019
1 parent 36d3442 commit ddf3637
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion camb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
__author__ = "Antony Lewis"
__contact__ = "antony at cosmologist dot info"
__version__ = "1.0.3"
__version__ = "1.0.4"

from . import baseconfig

Expand Down
Binary file modified camb/cambdll.dll
Binary file not shown.
6 changes: 5 additions & 1 deletion camb/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def calc_background(self, params):
"""
Calculate the background evolution and thermal history.
e.g. call this if you want to get derived parameters and call background functions
:param params: :class:`~.model.CAMBparams` instance to use
"""
self._check_params(params)
Expand Down Expand Up @@ -347,6 +348,8 @@ def _scale_cls(self, cls, CMB_unit=None, raw_cl=False, lens_potential=False):
def _lmax_setting(self, lmax=None, unlensed=False):
if self.Params.DoLensing and not unlensed:
lmax_calc = self.f_get_lmax_lensed()
if not lmax_calc:
raise CAMBError('lensed CL have not been calculated')
else:
lmax_calc = self.Params.max_l
if lmax is None:
Expand All @@ -355,14 +358,15 @@ def _lmax_setting(self, lmax=None, unlensed=False):
logging.warning('getting CMB power spectra to higher L than calculated, may be innacurate/zeroed.')
return lmax

def save_cmb_power_spectra(self, filename, lmax, CMB_unit='muK'):
def save_cmb_power_spectra(self, filename, lmax=None, CMB_unit='muK'):
r"""
Save CMB power to a plain text file. Output is lensed total :math:`\ell(\ell+1)C_\ell/2\pi` then lensing potential and cross: L TT EE BB TE PP PT PE.
:param filename: filename to save
:param lmax: lmax to save
:param CMB_unit: scale results from dimensionless. Use 'muK' for :math:`\mu K^2` units for CMB :math:`C_\ell` and :math:`\mu K` units for lensing cross.
"""
lmax = self._lmax_setting(lmax)
cmb = self.get_total_cls(lmax, CMB_unit=CMB_unit)
lens = self.get_lens_potential_cls(lmax, CMB_unit=CMB_unit)
ls = np.atleast_2d(np.arange(lmax + 1)).T
Expand Down
2 changes: 1 addition & 1 deletion fortran/camb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ subroutine CAMB_TransfersToPowers(CData)

if (CData%CP%WantCls) then
call ClTransferToCl(CData)
if (CP%DoLensing .and. global_error_flag==0) call lens_Cls(Cdata)
if (State%CP%DoLensing .and. global_error_flag==0) call lens_Cls(Cdata)
if (global_error_flag/=0) return
end if

Expand Down
4 changes: 2 additions & 2 deletions fortran/camb_python.f90
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ subroutine CAMB_SetTotCls(State,lmax, tot_scalar_Cls)
tot_scalar_cls(4,l) = State%CLData%Cl_scalar(l, C_Cross)
endif
end if
if (CP%WantTensors .and. l <= CP%Max_l_tensor) then
if (State%CP%WantTensors .and. l <= State%CP%Max_l_tensor) then
tot_scalar_cls(1:4,l) = tot_scalar_cls(1:4,l) &
+ State%CLData%Cl_tensor(l, CT_Temp:CT_Cross)
end if
Expand All @@ -392,7 +392,7 @@ subroutine CAMB_SetUnlensedCls(State,lmax, unlensed_cls)

unlensed_cls = 0
do l=State%CP%Min_l, lmax
if (State%CP%WantScalars .and. l<= CP%Max_l) then
if (State%CP%WantScalars .and. l<= State%CP%Max_l) then
unlensed_cls(1:2,l) = State%CLData%Cl_scalar(l, C_Temp:C_E)
unlensed_cls(4,l) = State%CLData%Cl_scalar(l, C_Cross)
end if
Expand Down
2 changes: 1 addition & 1 deletion fortran/config.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module config
use constants, only: const_twopi
implicit none

character(LEN=*), parameter :: version = '1.0.3'
character(LEN=*), parameter :: version = '1.0.4'

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

Expand Down

0 comments on commit ddf3637

Please sign in to comment.