1111import yaml
1212from astropy .cosmology import Planck18
1313from 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
1614from cs_util import plots as cs_plots
1715from mpl_toolkits .axes_grid1 import make_axes_locatable
1816from 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