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

basic powerspectra code + example #4

Merged
merged 6 commits into from
Apr 27, 2020
Merged

basic powerspectra code + example #4

merged 6 commits into from
Apr 27, 2020

Conversation

bhorowitz
Copy link
Collaborator

A little tf implementation of a powerspectra estimator (more or less copied from nbodykit's projected PS implementation)... It seems to match that from nbodykit in the couple realizations/boxsizes I chose. It currently doesn't go up to as high of k as nbodykit by default; probably something to do with nyquist frequency definitions.

The IO for the pk function is very rough; depending on how we end up defining other functions perhaps there could be some standardization such as wrapping up all ps-related functions (sigma8? HMF?) in some class.

code/utils/ps.py Outdated
W[...] = 2.0
W[..., 0] = 1.0
W[..., -1] = 1.0
kedges = np.arange(kmin, np.pi * 10 / 1 + dk/2, dk)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

probably should go to higher k here... not sure if we want to have a kmax or similar option here...

code/utils/ps.py Outdated
Comment on lines 29 to 30
dig = tf.Variable(dig,dtype=tf.int32)
Nsum = tf.Variable(Nsum,dtype=tf.complex64)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think these really have to be tf.Variables, but things work if they are tf variables? shrug

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe I could spend like 5 minutes to make this whole part differentiable too in case someone ever wants to take the derivative with respect to box size :P

@EiffL
Copy link
Member

EiffL commented Apr 3, 2020

I've looked at this PR, it looks pretty good :-) I'll just wait until we have code to do the CIC painting, so that we can test computing the powerspectrum directly from a TF field.
This is going to happen with #18

@EiffL EiffL added enhancement New feature or request good first issue Good for newcomers labels Apr 24, 2020
@EiffL EiffL added this to the paper:baseline milestone Apr 24, 2020
@EiffL
Copy link
Member

EiffL commented Apr 24, 2020

Ok, so I've used this stuff in this demo notebook:
https://github.com/DifferentiableUniverseInitiative/DHOD/blob/u/EiffL/FlowPM/nb/PowerSpectrum.ipynb

It seems to work :-) but I have a few comments:

  • It seems that the code does work if my box has nc=128, and bs=250, there are bins with Num =0 in it, so that it returns NaNs. It's essentially I think just a matter of not creating a k vector too long, but I haven't worked it through....

  • Could you move only the pk code (and associated function) to a file in

diffhod/mock_observables/power_spectrum.py

This way, it follows a structure similar to halotools, and then people would use with:

from diffhod.mock_observables import pk
... = pk(....)

@bhorowitz
Copy link
Collaborator Author

bhorowitz commented Apr 27, 2020

Okay! I fixed the kmax issue, and added a very trivial test (pk of noise) which I compared vs. nbodykit's powerspectra. I wasn't sure if we wanted to add a requirement for flowpm in order to do a slightly more nuanced test involving a flowpm mesh object with a real density field.

@EiffL
Copy link
Member

EiffL commented Apr 27, 2020

Awesome :-D I'm happy to leave flowpm out of the validation of the power spectrum. waiting to see if we get the green light from github CI :-)

@EiffL
Copy link
Member

EiffL commented Apr 27, 2020

Ok fantatstic! Let me just try to massage the PR into a cleaner version....

@EiffL
Copy link
Member

EiffL commented Apr 27, 2020

@bhorowitz here is the magic I used to clean up the PR and only show your modifications in the list of changed files:

$ git checkout diffps
$ git rebase origin/master
$ git push -f

That simplifies the git history, and only keeps the modifications that differ from the current master branch. More info here: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request#perform-a-rebase

Copy link
Member

@EiffL EiffL left a comment

Choose a reason for hiding this comment

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

LGTM

@EiffL
Copy link
Member

EiffL commented Apr 27, 2020

Ok Ben, it's ok for me if you want to press the big Green Merge Button, go ahead ;-)
And in the meantime, @all-contributors please add @bhorowitz for code

@allcontributors
Copy link
Contributor

@EiffL

I've put up a pull request to add @bhorowitz! 🎉

@bhorowitz bhorowitz merged commit d2e2ac8 into master Apr 27, 2020
Differentiable HOD paper automation moved this from In progress to Done Apr 27, 2020
@EiffL EiffL deleted the diffps branch June 12, 2020 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants