@@ -28,7 +28,7 @@ class EllipticityDistribution(BaseValidationTest):
2828 'band_Mag' : ['V' , 'r' , 'g' ],
2929 'zlo' : 0.0 ,
3030 'zhi' : 2.0 ,
31- 'definition' : 'e_squared ' ,
31+ 'definition' : 'e_distortion ' ,
3232 'morphology' : ('LRG' , 'early' , 'disk' , 'late' ),
3333 'filename_template' : 'ellipticity/COSMOS/joachimi_et_al_2013/{}{}_{}.dat' ,
3434 'file-info' : {
@@ -46,22 +46,27 @@ class EllipticityDistribution(BaseValidationTest):
4646 'disk' :{'B/T_min' :0. , 'B/T_max' :0.2 , 'mag_lo' :24. , 'Mag_hi' :- 21. , 'Mag_lo' :- 17. },
4747 'late' :{'B/T_min' :0.4 , 'B/T_max' :0.7 , 'mag_lo' :24. , 'Mag_hi' :- 21. , 'Mag_lo' :- 17. },
4848 'irregular' :{'B/T_min' :0.0 , 'B/T_max' :1.0 },
49- 'ancillary_quantities' :['bulge_to_total_ratio_i' , 'bulge_to_total_ratio_stellar' ],
49+ 'ancillary_quantities' :['bulge_to_total_ratio_i' , 'bulge_to_total_ratio_stellar' ,
50+ 'bulge_to_total_ratio' ],
5051 'ancillary_keys' :['B/T' ],
5152 },
5253 },
5354 }
5455
5556 #define ellipticity functions
5657 @staticmethod
57- def e_default (e ):
58+ def e_shear (e ):
5859 return e
5960
6061 @staticmethod
61- def e_squared (a , b ):
62+ def e_distortion (a , b ):
6263 q = b / a
6364 return (1 - q ** 2 )/ (1 + q ** 2 )
6465
66+ @staticmethod
67+ def e_shear_to_distortion (e ):
68+ return 2 * e / (1 + e ** 2 )
69+
6570 #plotting constants
6671 lw2 = 2
6772 fsize = 16
@@ -86,6 +91,8 @@ def __init__(self, z='redshift_true', zlo=0., zhi=2., N_ebins=40, observation=''
8691 self .yfont_size = kwargs .get ('yfont_size' , 14 )
8792 self .legend_size = kwargs .get ('legend_size' , 6 )
8893 self .legend_title_size = kwargs .get ('legend_title_size' , 8 )
94+ self .catalog_ellipticity_definition = kwargs .get ('ellipticity_definition' , 'e_shear' )
95+ self .convert_to_distortion = kwargs .get ('convert_to_distortion' , False )
8996
9097 possible_mag_fields = ('mag_{}_lsst' ,
9198 'mag_{}_sdss' ,
@@ -103,16 +110,16 @@ def __init__(self, z='redshift_true', zlo=0., zhi=2., N_ebins=40, observation=''
103110 possible_native_luminosities = {'V' :'otherLuminosities/totalLuminositiesStellar:V:rest' ,
104111 }
105112
106- possible_ellipticity_definitions = {'e_default ' :{'possible_quantities' :[['ellipticity' , 'ellipticity_true' ]],
107- 'function' :self .e_default ,
108- 'xaxis_label' : r'$e = (1-q)/(1+q)$' ,
109- 'file_label' :'e ' ,
110- },
111- 'e_squared ' :{'possible_quantities' :[['size' , 'size_true' ], ['size_minor' , 'size_minor_true' ]],
112- 'function' :self .e_squared ,
113- 'xaxis_label' : r'$e = (1-q^2)/(1+q^2)$' ,
114- 'file_label' :'e2 ' ,
115- },
113+ possible_ellipticity_definitions = {'e_shear ' :{'possible_quantities' :[['ellipticity' , 'ellipticity_true' ]],
114+ 'function' :self .e_shear ,
115+ 'xaxis_label' : r'$e = (1-q)/(1+q)$' ,
116+ 'file_label' :'es ' ,
117+ },
118+ 'e_distortion ' :{'possible_quantities' :[['size' , 'size_true' ], ['size_minor' , 'size_minor_true' ]],
119+ 'function' :self .e_distortion ,
120+ 'xaxis_label' : r'$e = (1-q^2)/(1+q^2)$' ,
121+ 'file_label' :'ed ' ,
122+ },
116123 }
117124 #binning
118125 self .N_ebins = N_ebins
@@ -150,10 +157,16 @@ def __init__(self, z='redshift_true', zlo=0., zhi=2., N_ebins=40, observation=''
150157 self .Mag_hi = dict (zip (self .morphology , [self .validation_data .get ('cuts' , {}).get (m , {}).get ('Mag_hi' , Mag_hi ) for m in self .morphology ]))
151158
152159 #check for ellipticity definitions
153- self .possible_quantities = possible_ellipticity_definitions [self .validation_data .get ('definition' , 'e_default' )]['possible_quantities' ]
154- self .ellipticity_function = possible_ellipticity_definitions [self .validation_data .get ('definition' , 'e_default' )].get ('function' )
155- self .xaxis_label = possible_ellipticity_definitions [self .validation_data .get ('definition' , 'e_default' )].get ('xaxis_label' )
156- self .file_label = possible_ellipticity_definitions [self .validation_data .get ('definition' , 'e_default' )].get ('file_label' )
160+ self .possible_quantities = possible_ellipticity_definitions [self .validation_data .get ('definition' , 'e_shear' )]['possible_quantities' ]
161+ self .ellipticity_function = possible_ellipticity_definitions [self .validation_data .get ('definition' , 'e_shear' )].get ('function' )
162+ self .xaxis_label = possible_ellipticity_definitions [self .validation_data .get ('definition' , 'e_shear' )].get ('xaxis_label' )
163+ self .file_label = possible_ellipticity_definitions [self .validation_data .get ('definition' , 'e_shear' )].get ('file_label' )
164+
165+ #check for ellipticity conversions and overwrite previous definitions
166+ if self .convert_to_distortion and self .catalog_ellipticity_definition == 'e_shear' :
167+ self .possible_quantities = possible_ellipticity_definitions [self .catalog_ellipticity_definition ]['possible_quantities' ]
168+ self .ellipticity_function = self .e_shear_to_distortion
169+ print ('Converting from e_shear to e_distortion' )
157170
158171 #check for native quantities
159172 self .native_luminosities = dict (zip ([band for band in possible_native_luminosities if band in self .band_Mag ],\
@@ -235,6 +248,7 @@ def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
235248 required_quantities .append (found_quantity )
236249 if not catalog_instance .has_quantities (required_quantities + self .filter_quantities ):
237250 return TestResult (skipped = True , summary = 'Missing some required quantities: {}' .format (', ' .join (required_quantities )))
251+ print ('Required quantities' , required_quantities )
238252 ancillary_quantity = None
239253 if self .possible_ancillary_quantities is not None :
240254 ancillary_quantity = catalog_instance .first_available (* self .possible_ancillary_quantities )
@@ -262,7 +276,7 @@ def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
262276 fontsize = self .yfont_size ) #setup a common axis label
263277
264278 #initialize arrays for storing histogram sums
265- N_array = np .zeros ((self .nrows , self .ncolumns , len (self .ebins )- 1 ), dtype = np . int )
279+ N_array = np .zeros ((self .nrows , self .ncolumns , len (self .ebins )- 1 ), dtype = int )
266280 sume_array = np .zeros ((self .nrows , self .ncolumns , len (self .ebins )- 1 ))
267281 sume2_array = np .zeros ((self .nrows , self .ncolumns , len (self .ebins )- 1 ))
268282
@@ -477,7 +491,7 @@ def save_quantities(keyname, results, filename, comment=''):
477491 else :
478492 fields = ('e_ave' , keyname )
479493 header = ', ' .join (('Data columns are: <e>' , keyname , ' ' ))
480- np .savetxt (filename , np .vstack (( results [k ] for k in fields ) ).T , fmt = '%12.4e' , header = header + comment )
494+ np .savetxt (filename , np .vstack ([ results [k ] for k in fields ] ).T , fmt = '%12.4e' , header = header + comment )
481495
482496
483497 def conclude_test (self , output_dir ):
0 commit comments