Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9e0b4bc
Merge branch 'master' of https://github.com/CosmoStat/shapepipe
tobias-liaudat Jul 19, 2021
e3a3e5c
Update MCCD version
tobias-liaudat Jul 19, 2021
9d8af37
Updating MCCD config files for the new version
tobias-liaudat Jul 19, 2021
17b1395
Adding rejection of objects with zero size that are not flagged
tobias-liaudat Jul 26, 2021
e73573e
Printing MCCD configuration parameters so that the info is saved in l…
tobias-liaudat Jul 27, 2021
e25bfe1
Propagate w_log to auxiliary mccd_fit_pipeline function
tobias-liaudat Jul 27, 2021
e2b191d
Print MCCD config files into the log and not the stdout
tobias-liaudat Jul 27, 2021
f862681
Merge branch 'develop' of https://github.com/CosmoStat/shapepipe
tobias-liaudat Jul 30, 2021
93b69c1
Adding style changes to shapepipe_auxiliary_mccd
tobias-liaudat Jul 30, 2021
8fc77c3
Style changes to mccd_plot_utilities
tobias-liaudat Jul 30, 2021
86ca3ec
Adding style changes to mccd_interpolation_script
tobias-liaudat Jul 30, 2021
bc4776f
Adding style changes to mccd_fit_runner
tobias-liaudat Jul 30, 2021
d173e88
Adding style change to mccd_fit_val_runner
tobias-liaudat Jul 30, 2021
faac965
Adding style changes to mccd_interp_runner
tobias-liaudat Jul 30, 2021
18e9786
Adding style changes to mccd_merge_starcat_runner
tobias-liaudat Jul 30, 2021
699b75b
Adding style changes to mccd_plots_runner
tobias-liaudat Jul 30, 2021
75395f6
Adding style changes to mccd_preprocessing runner
tobias-liaudat Jul 30, 2021
907d931
Adding style changes to mccd_val_runner
tobias-liaudat Jul 30, 2021
7142e2a
Small fixes to styling
tobias-liaudat Jul 30, 2021
5dc9e8a
Updating mccd_package name to lowercase
tobias-liaudat Jul 30, 2021
061ae5e
Modifs for multiple runner configuration. Handling module_config_sec
tobias-liaudat Jul 30, 2021
ae87b77
Changed string to f-string convention
tobias-liaudat Jul 30, 2021
f60bb68
Final styleguide changes to shapepipe_auxiliary_mccd
tobias-liaudat Jul 30, 2021
bceae67
Updated to f-string convention mccd_merge_starcat_runner
tobias-liaudat Jul 30, 2021
359cd1b
Fix indentation
tobias-liaudat Jul 30, 2021
1d50e97
Improved indentation with suggestions
tobias-liaudat Jul 30, 2021
075e4a0
change mccd_package directory name
tobias-liaudat Jul 30, 2021
0e6eb0f
Change to the good name of the directory mccd_package
tobias-liaudat Jul 30, 2021
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
47 changes: 33 additions & 14 deletions shapepipe/modules/mccd_fit_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,32 @@
"""

from shapepipe.modules.module_decorator import module_runner
from shapepipe.modules.MCCD_package import shapepipe_auxiliary_mccd as aux_mccd
from shapepipe.modules.mccd_package import shapepipe_auxiliary_mccd\
as aux_mccd
import mccd


@module_runner(input_module=['mccd_preprocessing_runner'], version='1.0',
file_pattern=['train_star_selection'],
file_ext=['.fits'], numbering_scheme='-0000000',
depends=['numpy', 'mccd', 'galsim'], run_method='parallel')
def mccd_fit_runner(input_file_list, run_dirs, file_number_string,
config, w_log):
@module_runner(
input_module=['mccd_preprocessing_runner'],
version='1.0',
file_pattern=['train_star_selection'],
file_ext=['.fits'],
numbering_scheme='-0000000',
depends=['numpy', 'mccd', 'galsim'],
run_method='parallel'
)
def mccd_fit_runner(
input_file_list,
run_dirs,
file_number_string,
config,
module_config_sec,
w_log
):
# Recover the MCCD config file and its params
config_file_path = config.getexpanded('MCCD', 'CONFIG_PATH')
mccd_mode = config.get('MCCD', 'MODE')
verbose = config.getboolean('MCCD', 'VERBOSE')
config_file_path = config.getexpanded(module_config_sec, 'CONFIG_PATH')
mccd_mode = config.get(module_config_sec, 'MODE')
verbose = config.getboolean(module_config_sec, 'VERBOSE')

# Parse MCCD config file
mccd_parser = mccd.auxiliary_fun.MCCDParamsParser(config_file_path)
Expand All @@ -35,11 +47,18 @@ def mccd_fit_runner(input_file_list, run_dirs, file_number_string,

if mccd_mode == 'FIT':
aux_mccd.mccd_fit_pipeline(
trainstar_path, file_number_string, mccd_parser, output_dir,
verbose, saving_name)
trainstar_path=trainstar_path,
file_number_string=file_number_string,
mccd_parser=mccd_parser,
output_dir=output_dir,
verbose=verbose,
saving_name=saving_name,
w_log=w_log
)

else:
raise ValueError('''mccd_fit_runner should be called when the
MODE is "FIT".''')
raise ValueError(
"mccd_fit_runner should be called when the MODE is 'FIT'."
)

return None, None
44 changes: 30 additions & 14 deletions shapepipe/modules/mccd_fit_val_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,31 @@
"""

from shapepipe.modules.module_decorator import module_runner
from shapepipe.modules.MCCD_package import shapepipe_auxiliary_mccd as aux_mccd
from shapepipe.modules.mccd_package import shapepipe_auxiliary_mccd as aux_mccd
import mccd


@module_runner(input_module=['mccd_preprocessing_runner'], version='1.0',
file_pattern=['train_star_selection', 'test_star_selection'],
file_ext=['.fits', '.fits'], numbering_scheme='-0000000',
depends=['numpy', 'mccd', 'galsim'], run_method='parallel')
def mccd_fit_val_runner(input_file_list, run_dirs, file_number_string,
config, w_log):
@module_runner(
input_module=['mccd_preprocessing_runner'],
version='1.0',
file_pattern=['train_star_selection', 'test_star_selection'],
file_ext=['.fits', '.fits'],
numbering_scheme='-0000000',
depends=['numpy', 'mccd', 'galsim'],
run_method='parallel'
)
def mccd_fit_val_runner(
input_file_list,
run_dirs,
file_number_string,
config,
module_config_sec,
w_log
):
# Recover the MCCD config file and its params
config_file_path = config.getexpanded('MCCD', 'CONFIG_PATH')
mccd_mode = config.get('MCCD', 'MODE')
verbose = config.getboolean('MCCD', 'VERBOSE')
config_file_path = config.getexpanded(module_config_sec, 'CONFIG_PATH')
mccd_mode = config.get(module_config_sec, 'MODE')
verbose = config.getboolean(module_config_sec, 'VERBOSE')

# Parse MCCD config file
mccd_parser = mccd.auxiliary_fun.MCCDParamsParser(config_file_path)
Expand All @@ -45,7 +56,9 @@ def mccd_fit_val_runner(input_file_list, run_dirs, file_number_string,
mccd_parser=mccd_parser,
output_dir=output_dir,
verbose=verbose,
saving_name=fit_saving_name)
saving_name=fit_saving_name,
w_log=w_log
)

# Fitted model is found in the output directory
mccd_model_path = output_dir + fit_saving_name + file_number_string \
Expand All @@ -58,10 +71,13 @@ def mccd_fit_val_runner(input_file_list, run_dirs, file_number_string,
output_dir=output_dir,
file_number_string=file_number_string,
w_log=w_log,
val_saving_name=val_saving_name)
val_saving_name=val_saving_name
)

else:
raise ValueError('''mccd_fit_val_runner should be called when the
MODE is "FIT_VALIDATION".''')
raise ValueError(
"mccd_fit_val_runner should be called when the MODE"
+ " is 'FIT_VALIDATION'."
)

return None, None
112 changes: 71 additions & 41 deletions shapepipe/modules/mccd_interp_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,49 @@
"""

from shapepipe.modules.module_decorator import module_runner
from shapepipe.modules.MCCD_package import mccd_interpolation_script\
from shapepipe.modules.mccd_package import mccd_interpolation_script\
as mccd_interp
from shapepipe.modules.MCCD_package import shapepipe_auxiliary_mccd as aux_mccd
from shapepipe.modules.mccd_package import shapepipe_auxiliary_mccd\
as aux_mccd
import os


@module_runner(input_module=['setools_runner'],
version='1.0',
file_pattern=['galaxy_selection'],
file_ext=['.npy'],
depends=['numpy', 'astropy', 'galsim', 'sqlitedict', 'mccd'],
run_method='parallel')
def mccd_interp_runner(input_file_list, run_dirs, file_number_string,
config, w_log):

mode = config.getexpanded('MCCD_INTERP_RUNNER', 'MODE')
pos_params = config.getlist('MCCD_INTERP_RUNNER', 'POSITION_PARAMS')
get_shapes = config.getboolean('MCCD_INTERP_RUNNER', 'GET_SHAPES')
@module_runner(
input_module=['setools_runner'],
version='1.0',
file_pattern=['galaxy_selection'],
file_ext=['.npy'],
depends=['numpy', 'astropy', 'galsim', 'sqlitedict', 'mccd'],
run_method='parallel'
)
def mccd_interp_runner(
input_file_list,
run_dirs,
file_number_string,
config,
module_config_sec,
w_log
):

mode = config.getexpanded(module_config_sec, 'MODE')
pos_params = config.getlist(module_config_sec, 'POSITION_PARAMS')
get_shapes = config.getboolean(module_config_sec, 'GET_SHAPES')
mccd_model_extension = '.npy'
output_dir = run_dirs['output']

if mode == 'CLASSIC':
psf_model_dir = config.getexpanded('MCCD_INTERP_RUNNER',
'PSF_MODEL_DIR')
psf_model_pattern = config.get('MCCD_INTERP_RUNNER',
'PSF_MODEL_PATTERN')
psf_separator = config.get('MCCD_INTERP_RUNNER',
'PSF_MODEL_SEPARATOR')
psf_model_dir = config.getexpanded(
module_config_sec,
'PSF_MODEL_DIR'
)
psf_model_pattern = config.get(
module_config_sec,
'PSF_MODEL_PATTERN'
)
psf_separator = config.get(
module_config_sec,
'PSF_MODEL_SEPARATOR'
)
# psfcat_path, galcat_path = input_file_list
galcat_path = input_file_list[0]

Expand All @@ -52,8 +67,10 @@ def mccd_interp_runner(input_file_list, run_dirs, file_number_string,

if not os.path.exists(psf_model_path):
error_msg = "The corresponding PSF model was not not found."
w_log.info("Error message: {}.\n On catalog with id: {}.".format(
error_msg, file_number_string))
w_log.info(
f"Error message: {error_msg}.\n On catalog with"
+ f" id: {file_number_string}."
)

return None, None

Expand All @@ -64,37 +81,50 @@ def mccd_interp_runner(input_file_list, run_dirs, file_number_string,
pos_params=pos_params,
ccd_id=int(ccd_id),
saving_path=saving_path,
get_shapes=get_shapes)
get_shapes=get_shapes
)

if output_msg is not None:
w_log.info("Error message: {}.\n On catalog with id: {}.".format(
output_msg, file_number_string))
w_log.info(
f"Error message: {output_msg}.\n On catalog with"
+ f" id: {file_number_string}."
)

elif mode == 'MULTI-EPOCH':
psf_model_dir = config.getexpanded('MCCD_INTERP_RUNNER',
'PSF_MODEL_DIR')
psf_model_pattern = config.get('MCCD_INTERP_RUNNER',
'PSF_MODEL_PATTERN')
f_wcs_path = config.getexpanded('MCCD_INTERP_RUNNER',
'ME_LOG_WCS')
psf_model_dir = config.getexpanded(
module_config_sec,
'PSF_MODEL_DIR'
)
psf_model_pattern = config.get(
module_config_sec,
'PSF_MODEL_PATTERN'
)
f_wcs_path = config.getexpanded(
module_config_sec,
'ME_LOG_WCS'
)

galcat_path = input_file_list[0]

inst = mccd_interp.MCCDinterpolator(None,
galcat_path,
output_dir,
file_number_string,
w_log,
pos_params,
get_shapes)
inst = mccd_interp.MCCDinterpolator(
None,
galcat_path,
output_dir,
file_number_string,
w_log,
pos_params,
get_shapes
)

inst.process_me(psf_model_dir, psf_model_pattern, f_wcs_path)

elif mode == 'VALIDATION':
ValueError('''MODE has to be in MULTI-EPOCH or CLASSIC.
For validation use MCCD validation runner''')
ValueError(
"MODE has to be in MULTI-EPOCH or CLASSIC. For validation"
+ " use MCCD validation runner."
)

else:
ValueError('MODE has to be in : [CLASSIC, MULTI-EPOCH]')
ValueError("MODE has to be in : [CLASSIC, MULTI-EPOCH]")

return None, None
Loading