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

Separating the cluster theory and models from Firecrown into an independent module. #345

Merged
merged 83 commits into from
Dec 11, 2023

Conversation

mattkwiecien
Copy link
Contributor

@mattkwiecien mattkwiecien commented Nov 2, 2023

Summary

Changeset to separate the cluster theory and models logic from the internal workings of Firecrown. As an added bonus, also updated the binned cluster number counts likelihood statistic to use ModelingTools in the expected firecrown workflow.

Cluster module

  • Added an AbundanceData class to wrap the sacc file and to be used by the likelihood
    • The sacc file data needs to be manipulated to extract the relevant cluster number counts (and masses) for the likelihood
    • Put this code within this wrapper class to keep the likelihood more clear from this sacc-specific logic
  • Removed firecrown infrastructure code and integration code from the ClusterAbundance class.
  • Added a new Kernel class to represent any ingredients in the cluster likelihood
    • Implemented kernels to represent the probability distribution P(z_spec|z_true), P(lambda|mass), etc
    • Created a MassRichnessGaussian of Kernel, anticipating having many of these. This could potentially fall into yagni territory (you aren't gonna need it).
  • Added a new Integrator class for the cluster module
    • Each integrator passes arguments to the cluster integrated differently, so we added this abstraction to allow specific integrators wrap and call the cluster abundance with their custom mapping
    • Implemented a NumCosmo and SciPy integrator as an example.

Cluster likelihood factory function

Modified the cluster likelihood to use dependency injection for all of the choices for our likelihood. Or in other words, moved all of the specific choices (integrator, cluster kernel ingredients, data vector) to the top of the call stack, so the user can swap in and out components to the likelihood.

Other firecrown changes

  • Added ClusterAbundance to ModelingTools.
    • As a part of this, I have ParamsMap passing through prepare.
    • This may need to change now that ModelingTools is an updatable...?
  • Added to setup.cfg instructions to tell mypy to ignore tests. Not sure if we want to keep this.

Tests

  • Upped test coverage of all cluster code to 100%
  • Ensured previous tests and new tests are all still passing
  • Total runtime of all tests is < .5 seconds. All tests except two take < 0.01 seconds. Those two tests are almost regression, maybe we want to flag them as such?

mattkwiecien and others added 30 commits October 4, 2023 12:18
Removed old cluster number count classes

Added new Kernel base class, with MassObservable and Redshift subclasses

Added some simple implementations of Kernel

Added Kernel Factories

Still WIP.
Stuck with the issue that the models in modelling tools also needs to know about the data (bounds for kernels)
Committing all work and going to start tests to check workflow.
Need to rethink how we include analytic solutions

Currently this is working but not how I want it
This is going to show up as a delete and add in git.
Noticed a bug? in the previous code with limits for integration.
Updated rest of the abundance code to do vector operations

Implemented a cache for HMF for now since it doesn't accept a vector of scale factors.
Adding unit tests for the new Murata classes
@mattkwiecien mattkwiecien marked this pull request as ready for review November 14, 2023 20:50
…uster abundance

Adding some tests to capture some edge cases exposed when moving sky_area.
Adjusting tests

Adding some mypy type checking here and there
Allowing a user to pass in an integration method into the num cosmo integrator.
Updating the cluster abundance data to return SaccBins instead of confusing built in types

Adding tests, and updating sacc file to reflect proper structure

Fixing mypy/pylint complaints.
…g locally. Switching 3.11 syntax for older syntax.

Updating cluster abundance tests to be more better.
Copy link
Contributor Author

@mattkwiecien mattkwiecien left a comment

Choose a reason for hiding this comment

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

Addition changes requested

firecrown/models/cluster/binning.py Outdated Show resolved Hide resolved
number count statistic. The data in this class is specific to a single
survey name."""

# Hard coded in SACC, how do we want to handle this?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We probably want to enforce a standard schema for the clusters data.


self.bin_edges = sacc_adapter.get_bin_edges(
self.survey_name, self.cluster_properties
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assert bin dimensions are equal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIx name

firecrown/models/cluster/kernel.py Outdated Show resolved Hide resolved
pytest.ini Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
tests/test_cluster_abundance.py Outdated Show resolved Hide resolved
tests/test_cluster_integrators.py Outdated Show resolved Hide resolved
tests/test_cluster_kernels.py Show resolved Hide resolved
@marcpaterno marcpaterno merged commit 3b9a4e5 into master Dec 11, 2023
8 checks passed
@marcpaterno marcpaterno deleted the clusters-stubs branch December 11, 2023 18:18
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.

None yet

3 participants