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

Modifications to run catalogs with or without agn contributions #177

Merged
merged 4 commits into from
Aug 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
29 changes: 19 additions & 10 deletions descqa/ColorDistribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def __init__(self, **kwargs): # pylint: disable=W0231
self.color_transformation_q = kwargs.get('color_transformation_q', True)
self.Mag_r_limit = kwargs.get('Mag_r_limit', None)
self.rest_frame = kwargs.get('rest_frame', bool(self.Mag_r_limit and not self.obs_r_mag_limit))

self.use_agn = kwargs.get('use_agn', True)
yymao marked this conversation as resolved.
Show resolved Hide resolved

# bins of color distribution
self.bins = np.linspace(-1, 4, 2000)
self.binsize = self.bins[1] - self.bins[0]
Expand Down Expand Up @@ -111,12 +112,17 @@ def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
if self.rest_frame:
possible_names = ('Mag_{}_lsst', 'Mag_{}_sdss', 'Mag_true_{}_lsst_z0', 'Mag_true_{}_sdss_z0')
else:
possible_names = ('mag_{}_sdss', 'mag_{}_des', 'mag_true_{}_sdss', 'mag_true_{}_des')
possible_lsst_names = ('mag_{}_lsst', 'mag_true_{}_lsst') if self.use_agn else ('mag_{}_noagn_lsst',
yymao marked this conversation as resolved.
Show resolved Hide resolved
'mag_true_{}_noagn_lsst')
possible_names = ('mag_{}_sdss', 'mag_{}_des', 'mag_true_{}_sdss', 'mag_true_{}_des') + possible_lsst_names

labels = {band: catalog_instance.first_available(*(n.format(band) for n in possible_names)) for band in bands}
labels = {k: v for k, v in labels.items() if v}

if len(labels) < 2:
return TestResult(skipped=True, summary='magnitudes in mock catalog do not have at least two needed bands.')
filters = set((v.rpartition('_')[-1] for v in labels.values()))

if len(filters) > 1:
return TestResult(skipped=True, summary='magnitudes in mock catalog have mixed filters.')
filter_this = filters.pop()
Expand All @@ -130,10 +136,11 @@ def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
'{} < {}'.format(labels['redshift'], self.zhi)]
data = catalog_instance.get_quantities(list(labels.values()), filters)
data = {k: data[v] for k, v in labels.items()}

print(list(data.keys()))
yymao marked this conversation as resolved.
Show resolved Hide resolved

# Color transformation
color_trans = None
if self.color_transformation_q:
if self.color_transformation_q and filter_this != 'lsst':
yymao marked this conversation as resolved.
Show resolved Hide resolved
color_trans_name = None
if self.validation_catalog == 'DEEP2':
color_trans_name = '{}2cfht'.format(filter_this)
Expand Down Expand Up @@ -180,7 +187,8 @@ def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
mock_color_dist[color]['binctr'] + color_shift[color], mock_color_dist[color]['cdf'],
self.obs_color_dist[color]['binctr'], self.obs_color_dist[color]['cdf'])

self.make_plots(mock_color_dist, color_shift, cvm_omega, cvm_omega_shift, catalog_name, output_dir)
self.make_plots(mock_color_dist, color_shift, cvm_omega, cvm_omega_shift, catalog_name,
output_dir, filter_this)

# Write to summary file
fn = os.path.join(output_dir, self.summary_output_file)
Expand All @@ -206,9 +214,10 @@ def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
return TestResult(inspect_only=True)


def make_plots(self, mock_color_dist, color_shift, cvm_omega, cvm_omega_shift, catalog_name, output_dir):
def make_plots(self, mock_color_dist, color_shift, cvm_omega, cvm_omega_shift, catalog_name,
output_dir, filters):
available_colors = [c for c in self.colors if c in mock_color_dist]
print(available_colors)

nrows = int(np.ceil(len(available_colors)/2.))
fig_pdf, axes_pdf = plt.subplots(nrows, 2, figsize=(8, 3.5*nrows))
fig_cdf, axes_cdf = plt.subplots(nrows, 2, figsize=(8, 3.5*nrows))
Expand All @@ -217,8 +226,8 @@ def make_plots(self, mock_color_dist, color_shift, cvm_omega, cvm_omega_shift, c
title = '$m_r < {:2.1f}, {:.1f} < z < {:.1f}$'.format(self.obs_r_mag_limit, self.zlo, self.zhi)
elif self.Mag_r_limit:
title = '$M_r < {:2.1f}, {:.1f} < z < {:.1f}$'.format(self.Mag_r_limit, self.zlo, self.zhi)

print(mock_color_dist.keys())
title = title + ' (LSST filters)' if filters == 'lsst' else title
yymao marked this conversation as resolved.
Show resolved Hide resolved

for ax_cdf, ax_pdf, color in zip(axes_cdf.flat, axes_pdf.flat, available_colors):

if color not in mock_color_dist or (self.validation_catalog and color not in self.obs_color_dist):
Expand Down Expand Up @@ -256,7 +265,7 @@ def make_plots(self, mock_color_dist, color_shift, cvm_omega, cvm_omega_shift, c
linestyle='--', color='C2')
ax_pdf.set_xlabel('${}$'.format(color))
ax_pdf.set_xlim(xmin, xmax)
ax_pdf.set_ylim(ymin=0.)
ax_pdf.set_ylim(bottom=0.)
ax_pdf.set_title(title)
ax_pdf.legend(loc='upper left', frameon=False)

Expand Down
10 changes: 10 additions & 0 deletions descqa/configs/Color_Dist_DEEP2_noagn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
subclass_name: ColorDistribution.ColorDistribution
obs_r_mag_limit: 24.0
zlo: 0.85
zhi: 0.95
validation_catalog: DEEP2
use_agn: false
plot_pdf_q: true
plot_cdf_q: false
color_transformation_q: true
description: Compare the mock galaxy color distribution with DEEP2
10 changes: 10 additions & 0 deletions descqa/configs/Color_Dist_SDSS_noagn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
subclass_name: ColorDistribution.ColorDistribution
obs_r_mag_limit: 17.7
zlo: 0.05
zhi: 0.1
validation_catalog: SDSS
use_agn: false
plot_pdf_q: true
plot_cdf_q: false
color_transformation_q: true
description: Compare the mock galaxy color distribution with SDSS