Пример #1
0
    ##FOR SOME REASON CAN'T DO BOTH OF THESE LINES IN THE SAME FOR LOOP?!?!?!
    for entry in all_info:
        if entry == '': del all_info[all_info.index(entry)]
    for entry in all_info:
        if 'START' in entry: del all_info[all_info.index(entry)]

    matches = chunks[1].split('\n')
    del matches[0], matches[-2:]

    ##Put the information for every source in the matched group in one source_group() class
    ##(see apply_criteria_lib for source_group())
    src_all = mkl.get_allinfo(all_info)

    ##This line applies positional criteria, and tells us if a simple one catalogue repeat source, returning
    ##how many combinations are possible and statistics on them
    repeated_cats, accepted_matches, accepted_inds, accepted_probs, jstats, chi_reds, g_stats = mkl.matches_retained(
        src_all, matches)
    match_crit = "%d of %d \ncombinations \npossible \n%s repeated cats" % (
        len(accepted_matches), len(matches), repeated_cats)

    ##If no combinations are possible, reject all info (goes into the eyeball document)
    if len(accepted_matches) == 0:
        cats = src_all.cats
        repeated_inds = [
            i for i in np.arange(len(cats)) if cats.count(cats[i]) > 1
        ]
        make_rejection(comp, g_stats, 'position', repeated_inds)

    ##If just one combo positionally possible, do a single combo check
    elif len(accepted_matches) == 1:
        single_match_test(src_all, comp, accepted_matches, accepted_inds,
                          g_stats, len(matches), repeated_cats, matches)
Пример #2
0
def make_plots(comp, i):
    ##Get the information into nice usable forms, and get rid of empty/pointless
    ##entries
    chunks = comp.split('START_COMP')
    all_info = chunks[0].split('\n')

    ##FOR SOME REASON CAN'T DO BOTH OF THESE LINES IN THE SAME FOR LOOP?!?!?!
    for entry in all_info:
        if entry == '': del all_info[all_info.index(entry)]
    for entry in all_info:
        if 'START' in entry: del all_info[all_info.index(entry)]

    matches = chunks[1].split('\n')
    del matches[0], matches[-2:]

    ##Put the information for every source in the matched group in one source_group() class
    ##(see apply_criteria_lib for source_group())
    src_all = mkl.get_allinfo(all_info)

    #print src_all.names[0]

    ##This line applies positional criteria, and tells us if a simple one catalogue repeat source, returning
    ##how many combinations are possible and statistics on them
    repeated_cats, accepted_matches, accepted_inds, accepted_probs, jstats, chi_reds, g_stats = mkl.matches_retained(
        src_all, matches)
    match_crit = "%d of %d \ncombinations \npossible \n%s repeated cats" % (
        len(accepted_matches), len(matches), repeated_cats)

    ##If no combinations are possible, reject all info (goes into the eyeball document)
    if len(accepted_matches) == 0:
        i = plot_accept_type(comp, accepted_inds,
                             match_crit, 'Positionally\nimpossible', 'N/A',
                             len(matches), plot_reject, src_all, 'position', i)

    ##If just one combo positionally possible, do a single combo check
    elif len(accepted_matches) == 1:
        i = single_match_test(src_all, comp, accepted_matches, accepted_inds,
                              g_stats, len(matches), repeated_cats, matches, i)
        ##(Any plotting gets done within single_match_test)

    ##If more than one combination is positionally possible:
    else:
        ##Check for a dominant source. The combination must be the only one with high position prob,
        ##all others with low positional proability, and must dominate spectrally
        num_cat = len(set([cat for cat in src_all.cats if cat != '-100000.0']))

        dom_source = mkl.spec_pos_agree(jstats, chi_reds, accepted_probs,
                                        num_cat)
        src_g = mkl.get_srcg(accepted_matches[0])
        ##If it finds a dominant source, accept it - counts as a spectral match
        if dom_source != 'none':
            jstat_resids, params, bses, chi_resids = mkl.calculate_resids(
                [accepted_matches[dom_source]])
            ##Find the probs of all the matches, and use the prob of the dom match to see what number match was accepted
            all_probs = [float(match.split()[-1]) for match in matches]
            accepted_prob = accepted_probs[dom_source]
            dom_num = all_probs.index(accepted_prob)

            i = plot_accept_type(comp, accepted_inds, match_crit,
                                 'Dom source (%d)' % (dom_num + 1),
                                 'Accept dom.\nsource', len(matches),
                                 plot_accept, src_all, 'spectral', i)

        ##If nothing dominates, send to check if a combined source works
        else:
            comb_crit, comb_source, comb_jstat, comb_chi_red = mkl.combine_flux(
                src_all, src_g, accepted_inds, 'plot=no', len(matches))
            ##See whether combined or split
            if 'split' in comb_crit:
                accept_type = 'split'
            else:
                accept_type = 'combine'
            ##Plot the combine or split, based on whether accepted or retained to investigate
            if 'Accepted' in comb_crit:
                i = plot_accept_type(comp, accepted_inds,
                                     match_crit, 'No dom. source', comb_crit,
                                     len(matches), plot_accept, src_all,
                                     accept_type, i)
            else:
                i = plot_accept_type(comp, accepted_inds,
                                     match_crit, 'No dom. source', comb_crit,
                                     len(matches), plot_eyeball, src_all,
                                     accept_type, i)
    return i
Пример #3
0
def make_plots(comp, i):
    ##Get the information into nice usable forms, and get rid of empty/pointless
    ##entries
    chunks = comp.split("START_COMP")
    all_info = chunks[0].split("\n")

    ##FOR SOME REASON CAN'T DO BOTH OF THESE LINES IN THE SAME FOR LOOP?!?!?!
    for entry in all_info:
        if entry == "":
            del all_info[all_info.index(entry)]
    for entry in all_info:
        if "START" in entry:
            del all_info[all_info.index(entry)]

    matches = chunks[1].split("\n")
    del matches[0], matches[-2:]

    ##Put the information for every source in the matched group in one source_group() class
    ##(see apply_criteria_lib for source_group())
    src_all = mkl.get_allinfo(all_info)

    # print src_all.names[0]

    ##This line applies positional criteria, and tells us if a simple one catalogue repeat source, returning
    ##how many combinations are possible and statistics on them
    repeated_cats, accepted_matches, accepted_inds, accepted_probs, jstats, chi_reds, g_stats = mkl.matches_retained(
        src_all, matches
    )
    match_crit = "%d of %d \ncombinations \npossible \n%s repeated cats" % (
        len(accepted_matches),
        len(matches),
        repeated_cats,
    )

    ##If no combinations are possible, reject all info (goes into the eyeball document)
    if len(accepted_matches) == 0:
        i = plot_accept_type(
            comp,
            accepted_inds,
            match_crit,
            "Positionally\nimpossible",
            "N/A",
            len(matches),
            plot_reject,
            src_all,
            "position",
            i,
        )

        ##If just one combo positionally possible, do a single combo check
    elif len(accepted_matches) == 1:
        i = single_match_test(
            src_all, comp, accepted_matches, accepted_inds, g_stats, len(matches), repeated_cats, matches, i
        )
        ##(Any plotting gets done within single_match_test)

        ##If more than one combination is positionally possible:
    else:
        ##Check for a dominant source. The combination must be the only one with high position prob,
        ##all others with low positional proability, and must dominate spectrally
        num_cat = len(set([cat for cat in src_all.cats if cat != "-100000.0"]))

        dom_source = mkl.spec_pos_agree(jstats, chi_reds, accepted_probs, num_cat)
        src_g = mkl.get_srcg(accepted_matches[0])
        ##If it finds a dominant source, accept it - counts as a spectral match
        if dom_source != "none":
            jstat_resids, params, bses, chi_resids = mkl.calculate_resids([accepted_matches[dom_source]])
            ##Find the probs of all the matches, and use the prob of the dom match to see what number match was accepted
            all_probs = [float(match.split()[-1]) for match in matches]
            accepted_prob = accepted_probs[dom_source]
            dom_num = all_probs.index(accepted_prob)

            i = plot_accept_type(
                comp,
                accepted_inds,
                match_crit,
                "Dom source (%d)" % (dom_num + 1),
                "Accept dom.\nsource",
                len(matches),
                plot_accept,
                src_all,
                "spectral",
                i,
            )

            ##If nothing dominates, send to check if a combined source works
        else:
            comb_crit, comb_source, comb_jstat, comb_chi_red = mkl.combine_flux(
                src_all, src_g, accepted_inds, "plot=no", len(matches)
            )
            ##See whether combined or split
            if "split" in comb_crit:
                accept_type = "split"
            else:
                accept_type = "combine"
                ##Plot the combine or split, based on whether accepted or retained to investigate
            if "Accepted" in comb_crit:
                i = plot_accept_type(
                    comp,
                    accepted_inds,
                    match_crit,
                    "No dom. source",
                    comb_crit,
                    len(matches),
                    plot_accept,
                    src_all,
                    accept_type,
                    i,
                )
            else:
                i = plot_accept_type(
                    comp,
                    accepted_inds,
                    match_crit,
                    "No dom. source",
                    comb_crit,
                    len(matches),
                    plot_eyeball,
                    src_all,
                    accept_type,
                    i,
                )
    return i
Пример #4
0
	##FOR SOME REASON CAN'T DO BOTH OF THESE LINES IN THE SAME FOR LOOP?!?!?!
	for entry in all_info:   
		if entry=='': del all_info[all_info.index(entry)]
	for entry in all_info:
		if 'START' in entry: del all_info[all_info.index(entry)]

	matches = chunks[1].split('\n')
	del matches[0],matches[-2:]
	
	##Put the information for every source in the matched group in one source_group() class
	##(see apply_criteria_lib for source_group())
	src_all = mkl.get_allinfo(all_info)
	
	##This line applies positional criteria, and tells us if a simple one catalogue repeat source, returning
	##how many combinations are possible and statistics on them
	repeated_cats,accepted_matches,accepted_inds,accepted_probs,jstats,chi_reds,g_stats = mkl.matches_retained(src_all,matches)
	match_crit = "%d of %d \ncombinations \npossible \n%s repeated cats" %(len(accepted_matches),len(matches),repeated_cats)
	
	##If no combinations are possible, reject all info (goes into the eyeball document)
	if len(accepted_matches)==0:
		cats = src_all.cats
		repeated_inds = [i for i in xrange(len(cats)) if cats.count(cats[i])>1]
		make_rejection(comp,g_stats,'position',repeated_inds)

	##If just one combo positionally possible, do a single combo check
	elif len(accepted_matches)==1:
		single_match_test(src_all,comp,accepted_matches,accepted_inds,g_stats,len(matches),repeated_cats,matches)
		
	##If more than one combination is positionally possible:
	else:
		##Check for a dominant source. The combination must be the only one with high position prob,