Commit 8c88546a authored by Miroslav Shaltev's avatar Miroslav Shaltev
Browse files

begin work on cache inspector

parent 78ad8b73
......@@ -14,6 +14,7 @@ AC_CONFIG_FILES([\
src/GoodiesAndClones/Makefile \
src/FollowUp/Gsl/Makefile \
src/FollowUp/Nomad/Makefile \
src/FollowUp/AfterMath/Makefile \
src/SearchOptimization/Makefile
])
AM_INIT_AUTOMAKE([1.11 foreign color-tests parallel-tests])
......
/*
* Copyright (C) 2012 Miroslav Shaltev.
*
* May include code snippets by:
* Holger Pletsch, Karl Wette, Reinhard Prix,
* Badri Krishnan, Alicia Sintes, Bernd Machenschalk.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with with program; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*/
/*********************************************************************************/
/** \author Miroslav Shaltev
* \file
* \ingroup pulsarApps
* \brief Fully-coherent extremum finder using NOMAD algorithm.
* This code is forked from Hierarchical semicoherent CW search code based on F-Statistic,
* exploiting global-correlation coordinates (Phys.Rev.Lett. 103, 181102, 2009)
* by Holger Pletsch.
*
*********************************************************************************/
#include "AfterMath.h"
using namespace std;
#define FNAMEIN "./aftermath.in" /**< Default output file basename */
#define FNAMEOUT "./aftermath.out" /**< Default output file basename */
#ifndef LAL_INT4_MAX
#define LAL_INT4_MAX 2147483647
#endif
#define BLOCKSIZE_REALLOC 50
AFTERMath *MAFTERMath;
static UserInput_t empty_UserInput;
/* ################################### MAIN ##################################### */
int main(int argc, char *argv[]) {
MAFTERMath = new AFTERMath(argc,argv);
MAFTERMath->XLALInitUserVars(argc,argv);
return EXIT_SUCCESS;
}
INT4 AFTERMath::XLALInitUserVars ( int argc, char *argv[] )
{
int ret;
uvar = &UserVariables;
/* set LAL error-handler */
lal_errhandler = LAL_ERR_EXIT;
uvar->fnamein = (char*)LALCalloc( strlen(FNAMEIN) + 1, sizeof(CHAR) );
strcpy(uvar->fnamein, FNAMEIN);
uvar->fnameout = (char*)LALCalloc( strlen(FNAMEOUT) + 1, sizeof(CHAR) );
strcpy(uvar->fnameout, FNAMEOUT);
/* register user input variables */
XLALRegisterUvarMember( version,BOOLEAN, 'V', SPECIAL, "Output version information");
XLALRegisterUvarMember( fnamein, STRING, 0, OPTIONAL, "Input filename");
XLALRegisterUvarMember( fnameout, STRING, 0, OPTIONAL, "Output filename");
XLALRegisterUvarMember( ephemEarth, STRING, 0, OPTIONAL, "Location of Earth ephemeris file");
XLALRegisterUvarMember( ephemSun, STRING, 0, OPTIONAL, "Location of Sun ephemeris file");
XLALRegisterUvarMember( segmentList, STRING, 0, OPTIONAL, "File containing a segment list used to compute Fisher ellipsoid: lines of form <startGPS endGPS duration[h] NumSFTs>");
/* read cmdline & cfgfile */
BOOLEAN should_exit = 0;
XLAL_CHECK( XLALUserVarReadAllInput( &should_exit, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
if ( should_exit ) {
exit (1);
}
if (uvar->help) // if user had requested help, then we're already done here
exit(0);
/* assemble version string */
if ( (VCSInfoString = XLALGetVersionString(0)) == NULL ) {
XLALPrintError("XLALGetVersionString(0) failed.\n");
return AFTERMATH_ESUB;
}
LogPrintfVerbatim( LOG_DEBUG, "Code-version: %s\n", VCSInfoString );
if ( uvar->version )
{
printf ("%s\n", VCSInfoString );
return 0;
}
edat = (EphemerisData *)LALCalloc(1, sizeof(EphemerisData));
if ( edat == NULL) {
fprintf(stderr, "error allocating memory [FStatNomad.cpp %d]\n" , __LINE__);
return(AFTERMATH_EMEM);
}
/* read in ephemeris data */
edat = XLALInitBarycenter(uvar->ephemEarth,uvar->ephemSun);
/* read the segment list */
segList = LocalXLALReadSegmentsFromFile(uvar->segmentList);
}
AFTERMath::AFTERMath(int argc, char *argv[]) {
/* ---------- Global variables -------------------- */
/* variables for logging */
uvar = NULL;
UserVariables = empty_UserInput; // initializes this struct to {0}
/* user variables */
edat = NULL;
}
AFTERMath::~AFTERMath() {}
/*
* Copyright (C) 2016 Miroslav Shaltev.
*
* May include code snippets by various individuals.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with with program; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*/
#ifndef _AFTERMATHH /* Double-include protection. */
#define _AFTERMATHH
#include <lal/LALConstants.h>
#include <lal/UserInput.h>
#include <lal/LALStdlib.h>
#include <lal/Date.h>
#include <lal/LogPrintf.h>
#include <lal/StringVector.h>
#include <lal/LALString.h>
#include <lal/UniversalDopplerMetric.h>
#include <lal/LALInitBarycenter.h>
/* lalapps includes */
#include <lalapps.h>
#define AFTERMATH_ENORM 0
#define AFTERMATH_ESUB 1
#define AFTERMATH_EARG 2
#define AFTERMATH_EBAD 3
#define AFTERMATH_EFILE 4
#define AFTERMATH_ENULL 5
#define AFTERMATH_EVAL 6
#define AFTERMATH_ENONULL 7
#define AFTERMATH_EDLOPEN 8
#define AFTERMATH_EWORKER 9
#define AFTERMATH_ECHECKPT 10
#define AFTERMATH_EMEM 11
#define AFTERMATH_ESFT 12
#define AFTERMATH_ECG 13
#define AFTERMATH_EXLAL 14
#define AFTERMATH_MSGENORM "Normal exit"
#define AFTERMATH_MSGESUB "Subroutine failed"
#define AFTERMATH_MSGEARG "Error parsing arguments"
#define AFTERMATH_MSGEBAD "Bad argument values"
#define AFTERMATH_MSGEFILE "Could not create output file"
#define AFTERMATH_MSGENULL "Null pointer"
#define AFTERMATH_MSGEVAL "Invalid value"
#define AFTERMATH_MSGENONULL "Pointer not null"
#define AFTERMATH_MSGECHECKPT "Could not resume from checkpoint"
#define AFTERMATH_MSGEMEM "Out of memory"
#define AFTERMATH_MSGESFT "SFT validity check failed"
#define AFTERMATH_MSGEXLAL "XLAL function call failed"
#define MTPHASE 0
#define MTAVFSTAT 1
#define TRUE (1==1)
#define FALSE (1==0)
#define USETYPE_SEARCH 0
#define USETYPE_EXTENDS 1
typedef enum {
STYPE_NONE = -1,
STYPE_ISO_ALPHA_DELTA,
STYPE_ISO_ALPHA_DELTA_FREQ_F1DOT,
STYPE_ISO_ALPHA_DELTA_FREQ_F1DOT_F2DOT,
STYPE_ISO_ALPHA_DELTA_FREQ_F1DOT_F2DOT_F3DOT,
STYPE_ISO_FREQ_F1DOT,
STYPE_ISO_FREQ_F1DOT_F2DOT,
STYPE_ISO_FREQ_F1DOT_F2DOT_F3DOT,
STYPE_BNS_ALPHA_DELTA_FREQ_ASINI_TASC_OMEGA_KAPPA_ETA,
STYPE_BNS_ALPHA_DELTA_FREQ_F1DOT_ASINI_TASC_OMEGA_KAPPA_ETA,
STYPE_BNS_ALPHA_DELTA_FREQ_F1DOT_F2DOT_ASINI_TASC_OMEGA_KAPPA_ETA,
STYPE_BNS_ALPHA_DELTA_FREQ_F1DOT_F2DOT_F3DOT_ASINI_TASC_OMEGA_KAPPA_ETA,
STYPE_BNS_FREQ_ASINI_TASC_OMEGA_KAPPA_ETA,
STYPE_BNS_FREQ_F1DOT_ASINI_TASC_OMEGA_KAPPA_ETA,
STYPE_BNS_FREQ_F1DOT_F2DOT_ASINI_TASC_OMEGA_KAPPA_ETA,
STYPE_BNS_FREQ_F1DOT_F2DOT_F3DOT_ASINI_TASC_OMEGA_KAPPA_ETA
} STypeID;
/******************************************************
* Protection against C++ name mangling
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
BOOLEAN help;
BOOLEAN version;
CHAR *fnamein;
CHAR *fnameout;
CHAR *ephemEarth;
CHAR *ephemSun;
CHAR *segmentList;
} UserInput_t;
#ifdef __cplusplus
} /* Close C++ protection */
#endif
typedef struct {
REAL8 alpha;
REAL8 delta;
REAL8 freq;
REAL8 f1dot;
REAL8 f2dot;
REAL8 f3dot;
LIGOTimeGPS TpSSB;
REAL8 argp;
REAL8 asini;
REAL8 ecc;
REAL8 period;
REAL8 stat;
REAL8 h0;
REAL8 cosi;
REAL8 psi;
REAL8 phi0;
} ExPoint;
typedef struct
{
EphemerisData *edat; /**< ephemeris data (from XLALInitBarycenter()) */
LIGOTimeGPS startTime; /**< start time of observation */
PulsarParams signalParams; /**< GW signal parameters: Amplitudes + doppler */
MultiLALDetector multiIFO; //!< detectors to generate data for
MultiNoiseFloor multiNoiseFloor; //!< ... and corresponding noise-floors to generate Gaussian white noise for
DopplerCoordinateSystem coordSys; /**< array of enums describing Doppler-coordinates to compute metric in */
} CMConfigVariables;
void PrintPoint(INT4 nseg,const ExPoint *p,const CHAR* msg, BOOLEAN bns);
LALSegList *LocalXLALReadSegmentsFromFile ( const char *fname );
class AFTERMath {
public:
AFTERMath(int argc, char *argv[]);
virtual ~AFTERMath();
virtual INT4 XLALInitUserVars( int argc, char *argv[]);
UserInput_t UserVariables;
UserInput_t *uvar;
void BinarySearch(BOOLEAN v) {
var_BinarySearch = v;
};
BOOLEAN BinarySearch() {
return var_BinarySearch;
};
void MetricIFO(LALStringVector* v) {
var_MetricIFO = v;
};
private:
CHAR *VCSInfoString;
BOOLEAN var_BinarySearch;
LALStringVector* var_MetricIFO;
EphemerisData *edat;
LALSegList *segList;
INT4 compute_phase_metric(DopplerPhaseMetric *phase_metric, gsl_matrix *g, LALSegList *seglist, LIGOTimeGPS refTimeGPS, INT4 MType, ExPoint *p, INT4 EType);
INT4 compute_fstat_metric(DopplerFstatMetric *fstat_metric, gsl_matrix *g, LALSegList *seglist, LIGOTimeGPS refTimeGPS, INT4 SType, ExPoint *p, INT4 EType);
BOOLEAN check_matrix(gsl_matrix *g);
void DoDisplayMetric(gsl_matrix *m);
};
#endif /* Double-include protection. */
#include "AfterMath.h"
/** Function to read a segment list from given filename, returns a *sorted* SegmentList
*
* The segment-list format parse here is consistent with Xavie's segment lists used previously
* and follows the format <repeated lines of form "startGPS endGPS duration[h] NumSFTs">,
* allowed comment-characters are '%' and '#'
*
* \note we (ab)use the integer 'id' field in LALSeg to carry the total number of SFTs
* contained in that segment. This will be used as a consistency check in
* XLALSetUpStacksFromSegmentList().
*
*/
LALSegList *
LocalXLALReadSegmentsFromFile ( const char *fname /**< name of file containing segment list */
)
{
const char *fn = __func__;
LALSegList *segList = NULL;
/** check input consistency */
if ( !fname ) {
XLALPrintError ( "%s: NULL input 'fname'", fn );
XLAL_ERROR_NULL ( XLAL_EINVAL );
}
/* read and parse segment-list file contents*/
LALParsedDataFile *flines = NULL;
if ( XLALParseDataFile ( &flines, fname ) != XLAL_SUCCESS )
XLAL_ERROR_NULL ( XLAL_EFUNC );
UINT4 numSegments = flines->lines->nTokens;
/* allocate and initialized segment list */
if ( (segList = (LALSegList*)XLALCalloc ( 1, sizeof(*segList) )) == NULL )
XLAL_ERROR_NULL ( XLAL_ENOMEM );
if ( XLALSegListInit ( segList ) != XLAL_SUCCESS )
XLAL_ERROR_NULL ( XLAL_EFUNC );
UINT4 iSeg;
for ( iSeg = 0; iSeg < numSegments; iSeg ++ )
{
REAL8 t0, t1, TspanHours;
INT4 NSFT;
LALSeg thisSeg;
int ret;
ret = sscanf ( flines->lines->tokens[iSeg], "%lf %lf %lf %d", &t0, &t1, &TspanHours, &NSFT );
if ( ret != 4 ) {
XLALPrintError ("%s: failed to parse data-line %d (%d) in segment-list %s: '%s'\n", fn, iSeg, ret, fname, flines->lines->tokens[iSeg] );
XLALSegListClear ( segList );
XLALFree ( segList );
XLALDestroyParsedDataFile ( flines );
XLAL_ERROR_NULL ( XLAL_ESYS );
}
/* check internal consistency of these numbers */
REAL8 hours = 3600.0;
if ( fabs ( t1 - t0 - TspanHours * hours ) >= 1.0 ) {
XLALPrintError ("%s: Inconsistent segment list, in line %d: t0 = %f, t1 = %f, Tspan = %f != t1 - t0 (to within 1s)\n", fn, iSeg, t0, t1, TspanHours );
XLAL_ERROR_NULL ( XLAL_EDOM );
}
LIGOTimeGPS start, end;
XLALGPSSetREAL8( &start, t0 );
XLALGPSSetREAL8( &end, t1 );
/* we set number of SFTs as 'id' field, as we have no other use for it */
if ( XLALSegSet ( &thisSeg, &start, &end, NSFT ) != XLAL_SUCCESS )
XLAL_ERROR_NULL ( XLAL_EFUNC );
if ( XLALSegListAppend ( segList, &thisSeg ) != XLAL_SUCCESS )
XLAL_ERROR_NULL ( XLAL_EFUNC );
} /* for iSeg < numSegments */
/* sort final segment list in increasing GPS start-times */
if ( XLALSegListSort( segList ) != XLAL_SUCCESS )
XLAL_ERROR_NULL ( XLAL_EFUNC );
/* free parsed segment file contents */
//if ( XLALDestroyParsedDataFile ( flines ) != XLAL_SUCCESS ) XLAL_ERROR_NULL ( XLAL_EFUNC );
return segList;
} /* XLALReadSegmentsFromFile() */
This diff is collapsed.
## Process this file with automake to produce Makefile.in
# $Id$
# for using lalapps-defines + functions
AM_CPPFLAGS = -I$(top_srcdir)/src/lalapps
LDADD = $(top_builddir)/src/lalapps/liblalapps.la
bin_PROGRAMS = cwsof_AfterMath
AFTERMATHSources = AfterMath.cpp AfterMath_helper.cpp AfterMath_metric.cpp AfterMath.h
cwsof_AfterMath.o:AfterMath.cpp
$(CXX) $(CPPFLAGS) $(CFLAGS) -c AfterMath.cpp
cwsof_AfterMath_SOURCES = $(AFTERMATHSources)
cwsof_AfterMath_CFLAGS = $(AM_CFLAGS) -O3 -funroll-loops -msse -msse2 -mfpmath=sse -march=core2
cwsof_AfterMath_CPPFLAGS = $(AM_CPPFLAGS) -fpermissive
cwsof_AfterMath_LDFLAGS = $(AM_LDFLAGS)
## make sure lalapps.la is rebuilt when appropriate
BUILT_SOURCES =
include $(top_srcdir)/misc/vcsID.common
TESTS_ENVIRONMENT = \
LALSUITE_TOP_SRCDIR=$(LALSUITE_TOP_SRCDIR) \
LAL_DATA_PATH=.:$${LALPULSAR_PREFIX:+"$${LALPULSAR_PREFIX}/share/lalpulsar"}:$${LALSUITE_TOP_SRCDIR:+"$${LALSUITE_TOP_SRCDIR}/lalpulsar/test/"}
CLEANFILES =
TESTS =
SUBDIRS = lalapps \
GoodiesAndClones \
FollowUp/Gsl
FollowUp/Gsl \
FollowUp/AfterMath
if NOMAD
SUBDIRS += SearchOptimization \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment