def correlate_redshift_emission_line(quasars, line, subset=False):
    """ Plot correlation between redshift and emission line strength.
        Provide Spearman's rho, pearson's R and linear regression. """

    # Get datapoints for which the redshift and line luminosity is known.
    # The error array of the redshift will be empty.
    REDSHIFT, REDSHIFT_ERR, LINE, LINE_ERR\
        = find_intersection(quasars, 'REDSHIFT', line)

    if subset:
        REDSHIFT_range = []
        LINE_range = []

        for i in xrange(len(REDSHIFT)):
            if REDSHIFT[i] > 1.5 and REDSHIFT[i] < 2.2:
                REDSHIFT_range.append(REDSHIFT[i])
                LINE_range.append(LINE[i])

        REDSHIFT = REDSHIFT_range
        LINE = LINE_range

    # Then look at the correlation coefficients and plot the linear regression
    print
    print "Spearman's Rho\nSelf-written method:\t{0}\nScipy method:\t\t{1}"\
        .format(spearmanr_sarah(REDSHIFT, LINE),
                scipy.stats.spearmanr(REDSHIFT, LINE)[0]),
    print
    print "Spearman's r\nSelf-written method:\t{0}\nScipy method:\t\t{1}"\
        .format(pearsonr_sarah(REDSHIFT, LINE),
                scipy.stats.pearsonr(REDSHIFT, LINE)[0])
    print
    print "Linear regression\nSarah: {0}\nGeert{1}"\
        .format(linear_regression(REDSHIFT, LINE), "Not implemented")
Ejemplo n.º 2
0
    def test_find_intersection_no_common(self):
        lst1 = LinkedList()
        lst2 = LinkedList()
        lst1.insert(4)
        lst1.insert(3)
        lst1.insert(2)
        lst1.insert(1)

        lst2.insert(4)
        lst2.insert(3)
        lst2.insert(2)

        lst = find_intersection(lst1, lst2)
        self.assertEqual(lst, None)
def main():
    """ Parse and clean dataset, then do statistics """

    quasars = parse_dataset('sdss_dr7_qsos.dat')

    print 'Example usage'
    quasars = parse_dataset('sdss_dr7_qsos.dat')
    for quasar in [quasars[1], quasars[1337], quasars[13370]]:
        si = quasar.to_si_for_Sarah()  # nieuwe quasar
        print quasar.RA, "=>", si.RA
        print quasar.DEC, "=>", si.DEC
        print '\n\n'


    attr1_list, attr1_err_list, attr2_list, attr2_err_list =\
        find_intersection(quasars, 'LOGL1350', 'LOGL5100')

    attr1_list, attr1_err_list, attr2_list, attr2_err_list,\
        attr3_list, attr3_err_list =\
        find_intersection(quasars, 'LOGL3000', 'LOGL5100', 'LOGBH')

    attr1_list, attr1_err_list, attr2_list, attr2_err_list,\
        attr3_list, attr3_err_list, attr4_list, attr4_err_list =\
        find_intersection(quasars, 'LOGL3000', 'LOGL5100', 'LOGBH', 'LOGLBOL')
Ejemplo n.º 4
0
 def test_find_intersection(self):
     lst = find_intersection(self.lst1, self.lst2)
     self.assertEqual(lst.size(), 4)
     self.assertEqual(lst.head.get_data(), 7)
     self.assertEqual(lst.head.get_next().get_data(), 5)