-
Notifications
You must be signed in to change notification settings - Fork 14
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
CSMF HOD #149
base: main
Are you sure you want to change the base?
CSMF HOD #149
Conversation
Add line of code that are able to compute CSMF HOD
back to origin
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think it would be nice to have user-contributed models in AbacusHOD. From a high level, though, it looks like the CSMF is implemented as a galaxy "type" in GRAND_HOD.py
, like LRG, ELG, etc, in such a way that it can have multi-tracer exclusion with these other types. That's what this if/else chain is about:
if randoms[i] <= LRG_marker:
Nout[tid, 0, 0] += 1 # counting
keep[i] = 1
elif randoms[i] <= ELG_marker:
Nout[tid, 1, 0] += 1 # counting
keep[i] = 2
elif randoms[i] <= QSO_marker:
Nout[tid, 2, 0] += 1 # counting
keep[i] = 3
elif randoms[i] <= CSMF_marker:
Nout[tid, 3, 0] += 1 # counting
keep[i] = 4
Is it really the spirit of the model that a CSMF galaxy is a type, like an LRG, ELG, etc?
To put it another way, should CSMF be implemented as a part of GRAND_HOD, or a separate model beside it? GRAND HOD refers the model from Sandy's paper, so I suspect that CSMF should be considered its own model and go in its own module. abacus_hod.py
probably needs to be generalized to handle more than one HOD model, as we've only dealt with GRAND HOD up to now.
In terms of debugging the numba segfault, I would recommend running a small problem with the NUMBA_DISABLE_JIT=1
environment variable set. Most problems that cause a segfault in Numba, like index overrun, will raise a Python exception instead when JIT is disabled. You can also sometimes remove the @njit
decorator from individual functions instead.
Hello @lgarrison, However, I am also fine with writing a separate file for the CSMF HOD if you prefer that approach. Lastly, thank you for sharing your idea about the seg fault. I will try what you said. However, the code runs without any issues as long as the simplistic function (which is activated currently) is used to draw a random stellar mass. |
I see, thanks for clarifying that this is for BGS galaxies. I do think it would be worth putting most of the functions in a new abacusutils/abacusnbody/hod/GRAND_HOD.py Lines 774 to 795 in 3f62344
etc. Could you start by moving as much as possible into a new Besides that, there are a few places in the Numba code where you use lists and then convert them to NumPy arrays, like this: abacusutils/abacusnbody/hod/GRAND_HOD.py Lines 70 to 75 in 3f62344
In both Numba and regular Python, it's better to pre-allocate arrays with Could you also add a test of your model? You can follow the example here: https://github.com/abacusorg/abacusutils/blob/main/tests/test_hod.py. The idea is to generate a mock catalog on a small sim and compare against a saved result. Finally, the red X on the PR is from the pre-commit checks. You can click on the "Details" button next to that check to see the issues it found. It looks like there are some undefined variables, and some unused variables. If you want to set up pre-commit to run locally, you can follow these instructions: https://abacusutils.readthedocs.io/en/latest/installation.html#pre-commit Thanks! |
Separation of GRAND_HOD to GRAND_HOD and CSMF_HOD, also removed the for loops
for more information, see https://pre-commit.ci
Hi @lgarrison Furthermore, I have removed the lists as you indicated and used np.cumsum. I will now work on a test example. But could you please give it a look and let me know if you're okay with the current structure? All the best |
removed the unused variables
for more information, see https://pre-commit.ci
Corrected undefined and unused variables
for more information, see https://pre-commit.ci
I created a test notebook showing how to create galaxy catalogues. I added Google Drive links to download the reference Haloes and Galaxy catalogues
for more information, see https://pre-commit.ci
@lgarrison Let me know if you are okay with using a jupyter notebook instead of a Python file. All the best |
Sorry for the delay, I've been thinking about the best approach here. Right now, So here's what I'm thinking. abacusutils can define an entry point for user packages to provide custom HOD implementations. This means that if a package with a custom HOD is pip-installed, abacusutils will know about it and be able to call it as one of the models. Custom HOD packages can also specify abacusutils version constraints, so if we do make breaking changes to Abacus HOD, downstream packages can add a version constraint until compatibility is restored. How does that sound to you? To be clear, I'd be happy to implement the entry point on the Abacus side (unless you wanted to). And sorry for making this a moving target! This is the first user-contributed HOD we've had, so we haven't had to think about these questions before. |
Hi, no worries about the delay. However, may I also make a suggestion: And then we work together to modernize the abacusHOD code now, instead of finding an intermediate solution and modernizing it in the future? We could, for instance, meet and discuss how we want to restructure the code. |
I updated the GRAND_HOD.py and the abacus_hod.py files such that the user can predict an HOD based on the conditional stellar mass function described in https://arxiv.org/pdf/0807.4932. The code also predicts the stellar mass for each galaxy. For the protection of the stellar mass, I implemented two functions. The first creates only stellar mass from a range of possible values, and the second (linear interpolation) can predict arbitrary stellar masses. However, the latter sometimes creates a segmentation fault. I have not figured out why that is the case. Therefore, the current version uses the simpler version.
This involved implementing the equations in https://arxiv.org/pdf/0807.4932 and updating most of the functions in GRAND_HOD.py. I have kept the same code structure and just added a few lines.
I am using the current implementation for my paper, which I plan to publish soon. If you are interested in seeing it, I am happy to share a preliminary version.
Furthermore, please let me know if you want to merge it to the main branch and if I need to make any adjustments.