From a795cd38d7dea6d3a9cc5cf02374e5790733f48b Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 7 Jan 2015 10:32:28 -0800 Subject: [PATCH 01/37] Move to one constructor for CorrelationFunctionSysTests (#32) --- stile/sys_tests.py | 60 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 4316f71..09d6feb 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -117,7 +117,46 @@ def __init__(self, t_field=None, t_title=None, x_field=None, x_title=None, 'nk': treecorr.NKCorrelation, 'kg': treecorr.KGCorrelation} -class CorrelationFunctionSysTest(SysTest): +def CorrelationFunctionSysTest(type=None): + """ + Initialize an instance of a BaseCorrelationFunctionSysTest type, based on the 'type' kwarg + given. Options are: + - GalaxyShear: tangential and cross shear of 'galaxy' type objects around 'galaxy lens' + type objects + - BrightStarShear: tangential and cross shear of 'galaxy' type objects around 'star bright' + type objects' + - StarXGalaxyDensity: number density of 'galaxy' objects around 'star' objects + - StarXStarShear: auto-correlation of the shapes of 'star' type objects + - GalaxyDensityCorrelation: position autocorrelation of 'galaxy' type objects + - StarDensity Correlation: position autocorrelation of 'star' type objects + - None: an empty BaseCorrelationFunctionSysTest class instance, which can be used for + multiple types of correlation functions (see the documentation for + BaseCorrelationFunctionSysTest for more details). Note that this kind of instance has a + slightly different call signature than the other methods, with the correlation function + type given first, and that it lacks many of the convenience variables the other + CorrelationFunctions have, such as self.objects_list and self.required_quantities. + """ + if type is None: + return BaseCorrelationFunctionSysTest() + elif type=='GalaxyShear': + return GalaxyShearSysTest() + elif type=='BrightStarShear': + return BrightStarShearSysTest() + elif type=='StarXGalaxyDensity': + return StarXGalaxyDensitySysTest() + elif type=='StarXGalaxyShear': + return StarXGalaxyShearSysTest() + elif type=='StarXStarShear': + return StarXStarShearSysTest() + elif type=='GalaxyDensityCorrelation': + return GalaxyDensityCorrelationSysTest() + elif type=='StarDensityCorrelation': + return StarDensityCorrelation() + else: + raise ArgumentError('Unknown correlation function type %s given to type kwarg'%type) + + +class BaseCorrelationFunctionSysTest(SysTest): """ A base class for the Stile systematics tests that use correlation functions. This implements the class method getCF(), which runs a TreeCorr correlation function on a given set of data. Exact @@ -499,8 +538,11 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, ax.set_xlabel(r) return fig + def __call__(self, *args, **kwargs): + return self.getCF(*args, **kwargs) + -class GalaxyShearSysTest(CorrelationFunctionSysTest): +class GalaxyShearSysTest(BaseCorrelationFunctionSysTest): """ Compute the tangential and cross shear around a set of real galaxies. """ @@ -512,7 +554,7 @@ class GalaxyShearSysTest(CorrelationFunctionSysTest): def __call__(self, data, data2=None, random=None, random2=None, config=None, **kwargs): return self.getCF('ng', data, data2, random, random2, config=config, **kwargs) -class BrightStarShearSysTest(CorrelationFunctionSysTest): +class BrightStarShearSysTest(BaseCorrelationFunctionSysTest): """ Compute the tangential and cross shear around a set of bright stars. """ @@ -524,7 +566,7 @@ class BrightStarShearSysTest(CorrelationFunctionSysTest): def __call__(self, data, data2=None, random=None, random2=None, config=None, **kwargs): return self.getCF('ng', data, data2, random, random2, config=config, **kwargs) -class StarXGalaxyDensitySysTest(CorrelationFunctionSysTest): +class StarXGalaxyDensitySysTest(BaseCorrelationFunctionSysTest): """ Compute the number density of galaxies around stars. """ @@ -536,7 +578,7 @@ class StarXGalaxyDensitySysTest(CorrelationFunctionSysTest): def __call__(self, data, data2=None, random=None, random2=None, config=None, **kwargs): return self.getCF('nn', data, data2, random, random2, config=config, **kwargs) -class StarXGalaxyShearSysTest(CorrelationFunctionSysTest): +class StarXGalaxyShearSysTest(BaseCorrelationFunctionSysTest): """ Compute the cross-correlation of galaxy and star shapes. """ @@ -548,7 +590,7 @@ class StarXGalaxyShearSysTest(CorrelationFunctionSysTest): def __call__(self, data, data2=None, random=None, random2=None, config=None, **kwargs): return self.getCF('gg', data, data2, random, random2, config=config, **kwargs) -class StarXStarShearSysTest(CorrelationFunctionSysTest): +class StarXStarShearSysTest(BaseCorrelationFunctionSysTest): """ Compute the auto-correlation of star shapes. """ @@ -560,7 +602,7 @@ class StarXStarShearSysTest(CorrelationFunctionSysTest): def __call__(self, data, data2=None, random=None, random2=None, config=None, **kwargs): return self.getCF('gg', data, data2, random, random2, config=config, **kwargs) -class StarXStarSizeResidualSysTest(CorrelationFunctionSysTest): +class StarXStarSizeResidualSysTest(BaseCorrelationFunctionSysTest): """ Compute the auto correlation of star-PSF size residuals. """ @@ -617,7 +659,7 @@ def __call__(self, data, data2=None, random=None, random2=None, config=None, **k return self.getCF('gg', new_data, new_data2, new_random, new_random2, config=config, **kwargs) -class GalaxyDensityCorrelationSysTest(CorrelationFunctionSysTest): +class GalaxyDensityCorrelationSysTest(BaseCorrelationFunctionSysTest): """ Compute the galaxy position autocorrelations. """ @@ -629,7 +671,7 @@ class GalaxyDensityCorrelationSysTest(CorrelationFunctionSysTest): def __call__(self, data, data2=None, random=None, random2=None, config=None, **kwargs): return self.getCF('nn', data, data2, random, random2, config=config, **kwargs) -class StarDensityCorrelationSysTest(CorrelationFunctionSysTest): +class StarDensityCorrelationSysTest(BaseCorrelationFunctionSysTest): """ Compute the star position autocorrelations. """ From 773060705b9efa8fab83c289a46af90c412fb449 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 9 Jan 2015 16:04:25 -0800 Subject: [PATCH 02/37] Slight documentation tweaks to correlation function generator (#32a) --- stile/sys_tests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 09d6feb..c7c011d 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -124,17 +124,17 @@ def CorrelationFunctionSysTest(type=None): - GalaxyShear: tangential and cross shear of 'galaxy' type objects around 'galaxy lens' type objects - BrightStarShear: tangential and cross shear of 'galaxy' type objects around 'star bright' - type objects' + type objects - StarXGalaxyDensity: number density of 'galaxy' objects around 'star' objects - - StarXStarShear: auto-correlation of the shapes of 'star' type objects + - StarXStarShear: autocorrelation of the shapes of 'star' type objects - GalaxyDensityCorrelation: position autocorrelation of 'galaxy' type objects - StarDensity Correlation: position autocorrelation of 'star' type objects - None: an empty BaseCorrelationFunctionSysTest class instance, which can be used for - multiple types of correlation functions (see the documentation for - BaseCorrelationFunctionSysTest for more details). Note that this kind of instance has a - slightly different call signature than the other methods, with the correlation function - type given first, and that it lacks many of the convenience variables the other - CorrelationFunctions have, such as self.objects_list and self.required_quantities. + multiple types of correlation functions. See the documentation for + BaseCorrelationFunctionSysTest for more details. Note that this type has a + slightly different call signature than the other methods (with the correlation function + type given as the first argument) and that it lacks many of the convenience variables the + other CorrelationFunctions have, such as self.objects_list and self.required_quantities. """ if type is None: return BaseCorrelationFunctionSysTest() From 17825017b3be71daf4c9eb07e73ceaec6f8b86c6 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 9 Jan 2015 16:18:31 -0800 Subject: [PATCH 03/37] Switch WhiskerPlots to new generator format (#32a) --- stile/sys_tests.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index c7c011d..c6619c4 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -858,7 +858,29 @@ def __call__(self, array, percentiles=None, field=None, verbose=False, ignore_ba # Return. return result -class WhiskerPlotSysTest(SysTest): +def WhiskerPlotSysTest(type=None): + """ + Initialize an instance of a BaseWhiskerPlotSysTest class, based on the 'type' kwarg given. + Options are: + - Star: whisker plot of shapes of PSF stars + - PSF: whisker plot of PSF shapes at the location of PSF stars + - Residual: whisker plot of (star shape-PSF shape) + - None: an empty BaseWhiskerPlotSysTest class instance, which can be used for multiple types + of whisker plots. See the documentation for BaseWhiskerPlotSysTest (especially the method + whiskerPlot) for more details. Note that this type has a different call signature than + the other methods and that it lacks many of the convenience variables the other + CorrelationFunctions have, such as self.objects_list and self.required_quantities. + """ + if type=='Star': + return WhiskerPlotStarSysTest() + elif type=='PSF': + return WhiskerPlotPSFSysTest() + elif type=='Residual': + return WhiskerPlotResidualSysTest() + else: + return BaseWhiskerPlotSysTest() + +class BaseWhiskerPlotSysTest(SysTest): short_name = 'whiskerplot' """ A base class for Stile systematics tests that generate whisker plots. This implements the class @@ -955,12 +977,13 @@ def whiskerPlot(self, x, y, g1, g2, size=None, linewidth=0.01, scale=None, if ylim is not None: ax.set_ylim(*ylim) return fig - + def __call__(self, *args, **kwargs): + return self.whiskerPlot(*args, **kwargs) def getData(self): return self.data -class WhiskerPlotStarSysTest(WhiskerPlotSysTest): +class WhiskerPlotStarSysTest(BaseWhiskerPlotSysTest): short_name = 'whiskerplot_star' long_name = 'Make a Whisker plot of stars' objects_list = ['star PSF'] @@ -980,7 +1003,7 @@ def __call__(self, array, linewidth=0.01, scale=None, figsize=None, xlim=xlim, ylim=ylim, equal_axis=True) -class WhiskerPlotPSFSysTest(WhiskerPlotSysTest): +class WhiskerPlotPSFSysTest(BaseWhiskerPlotSysTest): short_name = 'whiskerplot_psf' long_name = 'Make a Whisker plot of PSFs' objects_list = ['star PSF'] @@ -1000,7 +1023,7 @@ def __call__(self, array, linewidth=0.01, scale=None, figsize=None, xlim=xlim, ylim=ylim, equal_axis=True) -class WhiskerPlotResidualSysTest(WhiskerPlotSysTest): +class WhiskerPlotResidualSysTest(BaseWhiskerPlotSysTest): short_name = 'whiskerplot_residual' long_name = 'Make a Whisker plot of residuals' objects_list = ['star PSF'] From 2d4536a271811de7353cec4c9d1a403653683885 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 9 Jan 2015 16:33:29 -0800 Subject: [PATCH 04/37] Switch to generator format for ScatterPlotSysTests (#32a) --- stile/sys_tests.py | 56 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index c6619c4..714266c 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -1045,13 +1045,44 @@ def __call__(self, array, linewidth=0.01, scale=None, figsize=None, size_label=r'$\sigma$ [pixel]', xlim=xlim, ylim=ylim, equal_axis=True) -class ScatterPlotSysTest(SysTest): +def ScatterPlotSysTest(type=None): + """ + Initialize an instance of a BaseScatterPlotSysTest class, based on the 'type' kwarg given. + Options are: + - StarVsPSFG1: star vs PSF g1 + - StarVsPSFG2: star vs PSF g2 + - StarVsPSFSigma: star vs PSF sigma + - ResidualVsPSFG1: (star - PSF) g1 vs PSF g1 + - ResidualVsPSFG2: (star - PSF) g1 vs PSF g2 + - ResidualVsPSFSigma: (star - PSF) g1 vs PSF sigma + - None: an empty BaseScatterPlotSysTest class instance, which can be used for multiple types + of scatter plots. See the documentation for BaseScatterPlotSysTest (especially the method + scatterPlot) for more details. Note that this type has a different call signature than + the other methods and that it lacks many of the convenience variables the other + ScatterPlots have, such as self.objects_list and self.required_quantities. + """ + if type=='StarVsPSFG1': + return ScatterPlotStarVsPSFG1SysTest() + elif type=='StarVsPSFG2': + return ScatterPlotStarVsPSFG2SysTest() + elif type=='StarVsPSFSigma': + return ScatterPlotStarVsPSFSigmaSysTest() + elif type=='ResidualVsPSFG1': + return ScatterPlotResidualVsPSFG1SysTest() + elif type=='ResidualVsPSFG2': + return ScatterPlotResidualVsPSFG2SysTest() + elif type=='ResidualVsPSFSigma': + return ScatterPlotResidualVsPSFSigmaSysTest() + else: + return BaseScatterPlotSysTest() + +class BaseScatterPlotSysTest(SysTest): short_name = 'scatterplot' """ - A base class for Stile systematics tests that generate scatter plots. This implements the class - method scatterPlot. Every child class of ScatterPlotSysTest should use - ScatterPlotSysTest.scatterPlot through __call__. See the docstring for - ScatterPlotSysTest.scatterPlot for information on how to write further tests using it. + A base class for Stile systematics tests that generate scatter plots. This implements the class + method scatterPlot. Every child class of BaseScatterPlotSysTest should use + BaseScatterPlotSysTest.scatterPlot through __call__. See the docstring for + BaseScatterPlotSysTest.scatterPlot for information on how to write further tests using it. """ def __call__(self, array, x_field, y_field, yerr_field, z_field=None, residual=False, @@ -1425,9 +1456,10 @@ def getStatisticsPerCCD(self, ccds, x, y, yerr=None, z=None, stat="median"): return x_med, y_med, y_med_std else: raise ValueError('stat should be mean or median.') + def __call__(self, *args, **kwargs): + return self.scatterPlot(*args, **kwargs) - -class ScatterPlotStarVsPSFG1SysTest(ScatterPlotSysTest): +class ScatterPlotStarVsPSFG1SysTest(BaseScatterPlotSysTest): short_name = 'scatterplot_star_vs_psf_g1' long_name = 'Make a scatter plot of star g1 vs psf g1' objects_list = ['star PSF'] @@ -1442,7 +1474,7 @@ def __call__(self, array, per_ccd_stat=None, color='', lim=None): reference_line='one-to-one') -class ScatterPlotStarVsPSFG2SysTest(ScatterPlotSysTest): +class ScatterPlotStarVsPSFG2SysTest(BaseScatterPlotSysTest): short_name = 'scatterplot_star_vs_psf_g2' long_name = 'Make a scatter plot of star g2 vs psf g2' objects_list = ['star PSF'] @@ -1457,7 +1489,7 @@ def __call__(self, array, per_ccd_stat=None, color='', lim=None): reference_line='one-to-one') -class ScatterPlotStarVsPSFSigmaSysTest(ScatterPlotSysTest): +class ScatterPlotStarVsPSFSigmaSysTest(BaseScatterPlotSysTest): short_name = 'scatterplot_star_vs_psf_sigma' long_name = 'Make a scatter plot of star sigma vs psf sigma' objects_list = ['star PSF'] @@ -1473,7 +1505,7 @@ def __call__(self, array, per_ccd_stat=None, color='', lim=None): linear_regression=True, reference_line='one-to-one') -class ScatterPlotResidualVsPSFG1SysTest(ScatterPlotSysTest): +class ScatterPlotResidualVsPSFG1SysTest(BaseScatterPlotSysTest): short_name = 'scatterplot_residual_vs_psf_g1' long_name = 'Make a scatter plot of residual g1 vs psf g1' objects_list = ['star PSF'] @@ -1488,7 +1520,7 @@ def __call__(self, array, per_ccd_stat=None, color='', lim=None): linear_regression=True, reference_line='zero') -class ScatterPlotResidualVsPSFG2SysTest(ScatterPlotSysTest): +class ScatterPlotResidualVsPSFG2SysTest(BaseScatterPlotSysTest): short_name = 'scatterplot_residual_vs_psf_g2' long_name = 'Make a scatter plot of residual g2 vs psf g2' objects_list = ['star PSF'] @@ -1503,7 +1535,7 @@ def __call__(self, array, per_ccd_stat=None, color='', lim=None): linear_regression=True, reference_line='zero') -class ScatterPlotResidualVsPSFSigmaSysTest(ScatterPlotSysTest): +class ScatterPlotResidualVsPSFSigmaSysTest(BaseScatterPlotSysTest): short_name = 'scatterplot_residual_vs_psf_sigma' long_name = 'Make a scatter plot of residual sigma vs psf sigma' objects_list = ['star PSF'] From b0f264249dbe408728aa9ec848d610f678b3fef3 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 9 Jan 2015 16:35:35 -0800 Subject: [PATCH 05/37] Documentation fixes for the new generator functions (#32a) --- stile/sys_tests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 714266c..bfde9cc 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -160,9 +160,9 @@ class BaseCorrelationFunctionSysTest(SysTest): """ A base class for the Stile systematics tests that use correlation functions. This implements the class method getCF(), which runs a TreeCorr correlation function on a given set of data. Exact - arguments to this method should be created by child classes of CorrelationFunctionSysTest; see - the docstring for CorrelationFunctionSysTest.getCF() for information on how to write further - tests using it. + arguments to this method should be created by child classes of BaseCorrelationFunctionSysTest; + see the docstring for BaseCorrelationFunctionSysTest.getCF() for information on how to write + further tests using it. """ short_name = 'corrfunc' # Set the details (such as field names and titles) for all the possible plots generated by @@ -869,7 +869,7 @@ def WhiskerPlotSysTest(type=None): of whisker plots. See the documentation for BaseWhiskerPlotSysTest (especially the method whiskerPlot) for more details. Note that this type has a different call signature than the other methods and that it lacks many of the convenience variables the other - CorrelationFunctions have, such as self.objects_list and self.required_quantities. + WhiskerPlots have, such as self.objects_list and self.required_quantities. """ if type=='Star': return WhiskerPlotStarSysTest() @@ -884,9 +884,9 @@ class BaseWhiskerPlotSysTest(SysTest): short_name = 'whiskerplot' """ A base class for Stile systematics tests that generate whisker plots. This implements the class - method whiskerPlot. Every child class of WhiskerPlotSysTest should use - WhiskerPlotSysTest.whiskerPlot through __call__. See the docstring for - WhiskerPlotSysTest.whiskerPlot for information on how to write further tests using it. + method whiskerPlot. Every child class of BaseWhiskerPlotSysTest should use + BaseWhiskerPlotSysTest.whiskerPlot through __call__. See the docstring for + BaseWhiskerPlotSysTest.whiskerPlot for information on how to write further tests using it. """ def whiskerPlot(self, x, y, g1, g2, size=None, linewidth=0.01, scale=None, From 06845fa9b8234978c31c1612211a88d3254bb450 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Sun, 25 Jan 2015 22:33:20 -0500 Subject: [PATCH 06/37] Raise error for unknown types in ScatterPlot and WhiskerPlot creators (#32a) --- stile/sys_tests.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index bfde9cc..dd5a50b 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -877,8 +877,10 @@ def WhiskerPlotSysTest(type=None): return WhiskerPlotPSFSysTest() elif type=='Residual': return WhiskerPlotResidualSysTest() - else: + elif type is None: return BaseWhiskerPlotSysTest() + else: + raise ArgumentError('Unknown whisker plot type %s given to type kwarg'%type) class BaseWhiskerPlotSysTest(SysTest): short_name = 'whiskerplot' @@ -1073,8 +1075,10 @@ def ScatterPlotSysTest(type=None): return ScatterPlotResidualVsPSFG2SysTest() elif type=='ResidualVsPSFSigma': return ScatterPlotResidualVsPSFSigmaSysTest() - else: + elif type is None: return BaseScatterPlotSysTest() + else: + raise ArgumentError('Unknown scatter plot type %s given to type kwarg'%type) class BaseScatterPlotSysTest(SysTest): short_name = 'scatterplot' From 718641160a141daa7dc801c5f19ea88a1224146d Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Sun, 25 Jan 2015 23:53:00 -0500 Subject: [PATCH 07/37] Bugfixes to errors and generators in sys_tests.py (#32a) --- stile/sys_tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index dd5a50b..235a226 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -151,9 +151,9 @@ def CorrelationFunctionSysTest(type=None): elif type=='GalaxyDensityCorrelation': return GalaxyDensityCorrelationSysTest() elif type=='StarDensityCorrelation': - return StarDensityCorrelation() + return StarDensityCorrelationSysTest() else: - raise ArgumentError('Unknown correlation function type %s given to type kwarg'%type) + raise ValueError('Unknown correlation function type %s given to type kwarg'%type) class BaseCorrelationFunctionSysTest(SysTest): @@ -880,7 +880,7 @@ def WhiskerPlotSysTest(type=None): elif type is None: return BaseWhiskerPlotSysTest() else: - raise ArgumentError('Unknown whisker plot type %s given to type kwarg'%type) + raise ValueError('Unknown whisker plot type %s given to type kwarg'%type) class BaseWhiskerPlotSysTest(SysTest): short_name = 'whiskerplot' @@ -1078,7 +1078,7 @@ def ScatterPlotSysTest(type=None): elif type is None: return BaseScatterPlotSysTest() else: - raise ArgumentError('Unknown scatter plot type %s given to type kwarg'%type) + raise ValueError('Unknown scatter plot type %s given to type kwarg'%type) class BaseScatterPlotSysTest(SysTest): short_name = 'scatterplot' From dfe156a70bf54e26da1fd0233f82a1de1192b6fa Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Sun, 25 Jan 2015 23:53:27 -0500 Subject: [PATCH 08/37] Change which SysTests are imported directly to the stile namespace (#32a) --- stile/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stile/__init__.py b/stile/__init__.py index c32fad1..6517fc2 100644 --- a/stile/__init__.py +++ b/stile/__init__.py @@ -5,5 +5,5 @@ from . import treecorr_utils from .treecorr_utils import ReadTreeCorrResultsFile from .data_handler import DataHandler -from .sys_tests import (GalaxyShearSysTest, BrightStarShearSysTest, StarXGalaxyShearSysTest, - StarXStarShearSysTest, StatSysTest) +from .sys_tests import (StatSysTest, CorrelationFunctionSysTest, ScatterPlotSysTest, + WhiskerPlotSysTest) From 666bec24c4870a7d23b090804a197b2f7b08a284 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Sun, 25 Jan 2015 23:54:01 -0500 Subject: [PATCH 09/37] Test new generator functionality (#32a) --- tests/test_correlation_functions.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/test_correlation_functions.py b/tests/test_correlation_functions.py index 5362e0f..c088196 100755 --- a/tests/test_correlation_functions.py +++ b/tests/test_correlation_functions.py @@ -77,9 +77,28 @@ def test_getCF(self): self.assertRaises(ValueError, cf.getCF, 'hello', lens_data, source_data, config=stile_args) # Then, test a test that uses .getCF(). - realshear = stile.GalaxyShearSysTest() + realshear = stile.sys_tests.GalaxyShearSysTest() results3 = realshear(lens_data, source_data, config=stile_args) numpy.testing.assert_equal(results, results3) + + + def test_generator(self): + """Make sure the CorrelationFunctionSysTest() generator returns the right objects""" + object_list = ['GalaxyShear', 'BrightStarShear', 'StarXGalaxyDensity', 'StarXGalaxyShear', + 'StarXStarShear', 'GalaxyDensityCorrelation', 'StarDensityCorrelation'] + for object_type in object_list: + object_1 = stile.CorrelationFunctionSysTest(object_type) + object_2 = eval('stile.sys_tests.'+object_type+'SysTest()') + self.assertEqual(type(object_1),type(object_2)) + + self.assertRaises(ValueError,stile.CorrelationFunctionSysTest,'hello') + self.assertEqual(type(stile.sys_tests.BaseCorrelationFunctionSysTest()), + type(stile.CorrelationFunctionSysTest())) + + +if __name__=='__main__': + unittest.main() +>>>>>>> Test new generator functionality (#32a) if __name__ == '__main__': unittest.main() From af47c64879f5a63aa92ca75c4987e1b2177f3992 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Mon, 26 Jan 2015 00:00:30 -0500 Subject: [PATCH 10/37] Fix example to use correct syntax for new SysTest setup (#32a) --- examples/example_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_run.py b/examples/example_run.py index af16e2f..18907d6 100644 --- a/examples/example_run.py +++ b/examples/example_run.py @@ -8,7 +8,7 @@ def main(): dh = dummy.DummyDataHandler() bin_list = [stile.BinStep('ra',low=-1,high=1,step=1), stile.BinStep('dec',low=-1,high=1,step=1)] - sys_test = stile.GalaxyShearSysTest() + sys_test = stile.CorrelationFunctionSysTest(type='GalaxyShear') stile_args = {'ra_units': 'degrees', 'dec_units': 'degrees', 'min_sep': 0.05, 'max_sep': 1, 'sep_units': 'degrees', 'nbins': 20} From 5983da40d9168a632eec7cdb8e9a3a3a42656822 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 15 Jul 2015 20:53:13 -0400 Subject: [PATCH 11/37] Update base class names for new classes from master in sys_tests.py (#32a) --- stile/sys_tests.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 235a226..2caebce 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -128,7 +128,8 @@ def CorrelationFunctionSysTest(type=None): - StarXGalaxyDensity: number density of 'galaxy' objects around 'star' objects - StarXStarShear: autocorrelation of the shapes of 'star' type objects - GalaxyDensityCorrelation: position autocorrelation of 'galaxy' type objects - - StarDensity Correlation: position autocorrelation of 'star' type objects + - StarDensityCorrelation: position autocorrelation of 'star' type objects + - Rho1: rho1 statistics (autocorrelation of residual star shapes) - None: an empty BaseCorrelationFunctionSysTest class instance, which can be used for multiple types of correlation functions. See the documentation for BaseCorrelationFunctionSysTest for more details. Note that this type has a @@ -152,6 +153,8 @@ def CorrelationFunctionSysTest(type=None): return GalaxyDensityCorrelationSysTest() elif type=='StarDensityCorrelation': return StarDensityCorrelationSysTest() + elif type=='Rho1': + return Rho1SysTest() else: raise ValueError('Unknown correlation function type %s given to type kwarg'%type) @@ -625,7 +628,7 @@ def __call__(self, data, data2=None, random=None, random2=None, config=None, **k return self.getCF('kk', config=config, *data_list, **new_kwargs) -class Rho1SysTest(CorrelationFunctionSysTest): +class Rho1SysTest(BaseCorrelationFunctionSysTest): """ Compute the auto-correlation of residual star shapes (star shapes - psf shapes). """ @@ -984,7 +987,6 @@ def __call__(self, *args, **kwargs): def getData(self): return self.data - class WhiskerPlotStarSysTest(BaseWhiskerPlotSysTest): short_name = 'whiskerplot_star' long_name = 'Make a Whisker plot of stars' From f9e2f3c54968dd9059a46afb8fe56a17405ce7ec Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 15 Jul 2015 21:10:05 -0400 Subject: [PATCH 12/37] Remove extraneous definition of __call__ for ScatterPlotSysTests (#32a) --- stile/sys_tests.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 2caebce..3b5dcc4 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -1462,8 +1462,6 @@ def getStatisticsPerCCD(self, ccds, x, y, yerr=None, z=None, stat="median"): return x_med, y_med, y_med_std else: raise ValueError('stat should be mean or median.') - def __call__(self, *args, **kwargs): - return self.scatterPlot(*args, **kwargs) class ScatterPlotStarVsPSFG1SysTest(BaseScatterPlotSysTest): short_name = 'scatterplot_star_vs_psf_g1' From f18e1cc1605bcead434ccd6838b89c5402b68bee Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 25 Sep 2015 19:39:29 -0400 Subject: [PATCH 13/37] Add StarXStarSize to the correlation function initialization function (#32a) --- stile/sys_tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 3b5dcc4..db6b869 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -127,6 +127,7 @@ def CorrelationFunctionSysTest(type=None): type objects - StarXGalaxyDensity: number density of 'galaxy' objects around 'star' objects - StarXStarShear: autocorrelation of the shapes of 'star' type objects + - StarXStarSize: autocorrelation of the size residuals for 'star' type objects relative to PSF sizes - GalaxyDensityCorrelation: position autocorrelation of 'galaxy' type objects - StarDensityCorrelation: position autocorrelation of 'star' type objects - Rho1: rho1 statistics (autocorrelation of residual star shapes) @@ -149,6 +150,8 @@ def CorrelationFunctionSysTest(type=None): return StarXGalaxyShearSysTest() elif type=='StarXStarShear': return StarXStarShearSysTest() + elif type=='StarXStarSize': + return StarXStarSizeSysTest() elif type=='GalaxyDensityCorrelation': return GalaxyDensityCorrelationSysTest() elif type=='StarDensityCorrelation': From e3a5190dac3083201041b7a82a97b2bc04eb661c Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 4 Nov 2015 03:07:08 -0500 Subject: [PATCH 14/37] Add units to x axis in correlation functions (#77) --- stile/sys_tests.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index db6b869..e600fb0 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -412,6 +412,9 @@ def getCF(self, correlation_function_type, data, data2=None, results = stile.ReadTreeCorrResultsFile(output_file) os.close(handle) os.remove(output_file) + names = results.dtype.names + # Add the sep units to the column names of radial bins from TreeCorr outputs + names = [n+' [%s]'%treecorr_kwargs['sep_units'] if 'R' in n else n for n in names] return results def compensateDefault(self, data, data2, random, random2, both=False): @@ -453,8 +456,10 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, fields = data.dtype.names # Pick which radius measurement to use for t_r in ['', 'R_nominal', 'R']: - if t_r in fields: - r = t_r + is_r = [t_r in f for f in fields] + if any(is_r): + indx = is_r.index(True) + r = fields[indx] break else: raise ValueError('No radius parameter found in data') From f937b75debb5be6d07a09011a23fd624e31724a0 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 4 Nov 2015 03:36:10 -0500 Subject: [PATCH 15/37] Add line at y=0 to correlation function plots (#77) --- stile/sys_tests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index e600fb0..0b448c1 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -495,6 +495,7 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, # Plot the first thing curr_plot = 0 ax = fig.add_subplot(nrows, 1, 1) + ax.axhline(0, alpha=0.7, color='gray') ax.errorbar(data[r], data[pd.t_field], yerr=data[pd.sigma_field], color=colors[0], label=pd.t_title) if pd.x_title and plot_bmode: @@ -511,6 +512,7 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, if pd.x_field and plot_bmode and pd.t_im_field: # Both yb and y_im: plot (y, yb) on one plot and (y_im, yb_im) on the other. ax = fig.add_subplot(nrows, 1, 2) + ax.axhline(0, alpha=0.7, color='gray') ax.errorbar(data[r], data[pd.t_im_field], yerr=data[pd.sigma_field], color=colors[0], label=pd.t_im_title) ax.errorbar(data[r], data[pd.x_im_field], yerr=data[pd.sigma_field], color=colors[1], @@ -523,6 +525,7 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, if plot_data_only and pd.datarandom_t_field: # Plot the data-only measurements if requested curr_plot += 1 ax = fig.add_subplot(nrows, 1, 2) + ax.axhline(0, alpha=0.7, color='gray') ax.errorbar(data[r], data[pd.datarandom_t_field+'d'], yerr=data[pd.sigma_field], color=colors[0], label=pd.datarandom_t_title+'d}$') if plot_bmode and pd.datarandom_x_field: @@ -536,6 +539,7 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, # Plot the randoms-only measurements if requested if plot_random_only and pd.datarandom_t_field: ax = fig.add_subplot(nrows, 1, nrows) + ax.axhline(0, alpha=0.7, color='gray') ax.errorbar(data[r], data[pd.datarandom_t_field+'r'], yerr=data[pd.sigma_field], color=colors[0], label=pd.datarandom_t_title+'r}$') if plot_bmode and pd.datarandom_x_field: From 857186f5a3621a73b474a1dd10726e479977925a Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 4 Nov 2015 03:37:37 -0500 Subject: [PATCH 16/37] Make xi->xi_re for correlation functions with only xi (#77) --- stile/sys_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 0b448c1..f72e9da 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -187,7 +187,7 @@ class method getCF(), which runs a TreeCorr correlation function on a given set PlotDetails(t_field='', t_title=r'$\langle \kappa \rangle$', datarandom_t_field='kappa_', datarandom_t_title='$kappa_{', sigma_field='sigma', y_title="$\kappa$"), # nk - PlotDetails(t_field='xi', t_title=r'$\xi$', sigma_field='sigma_xi', y_title=r"$\xi$"), # k2 + PlotDetails(t_field='xi', t_title=r'$\xi_{\mathrm{re}}$', sigma_field='sigma_xi', y_title=r"$\xi$"), # k2 PlotDetails(t_field='', t_title=r'$\langle \kappa \gamma_T\rangle$', x_field='', x_title=r'$\langle \kappa \gamma_X\rangle$', datarandom_t_field='kgamT_', datarandom_t_title=r'$\kappa \gamma_{T', From ffed98d0d8c6fa67e5ec450bcee55c1c6f9ce0d7 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Thu, 5 Nov 2015 01:45:43 -0500 Subject: [PATCH 17/37] Add check for treecorr import in setup.py and sys_tests.py (#57) --- setup.py | 9 +++++++++ stile/sys_tests.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 29f9e26..701bca7 100755 --- a/setup.py +++ b/setup.py @@ -1,11 +1,20 @@ #!/usr/bin/env python from distutils.core import setup +try: + import treecorr +except ImportError: + import warnings + warnings.warn("treecorr package cannot be imported. Installation will proceed, but you may "+ + "wish to install it if you would like to use the correlation functions within "+ + "Stile.") + setup(name='Stile', version='0.1', description='Stile: Systematics Tests in Lensing pipeline', author='The Stile team', + requirements=['numpy'], author_email='melanie.simet@gmail.com', url='https://github.com/msimet/Stile', packages=['stile', 'stile.hsc'], diff --git a/stile/sys_tests.py b/stile/sys_tests.py index f72e9da..d7f7805 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -4,8 +4,15 @@ import numpy import stile import stile_utils -import treecorr -from treecorr.corr2 import corr2_valid_params +try: + import treecorr + from treecorr.corr2 import corr2_valid_params +except ImportError: + import warnings + warnings.warn("treecorr package cannot be imported. You may "+ + "wish to install it if you would like to use the correlation functions within "+ + "Stile.") + try: import matplotlib # We should decide which backend to use (this line allows running matplotlib even on sessions From eb213575ac66d68bfbb41cfb0531004dbafa33b2 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 11 Nov 2015 03:42:35 -0500 Subject: [PATCH 18/37] Fixed errors caused by master branch (#32a) --- stile/__init__.py | 2 +- stile/sys_tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stile/__init__.py b/stile/__init__.py index 6517fc2..3db2014 100644 --- a/stile/__init__.py +++ b/stile/__init__.py @@ -2,7 +2,7 @@ WriteASCIITable, WriteFITSTable) from .stile_utils import Parser, FormatArray, fieldNames from .binning import BinList, BinStep, BinFunction, ExpandBinList -from . import treecorr_utils +import treecorr_utils from .treecorr_utils import ReadTreeCorrResultsFile from .data_handler import DataHandler from .sys_tests import (StatSysTest, CorrelationFunctionSysTest, ScatterPlotSysTest, diff --git a/stile/sys_tests.py b/stile/sys_tests.py index d7f7805..d41d7dc 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -1574,7 +1574,7 @@ def __call__(self, array, per_ccd_stat=None, color='', lim=None): linear_regression=True, reference_line='zero') -class ScatterPlotResidualSigmaVsPSFMagSysTest(ScatterPlotSysTest): +class ScatterPlotResidualSigmaVsPSFMagSysTest(BaseScatterPlotSysTest): short_name = 'scatterplot_residual_sigma_vs_psf_magnitude' long_name = 'Make a scatter plot of residual sigma vs PSF magnitude' objects_list = ['star PSF'] From dcfd6282c19fc3770293463595566ea9c0d7f02a Mon Sep 17 00:00:00 2001 From: Hironao Miyatake Date: Wed, 30 Dec 2015 13:31:09 -0500 Subject: [PATCH 19/37] Now Stile works with hscPipe 3.9.0 --- stile/hsc/base_tasks.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stile/hsc/base_tasks.py b/stile/hsc/base_tasks.py index 62796b0..56822cd 100644 --- a/stile/hsc/base_tasks.py +++ b/stile/hsc/base_tasks.py @@ -1128,14 +1128,14 @@ def getFilenameBase(dataRef): @classmethod def _makeArgumentParser(cls): parser = lsst.pipe.base.ArgumentParser(name=cls._DefaultName) - parser.add_id_argument("--id", "deepCoadd", help="data ID, with patch/tract information", + parser.add_id_argument("--id", "deepCoadd_calexp", help="data ID, with patch/tract information", ContainerClass=ExistingCoaddDataIdContainer) parser.description = parser_description return parser def getCalibData(self, dataRef, shape_cols): calib_metadata_shape = None - calib_metadata = dataRef.get("deepCoadd_md", immediate=True) + calib_metadata = dataRef.get("deepCoadd_calexp_md", immediate=True) calib_type = "calexp" # This is just so computeShapes knows the format if shape_cols: calib_metadata_shape = calib_metadata @@ -1299,14 +1299,14 @@ def getFilenameBase(dataRefList): @classmethod def _makeArgumentParser(cls): parser = lsst.pipe.base.ArgumentParser(name=cls._DefaultName) - parser.add_id_argument("--id", "deepCoadd", help="data ID, with patch/tract information", + parser.add_id_argument("--id", "deepCoadd_calexp", help="data ID, with patch/tract information", ContainerClass=ExistingCoaddDataIdContainer) parser.description = parser_description return parser def getCalibData(self, dataRef, shape_cols): calib_metadata_shape = None - calib_metadata = dataRef.get("deepCoadd_md", immediate=True) + calib_metadata = dataRef.get("deepCoadd_calexp_md", immediate=True) calib_type = "calexp" # This is just so computeShapes knows the format if shape_cols: calib_metadata_shape = calib_metadata @@ -1386,7 +1386,7 @@ def getFilenameBase(dataRefList): @classmethod def _makeArgumentParser(cls): parser = lsst.pipe.base.ArgumentParser(name=cls._DefaultName) - parser.add_id_argument("--id", "deepCoadd", help="data ID, with patch/tract information", + parser.add_id_argument("--id", "deepCoadd_calexp", help="data ID, with patch/tract information", ContainerClass=ExistingCoaddDataIdContainer) parser.description = parser_description return parser From 69ef8742d55812f7b6e8519eb9e243c27bd8d0ad Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Tue, 19 Jan 2016 03:39:33 -0500 Subject: [PATCH 20/37] Add xi_+ and xi_- documentation to CorrelationFunctionSysTest docstring (#77) --- stile/sys_tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index d41d7dc..70ed5aa 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -144,6 +144,17 @@ def CorrelationFunctionSysTest(type=None): slightly different call signature than the other methods (with the correlation function type given as the first argument) and that it lacks many of the convenience variables the other CorrelationFunctions have, such as self.objects_list and self.required_quantities. + + Shear-shear correlation functions are usually xi_+ and xi_-. Xi_+ is, nominally, g1 times g2*. Specifically: + xi_+ = Re(g1)*Re(g2)+Im(g1)*Im(g2) + xi_+,im = Im(g1)*Re(g2) - Re(g1)*Im(g2) + xi_+,im should be consistent with 0 to within noise. + + Xi_- on the other hand is g1 times g2. + xi_- = Re(g1)*Re(g2)-Im(g1)*Im(g2) + xi_-,im = Im(g1)*Re(g2) + Re(g1)*Im(g2) + Similarly, xi_-,im should be 0. + """ if type is None: return BaseCorrelationFunctionSysTest() From 597622022af3d68e43d73ef9d8dc9ad10dd37fd6 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 22 Jan 2016 06:20:59 -0500 Subject: [PATCH 21/37] Fix new SysTest objects to new format (#32a) --- stile/sys_tests.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 70ed5aa..714e083 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -7,7 +7,9 @@ try: import treecorr from treecorr.corr2 import corr2_valid_params + has_treecorr = True except ImportError: + has_treecorr = False import warnings warnings.warn("treecorr package cannot be imported. You may "+ "wish to install it if you would like to use the correlation functions within "+ @@ -103,7 +105,7 @@ def __init__(self, t_field=None, t_title=None, x_field=None, x_title=None, self.sigma_field = sigma_field # 1-sigma error bar field self.y_title = y_title # y-axis label -if treecorr.version < '3.1': +if has_treecorr and treecorr.version < '3.1': treecorr_func_dict = {'gg': treecorr.G2Correlation, 'm2': treecorr.G2Correlation, 'ng': treecorr.NGCorrelation, @@ -113,7 +115,7 @@ def __init__(self, t_field=None, t_title=None, x_field=None, x_title=None, 'kk': treecorr.K2Correlation, 'nk': treecorr.NKCorrelation, 'kg': treecorr.KGCorrelation} -else: +elif has_treecorr: treecorr_func_dict = {'gg': treecorr.GGCorrelation, 'm2': treecorr.GGCorrelation, 'ng': treecorr.NGCorrelation, @@ -133,6 +135,7 @@ def CorrelationFunctionSysTest(type=None): - BrightStarShear: tangential and cross shear of 'galaxy' type objects around 'star bright' type objects - StarXGalaxyDensity: number density of 'galaxy' objects around 'star' objects + - StarXGalaxyShear: shear-shear cross correlation of 'galaxy' and 'star' type objects - StarXStarShear: autocorrelation of the shapes of 'star' type objects - StarXStarSize: autocorrelation of the size residuals for 'star' type objects relative to PSF sizes - GalaxyDensityCorrelation: position autocorrelation of 'galaxy' type objects @@ -1089,6 +1092,7 @@ def ScatterPlotSysTest(type=None): - ResidualVsPSFG1: (star - PSF) g1 vs PSF g1 - ResidualVsPSFG2: (star - PSF) g1 vs PSF g2 - ResidualVsPSFSigma: (star - PSF) g1 vs PSF sigma + - ResidualSigmaVsPSFMag: (star - PSF)/PSF sigma vs PSF magnitude - None: an empty BaseScatterPlotSysTest class instance, which can be used for multiple types of scatter plots. See the documentation for BaseScatterPlotSysTest (especially the method scatterPlot) for more details. Note that this type has a different call signature than From 08f4b2cc945d41bd1ca83cc12df34b2a4885dfcc Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Mon, 25 Jan 2016 12:20:11 -0500 Subject: [PATCH 22/37] Add descriptions of correlation function types & output of meanings (#77) --- stile/sys_tests.py | 53 ++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 714e083..53adaab 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -130,34 +130,51 @@ def CorrelationFunctionSysTest(type=None): """ Initialize an instance of a BaseCorrelationFunctionSysTest type, based on the 'type' kwarg given. Options are: - - GalaxyShear: tangential and cross shear of 'galaxy' type objects around 'galaxy lens' - type objects - - BrightStarShear: tangential and cross shear of 'galaxy' type objects around 'star bright' - type objects - - StarXGalaxyDensity: number density of 'galaxy' objects around 'star' objects + type objects (point-shear) + - StarXGalaxyDensity: number density of 'galaxy' objects around 'star' objects (point-point) - StarXGalaxyShear: shear-shear cross correlation of 'galaxy' and 'star' type objects - - StarXStarShear: autocorrelation of the shapes of 'star' type objects - - StarXStarSize: autocorrelation of the size residuals for 'star' type objects relative to PSF sizes - - GalaxyDensityCorrelation: position autocorrelation of 'galaxy' type objects - - StarDensityCorrelation: position autocorrelation of 'star' type objects - - Rho1: rho1 statistics (autocorrelation of residual star shapes) + (shear-shear) + - BrightStarShear: tangential and cross shear of 'galaxy' type objects around 'star bright' + - (point-shear) + - StarXStarShear: autocorrelation of the shapes of 'star' type objects (shear-shear) + - StarXStarSize: autocorrelation of the size residuals for 'star' type objects relative to + PSF sizes (scalar-scalar) + - GalaxyDensityCorrelation: position autocorrelation of 'galaxy' type objects (point-point) + - StarDensityCorrelation: position autocorrelation of 'star' type objects (point-point) + - Rho1: rho1 statistics (autocorrelation of residual star shapes, shear-shear) - None: an empty BaseCorrelationFunctionSysTest class instance, which can be used for multiple types of correlation functions. See the documentation for BaseCorrelationFunctionSysTest for more details. Note that this type has a slightly different call signature than the other methods (with the correlation function type given as the first argument) and that it lacks many of the convenience variables the other CorrelationFunctions have, such as self.objects_list and self.required_quantities. + + These produce different estimators depending on the type. Point-point estimates by default use + the Landy-Szalay estimator: + xi = (DD-2DR+RR)/RR + and must include a random catalog. + + All shears in the following descriptions are the complex form in the frame aligned with the + vector between the two points, that is, g = gamma_t + i*gamma_x. + + Point-shear estimates are equivalent to average tangential shear, returned as real + and imaginary . If random catalogs are given, they are used as random lenses, and + data*shear-random*shear is returned instead. - Shear-shear correlation functions are usually xi_+ and xi_-. Xi_+ is, nominally, g1 times g2*. Specifically: - xi_+ = Re(g1)*Re(g2)+Im(g1)*Im(g2) - xi_+,im = Im(g1)*Re(g2) - Re(g1)*Im(g2) - xi_+,im should be consistent with 0 to within noise. + Shear-shear correlation functions are xi_+ and xi_-. Xi_+ is, nominally, g1 times g2*, and is + given as both the real and imaginary components. xi_+,im should be consistent with 0 to within + noise. Xi_- on the other hand is g1 times g2 (not complex conjugate). Similarly, xi_-,im should + be 0. (Note that g1 and g2 here are two *complex* shears g1_t + i*g1_x and g1_t+i*g2_x from the + two catalogs, not the two components of a single shear in sky coordinates or chip frame.) - Xi_- on the other hand is g1 times g2. - xi_- = Re(g1)*Re(g2)-Im(g1)*Im(g2) - xi_-,im = Im(g1)*Re(g2) + Re(g1)*Im(g2) - Similarly, xi_-,im should be 0. + Point-scalar (point-kappa) estimates are equivalent to ; scalar-shear estimates are + equivalent to with a corresponding imaginary case; scalar-scalar estimates + are . Random catalogs result in compensated estimators as in the point-shear + case. + Aperture mass statistics of various kinds are also available via the + BaseCorrelationFunctionSysTest class; as we do not implement those for any standard Stile tests, + interested users are directed to the TreeCorr documentation for further information. """ if type is None: return BaseCorrelationFunctionSysTest() From 0fd2b74ee3f827fe0d4abe2f21c2187cd0d56aac Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 5 Feb 2016 16:57:39 -0500 Subject: [PATCH 23/37] Make changes for working unit tests (#77) --- stile/sys_tests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 53adaab..940948b 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -1521,7 +1521,7 @@ class ScatterPlotStarVsPSFG1SysTest(BaseScatterPlotSysTest): required_quantities = [('g1', 'g1_err', 'psf_g1')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotStarVsPSFG1SysTest, + return super(BaseScatterPlotStarVsPSFG1SysTest, self).__call__(array, 'psf_g1', 'g1', 'g1_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_1$', ylabel=r'$g^{\rm star}_1$', color=color, lim=lim, @@ -1536,7 +1536,7 @@ class ScatterPlotStarVsPSFG2SysTest(BaseScatterPlotSysTest): required_quantities = [('g2', 'g2_err', 'psf_g2')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotStarVsPSFG2SysTest, + return super(BaseScatterPlotStarVsPSFG2SysTest, self).__call__(array, 'psf_g2', 'g2', 'g2_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_2$', ylabel=r'$g^{\rm star}_2$', color=color, lim=lim, @@ -1551,7 +1551,7 @@ class ScatterPlotStarVsPSFSigmaSysTest(BaseScatterPlotSysTest): required_quantities = [('sigma', 'sigma_err', 'psf_sigma')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotStarVsPSFSigmaSysTest, + return super(BaseScatterPlotStarVsPSFSigmaSysTest, self).__call__(array, 'psf_sigma', 'sigma', 'sigma_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$\sigma^{\rm PSF}$ [arcsec]', @@ -1567,7 +1567,7 @@ class ScatterPlotResidualVsPSFG1SysTest(BaseScatterPlotSysTest): required_quantities = [('g1', 'g1_err', 'psf_g1')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotResidualVsPSFG1SysTest, + return super(BaseScatterPlotResidualVsPSFG1SysTest, self).__call__(array, 'psf_g1', 'g1', 'g1_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_1$', ylabel=r'$g^{\rm star}_1 - g^{\rm PSF}_1$', @@ -1582,7 +1582,7 @@ class ScatterPlotResidualVsPSFG2SysTest(BaseScatterPlotSysTest): required_quantities = [('g2', 'g2_err', 'psf_g2')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotResidualVsPSFG2SysTest, + return super(BaseScatterPlotResidualVsPSFG2SysTest, self).__call__(array, 'psf_g2', 'g2', 'g2_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_2$', ylabel=r'$g^{\rm star}_2 - g^{\rm PSF}_2$', @@ -1597,7 +1597,7 @@ class ScatterPlotResidualVsPSFSigmaSysTest(BaseScatterPlotSysTest): required_quantities = [('sigma', 'sigma_err', 'psf_sigma')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotResidualVsPSFSigmaSysTest, + return super(BaseScatterPlotResidualVsPSFSigmaSysTest, self).__call__(array, 'psf_sigma', 'sigma', 'sigma_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$\sigma^{\rm PSF}$ [arcsec]', @@ -1623,7 +1623,7 @@ def __call__(self, array, per_ccd_stat='None', color='', lim=None): use_array = numpy.lib.recfunctions.append_fields(use_array, 'sigma_residual_frac_err', use_array['sigma_err'] /use_array['psf_sigma']) - return super(ScatterPlotResidualSigmaVsPSFMagSysTest, + return super(BaseScatterPlotResidualSigmaVsPSFMagSysTest, self).__call__(use_array, 'mag_inst', 'sigma_residual_frac', 'sigma_residual_frac_err', residual=False, per_ccd_stat=self.per_ccd_stat, From e86b0283ee701b06ee0611014b2ecbaa99db5228 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 5 Feb 2016 17:14:28 -0500 Subject: [PATCH 24/37] Fix relative import in __init__ --- stile/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stile/__init__.py b/stile/__init__.py index 3db2014..6517fc2 100644 --- a/stile/__init__.py +++ b/stile/__init__.py @@ -2,7 +2,7 @@ WriteASCIITable, WriteFITSTable) from .stile_utils import Parser, FormatArray, fieldNames from .binning import BinList, BinStep, BinFunction, ExpandBinList -import treecorr_utils +from . import treecorr_utils from .treecorr_utils import ReadTreeCorrResultsFile from .data_handler import DataHandler from .sys_tests import (StatSysTest, CorrelationFunctionSysTest, ScatterPlotSysTest, From 66482f737bef1b12e6659c7b5627bbbd0d31503b Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Tue, 16 Feb 2016 22:02:03 -0500 Subject: [PATCH 25/37] Fix super() bug found by Hironao (#32a) --- stile/sys_tests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 940948b..53adaab 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -1521,7 +1521,7 @@ class ScatterPlotStarVsPSFG1SysTest(BaseScatterPlotSysTest): required_quantities = [('g1', 'g1_err', 'psf_g1')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotStarVsPSFG1SysTest, + return super(ScatterPlotStarVsPSFG1SysTest, self).__call__(array, 'psf_g1', 'g1', 'g1_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_1$', ylabel=r'$g^{\rm star}_1$', color=color, lim=lim, @@ -1536,7 +1536,7 @@ class ScatterPlotStarVsPSFG2SysTest(BaseScatterPlotSysTest): required_quantities = [('g2', 'g2_err', 'psf_g2')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotStarVsPSFG2SysTest, + return super(ScatterPlotStarVsPSFG2SysTest, self).__call__(array, 'psf_g2', 'g2', 'g2_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_2$', ylabel=r'$g^{\rm star}_2$', color=color, lim=lim, @@ -1551,7 +1551,7 @@ class ScatterPlotStarVsPSFSigmaSysTest(BaseScatterPlotSysTest): required_quantities = [('sigma', 'sigma_err', 'psf_sigma')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotStarVsPSFSigmaSysTest, + return super(ScatterPlotStarVsPSFSigmaSysTest, self).__call__(array, 'psf_sigma', 'sigma', 'sigma_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$\sigma^{\rm PSF}$ [arcsec]', @@ -1567,7 +1567,7 @@ class ScatterPlotResidualVsPSFG1SysTest(BaseScatterPlotSysTest): required_quantities = [('g1', 'g1_err', 'psf_g1')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotResidualVsPSFG1SysTest, + return super(ScatterPlotResidualVsPSFG1SysTest, self).__call__(array, 'psf_g1', 'g1', 'g1_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_1$', ylabel=r'$g^{\rm star}_1 - g^{\rm PSF}_1$', @@ -1582,7 +1582,7 @@ class ScatterPlotResidualVsPSFG2SysTest(BaseScatterPlotSysTest): required_quantities = [('g2', 'g2_err', 'psf_g2')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotResidualVsPSFG2SysTest, + return super(ScatterPlotResidualVsPSFG2SysTest, self).__call__(array, 'psf_g2', 'g2', 'g2_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_2$', ylabel=r'$g^{\rm star}_2 - g^{\rm PSF}_2$', @@ -1597,7 +1597,7 @@ class ScatterPlotResidualVsPSFSigmaSysTest(BaseScatterPlotSysTest): required_quantities = [('sigma', 'sigma_err', 'psf_sigma')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotResidualVsPSFSigmaSysTest, + return super(ScatterPlotResidualVsPSFSigmaSysTest, self).__call__(array, 'psf_sigma', 'sigma', 'sigma_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$\sigma^{\rm PSF}$ [arcsec]', @@ -1623,7 +1623,7 @@ def __call__(self, array, per_ccd_stat='None', color='', lim=None): use_array = numpy.lib.recfunctions.append_fields(use_array, 'sigma_residual_frac_err', use_array['sigma_err'] /use_array['psf_sigma']) - return super(BaseScatterPlotResidualSigmaVsPSFMagSysTest, + return super(ScatterPlotResidualSigmaVsPSFMagSysTest, self).__call__(use_array, 'mag_inst', 'sigma_residual_frac', 'sigma_residual_frac_err', residual=False, per_ccd_stat=self.per_ccd_stat, From 594d8840b4ab605dc01864f6787d85c30194c2a5 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 17 Feb 2016 12:37:52 -0500 Subject: [PATCH 26/37] Merge conflicts pt 2 (#77) --- stile/sys_tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 53adaab..8fb8206 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -130,12 +130,13 @@ def CorrelationFunctionSysTest(type=None): """ Initialize an instance of a BaseCorrelationFunctionSysTest type, based on the 'type' kwarg given. Options are: + - GalaxyShear: tangential and cross shear of 'galaxy' type objects around 'galaxy lens' + type objects (point-shear correlation function) + - BrightStarShear: tangential and cross shear of 'galaxy' type objects around 'star bright' type objects (point-shear) - StarXGalaxyDensity: number density of 'galaxy' objects around 'star' objects (point-point) - - StarXGalaxyShear: shear-shear cross correlation of 'galaxy' and 'star' type objects + - StarXGalaxyShear: shear-shear cross correlation of 'galaxy' and 'star' type objects (shear-shear) - - BrightStarShear: tangential and cross shear of 'galaxy' type objects around 'star bright' - - (point-shear) - StarXStarShear: autocorrelation of the shapes of 'star' type objects (shear-shear) - StarXStarSize: autocorrelation of the size residuals for 'star' type objects relative to PSF sizes (scalar-scalar) From 228ec4d6557dda5a4a012b3139f17ca8507712d5 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 11 Nov 2015 03:42:35 -0500 Subject: [PATCH 27/37] Fixed errors caused by master branch (#32a) --- stile/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stile/__init__.py b/stile/__init__.py index 6517fc2..3db2014 100644 --- a/stile/__init__.py +++ b/stile/__init__.py @@ -2,7 +2,7 @@ WriteASCIITable, WriteFITSTable) from .stile_utils import Parser, FormatArray, fieldNames from .binning import BinList, BinStep, BinFunction, ExpandBinList -from . import treecorr_utils +import treecorr_utils from .treecorr_utils import ReadTreeCorrResultsFile from .data_handler import DataHandler from .sys_tests import (StatSysTest, CorrelationFunctionSysTest, ScatterPlotSysTest, From c3533d38942d8fefa1925c1c545ec64e8123a902 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 5 Feb 2016 16:57:39 -0500 Subject: [PATCH 28/37] Make changes for working unit tests (#77) --- stile/sys_tests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 8fb8206..c0ebd5c 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -1522,7 +1522,7 @@ class ScatterPlotStarVsPSFG1SysTest(BaseScatterPlotSysTest): required_quantities = [('g1', 'g1_err', 'psf_g1')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotStarVsPSFG1SysTest, + return super(BaseScatterPlotStarVsPSFG1SysTest, self).__call__(array, 'psf_g1', 'g1', 'g1_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_1$', ylabel=r'$g^{\rm star}_1$', color=color, lim=lim, @@ -1537,7 +1537,7 @@ class ScatterPlotStarVsPSFG2SysTest(BaseScatterPlotSysTest): required_quantities = [('g2', 'g2_err', 'psf_g2')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotStarVsPSFG2SysTest, + return super(BaseScatterPlotStarVsPSFG2SysTest, self).__call__(array, 'psf_g2', 'g2', 'g2_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_2$', ylabel=r'$g^{\rm star}_2$', color=color, lim=lim, @@ -1552,7 +1552,7 @@ class ScatterPlotStarVsPSFSigmaSysTest(BaseScatterPlotSysTest): required_quantities = [('sigma', 'sigma_err', 'psf_sigma')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotStarVsPSFSigmaSysTest, + return super(BaseScatterPlotStarVsPSFSigmaSysTest, self).__call__(array, 'psf_sigma', 'sigma', 'sigma_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$\sigma^{\rm PSF}$ [arcsec]', @@ -1568,7 +1568,7 @@ class ScatterPlotResidualVsPSFG1SysTest(BaseScatterPlotSysTest): required_quantities = [('g1', 'g1_err', 'psf_g1')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotResidualVsPSFG1SysTest, + return super(BaseScatterPlotResidualVsPSFG1SysTest, self).__call__(array, 'psf_g1', 'g1', 'g1_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_1$', ylabel=r'$g^{\rm star}_1 - g^{\rm PSF}_1$', @@ -1583,7 +1583,7 @@ class ScatterPlotResidualVsPSFG2SysTest(BaseScatterPlotSysTest): required_quantities = [('g2', 'g2_err', 'psf_g2')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotResidualVsPSFG2SysTest, + return super(BaseScatterPlotResidualVsPSFG2SysTest, self).__call__(array, 'psf_g2', 'g2', 'g2_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_2$', ylabel=r'$g^{\rm star}_2 - g^{\rm PSF}_2$', @@ -1598,7 +1598,7 @@ class ScatterPlotResidualVsPSFSigmaSysTest(BaseScatterPlotSysTest): required_quantities = [('sigma', 'sigma_err', 'psf_sigma')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(ScatterPlotResidualVsPSFSigmaSysTest, + return super(BaseScatterPlotResidualVsPSFSigmaSysTest, self).__call__(array, 'psf_sigma', 'sigma', 'sigma_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$\sigma^{\rm PSF}$ [arcsec]', @@ -1624,7 +1624,7 @@ def __call__(self, array, per_ccd_stat='None', color='', lim=None): use_array = numpy.lib.recfunctions.append_fields(use_array, 'sigma_residual_frac_err', use_array['sigma_err'] /use_array['psf_sigma']) - return super(ScatterPlotResidualSigmaVsPSFMagSysTest, + return super(BaseScatterPlotResidualSigmaVsPSFMagSysTest, self).__call__(use_array, 'mag_inst', 'sigma_residual_frac', 'sigma_residual_frac_err', residual=False, per_ccd_stat=self.per_ccd_stat, From e73b8a558e87c27657afbf87a3c6a999ff5c7083 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Fri, 5 Feb 2016 17:14:28 -0500 Subject: [PATCH 29/37] Fix relative import in __init__ --- stile/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stile/__init__.py b/stile/__init__.py index 3db2014..6517fc2 100644 --- a/stile/__init__.py +++ b/stile/__init__.py @@ -2,7 +2,7 @@ WriteASCIITable, WriteFITSTable) from .stile_utils import Parser, FormatArray, fieldNames from .binning import BinList, BinStep, BinFunction, ExpandBinList -import treecorr_utils +from . import treecorr_utils from .treecorr_utils import ReadTreeCorrResultsFile from .data_handler import DataHandler from .sys_tests import (StatSysTest, CorrelationFunctionSysTest, ScatterPlotSysTest, From 837a15215616ceff6d3162582502876c4ef39916 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Tue, 16 Feb 2016 22:02:03 -0500 Subject: [PATCH 30/37] Fix super() bug found by Hironao (#32a) --- stile/sys_tests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index c0ebd5c..8fb8206 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -1522,7 +1522,7 @@ class ScatterPlotStarVsPSFG1SysTest(BaseScatterPlotSysTest): required_quantities = [('g1', 'g1_err', 'psf_g1')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotStarVsPSFG1SysTest, + return super(ScatterPlotStarVsPSFG1SysTest, self).__call__(array, 'psf_g1', 'g1', 'g1_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_1$', ylabel=r'$g^{\rm star}_1$', color=color, lim=lim, @@ -1537,7 +1537,7 @@ class ScatterPlotStarVsPSFG2SysTest(BaseScatterPlotSysTest): required_quantities = [('g2', 'g2_err', 'psf_g2')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotStarVsPSFG2SysTest, + return super(ScatterPlotStarVsPSFG2SysTest, self).__call__(array, 'psf_g2', 'g2', 'g2_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_2$', ylabel=r'$g^{\rm star}_2$', color=color, lim=lim, @@ -1552,7 +1552,7 @@ class ScatterPlotStarVsPSFSigmaSysTest(BaseScatterPlotSysTest): required_quantities = [('sigma', 'sigma_err', 'psf_sigma')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotStarVsPSFSigmaSysTest, + return super(ScatterPlotStarVsPSFSigmaSysTest, self).__call__(array, 'psf_sigma', 'sigma', 'sigma_err', residual=False, per_ccd_stat=per_ccd_stat, xlabel=r'$\sigma^{\rm PSF}$ [arcsec]', @@ -1568,7 +1568,7 @@ class ScatterPlotResidualVsPSFG1SysTest(BaseScatterPlotSysTest): required_quantities = [('g1', 'g1_err', 'psf_g1')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotResidualVsPSFG1SysTest, + return super(ScatterPlotResidualVsPSFG1SysTest, self).__call__(array, 'psf_g1', 'g1', 'g1_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_1$', ylabel=r'$g^{\rm star}_1 - g^{\rm PSF}_1$', @@ -1583,7 +1583,7 @@ class ScatterPlotResidualVsPSFG2SysTest(BaseScatterPlotSysTest): required_quantities = [('g2', 'g2_err', 'psf_g2')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotResidualVsPSFG2SysTest, + return super(ScatterPlotResidualVsPSFG2SysTest, self).__call__(array, 'psf_g2', 'g2', 'g2_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$g^{\rm PSF}_2$', ylabel=r'$g^{\rm star}_2 - g^{\rm PSF}_2$', @@ -1598,7 +1598,7 @@ class ScatterPlotResidualVsPSFSigmaSysTest(BaseScatterPlotSysTest): required_quantities = [('sigma', 'sigma_err', 'psf_sigma')] def __call__(self, array, per_ccd_stat=None, color='', lim=None): - return super(BaseScatterPlotResidualVsPSFSigmaSysTest, + return super(ScatterPlotResidualVsPSFSigmaSysTest, self).__call__(array, 'psf_sigma', 'sigma', 'sigma_err', residual=True, per_ccd_stat=per_ccd_stat, xlabel=r'$\sigma^{\rm PSF}$ [arcsec]', @@ -1624,7 +1624,7 @@ def __call__(self, array, per_ccd_stat='None', color='', lim=None): use_array = numpy.lib.recfunctions.append_fields(use_array, 'sigma_residual_frac_err', use_array['sigma_err'] /use_array['psf_sigma']) - return super(BaseScatterPlotResidualSigmaVsPSFMagSysTest, + return super(ScatterPlotResidualSigmaVsPSFMagSysTest, self).__call__(use_array, 'mag_inst', 'sigma_residual_frac', 'sigma_residual_frac_err', residual=False, per_ccd_stat=self.per_ccd_stat, From 281963eb785401c062bcc14c9ce48668a29d2852 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 17 Feb 2016 15:49:39 -0500 Subject: [PATCH 31/37] Fix merge-induced bug in tests/test_correlation_functions.py (#77) --- tests/test_correlation_functions.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/tests/test_correlation_functions.py b/tests/test_correlation_functions.py index 427dfe1..32f7911 100755 --- a/tests/test_correlation_functions.py +++ b/tests/test_correlation_functions.py @@ -98,21 +98,4 @@ def test_generator(self): if __name__=='__main__': unittest.main() ->>>>>>> Test new generator functionality (#32a) - def test_generator(self): - """Make sure the CorrelationFunctionSysTest() generator returns the right objects""" - object_list = ['GalaxyShear', 'BrightStarShear', 'StarXGalaxyDensity', 'StarXGalaxyShear', - 'StarXStarShear', 'GalaxyDensityCorrelation', 'StarDensityCorrelation'] - for object_type in object_list: - object_1 = stile.CorrelationFunctionSysTest(object_type) - object_2 = eval('stile.sys_tests.'+object_type+'SysTest()') - self.assertEqual(type(object_1), type(object_2)) - - self.assertRaises(ValueError, stile.CorrelationFunctionSysTest, 'hello') - self.assertEqual(type(stile.sys_tests.BaseCorrelationFunctionSysTest()), - type(stile.CorrelationFunctionSysTest())) - - -if __name__ == '__main__': - unittest.main() From 4d6e4c0165a59e748479e841f84effa50196f36c Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 17 Feb 2016 15:50:22 -0500 Subject: [PATCH 32/37] Actually rewrite name of radius column in corr func computation (#77) --- stile/sys_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index aee5ee1..119eb0d 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -454,6 +454,7 @@ def getCF(self, correlation_function_type, data, data2=None, names = results.dtype.names # Add the sep units to the column names of radial bins from TreeCorr outputs names = [n+' [%s]'%treecorr_kwargs['sep_units'] if 'R' in n else n for n in names] + results.dtype.names = names return results def compensateDefault(self, data, data2, random, random2, both=False): From 47ad9cd45118f5e5d406055b3350b7df48b3c365 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 17 Feb 2016 15:52:55 -0500 Subject: [PATCH 33/37] Change expected results from getCF() in test_correlation_functions (#77) --- tests/test_correlation_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_correlation_functions.py b/tests/test_correlation_functions.py index 32f7911..a537768 100755 --- a/tests/test_correlation_functions.py +++ b/tests/test_correlation_functions.py @@ -45,7 +45,7 @@ def setUp(self): (0.68766, 0.68766, 0.0, 0.0, 0.0, 0.0, 0.0), (0.79877, 0.79877, 0.0, 0.0, 0.0, 0.0, 0.0), (0.92784, 0.92784, 0.0, 0.0, 0.0, 0.0, 0.0)], - dtype=[("R_nom", float), ("", float), ("", float), ("", float), + dtype=[("R_nom [deg]", float), (" [deg]", float), ("", float), ("", float), ("sigma", float), ("weight", float), ("npairs", float)]) def test_getCF(self): From ce8933781e1edd92ababee25d3da73796c43508c Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 17 Feb 2016 15:55:45 -0500 Subject: [PATCH 34/37] Check for proper error in test_singlebin_input_errors (#77) --- tests/test_binning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_binning.py b/tests/test_binning.py index 57cc344..a6299df 100644 --- a/tests/test_binning.py +++ b/tests/test_binning.py @@ -338,7 +338,7 @@ def test_singlebin_input_errors(self): sfb = stile.binning.SingleFunctionBin(binfunction, 1) self.assertIsNotNone(sb.long_name) # check that this was made properly self.assertRaises(TypeError, sb, [1, 2, 3, 4]) - self.assertRaises(ValueError, sb, numpy.array([1, 2, 3, 4])) + self.assertRaises(IndexError, sb, numpy.array([1, 2, 3, 4])) self.assertRaises(ValueError, sb, numpy.array([(1, ), (2, ), (3, ), (4, )], dtype=[('field_1', int)])) self.assertRaises(TypeError, sb, 3) From 5a7eda6dce5689c9c3c88610306a1dfe2f598076 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Wed, 17 Feb 2016 16:02:46 -0500 Subject: [PATCH 35/37] Changelog for issue #77 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b63752b..273220b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ -2/10/15 Add a setup.py installer (issue #57) +2/17/16: Changes to correlation function plots & documentation (issue #77) +2/10/15: Add a setup.py installer (issue #57) 8/26/14: Change from relying on compiled C-code corr2 to Python package TreeCorr (issue #33) From 46b3c4b1e5520db4ef65563e09217bc44c56a408 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Tue, 1 Mar 2016 17:56:01 -0500 Subject: [PATCH 36/37] Tight_layout() in CorrelationFunctionSysTest plot() method as per Hironao's suggetsion (#77) --- stile/sys_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 119eb0d..5c1f3b4 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -591,6 +591,7 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, ax.set_ylabel(pd.y_title) ax.legend() ax.set_xlabel(r) + plt.tight_layout() return fig def __call__(self, *args, **kwargs): From 3630cc05280c1b57dd40b9415240b4d33e3a9c14 Mon Sep 17 00:00:00 2001 From: Melanie Simet Date: Mon, 14 Mar 2016 16:01:54 -0400 Subject: [PATCH 37/37] Force scientific notation in CF plotting (#77) --- stile/sys_tests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stile/sys_tests.py b/stile/sys_tests.py index 5c1f3b4..36cc855 100644 --- a/stile/sys_tests.py +++ b/stile/sys_tests.py @@ -547,6 +547,8 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, ax.set_xscale('log') ax.set_yscale(yscale) ax.set_xlim(xlim) + # To prevent too-long decimal y-axis ticklabels that push the label out of frame + ax.ticklabel_format(axis='y', style='sci', scilimits=(-3,5)) ax.set_ylabel(pd.y_title) ax.legend() if pd.x_field and plot_bmode and pd.t_im_field: @@ -559,6 +561,7 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, label=pd.x_im_title) ax.set_xscale('log') ax.set_yscale(yscale) + ax.ticklabel_format(axis='y', style='sci', scilimits=(-3,5)) ax.set_xlim(xlim) ax.set_ylabel(pd.y_title) ax.legend() @@ -573,6 +576,7 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, color=colors[1], label=pd.datarandom_x_title+'d}$') ax.set_xscale('log') ax.set_yscale(yscale) + ax.ticklabel_format(axis='y', style='sci', scilimits=(-3,5)) ax.set_xlim(xlim) ax.set_ylabel(pd.y_title) ax.legend() @@ -587,6 +591,7 @@ def plot(self, data, colors=['r', 'b'], log_yscale=False, color=colors[1], label=pd.datarandom_x_title+'r}$') ax.set_xscale('log') ax.set_yscale(yscale) + ax.ticklabel_format(axis='y', style='sci', scilimits=(-3,5)) ax.set_xlim(xlim) ax.set_ylabel(pd.y_title) ax.legend()