Skip to content

Commit 14dbd4f

Browse files
Removed obsolete function from make_catalog_runner (save_galsim_shapes)
1 parent e79b238 commit 14dbd4f

File tree

1 file changed

+0
-114
lines changed

1 file changed

+0
-114
lines changed

shapepipe/modules/make_catalog_runner.py

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -201,66 +201,6 @@ def save_ngmix_data(final_cat_file, ngmix_cat_path):
201201
ngmix_cat_file.close()
202202

203203

204-
def save_galsim_shapes(final_cat_file, galsim_cat_path):
205-
""" Save ngmix data
206-
207-
Save the ngmix catalog into the final one.
208-
209-
Parameters
210-
----------
211-
final_cat_file : io.FITSCatalog
212-
Final catalog.
213-
ngmix_cat_path : str
214-
Path to ngmix catalog to save.
215-
216-
"""
217-
218-
final_cat_file.open()
219-
obj_id = np.copy(final_cat_file.get_data()['NUMBER'])
220-
221-
galsim_cat_file = io.FITSCatalog(galsim_cat_path)
222-
galsim_cat_file.open()
223-
224-
galsim_id = galsim_cat_file.get_data()['id']
225-
226-
keys = galsim_cat_file.get_ext_name()[1:]
227-
output_dict = {'GALSIM_GAL_ELL_{}'.format(i): np.ones((len(obj_id), 2)) * -10. for i in keys}
228-
output_dict = {**output_dict, **{'GALSIM_GAL_ELL_ERR_{}'.format(i): np.ones((len(obj_id), 2)) * -10. for i in keys}}
229-
output_dict = {**output_dict, **{'GALSIM_GAL_ELL_UNCORR_{}'.format(i): np.ones((len(obj_id), 2)) * -10. for i in keys}}
230-
output_dict = {**output_dict, **{'GALSIM_GAL_SIGMA_{}'.format(i): np.zeros(len(obj_id)) for i in keys}}
231-
output_dict = {**output_dict, **{'GALSIM_PSF_ELL_{}'.format(i): np.ones((len(obj_id), 2)) * -10. for i in keys}}
232-
output_dict = {**output_dict, **{'GALSIM_PSF_SIGMA_{}'.format(i): np.zeros(len(obj_id)) for i in keys}}
233-
output_dict = {**output_dict, **{'GALSIM_FLAGS_{}'.format(i): np.ones(len(obj_id), dtype='int16') for i in keys}}
234-
output_dict = {**output_dict, **{'GALSIM_RES_{}'.format(i): np.ones(len(obj_id)) * -1. for i in keys}}
235-
for i, id_tmp in enumerate(obj_id):
236-
ind = np.where(id_tmp == galsim_id)[0]
237-
if len(ind) > 0:
238-
for key in keys:
239-
if key == 'ORIGINAL_PSF':
240-
output_dict['GALSIM_PSF_ELL_{}'.format(key)][i][0] = galsim_cat_file.get_data(key)['gal_uncorr_g1'][ind[0]]
241-
output_dict['GALSIM_PSF_ELL_{}'.format(key)][i][1] = galsim_cat_file.get_data(key)['gal_uncorr_g2'][ind[0]]
242-
output_dict['GALSIM_PSF_SIGMA_{}'.format(key)][i] = galsim_cat_file.get_data(key)['gal_sigma'][ind[0]]
243-
else:
244-
output_dict['GALSIM_GAL_ELL_{}'.format(key)][i][0] = galsim_cat_file.get_data(key)['gal_g1'][ind[0]]
245-
output_dict['GALSIM_GAL_ELL_{}'.format(key)][i][1] = galsim_cat_file.get_data(key)['gal_g2'][ind[0]]
246-
output_dict['GALSIM_GAL_ELL_ERR_{}'.format(key)][i][0] = galsim_cat_file.get_data(key)['gal_g1_err'][ind[0]]
247-
output_dict['GALSIM_GAL_ELL_ERR_{}'.format(key)][i][1] = galsim_cat_file.get_data(key)['gal_g2_err'][ind[0]]
248-
output_dict['GALSIM_GAL_ELL_UNCORR_{}'.format(key)][i][0] = galsim_cat_file.get_data(key)['gal_uncorr_g1'][ind[0]]
249-
output_dict['GALSIM_GAL_ELL_UNCORR_{}'.format(key)][i][1] = galsim_cat_file.get_data(key)['gal_uncorr_g2'][ind[0]]
250-
output_dict['GALSIM_GAL_SIGMA_{}'.format(key)][i] = galsim_cat_file.get_data(key)['gal_sigma'][ind[0]]
251-
output_dict['GALSIM_PSF_ELL_{}'.format(key)][i][0] = galsim_cat_file.get_data(key)['psf_g1'][ind[0]]
252-
output_dict['GALSIM_PSF_ELL_{}'.format(key)][i][1] = galsim_cat_file.get_data(key)['psf_g2'][ind[0]]
253-
output_dict['GALSIM_PSF_SIGMA_{}'.format(key)][i] = galsim_cat_file.get_data(key)['psf_sigma'][ind[0]]
254-
output_dict['GALSIM_FLAGS_{}'.format(key)][i] = galsim_cat_file.get_data(key)['gal_flag'][ind[0]]
255-
output_dict['GALSIM_RES_{}'.format(key)][i] = galsim_cat_file.get_data(key)['gal_resolution'][ind[0]]
256-
257-
for key in output_dict.keys():
258-
final_cat_file.add_col(key, output_dict[key])
259-
260-
final_cat_file.close()
261-
galsim_cat_file.close()
262-
263-
264204
def save_ngmix_mom_shapes(final_cat_file, ngmix_cat_path):
265205
""" Save ngmix data
266206
@@ -329,59 +269,6 @@ def save_ngmix_mom_shapes(final_cat_file, ngmix_cat_path):
329269
ngmix_cat_file.close()
330270

331271

332-
# def save_galsim_shapes(final_cat_file, galsim_cat_path):
333-
# """ Save ngmix data
334-
#
335-
# Save the ngmix catalog into the final one.
336-
#
337-
# Parameters
338-
# ----------
339-
# final_cat_file : io.FITSCatalog
340-
# Final catalog.
341-
# ngmix_cat_path : str
342-
# Path to ngmix catalog to save.
343-
#
344-
# """
345-
#
346-
# final_cat_file.open()
347-
# obj_id = np.copy(final_cat_file.get_data()['NUMBER'])
348-
#
349-
# galsim_cat_file = io.FITSCatalog(galsim_cat_path)
350-
# galsim_cat_file.open()
351-
# galsim_id = galsim_cat_file.get_data()['id']
352-
# # max_epoch = np.max(ngmix_n_epoch)
353-
#
354-
# output_dict = {'GALSIM_GAL_ELL': np.ones((len(obj_id), 2)) * -10.,
355-
# 'GALSIM_GAL_ELL_ERR': np.ones(len(obj_id)) * -1.,
356-
# 'GALSIM_GAL_SIGMA': np.zeros(len(obj_id)),
357-
# 'GALSIM_GAL_FLAG': np.ones(len(obj_id), dtype='int16'),
358-
# 'GALSIM_GAL_ELL_U': np.ones((len(obj_id), 2)) * -10.,
359-
# 'GALSIM_GAL_RES': np.ones(len(obj_id)) * -1.,
360-
# 'GALSIM_PSF_ELL': np.ones((len(obj_id), 2)) * -10.,
361-
# 'GALSIM_PSF_SIGMA': np.zeros(len(obj_id)),
362-
# 'GALSIM_PSF_FLAG': np.ones(len(obj_id), dtype='int16')}
363-
# for i, id_tmp in enumerate(obj_id):
364-
# ind = np.where(id_tmp == galsim_id)[0]
365-
# if len(ind) > 0:
366-
# output_dict['GALSIM_GAL_ELL'][i][0] = galsim_cat_file.get_data()['gal_g1'][ind[0]]
367-
# output_dict['GALSIM_GAL_ELL'][i][1] = galsim_cat_file.get_data()['gal_g2'][ind[0]]
368-
# output_dict['GALSIM_GAL_ELL_ERR'][i] = galsim_cat_file.get_data()['gal_g1_err'][ind[0]]
369-
# output_dict['GALSIM_GAL_SIGMA'][i] = galsim_cat_file.get_data()['gal_sigma'][ind[0]]
370-
# output_dict['GALSIM_GAL_FLAG'][i] = galsim_cat_file.get_data()['gal_flag'][ind[0]]
371-
# output_dict['GALSIM_GAL_RES'][i] = galsim_cat_file.get_data()['gal_resolution'][ind[0]]
372-
# output_dict['GALSIM_GAL_ELL_U'][i][0] = galsim_cat_file.get_data()['gal_uncorr_g1'][ind[0]]
373-
# output_dict['GALSIM_GAL_ELL_U'][i][1] = galsim_cat_file.get_data()['gal_uncorr_g2'][ind[0]]
374-
# output_dict['GALSIM_PSF_ELL'][i][0] = galsim_cat_file.get_data()['psf_g1'][ind[0]]
375-
# output_dict['GALSIM_PSF_ELL'][i][1] = galsim_cat_file.get_data()['psf_g2'][ind[0]]
376-
# output_dict['GALSIM_PSF_SIGMA'][i] = galsim_cat_file.get_data()['psf_sigma'][ind[0]]
377-
#
378-
# for key in output_dict.keys():
379-
# final_cat_file.add_col(key, output_dict[key])
380-
#
381-
# final_cat_file.close()
382-
# galsim_cat_file.close()
383-
384-
385272
def save_psf_data(final_cat_file, galaxy_psf_path, w_log):
386273
""" Save PSF data
387274
@@ -464,7 +351,6 @@ def make_catalog_runner(input_file_list, run_dirs, file_number_string,
464351
save_ngmix_data(final_cat_file, ngmix_cat_path)
465352
elif shape_type.lower() == "galsim":
466353
w_log.info('Save galsim data')
467-
# save_galsim_shapes(final_cat_file, ngmix_cat_path)
468354
save_ngmix_mom_shapes(final_cat_file, ngmix_cat_path)
469355

470356
# w_log.info('Save PSF data')

0 commit comments

Comments
 (0)