Skip to content

Commit

Permalink
fix: Avoid division by zero error in Local Group mass function analys…
Browse files Browse the repository at this point in the history
…is if no host halos were found

If no host halos meet the criteria for the Local Group mass function analysis then the host halo weight will be zero. In such cases we now report an impossible log-likelihood instead of attempting to normalize by this weight.
  • Loading branch information
abensonca committed Jul 28, 2021
1 parent fa11391 commit 03e574d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions source/galacticus.output.analyses.Local_Group_mass_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -550,17 +550,19 @@ subroutine localGroupMassFunctionFinalizeAnalysis(self)
! Normalize the mass function.
weight = sum(massFunctionCentrals)
weightVariance = sum(covarianceCentrals )
self%massFunction=+self%massFunction/weight
self%covariance =+self%covariance /weight**2
do i=1_c_size_t,size(self%massFunction)
do j=1_c_size_t,size(self%massFunction)
self%covariance(i,j)=+self%covariance (i,j) &
& +self%massFunction(i ) &
& *self%massFunction( j) &
& *weightVariance &
& /weight **2
if (weight > 0.0d0) then
self%massFunction=+self%massFunction/weight
self%covariance =+self%covariance /weight**2
do i=1_c_size_t,size(self%massFunction)
do j=1_c_size_t,size(self%massFunction)
self%covariance(i,j)=+self%covariance (i,j) &
& +self%massFunction(i ) &
& *self%massFunction( j) &
& *weightVariance &
& /weight **2
end do
end do
end do
end if
return
end subroutine localGroupMassFunctionFinalizeAnalysis

Expand Down

0 comments on commit 03e574d

Please sign in to comment.