-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add type annotations * Remove incorrect documentation * Remove extraneous import * Document and test _generate_ell_or_theta * Rename _generate_ell_or_theta to generate_bin_centers * Move ELL_FOR_XI_DEFAULTS to generators * Rename _ell_for_xi to log_linear_ells * Move log_linear_ells to generators * Move generate_bin_centers to generators * Temporary tweaks to fix CI failures from pylint 3.3 * Move _cached_angular_distribution and make_log_interpolator to utils * Move calculate_ells_for_interpolation to generators * Move EllOrThetaConfig to generators * Move generate_{ells_cells,reals} to generators * Move apply_{ells,thetas}_min_max to generators * Move use_source_factory and use_source_factory_metadata_index to source_factories * Start of TwoPointTheory * Put sources in TwoPointTheory; make it Updatable * Move ell_for_xi_config to TwoPointTheory * Move ell_or_theta_config into TwoPointTheory * Move ell_or_theta_{min,max} into TwoPointTheory * Move window to TwoPointTheory * Remove unused TwoPoint.theory_vector * Move sacc_tracers into TwoPointTheory * Remove needless implementation of _update --------- Co-authored-by: Sandro Dias Pinto Vitenti <vitenti@uel.br>
- Loading branch information
1 parent
1ec56d9
commit a26cc7a
Showing
7 changed files
with
499 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ dependencies: | |
- pylint | ||
- pytest | ||
- pytest-cov | ||
- python >= 3.10 | ||
- pyyaml | ||
- requests | ||
- sacc >= 0.11 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"""Factory functions for creating sources.""" | ||
|
||
from firecrown.likelihood.number_counts import NumberCountsFactory, NumberCounts | ||
from firecrown.likelihood.weak_lensing import WeakLensingFactory, WeakLensing | ||
from firecrown.metadata_types import InferredGalaxyZDist, Measurement, Galaxies | ||
|
||
|
||
def use_source_factory( | ||
inferred_galaxy_zdist: InferredGalaxyZDist, | ||
measurement: Measurement, | ||
wl_factory: WeakLensingFactory | None = None, | ||
nc_factory: NumberCountsFactory | None = None, | ||
) -> WeakLensing | NumberCounts: | ||
"""Apply the factory to the inferred galaxy redshift distribution.""" | ||
source: WeakLensing | NumberCounts | ||
if measurement not in inferred_galaxy_zdist.measurements: | ||
raise ValueError( | ||
f"Measurement {measurement} not found in inferred galaxy redshift " | ||
f"distribution {inferred_galaxy_zdist.bin_name}!" | ||
) | ||
|
||
match measurement: | ||
case Galaxies.COUNTS: | ||
assert nc_factory is not None | ||
source = nc_factory.create(inferred_galaxy_zdist) | ||
case ( | ||
Galaxies.SHEAR_E | ||
| Galaxies.SHEAR_T | ||
| Galaxies.SHEAR_MINUS | ||
| Galaxies.SHEAR_PLUS | ||
): | ||
assert wl_factory is not None | ||
source = wl_factory.create(inferred_galaxy_zdist) | ||
case _: | ||
raise ValueError(f"Measurement {measurement} not supported!") | ||
return source | ||
|
||
|
||
def use_source_factory_metadata_index( | ||
sacc_tracer: str, | ||
measurement: Measurement, | ||
wl_factory: WeakLensingFactory | None = None, | ||
nc_factory: NumberCountsFactory | None = None, | ||
) -> WeakLensing | NumberCounts: | ||
"""Apply the factory to create a source from metadata only.""" | ||
source: WeakLensing | NumberCounts | ||
match measurement: | ||
case Galaxies.COUNTS: | ||
assert nc_factory is not None | ||
source = nc_factory.create_from_metadata_only(sacc_tracer) | ||
case ( | ||
Galaxies.SHEAR_E | ||
| Galaxies.SHEAR_T | ||
| Galaxies.SHEAR_MINUS | ||
| Galaxies.SHEAR_PLUS | ||
): | ||
assert wl_factory is not None | ||
source = wl_factory.create_from_metadata_only(sacc_tracer) | ||
case _: | ||
raise ValueError(f"Measurement {measurement} not supported!") | ||
return source |
Oops, something went wrong.