LSSTDESC / CCL

DESC Core Cosmology Library: cosmology routines with validated numerical accuracy
BSD 3-Clause "New" or "Revised" License
145 stars 68 forks source link

Additional halos features #1068

Closed nikfilippas closed 1 year ago

nikfilippas commented 1 year ago

This is a rebased copy of 1065.

I brought the extra stuff from 1064 to here, so that we keep the other PR as clean as possible, and this PR also defines a library-level control to turn on/off the custom __eq__ methods, just as we had with the __repr__ methods.

Old Description

The main change this PR introduces, is to make mass_def an optional argument in HMCalculator because if mass_function and halo_bias are passed as instances (rather than str) we can just use their own mass_def. We can do that because some lines below we enforce that all mass_defs are equal. So an HMCalculator can be instantiated in one of the following ways:

## From strings
# hmc way 1
hmc = ccl.halos.HMCalculator(mass_function="Tinker10", halo_bias="Tinker10", mass_def="200c")

## From instances
# Initialize instances
# instances way 1
mdef = ccl.halos.MassDef200c()
hmf = ccl.halos.MassFunctionTinker10(mass_def=mdef)  # mass_def can also be a string
hbf = ccl.halos.HaloBiasTinker10(mass_def=mdef)      # mass_def can also be a string

# instances way 2
hmf = ccl.halos.MassFunc.from_name("Tinker10")(mass_def="200c")  # mass_def can also be an instance
hbf = ccl.halos.HaloBias.from_name("Tinker10")(mass_def="200c")  # mass_def can also be an instance

# instances way 3
hmf = ccl.halos.MassFunc.create_instance("Tinker10", mass_def="200c")  # mass_def can also be an instance
hbf = ccl.halos.HaloBias.create_instance("Tinker10", mass_def="200c")  # mass_def can also be an instance

# hmc way 2
hmc = ccl.halos.HMCalculator(mass_function=hmf, halo_bias=hbf, mass_def=mdef)

# hmc way 3
hmc = ccl.halos.HMCalculator(mass_function=hmf, halo_bias=hbf)