Exemplo n.º 1
0
def main():

    # analyse command line arguments
    file_name, interactive = lib_args.get_args()

    pixels = None
    pixels, header = lib_fits.read_first_image(file_name)

    background, dispersion, mx, hist_sum = lib_background.compute_background(
        pixels, interactive)

    test_gaussian = lib_background.modelling_function(
        np.arange(-10.0, 10.0, 1.0), 1.0, 1.0, 1.0).sum()

    print('RESULT: test_gaussian = {:3f}'.format(test_gaussian))
    signature_hist = 'RESULT: histogram = {:5d}'.format(hist_sum)
    print(signature_hist)
    print('RESULT: background = {:d}'.format(int(background)))
    print('RESULT: dispersion = {:d}'.format(int(dispersion)))

    # graphic output
    if interactive:
        # ...
        pass

    # end
    return 0
Exemplo n.º 2
0
def main():

    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)
    background, dispersion, _ = lib_background.compute_background(pixels)

    # search for clusters
    time0 = time.time()
    clustering = ParallelClustering()
    clusters = clustering(pixels, background, dispersion)
    time1 = time.time()
    max_cluster = clusters[0]

    # console output
    print(
        'number of clusters: {:2d}, greatest integral: {:7d}, x: {:4.1f}, y: {:4.1f}'
        .format(len(clusters), max_cluster.integral, max_cluster.column,
                max_cluster.row))
    print('clustering execution time: {:.3f} seconds'.format(time1 - time0))

    # graphic output
    if interactive:
        _, axis = plt.subplots()
        axis.imshow(lib_cluster.add_crosses(pixels, clusters))
        plt.show()

    return 0
Exemplo n.º 3
0
def main():

    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)
    background, dispersion, max_x = lib_background.compute_background(pixels)

    # console output
    print('background: {:d}, dispersion: {:d}'.format(int(background),int(dispersion)))

    # graphic output
    if interactive:

        fig, axis = plt.subplots()
        imgplot = axis.imshow(pixels)

        ax_thresh = plt.axes([0.25, 0.92, 0.65, 0.03])
        s_thresh = widgets.Slider(ax_thresh, 'Threshold', 0.0, max_x, valinit=background)

        update_slider = UpdateSlider(pixels,imgplot,fig)
        s_thresh.on_changed(update_slider)
        update_slider(background)

        plt.show()

    return 0
Exemplo n.º 4
0
def main():

    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)
    background, dispersion, max_x = lib_background.compute_background(pixels)
    clustering = lib_cluster.Clustering()
    clusters = clustering(pixels, background, dispersion)

    # console output
    if not interactive:

        print('{} clusters'.format(len(clusters)))

    else:
        # graphic output

        fig, axis = plt.subplots()
        imgplot = axis.imshow(pixels)

        axcolor = 'lightgoldenrodyellow'
        ax_thresh = plt.axes([0.25, 0.92, 0.65, 0.03], axisbg=axcolor)

        threshold = 6.0
        slider = widgets.Slider(ax_thresh, 'Threshold', 0.0, 5*threshold, valinit=threshold)

        update_slider = UpdateSlider(pixels, background, dispersion, imgplot, fig)
        slider.on_changed(update_slider)
        update_slider(threshold)

        plt.show()

    return 0
Exemplo n.º 5
0
def main():

    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)
    background, dispersion, _ = lib_background.compute_background(pixels)
    clustering = lib_cluster.Clustering()
    clusters = clustering(pixels, background, dispersion)
    max_cluster = clusters[0]

    # coordinates ra dec
    wcs = lib_wcs.get_wcs(header)

    for i, c in enumerate(clusters):
        show_cluster(wcs, i, c)

    # graphic output
    if interactive:
        import matplotlib.pyplot as plt
        import lib_graphics

        fig, axis = plt.subplots()
        axis.imshow(pixels, interpolation='none')
        fig.canvas.mpl_connect('motion_notify_event',
            lib_graphics.ShowClusterProperties(fig,clusters,ShowCelestialObjects(wcs)))
        plt.show()

    return 0
Exemplo n.º 6
0
def main():

    # analyse command line arguments

    file_name, interactive = lib_args.get_args()

    pixels = None
    pixels, header = lib_fits.read_first_image(file_name)

    signature_fmt_1 = 'RESULT: cd1_1 = {:.10f}'.format(header["CD1_1"])
    signature_fmt_2 = 'RESULT: cd1_2 = {:.10f}'.format(header["CD1_2"])
    signature_fmt_3 = 'RESULT: cd2_1 = {:.10f}'.format(header["CD2_1"])
    signature_fmt_4 = 'RESULT: cd2_2 = {:.10f}'.format(header["CD2_2"])

    print(signature_fmt_1)
    print(signature_fmt_2)
    print(signature_fmt_3)
    print(signature_fmt_4)


    if interactive:
        fig, main_axes = plt.subplots()
        main_axes.imshow(pixels)
        plt.show()

    return 0
def main():

    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)
    background, dispersion, _ = lib_background.compute_background(pixels)

    # search for clusters
    clustering = RecursiveClustering()
    clusters = clustering(pixels, background, dispersion)
    max_cluster = clusters[0]
    wcs = lib_wcs.get_wcs(header)
    pxy = lib_wcs.PixelXY(max_cluster.column, max_cluster.row)
    radec = lib_wcs.xy_to_radec(wcs, pxy)
    cobjects, _, _ = lib_stars.get_celestial_objects(radec)

    # console output
    print(
        'number of clusters: {:2d}, greatest integral: {:7d}, x: {:4.1f}, y: {:4.1f}'
        .format(len(clusters), max_cluster.integral, max_cluster.column,
                max_cluster.row))
    for cobj in cobjects.keys():
        print('celestial object: {}'.format(cobj))

    # graphic output
    if interactive:
        _, axis = plt.subplots()
        axis.imshow(lib_cluster.add_crosses(pixels, clusters))
        plt.show()

    return 0
Exemplo n.º 8
0
def main():

    # analyse command line arguments

    file_name, interactive = lib_args.get_args()

    data = None
    data, header = lib_fits.read_first_image(file_name)
    data = data[400:600, 300:500]
    done = np.zeros(data.shape)

    background, dispersion, mx, hist_sum = lib_background.compute_background(
        data, False)
    threshold = 2 * background + 6. * dispersion
    #threshold=11000
    cluster_pix_list = []
    for i in range(data.shape[0]):
        for j in range(data.shape[1]):
            if not done[i][j]:
                done[i][j] = 1
                if data[i][j] > threshold:
                    cluster_pixels = lib_pixels_set.PixelsSet()
                    cluster_pixels.add(i, j, data[i][j])
                    recursive_search(i, j, data, done, cluster_pixels,
                                     threshold)
                    if cluster_pixels.get_len() > 1:
                        cluster_pix_list.append(cluster_pixels)

    print([str(cluster) for cluster in cluster_pix_list])

    if interactive:
        fig, main_axes = plt.subplots()
        main_axes.imshow(data)
        for cluster in cluster_pix_list:
            peak = cluster.get_peak()
            plt.scatter([peak[1]], [peak[0]])

        fig, main_axes = plt.subplots()
        main_axes.imshow(data)
        for cluster in cluster_pix_list:
            for pixel in cluster.pixels:
                plt.plot(pixel[1], pixel[0], 'rs', alpha=0.05)

        fig, main_axes = plt.subplots()
        main_axes.imshow(data)
        matrix = np.zeros(data.shape)
        for cluster in cluster_pix_list:
            for pixel in cluster.pixels:
                matrix[pixel[0], pixel[1]] = 1
        plt.contour(matrix)

        plt.show()

    return 0
Exemplo n.º 9
0
def main():

    # analyse command line arguments
    file_name, interactive = lib_args.get_args()
    logging.info('----------------')
    logging.info('name of file: {}'.format(file_name))

    # read fits file
    header, pixels = lib_fits.read_first_image(file_name)
    logging.info('cd1_1: {CD1_1:.10f}'.format(**header))
    logging.info('cd1_2: {CD1_2:.10f}'.format(**header))
    logging.info('cd2_1: {CD2_1:.10f}'.format(**header))
    logging.info('cd2_2: {CD2_2:.10f}'.format(**header))

    # compute background
    background, dispersion, _ = lib_background.compute_background(pixels)
    logging.info('background: {:d}'.format(int(background)))
    logging.info('dispersion: {:d}'.format(int(dispersion)))

    # clustering
    clustering = lib_cluster.Clustering()
    clusters = clustering(pixels, background, dispersion)
    for icl, cl in enumerate(clusters):

        logging.info('----------------')
        logging.info('cluster {:d}: {}'.format(icl, cl))

        # radec coordinates of the greatest cluster
        wcs = lib_wcs.get_wcs(header)
        pxy = lib_wcs.PixelXY(cl.column, cl.row)
        radec = lib_wcs.xy_to_radec(wcs, pxy)
        logging.info('right ascension: {:.3f}'.format(radec.ra))
        logging.info('declination: {:.3f}'.format(radec.dec))

        # celestial objects for the biggest cluster
        cobjects, _, _ = get_celestial_objects(wcs, cl)
        for icobj, cobj in enumerate(cobjects.keys()):
            logging.info('celestial object {}: {}'.format(icobj, cobj))

    # graphic output
    if interactive:
        fig, axis = plt.subplots()
        axis.imshow(pixels, interpolation='none')
        fig.canvas.mpl_connect(
            'motion_notify_event',
            lib_graphics.ShowClusterProperties(fig, clusters,
                                               ShowCelestialObjects(wcs)))
        plt.show()

    logging.info('----------------')
    return 0
Exemplo n.º 10
0
def main():

    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)
    background, dispersion, _ = lib_background.compute_background(pixels)
    clustering = lib_cluster.Clustering()
    clusters = clustering(pixels, background, dispersion)
    max_cluster = clusters[0]

    # coordinates ra dec
    wcs = lib_wcs.get_wcs(header)

    for i, c in enumerate(clusters):
        show_cluster(wcs, i, c)
        break

    return 0
Exemplo n.º 11
0
def main():
    '''
    Main function of the program
    '''

    global reg

    # process command-line options
    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)

    logging.debug('cd1_1: %s, cd1_2: %s, cd2_1: %s, cd2_2: %s',
                  header['CD1_1'], header['CD1_2'], header['CD2_1'],
                  header['CD2_2'])
    logging.debug('height: %s, width: %s', pixels.shape[0], pixels.shape[1])

    # compute background
    background, dispersion, _ = lib_background.compute_background(pixels)
    logging.debug('background: %s, dispersion: %s', int(background),
                  int(dispersion))

    print('---------------------')
    # search for clusters in a sub-region of the image
    threshold = 6.0

    # graphic output
    if interactive:
        image = pixels

        reg = lib_cluster_thr.RegionThr(image,
                                        background + threshold * dispersion)
        reg.run_threaded()

        max_integral = reg.clusters[0].integral
        logging.info(
            'number of clusters: %2d, greatest integral: %7d, centroid x: %4.1f, centroid y: %4.1f',
            len(reg.clusters), max_integral, reg.clusters[0].centroid[1],
            reg.clusters[0].centroid[0])

        plt.show()

    return 0
Exemplo n.º 12
0
def main():

    # analyse command line arguments
    file_name, interactive = lib_args.get_args()

    # main tasks
    # ...

    # example of console output
    # ...
    print('RESULT: file = {}'.format(file_name))
    print('RESULT: interactive = {}'.format(interactive))

    # graphic output
    if interactive:
        # ...
        pass

    # end
    return 0
Exemplo n.º 13
0
def main():

    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)

    # console output
    print('RESULT: cd1_1 = {CD1_1:.10f}'.format(**header))
    print('RESULT: cd1_2 = {CD1_2:.10f}'.format(**header))
    print('RESULT: cd2_1 = {CD2_1:.10f}'.format(**header))
    print('RESULT: cd2_2 = {CD2_2:.10f}'.format(**header))

    # graphic output
    if interactive:
        import matplotlib.pyplot as plt

        _, axis = plt.subplots()
        plt.text(0, -10, file_name, fontsize=14, color='white')
        axis.imshow(pixels)
        plt.show()

    return 0
Exemplo n.º 14
0
def main():

    file_name, interactive = lib_args.get_args()

    # importing image
    pixels = None
    pixels, header = lib_fits.read_first_image(file_name)
    my_wcs = lib_wcs.get_wcs(header)
    clusters = ex3_clusters.find_clusters(pixels, False)

    for j in range(len(clusters)):
        peak_pixel = lib_wcs.PixelXY(clusters[j].y, clusters[j].x)
        cel_coord = lib_wcs.xy_to_radec(my_wcs, peak_pixel)
        acc_radius = 0.001
        celestial_objects, out, req = lib_stars.get_celestial_objects(
            cel_coord, acc_radius)

        signature_fmt_1 = 'RESULT: right_ascension_{:d} = {:.3f}'.format(
            j, cel_coord[0])
        signature_fmt_2 = 'RESULT: declination_{:d} = {:.3f}'.format(
            j, cel_coord[1])
        print(signature_fmt_1)
        print(signature_fmt_2)
        for i, key in enumerate(celestial_objects.keys()):
            signature_fmt_3 = 'RESULT: celestial_object_{:d}_{:d} = {}'.format(
                j, i, key)
            print(signature_fmt_3)

    # graphic output
    if interactive:
        fig, main_axes = plt.subplots()
        handler = Handler(fig, main_axes, my_wcs)
        main_axes.imshow(pixels)
        #fig.canvas.mpl_connect('motion_notify_event', handler.move)
        fig.canvas.mpl_connect('button_press_event', handler.on_click)

        plt.show()

    # end
    return 0
Exemplo n.º 15
0
def main():

    # analyse command line arguments

    file_name, interactive = lib_args.get_args()

    # importing image
    pixels = None
    pixels, header = lib_fits.read_first_image(file_name)
    my_wcs = lib_wcs.get_wcs(header)

    sorted_clusters = ex3_clusters.find_clusters(pixels, False)

    peak_pixel = lib_wcs.PixelXY(sorted_clusters[0].y, sorted_clusters[0].x)
    cel_coord = lib_wcs.xy_to_radec(my_wcs, peak_pixel)
    acc_radius = 0.001
    celestial_objects, out, req = lib_stars.get_celestial_objects(
        cel_coord, acc_radius)

    signature_fmt_1 = 'RESULT: right_ascension = {:.3f}'.format(cel_coord[0])
    signature_fmt_2 = 'RESULT: declination = {:.3f}'.format(cel_coord[1])
    print(signature_fmt_1)
    print(signature_fmt_2)
    i = 0
    for key in celestial_objects.keys():
        signature_fmt_3 = 'RESULT: celestial_object_{:d} = {}'.format(i, key)
        print(signature_fmt_3)
        i += 1

    # graphic output
    if interactive:
        # ...
        pass

    # end
    return 0
Exemplo n.º 16
0
def main():

    dirpath, interactive = lib_args.get_args()
    filepaths = scan_dir(dirpath)

    # batch console output
    if not interactive:

        for filepath in filepaths:
            print(filepath)

    # graphic interaction
    else:

        fig, img_axis = plt.subplots(figsize=(10, 5))
        plt.subplots_adjust(left=0.05, right=0.45, bottom=0.1, top=0.9)
        buttons_axis = plt.axes([0.55, 0.1, 0.4, 0.8])
        buttons = widgets.RadioButtons(buttons_axis, filepaths)
        callback = UpdateFile(img_axis, fig)
        buttons.on_clicked(callback)
        callback(filepaths[0])
        plt.show()

    return 0
Exemplo n.º 17
0
def main():

    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)

    z = lib_model.gaussian_model(np.arange(-10.0, 10.0, 1.0), 1.0, 1.0, 1.0)
    print('RESULT: test_gaussian = {:3f}'.format(np.sum(z)))

    y, x = lib_background.build_pixel_histogram(pixels, 200)
    print('RESULT: histogram = {:5d}'.format(np.sum(y)))

    background, dispersion, mx, y, x = lib_background.compute_background_from_histogram((y, x))

    # console output
    print('RESULT: background = {:d}'.format(int(background)))
    print('RESULT: dispersion = {:d}'.format(int(dispersion)))

    # graphic output
    if interactive:
        import matplotlib.pyplot as plt

        _, axis = plt.subplots()
        # axis.imshow(pixels)

        z = lib_model.gaussian_model(x, 1.0, background/mx, dispersion/mx)

        plt.plot(x, y, 'b+:', label='data')
        plt.plot(x, z, 'r.:', label='fit')
        plt.legend()
        plt.title('Flux distribution')
        plt.xlabel('Amplitude')
        plt.ylabel('Frequence')

        plt.show()

    return 0
Exemplo n.º 18
0
def main():
    '''
    Main function of the program
    '''

    global reg
    global strategy
    global in_cluster
    global in_scanning

    # process command-line options
    file_name, interactive = lib_args.get_args()
    header, pixels = lib_fits.read_first_image(file_name)

    logging.debug('cd1_1: %s, cd1_2: %s, cd2_1: %s, cd2_2: %s',
                  header['CD1_1'], header['CD1_2'], header['CD2_1'],
                  header['CD2_2'])
    logging.debug('height: %s, width: %s', pixels.shape[0], pixels.shape[1])

    # compute background
    background, dispersion, _ = lib_background.compute_background(pixels)
    logging.debug('background: %s, dispersion: %s', int(background),
                  int(dispersion))

    print('---------------------')
    # search for clusters in a sub-region of the image
    threshold = 6.0

    # graphic output
    if interactive:

        # cluster central
        image = pixels[45:70, 40:65]

        reg = lib_cluster.Region(image, background + threshold * dispersion)

        strategy = '4centers'
        in_cluster = 1.0
        in_scanning = 0.1

        def select_strategy(value):
            global strategy
            print(('select strategy=', value))
            strategy = value

        def select_in_cluster(value):
            global in_cluster
            in_cluster = value

        def select_in_scanning(value):
            global in_scanning
            in_scanning = value

        def start_animate(value):
            print(('animate with strategy=', strategy))
            reg.animate(in_cluster=in_cluster,
                        in_scanning=in_scanning,
                        strategy=strategy)

        strategies = ['random', 'all', 'center', '4centers']
        axis_strategy = plt.axes([0.2, 0.8, 0.15, 0.15])
        axis_strategy.set_title('Scanning strategy')
        strategy_widget = RadioButtons(axis_strategy, strategies)
        strategy_widget.set_active(strategies.index(strategy))
        strategy_widget.on_clicked(select_strategy)

        axis_in_cluster = plt.axes([0.2, 0.7, 0.65, 0.03])
        in_cluster_widget = Slider(axis_in_cluster,
                                   'wait in clusters',
                                   0.0,
                                   5.0,
                                   valinit=in_cluster)
        in_cluster_widget.on_changed(select_in_cluster)

        axis_in_scanning = plt.axes([0.2, 0.6, 0.65, 0.03])
        in_scanning_widget = Slider(axis_in_scanning,
                                    'wait in scanning',
                                    0.0,
                                    1.0,
                                    valinit=in_scanning)
        in_scanning_widget.on_changed(select_in_scanning)

        axis_animate = plt.axes([0.2, 0.5, 0.1, 0.03])
        in_animate = Button(axis_animate, 'Animate')
        in_animate.on_clicked(start_animate)

        plt.show()

    return 0
Exemplo n.º 19
0
def main():

    # analyse command line arguments
    file_name, interactive = lib_args.get_args()

    # importing image
    pixels = None
    pixels, header = lib_fits.read_first_image(file_name)

    pattern = lib_cluster.build_pattern(interactive)

    background, dispersion, mx, hist_sum = lib_background.compute_background(
        pixels, interactive)
    threshold = background + 6. * dispersion

    extended_image = lib_cluster.extend(pixels, interactive, 0, 4)
    convolved_image = lib_cluster.convolve(extended_image, pattern)
    extended_convolved_image = lib_cluster.extend(convolved_image, interactive,
                                                  0, 1)

    max_mask = lib_cluster.has_peak(convolved_image, interactive, threshold)
    peak_list = lib_cluster.get_peaks_from_mask(max_mask)
    clusters = lib_cluster.get_clusters(peak_list, pixels, threshold)
    sorted_clusters = sorted(clusters, key=lambda cluster: -cluster.int_lumi)

    print('RESULT: pattern_sum = {:5.0f}'.format(pattern.sum().sum()))

    print('RESULT: extended_image_width = {:2d}'.format(
        extended_image.shape[0]))
    print('RESULT: extended_image_height = {:2d}'.format(
        extended_image.shape[1]))
    print('RESULT: extended_image_sum = {:5.0f}'.format(
        extended_image.sum().sum()))

    print('RESULT: convolution_image_width = {:2d}'.format(
        convolved_image.shape[0]))
    print('RESULT: convolution_image_height = {:2d}'.format(
        convolved_image.shape[1]))
    print('RESULT: convolution_image_sum = {:5.0f}'.format(
        convolved_image.sum().sum()))

    print('RESULT: extended_convolution_image_width = {:2d}'.format(
        extended_convolved_image.shape[0]))
    print('RESULT: extended_convolution_image_height = {:2d}'.format(
        extended_convolved_image.shape[1]))
    print('RESULT: extended_convolution_image_sum = {:5.0f}'.format(
        extended_convolved_image.sum().sum()))

    print('RESULT: peaks_number={:2d}'.format(max_mask.sum().sum()))

    print('RESULT: clusters_number={:2d}'.format(len(sorted_clusters)))
    print('RESULT: cluster_max_top={:5d}'.format(
        int(sorted_clusters[0].peak_lumi)))

    print('RESULT: cluster_max_integral={:5d}'.format(
        int(sorted_clusters[0].int_lumi)))
    print('RESULT: cluster_max_column={:5d}'.format(int(sorted_clusters[0].y)))
    print('RESULT: cluster_max_row={:5d}'.format(int(sorted_clusters[0].x)))

    # graphic output
    if interactive:
        fig, main_axes = plt.subplots()
        main_axes.imshow(convolved_image)
        #plt.show()

    # end
    return 0
Exemplo n.º 20
0
def main():

    file_name, interactive = lib_args.get_args()
    #print(file_name)
    header, pixels = lib_fits.read_first_image(file_name)
    background, dispersion, _ = lib_background.compute_background(pixels)

    # search for clusters
    clustering = lib_cluster.Clustering()
    #   clusters = clustering(pixels, background, dispersion)

    pattern = clustering.step_build_pattern()

    print('RESULT: pattern_sum = {:5.0f}'.format(np.sum(pattern)))

    ext_image = clustering.step_extend_image(pixels)

    print('RESULT: extended_image_width = {:2d}'.format(ext_image.shape[1]))
    print('RESULT: extended_image_height = {:2d}'.format(ext_image.shape[0]))
    print('RESULT: extended_image_sum = {:5.0f}'.format(np.sum(ext_image)))

    cp_image = clustering.step_build_convolution_image(ext_image)

    print('RESULT: convolution_image_width = {:2d}'.format(cp_image.shape[1]))
    print('RESULT: convolution_image_height = {:2d}'.format(cp_image.shape[0]))
    print('RESULT: convolution_image_sum = {:5.0f}'.format(np.sum(cp_image)))

    ext_cp_image = clustering.step_extend_convolution_image(cp_image)

    print('RESULT: extended_convolution_image_width = {:2d}'.format(ext_cp_image.shape[1]))
    print('RESULT: extended_convolution_image_height = {:2d}'.format(ext_cp_image.shape[0]))
    print('RESULT: extended_convolution_image_sum = {:5.0f}'.format(np.sum(ext_cp_image)))

    peaks = clustering.step_detect_peaks(pixels, cp_image, ext_cp_image, background, dispersion)

    print('RESULT: peaks_number = {:2d}'.format(len(peaks)))

    #for npeak, peak in enumerate(peaks):
    #    print('peak[{}]: {}'.format(npeak, peak))
    clusters = clustering.step_build_clusters(pixels, peaks, background, dispersion)

    print('RESULT: clusters_number = {:2d}'.format(len(clusters)))

    clusters, max_top = clustering.step_sort_clusters(clusters)

    print('RESULT: cluster_max_top = {:5d}'.format(max_top))

    max_cluster = clusters[0]

    # console output
    print('RESULT: cluster_max_integral = {:5d}'.format(max_cluster.integral))
    print('RESULT: cluster_max_column = {:5d}'.format(max_cluster.column))
    print('RESULT: cluster_max_row = {:5d}'.format(max_cluster.row))

    # graphic output
    if interactive:
        import matplotlib.pyplot as plt

        _, axes = plt.subplots(2)
        _ = axes[0].imshow(clustering._build_pattern())
        _ = axes[1].imshow(lib_cluster.add_crosses(pixels,clusters))
        plt.show()

    return 0
Exemplo n.º 21
0
# -*- coding: utf-8 -*-


import sys
sys.path.append('../skeletons')
sys.path.append('../solutions')
import lib_args
import lib_fits
import lib_background
import lib_cluster
import lib_wcs
import lib_stars


# prepare clusters
file_name, interactive = lib_args.get_args()
header, pixels = lib_fits.read_first_image(file_name)
print('image shape is {}'.format(pixels.shape))
background, dispersion, _ = lib_background.compute_background(pixels)
pattern_radius = 4
clustering = lib_cluster.Clustering(pattern_radius)
clusters = clustering(pixels, background, dispersion)
nb_patho = 0
nb_symptom = 0

# print clusters details
for icl, cl in enumerate(clusters):
    print('cluster {:d}: {}'.format(icl, cl))

# check no cluster
if len(clusters) == 0: