def __init__(self, input_catalog):
        """

        @param input_catalog:
        """
        self.input_catalogue = input_catalog
        self.prfs_d = extract_settings_luca()
Example #2
0
    def __init__(self):
        """

        """
        self.filter_p_number = 9
        self.prfs_d = extract_settings_luca()

        self.scmp_cf = '10_1.1_0.5_0.04'
        self.sex_cf = '30_1.5_1.5_0.01_4'
        self.fig_size = [16.53, 11.69]
        self.dpi = 100

        self.save = True
        self.tmp_d = redo_tmp_d()

        i_mag_l = []
        i_pm_l = []
        n_se_l = []
        n_false_l = []
        n_true_l = []
        n_meas_l = []
        f_pur_l = []
        f_dr_l = []
        f_com_l = []

        for mag_ in self.prfs_d['mags']:
            self.mag = mag_
            stats_d = self.check_pm_distribution()

            for pm_ in self.prfs_d['pms']:
                i_mag_l.append(self.mag)
                i_pm_l.append(pm_)
                n_se_l.append(stats_d[mag_][pm_]['n_se'])
                n_false_l.append(stats_d[mag_][pm_]['n_false'])
                n_true_l.append(stats_d[mag_][pm_]['n_true'])
                n_meas_l.append(stats_d[mag_][pm_]['n_meas'])
                f_pur_l.append(stats_d[mag_][pm_]['f_pur'])
                f_dr_l.append(stats_d[mag_][pm_]['f_pur'])
                f_com_l.append(stats_d[mag_][pm_]['f_com'])

        i_mag_s = Series(i_mag_l, name='mag_bin')
        i_pm_s = Series(i_pm_l, name='i_pm')
        n_se_s = Series(n_se_l, name='n_se')
        n_false_s = Series(n_false_l, name='n_false')
        n_true_s = Series(n_true_l, name='n_true')
        n_meas_s = Series(n_meas_l, name='n_meas')
        f_dr_s = Series(f_dr_l, name='f_dr')
        f_pur_s = Series(f_pur_l, name='f_pur')
        f_com_s = Series(f_com_l, name='f_com')

        self.out_df = concat([
            i_mag_s, i_pm_s, n_se_s, n_false_s, n_true_s, n_meas_s, f_dr_s,
            f_pur_s, f_com_s
        ],
                             axis=1)
        self.out_df.to_csv('total.csv')

        self.plot()
    def __init__(self):
        """

        """
        self.bypassfilter = True
        self.plot = False
        self.prfs_d = extract_settings_luca()

        pass
Example #4
0
def compute_factors(stats_d, tmp_d):
    """
    N_meas: number of all detected sources(including false detections)
    N_se: number of simulated sources recovered by source extraction
    N_true: number of simulated input sources
    f_dr: detection rate f_pur: purity
    f_com: completeness

    f_dr = N_meas / N_true = (N_se + N_false) / N_true
    f_pur = N_se / N_meas = N_se / (N_se + N_false)
    f_com = f_dr * f_pur = N_se / N_true

    :param stats_d:
    :param tmp_d:
    :return:
    """
    prfs_d = extract_settings_luca()

    for mag_ in prfs_d['mags']:
        for pm_ in prfs_d['pms']:
            n_meas = tmp_d[mag_][pm_]['right'] + tmp_d[mag_][pm_]['false']
            # stats_d[mag_][pm_]['n_meas'].append(n_meas)
            stats_d[mag_][pm_]['n_meas'] = n_meas
            n_false = tmp_d[mag_][pm_]['false']
            # stats_d[mag_][pm_]['n_false'].append(n_false)
            stats_d[mag_][pm_]['n_false'] = n_false
            n_se = tmp_d[mag_][pm_]['right']
            # stats_d[mag_][pm_]['n_se'].append(n_se)
            stats_d[mag_][pm_]['n_se'] = n_se
            n_true = tmp_d[mag_][pm_]['total']
            # stats_d[mag_][pm_]['n_true'].append(n_true)
            stats_d[mag_][pm_]['n_true'] = n_true
            # Factors computation
            try:
                f_dr = float(n_meas) / float(n_true)
                f_dr = float("{0:.2f}".format(f_dr))
                stats_d[mag_][pm_]['f_dr'] = f_dr
            except ZeroDivisionError:
                stats_d[mag_][pm_]['f_dr'] = nan
            try:
                f_pur = float(n_se) / float(n_meas)
                f_pur = float("{0:.2f}".format(f_pur))
                stats_d[mag_][pm_]['f_pur'] = f_pur
            except ZeroDivisionError:
                stats_d[mag_][pm_]['f_pur'] = nan
            try:
                f_com = float(n_se) / float(n_true)
                f_com = float("{0:.2f}".format(f_com))
                stats_d[mag_][pm_]['f_com'] = f_com
            except ZeroDivisionError:
                stats_d[mag_][pm_]['f_com'] = nan

    return stats_d
Example #5
0
def gets_filtered_catalog(scmp_cf, sex_cf, mag, filter_p_number):
    """

    :return: filtered_cat, filtered catalog
    """
    prfs_d = extract_settings_luca()
    filter_n = 'filt_{}_{}_{}.csv'.format(scmp_cf, mag, filter_p_number)
    filter_o_n = '{}/{}/{}/{}/{}'.format(prfs_d['filtered'], mag, sex_cf,
                                         scmp_cf, filter_n)

    print('Opens filtered catalog {}'.format(filter_n))
    # Cross with filtered data - Opens datafile
    filtered_cat = read_csv('{}'.format(filter_o_n), index_col=0)

    return filtered_cat
Example #6
0
def get_norm_speed(o_pm):
    """

    :return:
    """
    prfs_d = extract_settings_luca()

    speeds_d = speeds_range(prfs_d, 50)

    pm_norm = 0
    for key_ in speeds_d.keys():
        low = speeds_d[key_][0]
        high = speeds_d[key_][1]
        if low < o_pm < high:
            pm_norm = key_

    return pm_norm
Example #7
0
def check_source(catalog_n, o_cat, i_alpha, i_delta):
    """

    :param catalog_n:
    :param o_cat:
    :param i_alpha:
    :param i_delta:
    :return:
    """
    prfs_d = extract_settings_luca()

    o_df = o_cat[o_cat['catalog'].isin([catalog_n])]
    o_df = o_df[o_df['alpha_j2000'] + prfs_d['tolerance'] > i_alpha]
    o_df = o_df[i_alpha > o_df['alpha_j2000'] - prfs_d['tolerance']]
    o_df = o_df[o_df['delta_j2000'] + prfs_d['tolerance'] > i_delta]
    o_df = o_df[i_delta > o_df['delta_j2000'] - prfs_d['tolerance']]

    return o_df
Example #8
0
def redo_stats_d():
    """ Creates a dictionary

    :return: tmp_d
    """
    prfs_d = extract_settings_luca()
    stats_d = {}
    for mag_ in prfs_d['mags']:
        stats_d[mag_] = {}
        for pm_ in prfs_d['pms']:
            stats_d[mag_][pm_] = {
                'n_meas': [],
                'n_false': [],
                'n_se': [],
                'n_true': [],
                'f_dr': [],
                'f_pur': [],
                'f_com': []
            }

    return stats_d
Example #9
0
    def __init__(self):
        """

        """
        self.filter_p_number = 3  # We are going extract all values
        self.prfs_d = extract_settings_luca()

        self.scmp_cf = '10_1.1_0.5_0.04'
        self.sex_cf = '30_1.5_1.5_0.01_4'

        self.save = True
        self.tmp_d = redo_tmp_d()
        self.input_sources_d = {}

        for mag_ in self.prfs_d['mags']:
            self.mag = mag_
            self.input_sources_d[self.mag] = {
                'SSO': [],
                'star': [],
                'galaxy': []
            }
            self.check_filtered_sources()
            self.create_stats()
    def __init__(self):
        """

        """
        self.prfs_d = extract_settings_luca()
Example #11
0
def redo_tmp_d():
    """ Creates a dictionary
    TODO - Automatic number!

    :return: tmp_d
    """
    prfs_d = extract_settings_luca()
    total_d = {
        '20-21': {
            0: 0,
            0.001: 21,
            0.003: 22,
            0.01: 14,
            0.03: 17,
            0.1: 19,
            0.3: 22,
            1: 23,
            3: 19,
            10: 18,
            30: 21
        },
        '21-22': {
            0: 0,
            0.001: 22,
            0.003: 21,
            0.01: 19,
            0.03: 24,
            0.1: 16,
            0.3: 23,
            1: 18,
            3: 24,
            10: 24,
            30: 19
        },
        '22-23': {
            0: 0,
            0.001: 18,
            0.003: 24,
            0.01: 21,
            0.03: 22,
            0.1: 16,
            0.3: 22,
            1: 20,
            3: 20,
            10: 21,
            30: 26
        },
        '23-24': {
            0: 0,
            0.001: 21,
            0.003: 19,
            0.01: 25,
            0.03: 23,
            0.1: 22,
            0.3: 19,
            1: 20,
            3: 17,
            10: 20,
            30: 21
        },
        '24-25': {
            0: 0,
            0.001: 22,
            0.003: 19,
            0.01: 20,
            0.03: 14,
            0.1: 22,
            0.3: 17,
            1: 21,
            3: 20,
            10: 21,
            30: 18
        },
        '25-26': {
            0: 0,
            0.001: 14,
            0.003: 23,
            0.01: 19,
            0.03: 27,
            0.1: 25,
            0.3: 29,
            1: 23,
            3: 21,
            10: 16,
            30: 22
        },
        '26-27': {
            0: 0,
            0.001: 21,
            0.003: 20,
            0.01: 22,
            0.03: 22,
            0.1: 22,
            0.3: 20,
            1: 18,
            3: 25,
            10: 23,
            30: 14
        }
    }

    tmp_d = {}
    for mag_ in prfs_d['mags']:
        tmp_d[mag_] = {}
        tmp_d[mag_][0] = {'right': 0, 'false': 0, 'total': total_d[mag_][0]}
        for pm_ in prfs_d['pms']:
            tmp_d[mag_][pm_] = {
                'right': 0,
                'false': 0,
                'total': total_d[mag_][pm_]
            }

    return tmp_d