/// /// Compute the extent of the bounding box of the mismatch ellipse of a metric \f$ g_{ij} \f$. /// gsl_vector *XLALMetricEllipseBoundingBox( const gsl_matrix *g_ij, ///< [in] Parameter-space metric \f$ g_{ij} \f$ const double max_mismatch ///< [in] Maximum prescribed mismatch ) { // Check input XLAL_CHECK_NULL( g_ij != NULL, XLAL_EFAULT ); XLAL_CHECK_NULL( g_ij->size1 == g_ij->size2, XLAL_ESIZE ); const size_t n = g_ij->size1; // Allocate memory gsl_matrix *GAMAT_NULL( LU_decomp, n, n ); gsl_permutation *GAPERM_NULL( LU_perm, n ); gsl_matrix *GAMAT_NULL( diag_norm, n, n ); gsl_matrix *GAMAT_NULL( inverse, n, n ); gsl_vector *GAVEC_NULL( bounding_box, n ); // Diagonally normalize metric XLAL_CHECK_NULL( XLALDiagNormalizeMetric( &LU_decomp, &diag_norm, g_ij ) == XLAL_SUCCESS, XLAL_EFUNC ); // Compute metric inverse int LU_sign = 0; XLAL_CHECK_NULL( gsl_linalg_LU_decomp( LU_decomp, LU_perm, &LU_sign ) == 0, XLAL_EFAILED, "'g_ij' cannot be LU-decomposed" ); XLAL_CHECK_NULL( gsl_linalg_LU_invert( LU_decomp, LU_perm, inverse ) == 0, XLAL_EFAILED, "'g_ij' cannot be inverted" ); // Compute bounding box, and invert diagonal normalization for( size_t i = 0; i < n; ++i ) { const double diag_norm_i = gsl_matrix_get( diag_norm, i, i ); const double bounding_box_i = 2.0 * sqrt( max_mismatch * gsl_matrix_get( inverse, i, i ) ) * diag_norm_i; gsl_vector_set( bounding_box, i, bounding_box_i ); } // Cleanup GFMAT( LU_decomp, diag_norm, inverse ); GFPERM( LU_perm ); return bounding_box; } // XLALMetricEllipseBoundingBox()
int XLALOutputDopplerMetric ( FILE *fp, const DopplerPhaseMetric *Pmetric, const DopplerFstatMetric *Fmetric, const ResultHistory_t *history ) { UINT4 i; REAL8 A, B, C, D; // ----- input sanity checks XLAL_CHECK ( fp != NULL, XLAL_EFAULT ); XLAL_CHECK ( Pmetric != NULL || Fmetric != NULL, XLAL_EFAULT ); const DopplerMetricParams *meta = (Pmetric != NULL) ? &(Pmetric->meta) : &(Fmetric->meta); XLAL_CHECK ( XLALSegListIsInitialized ( &(meta->segmentList) ), XLAL_EINVAL, "Got un-initialized segment list in 'metric->meta.segmentList'\n" ); UINT4 Nseg = meta->segmentList.length; XLAL_CHECK ( Nseg >= 1, XLAL_EDOM, "Got invalid zero-length segment list 'metric->meta.segmentList'\n" ); /* useful shortcuts */ const PulsarDopplerParams *doppler = &(meta->signalParams.Doppler); const PulsarAmplitudeParams *Amp = &(meta->signalParams.Amp); /* output history info */ if ( history ) { if ( history->app_name ) fprintf (fp, "%%%% app_name: %s\n", history->app_name ); if ( history->cmdline) fprintf (fp, "%%%% commandline: %s\n", history->cmdline ); if ( history->VCSInfoString ) fprintf (fp, "%%%% Code Version: %s\n", history->VCSInfoString ); } fprintf ( fp, "DopplerCoordinates = { " ); for ( i=0; i < meta->coordSys.dim; i ++ ) { if ( i > 0 ) fprintf ( fp, ", " ); fprintf ( fp, "\"%s\"", XLALDopplerCoordinateName(meta->coordSys.coordIDs[i])); } fprintf ( fp, "};\n"); { /* output projection info */ const char *pname; if ( meta->projectCoord < 0 ) pname = "None"; else pname = XLALDopplerCoordinateName ( meta->coordSys.coordIDs[meta->projectCoord] ); fprintf ( fp, "%%%% Projection onto subspace orthogonal to coordinate: '%s'\n", pname); } fprintf ( fp, "%%%% DetectorMotionType = '%s'\n", XLALDetectorMotionName(meta->detMotionType) ); fprintf ( fp, "h0 = %g;\ncosi = %g;\npsi = %g;\nphi0 = %g;\n", Amp->h0, Amp->cosi, Amp->psi, Amp->phi0 ); fprintf ( fp, "%%%% DopplerPoint = {\n"); fprintf ( fp, "refTime = %.1f;\n", XLALGPSGetREAL8 ( &doppler->refTime ) ); fprintf ( fp, "Alpha = %f;\nDelta = %f;\n", doppler->Alpha, doppler->Delta ); fprintf ( fp, "fkdot = [%f, %g, %g, %g ];\n", doppler->fkdot[0], doppler->fkdot[1], doppler->fkdot[2], doppler->fkdot[3] ); if ( doppler->asini > 0 ) { fprintf ( fp, "%%%% orbit = { \n"); fprintf ( fp, "%%%% tp = {%d, %d}\n", doppler->tp.gpsSeconds, doppler->tp.gpsNanoSeconds ); fprintf ( fp, "%%%% argp = %g\n", doppler->argp ); fprintf ( fp, "%%%% asini = %g\n", doppler->asini ); fprintf ( fp, "%%%% ecc = %g\n", doppler->ecc ); fprintf ( fp, "%%%% period = %g\n", doppler->period ); fprintf ( fp, "%%%% }\n"); } /* if doppler->orbit */ fprintf ( fp, "%%%% }\n"); LIGOTimeGPS *tStart = &(meta->segmentList.segs[0].start); LIGOTimeGPS *tEnd = &(meta->segmentList.segs[Nseg-1].end); REAL8 Tspan = XLALGPSDiff ( tEnd, tStart ); fprintf ( fp, "startTime = %.1f;\n", XLALGPSGetREAL8 ( tStart ) ); fprintf ( fp, "Tspan = %.1f;\n", Tspan ); fprintf ( fp, "Nseg = %d;\n", Nseg ); fprintf ( fp, "detectors = {"); for ( i=0; i < meta->multiIFO.length; i ++ ) { if ( i > 0 ) fprintf ( fp, ", "); fprintf ( fp, "\"%s\"", meta->multiIFO.sites[i].frDetector.name ); } fprintf ( fp, "};\n"); fprintf ( fp, "detectorWeights = ["); for ( i=0; i < meta->multiNoiseFloor.length; i ++ ) { if ( i > 0 ) fprintf ( fp, ", "); fprintf ( fp, "%f", meta->multiNoiseFloor.sqrtSn[i] ); } fprintf ( fp, "];\n"); /* ----- output phase metric ---------- */ if ( Pmetric != NULL ) { fprintf ( fp, "\ng_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, Pmetric->g_ij ); fprintf ( fp, "maxrelerr_gPh = %.2e;\n", Pmetric->maxrelerr ); gsl_matrix *gN_ij = NULL; if ( XLALNaturalizeMetric ( &gN_ij, NULL, Pmetric->g_ij, meta ) != XLAL_SUCCESS ) { XLALPrintError ("%s: something failed Naturalizing phase metric g_ij!\n", __func__ ); XLAL_ERROR ( XLAL_EFUNC ); } fprintf ( fp, "\ngN_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, gN_ij ); gsl_matrix_free ( gN_ij ); gsl_matrix *gDN_ij = NULL; if ( XLALDiagNormalizeMetric ( &gDN_ij, NULL, Pmetric->g_ij ) != XLAL_SUCCESS ) { XLALPrintError ("%s: something failed NormDiagonalizing phase metric g_ij!\n", __func__ ); XLAL_ERROR ( XLAL_EFUNC ); } fprintf ( fp, "\ngDN_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, gDN_ij ); gsl_matrix_free ( gDN_ij ); } /* ----- output F-metric (and related matrices ---------- */ if ( Fmetric != NULL ) { fprintf ( fp, "\ngF_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, Fmetric->gF_ij ); fprintf ( fp, "\ngFav_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, Fmetric->gFav_ij ); fprintf ( fp, "\nm1_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, Fmetric->m1_ij ); fprintf ( fp, "\nm2_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, Fmetric->m2_ij ); fprintf ( fp, "\nm3_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, Fmetric->m3_ij ); fprintf ( fp, "maxrelerr_gF = %.2e;\n", Fmetric->maxrelerr ); } /* ----- output Fisher matrix ---------- */ if ( Fmetric != NULL && Fmetric->Fisher_ab != NULL ) { A = gsl_matrix_get ( Fmetric->Fisher_ab, 0, 0 ); B = gsl_matrix_get ( Fmetric->Fisher_ab, 1, 1 ); C = gsl_matrix_get ( Fmetric->Fisher_ab, 0, 1 ); D = A * B - C * C; fprintf ( fp, "\nA = %.16g;\nB = %.16g;\nC = %.16g;\nD = %.16g;\n", A, B, C, D ); fprintf ( fp, "\nrho2 = %.16g;\n", Fmetric->rho2 ); fprintf (fp, "\nFisher_ab = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, Fmetric->Fisher_ab ); } // ---------- output segment list at the end, as this can potentially become quite long and distracting char *seglist_octave; XLAL_CHECK ( (seglist_octave = XLALSegList2String ( &(meta->segmentList) )) != NULL, XLAL_EFUNC, "XLALSegList2String() with xlalErrno = %d\n", xlalErrno ); fprintf ( fp, "\n\nsegmentList = %s;\n", seglist_octave ); XLALFree ( seglist_octave ); return XLAL_SUCCESS; } /* XLALOutputDopplerMetric() */