From e5e980c53990f47440ba4e2e1e2e9dc07548a662 Mon Sep 17 00:00:00 2001 From: Martin Reinecke Date: Wed, 17 Oct 2012 11:47:12 +0200 Subject: [PATCH] make ring sorting more determninistic --- libsharp/sharp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libsharp/sharp.c b/libsharp/sharp.c index 6e832c3..c089ecb 100644 --- a/libsharp/sharp.c +++ b/libsharp/sharp.c @@ -116,7 +116,9 @@ static int ringpair_compare (const void *xa, const void *xb) { const sharp_ringpair *a=xa, *b=xb; if (a->r1.nph==b->r1.nph) - return (a->r1.phi0 < b->r1.phi0) ? -1 : (a->r1.phi0 > b->r1.phi0) ? 1 : 0; + return (a->r1.phi0 < b->r1.phi0) ? -1 : + ((a->r1.phi0 > b->r1.phi0) ? 1 : + (a->r1.cth>b->r1.cth ? -1 : 1)); return (a->r1.nphr1.nph) ? -1 : 1; } @@ -186,7 +188,13 @@ void sharp_make_geom_info (int nrings, const int *nph, const ptrdiff_t *ofs, info->pair[info->npairs].r1=infos[pos]; if ((pospair[info->npairs].r2=infos[pos+1]; + if (infos[pos].cth>0) // make sure northern ring is in r1 + info->pair[info->npairs].r2=infos[pos+1]; + else + { + info->pair[info->npairs].r1=infos[pos+1]; + info->pair[info->npairs].r2=infos[pos]; + } ++pos; } else