Skip to content
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

Mcmc debug #60

Merged
merged 6 commits into from
Nov 13, 2024
Merged

Mcmc debug #60

merged 6 commits into from
Nov 13, 2024

Conversation

cwjames1983
Copy link
Collaborator

I have altered the definition of bins in grid.py

Checks have been done that MC FRBs get generated according to the new grid, AND that likelihoods get correctly evaluated in 1D and 2D

This change has lots of little things, but is pretty important, so I'm asking you both to check it.

I've temporarily left some commented-out code in for comparative purposes in likelihoods. But some old code in comments can easily be deleted.

Copy link
Contributor

@profxj profxj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments here and there but nothing significant enough for
me to not Approve. So I am.

dkzs1 = 1. - dkzs2

# checks for values which are too large
toobigz = np.where(zlist > self.zvals[-1] + self.dz/2.)[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might put this at the start of the method

NOTE: the routine GenMCFRB does not know 'w', merely
which w bin it generates.

"""
# Boost?
if self.state.energy.luminosity_function in [1, 2]:
Emax_boost = 2.0
Emax_boost = 3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this variable described somewhere?

#MCz = self.zvals[iz2] + (kz2-0.5)*dz

# weigts between iz1 and iz2
if fz < 0.5:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not the prettiest code
is it at least efficient?

Eth = self.thresholds[j, iz2, iDM2] * kDM2
Eth *= kz2 ** 2 # assume threshold goes as Eth~z^2 in the near Universe

fDM = r / pDMc[iDM2]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also appears rather inefficient..
but I'd have to look really carefully to see if there
were obvious speed-ups

idms1=kdms.astype('int')
idms2=idms1+1
dkdms=kdms-idms1
#ddm=dmvals[1]-dmvals[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

idmobs2=idmobs1+1
dkdmobs=kdmobs-idmobs1 # applies to idms2

#kdmobs=(survey.DMs - np.median(survey.DMGs + survey.DMhalos))/ddm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

# get indices in z space. See dm comments above. This will not work for log-spaced z
#dz=zvals[1]-zvals[0]
#kzs=Zobs/dz - 0.5
#Bin0 = np.where(kzs < 0.)[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

# The thresholds have already been calculated at mean values
# of the below quantities. Hence, we use the DM relative to
# those means, not the actual DMEG for that FRB
#kdmobs=(survey.DMs - np.median(survey.DMGs + survey.DMhalos))/ddm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

@@ -0,0 +1,244 @@
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is only for testing, can we move it into tests/

"""
# get indices in dm space
kdms=DMlist/self.ddm - 0.5 # idea: if DMobs = ddm, we are half-way between bin 0 and bin 1
Bin0 = np.where(kdms < 0.)[0] # if DMs are in the lower half of the lowest bin, use lowest bin only
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow this comment. Is this line not redundant as kdms should start at 1 so -0.5 means it will never go negative? Same for kzs below.

@JordanHoffmann3 JordanHoffmann3 merged commit f2f08b5 into mcmc_reps Nov 13, 2024
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants