Ejemplo n.º 1
0
def run_once(cmd_input_file=None, galaxy_input=None, triout=None, rmfiles=False,
             dry_run=False, do_norm=True, do_norm_kw={},
             cols=None, filter1=None, filter2=None, target=None,
             fake_file=None):

    cmd_input_file = do_norm_kw.get('cmd_input_file', cmd_input_file)
    galaxy_input = do_norm_kw.get('galaxy_input', galaxy_input)
    filter1 = do_norm_kw.get('filter1', filter1)
    filter2 = do_norm_kw.get('filter2', filter2)
    target = do_norm_kw.get('target', target)
    fake_file = do_norm_kw.get('fake_file', fake_file)
    ast_corr = do_norm_kw.get('ast_corr', False)
    diag_plot = do_norm_kw.get('diag_plot', False)
    triout =  do_norm_kw.get('triout', triout)

    rsp.trilegal.utils.run_trilegal(cmd_input_file, galaxy_input, triout,
                                    rmfiles=rmfiles, dry_run=dry_run)

    if ast_corr is True and dry_run is False:
        assert fake_file is not None, 'Need fake file for ast corrections'
        logger.info('adding ast corrections to {}'.format(triout))
        sgal = load_trilegal_catalog(triout, filter1, filter2, only_keys=None)
        rsp.ast_correct_starpop(sgal, overwrite=True, outfile=triout,
                                fake_file=fake_file, diag_plot=False)
        do_norm_kw['sgal'] = sgal

    if do_norm:
        do_norm_kw['triout'] = triout
        sgal, norm, inorm, (srgb, sagb), (rgb, agb) = \
            do_normalization(**do_norm_kw)
        if ast_corr:
            filter1 = '%s_cor' % filter1
            filter2 = '%s_cor' % filter2

        result_dict = gather_results(sgal, norm, target, filter1, filter2,
                                     narratio_dict={'rgb': rgb, 'agb': agb,
                                                    'srgb': srgb, 'sagb': sagb,
                                                    'inorm': inorm})
        result_dict['contam_line'] = contamination_by_phases(sgal, srgb, sagb,
                                                             filter2)
        #if diag_plot:
            #model_cmd_withasts(sgal, rgb=rgb, agb=agb, inorm=inorm,
            #                   **do_norm_kw)
            #import pdb; pdb.set_trace()
        return result_dict, ast_corr
Ejemplo n.º 2
0
def prepare_outfiles(inps, inp_extra):
    """
    set up default output file syntax
    """
    # where things are going
    if inps.outfile_loc is None:
        inps.outfile_loc = os.path.split(inps.matchphot)[0]
        assert os.path.isdir(inps.outfile_loc), 'bad output directory'
    else:
        rsp.fileio.ensure_dir(inps.outfile_loc)

    inps.target, inps.filter1, inps.filter2 = rsp.parse_pipeline(inps.matchphot)
    # trilegal sfr filename
    inps.object_sfr_file = os.path.join(inps.outfile_loc,
                                        '{0}{1}.trisfr'.format(inps.target,
                                                               inp_extra))
    # trilegal galaxy input filename
    inps.galaxy_input = os.path.join(inps.outfile_loc,
                                     '{0}{1}.galinp'.format(inps.target,
                                                            inp_extra))
    return inps