Skip to content

Commit a312e85

Browse files
committed
Merge branch 'pyproject_docker' into develop
2 parents 00ecbef + 22a2be2 commit a312e85

File tree

2 files changed

+63
-58
lines changed

2 files changed

+63
-58
lines changed

notebooks/cosmo_val/run_cosmo_val.py

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
cv = CosmologyValidation(
2222
versions=["SP_v1.4.5"],
2323
data_base_dir="/n17data/mkilbing/astro/data",
24-
npatch=100,
24+
npatch=1,
25+
theta_min=1,
26+
theta_max=250,
27+
nbins=20,
28+
theta_min_plot=1,
29+
theta_max_plot=250,
2530
ylim_alpha=[-0.01, 0.05],
2631
)
2732

@@ -56,41 +61,41 @@
5661
cv.plot_2pcf()
5762

5863
# %%
59-
cv.plot_aperture_mass_dispersion()
60-
61-
# %%
62-
cv.plot_pure_eb(
63-
min_sep_int=0.08,
64-
max_sep_int=300,
65-
nbins_int=100,
66-
npatch=256,
67-
var_method="jackknife",
68-
)
69-
70-
# %%
71-
cv.plot_cosebis(
72-
min_sep=0.9,
73-
max_sep=250,
74-
nbins=2000,
75-
npatch=128,
76-
var_method="jackknife",
77-
nmodes=5,
78-
scale_cuts=[
79-
(1, 250),
80-
(2, 250),
81-
(3, 250),
82-
(4, 250),
83-
(5, 250),
84-
(6, 250),
85-
(7, 250),
86-
(8, 250),
87-
(9, 250),
88-
(10, 250),
89-
(15, 250),
90-
(20, 250),
91-
],
92-
fiducial_scale_cut=(10, 250),
93-
)
64+
# cv.plot_aperture_mass_dispersion()
65+
66+
# # %%
67+
# cv.plot_pure_eb(
68+
# min_sep_int=0.08,
69+
# max_sep_int=300,
70+
# nbins_int=100,
71+
# npatch=256,
72+
# var_method="jackknife",
73+
# )
74+
75+
# # %%
76+
# cv.plot_cosebis(
77+
# min_sep=0.9,
78+
# max_sep=250,
79+
# nbins=2000,
80+
# npatch=128,
81+
# var_method="jackknife",
82+
# nmodes=5,
83+
# scale_cuts=[
84+
# (1, 250),
85+
# (2, 250),
86+
# (3, 250),
87+
# (4, 250),
88+
# (5, 250),
89+
# (6, 250),
90+
# (7, 250),
91+
# (8, 250),
92+
# (9, 250),
93+
# (10, 250),
94+
# (15, 250),
95+
# (20, 250),
96+
# ],
97+
# fiducial_scale_cut=(10, 250),
98+
# )
9499

95100
# %%
96101
cv.plot_pseudo_cl()

src/sp_validation/cosmo_val.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import yaml
1212
from astropy.cosmology import Planck18
1313
from astropy.io import fits
14-
from cosmo_numba.B_modes.cosebis import COSEBIS
15-
from cosmo_numba.B_modes.schneider2022 import get_pure_EB_modes
1614
from cs_util import plots as cs_plots
1715
from mpl_toolkits.axes_grid1 import make_axes_locatable
1816
from scipy import stats
@@ -274,7 +272,7 @@ def plot_rho_stats(self, abs=False):
274272
)
275273

276274
self.print_done(
277-
f"Rho stats plot saved to "
275+
"Rho stats plot saved to "
278276
+ f"{os.path.abspath(self.rho_stat_handler.catalogs._output)}/{savefig}",
279277
)
280278

@@ -294,7 +292,7 @@ def plot_tau_stats(self, plot_tau_m=False):
294292
)
295293

296294
self.print_done(
297-
f"Tau stats plot saved to "
295+
"Tau stats plot saved to "
298296
+ f"{os.path.abspath(self.tau_stat_handler.catalogs._output)}/{savefig}",
299297
)
300298

@@ -489,7 +487,6 @@ def plot_footprints(self):
489487
self.print_start("Plotting footprints:")
490488
for ver in self.versions:
491489
self.print_magenta(ver)
492-
results = self.results[ver]
493490

494491
fp = FootprintPlotter()
495492

@@ -766,7 +763,7 @@ def plot_objectwise_leakage(self):
766763
self.calculate_objectwise_leakage()
767764

768765
self.print_start("Plotting object-wise leakage:")
769-
fig = cs_plots.figure(figsize=(15, 15))
766+
cs_plots.figure(figsize=(15, 15))
770767

771768
linestyles = ["-", "--", ":"]
772769
fillstyles = ["full", "none", "left", "right", "bottom", "top"]
@@ -866,7 +863,7 @@ def plot_weights(self, nbins=200):
866863
else:
867864
self.print_start("Computing weight histograms:")
868865

869-
bins = np.linspace(0, 1.2, nbins + 1)
866+
fig, ax = plt.subplots(1, 1, figsize=(10, 7))
870867
for ver in self.versions:
871868
self.print_magenta(ver)
872869
with self.results[ver].temporarily_read_data():
@@ -882,14 +879,14 @@ def plot_weights(self, nbins=200):
882879
color=self.cc[ver]["colour"],
883880
)
884881

885-
plt.xlabel(f"$w$")
882+
plt.xlabel("$w$")
886883
plt.ylabel("frequency")
887884
plt.yscale("log")
888885
plt.legend()
889886
# plt.xlim([-0.01, 1.2])
890887
cs_plots.savefig(out_path, close_fig=False)
891888
cs_plots.show()
892-
self.print_done("Ellipticity histograms saved to " + out_path)
889+
self.print_done("Weight histograms saved to " + out_path)
893890

894891
def plot_separation(self, nbins=200):
895892
self.print_start("Separation histograms")
@@ -978,21 +975,13 @@ def calculate_2pcf(self, ver, npatch=None, save_fits=False, **treecorr_config):
978975

979976
self.print_magenta(f"Computing {ver} ξ±")
980977

978+
npatch = npatch or self.npatch
981979
treecorr_config = {
982980
**self.treecorr_config,
983981
**treecorr_config,
982+
"var_method": "jackknife" if int(npatch) > 1 else "shot",
984983
}
985984

986-
npatch = npatch or self.npatch
987-
var_method = treecorr_config["var_method"]
988-
if npatch == 0 and var_method != "shot":
989-
print(
990-
f"Zero patches specified, but var_method is set to {var_method}. "
991-
"Switching to 'shot' variance method; try setting npatch > nbins"
992-
" to use e.g. jackknife variance."
993-
)
994-
treecorr_config["var_method"] = "shot"
995-
996985
gg = treecorr.GGCorrelation(treecorr_config)
997986

998987
# If the output file already exists, skip the calculation
@@ -1426,6 +1415,7 @@ def calculate_pure_eb(
14261415
nbins_int=100,
14271416
npatch=256,
14281417
var_method="jackknife",
1418+
cov_path_int=None,
14291419
):
14301420
"""
14311421
Calculate the pure E/B modes for the given catalog version.
@@ -1456,6 +1446,12 @@ def calculate_pure_eb(
14561446
the value in self.npatch if not provided.
14571447
var_method : str, optional
14581448
Variance estimation method. Defaults to "jackknife".
1449+
cov_path_fmt : str, optional
1450+
Path to the covariance matrix for the reporting binning. Replaces the
1451+
treecorr covariance matrix if provided, meaning that var_method has no
1452+
effect on the results although it is still passed to
1453+
CosmologyValidation.calculate_2pcf.
1454+
14591455
14601456
Returns
14611457
-------
@@ -1476,6 +1472,8 @@ def calculate_pure_eb(
14761472
- A shared patch file is used for the reporting and integration binning,
14771473
and is created if it does not exist.
14781474
"""
1475+
from cosmo_numba.B_modes.schneider2022 import get_pure_EB_modes
1476+
14791477
self.print_start(f"Computing {version} pure E/B")
14801478

14811479
npatch = npatch or self.npatch
@@ -1823,8 +1821,7 @@ def populate_results(
18231821

18241822
# PTE as a function of lower scale cut plot
18251823
def calculate_ptes(results, start_p=0, start_m=0):
1826-
gg, gg_int = results["gg"], results["gg_int"]
1827-
nbins, npatch = gg.nbins, gg.npatch1
1824+
npatch = gg.npatch1
18281825

18291826
ptes_p, ptes_m = [], []
18301827
for ptes, key, start, stop in zip(
@@ -1963,6 +1960,8 @@ def calculate_cosebis(
19631960
TODO
19641961
19651962
"""
1963+
from cosmo_numba.B_modes.cosebis import COSEBIS
1964+
19661965
self.print_start(f"Computing {version} COSEBIs")
19671966

19681967
npatch = npatch or self.npatch
@@ -2047,6 +2046,7 @@ def plot_cosebis(
20472046
scale_cuts=None,
20482047
fiducial_scale_cut=None,
20492048
):
2049+
20502050
if np.isscalar(scale_cuts[0]):
20512051
scale_cuts = [scale_cuts]
20522052

@@ -2164,7 +2164,7 @@ def calculate_pseudo_cl_eb_cov(self):
21642164
for ver in self.versions:
21652165
self.print_magenta(ver)
21662166

2167-
if not ver in self._pseudo_cls.keys():
2167+
if ver not in self._pseudo_cls.keys():
21682168
self._pseudo_cls[ver] = {}
21692169

21702170
out_path = os.path.abspath(

0 commit comments

Comments
 (0)