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

Ia selfcalibration arcmin #189

Draft
wants to merge 127 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
caed3e5
Added an option to get the seperation in Mpc corresponding to Arcmin …
empEvil Apr 27, 2021
72b476c
forgot imports
empEvil Apr 28, 2021
a982924
printing details!
empEvil Apr 28, 2021
7c48abb
added mean redshift info
empEvil Apr 29, 2021
c9a5cf1
fixing linebreak
empEvil Apr 29, 2021
57f60fe
Update twopoint_scia.py
empEvil Apr 29, 2021
80daa95
Update twopoint_scia.py
empEvil Apr 29, 2021
5553e4d
fixing an issue with copying the configuration
empEvil Apr 30, 2021
7a7c48f
fixed printout
empEvil Apr 30, 2021
ae03e49
Testing if we can use Treecorr's built in every_nth
empEvil May 14, 2021
dde0406
Update twopoint.py
empEvil May 14, 2021
018a4ee
trying to add random catalogs back in
empEvil Jun 8, 2021
ccdc13c
added imports
empEvil Jun 8, 2021
d97fe2a
Update random_cats_source.py
empEvil Jun 8, 2021
c259efb
Update random_cats_source.py
empEvil Jun 8, 2021
008cd7b
Update random_cats_source.py
empEvil Jun 8, 2021
545f67b
ensuring that NN gets the right min/max sep
empEvil Jun 8, 2021
10cb0d5
Update twopoint_scia.py
empEvil Jun 11, 2021
ac1620c
Update twopoint_scia.py
empEvil Jun 12, 2021
d6a693c
Update twopoint_scia.py
empEvil Jun 14, 2021
fdf8bce
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Jun 16, 2021
1a19d70
First pass on updating TXSCIA to twopoint 2.0
empEvil Jun 16, 2021
7a34eab
fixing laptop_pipeline
empEvil Jun 16, 2021
9c67c44
Update random_cats_source.py
empEvil Jun 16, 2021
3a4114d
Update calibrate.py
empEvil Jun 16, 2021
9a9a4d2
temporary fix to the lens-catalog issue
empEvil Jun 16, 2021
b987ca2
Update twopoint_scia.py
empEvil Jun 16, 2021
5248c0c
fixing calls changed with new twopoint.py
empEvil Jun 16, 2021
13846b4
changing config
empEvil Jun 16, 2021
5109590
Update laptop_config.yml
empEvil Jun 16, 2021
4982e77
fixing redshift issues
empEvil Jun 16, 2021
d9b5890
Update calibrate.py
empEvil Jun 16, 2021
9244ac9
Update twopoint_scia.py
empEvil Jun 17, 2021
cb330f8
fixed a typo
empEvil Jun 17, 2021
f91e02c
moving comoving generation
empEvil Jun 17, 2021
d19fc10
Update laptop_pipeline.yml
empEvil Jun 17, 2021
25168ba
fixed imports
empEvil Jun 17, 2021
b5ccedc
Update random_cats_source.py
empEvil Jun 17, 2021
4082f9a
Update calibrate.py
empEvil Jun 17, 2021
b7fdac0
Update twopoint_scia.py
empEvil Jun 17, 2021
51d69b7
Update twopoint_scia.py
empEvil Jun 17, 2021
04a7214
Update random_cats_source.py
empEvil Jun 17, 2021
a84cb02
Update twopoint_scia.py
empEvil Jun 17, 2021
dce5bbe
Update twopoint_scia.py
empEvil Jun 17, 2021
2fd862a
Update twopoint_scia.py
empEvil Jun 17, 2021
1586519
Update random_cats_source.py
empEvil Jun 22, 2021
4af2762
Update twopoint_scia.py
empEvil Jun 25, 2021
68d3a0b
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Jul 14, 2021
dfe705c
updated to use the new naming scheme
empEvil Jul 14, 2021
f4a7457
Update random_cats_source.py
empEvil Jul 14, 2021
24a0fce
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Jul 15, 2021
67d03fa
added the prepare patches stage to self-calibration so we can remove …
empEvil Jul 15, 2021
1fbae17
fixing a naming error
empEvil Sep 7, 2021
430d7d7
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Sep 7, 2021
33d8a43
Update RAIL
empEvil Sep 7, 2021
5c1ea55
updating to use the aux_source map instead of aux_map
empEvil Sep 7, 2021
24009b0
Revert "Update RAIL"
empEvil Sep 7, 2021
1ee6b1b
changed to using the lens map, due to the need of depth information
empEvil Sep 7, 2021
a9bfb2e
fix to utilize the cache of patches
empEvil Sep 8, 2021
3f85ce9
fixed tiny bug
empEvil Sep 12, 2021
efb0444
modifying the config file
empEvil Sep 12, 2021
6774dd7
adding a missing timer for pos-pos
empEvil Sep 17, 2021
226c26e
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Mar 24, 2022
671f306
Removing the random sources, see other branch
empEvil Mar 25, 2022
938975f
fixing a missing import
empEvil Mar 25, 2022
029fb0e
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil May 23, 2022
d21a571
attempt to fix lacking random catalog
empEvil May 24, 2022
c352e79
fixed bugs in both Metacal and Metadetect
empEvil May 24, 2022
ab78d7a
fixing the examples
empEvil May 26, 2022
3da77dd
cleaning up a few imports
empEvil May 26, 2022
413ab5a
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Apr 24, 2023
20c6ae9
trying to fix calibration part
empEvil May 8, 2023
46f48a8
simplyfying the saving r
empEvil May 8, 2023
f7b5cf7
updating prepare_patches in SCIA part
empEvil May 8, 2023
224ceec
fixed import error
empEvil May 9, 2023
3124a5b
adding missing config option
empEvil May 9, 2023
06be7cb
fixing more missing options
empEvil May 9, 2023
383d162
adding missing dict
empEvil May 9, 2023
f8e9414
removing sep_units
empEvil May 9, 2023
5c5fd0c
fixing missing counters
empEvil May 9, 2023
d823b45
adding missing option
empEvil May 9, 2023
f76244c
fixing change in output saving
empEvil May 9, 2023
3c13b8a
Trying to fix double loading in prepare_patches
empEvil May 24, 2023
05bf006
adding touching patches, and debug
empEvil May 26, 2023
8da0c2f
debugging
empEvil May 26, 2023
a2cc366
more fixing/debugging
empEvil May 26, 2023
1a53262
debug
empEvil May 26, 2023
5919c5d
debug messages
empEvil May 26, 2023
2b2d217
more debug messaging
empEvil May 26, 2023
56adb9f
ensuring that use_randoms exist in the config
empEvil May 29, 2023
9bbdb67
fixed a double config option
empEvil May 29, 2023
70d12ea
adding more print statements temp.
empEvil Jun 8, 2023
ac6723f
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Aug 4, 2023
e94cfca
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Aug 25, 2023
87447d0
removed breaking statement
empEvil Aug 25, 2023
404e867
removing part of the Fiducial cosmology
empEvil Aug 25, 2023
4dfbb9f
Updating fiducial cosmology type, to use-qp branch
empEvil Aug 25, 2023
bce10e5
more cleanup
empEvil Aug 25, 2023
df3286e
updating how this branch read in cosmology
empEvil Aug 25, 2023
8678f5e
playing with the fiducial cosmology loading
empEvil Aug 25, 2023
838117b
more ccl interaction
empEvil Aug 25, 2023
9aaebbe
Update twopoint_scia.py
empEvil Nov 3, 2023
57cc9b7
New up to date extension
empEvil Apr 22, 2024
4764937
bug fix in imports
empEvil Apr 22, 2024
9f6ad3a
Merge branch 'master' into IA_selfcalibration_arcmin
empEvil Apr 22, 2024
62af258
Fixing renaming
empEvil Apr 22, 2024
7470600
naming issues
empEvil Apr 22, 2024
0cc3645
removing the need for binned_lens_catalog
empEvil Apr 22, 2024
9552937
fixed a config bug
empEvil Apr 23, 2024
938da33
fixed missing indent
empEvil Apr 23, 2024
e3b9449
Fixed another little bug
empEvil Apr 23, 2024
dbdb308
Fixed error in output
empEvil Apr 23, 2024
0a7bd8b
added the option to do TwoPointPixel with source maps only
empEvil Jun 18, 2024
e2d49c8
added needed options to select_calculations
empEvil Jun 18, 2024
b82953d
fixed a typo
empEvil Jun 18, 2024
e3b203c
fixing another typo
empEvil Jun 18, 2024
7dde5bc
moving the source calculations to a new class instead
empEvil Jun 18, 2024
85db429
adding the new class to the init file
empEvil Jun 18, 2024
504d919
let's save the redshift into the calibrated data
empEvil Jun 21, 2024
bec389e
fixing naming conventions
empEvil Jun 21, 2024
0bd5cec
added a new stage using alternative metric to calculate SCIA
empEvil Jun 21, 2024
fe65ee5
fixed a typo
empEvil Jun 21, 2024
66275e9
adding config info
empEvil Jun 21, 2024
e6353c7
cleaned up the code a bit
empEvil Jun 21, 2024
a559a92
added separation units
empEvil Jun 21, 2024
df36161
added an option to choose between r or z
empEvil Jun 24, 2024
9ae9141
Forcing jacknifeSources to assume HDF5
empEvil Jun 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions data/fiducial_cosmology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Omega_k: 0.000000e+00
k_sign: 0
w0: -1.000000e+00
wa: 0.000000e+00
H0: 7.100000e+01
h: 7.100000e-01
Neff: 3.046000e+00
N_nu_mass: 0
Expand All @@ -24,8 +23,6 @@ mu_0: 0.000000e+00
sigma_0: 0.000000e+00
sigma8: 8.000000e-01
Omega_l: 7.351283e-01
z_star: nan
has_mgrowth: 0
nz_mgrowth: 0
c1_mg: 1.0
c2_mg: 1.0
Expand Down
8 changes: 8 additions & 0 deletions examples/metacal/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ TXMapCorrelations:
outlier_fraction: 0.05
nbin: 20

TXShearCalibration:
3Dcoords: True
redshift_shearcatalog: True
redshift_name: 'redshift_true'

TXTwoPointSCIA:
do_pos_pos: False
use_randoms: False

PZRailSummarizeLens:
leafsize: 20
Expand Down
15 changes: 9 additions & 6 deletions examples/metacal/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ stages:
- name: TXMapCorrelations # plot the correlations between systematics and data
- name: TXApertureMass # Compute aperture-mass statistics
threads_per_process: 2
- name: TXTwoPointFourier # Compute power spectra C_ell
# Disablig this since not yet synchronised with new Treecorr MPI
# - name: TXSelfCalibrationIA # Self-calibration intrinsic alignments of galaxies
# Disabling these as they take too long for a quick test.
# Disabled since not yet synchronised with new Treecorr MPI
- name: TXTwoPointSCIA # Self-calibration intrinsic alignments of galaxies
threads_per_process: 2

# Disabling these as they takes too long for a quick test.
# The latter three need NaMaster
# - name: TXRealGaussianCovariance # Compute covariance of real-space correlations
# - name: TXTwoPointFourier # Compute power spectra C_ell
# - name: TXFourierNamasterCovariance # Compute the C_ell covariance
Expand Down Expand Up @@ -115,8 +117,9 @@ inputs:
# This file comes with the code
fiducial_cosmology: data/fiducial_cosmology.yml
# For the self-calibration extension we are not using Random_cat_source for now
# So it is set to Null, so the yaml intepreter returns a None value to python.
random_cats_source: Null
# So it is set to None, so the yaml intepreter returns a None value to python.
random_cats_source: None
binned_random_catalog_source: None
flow: data/example/inputs/example_flow.pkl

# if supported by the launcher, restart the pipeline where it left off
Expand Down
9 changes: 9 additions & 0 deletions examples/metadetect/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ PZRealizationsPlotLens:
photoz_realizations: lens_photoz_realizations
photoz_realizations_plot: lens_photoz_realizations_plot

TXShearCalibration:
3Dcoords: True
redshift_shearcatalog: True
redshift_name: '00/redshift_true'

TXTwoPointSCIA:
do_pos_pos: False
use_randoms: False

TXPhotozPlotSource:
name: TXPhotozPlotSource
aliases:
Expand Down
9 changes: 5 additions & 4 deletions examples/metadetect/pipeline.yml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ stages:
threads_per_process: 2
- name: TXTwoPointFourier # Compute power spectra C_ell
# Disabled since not yet synchronised with new Treecorr MPI
# - name: TXSelfCalibrationIA # Self-calibration intrinsic alignments of galaxies
- name: TXTwoPointSCIA # Self-calibration intrinsic alignments of galaxies

# Disabling these as they takes too long for a quick test.
# The latter two need NaMaster
Expand Down Expand Up @@ -123,9 +123,10 @@ inputs:
star_catalog: data/example/inputs/star_catalog.hdf5
# This file comes with the code
fiducial_cosmology: data/fiducial_cosmology.yml
# For the self-calibration extension we are not using Random_cat_source for now
# So it is set to Null, so the yaml intepreter returns a None value to python.
random_cats_source: Null
# For the self-calibration extension if we are not using random_catalog_source for now
# So it is set to Null, so the yaml intepreter returns a None value to python. OBS
# the binned_random_catalog_source should also be set to Null in this case.
binned_random_catalog_source: None
flow: data/example/inputs/example_flow.pkl

# if supported by the launcher, restart the pipeline where it left off
Expand Down
2 changes: 1 addition & 1 deletion txpipe/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@

# Here are the stages that mostly will be used for other projects
# such as the self-calibration of Intrinsic alignment.
from .extensions.twopoint_scia import TXSelfCalibrationIA
from .extensions.twopoint_scia import TXTwoPointSelfCalibrationIA, TXTwoPointSourcePixels, TXTwoPointSCIAArc
from .extensions.clmm import CLClusterShearCatalogs, CLClusterBinningRedshiftRichness
from .covariance_nmt import TXFourierNamasterCovariance, TXRealNamasterCovariance
43 changes: 39 additions & 4 deletions txpipe/calibrate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .base_stage import PipelineStage
from .data_types import ShearCatalog, TomographyCatalog
from .utils import read_shear_catalog_type, Calibrator, Splitter, rename_iterated
from .data_types import ShearCatalog, TomographyCatalog, FiducialCosmology
from .utils import read_shear_catalog_type, Calibrator, Splitter, rename_iterated, SourceNumberDensityStats
import numpy as np


Expand Down Expand Up @@ -31,6 +31,7 @@ class TXShearCalibration(PipelineStage):
inputs = [
("shear_catalog", ShearCatalog),
("shear_tomography_catalog", TomographyCatalog),
("fiducial_cosmology", FiducialCosmology),
]

outputs = [
Expand All @@ -41,6 +42,9 @@ class TXShearCalibration(PipelineStage):
"use_true_shear": False,
"chunk_rows": 100_000,
"subtract_mean_shear": True,
'redshift_shearcatalog': False,
'3Dcoords': False,
'redshift_name': 'redshift_true',
"extra_cols": [""],
}

Expand All @@ -51,6 +55,9 @@ def run(self):
use_true = self.config["use_true_shear"]
extra_cols = [c for c in self.config["extra_cols"] if c]
subtract_mean_shear = self.config["subtract_mean_shear"]
Dcoords = self.config['3Dcoords']
redshift_shearcatalog = self.config["redshift_shearcatalog"]
z_name = self.config['redshift_name']

# Prepare the output file, and create a splitter object,
# whose job is to save the separate bins to separate HDF5
Expand All @@ -69,12 +76,23 @@ def run(self):

cat_cols += [f"00/{c}" for c in extra_cols]
renames.update({f"00/{c}":c for c in extra_cols})

if Dcoords:
if redshift_shearcatalog:
cat_cols += [z_name]
else:
raise ValueError(f"To use 3Dcoords the shear catalog needs a redshift")


if cat_type!='hsc':
output_cols = ["ra", "dec", "weight", "g1", "g2"] + extra_cols
else:
output_cols = ["ra", "dec", "weight", "g1", "g2","c1","c2"] + extra_cols

if Dcoords:
output_cols.append("r")
output_cols.append("z")
print("Using 3D coords, hopefully a mean readshift is defined")

# We parallelize by bin. This isn't ideal but we don't know the number
# of objects in each bin per chunk, so we can't parallelize in full. This
#  is a quick stage though.
Expand Down Expand Up @@ -110,6 +128,8 @@ def run(self):

# Rename mcal_g1 -> g1 etc
self.rename_metacal(data)
if Dcoords:
self.redshift_to_comoving(data, z_name)

#  Now output the calibrated bin data for this processor
for b in my_bins:
Expand Down Expand Up @@ -144,6 +164,7 @@ def run(self):
output_file.close()

def setup_output(self, extra_cols):
Dcoords = self.config['3Dcoords']
# count the expected number of objects per bin from the tomo data
with self.open_input("shear_tomography_catalog") as f:
counts = f["tomography/counts"][:]
Expand All @@ -154,7 +175,10 @@ def setup_output(self, extra_cols):
f = self.open_output("binned_shear_catalog", parallel=True)

#  we only retain these columns
cols = ["ra", "dec", "weight", "g1", "g2"] + extra_cols
if Dcoords:
cols = ["ra", "dec", "r", "z", "weight", "g1", "g2"] + extra_cols
else:
cols = ["ra", "dec", "weight", "g1", "g2"] + extra_cols

# structure is /shear/bin_1, /shear/bin_2, etc
g = f.create_group("shear")
Expand Down Expand Up @@ -190,3 +214,14 @@ def rename_metacal(self, d):
d["g1"] = d[f"{prefix}_g1"]
d["g2"] = d[f"{prefix}_g2"]
del d[f"{prefix}_g1"], d[f"{prefix}_g2"]

def redshift_to_comoving(self, d, name):
import pyccl as ccl
cosmo = self.open_input("fiducial_cosmology", wrapper=True).to_ccl()
#renaming the redshift name
d["z"] = d[name]
d["r"] = ccl.background.comoving_radial_distance(cosmo, 1/(1+d[name]))




Loading