diff --git a/.travis.yml b/.travis.yml index 3b85065..0dcb9e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -127,11 +127,13 @@ script: # test elliptical errors - cd tests/elltest/ - nway.py --radius=10.0 randomcatX.fits :pos_err randomcatO.fits 0.1 --out=random_circtest.fits --min-prob=0.01 - - nway-explain.py random_circtest.fits 95 || exit 1 - - nway.py --radius=10.0 randomcatX.fits :a:b randomcatO.fits 0.1 --out=random_asymtest.fits --min-prob=0.01 || exit 1 - - nway-explain.py random_asymtest.fits 95 || exit 1 - - nway.py --radius=10.0 randomcatX.fits :a:b:phi randomcatO.fits 0.1 --out=random_elltest.fits --min-prob=0.01 || exit 1 - - nway-explain.py random_elltest.fits 95 || exit 1 + - nway-explain.py random_circtest.fits 95 + - nway.py --radius=10.0 randomcatX.fits :a:b randomcatO.fits 0.1 --out=random_asymtest.fits --min-prob=0.01 + - nway-explain.py random_asymtest.fits 95 + - nway.py --radius=10.0 randomcatX.fits :a:b:phi randomcatO.fits 0.1 --out=random_elltest.fits --min-prob=0.01 + - nway-explain.py random_elltest.fits 95 + - nway.py --radius=10.0 randomcatX.fits :a:b:phi randomcatR.fits :a:b:phi randomcatO.fits 0.1 --out=random3_elltest.fits --min-prob=0.01 + - nway-explain.py random3_elltest.fits 95 - cd - - python nway-apitest.py diff --git a/nway-explain.py b/nway-explain.py index 5cb7f0f..d1dde82 100644 --- a/nway-explain.py +++ b/nway-explain.py @@ -139,7 +139,8 @@ def converr(err): pa_errs = numpy.array([pa_err for ra, dec, ra_err, dec_err, pa_err in pos if ra != -99]) r, = plt.plot(convx(ras), convy(decs), marker=marker, mec=color, mfc='None', ms=8, mew=2, ls=' ', label='%s %s' % (col_ra, col_dec)) #plt.circles(ras, decs, errs, facecolor='None', edgecolor=r.get_color()) - patches = [Ellipse((convx(ra), convy(dec)), converr(ra_err), converr(dec_err), angle=pa_err) + print(tblname, pa_err) + patches = [Ellipse((convx(ra), convy(dec)), 2 * converr(ra_err), 2 * converr(dec_err), angle=90 - pa_err) for ra, dec, ra_err, dec_err, pa_err in zip(ras, decs, ra_errs, dec_errs, pa_errs)] p = PatchCollection(patches) p.set_facecolor('None') diff --git a/nway.py b/nway.py index c150438..3a66b23 100644 --- a/nway.py +++ b/nway.py @@ -383,8 +383,8 @@ def make_separation_table_matrix(kstr, table, table_names): # identify the prior prior_j = source_densities[augmented_cats[0]] / numpy.product(source_densities_plus[augmented_cats]) # compute a log_bf - errors_selected = [[errors[k][j]] for k in augmented_cats] if simple_errors: + errors_selected = [[errors[k][j]] for k in augmented_cats] separations_selected = [[[separations[k][k2][j]] for k2 in augmented_cats] for k in augmented_cats] log_bf_j = bayesdist.log_bf(numpy.array(separations_selected), @@ -394,6 +394,8 @@ def make_separation_table_matrix(kstr, table, table_names): for k2 in augmented_cats] for k in augmented_cats] separations_selected_dec = [[[separations_dec[k][k2][j]] for k2 in augmented_cats] for k in augmented_cats] + errors_selected = [([errors[k][0][j]], [errors[k][1][j]], [errors[k][2][j]]) + for k in augmented_cats] log_bf_j = bayesdist.log_bf_elliptical(numpy.array(separations_selected_ra), numpy.array(separations_selected_dec), numpy.array(errors_selected)) @@ -638,6 +640,3 @@ def make_separation_table_matrix(kstr, table, table_names): import nwaylib.checkupdates nwaylib.checkupdates.checkupdates() - - - diff --git a/tests/elltest/genrandom_geometric.py b/tests/elltest/genrandom_geometric.py index 9421a47..9198af0 100644 --- a/tests/elltest/genrandom_geometric.py +++ b/tests/elltest/genrandom_geometric.py @@ -16,7 +16,9 @@ fout.close() fout = open('randomcatX.csv', 'w') +fout2 = open('randomcatR.csv', 'w') fout.write('ID,RA,DEC,pos_err,a,b,phi\n') +fout2.write('ID,RA,DEC,pos_err,a,b,phi\n') id = 1 ractr = rarange.mean() @@ -41,6 +43,8 @@ rotangle = angle if (i+1) % 4 == 0 else angle + pi/2 fout.write("%d,%.6f,%.6f,%.6f,%.6f,%.6f,%.6f\n" % (id, ra, dec, symerror*60*60, a*60*60, b*60*60, rotangle/pi*180)) + fout2.write("%d,%.6f,%.6f,%.6f,%.6f,%.6f,%.6f\n" % (id, numpy.random.normal(ra, symerror), numpy.random.normal(dec, symerror), symerror*60*60, a*60*60, b*60*60, rotangle/pi*180)) id += 1 lastr = r fout.close() +fout2.close() diff --git a/tests/elltest/genrandom_geometric.sh b/tests/elltest/genrandom_geometric.sh index cd6fbdb..6a50096 100644 --- a/tests/elltest/genrandom_geometric.sh +++ b/tests/elltest/genrandom_geometric.sh @@ -3,6 +3,9 @@ python3 genrandom_geometric.py || exit 1 topcat -stilts tcopy in=randomcatX.csv ifmt=CSV out=randomcatX.fits || exit 1 nway-write-header.py randomcatX.fits CHANDRA 0.010 || exit 1 +topcat -stilts tcopy in=randomcatR.csv ifmt=CSV out=randomcatR.fits || exit 1 +nway-write-header.py randomcatR.fits XMM 0.010 || exit 1 + topcat -stilts tcopy in=randomcatO.csv ifmt=CSV out=randomcatO.fits || exit 1 nway-write-header.py randomcatO.fits OPT 0.010 || exit 1 @@ -12,8 +15,9 @@ nway.py --radius=10.0 randomcatX.fits :a:b randomcatO.fits 0.1 --out=random_asym nway.py --radius=10.0 randomcatX.fits :a:b:phi randomcatO.fits 0.1 --out=random_elltest.fits --min-prob=0.01 || exit 1 +nway.py --radius=10.0 randomcatX.fits :a:b:phi randomcatR.fits :a:b:phi randomcatO.fits 0.1 --out=random3_elltest.fits --min-prob=0.01 || exit 1 -echo topcat -stilts plot2sky \ +topcat -stilts plot2sky \ xpix=1081 ypix=548 \ crowd=0.9998301109057076 \ clon=150.0338559501912 clat=2.040905749390326 radius=0.003505914272661 \ @@ -31,7 +35,7 @@ echo topcat -stilts plot2sky \ shading_2=auto \ layer_3=Mark \ lon_3=OPT_RA lat_3=OPT_DEC aux_3=p_i \ - shading_3=aux size_3=3 \ + shading_3=aux size_3=3 nway-explain.py random_circtest.fits 95 || exit 1 diff --git a/tests/elltest/randomcatR.fits b/tests/elltest/randomcatR.fits new file mode 100644 index 0000000..d44210d Binary files /dev/null and b/tests/elltest/randomcatR.fits differ diff --git a/tests/elltest/randomcatX.fits b/tests/elltest/randomcatX.fits index b820429..cfd37c3 100644 Binary files a/tests/elltest/randomcatX.fits and b/tests/elltest/randomcatX.fits differ