28#include <lal/VectorMath.h>
29#include <lal/UserInputPrint.h>
32#define COMPARE_BY( x, y ) do { if ( (x) < (y) ) return -1; if ( (x) > (y) ) return +1; } while(0)
69static int compare_templates(
BOOLEAN *equal,
const char *loc_str,
const char *tmpl_str,
const UINT4 round_param_to_dp,
const UINT4 round_param_to_sf,
const REAL8 param_tol_mism,
const gsl_matrix *
metric,
const SuperskyTransformData *rssky_transf,
const UINT8 serial_1,
const UINT8 serial_2,
const PulsarDopplerParams *phys_1,
const PulsarDopplerParams *phys_2 );
94 snprintf( buf,
sizeof( buf ),
"%0.*f", dp,
x );
98 snprintf( buf,
sizeof( buf ),
"%0.*e", sf - 1,
x );
108 const WeaveResultsToplist *toplist
116 WeaveResultsToplistItem *item =
XLALCalloc( 1,
sizeof( *item ) );
119 const WeaveStatisticsParams *
params = toplist-> statistics_params;
129 if ( store_per_segment_stats ) {
130 item->coh_alpha =
XLALCalloc(
params->nsegments,
sizeof( *item->coh_alpha ) );
132 item->coh_delta =
XLALCalloc(
params->nsegments,
sizeof( *item->coh_delta ) );
134 for (
size_t k = 0;
k <= toplist->nspins; ++
k ) {
141 for (
UINT4 istage = 0; istage < 2; istage ++ ) {
142 if ( store_coh2F[istage] ) {
143 item->stage[istage].coh2F =
XLALCalloc(
params->nsegments,
sizeof( *item->stage[istage].coh2F ) );
146 if ( store_coh2F_det[istage] ) {
147 for (
UINT4 X = 0; X <
params->detectors->length; ++X ) {
148 item->stage[istage].coh2F_det[X] =
XLALCalloc(
params->nsegments,
sizeof( *item->stage[istage].coh2F_det[X] ) );
162 WeaveResultsToplistItem *item
165 if ( item != NULL ) {
171 for (
size_t istage = 0; istage < 2; ++istage ) {
172 XLALFree( item->stage[istage].coh2F );
174 XLALFree( item->stage[istage].coh2F_det[X] );
191 const WeaveResultsToplistItem *ix = (
const WeaveResultsToplistItem * )
x;
192 const WeaveResultsToplistItem *iy = (
const WeaveResultsToplistItem * )
y;
193 COMPARE_BY( item_get_rank_stat_fcn( iy ), item_get_rank_stat_fcn( ix ) );
202 const WeaveResultsToplist *toplist
219 for (
size_t k = 1;
k <= toplist->nspins; ++
k ) {
220 snprintf( col_name,
sizeof( col_name ),
"f%zudot [Hz/s^%zu]",
k,
k );
224 const WeaveStatisticsParams *
params = toplist->statistics_params;
226 const char *stage_suffix[2] = {
"",
"_rec"};
228 for (
UINT4 istage = 0; istage < 2; istage ++ ) {
240 for (
size_t i = 0;
i <
params->detectors->length; ++
i ) {
254 for (
size_t i = 0;
i <
params->detectors->length; ++
i ) {
268 for (
size_t i = 0;
i <
params->detectors->length; ++
i ) {
300 for (
size_t i = 0;
i <
params->detectors->length; ++
i ) {
314 if ( per_segment_stats ) {
318 for (
size_t k = 1;
k <= toplist->nspins; ++
k ) {
319 snprintf( col_name,
sizeof( col_name ),
"f%zudot_seg [Hz/s^%zu]",
k,
k );
333 for (
size_t i = 0;
i <
params->detectors->length; ++
i ) {
356 WeaveResultsToplistItem *item = ( WeaveResultsToplistItem * )
x;
357 WeaveStatisticsParams *stats_params = ( WeaveStatisticsParams * )param;
358 UINT4 ndetectors = stats_params->detectors->length;
359 UINT4 nsegments = stats_params->nsegments;
361 for (
UINT4 istage = 0; istage < 2; istage ++ ) {
366 XLAL_CHECK( istage > 0,
XLAL_EERR,
"BUG: requested 'coh2F' or 'coh2F_det' in stage0 completion loop ==> should never happen!\n" );
368 semi_phys.refTime = stats_params->ref_time;
369 semi_phys.Alpha = item->semi_alpha;
370 semi_phys.Delta = item->semi_delta;
371 memcpy( semi_phys.fkdot, item->semi_fkdot,
sizeof( semi_phys.fkdot ) );
373 const UINT4 nfreqs = 1;
374 for (
size_t l = 0;
l < nsegments; ++
l ) {
381 item->stage[istage].coh2F[
l] = coh2F->
data[0];
384 XLAL_CHECK( have_coh2F_det,
XLAL_EFAILED,
"BUG: caller requested per-detector 2F-statistic, but was not computed\n" );
385 for (
UINT4 X = 0; X < ndetectors; ++X ) {
386 item->stage[istage].coh2F_det[X][
l] = ( coh2F_det[X] != NULL ) ? coh2F_det[X]->
data[0] : NAN;
394 item->stage[istage].max2F = 0;
395 for (
size_t l = 0;
l < nsegments; ++
l ) {
396 item->stage[istage].max2F = fmaxf( item->stage[istage].max2F, item->stage[istage].coh2F[
l] );
401 for (
size_t X = 0; X < ndetectors; ++X ) {
402 item->stage[istage].max2F_det[X] = 0;
403 for (
size_t l = 0;
l < nsegments; ++
l ) {
404 REAL4 item_Xl = item->stage[istage].coh2F_det[X][
l];
405 item->stage[istage].max2F_det[X] = isnan( item_Xl ) ? item->stage[istage].max2F_det[X] : fmaxf( item->stage[istage].max2F_det[X], item_Xl );
411 item->stage[istage].sum2F = 0;
412 for (
size_t l = 0;
l < nsegments; ++
l ) {
413 item->stage[istage].sum2F += item->stage[istage].coh2F[
l];
418 for (
size_t X = 0; X < ndetectors; ++X ) {
419 item->stage[istage].sum2F_det[X] = 0;
420 for (
size_t l = 0;
l < nsegments; ++
l ) {
421 REAL4 item_Xl = item->stage[istage].coh2F_det[X][
l];
422 item->stage[istage].sum2F_det[X] += isnan( item_Xl ) ? 0 : item_Xl;
428 item->stage[istage].mean2F = item->stage[istage].sum2F / nsegments;
432 for (
size_t X = 0; X < ndetectors; ++X ) {
433 item->stage[istage].mean2F_det[X] = item->stage[istage].sum2F_det[X] / stats_params->n2F_det[X];
438 item->stage[istage].log10BSGL =
XLALComputeBSGL( item->stage[istage].sum2F, item->stage[istage].sum2F_det, stats_params->BSGL_setup );
442 item->stage[istage].log10BSGLtL =
XLALComputeBSGLtL( item->stage[istage].sum2F, item->stage[istage].sum2F_det, item->stage[istage].max2F_det, stats_params->BSGL_setup );
446 item->stage[istage].log10BtSGLtL =
XLALComputeBtSGLtL( item->stage[istage].max2F, item->stage[istage].sum2F_det, item->stage[istage].max2F_det, stats_params->BSGL_setup );
450 item->stage[istage].ncount = 0;
451 for (
size_t l = 0;
l < nsegments; ++
l ) {
452 item->stage[istage].ncount += ( item->stage[istage].coh2F[
l] > stats_params->nc_2Fth ) ? 1 : 0;
457 for (
size_t X = 0; X < ndetectors; ++X ) {
458 item->stage[istage].ncount_det[X] = 0;
459 for (
size_t l = 0;
l < nsegments; ++
l ) {
460 REAL4 item_Xl = item->stage[istage].coh2F_det[X][
l];
461 if ( isnan( item_Xl ) ) {
464 item->stage[istage].ncount_det[X] += ( item_Xl > stats_params->nc_2Fth ) ? 1 : 0;
499 const WeaveResultsToplistItem *ix = *(
const WeaveResultsToplistItem *
const * )
x;
500 const WeaveResultsToplistItem *iy = *(
const WeaveResultsToplistItem *
const * )
y;
506 COMPARE_BY( ix->semi_fkdot[0], iy->semi_fkdot[0] );
518 const WeaveResultsToplistItem *ix = *(
const WeaveResultsToplistItem *
const * )
x;
519 const WeaveResultsToplistItem *iy = *(
const WeaveResultsToplistItem *
const * )
y;
530 const char *tmpl_str,
531 const UINT4 round_param_to_dp,
532 const UINT4 round_param_to_sf,
533 const REAL8 param_tol_mism,
535 const SuperskyTransformData *rssky_transf,
536 const UINT8 serial_1,
537 const UINT8 serial_2,
558 for (
size_t i = 0;
i < 2; ++
i ) {
566 double rssky_array[2][
metric->size1];
567 gsl_vector_view rssky_view[2] = { gsl_vector_view_array( rssky_array[0],
metric->size1 ), gsl_vector_view_array( rssky_array[1],
metric->size1 ) };
568 gsl_vector *
const rssky[2] = { &rssky_view[0].vector, &rssky_view[1].vector };
569 for (
size_t i = 0;
i < 2; ++
i ) {
575 double u_array[
metric->size1];
576 gsl_vector_view u_view = gsl_vector_view_array( u_array,
metric->size1 );
577 gsl_vector *
const u = &u_view.vector;
578 gsl_vector_memcpy(
u, rssky[0] );
579 gsl_vector_sub(
u, rssky[1] );
582 double v_array[
metric->size1];
583 gsl_vector_view v_view = gsl_vector_view_array( v_array,
metric->size1 );
584 gsl_vector *
const v = &v_view.vector;
585 gsl_blas_dsymv( CblasUpper, 1.0,
metric,
u, 0.0, v );
589 gsl_blas_ddot(
u, v, &mism );
592 if ( mism > param_tol_mism ) {
594 XLALPrintInfo(
"%s: at %s, mismatch between %s template parameters exceeds tolerance: %g > %g\n",
__func__, loc_str, tmpl_str, mism, param_tol_mism );
597 for (
size_t i = 0;
i < 2; ++
i ) {
599 phys_orig[
i].
Alpha, phys_orig[
i].
Delta, phys_orig[
i].fkdot[0], phys_orig[
i].fkdot[1] );
600 if ( round_param_to_dp > 0 ) {
601 XLALPrintInfo(
"%s: physical %zu = {%.15g,%.15g,%.15g,%.15g} rounded to %u d.p., %u s.f.\n",
__func__,
i + 1,
603 round_param_to_dp, round_param_to_sf );
606 for (
size_t i = 0;
i < 2; ++
i ) {
608 for (
size_t j = 0;
j < rssky[
i]->size; ++
j ) {
609 XLALPrintInfo(
"%c%.15g",
j == 0 ?
'{' :
',', gsl_vector_get( rssky[
i],
j ) );
614 for (
size_t j = 0;
j <
u->size; ++
j ) {
619 for (
size_t j = 0;
j <
u->size; ++
j ) {
620 XLALPrintInfo(
"%c%.15g",
j == 0 ?
'{' :
',', gsl_vector_get(
u,
j ) * gsl_vector_get( v,
j ) );
650 }
else if ( errnum != 0 ) {
661 WeaveStatisticsParams *statistics_params,
662 const char *stat_name,
663 const char *stat_desc,
664 const UINT4 toplist_limit,
677 WeaveResultsToplist *toplist =
XLALCalloc( 1,
sizeof( *toplist ) );
681 toplist->nspins = nspins;
682 toplist->stat_name = stat_name;
683 toplist->stat_desc = stat_desc;
684 toplist->rank_stats_fcn = toplist_rank_stats_fcn;
685 toplist->item_get_rank_stat_fcn = toplist_item_get_rank_stat_fcn;
686 toplist->item_set_rank_stat_fcn = toplist_item_set_rank_stat_fcn;
687 toplist->statistics_params = statistics_params;
701 WeaveResultsToplist *toplist
704 if ( toplist != NULL ) {
716 WeaveResultsToplist *toplist,
717 const WeaveSemiResults *semi_res,
718 const UINT4 semi_nfreqs
726 if ( toplist->maybe_add_freq_idxs == NULL || toplist->maybe_add_freq_idxs->length < semi_nfreqs ) {
732 const REAL4 *toplist_rank_stats = toplist->rank_stats_fcn( semi_res );
737 const REAL4 heap_root_rank_stat = heap_full ? toplist->item_get_rank_stat_fcn(
XLALHeapRoot( toplist->heap ) ) : GSL_NEGINF;
741 UINT4 n_maybe_add = 0;
745 const WeaveStatisticsParams *
params = toplist->statistics_params;
749 for (
UINT4 idx = 0; idx < n_maybe_add; ++idx ) {
750 const UINT4 freq_idx = toplist->maybe_add_freq_idxs->data[idx];
753 if ( toplist->saved_item == NULL ) {
757 WeaveResultsToplistItem *item = toplist->saved_item;
760 toplist->item_set_rank_stat_fcn( item, toplist_rank_stats[freq_idx] );
766 if ( item == toplist->saved_item ) {
771 item->serial = ++toplist->serial;
774 item->semi_alpha = semi_res->semi_phys.Alpha;
775 item->semi_delta = semi_res->semi_phys.Delta;
776 item->semi_fkdot[0] = semi_res->semi_phys.fkdot[0] + freq_idx * semi_res->dfreq;
777 for (
size_t k = 1;
k <= toplist->nspins; ++
k ) {
778 item->semi_fkdot[
k] = semi_res->semi_phys.fkdot[
k];
782 if ( per_seg_coords ) {
783 for (
size_t j = 0;
j < semi_res->nsegments; ++
j ) {
784 item->coh_alpha[
j] = semi_res->coh_phys[
j].Alpha;
785 item->coh_delta[
j] = semi_res->coh_phys[
j].Delta;
786 item->coh_fkdot[0][
j] = semi_res->coh_phys[
j].fkdot[0] + freq_idx * semi_res->dfreq;
787 for (
size_t k = 1;
k <= toplist->nspins; ++
k ) {
788 item->coh_fkdot[
k][
j] = semi_res->coh_phys[
j].fkdot[
k];
807 for (
size_t i = 0;
i < semi_res->ndetectors; ++
i ) {
808 for (
size_t j = 0;
j < semi_res->nsegments; ++
j ) {
809 if ( semi_res->coh2F_det[
i][
j] != NULL ) {
810 item->stage[0].coh2F_det[
i][
j] = semi_res->coh2F_det[
i][
j][freq_idx];
814 item->stage[0].coh2F_det[
i][
j] = NAN;
821 item->stage[0].max2F = semi_res->max2F->data[freq_idx];
824 for (
size_t i = 0;
i < semi_res->ndetectors; ++
i ) {
825 item->stage[0].max2F_det[
i] = semi_res->max2F_det[
i]->data[freq_idx];
830 item->stage[0].sum2F = semi_res->sum2F->data[freq_idx];
833 for (
size_t i = 0;
i < semi_res->ndetectors; ++
i ) {
834 item->stage[0].sum2F_det[
i] = semi_res->sum2F_det[
i]->data[freq_idx];
839 item->stage[0].mean2F = semi_res->mean2F->data[freq_idx];
843 item->stage[0].log10BSGL = semi_res->log10BSGL->data[freq_idx];
847 item->stage[0].log10BSGLtL = semi_res->log10BSGLtL->data[freq_idx];
851 item->stage[0].log10BtSGLtL = semi_res->log10BtSGLtL->data[freq_idx];
864 WeaveResultsToplist *toplist
882 const WeaveResultsToplist *toplist
892 snprintf(
name,
sizeof(
name ),
"%s_toplist", toplist->stat_name );
894 snprintf(
desc,
sizeof(
desc ),
"toplist ranked by %s", toplist->stat_desc );
915 WeaveResultsToplist *toplist
925 snprintf(
name,
sizeof(
name ),
"%s_toplist", toplist->stat_name );
933 while ( nrows > 0 ) {
936 if ( toplist->saved_item == NULL ) {
945 if ( toplist->serial < toplist->saved_item->serial ) {
946 toplist->serial = toplist->saved_item->serial;
966 const WeaveSetupData *setup,
967 const BOOLEAN sort_by_semi_phys,
968 const UINT4 round_param_to_dp,
969 const UINT4 round_param_to_sf,
970 const REAL8 unmatched_item_tol,
971 const REAL8 param_tol_mism,
973 const UINT4 toplist_compare_limit,
974 const WeaveResultsToplist *toplist_1,
975 const WeaveResultsToplist *toplist_2
990 const WeaveResultsToplist *toplist = toplist_1;
991 const WeaveStatisticsParams *
params = toplist->statistics_params;
1008 const WeaveResultsToplistItem **items_1 = (
const WeaveResultsToplistItem ** )
XLALHeapElements( toplist_1->heap );
1010 const WeaveResultsToplistItem **items_2 = (
const WeaveResultsToplistItem ** )
XLALHeapElements( toplist_2->heap );
1014 const WeaveResultsToplistItem **matched_1 =
XLALCalloc(
n,
sizeof( *matched_1 ) );
1016 const WeaveResultsToplistItem **matched_2 =
XLALCalloc(
n,
sizeof( *matched_2 ) );
1018 size_t matched_n = 0;
1019 if ( sort_by_semi_phys ) {
1026 memcpy( matched_1, items_1,
n *
sizeof( *matched_1 ) );
1027 memcpy( matched_2, items_2,
n *
sizeof( *matched_2 ) );
1037 size_t n_1 = 0, n_2 = 0;
1038 while ( n_1 <
n && n_2 <
n ) {
1039 if ( items_1[n_1]->serial < items_2[n_2]->serial ) {
1041 }
else if ( items_2[n_2]->serial < items_1[n_1]->serial ) {
1044 matched_1[matched_n] = items_1[n_1++];
1045 matched_2[matched_n] = items_2[n_2++];
1053 if ( toplist_compare_limit > 0 && matched_n > toplist_compare_limit ) {
1054 matched_n = toplist_compare_limit;
1058 const long int unmatched_n =
n - matched_n;
1059 const long int unmatched_item_tol_n = lrint( unmatched_item_tol *
n );
1060 if ( unmatched_n > unmatched_item_tol_n ) {
1062 XLALPrintInfo(
"%s: number of unmatched %s toplist items %lu exceeds tolerance %0.3e * %zu = %lu\n",
__func__, toplist->stat_desc, unmatched_n, unmatched_item_tol,
n, unmatched_item_tol_n );
1074 XLALPrintInfo(
"%s: comparing %zu matched items from toplists ranked by %s ...\n",
__func__, matched_n, toplist->stat_desc );
1079 if ( ( *equal ) && ( param_tol_mism > 0 ) ) {
1080 for (
size_t i = 0;
i < matched_n; ++
i ) {
1082 snprintf( loc_str,
sizeof( loc_str ),
"toplist item %zu",
i );
1083 const UINT8 serial_1 = matched_1[
i]->serial;
1084 const UINT8 serial_2 = matched_2[
i]->serial;
1087 semi_phys_1.Alpha = matched_1[
i]->semi_alpha;
1088 semi_phys_2.Alpha = matched_2[
i]->semi_alpha;
1089 semi_phys_1.Delta = matched_1[
i]->semi_delta;
1090 semi_phys_2.Delta = matched_2[
i]->semi_delta;
1091 for (
size_t k = 0;
k <= toplist->nspins; ++
k ) {
1092 semi_phys_1.fkdot[
k] = matched_1[
i]->semi_fkdot[
k];
1093 semi_phys_2.fkdot[
k] = matched_2[
i]->semi_fkdot[
k];
1096 loc_str,
"semicoherent",
1097 round_param_to_dp, round_param_to_sf, param_tol_mism,
1098 setup->metrics->semi_rssky_metric, setup->metrics->semi_rssky_transf,
1100 &semi_phys_1, &semi_phys_2
1113 for (
size_t i = 0;
i < matched_n; ++
i ) {
1114 for (
size_t j = 0;
j <
params->nsegments; ++
j ) {
1116 snprintf( loc_str,
sizeof( loc_str ),
"toplist item %zu, segment %zu",
i,
j );
1117 const UINT8 serial_1 = matched_1[
i]->serial;
1118 const UINT8 serial_2 = matched_2[
i]->serial;
1121 coh_phys_1.Alpha = matched_1[
i]->coh_alpha[
j];
1122 coh_phys_2.Alpha = matched_2[
i]->coh_alpha[
j];
1123 coh_phys_1.Delta = matched_1[
i]->coh_delta[
j];
1124 coh_phys_2.Delta = matched_2[
i]->coh_delta[
j];
1125 for (
size_t k = 0;
k <= toplist->nspins; ++
k ) {
1126 coh_phys_1.fkdot[
k] = matched_1[
i]->coh_fkdot[
k][
j];
1127 coh_phys_2.fkdot[
k] = matched_2[
i]->coh_fkdot[
k][
j];
1130 loc_str,
"coherent",
1131 round_param_to_dp, round_param_to_sf, param_tol_mism,
1132 setup->metrics->coh_rssky_metric[
j], setup->metrics->coh_rssky_transf[
j],
1134 &coh_phys_1, &coh_phys_2
1147 for (
UINT4 istage = 0; istage < 2; ++ istage ) {
1154 for (
size_t i = 0;
i < matched_n; ++
i ) {
1155 res_1->
data[r1++] = matched_1[
i]->stage[istage].mean2F;
1156 res_2->
data[
r2++] = matched_2[
i]->stage[istage].mean2F;
1165 for (
size_t k = 0;
k <
params->detectors->length; ++
k ) {
1166 for (
size_t i = 0;
i < matched_n; ++
i ) {
1167 res_1->
data[r1++] = matched_1[
i]->stage[istage].mean2F_det[
k];
1168 res_2->
data[
r2++] = matched_2[
i]->stage[istage].mean2F_det[
k];
1178 for (
size_t j = 0;
j <
params->nsegments; ++
j ) {
1179 for (
size_t i = 0;
i < matched_n; ++
i ) {
1180 res_1->
data[r1++] = matched_1[
i]->stage[istage].coh2F[
j];
1181 res_2->
data[
r2++] = matched_2[
i]->stage[istage].coh2F[
j];
1191 for (
size_t j = 0;
j <
params->nsegments; ++
j ) {
1192 for (
size_t k = 0;
k <
params->detectors->length; ++
k ) {
1193 if ( isfinite( items_1[0]->
stage[istage].coh2F_det[
k][
j] ) || isfinite( items_2[0]->
stage[istage].coh2F_det[
k][
j] ) ) {
1194 for (
size_t i = 0;
i < matched_n; ++
i ) {
1195 res_1->
data[r1++] = matched_1[
i]->stage[istage].coh2F_det[
k][
j];
1196 res_2->
data[
r2++] = matched_2[
i]->stage[istage].coh2F_det[
k][
j];
1208 for (
size_t i = 0;
i < matched_n; ++
i ) {
1209 res_1->
data[r1++] = matched_1[
i]->stage[istage].max2F;
1210 res_2->
data[
r2++] = matched_2[
i]->stage[istage].max2F;
1219 for (
size_t k = 0;
k <
params->detectors->length; ++
k ) {
1220 for (
size_t i = 0;
i < matched_n; ++
i ) {
1221 res_1->
data[r1++] = matched_1[
i]->stage[istage].max2F_det[
k];
1222 res_2->
data[
r2++] = matched_2[
i]->stage[istage].max2F_det[
k];
1232 for (
size_t i = 0;
i < matched_n; ++
i ) {
1233 res_1->
data[r1++] = matched_1[
i]->stage[istage].sum2F;
1234 res_2->
data[
r2++] = matched_2[
i]->stage[istage].sum2F;
1243 for (
size_t k = 0;
k <
params->detectors->length; ++
k ) {
1244 for (
size_t i = 0;
i < matched_n; ++
i ) {
1245 res_1->
data[r1++] = matched_1[
i]->stage[istage].sum2F_det[
k];
1246 res_2->
data[
r2++] = matched_2[
i]->stage[istage].sum2F_det[
k];
1256 for (
size_t i = 0;
i < matched_n; ++
i ) {
1257 res_1->
data[r1++] = matched_1[
i]->stage[istage].log10BSGL;
1258 res_2->
data[
r2++] = matched_2[
i]->stage[istage].log10BSGL;
1267 for (
size_t i = 0;
i < matched_n; ++
i ) {
1268 res_1->
data[r1++] = matched_1[
i]->stage[istage].log10BSGLtL;
1269 res_2->
data[
r2++] = matched_2[
i]->stage[istage].log10BSGLtL;
1278 for (
size_t i = 0;
i < matched_n; ++
i ) {
1279 res_1->
data[r1++] = matched_1[
i]->stage[istage].log10BtSGLtL;
1280 res_2->
data[
r2++] = matched_2[
i]->stage[istage].log10BtSGLtL;
1289 for (
size_t i = 0;
i < matched_n; ++
i ) {
1290 res_1->
data[r1++] = matched_1[
i]->stage[istage].ncount;
1291 res_2->
data[
r2++] = matched_2[
i]->stage[istage].ncount;
1300 for (
size_t k = 0;
k <
params->detectors->length; ++
k ) {
1301 for (
size_t i = 0;
i < matched_n; ++
i ) {
1302 res_1->
data[r1++] = matched_1[
i]->stage[istage].ncount_det[
k];
1303 res_2->
data[
r2++] = matched_2[
i]->stage[istage].ncount_det[
k];
int XLALWeaveCohResultsExtract(REAL4Vector **coh2F, REAL4Vector *coh2F_det[PULSAR_MAX_DETECTORS], BOOLEAN *have_coh2F_det, WeaveCohResults *coh_res, const WeaveCohInput *coh_input)
Simple API function to extract pointers to 2F results from WeaveCohResults.
int XLALWeaveCohResultsCompute(WeaveCohResults **coh_res, WeaveCohInput *coh_input, const PulsarDopplerParams *coh_phys, const UINT4 coh_nfreqs, WeaveSearchTiming *tim)
Create and compute coherent results.
int XLALWeaveSemiCoh2FExtract(REAL4 *coh2F, const WeaveSemiResults *semi_res, const UINT4 freq_idx)
Extract 2F results from WeaveSemiResults; handles results stores in CUDA device memory.
Module which computes coherent and semicoherent results.
#define __func__
log an I/O error, i.e.
int XLALFITSTableWriteRow(FITSFile UNUSED *file, const void UNUSED *record)
int XLALFITSTableReadRow(FITSFile UNUSED *file, void UNUSED *record, UINT8 UNUSED *rem_nrows)
int XLALFITSTableOpenWrite(FITSFile UNUSED *file, const CHAR UNUSED *name, const CHAR UNUSED *comment)
int XLALFITSHeaderWriteUINT8(FITSFile UNUSED *file, const CHAR UNUSED *key, const UINT8 UNUSED value, const CHAR UNUSED *comment)
int XLALFITSHeaderReadUINT8(FITSFile UNUSED *file, const CHAR UNUSED *key, UINT8 UNUSED *value)
int XLALFITSTableOpenRead(FITSFile UNUSED *file, const CHAR UNUSED *name, UINT8 UNUSED *nrows)
int XLALWeaveResultsToplistAdd(WeaveResultsToplist *toplist, const WeaveSemiResults *semi_res, const UINT4 semi_nfreqs)
Add semicoherent results to toplist.
static int toplist_fits_table_write_visitor(void *param, const void *x)
Visitor function for writing a toplist to a FITS table.
void XLALWeaveResultsToplistDestroy(WeaveResultsToplist *toplist)
Free results toplist.
static double round_to_dp_sf(double x, const UINT4 dp, const UINT4 sf)
Round a floating-point number 'x' to 'dp' decimal places (if > 0), then 'sf' significant figures (if ...
WeaveResultsToplist * XLALWeaveResultsToplistCreate(const size_t nspins, WeaveStatisticsParams *statistics_params, const char *stat_name, const char *stat_desc, const UINT4 toplist_limit, WeaveResultsToplistRankingStats toplist_rank_stats_fcn, WeaveResultsToplistItemGetRankStat toplist_item_get_rank_stat_fcn, WeaveResultsToplistItemSetRankStat toplist_item_set_rank_stat_fcn)
Create results toplist.
static int toplist_fits_table_init(FITSFile *file, const WeaveResultsToplist *toplist)
Initialise a FITS table for writing/reading a toplist.
static int toplist_item_sort_by_serial(const void *x, const void *y)
Sort toplist items by serial number of template.
int XLALWeaveResultsToplistReadAppend(FITSFile *file, WeaveResultsToplist *toplist)
Read results from a FITS file and append to existing results toplist.
static int toplist_item_compare(void *param, const void *x, const void *y)
Compare toplist items.
static void toplist_item_destroy(WeaveResultsToplistItem *item)
Destroy a toplist item.
int XLALWeaveResultsToplistCompare(BOOLEAN *equal, const WeaveSetupData *setup, const BOOLEAN sort_by_semi_phys, const UINT4 round_param_to_dp, const UINT4 round_param_to_sf, const REAL8 unmatched_item_tol, const REAL8 param_tol_mism, const VectorComparison *result_tol, const UINT4 toplist_compare_limit, const WeaveResultsToplist *toplist_1, const WeaveResultsToplist *toplist_2)
Compare two results toplists and return whether they are equal.
static int compare_vectors(BOOLEAN *equal, const VectorComparison *result_tol, const REAL4Vector *res_1, const REAL4Vector *res_2, const UINT4 r1, const UINT4 r2)
Compare two vectors of results.
static int compare_templates(BOOLEAN *equal, const char *loc_str, const char *tmpl_str, const UINT4 round_param_to_dp, const UINT4 round_param_to_sf, const REAL8 param_tol_mism, const gsl_matrix *metric, const SuperskyTransformData *rssky_transf, const UINT8 serial_1, const UINT8 serial_2, const PulsarDopplerParams *phys_1, const PulsarDopplerParams *phys_2)
Compute two template parameters.
int XLALWeaveResultsToplistWrite(FITSFile *file, const WeaveResultsToplist *toplist)
Write results toplist to a FITS file.
static WeaveResultsToplistItem * toplist_item_create(const WeaveResultsToplist *toplist)
Create a toplist item.
static int toplist_fill_completionloop_stats(void *param, void *x)
Function to update given toplist item with missing 'completion loop' statistics.
static int toplist_item_sort_by_semi_phys(const void *x, const void *y)
Sort toplist items by physical coordinates of semicoherent template.
int XLALWeaveResultsToplistCompletionLoop(WeaveResultsToplist *toplist)
Compute all missing 'extra' (non-toplist-ranking) statistics for all toplist entries.
Module which handles toplists of results.
REAL4(* WeaveResultsToplistItemGetRankStat)(const WeaveResultsToplistItem *item)
Function which returns the value of the statistic by which toplist items are ranked.
const REAL4 *(* WeaveResultsToplistRankingStats)(const WeaveSemiResults *semi_res)
Function which returns pointer to array of statistics by which toplist items are ranked.
void(* WeaveResultsToplistItemSetRankStat)(WeaveResultsToplistItem *item, const REAL4 value)
Function which sets the value of the statistic by which toplist items are ranked.
@ WEAVE_SIMULATE
Simulate search (implicitly with full memory allocation)
enum tagWeaveStatisticType WeaveStatisticType
@ WEAVE_STATISTIC_MEAN2F_DET
Per detector average F-statistic.
@ WEAVE_STATISTIC_COH2F
Per segment multi-detector F-statistic.
@ WEAVE_STATISTIC_NCOUNT_DET
Hough number count per detector.
@ WEAVE_STATISTIC_COH2F_DET
Per segment per-detector F-statistic.
@ WEAVE_STATISTIC_BtSGLtL
(transient-)line robust log10(B_tS/GLtL) statistic
@ WEAVE_STATISTIC_SUM2F_DET
Per detector sum F-statistic.
@ WEAVE_STATISTIC_MAX2F_DET
@ WEAVE_STATISTIC_MEAN2F
Multi-detector average (over segments) F-statistic.
@ WEAVE_STATISTIC_BSGLtL
(transient-)line robust log10(B_S/GLtL) statistic
@ WEAVE_STATISTIC_BSGL
Line-robust log10(B_S/GL) statistic.
@ WEAVE_STATISTIC_NCOUNT
Hough number count.
@ WEAVE_STATISTIC_SUM2F
Multi-detector sum (over segments) F-statistic.
#define WEAVE_STATISTIC_NAME(ws)
Names of all possible statistics.
#define XLAL_FITS_TABLE_COLUMN_BEGIN(record_type)
#define XLAL_FITS_TABLE_COLUMN_ADD_NAMED(file, type, field, col_name)
#define XLAL_FITS_TABLE_COLUMN_ADD_PTR_ARRAY_NAMED(file, type, length, field, col_name)
struct tagFITSFile FITSFile
Representation of a FITS file.
#define XLAL_INIT_DECL(var,...)
int XLALHeapVisit(const LALHeap *h, LALHeapVisitFcn visit, void *visit_param)
int XLALHeapAdd(LALHeap *h, void **x)
int XLALHeapModify(LALHeap *h, LALHeapModifyFcn modify, void *modify_param)
int XLALHeapSize(const LALHeap *h)
const void * XLALHeapRoot(const LALHeap *h)
int XLALHeapIsFull(const LALHeap *h)
const void ** XLALHeapElements(const LALHeap *h)
void(* LALHeapDtorFcn)(void *x)
void XLALHeapDestroy(LALHeap *h)
LALHeap * XLALHeapCreate2(LALHeapDtorFcn dtor, int max_size, int min_or_max_heap, LALHeapCmpParamFcn cmp, void *cmp_param)
void * XLALCalloc(size_t m, size_t n)
int XLALCompareREAL4Vectors(VectorComparison *result, const REAL4Vector *x, const REAL4Vector *y, const VectorComparison *tol)
Compare two REAL4 vectors using various different comparison metrics.
REAL4 XLALComputeBSGLtL(const REAL4 twoF, const REAL4 twoFX[PULSAR_MAX_DETECTORS], const REAL4 maxtwoFlX[PULSAR_MAX_DETECTORS], const BSGLSetup *setup)
Single-bin wrapper of XLALVectorComputeBSGLtL(), provided for backwards compatibility.
REAL4 XLALComputeBtSGLtL(const REAL4 maxtwoFl, const REAL4 twoFX[PULSAR_MAX_DETECTORS], const REAL4 maxtwoFXl[PULSAR_MAX_DETECTORS], const BSGLSetup *setup)
Single-bin wrapper of XLALVectorComputeBtSGLtL(), provided for backwards compatibility.
REAL4 XLALComputeBSGL(const REAL4 twoF, const REAL4 twoFX[PULSAR_MAX_DETECTORS], const BSGLSetup *setup)
Single-bin wrapper of XLALVectorComputeBSGL(), provided for backwards compatibility.
#define PULSAR_MAX_DETECTORS
maximal number of detectors we can handle (for static arrays of detector quantities)
#define PULSAR_MAX_SPINS
maximal number of spin-parameters (Freq + spindowns) we can handle
int XLALConvertPhysicalToSuperskyPoint(gsl_vector *out_rssky, const PulsarDopplerParams *in_phys, const SuperskyTransformData *rssky_transf)
Convert a point from physical to supersky coordinates.
REAL4Vector * XLALCreateREAL4Vector(UINT4 length)
void XLALDestroyUINT4Vector(UINT4Vector *vector)
UINT4Vector * XLALResizeUINT4Vector(UINT4Vector *vector, UINT4 length)
void XLALDestroyREAL4Vector(REAL4Vector *vector)
int XLALVectorFindScalarLessEqualREAL4(UINT4 *count, UINT4 *out, REAL4 scalar, const REAL4 *in, const UINT4 len)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK(assertion,...)
#define XLAL_TRY(statement, errnum)
#define XLAL_CHECK_NULL(assertion,...)
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
PulsarSpins fkdot
Intrinsic spins: [Freq, f1dot, f2dot, ... ] where fkdot = d^kFreq/dt^k.
REAL8 Delta
Sky position: DEC (latitude) in equatorial coords and radians.
REAL8 Alpha
Sky position: RA (longitude) in equatorial coords and radians.
Struct holding the results of comparing two floating-point vectors (real-valued or complex),...
Toplist of output results.
WeaveResultsToplistItemSetRankStat item_set_rank_stat_fcn
Function which sets the value of the statistic by which toplist items are ranked.
UINT4Vector * maybe_add_freq_idxs
Vector of indexes of toplist results which should be considered for addition.
WeaveResultsToplistItem * saved_item
Save a no-longer-used toplist item for re-use.
const char * stat_desc
Description of ranking statistic.
UINT8 serial
Serial number which is incremented for each item.
size_t nspins
Number of spindown parameters to output.
const char * stat_name
Name of ranking statistic.
WeaveResultsToplistItemGetRankStat item_get_rank_stat_fcn
Function which returns the value of the statistic by which toplist items are ranked.
WeaveStatisticsParams * statistics_params
Struct holding all parameters for which statistics to output and compute, when, and how NOTE: this is...
LALHeap * heap
Heap which ranks toplist items.
WeaveResultsToplistRankingStats rank_stats_fcn
Function which returns pointer to array of statistics by which toplist items are ranked.