Skip to content

Commit

Permalink
Merge pull request #11 from patricialarsen/shear_test
Browse files Browse the repository at this point in the history
adding srv tests, testing add on catalogs, testing analysis_tools (th…
  • Loading branch information
patricialarsen authored Oct 18, 2022
2 parents 9891f4f + 784521b commit f620037
Show file tree
Hide file tree
Showing 22 changed files with 1,920 additions and 167 deletions.
17 changes: 17 additions & 0 deletions descqa/configs/srv_analysistools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
subclass_name: srv_analysistools.TestMetric
description: 'test install of analysis tools'
included_by_default: true

ra: 'ra'
dec: 'dec'
models: ['cModel']

bands: ['r','i']

catalog_filters:

- filters: ['detect_isIsolated','extendedness==0','detect_isPrimary']

mag_lim: 26
snr_lim: 5.0
compare: True
17 changes: 9 additions & 8 deletions descqa/configs/srv_colortest.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
subclass_name: srv_colortest.CheckFluxes
description: 'Check flags'
subclass_name: srv_colortest2.CheckFluxes
description: 'Check fluxes and magnitudes'
included_by_default: true

ra: 'ra'
dec: 'dec'
cmodel: 'cModelFlux_'
cmodel_err: 'cModelFluxErr_'
cmodel_flag: 'cModelFlux_flag_'
models: ['calib','cModel','gaap']

bands:
- bands: ['r','u','i']
bands: ['r','u','i','g','z','y']

catalog_filters:

- filters: ['mag_r < 28', 'mag_i < 28']
- filters: ['detect_isIsolated','extendedness==0','detect_isPrimary']

mag_lim: 26
snr_lim: 5.0
compare: True
46 changes: 38 additions & 8 deletions descqa/configs/srv_ngals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,52 @@ ra: 'ra'
dec: 'dec'

flags_to_check:
- quantities: 'psFlux_flag_u'

#- quantities: 'deblend_skipped'
#kind: 'bool'
#flag_val: True

# - quantities: 'refBand'
#kind: 'str'
#flag_val: 'r'
#
#- quantities: 'sky_object'
#kind: 'bool'
#flag_val: True

- quantities: 'cModelFlux_flag_i'
kind: 'bool'
flag_val: False
flag_val: True

- quantities: 'good'
- quantities: 'cModelFlux_flag_r'
kind: 'bool'
flag_val: False
flag_val: True

#- quantities: 'shape_flag'
#kind: 'bool'
#flag_val: True

- quantities: 'I_flag'
#- quantities: 'xy_flag'
#kind: 'bool'
#flag_val: True

- quantities: 'detect_isIsolated'
kind: 'bool'
flag_val: False
flag_val: True

- quantities: 'cModelFlux_flag_r'
#- quantities: 'i_pixelFlags_bad'
#kind: 'bool'
#flag_val: True

# - quantities: 'i_pixelFlags_interpolatedCenter'
#kind: 'bool'
#flag_val: True

- quantities: 'good'
kind: 'bool'
flag_val: False


catalog_filters:

- filters: ['extendedness==1']
- filters: ['extendedness==1','detect_isPrimary','mag_r < 25']
25 changes: 25 additions & 0 deletions descqa/configs/srv_ngals_dc2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
subclass_name: srv_ngals.CheckNgals
description: 'Check flags'
included_by_default: true
ra: 'ra'
dec: 'dec'

flags_to_check:

- quantities: 'cModelFlux_flag_i'
kind: 'bool'
flag_val: True

- quantities: 'cModelFlux_flag_r'
kind: 'bool'
flag_val: True

- quantities: 'good'
kind: 'bool'
flag_val: False


catalog_filters:

- filters: ['mag_r < 25']

75 changes: 75 additions & 0 deletions descqa/configs/srv_readiness_dc2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
subclass_name: readiness_test_synchronous.CheckQuantities
description: 'Plot histograms of listed quantities and perform range, finiteness, mean and standard deviation checks.'
included_by_default: true

subset_size: 1000000

quantities_to_check:
- quantities: ['ra', 'dec']
kind: 'double'
label: 'deg'
min: [-2.51, -2.49]
max: [2.49, 2.51]
f_inf: 0
f_nan: 0
f_outlier: 0

- quantities: ['cModelFlux_i','cModelFlux_r','cModelFlux_g']
kind: 'double'
label: 'cModelFlux (i,r,g)'
min: [-0.2, 0]
max: [0, 0.2]
f_inf: 0
log: true
f_nan: 0
f_outlier: 0

- quantities: ['psFlux_i', 'psFlux_r','psFlux_g']
kind: 'double'
label: 'psFlux (i,r,g)'
min: [0, 0.001]
max: [179.99, 180]
f_inf: 0
log: true
f_nan: 0
f_outlier: 0

- quantities: ['mag_i','mag_r','mag_g']
kind: 'double'
label: 'mag_x (x=i,r,g)'
min: [null, 15]
max: [25, null]
f_inf: 0
f_nan: 0
f_outlier: 0

- quantities: 'blendedness'
kind: 'double'
label: 'blendedness'
min: [NULL, NULL]
max: [NULL, NULL]
f_inf: 0
f_nan: 0
f_outlier: 0


- quantities: 'psf_fwhm_r'
kind: 'double'
label: 'FWHM of r band'
min: [NULL, NULL]
max: [NULL, NULL]
f_inf: 0
f_nan: 0
f_outlier: 0


- quantities: ['shear_1', 'shear_2']
kind: 'double'
label: 'shear_12'
min: [null, -0.1]
max: [0.1, null]
f_inf: 0
f_nan: 0
f_outlier: 0


56 changes: 56 additions & 0 deletions descqa/configs/srv_readiness_dp02.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
subclass_name: readiness_test_synchronous.CheckQuantities
description: 'Plot histograms of listed quantities and perform range, finiteness, mean and standard deviation checks.'
included_by_default: true

subset_size: 1000000

quantities_to_check:
- quantities: ['ra', 'dec']
kind: 'double'
label: 'deg'
min: [-2.51, -2.49]
max: [2.49, 2.51]
f_inf: 0

- quantities: ['cModelFlux_i','cModelFlux_r','cModelFlux_g']
kind: 'double'
label: 'cModelFlux (i,r,g)'
min: [-0.2, 0]
max: [0, 0.2]
f_inf: 0
log: true

- quantities: ['psFlux_i', 'psFlux_r','psFlux_g']
kind: 'double'
label: 'psFlux (i,r,g)'
min: [0, 0.001]
max: [179.99, 180]
f_inf: 0
log: true

- quantities: ['mag_i','mag_r','mag_g']
kind: 'double'
label: 'mag_x (x=i,r,g)'
min: [null, 15]
max: [25, null]
f_inf: 0

- quantities: 'deblend_nChild'
kind: 'int'
label: '# blended objects'

- quantities: 'refFwhm'
kind: 'double'
label: 'FWHM of ref band'

- quantities: ['shear_1', 'shear_2']
kind: 'double'
label: 'shear_12'
min: [null, -0.1]
max: [0.1, null]
f_inf: 0

catalog_filters:

- filters: ['extendedness==1', 'sky_object==False', 'shape_flag==False','detect_isPrimary']

2 changes: 1 addition & 1 deletion descqa/configs/srv_shear.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
subclass_name: srv_s1s2.CheckEllipticity
subclass_name: srv_shear.CheckEllipticity
description: 'Check ellipticity values and moments'
included_by_default: true

Expand Down
17 changes: 17 additions & 0 deletions descqa/configs/srv_shear_dp02.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
subclass_name: srv_shear.CheckEllipticity
description: 'Check ellipticity values and moments'
included_by_default: true

ra: 'ra'
dec: 'dec'
Ixx: 'Ixx_pixel'
Iyy: 'Iyy_pixel'
Ixy: 'Ixy_pixel'
IxxPSF: 'IxxPSF_pixel'
IyyPSF: 'IyyPSF_pixel'
IxyPSF: 'IxyPSF_pixel'
psf_fwhm: 'psf_fwhm'
bands: ['r','i','g','z','y']

catalog_filters:
- filters: ['extendedness==1','detect_isPrimary']
2 changes: 2 additions & 0 deletions descqa/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def send_to_master(value, kind):
recvbuf = np.zeros(tot_num)
elif kind=='bool':
recvbuf = np.zeros(tot_num)!=0.0
elif kind=='int':
recvbuf = np.zeros(tot_num).astype(int)
else:
raise NotImplementedError
else:
Expand Down
19 changes: 13 additions & 6 deletions descqa/readiness_test_synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import re
import fnmatch
from itertools import cycle
from itertools import cycle, chain
from collections import defaultdict, OrderedDict
import numpy as np
import numexpr as ne
Expand Down Expand Up @@ -48,6 +48,7 @@ def find_outlier(x,subset_size):
x_small = np.random.choice(x,size=subset_size)
l, m, h = np.percentile(x_small, norm.cdf([-1, 0, 1])*100)
else:
x_small = x
l, m, h = np.percentile(x_small, norm.cdf([-1, 0, 1])*100)
d = (h-l) * 0.5
return np.sum((x > (m + d*3)) | (x < (m - d*3)))
Expand Down Expand Up @@ -155,9 +156,9 @@ def __init__(self, **kwargs):
if not all(d.get('quantity') for d in self.uniqueness_to_check):
raise ValueError('yaml file error: `quantity` must exist for each item in `uniqueness_to_check`')

if self.catalog_filters:
if not all(d.get('quantity') for d in self.catalog_filters):
raise ValueError('yaml file error: `quantity` must exist for each item in `catalog_filters`')
#if self.catalog_filters:
# if not all(d.get('quantity') for d in self.catalog_filters):
# raise ValueError('yaml file error: `quantity` must exist for each item in `catalog_filters`')

if not all(d.get('min') for d in self.catalog_filters) or all(d.get('max') for d in self.catalog_filters):
raise ValueError('yaml file error: `min` or `max` must exist for each item in `catalog_filters`')
Expand Down Expand Up @@ -266,8 +267,14 @@ def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
catalog_name = catalog_name.partition("_")[0]
version = getattr(catalog_instance, 'version', '') if not self.no_version else ''

filters=[]
for i, filt in enumerate(self.catalog_filters):
filters.append(filt['filters'])
filters = list(chain(*filters))

print(filters)
# check filters
filters = []
"""filters = []
filter_labels = ''
for d in self.catalog_filters:
if rank==0:
Expand All @@ -288,7 +295,7 @@ def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
else:
self.record_result('Found no matching quantity for filtering on {}'.format(fq), failed=True)
continue

"""
lgnd_loc_dflt ='best'


Expand Down
Loading

0 comments on commit f620037

Please sign in to comment.