In [1]:
from matplotlib_venn import venn2
import matplotlib.pyplot as plt
from astropy.table import Table
import numpy as np
import os

def venn_plot(results,maxdiff,gaiamag,plots):
    mask = np.logical_and(
                np.logical_and(results['gaiamag'] > gaiamag - 0.1,results['gaiamag'] < gaiamag + 0.1),
                np.logical_and(results['maxdiff'] > maxdiff - 0.1,results['maxdiff'] < maxdiff + 0.1)
    )
    plottab = results[mask]
    rowdic = dict()
    for i in range(len(plottab)):
        row = plottab[i]
        rowdic[row['data-source']] = row
    row = plottab[0]

    					

    plt.suptitle(f"Crossmatch GAIA mag={gaiamag} Pixel dist={maxdiff}", y=1.05, fontsize=14)
    plt.title(f"{row['observatory']} {row['datenite']} {row['object']} {row['filter']} {row['exptime']:.1f}s {row['filename']}", fontsize=12)

    gnbr =rowdic['_gaia']['nbr-sources']
    if 'sextractor' in plots:
        plt.subplot(1, 2, 1)
        matched_dup = rowdic['sextractor']['matched-gaia']+rowdic['sextractor']['dup-matched']
        matched = rowdic['sextractor']['matched-gaia']
        snbr =rowdic['sextractor']['nbr-sources']
        vd = venn2(subsets = (gnbr-matched,snbr-matched_dup,matched), set_labels = ('GAIA', 'SEXTRACTOR', 'Matched'))
        vd.get_label_by_id("10").set_y(.1)
        vd.get_label_by_id("01").set_y(-.1)
    if 'fortran' in plots:
        plt.subplot(1, 2, 2)
        matched_dup = rowdic['fortran']['matched-gaia']+rowdic['fortran']['dup-matched']
        matched = rowdic['fortran']['matched-gaia']
        snbr =rowdic['fortran']['nbr-sources']
        vd = venn2(subsets = (gnbr-matched,snbr-matched_dup,matched), set_labels = ('GAIA', 'FORTRAN', 'Matched'))
        vd.get_label_by_id("10").set_y(.1)
        vd.get_label_by_id("01").set_y(-.1)


    plt.show()


image_file = os.environ['RFILE']
image_file.replace("\\","/")
result_file = image_file + "_results.ecsv"
print(f"report file: {result_file}")
results = Table.read(result_file)

pdistances = (results.group_by('maxdiff')).groups.keys['maxdiff'].data
gmags = (results.group_by('gaiamag')).groups.keys['gaiamag'].data
datasrcs = (results.group_by('data-source')).groups.keys['data-source'].data
n = (len(gmags) // 2)  # we want the index of the middle gaia magnitude
gaiamag = gmags[n]
n = (len(pdistances) // 2) # we want the index of the middle pixel distance
pdistance = pdistances[n]
plots = list()
for src in datasrcs:
    if src != '_gaia':
        plots.append(src)

for maxdiff in pdistances:
    venn_plot(results,maxdiff,gaiamag,plots)


for gaiamag in gmags:
    venn_plot(results,pdistance,gaiamag,plots)
report file: c:\users\clkot\docs\AAVSONet\photometry\test_seg_01\bsm_tx\231107\231107.0101.bz2_results.ecsv
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image