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

ENH: Subhalo abundance (SHAM) code #614

Open
wants to merge 11 commits into
base: module/halos
Choose a base branch
from

Conversation

Fox-Davidson
Copy link
Collaborator

@Fox-Davidson Fox-Davidson commented Feb 26, 2024

Description

This PR adds code to compute the subhalo abundance matching of internally generated halo/subhalo and galaxy catalogues based on a monotonic relation between their masses and the quenching model proposed in Peng et al 2010. Galaxy parameters given as examples are from the Schechter functions found in Birrer et al 2015.

Checklist

  • Follow the Contributor Guidelines
  • Write unit tests
  • Write documentation strings
  • Assign someone from your working team to review this pull request
  • Assign someone from the infrastructure team to review this pull request

@Fox-Davidson Fox-Davidson added documentation Improvements or additions to documentation enhancement Improvement of existing feature module: halos tests new feature New feature, such as a new model labels Feb 26, 2024
@itrharrison itrharrison self-requested a review September 5, 2024 11:50
Copy link
Contributor

@itrharrison itrharrison left a comment

Choose a reason for hiding this comment

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

Looks good!

A few comments on the code, mostly related to removing the internal yaml manipulation.

You should also make sure that documentation exists and compiles properly.

The test suite is impressively comprehensive, well done!

It looks like the halos module which you are merged into is failing its tests due to the classy dependency. I will look into this.

I have not explicitly reviewed the science here; this process is happening independently through the manuscript draft. The extensive test suite should mean that any calculations are performed as intended.

function += ' m_max: $m_max\n sky_area: $sky_area\n'

# Make one large string
yaml_lines = line1 + line2 + line3 + line4 + line5 + line6 + line7 + line8 + line9 + line10
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better if we could avoid these internal yaml manipulations and replace them with usage of the input yaml to the skypy pipeline, and/or calls to the skypy functions directly in python where necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

See also the argparse module which would be used to do any reading and manipulation necessary, example here:

parser = argparse.ArgumentParser(description="SkyPy pipeline driver")

gal_type_fin : (nm, ) array_like
List of assigned galaxies types with the tags 1,2,3,4 for
red centrals, red satellites, blue centrals, blue satellites
print_out : Boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

The skypy pipeline call includes a "verbose" flag which could be used instead of this print_out keyword.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the review. I am struggling to work out how to interact with the verbose keyword as I can't see that it is used anywhere in the galaxies module as an example. From the documentation, this would be applied to the code as a command line argument and I wouldn't expect this code to be used as such due to the dictionary output. Any help would be appreciated.

# Get a catalogue for each population

# Names for created files, randomly generate tag
rand_tag = int((10**8)*np.random.rand(1))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be done more reliably / reproducibly? If it is for differentiating files when multiprocessing, a processor rank could be used instead. Alternatively a time stamp tag could be used too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly removing all of the internal yaml file writing / reading will abrogate the need for this.

List of ID values for halos
z_fin: (nh, ) array_like
List of redshifts for halos
gal_type_fin: (nh, ) array_like
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this labels be more informative? i.e be strings like 'red_central' rather than integers.

min_mass = 10**(7.5)
max_mass = 10**(14)

file_test = '/mnt/c/Users/user/Documents/skypy_dev/skypy/skypy/halos/test_gal.yaml'
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a relative not absolute file path.


# Open file and check structure
# Create expected lines
line1 = 'm_star: !numpy.power [10, 10.58]\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

See above comments on using the skypy pipeline machinery rather than internal yaml manipulation.


@pytest.mark.skipif(not HAS_COLOSSUS, reason='test requires colossus')
@pytest.mark.flaky
def test_assignment():
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add comments (just short ones) describing what each test is for right underneath the def?

@@ -57,15 +57,15 @@ def test_growth():
Dzprime = growth_function_derivative(redshift, cosmology_flat)

# Test growth factor
assert redshift.shape == fz.shape,\
assert redshift.shape == fz.shape, \
Copy link
Contributor

Choose a reason for hiding this comment

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

We would not want to touch the power spectrum module here. Not sure if this has been done by some auto tool?

Copy link
Contributor

Choose a reason for hiding this comment

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

...okay, this appears to be some stricter codestyle which should be fixed by #630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement Improvement of existing feature module: halos new feature New feature, such as a new model tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants