diff --git a/00boot b/00boot index 2ef0160784bcdd7284fee73f21eca8208ef6506e..cc2a61680e0a2e698d11fc0e061d71a7817d2154 100755 --- a/00boot +++ b/00boot @@ -8,7 +8,7 @@ fail () { } ## Run 00boot in subdirs -for d in lal lalapps; do +for d in lal lalframe lalxml lalstochastic lalapps; do echo "00boot: running 00boot in $d" (cd "$d" && ./00boot 1>/dev/null) || fail "00boot in $d" done diff --git a/Makefile.am b/Makefile.am index 74c89eb438f92876e6719ddff3e010f2fcf5ecd2..f5b6531e295b57ecace621caea8a589b9db7ff40 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,6 @@ ACLOCAL_AMFLAGS = -I lal/misc SUBDIRS = @subdirs@ +distcleancheck_listfiles = find . -type f \! -name "LALVCSInfo.h" -print MAINTAINERCLEANFILES = lalsuite.spec vcs-clean: cvs-clean cvs-clean: maintainer-clean diff --git a/configure.ac b/configure.ac index 126e6ef5fb771d1a3dde2dd692e90100a62b1e52..47a0d28e17cfab053684a900b6d7a7422b7d35d1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([lalsuite],[6.2],[lal-discuss@gravity.phys.uwm.edu]) +AC_INIT([lalsuite],[6.4],[lal-discuss@gravity.phys.uwm.edu]) AC_CONFIG_SRCDIR([lal/configure.ac]) AC_CONFIG_AUX_DIR([lal/misc]) AC_CONFIG_MACRO_DIR([lal/misc]) @@ -7,71 +7,52 @@ AC_CONFIG_FILES([lalsuite.spec]) AM_INIT_AUTOMAKE([foreign]) AC_PREFIX_DEFAULT([/opt/lscsoft/lalsuite]) -LAL_ENABLE_FRAME LAL_ENABLE_METAIO -LAL_ENABLE_XML -AM_PROG_LIBTOOL +AC_PROG_LIBTOOL lalsuite_top_builddir='$(top_builddir)/..' +lalsuite_top_srcdir='$(top_srcdir)/..' LALSUITE_BUILD="true" LAL_LIBS="${lalsuite_top_builddir}/lal/lib/liblal.la" LAL_CFLAGS="-I${lalsuite_top_builddir}/lal/include" -export LALSUITE_BUILD LAL_LIBS LAL_CFLAGS +LAL_TOP_SRCDIR="${lalsuite_top_srcdir}/lal" +export LALSUITE_BUILD LAL_LIBS LAL_CFLAGS LAL_TOP_SRCDIR LALSUPPORT_LIBS="${lalsuite_top_builddir}/lal/packages/support/src/liblalsupport.la" export LALSUPPORT_LIBS -LALSTOCHASTIC_LIBS="${lalsuite_top_builddir}/lal/packages/stochastic/src/liblalstochastic.la" -export LALSTOCHASTIC_LIBS +LALMETAIO_LIBS="${lalsuite_top_builddir}/lal/packages/support/src/liblalmetaio.la" +export LALMETAIO_LIBS +LALFRAME_LIBS="${lalsuite_top_builddir}/lalframe/src/liblalframe.la" +LALFRAME_CFLAGS="-I${lalsuite_top_builddir}/lalframe/include" +export LALFRAME_LIBS LALFRAME_CFLAGS +LALXML_LIBS="${lalsuite_top_builddir}/lalxml/src/liblalxml.la" +LALXML_CFLAGS="-I${lalsuite_top_builddir}/lalxml/include" +export LALXML_LIBS LALXML_CFLAGS +LALSTOCHASTIC_LIBS="${lalsuite_top_builddir}/lalstochastic/src/liblalstochastic.la" +LALSTOCHASTIC_CFLAGS="-I${lalsuite_top_builddir}/lalstochastic/include" +export LALSTOCHASTIC_LIBS LALSTOCHASTIC_CFLAGS -if test "$frame" = "true" ; then - LIBS_save="$LIBS" - CPPFLAGS_save="$CPPFLAGS" - PKG_CHECK_MODULES(FRAME, libframe, [ true ], [ false ]) - LIBS="$FRAME_LIBS $LIBS" - CPPFLAGS="$CPPFLAGS $FRAME_CFLAGS" - AC_SEARCH_LIBS(FrLibIni, Frame, , [AC_MSG_WARN(disabling framelib support)] - [frame="false"]) - CPPFLAGS="$CPPFLAGS_save" - LIBS="$LIBS_save" -fi if test "$metaio" = "true" ; then - LIBS_save="$LIBS" - CPPFLAGS_save="$CPPFLAGS" - PKG_CHECK_MODULES(METAIO, libmetaio, [ true ], [ false ]) - LIBS="$METAIO_LIBS $LIBS" - CPPFLAGS="$CPPFLAGS $METAIO_CFLAGS" - AC_SEARCH_LIBS(MetaioOpen, metaio dataflow, , [AC_MSG_WARN(disabling metaio support)] - [metaio="false"]) - CPPFLAGS="$CPPFLAGS_save" - LIBS="$LIBS_save" - LIBS_save="$LIBS" - CPPFLAGS_save="$CPPFLAGS" -fi -if test "$xml" = "true" ; then - PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= 2.6, [ true ], [ false ]) - LIBS="$LIBXML2_LIBS $LIBS" - CPPFLAGS="$CPPFLAGS $LIBXML2_CFLAGS" - AC_SEARCH_LIBS(xmlInitParser, xml2, , [AC_MSG_WARN(disabling xml support)] - [xml="false"]) - CPPFLAGS="$CPPFLAGS_save" - LIBS="$LIBS_save" + LIBS_save="$LIBS" + CPPFLAGS_save="$CPPFLAGS" + PKG_CHECK_MODULES([METAIO],[libmetaio],[true],[false]) + LIBS="$METAIO_LIBS $LIBS" + CPPFLAGS="$CPPFLAGS $METAIO_CFLAGS" + AC_SEARCH_LIBS([MetaioOpen],[metaio],,[AC_MSG_WARN([disabling metaio support])] + [metaio="false"]) + CPPFLAGS="$CPPFLAGS_save" + LIBS="$LIBS_save" fi -if test "$frame" = "true" ; then - LALFRAME_LIBS="${lalsuite_top_builddir}/lal/packages/framedata/src/liblalframe.la" - export LALFRAME_LIBS - -fi if test "$metaio" = "true" ; then - LALMETAIO_LIBS="${lalsuite_top_builddir}/lal/packages/support/src/liblalmetaio.la" - export LALMETAIO_LIBS -fi -if test "$xml" = "true" ; then - LALXML_LIBS="${lalsuite_top_builddir}/lal/packages/support/src/liblalxml.la" - export LALXML_LIBS + LALMETAIO_LIBS="${lalsuite_top_builddir}/lal/packages/support/src/liblalmetaio.la" + export LALMETAIO_LIBS fi AC_CONFIG_SUBDIRS([lal]) +AC_CONFIG_SUBDIRS([lalframe]) +AC_CONFIG_SUBDIRS([lalxml]) +AC_CONFIG_SUBDIRS([lalstochastic]) AC_CONFIG_SUBDIRS([lalapps]) AC_OUTPUT diff --git a/debian/rules b/debian/rules index 6278700fd72ddce9311320d8568ce655828dd9c2..06407e856c906c334c89979d52924dfbcb4d66e6 100755 --- a/debian/rules +++ b/debian/rules @@ -45,7 +45,8 @@ config.status : configure --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info \ --enable-nightly=no \ --enable-frame --enable-metaio \ - --disable-debug + --disable-debug \ + --disable-gcc-flags #DEBUG# #ls -lR #DEBUG# diff --git a/glue/MANIFEST.in b/glue/MANIFEST.in index decb35476202dc6d248b063e9cdf0e433532873b..3862b14745bf0ac26b3dfaf96388e98ae75b103c 100644 --- a/glue/MANIFEST.in +++ b/glue/MANIFEST.in @@ -11,6 +11,7 @@ include src/conf/s6_qreplication/lho/* include src/conf/s6_qreplication/llo/* include src/conf/s6_qreplication/cit/* include src/php/README +include src/php/dq_report/* include src/php/seginsert/* include src/php/seginsert/img/* include src/php/seginsert/scripts/* diff --git a/glue/bin/LSCdataFindcheck b/glue/bin/LSCdataFindcheck index 1d33813fe3174af1f33561dce16496f88571c549..59fc5130584b932de04c5dc613d8cf519ad5f17f 100644 --- a/glue/bin/LSCdataFindcheck +++ b/glue/bin/LSCdataFindcheck @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -37,15 +37,16 @@ import os import sys +from glue import git_version from glue.lal import CacheEntry from glue.lal import LIGOTimeGPS from glue import segments from glue import segmentsUtils -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -72,7 +73,9 @@ def write_error_lines(lines): def parse_command_line(): - parser = OptionParser(version = "%prog CVS $Id$") + parser = OptionParser( + version = "Name: %%prog\n%s" % git_version.verbose_msg + ) parser.add_option("--segwizard-segments", metavar = "filename", help = "Read segments to check from the named segwizard-format text file.") parser.add_option("--gps-start-time", metavar = "seconds", help = "Check a single segment starting at this time (must also set --gps-end-time).") parser.add_option("--gps-end-time", metavar = "seconds", help = "Check a single segment ending at this time (must also set --gps-start-time).") diff --git a/glue/bin/dmtdq_seg_insert b/glue/bin/dmtdq_seg_insert index 12d7d1e98575e3f5fd9d7e18cbc98250f4494b65..86cc8ca0a9f7e2121cfb3b088b33a2030c55bd33 100644 --- a/glue/bin/dmtdq_seg_insert +++ b/glue/bin/dmtdq_seg_insert @@ -29,6 +29,7 @@ import exceptions import re try: + from glue import LDBDWClient from glue import LDBDClient from glue import gsiserverutils except ImportError, e: @@ -102,6 +103,26 @@ if not hostPortString: print >>sys.stderr, "Enter 'dmtdq_seg_insert --help' for usage" sys.exit(1) +def openconn(host,port,identity): + if port != 443: + try: + myClient = LDBDClient.LDBDClient(host, port, identity) + + except Exception, e: + print >>sys.stderr, \ + "Unable to connect to LDBDServer %s:%d" % (host, port) + if gsiserverutils.checkCredentials(): + print >>sys.stderr, "Got the following error : " + str(e) + print >>sys.stderr, "Enter '%s --help' for usage" % sys.argv[0] + sys.exit(1) + else: + try: + myClient = LDBDWClient.LDBDClient(host, port, identity) + except Exception,e: + print >>sys.stderr, "Unable to connect to LDBDServer %s:%d, %s" % (host, port, str(e)) + sys.exit(1) + return myClient + if hostPortString.find(':') < 0: # no port specified host = hostPortString @@ -118,7 +139,7 @@ if not ping and not infile: # open connection to LDBD Server identity = "/DC=org/DC=doegrids/OU=Services/CN=ldbd/%s" % host try: - myClient = LDBDClient.LDBDClient(host, port, identity) + myClient = openconn(host, port, identity) except Exception, e: print >>sys.stderr, \ diff --git a/glue/bin/gracedb b/glue/bin/gracedb old mode 100755 new mode 100644 index 47ae45a4a822ca3f41014c7b51810146848bf655..fd805242d0e92ad3b2342c4148f919878311e53b --- a/glue/bin/gracedb +++ b/glue/bin/gracedb @@ -6,6 +6,21 @@ import os, sys DEFAULT_SERVICE_URL = "https://archie.phys.uwm.edu/gracedb/cli" +#----------------------------------------------------------------- +# Util routines + +def error(*message): + message = "".join(message) + "\n" + sys.stderr.write("ERROR: " + message) + +def warning(*message): + message = "".join(message) + "\n" + sys.stderr.write("WARNING: " + message) + +def output(*message): + message = "".join(message) + "\n" + sys.stdout.write(message) + #----------------------------------------------------------------- # HTTP/S Proxy classses # Taken from: http://code.activestate.com/recipes/456195/ @@ -156,14 +171,14 @@ def checkProxy(fname): cert.get_ext('proxyCertInfo') except LookupError: # Really, there shouldn't be an undefined extension. - print "Warning: You seem to be using a pre-RFC proxy." - print "Try doing grid-proxy-init -rfc" + warning("Warning: You seem to be using a pre-RFC proxy.\n" + "Try doing grid-proxy-init -rfc") except ImportError: - print "Warning: Cannot load M2Crypto. Not able to check proxy" - print " If you are getting errors, perhaps you are not using" - print ' an RFC compliant proxy. Did you do "grid-proxy-init -rfc"?' - print "To enable proxy checking, install m2crypto (CentOS, RedHat)," - print "python-m2crypto (Debian) or py25-m2crypto (MacPorts)" + warning("Warning: Cannot load M2Crypto. Not able to check proxy\n" + " If you are getting errors, perhaps you are not using\n" + ' an RFC compliant proxy. Did you do "grid-proxy-init -rfc"?\n' + "To enable proxy checking, install m2crypto (CentOS, RedHat),\n" + "python-m2crypto (Debian) or py25-m2crypto (MacPorts)") def findUserCredentials(warnOnOldProxy=1): @@ -219,36 +234,56 @@ class Client: key_file=key, cert_file=cert) self.url = url - def send(self, method, **kw): + def send(self, method, httpmethod="POST", **kw): try: kw['cli'] = 'true' + kw['cli_version'] = "1" kw = urllib.urlencode(kw) + headers = {'connection' : 'keep-alive'} url = "%s/%s" % (self.url, method) - self.conn.request("POST", url, kw, {}) - return self.conn.getresponse().read() + self.conn.request(httpmethod, url, kw, headers) + response = self.conn.getresponse() + rv = response.read() + except Exception, e: + return { 'error': "client send exception: " + str(e) } + # XXX Bad! Should be JSON conversion + try: + return eval(rv) except Exception, e: - return "ERROR: " + str(e) + return {'error': "while parsing:%s\nclient send exception: %s" % (rv, str(e))} def upload(self, method, fields, files): + # Do an tiny GET request to get SSL primed. + # Large initial SSL/POST requests will choke the server. + r = self.send('ping', 'POST', ack='priming') + if 'error' in r and r['error']: + return r try: fields += [('cli', 'true')] + fields += [('cli_version', "1")] content_type, body = encode_multipart_formdata(fields, files) headers = { 'content-type': content_type, 'content-length': str(len(body)), + 'connection': 'keep-alive', } url = "%s/%s" % (self.url, method) self.conn.request("POST", url, body, headers) response = self.conn.getresponse() - return response.read() + rv = response.read() + except Exception, e: + return { "error" : "client upload exception: " + str(e) } + # XXX should be JSON conversion + try: + return eval(rv) except Exception, e: - return "ERROR: " + str(e) + return {'error': "while parsing:%s\nclient upload exception: %s" % (rv, str(e))} #----------------------------------------------------------------- # Main -if __name__ == "__main__": +def main(): usage ="""%%prog [options] GROUP TYPE EVENTFILE where GROUP is one of %(groups)s TYPE is one of %(types)s @@ -312,7 +347,7 @@ Longer strings will be truncated.""" % { op.error("not enough arguments") elif args[0] == 'ping': msg = " ".join(args[1:]) or "PING" - print client.send('ping', ack=msg) + response = client.send('ping', ack=msg) elif args[0] == 'upload': if len(args) < 3: op.error("not enough arguments for upload") @@ -328,13 +363,13 @@ Longer strings will be truncated.""" % { files = [ ('upload', filename, sys.stdin.read()) ] else: files = [ ('upload', filename, open(filename,'r').read()) ] - print client.upload('upload', fields, files) + response = client.upload('upload', fields, files) elif args[0] == 'log': if len(args) < 3: op.error("not enough arguments for log") graceid = args[1] message = " ".join(args[2:]) - print client.send('log', graceid=graceid, message=message) + response = client.send('log', graceid=graceid, message=message) elif len(args) == 3: group = args[0] type = args[1] @@ -343,7 +378,7 @@ Longer strings will be truncated.""" % { if type in typeCodeMap: type = typeCodeMap[type] else: - print "Type must be one of: ", ", ".join(typeCodeMap.keys()) + error("Type must be one of: ", ", ".join(typeCodeMap.keys())) sys.exit(1) fields = [ @@ -358,15 +393,30 @@ Longer strings will be truncated.""" % { response = client.upload("create", fields, files) - if response: - if response.startswith('ERROR'): - print response - sys.exit(1) - else: - print "UID: ", response - sys.exit(0) - else: - print "There was a problem. Did you do grid-proxy-init -rfc?" + if not response: + error("There was a problem. Did you do grid-proxy-init -rfc?") sys.exit(1) else: op.error("") + sys.exit(1) + + # Output the response. + + exitCode = 0 + if ('error' in response) and response['error']: + error(response['error']) + exitCode = 1 + if ('warning' in response) and response['warning']: + warning(response['warning']) + if ('output' in response) and response['output']: + output(response['output']) + + return exitCode + +if __name__ == "__main__": + try: + code = main() + except Exception, e: + error(str(e)) + sys.exit(1) + sys.exit(code) diff --git a/glue/bin/ldbdc b/glue/bin/ldbdc index d20578ee7177ad5478bbd60cb6e54ffa921eb468..95810929d4c8b21c1bb6e1778954ca7e8a7cfb8d 100644 --- a/glue/bin/ldbdc +++ b/glue/bin/ldbdc @@ -30,6 +30,7 @@ import re try: from glue import LDBDClient + from glue import LDBDWClient from glue import gsiserverutils except ImportError, e: print >> sys.stderr, """ @@ -53,6 +54,7 @@ Usage: ldbdc.py [OPTIONS] -q, --query QUERY execute SQL query QUERY -o, --output FILE write output to FILE -D, --dmt-segments insert the XML data as DMT segment data + -a, --disable-gssapi disable grid certificate authentication -p, --ping ping the server -h, --help print this message @@ -65,7 +67,7 @@ def help(): usage() sys.exit(0) -shortop = "r:j:d:i:f:q:o:Dvph" +shortop = "r:j:d:i:f:q:o:Dvpha" longop = [ "server=", "identity=", @@ -75,6 +77,7 @@ longop = [ "query=", "output=", "dmt-segments", + "disable-gssapi", "ping", "help" ] @@ -94,6 +97,7 @@ pfnlist = None outfile = None squery = None dmtsegs = None +disableauth = None ping = None # environment variables override defaults but not @@ -122,6 +126,8 @@ for o, a in opts: outfile = a elif o in ("-D", "--dmt-segments"): dmtsegs = 1 + elif o in ("-D", "--disable-gssapi"): + disableauth = 1 elif o in ("-p", "--ping"): ping = 1 @@ -163,17 +169,28 @@ if dmtsegs and pfnlist: if not identity: identity = "/DC=org/DC=doegrids/OU=Services/CN=ldbd/%s" % host +if disableauth: + identity = None + # open connection to LDBD Server -try: - myClient = LDBDClient.LDBDClient(host, port, identity) +if port in (30015,30020,30021,30022,30023): + try: + myClient = LDBDClient.LDBDClient(host, port, identity) + + except Exception, e: + print >>sys.stderr, \ + "Unable to connect to LDBD Server %s:%d" % (host, port) + if gsiserverutils.checkCredentials(): + print >>sys.stderr, "Got the following error : " + str(e) + print >>sys.stderr, "Enter 'ldbdc --help' for usage" + sys.exit(1) +elif port==443: + try: + myClient = LDBDWClient.LDBDClient(host,port,identity) + except Exception, e: + print >>sys.stderr, "Unable to connect to LDBD Server %s:%d" % (host,port) + sys.exit(1) -except Exception, e: - print >>sys.stderr, \ - "Unable to connect to LDBD Server %s:%d" % (host, port) - if gsiserverutils.checkCredentials(): - print >>sys.stderr, "Got the following error : " + str(e) - print >>sys.stderr, "Enter 'ldbdc --help' for usage" - sys.exit(1) try: if ping: diff --git a/glue/bin/ldbdd b/glue/bin/ldbdd index e14678d2c6f9bd5842d017dbcadfb8e12c6f03ee..6cfe79d47c03d03850dce76e2cde0328928e7d39 100644 --- a/glue/bin/ldbdd +++ b/glue/bin/ldbdd @@ -169,7 +169,9 @@ if not configFilePath: # created elsewhere configuration = { 'server' : None, + 'ipaddr' : '', 'port' : 30015, + 'secure' : 'yes', 'gridmap' : 'grid-mapfile', 'certfile' : 'ldbdcert.pem', 'keyfile' : 'ldbdkey.pem', @@ -317,7 +319,9 @@ class LDBDDaemon(object): self.keyFilePath = configuration["keyfile"] self.gridmapFilePath = configuration["gridmap"] self.pidFilePath = configuration["pidfile"] + self.ipaddr = configuration["ipaddr"] self.port = configuration["port"] + self.secure = configuration["secure"] myLogger = logging.getLogger('ldbdd') @@ -443,31 +447,52 @@ class LDBDDaemon(object): @return: None """ + # create TCPIO Attribute object and initialize to pass to server + tcpIOAttr = io.TCPIOAttr() + authData = io.AuthData() + # create a callback to use for authorization gridmap = gsiserverutils.Gridmap(self.gridmapFilePath, self.logger) callback = gsiserverutils.AuthCallback(gridmap, self.logger, callback=None) - # create authorization data object and set callback - authData = io.AuthData() + # set authorization callback authData.set_callback(callback, self) self.authData = authData - - # create TCPIO Attribute object and initialize to pass to server - # - # we use secure IO authentication using GSSAPI and authorization back - # to a callback function, which reads a gridmap file - tcpIOAttr = io.TCPIOAttr() - tcpIOAttr.set_authentication_mode( - io.ioc.GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI) - tcpIOAttr.set_authorization_mode( - io.ioc.GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK, authData) - tcpIOAttr.set_channel_mode( - io.ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR) - tcpIOAttr.set_delegation_mode( - io.ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_FULL_PROXY) - + + if self.secure == 'no': + # set up an unathenticated connection + self.logger.info("Disabling security") + tcpIOAttr.set_authentication_mode( + io.ioc.GLOBUS_IO_SECURE_AUTHENTICATION_MODE_NONE) + tcpIOAttr.set_authorization_mode( + io.ioc.GLOBUS_IO_SECURE_AUTHORIZATION_MODE_NONE, authData) + tcpIOAttr.set_channel_mode( + io.ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR) + tcpIOAttr.set_delegation_mode( + io.ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_NONE) + + else: + # we use secure IO authentication using GSSAPI and authorization back + # to a callback function, which reads a gridmap file + self.logger.info("Enabling security") + tcpIOAttr.set_authentication_mode( + io.ioc.GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI) + tcpIOAttr.set_authorization_mode( + io.ioc.GLOBUS_IO_SECURE_AUTHORIZATION_MODE_CALLBACK, authData) + tcpIOAttr.set_channel_mode( + io.ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR) + tcpIOAttr.set_delegation_mode( + io.ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_FULL_PROXY) + self.tcpIOAttr = tcpIOAttr + # bind to an interface, if specified + if self.ipaddr is not '': + self.logger.info("Listening on ip address: %s" % self.ipaddr) + self.tcpIOAttr.set_interface(self.ipaddr) + else: + self.logger.info("Listening on all interfaces") + # start the server self.running = 0 self.nap = 1 @@ -475,9 +500,8 @@ class LDBDDaemon(object): try: self.logger.info("Starting server on port %d" % self.port) server = io.ThreadingGSITCPSocketServer( - addr=("", self.port), + addr=(self.ipaddr, self.port), RequestHandlerClass=self.handler, - #io.ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR, channel_mode=io.ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR, delegation_mode=io.ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_FULL_PROXY, tcpAttr=self.tcpIOAttr diff --git a/glue/bin/ligo_data_find b/glue/bin/ligo_data_find index aa1feb9c5957973167c7a16b6726ed3b5252f9e7..496d6ffda90f615024d56a0632fb0b651f313667 100644 --- a/glue/bin/ligo_data_find +++ b/glue/bin/ligo_data_find @@ -35,6 +35,8 @@ import urlparse import time import calendar +import glue.segments + try: import M2Crypto import cjson @@ -86,10 +88,13 @@ NAME SYNOPSIS ligo_data_find --server=NAME:PORT --observatory=NAME --type=NAME - --gps-start-time=GPS --gps-end-time=GPS [ --lal-cache ] + --gps-start-time=GPS --gps-end-time=GPS + [ --lal-cache ] [ --frame-cache ] [ --url-type=SCHEME ] [ --match=EXPRESSION ] - [ --names-only ] [--show-times] [ --version ] - [ --no-proxy ] + [ --names-only ] [ --show-times ] [ --version ] + [ --no-proxy ] [ --gaps ] + + ligo_data_find --server=NAME:PORT --observatory OBS --type TYPE --latest ligo_data_find --server=NAME:PORT --filename @@ -132,6 +137,9 @@ DESCRIPTION -l, --lal-cache format output for use as a LAL cache file + -W --frame-cache + format output for use as a frame cache file + -m, --match return only results that match a regular expression @@ -139,6 +147,15 @@ DESCRIPTION return only the names of files with particular values for instrument, type, start, and end rather than full URLs + -g, --gaps + check the returned list of URLs or paths to see if the + files cover the requested interval; a return value of + zero (0) indicates the interval is covered, a value of + one (1) indicates at least one gap exists and the interval + is not covered, and a value of (2) indicates that the + entire interval is not covered; missing gaps are + printed to stderr + -P, --no-proxy attempt to authenticate without a grid proxy. @@ -152,12 +169,14 @@ DESCRIPTION -y, --show-types list available types + -T, --latest + -a, --show-times - list gps-second segments for all data of type specified. - Must be used with --type foo and --observatory bar, where foo + list gps-second segments for all data of type specified. + Must be used with --type foo and --observatory bar, where foo is a frame type and bar is an observatory. Optionally - Supports one or both of --gps-start-time and - --gps-end-time to restrict returned time ranges. + Supports one or both of --gps-start-time and + --gps-end-time to restrict returned time ranges. -p, --ping ping the LDRDataFind server @@ -178,19 +197,6 @@ ENVIRONMENT LIGO_DATAFIND_MATCH can be set to avoid having to use the --match option on the command line. - -EXAMPLE - -$ ligo_data_find --server=dataserver.phys.uwm.edu --observatory=H ---type=RDS_R_L3 --gps-start-time=714024240 --gps-end-time=714024340 --url-type=file -file://localhost/nfsdata01/S1/RDS_R_L3/H/714023808-714029599/H-RDS_R_L3-714024224-16.gwf -file://localhost/nfsdata01/S1/RDS_R_L3/H/714023808-714029599/H-RDS_R_L3-714024240-16.gwf -file://localhost/nfsdata01/S1/RDS_R_L3/H/714023808-714029599/H-RDS_R_L3-714024256-16.gwf -file://localhost/nfsdata01/S1/RDS_R_L3/H/714023808-714029599/H-RDS_R_L3-714024272-16.gwf -file://localhost/nfsdata01/S1/RDS_R_L3/H/714023808-714029599/H-RDS_R_L3-714024288-16.gwf -file://localhost/nfsdata01/S1/RDS_R_L3/H/714023808-714029599/H-RDS_R_L3-714024304-16.gwf -file://localhost/nfsdata01/S1/RDS_R_L3/H/714023808-714029599/H-RDS_R_L3-714024320-16.gwf -file://localhost/nfsdata01/S1/RDS_R_L3/H/714023808-714029599/H-RDS_R_L3-714024336-16.gwf \ """ print >>sys.stderr, msg @@ -200,7 +206,7 @@ def main(): """ # grab command line options - shortop = "vt:s:e:wyaphlr:f:u:m:o:nPdO:" + shortop = "vt:s:e:wyaphlr:f:u:m:o:nPdO:gWT" longop = [ "version", "help", @@ -213,6 +219,7 @@ def main(): "ping", "server=", "lal-cache", + "frame-cache", "filename=", "url-type=", "match=", @@ -221,6 +228,8 @@ def main(): "no-proxy", "disable-host-auth", "output-file=", + "gaps", + "latest", ] try: @@ -234,6 +243,7 @@ def main(): hostPortString = None port = None lalcache = False + wcache = False noproxy = False # i.e., use proxy by default namesOnly = False output_file = sys.stdout @@ -247,6 +257,7 @@ def main(): 'filename': None, 'urlType': None, 'match': None, + 'checkGaps': None } # default method @@ -288,6 +299,8 @@ def main(): clientMethodArgDict['type'] = a elif o in ("-l", "--lal-cache"): lalcache = True + elif o in ("-W", "--frame-cache"): + wcache = True elif o in ("-f", "--filename"): clientMethodArgDict['filename'] = a clientMethod = 'singleFrameFind' @@ -308,10 +321,14 @@ def main(): elif o in ("-a","--show-times"): clientMethodArgDict['show-times'] = True clientMethod = 'showTimes' + elif o in ("-T", "--latest"): + clientMethod = 'latest' elif o in ("-P","--no-proxy"): noproxy = True elif o in ("-O", "--output-file"): output_file = open(a, "w") + elif o in ("-g", "--gaps"): + clientMethodArgDict['checkGaps'] = True if not clientMethod: print >>sys.stderr, "Bad combination or missing options" @@ -337,6 +354,7 @@ def main(): clientMethodArgDict['output_file'] = output_file clientMethodArgDict['namesOnly'] = namesOnly clientMethodArgDict['lalcache'] = lalcache + clientMethodArgDict['wcache'] = wcache # find credential unless either the user has # specified no proxy credential or we are going @@ -351,9 +369,10 @@ def main(): clientMethodArgDict['keyFile'] = keyFile # execute the query and print the result + ret = None try: if clientMethod == 'findFrameURLs': - findFrameURLs(clientMethodArgDict) + ret = findFrameURLs(clientMethodArgDict) elif clientMethod == 'showObservatories': showObservatories(clientMethodArgDict) elif clientMethod == 'showTypes': @@ -364,6 +383,8 @@ def main(): singleFrameFind(clientMethodArgDict) elif clientMethod == 'ping': ping(clientMethodArgDict) + elif clientMethod == 'latest': + latest(clientMethodArgDict) except Exception, e: print >>sys.stderr, "Error querying LDRDataFindServer: %s" % str(e) @@ -371,7 +392,11 @@ def main(): sys.exit(1) output_file.close() - sys.exit(0) + + if ret is None: + sys.exit(0) + else: + sys.exit(ret) def findCredential(): """ @@ -399,6 +424,7 @@ def findCredential(): if os.environ.has_key('X509_USER_KEY'): certFile = os.environ['X509_USER_CERT'] keyFile = os.environ['X509_USER_KEY'] + return certFile, keyFile # search for proxy file on disk uid = os.getuid() @@ -556,7 +582,9 @@ def findFrameURLs(args): namesOnly = args['namesOnly'] lalcache = args['lalcache'] + wcache = args['wcache'] output_file = args['output_file'] + checkGaps = args['checkGaps'] if not site or not frameType or not gpsStart or not gpsEnd: msg = """\ @@ -613,6 +641,88 @@ be present when searching for groups of files # decode the JSON urlList = cjson.decode(body) + # special branch to check for gaps + if checkGaps: + searchSegment = glue.segments.segment(int(gpsStart), int(gpsEnd)) + + if len(urlList) == 0: + # the interval is not covered at all so the + # return value should be 2 and we will print + # the missing interval or gap to stderr and + # nothing to stdout or the output_file + print >>sys.stderr, 'missing segments: %s' % str(searchSegment) + return 2 + + # parse the URLs to create a segment representation + lfnList = [ os.path.basename(url) for url in urlList ] + timeDuration = [ s[:-4].split('-')[2:4] for s in lfnList ] + intervals = [ [int(x), int(x) + int(y)] for x,y in timeDuration ] + returnedSegments = glue.segments.segmentlist([ glue.segments.segment(i) for i in intervals ]) + + # normalize the segment list + returnedSegments.coalesce() + + # see if the returned segments cover the search segment + if searchSegment in returnedSegments: + # the interval is covered entirely so the + # return value should be zero (0) and we will + # print the URLs to stdout and nothing to stderr + if namesOnly: + lfns = parseLFNs(urlList) + for lfn in lfns: + print >>output_file, "%s" % lfn + + elif lalcache: + for pfn in urlList: + lfn = os.path.basename(pfn) + head, ext = os.path.splitext(lfn) + a, b, c, d = head.split('-') + print >>output_file, "%s %s %s %s %s" % (a, b, c, d, pfn) + + elif wcache: + wcachedict = wcacheFromURLList(urlList) + for item in wcachedict: + print >>output_file, "%s %s %s %s %s %s" % tuple(wcachedict[item]) + + else: + for pfn in urlList: + print >>output_file, "%s" % pfn + + return 0 + + else: + # the interval is not covered entirely so the return + # value should be one (1) and we will print the URLs + # we did find to stdout and the missing segments + # to stderr + if namesOnly: + lfns = parseLFNs(urlList) + for lfn in lfns: + print >>output_file, "%s" % lfn + + elif lalcache: + for pfn in urlList: + lfn = os.path.basename(pfn) + head, ext = os.path.splitext(lfn) + a, b, c, d = head.split('-') + print >>output_file, "%s %s %s %s %s" % (a, b, c, d, pfn) + + elif wcache: + wcachedict = wcacheFromURLList(urlList) + for item in wcachedict: + print >>output_file, "%s %s %s %s %s %s" % tuple(wcachedict[item]) + + else: + for pfn in urlList: + print >>output_file, "%s" % pfn + + missingSegments = glue.segments.segmentlist([searchSegment]) - returnedSegments + print >>sys.stderr, 'missing segments: %s' % missingSegments + + return 1 + + + if len(urlList) == 0: print >>sys.stderr, "No files found!" return @@ -629,6 +739,11 @@ be present when searching for groups of files a, b, c, d = head.split('-') print >>output_file, "%s %s %s %s %s" % (a, b, c, d, pfn) + elif wcache: + wcachedict = wcacheFromURLList(urlList) + for item in wcachedict: + print >>output_file, "%s %s %s %s %s %s" % tuple(wcachedict[item]) + else: for pfn in urlList: print >>output_file, "%s" % pfn @@ -832,6 +947,24 @@ or just a beginning or just an end time. for s in segmentList: print >>output_file, "%d %d" % tuple(s) +def wcacheFromURLList(urlList): + wcachedict={} + for pfn in urlList: + dir=os.path.split(urlparse.urlparse(pfn)[2])[0] + lfn = os.path.basename(pfn) + head, ext = os.path.splitext(lfn) + a, b, c, d = head.split('-') + tend=str(int(c)+int(d)) + if wcachedict.has_key(dir): + l=wcachedict[dir] + if int(l[2]) > int(c): + wcachedict[dir][2]=c + if int(l[3]) < int(tend): + wcachedict[dir][3]=tend + else: + wcachedict[dir]=[a, b, c, tend, d, dir] + return wcachedict + def singleFrameFind(args): """ Query for the URLs for a single file. @@ -846,6 +979,7 @@ def singleFrameFind(args): keyFile = args['keyFile'] lalcache = args['lalcache'] + wcache = args['wcache'] output_file = args['output_file'] namesOnly = args['namesOnly'] @@ -907,6 +1041,110 @@ def singleFrameFind(args): a, b, c, d = head.split('-') print >>output_file, "%s %s %s %s %s" % (a, b, c, d, pfn) + elif wcache: + wcachedict = wcacheFromURLList(urlList) + for item in wcachedict: + print >>output_file, "%s %s %s %s %s %s" % tuple(wcachedict[item]) + + else: + for pfn in urlList: + print >>output_file, "%s" % pfn + +def latest(args): + """ + Given observatory and type with possibly a URL type + query the server to find the URL(s) for the latest + GPS time frame file that the server knows about. + """ + + host = args['host'] + port = args['port'] + + site = args['observatory'] + frameType = args['type'] + + urlType = args['urlType'] + + certFile = args['certFile'] + keyFile = args['keyFile'] + + namesOnly = args['namesOnly'] + lalcache = args['lalcache'] + wcache = args['wcache'] + output_file = args['output_file'] + + if not site or not frameType: + msg = """\ +Bad combination of command line arguments: +--observatory --type --latest must all +be present when searching for the latest file +""" + raise RuntimeError(msg) + + + if port: + server = "%s:%d" % (host, port) + else: + server = host + + # construct the URL for the latest query + url = "/LDR/services/data/v1/gwf/%s/%s/latest" % (site, frameType) + + # if a URL type is specified append it to the path + if urlType: + url += "/%s" % urlType + + # request JSON output + url += ".json" + + # if we have a credential then use it when setting up the connection + if certFile and keyFile: + h = httplib.HTTPSConnection(server, key_file = keyFile, cert_file = certFile) + else: + h = httplib.HTTPConnection(server) + + # query the server + try: + h.request("GET", url) + response = h.getresponse() + except Exception, e: + msg = "Unable to query server %s: %s\n\nPerhaps you need a valid proxy credential?\n" % (server, e) + raise RuntimeError, msg + + # the server did respond to check the status + if response.status != 200: + msg = "Server returned code %d: %s" % (response.status, response.reason) + body = response.read() + msg += body + raise RuntimeError, msg + + # since status is 200 OK read the URLs + body = response.read() + + # decode the JSON + urlList = cjson.decode(body) + + if len(urlList) == 0: + print >>sys.stderr, "No files found!" + return 1 + + elif namesOnly: + lfns = parseLFNs(urlList) + for lfn in lfns: + print >>output_file, "%s" % lfn + + elif lalcache: + for pfn in urlList: + lfn = os.path.basename(pfn) + head, ext = os.path.splitext(lfn) + a, b, c, d = head.split('-') + print >>output_file, "%s %s %s %s %s" % (a, b, c, d, pfn) + + elif wcache: + wcachedict = wcacheFromURLList(urlList) + for item in wcachedict: + print >>output_file, "%s %s %s %s %s %s" % tuple(wcachedict[item]) + else: for pfn in urlList: print >>output_file, "%s" % pfn diff --git a/glue/bin/ligolw_add b/glue/bin/ligolw_add index 057027e55501da54b7825b4dbcd93ac44b3d04e0..e4c30d17315c4982d3a1231b5f5622154446653d 100644 --- a/glue/bin/ligolw_add +++ b/glue/bin/ligolw_add @@ -1,8 +1,6 @@ #!/usr/bin/python # -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -38,6 +36,7 @@ import os import sys +from glue import git_version from glue.lal import CacheEntry from glue.ligolw.utils import ligolw_add from glue.ligolw import ligolw @@ -45,9 +44,9 @@ from glue.ligolw import lsctables from glue.ligolw import utils -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -64,7 +63,7 @@ def parse_command_line(): Parse the command line, return an options object and a list of URLs. """ parser = OptionParser( - version = "%prog CVS $Id$", + version = "Name: %%prog\n%s" % git_version.verbose_msg, usage = "%prog [options] [url ...]", description = "Combines one or more LIGO Light Weight XML files into a single output file. The output is written to stdout or to the filename specified by --output. In addition to regular files, many common URL types can be read such as http:// and ftp://. Any input files or URLs whose names end in \".gz\" are assumed to be gzip-compressed, and will be uncompressed while reading. If the output file's name ends in \".gz\", the output document will be gzip-compressed while writing. Table elements contained in the document will be merged so that there is not more than one table of any given name in the output. To accomplish this, any tables in the input documents that share the same name must have compatible columns, meaning the same column names with matching types (but not necessarily in the same order)." ) diff --git a/glue/bin/ligolw_burst2mon b/glue/bin/ligolw_burst2mon index 4dcfe5e6d4907356b726c0559b4e3e02c5c92a0c..ba2edcd616454062a61ce8bcc50158b0c6e445c4 100644 --- a/glue/bin/ligolw_burst2mon +++ b/glue/bin/ligolw_burst2mon @@ -1,8 +1,6 @@ #!/usr/bin/python # -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -35,6 +33,7 @@ import sys import time +from glue import git_version from glue import segments from glue.ligolw import ligolw from glue.ligolw import table @@ -43,9 +42,9 @@ from glue.ligolw import utils from pylal.date import XLALUTCToGPS -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__version__ = "$Revision$"[11:-2] -__date__ = "$Date$"[7:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -58,7 +57,7 @@ __date__ = "$Date$"[7:-2] parser = OptionParser( - version = "%prog CVS $Id$" + version = "Name: %%prog\n%s" % git_version.verbose_msg ) parser.add_option("-c", "--comment", metavar = "text", default = "", help = "set process comment") parser.add_option("-i", "--input", metavar = "filename", help = "read from filename (default = stdin)") diff --git a/glue/bin/ligolw_cbc_glitch_page b/glue/bin/ligolw_cbc_glitch_page index d343bfb9d313d6552944b951fbbb9c9806a50a4a..a9ed7092c6ed26805add048cbb5a60abe776a700 100644 --- a/glue/bin/ligolw_cbc_glitch_page +++ b/glue/bin/ligolw_cbc_glitch_page @@ -32,7 +32,7 @@ import os import glob import tempfile -import glue.segments +from glue.segments import segmentlist, segment from glue.ligolw import ligolw from glue.ligolw import lsctables @@ -40,6 +40,7 @@ from glue.ligolw import utils from glue.ligolw.utils import ligolw_sqlite from glue.ligolw import dbtables +from glue.segmentdb import query_engine from glue.segmentdb import segmentdb_utils from glue import gpstime @@ -62,6 +63,11 @@ def parse_command_line(): Parse the command line, return an options object """ + def require(flag, message): + if not flag: + print >>sys.stdout, message + sys.exit(1) + parser = OptionParser( version = "%prog CVS $Header$", usage = "%prog --trigger-dir dir --segments url --html-file file --ifo ifo --timestamp-file [other options]", @@ -69,6 +75,7 @@ def parse_command_line(): ) parser.add_option("-t", "--trigger-dir", metavar="dir", help = "Location of XML files containing sngl_inspiral tables") + parser.add_option("-e", "--trigger-db", metavar="database", help = "Location of an already-created sqlite database") parser.add_option("-s", "--segments", metavar="url", help = "URL to contact for DQ flags (ldbd: or file:)") parser.add_option("-f", "--html-file", metavar="file", help = "Location of html file to write") parser.add_option("-i", "--ifo", metavar="ifo", help = "IFO") @@ -86,9 +93,10 @@ def parse_command_line(): options, others = parser.parse_args() # Make sure we have all required parameters - if not (options.trigger_dir and options.segments and options.ifo and options.timestamp_file and options.html_file): - print "Usgae: %prog --trigger-dir dir --segments url --html-file file --ifo ifo --timestamp-file [other options]" - sys.exit(-1) + require(options.trigger_dir or options.trigger_db, "Missing required argument [--trigger-dir | --trigger-db]") + require(options.ifo, "Missing required argument --ifo") + require(options.html_file, "Missing required argument --html-file") + require(options.timestamp_file or (options.gps_start_time and options.gps_end_time), "Missing required argument [--timestamp-file | --gps-start-time --gps-end-time]") return options @@ -98,12 +106,11 @@ def generate_html(outf, triggers, colors): # echo "<p><tt><a href=\"${xmlfile}\">${xmlfile}</a></tt>" >> ${htmlfile} print >>outf, '<p>' print >>outf, '<table border=1>' - print >>outf, ' <tr bgcolor="#9999ff"><th>ifo</th><th>end time UTC</th><th>end_time</th><th>end_time_ns</th><th>snr</th><th>eff_distance</th><th>Ω scan</th><th>DQ flags</th></tr>' + print >>outf, ' <tr bgcolor="#9999ff"><th>ifo</th><th>end time UTC</th><th>end_time</th><th>end_time_ns</th><th>snr</th><th>eff_distance</th><th>χ<sup>2</sup></th><th>Ω scan</th><th>DQ flags</th></tr>' for count, trig in enumerate(triggers): print >>outf, ' <tr valign="top" bgcolor="%s">' % colors[count % 2] - print >>outf, ' <td>%s</td>' % (trig[0]) end_time_utc = os.popen('tconvert %d' % trig[1]).next().strip() @@ -116,7 +123,7 @@ def generate_html(outf, triggers, colors): print >>outf, ' <td>' for name, value in trig[-1].items(): - if not name.startswith('DMT'): + if name.find('Light') != -1 or name.find('Up') != -1 or name.find('Calibrated') != -1: print >>outf, ' <b>%s</b><br>' % name else: print >>outf, ' %s %s %s<br>' % (name, value[0], value[2]) @@ -131,73 +138,49 @@ def generate_html(outf, triggers, colors): -def setup_files(dir_name, gps_start_time, gps_end_time): - # Filter out the ones that are outside our time range - xml_files = segmentdb_utils.get_all_files_in_range(dir_name, gps_start_time, gps_end_time) +def setup_files(dir_name, db_name, gps_start_time, gps_end_time): + if db_name: + temp_db = None + connection = sqlite3.connect(db_name) + else: + # Filter out the ones that are outside our time range + xml_files = segmentdb_utils.get_all_files_in_range(dir_name, gps_start_time, gps_end_time) - handle, temp_db = tempfile.mkstemp(suffix='.sqlite') - os.close(handle) + handle, temp_db = tempfile.mkstemp(suffix='.sqlite') + os.close(handle) - target = dbtables.get_connection_filename(temp_db, None, True, False) - connection = ligolw_sqlite.setup(target) + target = dbtables.get_connection_filename(temp_db, None, True, False) + connection = ligolw_sqlite.setup(target) - ligolw_sqlite.insert(connection, xml_files) + ligolw_sqlite.insert(connection, xml_files) return temp_db, connection +def get_times_with_flags(gps_start_time, gps_end_time): + # Find times where there were no DQ flags, rather than checking the time of each trigger + segment_connection = segmentdb_utils.setup_database(os.environ['S6_SEGMENT_SERVER']) + engine = query_engine.LdbdQueryEngine(segment_connection) -# -# ============================================================================= -# -# Main -# -# ============================================================================= -# - -if __name__ == '__main__': - options = parse_command_line() - - # Do we have everything we need for omage scans? - omega_ok = options.omega_conf and options.omega_frame_dir and options.omega_out_dir - - if not omega_ok: - print >>sys.stderr, "Warning: Missing omega options, omega scans will not be run" - - - kcount = int(options.known_count) - ucount = int(options.unknown_count) - - # Run up to now or the user-provided time - if options.gps_end_time: - gps_end_time = int(options.gps_end_time) - else: - gps_end_time = gpstime.GpsSecondsFromPyUTC(time.time()) - - # Find the last time we ran (in principle we could get this from the time - # stamp on the HTML file, but we should allow for the possibility that - # someone might hand-edit that file) - if options.gps_start_time: - gps_start_time = int(options.gps_start_time) - elif os.path.exists(options.timestamp_file): - f = open(options.timestamp_file) - gps_start_time = int(f.next()) - f.close() - else: - # Looks like we've never run before, start a day ago - gps_start_time = gps_end_time - (60 * 60 * 24) + sql = "SELECT start_time, end_time FROM segment " + sql += " WHERE NOT (%s > segment.end_time OR segment.start_time > %s) " % (gps_start_time, gps_end_time) + sql += " AND segment.segment_def_id IN (SELECT DISTINCT segment_definer.segment_def_id FROM segment_definer, segment_summary " + sql += " WHERE segment_definer.ifos = '%s' " % options.ifo + sql += " AND segment_definer.segment_def_id = segment_summary.segment_def_id " + sql += " AND segment_summary.segment_def_cdb = segment_definer.creator_db " + sql += " AND segment_definer.name NOT IN ('DMT-SCIENCE', 'DMT-LIGHT', 'DMT-UP', 'DMT-CALIBRATED', 'DMT-INJECTION') " + sql += " AND NOT (%s > segment.end_time OR segment.start_time > %s)) " % (gps_start_time, gps_end_time) + times_with_flags = segmentlist([segment(row[0], row[1]) for row in engine.query(sql)]) + times_with_flags.coalesce() - # Load the relevant trigger XML files into a sqlite DB and - # get a connection - temp_db, connection = setup_files(options.trigger_dir, gps_start_time, gps_end_time) + return times_with_flags - # Did we find any triggers? If not there won't even be a sngl_inspiral - # table, so the normal query will fail - have_triggers = connection.cursor().execute("SELECT COUNT(*) FROM sqlite_master WHERE name = 'sngl_inspiral'").fetchone()[0] +def get_triggers_in_times(options, gps_start_time, gps_end_time, valid_times, count): + if not abs(valid_times): + return [] - # Note, the S5 version of this script had the condition # search = 'FindChirpSPtwoPN' # The triggers from MBTA don't set this, alough it could if desirable. @@ -229,12 +212,13 @@ if __name__ == '__main__': # # So we have to be a little trickier... # - if have_triggers: - rows = connection.cursor().execute("""SELECT sngl_inspiral.ifo, + + rows = connection.cursor().execute("""SELECT sngl_inspiral.ifo, sngl_inspiral.end_time, sngl_inspiral.end_time_ns, sngl_inspiral.snr, - sngl_inspiral.eff_distance + sngl_inspiral.eff_distance, + sngl_inspiral.chisq FROM sngl_inspiral WHERE (cast(sngl_inspiral.end_time as char) || " -- " || cast(sngl_inspiral.snr as char)) IN (SELECT cast(end_time as char) || " -- " || cast(MAX(snr) as char) @@ -247,23 +231,20 @@ if __name__ == '__main__': ORDER BY snr desc) AND sngl_inspiral.ifo = ? ORDER BY snr DESC""", (gps_start_time, gps_end_time, options.ifo, options.min_glitch_snr, options.ifo) ) - else: - # Use an empty array so the rest of the code will flow through and - # update the page accordingly - rows = [] - - # ligolw_sicluster --cluster-window ${clusterwindow} --sort-descending-snr ${xmlfile} + ret = [] + i = 0 - known_trigs = [] - unknown_trigs = [] - - for ifo, end_time, end_time_ns, snr, e_dist, in rows: + for ifo, end_time, end_time_ns, snr, eff_dist, chisq in rows: trig_time = end_time if end_time_ns >= 500000000: trig_time += 1 - # Find the flags on at this time + if trig_time not in valid_times: + continue + + # Find the flags on at this time. We need this even for "unknown" times, since + # we need to check for DMT-SCIENCE etc flags = {} pipe = os.popen('ligolw_dq_query --segment=%s --include-segments %s --in-segments-only --report %d' % (options.segments, ifo, end_time)) @@ -285,18 +266,87 @@ if __name__ == '__main__': del flags[flag] if len(ifo_status) > 0: - ifo_status = ifo_status[:-1] + ifo_status = ifo_status[:-1] + flags[ifo_status] = True + ret.append((ifo, end_time, end_time_ns, snr, eff_dist, chisq, flags)) - if len(flags) == 0: - if len(unknown_trigs) < ucount: - flags[ifo_status] = True - unknown_trigs.append((ifo, end_time, end_time_ns, snr, e_dist, flags)) - elif len(known_trigs) < kcount: - flags[ifo_status] = True - known_trigs.append((ifo, end_time, end_time_ns, snr, e_dist, flags)) - if omega_ok: + i += 1 + + if i > count: + break + + return ret + + +# +# ============================================================================= +# +# Main +# +# ============================================================================= +# + +if __name__ == '__main__': + options = parse_command_line() + + # Do we have everything we need for omage scans? + omega_ok = options.omega_conf and options.omega_frame_dir and options.omega_out_dir + + if not omega_ok: + print >>sys.stderr, "Warning: Missing omega options, omega scans will not be run" + + + kcount = int(options.known_count) + ucount = int(options.unknown_count) + + # Run up to now or the user-provided time + if options.gps_end_time: + gps_end_time = int(options.gps_end_time) + else: + gps_end_time = gpstime.GpsSecondsFromPyUTC(time.time()) + + # Find the last time we ran (in principle we could get this from the time + # stamp on the HTML file, but we should allow for the possibility that + # someone might hand-edit that file) + if options.gps_start_time: + gps_start_time = int(options.gps_start_time) + elif os.path.exists(options.timestamp_file): + f = open(options.timestamp_file) + gps_start_time = int(f.next()) + f.close() + else: + # Looks like we've never run before, start a day ago + gps_start_time = gps_end_time - (60 * 60 * 24) + + + # Load the relevant trigger XML files into a sqlite DB and + # get a connection + temp_db, connection = setup_files(options.trigger_dir, options.trigger_db, gps_start_time, gps_end_time) + + # Did we find any triggers? If not there won't even be a sngl_inspiral + # table, so the normal query will fail + + have_triggers = connection.cursor().execute("SELECT COUNT(*) FROM sqlite_master WHERE name = 'sngl_inspiral'").fetchone()[0] + + if have_triggers: + times_with_flags = get_times_with_flags(gps_start_time, gps_end_time) + times_without_flags = segmentlist([segment(gps_start_time,gps_end_time)]) - times_with_flags + + known_trigs = get_triggers_in_times(options, gps_start_time, gps_end_time, times_with_flags, kcount) + unknown_trigs = get_triggers_in_times(options, gps_start_time, gps_end_time, times_without_flags, ucount) + else: + # Use an empty array so the rest of the code will flow through and + # update the page accordingly + known_trigs = [] + unknown_trigs = [] + + # ligolw_sicluster --cluster-window ${clusterwindow} --sort-descending-snr ${xmlfile} + + # Do the omega scans if requested + if omega_ok: + for ifo, end_time, end_time_ns, snr, eff_dist, chisq, flags in (known_trigs + unknown_trigs): # The frames may live in a directory with subdirectories by time. If the given directory # contains a '%d' populate it with the first 4 digits of the time. full_path = options.omega_frame_dir @@ -306,13 +356,7 @@ if __name__ == '__main__': os.system("nohup condor_run ~omega/opt/omega/bin/wpipeline scan -r -c %s -f %s -o %s/%d %d < /dev/null &>/dev/null &" % ( options.omega_conf, full_path, options.omega_out_dir, end_time, end_time )) - # Print no more than the top ten known and unknown triggers - # (the ranking is done by the 'ODRER BY snr DESC' in the query above) - - if len(known_trigs) == kcount and len(unknown_trigs) == ucount: - break - - + # Convert to html, prepend to the file. out_tmp = StringIO.StringIO() @@ -347,7 +391,8 @@ if __name__ == '__main__': print >>f, gps_end_time f.close() - # Clean up after ourselves. - os.remove(temp_db) + # If we created our own database, clean up after ourselves. + if temp_db: + os.remove(temp_db) diff --git a/glue/bin/ligolw_cut b/glue/bin/ligolw_cut index 72719bcd055a1a163341a8bb15e9a54dd4c67822..b9dc0b40d5dda00f17078c23f69110a0791fd0d8 100644 --- a/glue/bin/ligolw_cut +++ b/glue/bin/ligolw_cut @@ -1,8 +1,6 @@ #!/usr/bin/python # -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -37,15 +35,16 @@ from optparse import OptionParser import sys +from glue import git_version from glue.ligolw import ligolw from glue.ligolw import table #from glue.ligolw import lsctables from glue.ligolw import utils -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -59,7 +58,7 @@ __version__ = "$Revision$"[11:-2] def parse_command_line(): parser = OptionParser( - version = "%prog CVS $Id$", + version = "Name: %%prog\n%s" % git_version.verbose_msg, usage = "%prog [options] [file ...]", description = "%prog removes XML elements from a LIGO Light Weight XML file. If file names are given on the command line, those files are read, processed, and rewritten one at a time, otherwise input is read from stdin and output written to stdout. Any file name ending in \".gz\" is assumed to be gzip-compressed and will be decompressed and recompressed during I/O." ) diff --git a/glue/bin/ligolw_dq_active_cats b/glue/bin/ligolw_dq_active_cats index cda102e0e3b4966e9842e7d0b8e65defcee08bfe..248300def2f2650eb3bfc7ff40eff30872db8ae3 100755 --- a/glue/bin/ligolw_dq_active_cats +++ b/glue/bin/ligolw_dq_active_cats @@ -1,8 +1,9 @@ #!/usr/bin/env python # -# ligolw_print_active_cats: print active defined cat vetos for a given time +# ligolw_dq_active_cats: print state of defined cat vetos for a given +# time # -# Copyright (C) 2009 Josh Smith and Jameson Rollins +# Copyright (C) 2009 Jameson Rollins and Josh Smith # # 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 @@ -26,51 +27,65 @@ from subprocess import * # usage def usage(): - print "usage: LIGOLW_VETO_FILE=<file>", CMD, "<gpstime>" + print "usage: LIGOLW_VETO_FILE=<file>", CMD, "<gpstime> [<duration>]" print """ -Indicate whether flags from a category definer are active, inactive, or undefined. -The output is one line per category-defined veto, of the form: +For specified time and category definer file, output flag states. If +a duration is also specified, then the flag states are output for the +entire duration, starting at gpstime, in an OR manor, with preference +given to the flags in the order defined below. The output is one line +per category-defined veto, of the form: - <flag> <cat> <ifo:channel> + <state> <cat> <ifo:flag> -The flags are: +The states are: + = active - = defined but inactive ! = undefined -The environment variable LIGOLW_VETO_FILE must contain the path or URL of a -category definer file.""" +The environment variable LIGOLW_VETO_FILE must contain the path or URL +of a category definer file.""" # simple failure function def failure(error='', errnum=1): sys.stderr.write(error) sys.exit(errnum) -# make a veto:cat dictionary from defined veto cat flags from a veto file -# returns a dictionary with flag names as keys (<ifo>:<channel name>, and -# categories as values -def get_veto_cats(): - cmd = 'ligolw_print -t veto_definer -c ifo -c name -c category -d " " %s' % (VETO_FILE) +# make category/start_time/end_time dictionaries from defined veto cat +# flags from a veto file. returns three dictionaries with flag names +# as keys (<ifo>:<flag>) and categories, start times, and end times as +# values +def get_cats(): + cmd = 'ligolw_print -t veto_definer -d " " -c ifo -c name -c category -c start_time -c end_time %s' % (VETO_FILE) p1 = Popen(cmd, stdout=PIPE, shell=True) - vetos = {} + categories = {} + start_times = {} + end_times = {} for line in p1.communicate()[0].split('\n'): - if line != '': - info = line.split(' ') - vetos[info[0] + ':' + info[1]] = info[2] + if line == '': continue + info = line.split(' ') + flag = info[0] + ':' + info[1] + cat = info[2] + start = float(info[3]) + end = float(info[4]) + if end == 0: end = float('inf') + + categories[flag] = cat + start_times[flag] = start + end_times[flag] = end if p1.wait() == 0: - return vetos + return categories, start_times, end_times else: - failure("Could not retrieve veto definitions from veto definier file.\n") + failure("Could not retrieve info from veto definier file.\n") # retrieve flags of type ('defined', 'active') for time -def get_flags(type, time): +def get_flags(type, time, duration=0): # convert time to integer, since that's what dq_query accepts at the moment time = int(time) - cmd1 = 'ligolw_dq_query --dmt-file --%s %s' % (type, time) + cmd1 = 'ligolw_dq_query --dmt-file --%s --end-pad %s %s' % (type, duration, time) cmd2 = 'ligolw_print -t segment_definer -c ifos -c name -d :' - p1 = Popen(cmd1, stdout=PIPE, shell=True)#, shell=True) + p1 = Popen(cmd1, stdout=PIPE, shell=True) p2 = Popen(cmd2, stdin=p1.stdout, stdout=PIPE, shell=True) flags = [] [flags.append(line) for line in p2.communicate()[0].split('\n') if line != ''] @@ -78,24 +93,31 @@ def get_flags(type, time): if p1.wait() == 0 and p2.wait() == 0: return flags else: - failure("Could not retrieve %s veto flags.\n" % (type)) + failure("Could not retrieve %s flags.\n" % (type)) ############################################################ -CMD = os.path.basename(sys.argv[0]) +CMD = os.path.basename(sys.argv.pop(0)) # single input argument is GPS time (or --help) try: - if sys.argv[1] in ['--help', '-h', '-help']: + if sys.argv[0] in ['--help', '-h', '-help']: usage() sys.exit() else: - time = float(sys.argv[1]) + time = float(sys.argv.pop(0)) except IndexError: failure("Must specify a GPS time. Type '--help' for more info.\n") except ValueError: failure("GPS time must be a number. Type '--help' for more info.\n") - + +try: + duration = int(sys.argv.pop(0)) +except ValueError: + failure("Duration must be an integer. Type '--help' for more info.\n") +except IndexError: + duration = 0 + # get the veto file from the environment VETO_FILE = os.getenv("LIGOLW_VETO_FILE") if VETO_FILE == None: @@ -103,25 +125,32 @@ if VETO_FILE == None: ############################################################ -# get veto dictionary from definer file -vetos = get_veto_cats() +# get categories, start and end times from definer file +categories, start_times, end_times = get_cats() # retrieve active flags for time -actives = get_flags('active', time) +actives = get_flags('active', time, duration) # retrieve defined flags for time -defined = get_flags('defined', time) +defined = get_flags('defined', time, duration) # process all vetos -for channel, cat in vetos.iteritems(): - # set the appropriate flag - if channel in defined: - if channel in actives: - flag = '+' +for flag, category in categories.iteritems(): + + # check that the flag is valid for the time + if time < start_times[flag]: + continue + if time >= end_times[flag]: + continue + + # set the appropriate state indicator + if flag in defined: + if flag in actives: + state = '+' else: - flag = '-' + state = '-' else: - flag = '!' + state = '!' - # output the channel info - print flag, cat, channel + # output the info + print state, category, flag diff --git a/glue/bin/ligolw_dq_query b/glue/bin/ligolw_dq_query index 58b0767105e12ca226e82940da15d0a5569d7477..bfeac4924f8f57528f405f2ab7ceec02070a5c2b 100644 --- a/glue/bin/ligolw_dq_query +++ b/glue/bin/ligolw_dq_query @@ -86,7 +86,12 @@ from glue.ligolw import dbtables PROGRAM_NAME = sys.argv[0].replace('./','') PROGRAM_PID = os.getpid() -USER_NAME = pwd.getpwuid(os.getuid())[0] + +try: + USER_NAME = os.getlogin() +except: + USER_NAME = pwd.getpwuid(os.getuid())[0] + @@ -157,8 +162,8 @@ def parse_command_line(): # Make sure we know who to contact for data if options.segment_url: - if options.segment_url.startswith('ldbd:'): - database_location = options.segment_url[len('ldbd://'):] + if options.segment_url.startswith('ldbd'): + database_location = options.segment_url elif options.segment_url.startswith('file:'): file_location = options.segment_url[len('file://'):] else: @@ -179,7 +184,7 @@ def parse_command_line(): elif options.database: if 'S6_SEGMENT_SERVER' not in os.environ: raise ValueError( "--database specified but S6_SEGMENT_SERVER not set" ) - database_location = os.environ['S6_SEGMENT_SERVER'][len('ldbd://'):] + database_location = os.environ['S6_SEGMENT_SERVER'] elif options.dmt_files: if 'ONLINEDQ' not in os.environ: raise ValueError( "--dmt-files specified but ONLINEDQ not set" ) @@ -296,7 +301,7 @@ def run_report(doc, process_id, engine, include_segments, times, in_segments_onl for ifo, name, version, start_time, end_time in rows: full_name = get_full_name(ifo, name, version) in_times[full_name] = [start_time, end_time] - print '%-45s[%d %d %d)' % (full_name, start_time, tm, end_time) + print '%-45s [%d %d %d)' % (full_name, start_time, tm, end_time) if not in_segments_only: # Segments we are between. Latest end time before of interest. @@ -328,7 +333,7 @@ def run_report(doc, process_id, engine, include_segments, times, in_segments_onl for key in out_times: if key not in in_times: value = out_times[key] - print '%-45s%s %d %s' % (key, value[0], tm, value[1]) + print '%-45s %s %d %s' % (key, value[0], tm, value[1]) def run_active(doc, process_id, engine, include_segments, times): diff --git a/glue/bin/ligolw_inspiral2mon b/glue/bin/ligolw_inspiral2mon index aeb649aa0ac77ebb3532c1464cb1acbc61ad738b..8892c42a5c19f31cadb9a3d8b99b166cd5541b87 100644 --- a/glue/bin/ligolw_inspiral2mon +++ b/glue/bin/ligolw_inspiral2mon @@ -1,8 +1,6 @@ #!/usr/bin/python # -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -35,6 +33,7 @@ import sys import time +from glue import git_version from glue import segments from glue import gpstime from glue.ligolw import ligolw @@ -43,9 +42,9 @@ from glue.ligolw import lsctables from glue.ligolw import utils -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__version__ = "$Revision$"[11:-2] -__date__ = "$Date$"[7:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -58,7 +57,7 @@ __date__ = "$Date$"[7:-2] parser = OptionParser( - version = "%prog CVS $Id$" + version = "Name: %%prog\n%s" % git_version.verbose_msg ) parser.add_option("-c", "--comment", metavar = "text", default = "", help = "set process comment") parser.add_option("-i", "--input", metavar = "filename", help = "read from filename (default = stdin)") diff --git a/glue/bin/ligolw_print b/glue/bin/ligolw_print index da667bb8c3749b3f9e3f1d7eab68f1706d66ef02..3e4b0a1e27f422bc8970dbb1f47b233e7a4d94c4 100644 --- a/glue/bin/ligolw_print +++ b/glue/bin/ligolw_print @@ -1,8 +1,6 @@ #!/usr/bin/python # -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -33,22 +31,23 @@ Print things from LIGO LW XML files. Inspired by lwtprint from LIGOTools. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] - - from optparse import OptionParser -from glue.lal import CacheEntry +from glue import git_version from glue import segmentsUtils +from glue.lal import CacheEntry from glue.ligolw import ligolw from glue.ligolw import table from glue.ligolw import array from glue.ligolw import utils +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date + + # # ============================================================================= # @@ -60,7 +59,7 @@ from glue.ligolw import utils def parse_command_line(): parser = OptionParser( - version = "%prog CVS $Id$", + version = "Name: %%prog\n%s" % git_version.verbose_msg, usage = "%prog [options] [url ...]", description = "Prints the contents of table elements from one or more LIGO Light Weight XML files to stdout in delimited ASCII format. In addition to regular files, the program can read from many common URLs such as http:// and ftp://. Any filename or URL that ends in \".gz\" is assumed to be gzip-compressed, and will be decompressed on input. If no filenames or URLs are given, then input is read from stdin." ) @@ -128,9 +127,6 @@ def ContentHandler(xmldoc): return ligolw.PartialLIGOLWContentHandler(xmldoc, lambda name, attrs: (name in (ligolw.Table.tagName, ligolw.Array.tagName)) and (table.StripTableName(attrs["Name"]) in options.table or array.StripArrayName(attrs["Name"]) in options.array)) -utils.ContentHandler = ContentHandler - - # # ============================================================================= # @@ -193,13 +189,22 @@ if options.constrain_lsc_tables: from glue.ligolw import lsctables +# +# If specific columns have been requested, don't load any others. +# + + +if options.column is not None: + table.Table.loadcolumns = set(options.column) + + # # Loop over input URLs # for url in urls: - xmldoc = utils.load_url(url, verbose = options.verbose, gz = (url or "stdin").endswith(".gz")) + xmldoc = utils.load_url(url, verbose = options.verbose, gz = (url or "stdin").endswith(".gz"), contenthandler = ContentHandler) table.InterningRowBuilder.strings.clear() for elem in ligolw.WalkChildren(xmldoc): if elem.tagName == ligolw.Table.tagName: diff --git a/glue/bin/ligolw_publish_dqxml b/glue/bin/ligolw_publish_dqxml index 8346b469b53349870b1d084f73ba92fe83a717c2..b7307d473ee4edb9e1bf9352918779ddbf918e65 100644 --- a/glue/bin/ligolw_publish_dqxml +++ b/glue/bin/ligolw_publish_dqxml @@ -35,8 +35,6 @@ import logging.handlers from optparse import OptionParser -from glue import LDBDClient -from glue import gsiserverutils from glue import lal from glue import segments from glue import gpstime @@ -95,15 +93,42 @@ if not options.server: if options.server.find(':') < 0: # no port specified host = options.server + port = 30015 else: # server and port specified host, portString = options.server.split(':') port = int(portString) identity = "/DC=org/DC=doegrids/OU=Services/CN=ldbd/%s" % host + + +def openconn(host,port,identity): + if port != 443: + try: + from glue import LDBDClient + from glue import gsiserverutils + myClient = LDBDClient.LDBDClient(host, port, identity) + + except Exception, e: + print >>sys.stderr, \ + "Unable to connect to LDBDServer %s:%d" % (host, port) + if gsiserverutils.checkCredentials(): + print >>sys.stderr, "Got the following error : " + str(e) + print >>sys.stderr, "Enter '%s --help' for usage" % sys.argv[0] + sys.exit(1) + else: + try: + from glue import LDBDWClient + myClient = LDBDWClient.LDBDClient(host, port, identity) + except Exception,e: + print >>sys.stderr, "Unable to connect to LDBDServer %s:%d, %s" % (host, port, str(e)) + sys.exit(1) + return myClient + + if options.ping: - myClient = LDBDClient.LDBDClient(host, port, identity) - msg = myClient.ping() + client = openconn(host, port, identity) + msg = client.ping() print msg sys.exit(0) @@ -176,8 +201,8 @@ try: xmltext = fh.read() fh.close() logger.debug("inserting %s" % infile) - myClient = LDBDClient.LDBDClient(host, port, identity) - result = myClient.insertdmt(xmltext) + client = openconn(host, port, identity) + result = client.insertdmt(xmltext) del xmltext except KeyboardInterrupt: logger.info("caught keyboard interrupt") @@ -214,3 +239,4 @@ except Exception, e: logger.info("exiting") os.unlink(options.pid_file) sys.exit(0) + diff --git a/glue/bin/ligolw_segment_insert b/glue/bin/ligolw_segment_insert index 52af49c83e20ec231ffb9c6b30be71f7c9ee7669..450e0091c7480044e5fda8e83ec0b3a3ef68e465 100644 --- a/glue/bin/ligolw_segment_insert +++ b/glue/bin/ligolw_segment_insert @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python ################################################################### import os @@ -27,6 +27,7 @@ You must have pyRXP installed and in your PYTHONPATH to run %s. try: from glue import gpstime from glue import ldbd + from glue import LDBDWClient from glue import LDBDClient from glue import gsiserverutils from glue import segments @@ -53,7 +54,12 @@ __src__ = "$Source: /usr/local/cvs/lscsoft/glue/bin/ligolw_segment_insert,v $" PROGRAM_NAME = sys.argv[0].replace('./','') PROGRAM_PID = os.getpid() -USER_NAME = os.getlogin() + +try: + USER_NAME = os.getlogin() +except: + USER_NAME = pwd.getpwuid(os.getuid())[0] + ################################################################## # Command Line @@ -131,21 +137,31 @@ if len(errmsg) and not options.ping: print >> sys.stderr, errmsg print >> sys.stderr, "Run\n %s --help\nfor more information." % sys.argv[0] sys.exit(1) + + ######################################################################## -# Open connection to LDBD Server -######################################################################## -try: - myClient = LDBDClient.LDBDClient(host, port, identity) - -except Exception, e: - print >>sys.stderr, \ - "Unable to connect to LDBDServer %s:%d" % (host, port) - if gsiserverutils.checkCredentials(): - print >>sys.stderr, "Got the following error : " + str(e) - print >>sys.stderr, "Enter '%s --help' for usage" % sys.argv[0] - sys.exit(1) +def openconn(host,port,identity): + if port != 443: + try: + myClient = LDBDClient.LDBDClient(host, port, identity) + + except Exception, e: + print >>sys.stderr, \ + "Unable to connect to LDBDServer %s:%d" % (host, port) + if gsiserverutils.checkCredentials(): + print >>sys.stderr, "Got the following error : " + str(e) + print >>sys.stderr, "Enter '%s --help' for usage" % sys.argv[0] + sys.exit(1) + else: + try: + myClient = LDBDWClient.LDBDClient(host, port, identity) + except Exception,e: + print >>sys.stderr, "Unable to connect to LDBDServer %s:%d, %s" % (host, port, str(e)) + sys.exit(1) + return myClient ###################################################################### if options.ping: + myClient = openconn(host,port,identitiy) print myClient.ping() else: ######################################################################## @@ -170,8 +186,8 @@ else: ######################################################################## # Table process and process_params will be popullated by calling the # process/process_params utility - - myClient = LDBDClient.LDBDClient(host, port, identity) + + myClient = openconn(host,port,identity) doc = ligolw.Document() doc.appendChild(ligolw.LIGO_LW()) @@ -189,7 +205,6 @@ else: active_segments = segments.segmentlist() #-----------------Check version and type existence------------------------- - myClient = LDBDClient.LDBDClient(host, port, identity) if options.insert: sql = "SELECT max(segment_definer.version), count(segment_definer.segment_def_id), " sql += "max(segment_summary.end_time) FROM segment_definer, segment_summary WHERE " @@ -202,11 +217,11 @@ else: sql += "name = '%s' AND " % options.name sql += "version = %d " % int(options.version) typexml = myClient.query(sql) - - + del myClient myClient = None + # parse the result returned from the database query type_md = ldbd.LIGOMetadata(xmlparser,lwtparser) xmlparser.eoCB = dtd_uri_callback @@ -367,8 +382,7 @@ Please correct your version number.""" % (options.ifos,options.name,max_version) fp.write(fake_file.getvalue()) fp.close() else: - if not myClient: - myClient = LDBDClient.LDBDClient(host, port, identity) + myClient = openconn(host, port, identity) myClient.insert(fake_file.getvalue()) ####################################################################################### @@ -386,7 +400,7 @@ Please correct your version number.""" % (options.ifos,options.name,max_version) #-----------------------------------------------------------# # query the database to get the segment_def_id and creator_db # of this given segment type - myClient = LDBDClient.LDBDClient(host, port, identity) + myClient = openconn(host,port,identity) sql = "SELECT creator_db, hex(segment_def_id) AS segment_def_id " sql += "From segment_definer WHERE " sql += "ifos = '%s' AND " % options.ifos @@ -597,8 +611,7 @@ Please correct your version number.""" % (options.ifos,options.name,max_version) fp.write(segment_md.xml()) fp.close() else: - if not myClient: - myClient = LDBDClient.LDBDClient(host, port, identity) + myClient = openconn(host,port,identity) myClient.insert(segment_md.xml()) sys.exit(0) diff --git a/glue/bin/ligolw_segment_query b/glue/bin/ligolw_segment_query index bd92f4ed5bc3bc27a5ae5f8f006799b237125cda..d2913d575b0b77146fdd5cc3d6f9c80030b2a5d5 100644 --- a/glue/bin/ligolw_segment_query +++ b/glue/bin/ligolw_segment_query @@ -109,7 +109,7 @@ def parse_command_line(): # Major modes parser.add_option("-p", "--ping", action = "store_true", help = "Ping the target server") parser.add_option("-y", "--show-types", action = "store_true", help = "Returns a xml table containing segment type information: ifos, name, version, segment_definer.comment, segment_summary.start_time, segment_summary.end_time, segment_summary.comment") - parser.add_option("-u", "--query-types", action = "store_true", help = "Returns a ligolw document whose segment_definer table includes all segment types defined in the given period and included by include-segments, and whose segment table includes all active segments matching the same criteria.") + parser.add_option("-u", "--query-types", action = "store_true", help = "Returns a ligolw document whose segment_definer table includes all segment types defined in the given period and included by include-segments and whose segment_summary table indicates the times for which those segments are defined.") parser.add_option("-q", "--query-segments", action = "store_true", help = "Returns a ligolw document whose segment table contains the times included by the include-segments flag and excluded by exclude-segments") # Time options @@ -118,8 +118,8 @@ def parse_command_line(): # Data location options - parser.add_option("-t", "--segment-url", metavar = "segment_url", help = "Segment URL. Users have to specify a prefix 'ldbd://' in front of the actual url where the segment database locates. For example, '--segment-url=ldbd://nldas.ligo-wa.caltech.edu:30015'. Port number is optional, if not present, the default port 30015 will be used. ") - parser.add_option("-d", "--database", metavar = "use_database", action = "store_true", help = "use database specified by environment variable S6_SEGMENT_SERVER. For example, 'S6_SEGMENT_SERVER=ldbd://nldas.ligo-wa.caltech.edu'") + parser.add_option("-t", "--segment-url", metavar = "segment_url", help = "Segment URL. Users have to specify either 'ldbd://' for a secure connection or 'ldbdi://' for an insecure connection in the segment database url. For example, '--segment-url=ldbd://segdb.ligo.caltech.edu:30015'. Port number is optional, if not present, the default port 30015 will be used for secure connections and 30016 for insecure connections. ") + parser.add_option("-d", "--database", metavar = "use_database", action = "store_true", help = "use database specified by environment variable S6_SEGMENT_SERVER. For example, 'S6_SEGMENT_SERVER=ldbd://segdb.ligo.caltech.edu'") parser.add_option("-f", "--dmt-files", metavar = "use_files", action = "store_true", help = "use files in directory specified by environment variable ONLINEDQ, for example, 'ONLINEDQ=file:///path_to_dmt'. 'file://' is the prefix, the acutal directory to DMT xml files starts with '/'.") @@ -151,8 +151,8 @@ def parse_command_line(): # Make sure we know who to contact for data if options.segment_url: - if options.segment_url.startswith('ldbd:'): - database_location = options.segment_url[len('ldbd://'):] + if options.segment_url.startswith('ldbd'): + database_location = options.segment_url elif options.segment_url.startswith('file:'): file_location = options.segment_url[len('file://'):] else: @@ -173,7 +173,7 @@ def parse_command_line(): elif options.database: if 'S6_SEGMENT_SERVER' not in os.environ: raise ValueError( "--database specified but S6_SEGMENT_SERVER not set" ) - database_location = os.environ['S6_SEGMENT_SERVER'][len('ldbd://'):] + database_location = os.environ['S6_SEGMENT_SERVER'] elif options.dmt_files: if 'ONLINEDQ' not in os.environ: raise ValueError( "--dmt-files specified but ONLINEDQ not set" ) @@ -355,8 +355,8 @@ def run_query_types(doc, proc_id, connection, engine, gps_start_time, gps_end_ti for key in segment_types: # Make sure the intervals fall within the query window and coalesce - segment_types[key] &= query_segment segment_types[key].coalesce() + segment_types[key] &= query_segment seg_def_id = seg_def_table.get_next_id() segment_definer = lsctables.SegmentDef() @@ -437,8 +437,9 @@ def run_query_segments(doc, process_id, engine, gps_start_time, gps_end_time, in excluded_segments = segmentdb_utils.query_segments(engine, 'segment', ex_segdefs) excluded_segments = reduce(operator.or_, excluded_segments).coalesce() - found_segments -= excluded_segments found_segments.coalesce() + found_segments -= excluded_segments + # Add the result type to the segment definer table diff --git a/glue/bin/ligolw_segments_from_cats b/glue/bin/ligolw_segments_from_cats index e8218986bce1a762dbdce12b9d9e5f54a86687e2..6fdf036881a1e4ea122991f8c136494dd046b504 100644 --- a/glue/bin/ligolw_segments_from_cats +++ b/glue/bin/ligolw_segments_from_cats @@ -153,8 +153,8 @@ def parse_command_line(): # (This is redundant with ligolw_segment_query, maybe move to # query_engine) if options.segment_url: - if options.segment_url.startswith('ldbd:'): - database_location = options.segment_url[len('ldbd://'):] + if options.segment_url.startswith('ldbd'): + database_location = options.segment_url elif options.segment_url.startswith('file:'): file_location = options.segment_url[len('file://'):] else: @@ -175,7 +175,7 @@ def parse_command_line(): elif options.database: if 'S6_SEGMENT_SERVER' not in os.environ: raise ValueError( "--database specified by S6_SEGMENT_SERVER not set" ) - database_location = os.environ['S6_SEGMENT_SERVER'][len('ldbd://'):] + database_location = os.environ['S6_SEGMENT_SERVER'] elif options.dmt_file: if 'ONLINEDQ' not in os.environ: raise ValueError( "--dmt-file specified but ONLINEDQ not set" ) @@ -318,8 +318,9 @@ if __name__ == '__main__': end_time = now veto_interval = glue.segments.segmentlist([glue.segments.segment(start_time, end_time)]) - veto_interval &= cli_interval veto_interval.coalesce() + veto_interval &= cli_interval + if len(veto_interval) > 0: segdefs.append( (ifo, name, version, veto_interval[0][0], veto_interval[0][1], start_pad, end_pad) ) diff --git a/glue/bin/ligolw_sqlite b/glue/bin/ligolw_sqlite index 5acb4e427fb66adff7c4c0255d209daef846f1eb..b6e5945a490b4aa8f7bffa97950e8994f4728188 100644 --- a/glue/bin/ligolw_sqlite +++ b/glue/bin/ligolw_sqlite @@ -1,8 +1,6 @@ #!/usr/bin/python # -# $Id$ -# -# Copyright (C) 2007 Kipp C. Cannon +# Copyright (C) 2007 Kipp Cannon # # 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 @@ -43,6 +41,7 @@ except ImportError: import sys +from glue import git_version from glue.lal import CacheEntry from glue.ligolw import dbtables from glue.ligolw.utils import ligolw_sqlite @@ -57,9 +56,9 @@ dbtables.ligolwtypes.ToPyType["ilwd:char"] = unicode dbtables.lsctables.SnglInspiralTable.next_id = dbtables.lsctables.SnglInspiralID(0) -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -77,7 +76,7 @@ def parse_command_line(): names. """ parser = OptionParser( - version = "%prog CVS $Id$", + version = "Name: %%prog\n%s" % git_version.verbose_msg, usage = "%prog -d|--database filename [options] [url ...]", description = "Transfers data between LIGO Light Weight XML files and SQLite database files. The contents of the XML documents listed on the command line will be inserted, in order, into the SQLite database file identified by the --database argument. If the database exists the contents of the XML documents will be added to it, otherwise a new database file is created. If --extract is given on the command line, then the database contents will be converted to XML and written to the file named by this argument. The input XML documents can be regular files or many common URLs such as ftp:// and http://. If no input documents are named then input is read from stdin unless --extract is given in which case the datase contents are extracted to XML without reading any input documents. Input XML documents ending in .gz will be gzip-decompressed while being read, and if the file named by --extract ends in .gz then it will be gzip-compressed when written." ) @@ -98,7 +97,6 @@ def parse_command_line(): return options, (urls or [None]) - # # ============================================================================= # @@ -112,6 +110,7 @@ def parse_command_line(): # Command line # + if __name__ == '__main__': options, urls = parse_command_line() @@ -119,16 +118,21 @@ if __name__ == '__main__': will_replace_file = will_write_to_file and options.replace will_use_tmp_space = will_write_to_file and (options.tmp_space is not None) + # # Open database # - target = dbtables.get_connection_filename(options.database, tmp_path = (will_use_tmp_space or None) and options.tmp_space, replace_file = will_replace_file, verbose = options.verbose) + + target = dbtables.get_connection_filename(options.database, tmp_path = (will_use_tmp_space or None) and options.tmp_space, replace_file = will_replace_file, verbose = options.verbose) connection = ligolw_sqlite.setup(target) + # # Insert files # + + if (options.extract is None) or (urls != [None]): ligolw_sqlite.insert(connection, urls, preserve_ids = options.preserve_ids, verbose = options.verbose) @@ -136,6 +140,8 @@ if __name__ == '__main__': # # Extract database contents # + + if options.extract is not None: if options.extract == "-": # stdout @@ -146,12 +152,23 @@ if __name__ == '__main__': # # Close database # + + connection.close() + # # Move database to final location # + + dbtables.put_connection_filename(options.database, target, verbose = options.verbose) + + # + # Done + # + + if options.verbose: print >>sys.stderr, "done." diff --git a/glue/bin/ligolw_veto_sngl_trigger b/glue/bin/ligolw_veto_sngl_trigger index e26f9d82412040a16dc1c6987404ccd482397a57..f5b42f67312073cd641c3f99f4a950e1fb9ef400 100644 --- a/glue/bin/ligolw_veto_sngl_trigger +++ b/glue/bin/ligolw_veto_sngl_trigger @@ -195,7 +195,7 @@ if __name__ == '__main__': gps_start_time = gps_end_time - (60 * 60 * 24) # Find trigger files - trigger_files = segmentdb_utils.get_all_files_in_range(options.trigger_dir, gps_start_time, gps_end_time) + trigger_files = segmentdb_utils.get_all_files_in_range(options.trigger_dir, gps_start_time, gps_end_time, pad=0) # If there are no files in the time range then there's nothing to do if not trigger_files: @@ -274,6 +274,38 @@ if __name__ == '__main__': cursor.execute("UPDATE %s SET process_id='process:process_id:0'" % table_name) cursor.execute("UPDATE search_summary SET process_id='process:process_id:0'") + # Determine which tables we're outputting + output_tables = [] + for name in ['process','process_params',table_name,'search_summary','summ_value']: + count = int(cursor.execute("select count(*) from sqlite_master where name='%s'" % name).fetchone()[0]) + if count: + output_tables.append(name) + + # Write out a set of triggers that cuts out non-science time + for ifo in options.ifos.split(','): + subquery = "SELECT %s.end_time FROM %s, segment, segment_definer " % (table_name, table_name) + subquery += " WHERE segment_definer.segment_def_id = segment.segment_def_id " + subquery += " AND segment_definer.name = 'DMT-SCIENCE' " + subquery += " AND segment_definer.ifos = '%s' " % (ifo) + subquery += " AND (%s.end_time BETWEEN segment.start_time AND segment.end_time)" % (table_name) + + sql = 'DELETE FROM %s WHERE end_time NOT IN (%s)' % (table_name, subquery) + + cursor.execute(sql) + + base_dir = options.output_dir or '.' + first_four = gps_start_time / 100000 + outdir = "%s/%s-SCI/%s-SCI-%d" % (base_dir, ifo, ifo, first_four) + outname = "%s/%s-SCI-%d-%d.xml" % (outdir, ifo, gps_start_time, (gps_end_time - gps_start_time)) + + try: + os.makedirs(outdir) + except: + pass + + ligolw_sqlite.extract(connection, outname, table_names=output_tables) + + # Backup the sngl_ table sql = cursor.execute("SELECT sql FROM sqlite_master WHERE name='%s'" % table_name).fetchone()[0] pos = sql.index(table_name) + len(table_name) @@ -283,12 +315,6 @@ if __name__ == '__main__': cursor.execute('INSERT INTO %s_backup SELECT * FROM %s' % (table_name, table_name)) - # Determine which tables we're outputting - output_tables = [] - for name in ['process','process_params',table_name,'search_summary','summ_value']: - count = int(cursor.execute("select count(*) from sqlite_master where name='%s'" % name).fetchone()[0]) - if count: - output_tables.append(name) ops = [] if options.separate: @@ -338,7 +364,7 @@ if __name__ == '__main__': # If we started from a timestamp file, update it if options.timestamp_file: f = open(options.timestamp_file, 'w') - print >>f, gps_end_time + print >>f, (gps_end_time + 1) f.close() # Clean up diff --git a/glue/bin/segdb_coalesce b/glue/bin/segdb_coalesce index 4fa9facc56813740213c9bc6c84222db7f53d70b..e4135360d2e534e311f7300223c1fdf01289d609 100644 --- a/glue/bin/segdb_coalesce +++ b/glue/bin/segdb_coalesce @@ -1,282 +1,164 @@ -#!/usr/bin/env python - -# This script coalesces segment and segment_summary table at LHO and LLO segment database machine -# At LHO, this script only coalesces H1, H2 segments -# At LLO, this script only coalesces L1 segments +#!/usr/bin/python +# +# xml dq publishing script for virgo (or other) dq xml files +# +# $Id$ +# +# Copyright (C) 2009 Duncan Brown +# +# This is part of the Grid LSC User Environment (GLUE) +# +# GLUE 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 +# this program. If not, see <http://www.gnu.org/licenses/>. import sys +import pwd import os +import re +import exceptions +import re import time -import socket -import ConfigParser -from optparse import OptionParser - - -try: - import DB2 -except: - pass - -try: - from glue import gpstime - from glue import segments -except ImportError, e: - print >> sys.stderr, """ -Error: unable to import modules from glue. - -Check that glue is correctly installed and in your PYTHONPATH. - -%s -""" % e - -#================================================================================ -__author__ = "Ping Wei <piwei@physics.syr.edu>" -__date__ = "$Date$"[7:-2] -__version__ ="$Revision$"[11:-2] -__src__ = "$Source$" -#================================================================================ -# Command Line -#================================================================================ -def parse_command_line(): - parser = OptionParser() - - parser.add_option("-s", "--gps-start-time", metavar = "gps_start_time", help = "Start of GPS time range") - parser.add_option("-e", "--gps-end-time", metavar = "gps_end_time", help = "End of GPS time range") - parser.add_option("-d", "--database-name", metavar = "database_name", help = "name of the database you run coalescing on. Currently segdb_coalesce only supports seg6_lho, seg6_llo and seg6_cit") - - opts, others = parser.parse_args() - - return opts - - -options = parse_command_line() - -if not options.gps_start_time: - print "Error: --gps-start-time is required" - sys.exit(1) -if not options.gps_end_time: - print "Error: --gps-end-time is required" - sys.exit(1) -if not options.database_name: - print "Error: --database-name is required, please specify one of [seg6_lho | seg6_llo | seg6_cit ]" - sys.exit(1) - - -# Set up connection to the database -database = options.database_name -try: - dbconn = DB2.connect(dsn=database, uid='', pwd='') - curs = dbconn.cursor() -except Exception, e: - print e - sys.exit(1) - -# Get coalesce time range -st = int(options.gps_start_time) -et = int(options.gps_end_time) - -#================================================================================ -# Insert a new row in the process table -#================================================================================ -# get current_time for later use -current_time = gpstime.GpsSecondsFromPyUTC(time.time()) - - -# prepare values for the new row to be inserted into the process table -program = sys.argv[0].replace('./','') -node = socket.gethostname() -username = os.getlogin() -unix_procid = os.getpid() -start_time = current_time -end_time = None -jobid = 0 -domain = 'coalesce_local' - -sql = "select hex(GENERATE_UNIQUE()) from sysibm.sysdummy1" -curs.execute(sql) -hex_procid = curs.fetchone()[0] -process_id = 'x' + '\'' + hex_procid + '\'' +import logging +import logging.handlers -if database == 'seg6_lho': - process_creator_db = 1 -elif database == 'seg6_llo': - process_creator_db = 2 -elif database == 'seg6_cit': - process_creator_db = 3 +from optparse import OptionParser +from glue import gsiserverutils +from glue import segments +from glue import gpstime -# insert new row into process table -sql = "INSERT INTO process " -sql += "(program, is_online, node, username, unix_procid, start_time, jobid, domain, process_id, creator_db) " -sql += "VALUES ('%s', 0, '%s', '%s', %d, %d, %d, '%s',%s, %d)" % (program, node, username, unix_procid, start_time, jobid, domain, process_id, process_creator_db) -curs.execute(sql) -curs.execute("commit") +from glue.ligolw import ligolw +from glue.ligolw import lsctables +from glue.ligolw import utils as ligolw_utils +from glue.ligolw.utils import segments as ligolw_segments +from glue.ligolw.utils import process as ligolw_process +from glue.ligolw.utils import coalesce_db as ligolw_coalesce -# get the BLOB process_id for later reference -sql = "SELECT BLOB(process_id) from process where hex(process_id)='%s' " % hex_procid -curs.execute(sql) -blob_procid = curs.fetchone()[0] +from glue.segmentdb import segmentdb_utils -#======================================================================== -# fetch, coalesce and delete segments and summarys -#======================================================================== -# create the tmp segment table with primary ids to delete -try: - curs.execute("CREATE TABLE tmp_co_seg (prim_id CHAR(13) FOR BIT DATA NOT NULL PRIMARY KEY);") - curs.execute("CREATE INDEX tmp_co_seg_in on tmp_co_seg(prim_id)") - curs.execute("commit") -except: - # if table already exist, delete its content - curs.execute("delete from tmp_co_seg") - curs.execute("commit") +PROGRAM_NAME = sys.argv[0].replace('./','') +PROGRAM_PID = os.getpid() -# create the tmp summary table with primary ids to delete try: - curs.execute("CREATE TABLE tmp_co_sum (prim_id CHAR(13) FOR BIT DATA NOT NULL PRIMARY KEY);") - curs.execute("CREATE INDEX tmp_co_sum_in on tmp_co_sum(prim_id)") - curs.execute("commit") + USER_NAME = os.getlogin() except: - # if table already exist, delete its content - curs.execute("delete from tmp_co_sum") - curs.execute("commit") - -# find unique segment types exist in the database within the time range specified by user -sql = "SELECT distinct hex(segment_def_id) from segment_summary " -sql += "WHERE creator_db = %d " % process_creator_db -sql += "AND start_time <= %d " % et -sql += "AND end_time >= %d " % st - -curs.execute(sql) -def_ids = curs.fetchall() - - -# loop in the segment types to fetch, coalesce, insert and delete -for d in def_ids: - # get the BLOB segment_def_id for later use - sql = "SELECT BLOB(segment_def_id), ifos, name " - sql += "FROM segment_definer " - sql += "WHERE hex(segment_def_id) = '%s' " % d[0] - sql += "AND creator_db = %d " % process_creator_db - - curs.execute(sql) - result = curs.fetchone() - blob_defid = result[0] - ifos = result[1].strip() - name = result[2] - - # get the segment start_time, end_time to coalesce, and according primary key to delete - sql = "SELECT start_time, end_time, BLOB(segment_id) FROM segment " - sql += "WHERE hex(segment_def_id) = '%s' and segment_def_cdb = %d " % (d[0], process_creator_db) - sql += "AND start_time <= %d " % et - sql += "AND end_time >= %d " % st - sql +=" ORDER BY start_time " - - print "Retrieving start_time and end_time to coalesce for %s, %s ..." %(ifos, name) - curs.execute(sql) - seg_bf_cos = curs.fetchall() # get the segments to coalesce - - # get the summary start_time, end_time to coalesce, and according primary key to delete - sql = "SELECT start_time, end_time, BLOB(segment_sum_id) " - sql += "FROM segment_summary " - sql += "WHERE hex(segment_def_id) = '%s' and segment_def_cdb = %d " % (d[0], process_creator_db) - sql += "AND start_time <= %d " % et - sql += "AND end_time >= %d " % st - sql +=" ORDER BY start_time " - - curs.execute(sql) - sum_bf_cos = curs.fetchall() # get the summarys to coalesce - - - # coalesce the segments and summarys, populate the tmp tables with the primary ids to delete - print "Coalescing segments ... " - seg_ids_to_delete = [] - sum_ids_to_delete = [] - segs = segments.segmentlist([]) - sums = segments.segmentlist([]) - for bf in seg_bf_cos: - seg = segments.segment(int(bf[0]), int(bf[1])) - segs.append(seg) - seg_ids_to_delete.append(bf[2]) - - for bf in sum_bf_cos: - sum = segments.segment(int(bf[0]), int(bf[1])) - sums.append(sum) - sum_ids_to_delete.append(bf[2]) + USER_NAME = pwd.getpwuid(os.getuid())[0] - segs.coalesce() - sums.coalesce() +__author__ = "Ping Wei <piwei@physics.syr.edu>" +__date__ = "$Date$"[7:-2] +__version__ = "$Revision$"[11:-2] - # populate the tmp tables with primary ids to delete - sql = "INSERT INTO tmp_co_seg VALUES(?) " - curs.executemany(sql, seg_ids_to_delete) - curs.execute("commit") +parser = OptionParser( + version = "%prog CVS $Header$", + usage = "%prog [OPTIONS]", + description = "Coalesce segments and summary intervals in the database") - sql = "INSERT INTO tmp_co_sum VALUES(?) " - curs.executemany(sql, sum_ids_to_delete) - curs.execute("commit") +parser.add_option("-d", "--database-name", metavar = "database_name", help = "name of the database you run coalescing on") +parser.add_option("-S", "--state-file", metavar = "FILE", help = "read coalesced time range from FILE") +parser.add_option("-P", "--pid-file", metavar = "FILE", help = "use FILE as process lock file") +parser.add_option("-l", "--log-file", metavar = "FILE", help = "use FILE as log file") +parser.add_option("-L", "--log-level", metavar = "LEVEL", default = "INFO", help = "set logging level to LEVEL") +options, filenames = parser.parse_args() +if not options.database_name: + raise ValueError, "missing argument --database-name" +if not options.state_file: + raise ValueError, "missing argument --state-file" +if not options.pid_file: + raise ValueError, "missing argument --pid-file" +if not options.log_file: + raise ValueError, "missing argument --log-file" - # insert coalesced segments back in to the database - print "Inserting coalesced segments back in ... " - - # insert coalesced segs into segment table - insert_list = [] - for s in segs: - # generate unique id for insertion - curs.execute("VALUES BLOB(GENERATE_UNIQUE())") - prim_id = curs.fetchone()[0] - - # generate a list of values to insert using executemany() - insert_list.append((prim_id, process_creator_db, s[0], s[1], blob_defid, process_creator_db, blob_procid)) - - sql = "INSERT INTO segment " - sql += "(segment_id, creator_db, start_time, end_time, segment_def_id, segment_def_cdb, process_id) " - sql += "VALUES (?,?,?,?,?,?,?) " - curs.executemany(sql, insert_list) - curs.execute("commit") - - - # insert coalesced sums into segment_summary table - insert_list = [] - for s in sums: - # generate unique id for insertion - curs.execute("VALUES BLOB(GENERATE_UNIQUE())") - prim_id = curs.fetchone()[0] - - # generate a list of values to insert using executemany() - insert_list.append((prim_id, process_creator_db, s[0], s[1], blob_defid, process_creator_db, blob_procid)) - - sql = "INSERT INTO segment_summary " - sql += "(segment_sum_id, creator_db, start_time, end_time, segment_def_id, segment_def_cdb, process_id) " - sql += "VALUES (?,?,?,?,?,?,?) " - curs.executemany(sql, insert_list) - curs.execute("commit") - +# check for an existing lock file +if os.access(options.pid_file,os.F_OK): + raise RuntimeError, "lock file exists: %s" % options.pid_file - # delete un-coalesced segments - print "deleting un-coalesced segemnts ... " - print - sql = "DELETE FROM segment " - sql += "WHERE segment_id in (SELECT * FROM tmp_co_seg ORDER BY prim_id)" - curs.execute(sql) - curs.execute("commit") +# create lock file +fp = open(options.pid_file, "w") +fp.write("lock") +fp.close() - sql = "DELETE FROM segment_summary " - sql += "WHERE segment_sum_id in (SELECT * FROM tmp_co_sum ORDER BY prim_id)" - sql += "AND segment_def_cdb = %d " % process_creator_db - curs.execute(sql) - curs.execute("commit") - # empty the tmp table for the next segment type - curs.execute("DELETE FROM tmp_co_seg") - curs.execute("DELETE FROM tmp_co_sum") - curs.execute("commit") +try: + # setup the output file + outdoc = ligolw.Document() + outdoc.appendChild(ligolw.LIGO_LW()) + proc_id = ligolw_process.register_to_xmldoc(outdoc, PROGRAM_NAME, options.__dict__).process_id + + # set up logging + logger = logging.getLogger('segdb_coalesce') + handler = logging.handlers.RotatingFileHandler(options.log_file, 'a', 1048576, 5) + formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') + handler.setFormatter(formatter) + logger.addHandler(handler) + logger.setLevel(eval("logging." + options.log_level)) + logger.debug("pid file = " + options.pid_file) + logger.debug("log file = " + options.log_file) + logger.debug("log level = " + options.log_level) + + # read in the coalesced time range + logger.debug("reading state from %s" % options.state_file) + indoc = ligolw_utils.load_url(options.state_file, gz = (options.state_file or "stdin").endswith(".gz")) + coalesced_range = segmentdb_utils.find_segments(indoc,"P1:COALESCED:0") + end_times = [] + for c in coalesced_range: + end_times.append(c[1]) + max_endtime = max(end_times) + logger.debug("coalesced time range = %s" % str(coalesced_range)) + + # make a list of the time range that need to be coalesced: + ######################### + current_time = gpstime.GpsSecondsFromPyUTC(time.time()) + pending_range = [(max_endtime, current_time)] + st = max_endtime + et = current_time + logger.debug("pending range is [%d,%d)" % (st,et)) + + # coalesce the pending range and add them to the list of coalesced range + logger.debug("start coalescing") + result,data_existence = ligolw_coalesce.coalesce_seg(options.database_name,st,et) + if result == 0 and data_existence == 1: + coalesced_range |= segments.segmentlist([(st,et)]) + coalesced_id = segmentdb_utils.add_to_segment_definer(outdoc,proc_id,"P1","COALESCED",0) + segmentdb_utils.add_to_segment(outdoc,proc_id,coalesced_id,coalesced_range) + + # write the new segment state file on top of the old one + ligolw_utils.write_filename(outdoc, options.state_file) + + logger.info("finished coalescing range [%d,%d)" % (st,et)) + logger.info("exiting") + elif result == 0 and data_existence != 1: + logger.info("no data found in time range, state_file remians unchanged") + if result != 0 : + logger.error("fail to coalesce, state_file remains unchanged") + try: + os.unlink(options.pid_file) + except: + pass + logger.error(result) + sys.exit(1) +except Exception, e: + try: + logger.error(str(e)) + except: + pass + print >>sys.stderr, "runtime error (%s)" % str(e) + os.unlink(options.pid_file) + sys.exit(1) -curs.execute("drop table tmp_co_seg") -curs.execute("drop table tmp_co_sum") -curs.execute("commit") -curs.close() +os.unlink(options.pid_file) sys.exit(0) + diff --git a/glue/debian/changelog b/glue/debian/changelog index 9d4bf629cfd9d48a169d428925da94afbfc6dcc7..a1a00e09fc1c9b969a020007ebd9a877e0e0c36b 100644 --- a/glue/debian/changelog +++ b/glue/debian/changelog @@ -1,3 +1,27 @@ +python-glue (1.28.1-2) unstable; urgency=low + + * python version fix (c&p from 1.28-5) + + -- Steffen Grunewald <steffen.grunewald@aei.mpg.de> Wed, 26 Aug 2009 09:09:09 +0200 + +python-glue (1.28.1-1) unstable; urgency=low + + * Initial release of 1.28.1 + + -- Adam Mercer <adam.mercer@ligo.org> Thu, 13 Aug 2009 11:45:16 -0500 + +python-glue (1.28-1) unstable; urgency=low + + * Initial release of 1.28 + + -- Duncan Brown <dabrown@physics.syr.edu> Mon, 27 Jun 2009 22:30:00 -0500 + +python-glue (1.27-1) unstable; urgency=low + + * Initial release of 1.27 + + -- Duncan Brown <dabrown@physics.syr.edu> Mon, 27 Jun 2009 22:20:00 -0500 + python-glue (1.26-1) unstable; urgency=low * Initial release of 1.26 diff --git a/glue/debian/control b/glue/debian/control index 3e7dbf38f230af019548e960c6effd37475b7177..6bde6463ac2923542dbc41f7fc647ad7bbc5483d 100644 --- a/glue/debian/control +++ b/glue/debian/control @@ -7,8 +7,8 @@ Standards-Version: 3.7.2 Package: python-glue Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, python2.4 (>= 2.4), python-cjson, python-m2crypto -Recommends: python-numpy (>= 1.0), python-xml, python-pysqlite2 (>= 2.2), libsqlite3-0 (>= 3.3), pyrxp | python-pyrxp, python2.5 +Depends: ${shlibs:Depends}, ${misc:Depends}, python (>= 2.4), python-cjson, python-m2crypto +Recommends: python-numpy (>= 1.0), python-xml, python-pysqlite2 (>= 2.2), libsqlite3-0 (>= 3.3), pyrxp | python-pyrxp, python2.4, python2.5 Replaces: glue Conflicts: glue Description: The Grid LSC User Environment diff --git a/glue/debian/rules b/glue/debian/rules index 610610e6708b4ee2f0c3e7eae47199ac50dae76e..beb7d85c1e33cd9c1455d139d3cd9f530771368c 100755 --- a/glue/debian/rules +++ b/glue/debian/rules @@ -62,7 +62,7 @@ install: build # $(MAKE) DESTDIR=$(CURDIR)/debian/$(PACKAGE) install mkdir -p $(CURDIR)/debian/$(PACKAGE)/$(PREFIX)/share/doc/glue set -e; \ - for v in 2.5 2.4; do \ + for v in 2.4 2.5; do \ CFLAGS="$(CFLAGS)" \ python$$v setup.py build; \ CFLAGS="$(CFLAGS)" \ @@ -86,10 +86,11 @@ install: build set -e; \ for i in `find debian/$(PACKAGE)/$(PREFIX)/bin -type f`; do \ echo $$i; \ - if head -n1 $$i | grep -q '^#!.*python$$' ; then \ - sed -i '1s/python$$/python2.4/' $$i; \ + if head -n1 $$i | grep -q '^#!.*python2\..' ; then \ + sed -i '1s/python2\../python/' $$i; \ fi ; \ done + cp -p debian/glue-user-env.* $(CURDIR)/debian/$(PACKAGE)/$(PREFIX)/etc/ binary: build install dh_testdir diff --git a/glue/etc/glue.spec b/glue/etc/glue.spec index 8a5b5bcdfd0d421d33fca13c9432914af5e8f434..75cd1a2746b1d2f2e4f1bac05c94dc69ed409c52 100644 --- a/glue/etc/glue.spec +++ b/glue/etc/glue.spec @@ -6,7 +6,7 @@ Name: glue Summary: The Grid LSC User Environment -Version: 1.26 +Version: 1.28.1 Release: 1.lscsoft License: None Group: Development/Libraries @@ -46,6 +46,9 @@ rm -rf $RPM_BUILD_ROOT %{_prefix}/var/ %changelog +* Mon Jul 27 2009 Duncan Brown <dabrown@physics.syr.edu> +- First S6 release of glue + * Wed Jul 01 2009 Duncan Brown <dabrown@physics.syr.edu> - Pre S6 release of glue diff --git a/glue/etc/ldbdserver.ini b/glue/etc/ldbdserver.ini index 894222b9cb7b6aafcf6e613780b015385e28dd38..25770821543109302ef594ccfc2944577f1f829e 100644 --- a/glue/etc/ldbdserver.ini +++ b/glue/etc/ldbdserver.ini @@ -1,19 +1,23 @@ [ldbdd] server = LDBDServer -port = 30020 -gridmap = /export/ldbd/etc/grid-security/ldbdserver/grid-mapfile -certfile = /export/ldbd/etc/grid-security/ldbdserver/ldbdcert.pem -keyfile = /export/ldbd/etc/grid-security/ldbdserver/ldbdkey.pem +secure = yes +ipaddr = '' +port = +gridmap = /usr3/ldbd/etc/grid-mapfile +gridmap_insert = /usr3/ldbd/etc/grid-mapfile-insert +gridmap_insertmap = /usr3/ldbd/etc/grid-mapfile-insertmap +gridmap_insertdmt = /usr3/ldbd/etc/grid-mapfile-insertdmt +certfile = /usr3/ldbd/etc/ldbdcert.pem +keyfile = /usr3/ldbd/etc/ldbdkey.pem dbname = segment dbuser = grid -dbpasswd = -rls = +dbpasswd = +rls = max_client_byte_string = 1048576 -pidfile = /export/ldbd/var/run/ldbdserver.pid -logfile = /export/ldbd/var/log/ldbdserver.log +pidfile = /usr3/ldbd/var/run/ldbdd.pid +logfile = /usr3/ldbd/var/log/ldbdd.log logmaxbytes = 1024 * 1024 * 1 logbackupcount = 5 loglevel = DEBUG ldbd_com = PING,QUERY,INSERT,INSERTMAP,INSERTDMT db2_com = SELECT,UPDATE,INSERT - diff --git a/glue/etc/ldbduser.ini b/glue/etc/ldbduser.ini index 951affa3c3ec3fa5e7645db819def3892cc9c72a..8b0d2c45425a3a312fbd62b44033c4611d4818b2 100644 --- a/glue/etc/ldbduser.ini +++ b/glue/etc/ldbduser.ini @@ -1,18 +1,24 @@ [ldbdd] server = LDBDServer +secure = yes +ipaddr = '' port = 30015 -gridmap = /export/ldbd/etc/grid-security/ldbduser/grid-mapfile -certfile = /export/ldbd/etc/grid-security/ldbduser/ldbdcert.pem -keyfile = /export/ldbd/etc/grid-security/ldbduser/ldbdkey.pem +gridmap = /usr3/ldbd/etc/grid-mapfile +gridmap_insert = /usr3/ldbd/etc/grid-mapfile-insert +gridmap_insertmap = /usr3/ldbd/etc/grid-mapfile-insertmap +gridmap_insertdmt = /usr3/ldbd/etc/grid-mapfile-insertdmt +certfile = /usr3/ldbd/etc/ldbdcert.pem +keyfile = /usr3/ldbd/etc/ldbdkey.pem dbname = segment dbuser = grid -dbpasswd = -rls = +dbpasswd = +rls = max_client_byte_string = 1048576 -pidfile = /export/ldbd/var/run/ldbduser.pid -logfile = /export/ldbd/var/log/ldbduser.log +pidfile = /usr3/ldbd/var/run/ldbdd.pid +logfile = /usr3/ldbd/var/log/ldbdd.log logmaxbytes = 1024 * 1024 * 1 logbackupcount = 5 +loglevel = DEBUG ldbd_com = PING,QUERY db2_com = SELECT loglevel = DEBUG diff --git a/glue/etc/ligolw.xsl b/glue/etc/ligolw.xsl index 49b0e659038223d41031b98edd07ce4728f13640..8d65837632916398ef293adcbb3c3d9367932937 100644 --- a/glue/etc/ligolw.xsl +++ b/glue/etc/ligolw.xsl @@ -26,7 +26,7 @@ </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> - <script type="text/javascript" src="ligolw-cbc3.js"></script> + <script type="text/javascript" src="ligolw.js"></script> <script> $(document).ready(function() { setup(); }); </script> diff --git a/glue/etc/segdb.conf b/glue/etc/segdb.conf index c72f1021bdfe49514b31834cdeb12c7f255d0d33..91623a5e27a9db31d74b97fa23263f29184dfd7e 100644 --- a/glue/etc/segdb.conf +++ b/glue/etc/segdb.conf @@ -13,6 +13,15 @@ SSLRandomSeed startup file:/dev/urandom 256 SSLRandomSeed connect builtin SSLCryptoDevice builtin +# One process with 15 threads for serving LDBD +WSGIDaemonProcess ldbd threads=15 user=ldbd group=ldbd python-path=/usr1/ldbd/segdb_sw/lib64/python2.4/site-packages:/usr1/ldbd/glue/lib64/python2.4/site-packages:/usr1/ldbd/glue/lib/python2.4/site-packages:/usr/lib64/python2.4/site-packages + +# Matches for ldbd +WSGIScriptAliasMatch /ldbd/.* /var/www/html/ldbd/LDBDWServer.wsgi + +# Load LDBD server on startup +WSGIImportScript /var/www/html/ldbd/LDBDWServer.wsgi process-group=ldbd application-group=%{GLOBAL} + <VirtualHost 128.230.52.70:443> DocumentRoot /opt/lscsoft/glue/var/php ServerName metaserver.phy.syr.edu:443 @@ -59,4 +68,22 @@ SSLCryptoDevice builtin require valid-user </Location> + <Location /dq_report> + AuthType Kerberos + SSLRequireSSL + AuthName "This content is viewable by only LIGO/Virgo personnel. Please enter your LIGO Directory name, e.g. albert.einstein, and password to continue." + KrbAuthRealms LIGO.ORG + Krb5KeyTab /etc/httpd/conf/keytab + require valid-user + </Location> + + <Directory /var/www/html/ldbd> + SSLVerifyClient require + SSLVerifyDepth 10 + SSLOptions +StdEnvVars +ExportCertData + WSGIProcessGroup ldbd + WSGIApplicationGroup %{GLOBAL} + Options -Indexes + </Directory> + </VirtualHost> diff --git a/glue/glue/LDBDClient.py b/glue/glue/LDBDClient.py index 31aeff36ed26042ba1115d35d6b8497dec94e6d8..5f918d66a2dc8acab70d98f10548b0c62e9349a2 100644 --- a/glue/glue/LDBDClient.py +++ b/glue/glue/LDBDClient.py @@ -199,24 +199,38 @@ class LDBDClient(object): pass try: - # create TCPIOAttr instance and set authentication mode to be GSSAPI + # create TCPIOAttr instance clientAttr = io.TCPIOAttr() - clientAttr.set_authentication_mode( - io.ioc.GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI) - - # create AuthData instance and set expected identity authData = io.AuthData() - authData.set_identity(identity) + soc = io.GSITCPSocket() - # set authorization, channel, and delegation modes - clientAttr.set_authorization_mode( - io.ioc.GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, authData) - clientAttr.set_channel_mode( - io.ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR) - clientAttr.set_delegation_mode( - io.ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_LIMITED_PROXY) + if identity is None: + # try an unauthenticated connection + clientAttr.set_authentication_mode( + io.ioc.GLOBUS_IO_SECURE_AUTHENTICATION_MODE_NONE) + clientAttr.set_authorization_mode( + io.ioc.GLOBUS_IO_SECURE_AUTHORIZATION_MODE_NONE, authData) + clientAttr.set_channel_mode( + io.ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR) + clientAttr.set_delegation_mode( + io.ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_NONE) + + else: + # set authentication mode to be GSSAPI + clientAttr.set_authentication_mode( + io.ioc.GLOBUS_IO_SECURE_AUTHENTICATION_MODE_GSSAPI) + + # set expected identity + authData.set_identity(identity) + + # set authorization, channel, and delegation modes + clientAttr.set_authorization_mode( + io.ioc.GLOBUS_IO_SECURE_AUTHORIZATION_MODE_IDENTITY, authData) + clientAttr.set_channel_mode( + io.ioc.GLOBUS_IO_SECURE_CHANNEL_MODE_CLEAR) + clientAttr.set_delegation_mode( + io.ioc.GLOBUS_IO_SECURE_DELEGATION_MODE_LIMITED_PROXY) - soc = io.GSITCPSocket() soc.connect(host, port, clientAttr) self.socket = soc self.sfile = soc.makefile("rw") diff --git a/glue/glue/LDBDServer.py b/glue/glue/LDBDServer.py index 7bae3d370a76723312985841badbcf1a74f5ae33..1d98362060f1d0bc49c55e2f5c4a786350b16204 100644 --- a/glue/glue/LDBDServer.py +++ b/glue/glue/LDBDServer.py @@ -317,6 +317,7 @@ class ServerHandler(SocketServer.BaseRequestHandler): try: del ligomd + del lwtparser except Exception, e: logger.error( "Error deleting metadata object in method query: %s" % e) @@ -365,6 +366,7 @@ class ServerHandler(SocketServer.BaseRequestHandler): try: del ligomd + del lwtparser except Exception, e: logger.error( "Error deleting metadata object in method insert: %s" % e) @@ -380,68 +382,9 @@ class ServerHandler(SocketServer.BaseRequestHandler): @return: None """ - global logger - global xmlparser, dbobj, rls - - logger.debug("Method insertmap called") - - if not rls: - msg = "server is not initialized for RLS connections" - logger.error(msg) - return (1, msg) - - # assume failure - code = 1 - - try: - # unpickle the PFN/LFN mappings from the client - lfnpfn_dict = cPickle.loads(arg[1]) - if not isinstance(lfnpfn_dict, dict): - raise ServerHandlerException, \ - "LFN/PFN mapping from client is not dictionary" - - # capture the remote users DN for insertion into the database - cred = self.request.get_delegated_credential() - remote_dn = cred.inquire_cred()[1].display() - - # create a ligo metadata object - lwtparser = ldbd.LIGOLwParser() - ligomd = ldbd.LIGOMetadata(xmlparser,lwtparser,dbobj) - - # parse the input string into a metadata object - ligomd.parse(arg[0]) - - # add a gridcert table to this request containing the users dn - ligomd.set_dn(remote_dn) - - # add the lfns to the metadata insert to populate the lfn table - for lfn in lfnpfn_dict.keys(): - ligomd.add_lfn(lfn) - - # insert the metadata into the database - result = str(ligomd.insert()) - logger.info("Method insert: %s rows affected by insert" % result) - - # insert the PFN/LFN mappings into the RLS - for lfn in lfnpfn_dict.keys(): - pfns = lfnpfn_dict[lfn] - if not isinstance( pfns, types.ListType ): - raise ServerHandlerException, \ - "PFN must be a single string or a list of PFNs" - rls.lrc_create_lfn( lfn, pfns[0] ) - for pfn in pfns[1:len(pfns)]: - rls.lrc_add( lfn, pfn ) - - logger.info("Method insertmap: insert LFN mappings for %s" % - str(lfnpfn_dict.keys())) - code = 0 - - except Exception, e: - result = ("Error inserting LFN/PFN mapping into RLS: %s" % e) - logger.error(result) - return (code,result) - - return (code,result) + msg = "server is not initialized for RLS connections" + logger.error(msg) + return (1, msg) def insertdmt(self, arg): """ @@ -673,12 +616,13 @@ class ServerHandler(SocketServer.BaseRequestHandler): try: del ligomd + del lwtparser del known_proc del seg_def_key del proc_key except Exception, e: logger.error( - "Error deleting metadata object in method insert: %s" % e) + "Error deleting metadata object in method insertdmt: %s" % e) return (code,result) diff --git a/glue/glue/gracedb/__init__.py b/glue/glue/gracedb/__init__.py index ac563c95e0c0769ded1743e0a1aed6369742966d..0c8a8cbafe93b659b77c130311099d8dad05943e 100644 --- a/glue/glue/gracedb/__init__.py +++ b/glue/glue/gracedb/__init__.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2009 LIGO Scientific Collaboration # # 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 @@ -25,11 +23,13 @@ # """ -DOM-like library for handling LIGO Light Weight XML files. +FIXME: ask somebody to document this. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +from glue import git_version + +__author__ = "LIGO Scientific Collaboration" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date __all__ = ["utils"] diff --git a/glue/glue/gracedb/utils.py b/glue/glue/gracedb/utils.py index ed3f54c9187397a9f96d758847b38d53078cae14..2cd6393e6630b8678876e14447014a528ca4137d 100644 --- a/glue/glue/gracedb/utils.py +++ b/glue/glue/gracedb/utils.py @@ -1,6 +1,10 @@ #!/usr/bin/python +from math import log +from time import gmtime, strftime + from pylal import Fr +from glue.lal import LIGOTimeGPS from glue.ligolw import ligolw from glue.ligolw import table from glue.ligolw import lsctables @@ -12,12 +16,15 @@ from glue.ligolw import lsctables ############################################################################## #Need these for each search: inspiral, burst, etc. -InspiralCoincDef = lsctables.CoincDef(search = u"MBTA_inspiral", \ +InspiralCoincDef = lsctables.CoincDef(search = u"inspiral", \ + search_coinc_type = 0, \ + description = \ + u"sngl_inspiral<-->sngl_inspiral coincidences") +#these should work for both Omega and CWB +BurstCoincDef = lsctables.CoincDef(search = u"burst", \ search_coinc_type = 0, \ description = \ - u"sngl_inspiral<-->sngl_inspiral \ - coincidences") -InspiralCoincId = 'coinc_inspiral:coinc_event_id:0' + u"coherent burst coincidences") #list of detectors participating in the coinc #MBTA only sends triples to gracedb at the time being so this list is @@ -36,13 +43,23 @@ V1_detlist = ['V1'] MBTA_set_keys = ['ifo', 'search', 'end_time', 'end_time_ns', 'mass1', 'mass2',\ 'mchirp', 'mtotal', 'eta', 'snr', 'eff_distance', 'event_id',\ 'process_id', 'channel'] +#Omega +Omega_set_keys = ['process_id', 'ifos', 'start_time', 'start_time_ns',\ + 'duration', 'confidence', 'coinc_event_id'] #this dictionary is the simplest way to assign event_id's #collisions are are taken care of in the process of conversion to sqlite insp_event_id_dict = {'H1': 'sngl_inspiral:event_id:0',\ 'L1': 'sngl_inspiral:event_id:1',\ 'V1': 'sngl_inspiral:event_id:2'} +#this one is designed for coherent searches, which don't have event_ids +coherent_event_id_dict = None +#the names of the variables we're going to get from omega +omega_vars = ['time', 'frequency', 'duration', 'bandwidth', 'modeTheta',\ + 'modePhi', 'probSignal', 'probGlitch', 'logSignal','logGlitch',\ + 'network', 'URL_web', 'URL_file'] + ############################################################################## # # convenience functions @@ -57,7 +74,7 @@ def compute_mchirp_eta(m1,m2): mtot = m1 + m2 mu = m1*m2/mtot eta = mu/mtot - mchirp = pow(mu,3/5)*mtot + mchirp = pow(mu,3.0/5.0)*mtot return float(mchirp), float(eta) @@ -82,9 +99,7 @@ def write_output_files(root_dir, xmldoc, log_content, \ ############################################################################## def populate_inspiral_tables(MBTA_frame, set_keys = MBTA_set_keys, \ - process_id = 'process:process_id:0', \ - event_id_dict = insp_event_id_dict, \ - coinc_event_id='coinc_inspiral:coinc_event_id:0'): + event_id_dict = insp_event_id_dict): """ create xml file and populate the SnglInspiral and CoincInspiral tables from a coinc .gwf file from MBTA @@ -102,8 +117,7 @@ def populate_inspiral_tables(MBTA_frame, set_keys = MBTA_set_keys, \ xmldoc = ligolw.Document() xmldoc.appendChild(ligolw.LIGO_LW()) #dictionaries to store about individual triggers - end_time_s = {} - end_time_ns = {} + end_time = {} snr = {} mass1 = {} mass2 = {} @@ -136,7 +150,7 @@ def populate_inspiral_tables(MBTA_frame, set_keys = MBTA_set_keys, \ far = [line.split(':')[1].split()[0] for line in log_data.splitlines() if \ 'False Alarm Rate' in line][0] for ifo in detectors: - end_time_s[ifo], end_time_ns[ifo] = str(event[ifo+':end_time']).split('.') + end_time[ifo] = LIGOTimeGPS(event[ifo+':end_time']) snr[ifo] = float(event[ifo+':SNR']) mass1[ifo] = float(event[ifo+':mass1']) mass2[ifo] = float(event[ifo+':mass2']) @@ -146,12 +160,13 @@ def populate_inspiral_tables(MBTA_frame, set_keys = MBTA_set_keys, \ #fill the SnglInspiralTable sin_table = lsctables.New(lsctables.SnglInspiralTable) xmldoc.childNodes[0].appendChild(sin_table) + process_id = lsctables.ProcessTable.get_next_id() for ifo in detectors: row = sin_table.RowType() row.ifo = ifo row.search = 'MBTA' - row.end_time = int(end_time_s[ifo]) - row.end_time_ns = int(end_time_ns[ifo]) + row.end_time = end_time[ifo].seconds + row.end_time_ns = end_time[ifo].nanoseconds row.mass1 = mass1[ifo] row.mass2 = mass2[ifo] row.mchirp = mchirp[ifo] @@ -174,17 +189,21 @@ def populate_inspiral_tables(MBTA_frame, set_keys = MBTA_set_keys, \ #https://www.lsc-group.phys.uwm.edu/ligovirgo/cbcnote/S6Plan/ #090505160219S6PlanningNotebookCoinc_and_Experiment_Tables_ihope_implementation? #highlight=%28coinc%29|%28table%29 + + temp_data_loc = None if len(detectors) < 2: - return xmldoc, log_data, detectors - + return xmldoc, log_data, temp_data_loc + + #coinc_event_id = coinc_event_id_base + str(UID) cin_table = lsctables.New(lsctables.CoincInspiralTable) xmldoc.childNodes[0].appendChild(cin_table) row = cin_table.RowType() row.set_ifos(detectors) - row.coinc_event_id = coinc_event_id - row.end_time = int(end_time_s['H1']) - row.end_time_ns = int(end_time_ns['H1']) + cid = lsctables.CoincTable.get_next_id() + row.coinc_event_id = cid + row.end_time = end_time['H1'].seconds + row.end_time_ns = end_time['H1'].nanoseconds row.mass = (sum(mass1.values()) + sum(mass2.values()))/3 row.mchirp = sum(mchirp.values())/3 #the snr here is really the snr NOT effective snr @@ -194,13 +213,74 @@ def populate_inspiral_tables(MBTA_frame, set_keys = MBTA_set_keys, \ row.combined_far = 0 cin_table.append(row) - return xmldoc, log_data, detectors + + xmldoc = populate_coinc_tables(xmldoc,cid,insp_event_id_dict,\ + InspiralCoincDef,detectors) + + return xmldoc, log_data, temp_data_loc + +def populate_burst_tables(datafile, set_keys = Omega_set_keys): + """ + """ + #initialize xml document + xmldoc = ligolw.Document() + xmldoc.appendChild(ligolw.LIGO_LW()) + + #extract the data from the intial Omega file + f = open(datafile, 'r') + omega_list = [] + for line in f.readlines(): + if not line.strip(): continue # ignore blank lines + elif '#' in line.strip()[0]: continue # ignore comments + elif '=' not in line: raise ValueError, "Improperly formatted line" + else: + omega_list.extend([dat.strip() for dat in line.split('=',1)]) + f.close() + omega_data = dict(zip(omega_list[::2],omega_list[1::2])) + # basic error checking +# for key in omega_data: +# if not (key in omega_vars): +# raise ValueError, "Unknown variable" + + #create the content for the event.log file + log_data = '\nLog File created '\ + +strftime("%a, %d %b %Y %H:%M:%S", gmtime())\ + +'\n' + + for var in omega_vars: + log_data += var + ': ' + omega_data[var] + '\n' + + #pull out the ifos + detectors = [ifo for ifo in omega_data['network'].split(',')] + + #fill the MutliBurstTable + mb_table = lsctables.New(lsctables.MultiBurstTable) + xmldoc.childNodes[0].appendChild(mb_table) + row = mb_table.RowType() + row.process_id = lsctables.ProcessTable.get_next_id() + row.set_ifos(detectors) + st = LIGOTimeGPS(omega_data['time']) + row.start_time = st.seconds + row.start_time_ns = st.nanoseconds + row.duration = None + row.confidence = -log(float(omega_data['probGlitch'])) + cid = lsctables.CoincTable.get_next_id() + row.coinc_event_id = cid + for key in mb_table.validcolumns.keys(): + if key not in set_keys: + setattr(row,key,None) + mb_table.append(row) + + xmldoc = populate_coinc_tables(xmldoc,cid, coherent_event_id_dict,\ + BurstCoincDef, detectors) + + return xmldoc, log_data, omega_data['URL_file'] + + -def populate_coinc_tables(xmldoc, coinc_event_id, event_id_dict, CoincDef, \ - detectors, process_id = 'process:process_id:0', \ - coinc_def_id ='coinc_definer:coinc_def_id:0', \ - time_slide_id = None, likelihood = None, \ - nevents = 3): +def populate_coinc_tables(xmldoc, coinc_event_id, event_id_dict,\ + CoincDef, detectors, \ + time_slide_id = None, likelihood = None): """ populate a set of coinc tables xmldoc: xml file to append the tables to @@ -209,18 +289,24 @@ def populate_coinc_tables(xmldoc, coinc_event_id, event_id_dict, CoincDef, \ """ #make sure there's actually a coinc there to write if len(detectors) < 2: - pass + return xmldoc else: #CoincTable coinc_table = lsctables.New(lsctables.CoincTable) xmldoc.childNodes[0].appendChild(coinc_table) row = coinc_table.RowType() - row.process_id = process_id - row.coinc_event_id = coinc_event_id #'coinc_inspiral:coinc_event_id:0' + row.process_id = lsctables.ProcessTable.get_next_id() + row.coinc_event_id = coinc_event_id + coinc_def_id = lsctables.CoincDefTable.get_next_id() row.coinc_def_id = coinc_def_id row.time_slide_id = time_slide_id row.set_instruments(detectors) - row.nevents = nevents + if 'inspiral' in CoincDef.search: + row.nevents = len(detectors) + elif 'burst' in CoincDef.search: + row.nevents = 1 + else: + raise ValueError, "Unrecognize CoincDef.search" row.likelihood = likelihood coinc_table.append(row) @@ -230,8 +316,17 @@ def populate_coinc_tables(xmldoc, coinc_event_id, event_id_dict, CoincDef, \ for ifo in detectors: row = coinc_map_table.RowType() row.coinc_event_id = coinc_event_id - row.table_name = lsctables.SnglInspiralTable.tableName.split(':')[0] - row.event_id = event_id_dict[ifo] + if 'inspiral' in CoincDef.search: + row.table_name = lsctables.SnglInspiralTable.tableName.split(':')[0] + elif 'burst' in CoincDef.search: + row.table_name = lsctables.MultiBurstTable.tableName.split(':')[0] + else: + raise ValueError, "Unrecognize CoincDef.search" + if event_id_dict: + row.event_id = event_id_dict[ifo] + coinc_map_table.append(row) + if not event_id_dict: + row.event_id = coinc_event_id coinc_map_table.append(row) #CoincDefTable @@ -241,8 +336,10 @@ def populate_coinc_tables(xmldoc, coinc_event_id, event_id_dict, CoincDef, \ row.coinc_def_id = coinc_def_id row.search = CoincDef.search row.search_coinc_type = CoincDef.search_coinc_type - row.description = InspiralCoincDef.description + row.description = CoincDef.description coinc_def_table.append(row) + + return xmldoc ############################################################################## @@ -251,10 +348,12 @@ def populate_coinc_tables(xmldoc, coinc_event_id, event_id_dict, CoincDef, \ # ############################################################################## +#here's how it works for inspirals #populate the tables -#xmldoc, log_data, detectors = populate_inspiral_tables("MbtaFake-930909680-16.gwf") -#populate_coinc_tables(xmldoc,InspiralCoincId,insp_event_id_dict,\ -# InspiralCoincDef,detectors) +#xmldoc, log_data, temp_data_loc = populate_inspiral_tables("MbtaFake-930909680-16.gwf") #write the output #write_output_files('.', xmldoc, log_data) +#here's how it works for bursts +#xmldoc, log_data, temp_data_loc = populate_burst_tables("initial.data") +#write_output_files('.', final_xmldoc, log_data) diff --git a/glue/glue/iterutils.py b/glue/glue/iterutils.py index 72c5ae502ac548fc222343f692956e6cf2cbf703..788b01b3177ed7c704683e68ceab5759941a23b3 100644 --- a/glue/glue/iterutils.py +++ b/glue/glue/iterutils.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2007 Kipp C. Cannon, Nickolas Fotopoulos +# Copyright (C) 2007 Kipp Cannon, Nickolas Fotopoulos # # 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 @@ -31,9 +29,12 @@ A collection of iteration utilities. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__version__ = "$Revision$"[11:-2] -__date__ = "$Date$"[7:-2] +from glue import git_version + + +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # diff --git a/glue/glue/lal.py b/glue/glue/lal.py index fb1edf54d7a9aa032ada59fce1c6ac4c4d074f13..70739259274934001acf5be6a6cdfc059fba2c5b 100644 --- a/glue/glue/lal.py +++ b/glue/glue/lal.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -40,12 +38,13 @@ import sys import urlparse +from glue import git_version from glue import segments -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$" -__version__ = "$Revision$" +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # diff --git a/glue/glue/lars/cli/__init__.py b/glue/glue/lars/cli/__init__.py index 6c6fdcf32e47ef76bce0c1b2e888ada8aaac2a04..b074aa4b9042af38c75ceaaf084421e1b02ca0d5 100644 --- a/glue/glue/lars/cli/__init__.py +++ b/glue/glue/lars/cli/__init__.py @@ -296,7 +296,7 @@ class Reserve(Command): try: info = objectify(server.info("", location)) found = True - except Exception, reason: + except xmlrpclib.Fault, reason: if not reason.faultString.endswith('not found'): raise if found: diff --git a/glue/glue/ldbd.py b/glue/glue/ldbd.py index ec87240f31fb93c1a65f6b72e26a66e0bec621b4..4b0656e0340de575e4ff5ebb258541054bf6be04 100644 --- a/glue/glue/ldbd.py +++ b/glue/glue/ldbd.py @@ -452,6 +452,9 @@ class LIGOMetadata: except DB2.Warning, e: self.curs.execute('rollback') raise LIGOLwDBError, e[2] + #except Exception, e: + # self.curs.execute('rollback') + # raise LIGOLwDBError, e[2] except KeyError: pass self.curs.execute('commit') diff --git a/glue/glue/ligolw/__init__.py b/glue/glue/ligolw/__init__.py index 8589392b26607fc5df278831786aad7196ab2406..daeedf117f16f72bf5e2365412e8515bd8db0c76 100644 --- a/glue/glue/ligolw/__init__.py +++ b/glue/glue/ligolw/__init__.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -28,8 +26,22 @@ DOM-like library for handling LIGO Light Weight XML files. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] -__all__ = ["ligolw", "types", "ilwd", "table", "array", "param", "lsctables", "utils"] +from glue import git_version + + +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date + + +__all__ = [ + "ligolw", + "types", + "ilwd", + "table", + "array", + "param", + "lsctables", + "utils" +] diff --git a/glue/glue/ligolw/array.py b/glue/glue/ligolw/array.py index f5fd57b959afe0b362f9f4d7c3f0d2638b05da44..a1a95beedb510a5e27540daf433873a27900c360 100644 --- a/glue/glue/ligolw/array.py +++ b/glue/glue/ligolw/array.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -47,17 +45,19 @@ import numpy import re import sys from xml.sax.saxutils import escape as xmlescape +from xml.sax.xmlreader import AttributesImpl as Attributes +from glue import git_version from glue import iterutils -import ligolw -import tokenizer -import types as ligolwtypes +from glue.ligolw import ligolw +from glue.ligolw import tokenizer +from glue.ligolw import types as ligolwtypes -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -118,17 +118,17 @@ def from_array(name, array, dim_names = None): Construct a LIGO Light Weight XML Array document subtree from a numpy array object. """ - doc = Array({u"Name": u"%s:array" % name, u"Type": ligolwtypes.FromNumPyType[str(array.dtype)]}) + doc = Array(Attributes({u"Name": u"%s:array" % name, u"Type": ligolwtypes.FromNumPyType[str(array.dtype)]})) s = list(array.shape) s.reverse() for n, dim in enumerate(s): attrs = {} if dim_names is not None: attrs[u"Name"] = dim_names[n] - child = ligolw.Dim(attrs) + child = ligolw.Dim(Attributes(attrs)) child.pcdata = unicode(dim) doc.appendChild(child) - child = ArrayStream({u"Type": u"Local", u"Delimiter": u" "}) + child = ArrayStream(Attributes({u"Type": u"Local", u"Delimiter": u" "})) doc.appendChild(child) doc.array = array return doc diff --git a/glue/glue/ligolw/dbtables.py b/glue/glue/ligolw/dbtables.py index ef283b5be1bc82abc5825fd02e76d9d3c9af2cb9..b379b11c4095bb13b8c9f9c4058b7fddebaee34c 100644 --- a/glue/glue/ligolw/dbtables.py +++ b/glue/glue/ligolw/dbtables.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2007 Kipp C. Cannon +# Copyright (C) 2007 Kipp Cannon # # 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 @@ -46,18 +44,20 @@ try: set except NameError: from sets import Set as set +from warnings import warn -import ligolw -import table -import lsctables -import types as ligolwtypes +from glue import git_version from glue import segments +from glue.ligolw import ligolw +from glue.ligolw import table +from glue.ligolw import lsctables +from glue.ligolw import types as ligolwtypes -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -69,6 +69,22 @@ __version__ = "$Revision$"[11:-2] # +def connection_db_type(connection): + """ + A totally broken attempt to determine what type of database a + connection object is attached to. Don't use this. + + The input is a DB API 2.0 compliant connection object, the return + value is one of the strings "sqlite3" or "mysql". Raises TypeError + when the database type cannot be determined. + """ + if "sqlite" in repr(connection): + return "sqlite" + if "mysql" in repr(connection): + return "mysql" + raise TypeError, connection + + def DBTable_set_connection(connection): """ Set the Python DB-API 2.0 compatible connection the DBTable class @@ -272,7 +288,8 @@ def idmap_get_new(connection, old, tbl): to re-map row IDs when merging multiple documents. """ cursor = connection.cursor() - new = cursor.execute("SELECT new FROM _idmap_ WHERE old == ?", (old,)).fetchone() + cursor.execute("SELECT new FROM _idmap_ WHERE old == ?", (old,)) + new = cursor.fetchone() if new is not None: # a new ID has already been created for this old ID return new[0] @@ -283,6 +300,28 @@ def idmap_get_new(connection, old, tbl): return new +def idmap_get_max_id(connection, id_class): + """ + Given an ilwd:char ID class, return the highest ID from the table + for whose IDs that is the class. + + Example: + + >>> id = ilwd.get_ilwdchar("sngl_burst:event_id:0") + >>> print id + sngl_inspiral:event_id:0 + >>> max = get_max_id(connection, type(id)) + >>> print max + sngl_inspiral:event_id:1054 + """ + cursor = connection.cursor() + cursor.execute("SELECT MAX(CAST(SUBSTR(%s, %d, 10) AS INTEGER)) FROM %s" % (id_class.column_name, id_class.index_offset + 1, id_class.table_name)) + max = cursor.fetchone()[0] + if max is None: + return None + return id_class(max) + + # # ============================================================================= # @@ -310,7 +349,9 @@ def get_table_names(connection): """ Return a list of the table names in the database. """ - return [name for (name,) in connection.cursor().execute("SELECT name FROM sqlite_master WHERE type == 'table'")] + cursor = connection.cursor() + cursor.execute("SELECT name FROM sqlite_master WHERE type == 'table'") + return [name for (name,) in cursor] def get_column_info(connection, table_name): @@ -318,7 +359,9 @@ def get_column_info(connection, table_name): Return an in order list of (name, type) tuples describing the columns in the given table. """ - statement, = connection.cursor().execute("SELECT sql FROM sqlite_master WHERE type == 'table' AND name == ?", (table_name,)).fetchone() + cursor = connection.cursor() + cursor.execute("SELECT sql FROM sqlite_master WHERE type == 'table' AND name == ?", (table_name,)) + statement, = cursor.fetchone() coldefs = re.match(_sql_create_table_pattern, statement).groupdict()["coldefs"] return [(coldef.groupdict()["name"], coldef.groupdict()["type"]) for coldef in re.finditer(_sql_coldef_pattern, coldefs) if coldef.groupdict()["name"].upper() not in ("PRIMARY", "UNIQUE", "CHECK")] @@ -395,36 +438,37 @@ class DBTable(table.Table): without developer intervention the column types will be guessed using a generic mapping of SQL types to LIGO Light Weight types. - Each instance of this class must be connected to a database, but - because the __init__() method must have the same signature as the - __init__() methods of other Element subclasses (so that this class - can be used as a drop-in replacement during document parsing), it - is not possible to pass a connection object into the __init__() - method as a separate argument. Instead, the connection object is - passed into the __init__() method via a class attribute. The - procedure is: set the class attribute, create instances of the - class connected to that database, set the class attribute to a new - value, create instances of the class connected to a different - database, and so on. A utility function is available for setting - the class attribute, and should be used. + Each instance of this class must be connected to a database. The + (Python DBAPI 2.0 compatible) connection object is passed to the + class via the connection parameter at instance creation time. Example: - import dbtables - - # set class attribute - dbtables.DBTable_set_connection(connection) - - # create a process table instance connected to that database - table_elem = dbtables.DBTable(AttributesImpl({u"Name": u"process:table"})) + >>> tbl = dbtables.DBTable(AttributesImpl({u"Name": u"process:table"}), connection = connection) + + There is not yet a LIGO Light Weight content handler that is able + to do this correctly, so for the time-being a mechanism is used + where in the connection is stored as an attribute of the DBTable + class. This makes it difficult to work with more than one database + at a time, and is the subject of on-going development effort. See + the DBTable_set_connection() function for information on how to set + the class attribute. + + If a custom glue.ligolw.Table subclass is defined in + glue.ligolw.lsctables whose name matches the name of the DBTable + being constructed, the lsctables class is added to the list of + parent classes. This allows the lsctables class' methods to be + used with the DBTable instances but not all of the methods will + necessarily work with the database-backed version of the class. + Your mileage may vary. """ # # When instances of this class are created, they initialize their - # connection attributes from the value of this class attribute at - # the time of their creation. The value must be passed into the - # __init__() method this way because it cannot be passed in as a - # separate argument; this class' __init__() method must have the - # same signature as normal Element subclasses. + # connection attributes from the value of this class attribute. + # + # NOTE: this is deprecated; this class attribute will be removed, + # and the connection parameter of the __init__() method will be the + # only way to pass this information to the class in the future. # connection = None @@ -435,20 +479,17 @@ class DBTable(table.Table): # no, try to retrieve it from lsctables attrs, = args name = table.StripTableName(attrs[u"Name"]) - try: + if name in lsctables.TableByName: + # found metadata in lsctables, construct + # custom subclass. the class from + # lsctables is added as a parent class to + # allow methods from that class to be used + # with this class, however there is no + # guarantee that all parent class methods + # will be appropriate for use with the + # DB-backed object. lsccls = lsctables.TableByName[name] - except KeyError: - # unknown table, give up - pass - else: - # found metadata, construct custom - # subclass. NOTE: this works because when - # using SQL-backed tables there can only be - # ONE of any table in a document, which - # solves the problem of trying to share the - # next_id attribute across multiple - # instances of a table. - class CustomDBTable(cls): + class CustomDBTable(cls, lsccls): tableName = lsccls.tableName validcolumns = lsccls.validcolumns loadcolumns = lsccls.loadcolumns @@ -478,6 +519,7 @@ class DBTable(table.Table): if "connection" in kwargs: self.connection = kwargs.pop("connection") else: + warn("use of \"connection\" class attribute to provide database connection information at DBTable instance creation time is deprecated. Use \"connection\" parameter of .__init__() method instead", DeprecationWarning) self.connection = self.connection # pre-allocate a cursor for internal queries @@ -495,7 +537,11 @@ class DBTable(table.Table): self.dbcolumntypes = self.columntypes # create the table - statement = "CREATE TABLE IF NOT EXISTS " + self.dbtablename + " (" + ", ".join(map(lambda n, t: "%s %s" % (n, ligolwtypes.ToSQLiteType[t]), self.dbcolumnnames, self.dbcolumntypes)) + ToSQLType = { + "sqlite": ligolwtypes.ToSQLiteType, + "mysql": ligolwtypes.ToMySQLType + }[connection_db_type(self.connection)] + statement = "CREATE TABLE IF NOT EXISTS " + self.dbtablename + " (" + ", ".join(map(lambda n, t: "%s %s" % (n, ToSQLType[t]), self.dbcolumnnames, self.dbcolumntypes)) if self.constraints is not None: statement += ", " + self.constraints statement += ")" @@ -505,7 +551,11 @@ class DBTable(table.Table): self.last_maxrowid = self.maxrowid() or 0 # construct the SQL to be used to insert new rows - self.append_statement = "INSERT INTO %s (%s) VALUES (%s)" % (self.dbtablename, ",".join(self.dbcolumnnames), ",".join("?" * len(self.dbcolumnnames))) + params = { + "sqlite": ",".join("?" * len(self.dbcolumnnames)), + "mysql": ",".join(["%s"] * len(self.dbcolumnnames)) + }[connection_db_type(self.connection)] + self.append_statement = "INSERT INTO %s (%s) VALUES (%s)" % (self.dbtablename, ",".join(self.dbcolumnnames), params) def _end_of_rows(self): # FIXME: is this needed? @@ -514,48 +564,54 @@ class DBTable(table.Table): def sync_next_id(self): if self.next_id is not None: - last, = self.cursor.execute("SELECT MAX(CAST(SUBSTR(%s, %d, 10) AS INTEGER)) FROM %s" % (self.next_id.column_name, self.next_id.index_offset + 1, self.dbtablename)).fetchone() - if last is None: + max_id = idmap_get_max_id(self.connection, type(self.next_id)) + if max_id is None: self.set_next_id(type(self.next_id)(0)) else: - self.set_next_id(type(self.next_id)(last + 1)) + self.set_next_id(max_id + 1) return self.next_id def maxrowid(self): - return self.cursor.execute("SELECT MAX(ROWID) FROM %s" % self.dbtablename).fetchone()[0] + self.cursor.execute("SELECT MAX(ROWID) FROM %s" % self.dbtablename) + return self.cursor.fetchone()[0] def __len__(self): - return self.cursor.execute("SELECT COUNT(*) FROM %s" % self.dbtablename).fetchone()[0] + self.cursor.execute("SELECT COUNT(*) FROM %s" % self.dbtablename) + return self.cursor.fetchone()[0] def __iter__(self): - for values in self.connection.cursor().execute("SELECT * FROM %s" % self.dbtablename): - yield self._row_from_cols(values) + cursor = self.connection.cursor() + cursor.execute("SELECT * FROM %s" % self.dbtablename) + for values in cursor: + yield self.row_from_cols(values) def _append(self, row): + """ + Standard .append() method. This method is for intended for + internal use only. + """ # FIXME: in Python 2.5 use attrgetter() for attribute # tuplization. self.cursor.execute(self.append_statement, map(lambda n: getattr(row, n), self.dbcolumnnames)) def _remapping_append(self, row): """ - Replacement for the standard append() method. This version - performs on the fly row ID reassignment, and so also - performs the function of the updateKeyMapping() method. - SQLite does not permit the PRIMARY KEY of a row to be - modified, so it needs to be done prior to insertion. This - method is intended for internal use only. + Replacement for the standard .append() method. This + version performs on the fly row ID reassignment, and so + also performs the function of the updateKeyMapping() + method. SQLite does not permit the PRIMARY KEY of a row to + be modified, so it needs to be done prior to insertion. + This method is intended for internal use only. """ if self.next_id is not None: # assign (and record) a new ID before inserting the # row to avoid collisions with existing rows setattr(row, self.next_id.column_name, idmap_get_new(self.connection, getattr(row, self.next_id.column_name), self)) - # FIXME: in Python 2.5 use attrgetter() for attribute - # tuplization. - self.cursor.execute(self.append_statement, map(lambda n: getattr(row, n), self.dbcolumnnames)) + self._append(row) append = _append - def _row_from_cols(self, values): + def row_from_cols(self, values): """ Given an iterable of values in the order of columns in the database, construct and return a row object. This is a @@ -566,6 +622,8 @@ class DBTable(table.Table): for c, v in zip(self.dbcolumnnames, values): setattr(row, c, v) return row + # backwards compatibility + _row_from_cols = row_from_cols def unlink(self): table.Table.unlink(self) @@ -601,6 +659,7 @@ class DBTable(table.Table): class ProcessTable(DBTable): + # FIXME: remove this class tableName = lsctables.ProcessTable.tableName validcolumns = lsctables.ProcessTable.validcolumns constraints = lsctables.ProcessTable.constraints @@ -630,41 +689,6 @@ class ProcessParamsTable(DBTable): DBTable.append(self, row) -class SearchSummaryTable(DBTable): - tableName = lsctables.SearchSummaryTable.tableName - validcolumns = lsctables.SearchSummaryTable.validcolumns - constraints = lsctables.SearchSummaryTable.constraints - next_id = lsctables.SearchSummaryTable.next_id - RowType = lsctables.SearchSummaryTable.RowType - how_to_index = lsctables.SearchSummaryTable.how_to_index - - def get_out_segmentlistdict(self, process_ids = None): - """ - Return a segmentlistdict mapping instrument to out segment - list. If process_ids is a list of process IDs, then only - rows with matching IDs are included otherwise all rows are - included. - - Note: the result is not coalesced, each segmentlist - contains the segments listed for that instrument as they - appeared in the table. - """ - # start a segment list dictionary - seglists = segments.segmentlistdict() - - # add segments from appropriate rows to segment list - # dictionary - for row in self: - ifos = row.get_ifos() - if ifos is None: - ifos = (None,) - if process_ids is None or row.process_id in process_ids: - seglists.extend(dict((ifo, segments.segmentlist([row.get_out()])) for ifo in ifos)) - - # done - return seglists - - class TimeSlideTable(DBTable): tableName = lsctables.TimeSlideTable.tableName validcolumns = lsctables.TimeSlideTable.validcolumns @@ -734,45 +758,6 @@ class TimeSlideTable(DBTable): raise NotImplementedError -class CoincDefTable(DBTable): - tableName = lsctables.CoincDefTable.tableName - validcolumns = lsctables.CoincDefTable.validcolumns - constraints = lsctables.CoincDefTable.constraints - next_id = lsctables.CoincDefTable.next_id - RowType = lsctables.CoincDefTable.RowType - how_to_index = lsctables.CoincDefTable.how_to_index - - def get_coinc_def_id(self, search, coinc_type, create_new = True, description = u""): - """ - Return the coinc_def_id for the row in the table whose - search string and search_coinc_type integer have the values - given. If a matching row is not found, the default - behaviour is to create a new row and return the ID assigned - to the new row. If, instead, create_new is False then - KeyError is raised when a matching row is not found. The - optional description parameter can be used to set the - description string assigned to the new row if one is - created, otherwise the new row is left with an empty - description. - """ - # look for the ID - for row in self: - if (row.search, row.search_coinc_type) == (search, coinc_type): - # found it - return row.coinc_def_id - - # coinc type not found in table - if not create_new: - raise KeyError, (search, coinc_type) - self.sync_next_id() - row = self.RowType() - row.coinc_def_id = self.get_next_id() - row.search = search - row.search_coinc_type = coinc_type - row.description = description - self.append(row) - - # # ============================================================================= # @@ -822,9 +807,7 @@ def build_indexes(connection, verbose = False): TableByName = { table.StripTableName(ProcessTable.tableName): ProcessTable, table.StripTableName(ProcessParamsTable.tableName): ProcessParamsTable, - table.StripTableName(SearchSummaryTable.tableName): SearchSummaryTable, - table.StripTableName(TimeSlideTable.tableName): TimeSlideTable, - table.StripTableName(CoincDefTable.tableName): CoincDefTable + table.StripTableName(TimeSlideTable.tableName): TimeSlideTable } @@ -862,8 +845,8 @@ def startTable(self, attrs): if name in map(table.StripTableName, NonDBTableNames): return __parent_startTable(self, attrs) if name in TableByName: - return TableByName[name](attrs) - return DBTable(attrs) + return TableByName[name](attrs, connection = DBTable.connection) + return DBTable(attrs, connection = DBTable.connection) ligolw.LIGOLWContentHandler.startTable = startTable diff --git a/glue/glue/ligolw/ilwd.c b/glue/glue/ligolw/ilwd.c index 1ce09acd859cf4aa93a3a4335ed73a3c555a5799..7207b8bbcecd11fa146c10a575c5b20e4a943e62 100644 --- a/glue/glue/ligolw/ilwd.c +++ b/glue/glue/ligolw/ilwd.c @@ -193,8 +193,12 @@ static PyObject *ligolw_ilwdchar___new__(PyTypeObject *type, PyObject *args, PyO Py_INCREF(new); } else { /* we weren't passed a string or an int or an ilwdchar - * instance: type error */ + * instance: if args contains exactly 1 object then this + * is a type error, otherwise it's a wrong number of + * arguments error */ Py_DECREF(new); + if(PyArg_ParseTuple(args, "O", &new)) + PyErr_SetObject(PyExc_TypeError, new); new = NULL; } diff --git a/glue/glue/ligolw/ilwd.py b/glue/glue/ligolw/ilwd.py index f1dcdba09e470428016b4276426be10fbdc5e5f8..6ab152cc3541db0343976ec9486e22d73c91c78d 100644 --- a/glue/glue/ligolw/ilwd.py +++ b/glue/glue/ligolw/ilwd.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -85,9 +83,12 @@ Example: import re -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +from glue import git_version + + +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -134,6 +135,9 @@ class inspiral_ilwdchar(long): def __str__(self): return "%s:%s:%d" % (self.table_name, self.column_name, long(self)) + def __conform__(self, protocol): + return unicode(self) + def __sub__(self, other): return long.__sub__(self, other) diff --git a/glue/glue/ligolw/ligolw.py b/glue/glue/ligolw/ligolw.py index f6e828eaf3095b6fd8673479f4270f23bcafe081..3d1d8a6ca39608c5603d4fdee11f98b1fcdf4ec9 100644 --- a/glue/glue/ligolw/ligolw.py +++ b/glue/glue/ligolw/ligolw.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -34,10 +32,6 @@ class for use with SAX2 parsers, and a convenience function for constructing a parser. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] - import re import sys @@ -46,7 +40,13 @@ from xml.sax.saxutils import escape as xmlescape from xml.sax.saxutils import unescape as xmlunescape -import types as ligolwtypes +from glue import git_version +from glue.ligolw import types as ligolwtypes + + +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -238,7 +238,17 @@ class Element(object): # modifies its internal data. probably not a good idea, # but I don't know how else to edit an attribute because # the stupid things don't export a method to do it. - self.attributes._attrs[attrname] = str(value) + self.attributes._attrs[attrname] = unicode(value) + + def removeAttribute(self, attrname): + # cafeful: this digs inside an AttributesImpl object and + # modifies its internal data. probably not a good idea, + # but I don't know how else to edit an attribute because + # the stupid things don't export a method to do it. + try: + del self.attributes._attrs[attrname] + except KeyError: + pass def appendData(self, content): """ @@ -324,6 +334,42 @@ class Param(Element): validchildren = [u"Comment"] validattributes = [u"Name", u"Type", u"Start", u"Scale", u"Unit", u"DataUnit"] + def get_unit(self): + """ + Retrieve the value of the "Unit" attribute. + """ + return self.getAttribute(u"Unit") + + def set_unit(self, value): + """ + Set the value of the "Unit" attribute. + """ + self.setAttribute(u"Unit", unicode(value)) + + def del_unit(self): + """ + Remove the "Unit" attribute. + """ + self.removeAttribute(u"Unit") + + def get_dataunit(self): + """ + Retrieve the value of the "DataUnit" attribute. + """ + return self.getAttribute(u"DataUnit") + + def set_dataunit(self, value): + """ + Set the value of the "DataUnit" attribute. + """ + self.setAttribute(u"DataUnit", unicode(value)) + + def del_dataunit(self): + """ + Remove the "DataUnit" attribute. + """ + self.removeAttribute(u"DataUnit") + class Table(Element): """ @@ -487,6 +533,14 @@ class Time(Element): raise ElementError, "invalid Type for Time: %s" % attrs[u"Type"] Element.__init__(self, attrs) + def write(self, file = sys.stdout, indent = u""): + if self.pcdata: + file.write(self.start_tag(indent)) + file.write(xmlescape(self.pcdata)) + file.write(self.end_tag(u"") + u"\n") + else: + file.write(self.start_tag(indent) + self.end_tag(u"") + u"\n") + class Document(Element): """ @@ -495,11 +549,13 @@ class Document(Element): tagName = u"Document" validchildren = [u"LIGO_LW"] - def write(self, file = sys.stdout): + def write(self, file = sys.stdout, xsl_file = None ): """ Write the document. """ file.write(Header + u"\n") + if xsl_file is not None: + file.write(u'<?xml-stylesheet type="text/xsl" href="' + xsl_file + u'" ?>' + u"\n") for c in self.childNodes: if c.tagName not in self.validchildren: raise ElementError, "invalid child %s for %s" % (c.tagName, self.tagName) diff --git a/glue/glue/ligolw/lsctables.py b/glue/glue/ligolw/lsctables.py index 7617227d34358f91244582b2f7cfcae7d8bdd680..c6d6ea81f4686e00f2059a0711bfa96c483433e3 100644 --- a/glue/glue/ligolw/lsctables.py +++ b/glue/glue/ligolw/lsctables.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -34,10 +32,6 @@ Maintainership of the table definitions is left as an excercise to interested users. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] - from xml import sax try: @@ -53,12 +47,18 @@ except NameError: from glue.iterutils import any, all +from glue import git_version from glue import segments from glue.lal import LIGOTimeGPS -import ligolw -import table -import types as ligolwtypes -import ilwd +from glue.ligolw import ligolw +from glue.ligolw import table +from glue.ligolw import types as ligolwtypes +from glue.ligolw import ilwd + + +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -149,7 +149,7 @@ def instrument_set_from_ifos(ifos): input contains "," --> output is set of strings split on "," with leading and trailing whitespace stripped from each piece - input contains "+" --> output is set of strings split on "," with + input contains "+" --> output is set of strings split on "+" with leading and trailing whitespace stripped from each piece else, after stripping input of leading and trailing whitespace, @@ -377,6 +377,9 @@ class SearchSummaryTable(table.Table): "nevents": "int_4s", "nnodes": "int_4s" } + how_to_index = { + "ss_pi_index": ("process_id",), + } def get_inlist(self): """ @@ -1022,7 +1025,14 @@ class MultiBurstTable(table.Table): "ligo_angle_sig": "real_4", "coinc_event_id": "ilwd:char" } - constraints = "PRIMARY KEY (coinc_event_id)" + # FIXME: like some other tables here, this table should have the + # constraint that the coinc_event_id column is a primary key. this + # breaks ID reassignment in ligolw_sqlite, so until that is fixed + # the constraint is being replaced with an index. + #constraints = "PRIMARY KEY (coinc_event_id)" + how_to_index = { + "mb_cei_index": ("coinc_event_id",) + } class MultiBurst(object): @@ -1389,10 +1399,10 @@ CoincInspiralTable.RowType = CoincInspiral # -SnglRingDownID = ilwd.get_ilwdchar_class(u"sngl_ringdown", u"event_id") +SnglRingdownID = ilwd.get_ilwdchar_class(u"sngl_ringdown", u"event_id") -class SnglRingDownTable(table.Table): +class SnglRingdownTable(table.Table): tableName = "sngl_ringdown:table" validcolumns = { "process_id": "ilwd:char", @@ -1419,12 +1429,57 @@ class SnglRingDownTable(table.Table): } constraints = "PRIMARY KEY (event_id)" # FIXME: ringdown pipeline needs to not encode data in event_id - #next_id = SnglRingDownID(0) + #next_id = SnglRingdownID(0) interncolumns = ("process_id", "ifo", "search", "channel") -class SnglRingDown(object): - __slots__ = SnglRingDownTable.validcolumns.keys() +class SnglRingdown(object): + __slots__ = SnglRingdownTable.validcolumns.keys() + + def get_start(self): + return LIGOTimeGPS(self.start_time, self.start_time_ns) + + def set_start(self, gps): + self.start_time, self.start_time_ns = gps.seconds, gps.nanoseconds + + +SnglRingdownTable.RowType = SnglRingdown + + +# +# ============================================================================= +# +# coinc_ringdown:table +# +# ============================================================================= +# + + +class CoincRingdownTable(table.Table): + tableName = "coinc_ringdown:table" + validcolumns = { + "coinc_event_id": "ilwd:char", + "ifos": "lstring", + "start_time": "int_4s", + "start_time_ns": "int_4s", + "frequency": "real_8", + "quality": "real_8", + "snr": "real_8", + "false_alarm_rate": "real_8" + } + # FIXME: like some other tables here, this table should have the + # constraint that the coinc_event_id column is a primary key. this + # breaks ID reassignment in ligolw_sqlite, so until that is fixed + # the constraint is being replaced with an index. + #constraints = "PRIMARY KEY (coinc_event_id)" + how_to_index = { + "cr_cei_index": ("coinc_event_id",) + } + interncolumns = ("coinc_event_id", "ifos") + + +class CoincRingdown(object): + __slots__ = CoincRingdownTable.validcolumns.keys() def get_start(self): return LIGOTimeGPS(self.start_time, self.start_time_ns) @@ -1432,8 +1487,14 @@ class SnglRingDown(object): def set_start(self, gps): self.start_time, self.start_time_ns = gps.seconds, gps.nanoseconds + def set_ifos(self, ifos): + self.ifos = ifos_from_instrument_set(ifos) + + def get_ifos(self): + return instrument_set_from_ifos(self.ifos) + -SnglRingDownTable.RowType = SnglRingDown +CoincRingdownTable.RowType = CoincRingdown # @@ -1777,10 +1838,10 @@ SimBurstTable.RowType = SimBurst # -SimRingDownID = ilwd.get_ilwdchar_class(u"sim_ringdown", u"simulation_id") +SimRingdownID = ilwd.get_ilwdchar_class(u"sim_ringdown", u"simulation_id") -class SimRingDownTable(table.Table): +class SimRingdownTable(table.Table): tableName = "sim_ringdown:table" validcolumns = { "process_id": "ilwd:char", @@ -1813,12 +1874,12 @@ class SimRingDownTable(table.Table): "simulation_id": "ilwd:char" } constraints = "PRIMARY KEY (simulation_id)" - next_id = SimRingDownID(0) + next_id = SimRingdownID(0) interncolumns = ("process_id", "waveform", "coordinates") -class SimRingDown(object): - __slots__ = SimRingDownTable.validcolumns.keys() +class SimRingdown(object): + __slots__ = SimRingdownTable.validcolumns.keys() def get_start(self, site = None): if not site: @@ -1828,7 +1889,7 @@ class SimRingDown(object): return LIGOTimeGPS(getattr(self, site + '_start_time'), getattr(self, site + '_start_time_ns')) -SimRingDownTable.RowType = SimRingDown +SimRingdownTable.RowType = SimRingdown # @@ -2379,10 +2440,11 @@ class CoincDefTable(table.Table): description. """ # look for the ID - for row in self: - if (row.search, row.search_coinc_type) == (search, search_coinc_type): - # found it - return row.coinc_def_id + rows = [row for row in self if (row.search, row.search_coinc_type) == (search, search_coinc_type)] + if len(rows) > 1: + raise ValueError, "search/search coinc type = %s/%d is not unique" % (search, search_coinc_type) + if len(rows) > 0: + return rows[0].coinc_def_id # coinc type not found in table if not create_new: @@ -2607,6 +2669,63 @@ class VetoDef(object): VetoDefTable.RowType = VetoDef + +# +# ============================================================================= +# +# summ_mime:table +# +# ============================================================================= +# + + +SummMimeID = ilwd.get_ilwdchar_class(u"summ_mime", u"summ_mime_id") + + +class SummMimeTable(table.Table): + tableName = "summ_mime:table" + validcolumns = { + "origin": "lstring", + "process_id": "ilwd:char", + "filename": "lstring", + "submitter": "lstring", + "frameset_group": "lstring", + "segment_def_id": "ilwd:char", + "start_time": "int_4s", + "start_time_ns": "int_4s", + "end_time": "int_4s", + "end_time_ns": "int_4s", + "channel": "lstring", + "descrip": "lstring", + "mimedata": "blob", + "mimedata_length": "int_4s", + "mimetype": "lstring", + "comment": "lstring", + "summ_mime_id": "ilwd:char" + } + constraints = "PRIMARY KEY (summ_mime_id)" + next_id = SummMimeID(0) + + +class SummMime(object): + __slots__ = SummMimeTable.validcolumns.keys() + + def get_start(self): + return LIGOTimeGPS(self.start_time, self.start_time_ns) + + def set_start(self, gps): + self.start_time, self.start_time_ns = gps.seconds, gps.nanoseconds + + def get_end(self): + return LIGOTimeGPS(self.end_time, self.end_time_ns) + + def set_end(self, gps): + self.end_time, self.end_time_ns = gps.seconds, gps.nanoseconds + + +SummMimeTable.RowType = SummMime + + # # ============================================================================= # @@ -2629,15 +2748,17 @@ TableByName = { table.StripTableName(SearchSummVarsTable.tableName): SearchSummVarsTable, table.StripTableName(ExperimentTable.tableName): ExperimentTable, table.StripTableName(ExperimentSummaryTable.tableName): ExperimentSummaryTable, + table.StripTableName(ExperimentMapTable.tableName): ExperimentMapTable, table.StripTableName(SnglBurstTable.tableName): SnglBurstTable, table.StripTableName(MultiBurstTable.tableName): MultiBurstTable, table.StripTableName(SnglInspiralTable.tableName): SnglInspiralTable, table.StripTableName(CoincInspiralTable.tableName): CoincInspiralTable, - table.StripTableName(SnglRingDownTable.tableName): SnglRingDownTable, + table.StripTableName(SnglRingdownTable.tableName): SnglRingdownTable, + table.StripTableName(CoincRingdownTable.tableName): CoincRingdownTable, table.StripTableName(MultiInspiralTable.tableName): MultiInspiralTable, table.StripTableName(SimInspiralTable.tableName): SimInspiralTable, table.StripTableName(SimBurstTable.tableName): SimBurstTable, - table.StripTableName(SimRingDownTable.tableName): SimRingDownTable, + table.StripTableName(SimRingdownTable.tableName): SimRingdownTable, table.StripTableName(SummValueTable.tableName): SummValueTable, table.StripTableName(SimInstParamsTable.tableName): SimInstParamsTable, table.StripTableName(StochasticTable.tableName): StochasticTable, @@ -2653,7 +2774,8 @@ TableByName = { table.StripTableName(CoincMapTable.tableName): CoincMapTable, table.StripTableName(DQSpecListTable.tableName): DQSpecListTable, table.StripTableName(LIGOLWMonTable.tableName): LIGOLWMonTable, - table.StripTableName(VetoDefTable.tableName): VetoDefTable + table.StripTableName(VetoDefTable.tableName): VetoDefTable, + table.StripTableName(SummMimeTable.tableName): SummMimeTable } diff --git a/glue/glue/ligolw/param.py b/glue/glue/ligolw/param.py index 646cfea2b2ecaebe02b9c862f22e488fb47ccf01..75ff4afa4e39ff7fc24a21c894283ccc65b104de 100644 --- a/glue/glue/ligolw/param.py +++ b/glue/glue/ligolw/param.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -34,15 +32,17 @@ High-level support for Param elements. import re import sys from xml.sax.saxutils import escape as xmlescape +from xml.sax.xmlreader import AttributesImpl as Attributes -import ligolw -import types as ligolwtypes +from glue import git_version +from glue.ligolw import ligolw +from glue.ligolw import types as ligolwtypes -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -98,12 +98,24 @@ def getParamsByName(elem, name): # -def new_param(name, type, value, comment = None): +def new_param(name, type, value, start = None, scale = None, unit = None, dataunit = None, comment = None): """ - Construct a LIGO Light Weight XML Param document subtree. + Construct a LIGO Light Weight XML Param document subtree. FIXME: + document keyword arguments. """ - elem = Param({u"Name": u"%s:param" % name, u"Type": type}) + # FIXME: I have no idea how most of the attributes should be + # encoded, I don't even know what they're supposed to be. + attrs = {u"Name": u"%s:param" % name, u"Type": type} + if start is not None: + attrs[u"Start"] = unicode(start) + if scale is not None: + attrs[u"Scale"] = ligolwtypes.FormatFunc["real_8"](scale) + elem = Param(Attributes(attrs)) elem.pcdata = value + if unit is not None: + elem.set_unit(unit) + if dataunit is not None: + elem.set_dataunit(dataunit) if comment is not None: elem.appendChild(ligolw.Comment()) elem.childNodes[-1].pcdata = comment @@ -121,12 +133,13 @@ def get_param(xmldoc, name): return params[0] -def from_pyvalue(name, value, comment = None): +def from_pyvalue(name, value, **kwargs): """ Convenience wrapper for new_param() that constructs a Param element - from an instance of a Python builtin type. + from an instance of a Python builtin type. See new_param() for a + description of the valid keyword arguments. """ - return new_param(name, ligolwtypes.FromPyType[value.__class__], value, comment = comment) + return new_param(name, ligolwtypes.FromPyType[value.__class__], value, **kwargs) def get_pyvalue(xml, name): @@ -188,7 +201,7 @@ class Param(ligolw.Param): if c.tagName not in self.validchildren: raise ElementError, "invalid child %s for %s" % (c.tagName, self.tagName) c.write(file, indent + ligolw.Indent) - if self.pcdata: + if self.pcdata is not None: # we have to strip quote characters from string # formats (see comment above) file.write(indent + ligolw.Indent) diff --git a/glue/glue/ligolw/table.py b/glue/glue/ligolw/table.py index a1249c0d2931d133cb7c8c60314745921d775bfd..4e821f50f5f2646c3554c98c5099c91267cfb2b5 100644 --- a/glue/glue/ligolw/table.py +++ b/glue/glue/ligolw/table.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -46,11 +44,6 @@ columns of the table. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] - - import copy import re import sys @@ -58,9 +51,15 @@ from xml.sax.saxutils import escape as xmlescape from xml.sax.xmlreader import AttributesImpl -import ligolw -import tokenizer -import types as ligolwtypes +from glue import git_version +from glue.ligolw import ligolw +from glue.ligolw import tokenizer +from glue.ligolw import types as ligolwtypes + + +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -211,6 +210,25 @@ def reassign_ids(elem): tbl.applyKeyMapping(mapping) +def reset_next_ids(classes): + """ + For each class in the list, if the .next_id attribute is not None + (meaning the table has an ID generator associated with it), set + .next_id to 0. This has the effect of reset the ID generators, and + is useful in applications that process multiple documents and wish + to reset all the ID generators between documents so that the + assigned IDs don't grow without bound as each document is + processed. + + Example: + + >>> reset_next_ids(lsctables.TableByName.values()) + """ + for cls in classes: + if cls.next_id is not None: + cls.set_next_id(type(cls.next_id)(0)) + + # # ============================================================================= # diff --git a/glue/glue/ligolw/tokenizer.Tokenizer.c b/glue/glue/ligolw/tokenizer.Tokenizer.c index 6fca238be7afb0bcc17d7c8c292067e6c1a86cde..726bab2837f13bf7a38634bf02ee848811cee0bb 100644 --- a/glue/glue/ligolw/tokenizer.Tokenizer.c +++ b/glue/glue/ligolw/tokenizer.Tokenizer.c @@ -194,7 +194,7 @@ static void parse_error(PyObject *exception, const Py_UNICODE *buffer, size_t bu pos_str = PyUnicode_Encode(pos, 1, NULL, NULL); if(buffer_str && pos_str) - PyErr_Format(exception, "parse error in '%s' near '%s' at position %ld: %s", PyString_AS_STRING(buffer_str), PyString_AS_STRING(pos_str), pos - buffer + 1, msg); + PyErr_Format(exception, "parse error in '%s' near '%s' at position %zd: %s", PyString_AS_STRING(buffer_str), PyString_AS_STRING(pos_str), pos - buffer + 1, msg); else PyErr_Format(exception, "parse error (details not available): %s", msg); diff --git a/glue/glue/ligolw/types.py b/glue/glue/ligolw/types.py index 2c42dc2e5446c401cbddeebe239a49a6650bd83f..3a5acd7a499288250aacba5e397f8f36833f3622 100644 --- a/glue/glue/ligolw/types.py +++ b/glue/glue/ligolw/types.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -69,12 +67,13 @@ References: import base64 -import ilwd +from glue import git_version +from glue.ligolw import ilwd -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -217,12 +216,34 @@ FromNumPyType = { # # ============================================================================= # -# Conversion To and From Native SQLite Types +# Conversion To and From Native Database Types # # ============================================================================= # +ToMySQLType = { + u"char_s": "CHAR(20)", + u"char_v": "VARCHAR(64)", + u"ilwd:char": "VARCHAR(64)", + u"ilwd:char_u": "BLOB", + u"blob": "BLOB", + u"lstring": "VARCHAR(255)", + u"string": "VARCHAR(255)", + u"int_2s": "SMALLINT", + u"int_2u": "SMALLINT", + u"int_4s": "INTEGER", + u"int_4u": "INTEGER", + u"int_8s": "BIGINT", + u"int_8u": "BIGINT", + u"int": "INTEGER", + u"real_4": "FLOAT", + u"real_8": "DOUBLE", + u"float": "FLOAT", + u"double": "DOUBLE" +} + + ToSQLiteType = { u"char_s": "TEXT", u"char_v": "TEXT", diff --git a/glue/glue/ligolw/utils/__init__.py b/glue/glue/ligolw/utils/__init__.py index 891aed7bc3e24de67927c491f493da5743902494..445cb7091e7d939c75afa3d10363f49ac5f85fe2 100644 --- a/glue/glue/ligolw/utils/__init__.py +++ b/glue/glue/ligolw/utils/__init__.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -53,12 +51,13 @@ except: os.SEEK_SET, os.SEEK_CUR, os.SEEK_END = range(3) +from glue import git_version from glue.ligolw import ligolw -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date __all__ = [] @@ -85,6 +84,7 @@ class IOTrappedSignal(Exception): return "trapped signal %d" % self.signum +# FIXME: remove, use parameter passed to load_*() functions instead ContentHandler = ligolw.LIGOLWContentHandler @@ -264,7 +264,7 @@ class MD5File(object): return self.fileobj.close() -def load_fileobj(fileobj, gz = False, xmldoc = None): +def load_fileobj(fileobj, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file object fileobj, and return the contents as a LIGO Light Weight document tree. The file object @@ -287,11 +287,11 @@ def load_fileobj(fileobj, gz = False, xmldoc = None): fileobj = gzip.GzipFile(mode = "rb", fileobj = RewindableInputFile(fileobj)) if xmldoc is None: xmldoc = ligolw.Document() - ligolw.make_parser(ContentHandler(xmldoc)).parse(fileobj) + ligolw.make_parser((contenthandler or ContentHandler)(xmldoc)).parse(fileobj) return xmldoc, md5obj.hexdigest() -def load_filename(filename, verbose = False, gz = False, xmldoc = None): +def load_filename(filename, verbose = False, gz = False, xmldoc = None, contenthandler = None): """ Parse the contents of the file identified by filename, and return the contents as a LIGO Light Weight document tree. Helpful @@ -313,13 +313,13 @@ def load_filename(filename, verbose = False, gz = False, xmldoc = None): fileobj = file(filename) else: fileobj = sys.stdin - xmldoc, hexdigest = load_fileobj(fileobj, gz = gz, xmldoc = xmldoc) + xmldoc, hexdigest = load_fileobj(fileobj, gz = gz, xmldoc = xmldoc, contenthandler = contenthandler) if verbose: print >>sys.stderr, "md5sum: %s %s" % (hexdigest, filename or "") return xmldoc -def load_url(url, verbose = False, gz = False, xmldoc = None): +def load_url(url, verbose = False, gz = False, xmldoc = None, contenthandler = None): """ This function has the same behaviour as load_filename() but accepts a URL instead of a filename. Any source from which Python's @@ -343,13 +343,13 @@ def load_url(url, verbose = False, gz = False, xmldoc = None): fileobj = urllib2.urlopen(url) else: fileobj = sys.stdin - xmldoc, hexdigest = load_fileobj(fileobj, gz = gz, xmldoc = xmldoc) + xmldoc, hexdigest = load_fileobj(fileobj, gz = gz, xmldoc = xmldoc, contenthandler = contenthandler) if verbose: print >>sys.stderr, "md5sum: %s %s" % (hexdigest, url or "") return xmldoc -def write_fileobj(xmldoc, fileobj, gz = False): +def write_fileobj(xmldoc, fileobj, gz = False, xsl_file = None): """ Writes the LIGO Light Weight document tree rooted at xmldoc to the given file object. The file object need not be seekable. The @@ -390,7 +390,7 @@ def write_fileobj(xmldoc, fileobj, gz = False): if gz: fileobj = gzip.GzipFile(mode = "wb", fileobj = fileobj) fileobj = codecs.EncodedFile(fileobj, "unicode_internal", "utf_8") - xmldoc.write(fileobj) + xmldoc.write(fileobj, xsl_file = xsl_file) fileobj.flush() del fileobj @@ -405,7 +405,7 @@ def write_fileobj(xmldoc, fileobj, gz = False): return md5obj.hexdigest() -def write_filename(xmldoc, filename, verbose = False, gz = False): +def write_filename(xmldoc, filename, verbose = False, gz = False, xsl_file = None): """ Writes the LIGO Light Weight document tree rooted at xmldoc to the file name filename. Friendly verbosity messages are printed while @@ -434,7 +434,7 @@ def write_filename(xmldoc, filename, verbose = False, gz = False): fileobj = file(filename, "w") else: fileobj = sys.stdout - hexdigest = write_fileobj(xmldoc, fileobj, gz = gz) + hexdigest = write_fileobj(xmldoc, fileobj, gz = gz, xsl_file = xsl_file) fileobj.close() if verbose: print >>sys.stderr, "md5sum: %s %s" % (hexdigest, filename or "") diff --git a/glue/glue/ligolw/utils/ligolw_add.py b/glue/glue/ligolw/utils/ligolw_add.py index f4cdba6c10312180cac5d2afa5ce581c87c172a0..a3fcb97a7944133e6bda3149939a8cc5d686eb6d 100644 --- a/glue/glue/ligolw/utils/ligolw_add.py +++ b/glue/glue/ligolw/utils/ligolw_add.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -36,15 +34,16 @@ import sys from urlparse import urlparse +from glue import git_version from glue.ligolw import ligolw from glue.ligolw import table from glue.ligolw import lsctables from glue.ligolw import utils -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -173,7 +172,7 @@ def merge_compatible_tables(elem): # -def ligolw_add(xmldoc, urls, non_lsc_tables_ok = False, verbose = False): +def ligolw_add(xmldoc, urls, non_lsc_tables_ok = False, verbose = False, contenthandler = None): """ An implementation of the LIGO LW add algorithm. urls is a list of URLs (or filenames) to load, xmldoc is the XML document tree to @@ -183,7 +182,7 @@ def ligolw_add(xmldoc, urls, non_lsc_tables_ok = False, verbose = False): for n, url in enumerate(urls): if verbose: print >>sys.stderr, "%d/%d:" % (n + 1, len(urls)), - utils.load_url(url, verbose = verbose, gz = (url or "stdin").endswith(".gz"), xmldoc = xmldoc) + utils.load_url(url, verbose = verbose, gz = (url or "stdin").endswith(".gz"), xmldoc = xmldoc, contenthandler = contenthandler) # ID reassignment if not non_lsc_tables_ok and lsctables.HasNonLSCTables(xmldoc): diff --git a/glue/glue/ligolw/utils/ligolw_sqlite.py b/glue/glue/ligolw/utils/ligolw_sqlite.py index f46c7cf9d57691bbacf0059e2e6479cf742da57c..b472c103d8d5c5ede684d4a794724e0dc0c53ed5 100644 --- a/glue/glue/ligolw/utils/ligolw_sqlite.py +++ b/glue/glue/ligolw/utils/ligolw_sqlite.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -34,6 +32,7 @@ except ImportError: import sys +from glue import git_version from glue.ligolw import ligolw from glue.ligolw import dbtables from glue.ligolw import utils @@ -48,9 +47,9 @@ dbtables.ligolwtypes.ToPyType["ilwd:char"] = unicode dbtables.lsctables.SnglInspiralTable.next_id = dbtables.lsctables.SnglInspiralID(0) -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -123,10 +122,10 @@ def insert(connection, urls, preserve_ids = False, verbose = False): # -def extract(connection, filename, table_names = None, verbose = False): +def extract(connection, filename, table_names = None, verbose = False, xsl_file = None): xmldoc = ligolw.Document() xmldoc.appendChild(dbtables.get_xml(connection, table_names)) - utils.write_filename(xmldoc, filename, gz = (filename or "stdout").endswith(".gz"), verbose = verbose) + utils.write_filename(xmldoc, filename, gz = (filename or "stdout").endswith(".gz"), verbose = verbose, xsl_file = xsl_file) # delete cursors xmldoc.unlink() diff --git a/glue/glue/ligolw/utils/process.py b/glue/glue/ligolw/utils/process.py index be2a209dd6098d9759e45fc306ae3bafb7c09578..8bf861cb70be94ba9c711e10a1bbb26aeb6077da 100644 --- a/glue/glue/ligolw/utils/process.py +++ b/glue/glue/ligolw/utils/process.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -38,6 +36,7 @@ import StringIO import time +from glue import git_version from glue import gpstime from glue.ligolw import ligolw from glue.ligolw import table @@ -45,9 +44,9 @@ from glue.ligolw import lsctables from glue.ligolw import types as ligolwtypes -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>, Larne Pekowsky <lppekows@physics.syr.edu>" -__version__ = "$Revision$"[11:-2] -__date__ = "$Date$"[7:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>, Larne Pekowsky <lppekows@physics.syr.edu>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -59,6 +58,30 @@ __date__ = "$Date$"[7:-2] # +def get_username(): + """ + Try to retrieve the username from a variety of sources. First the + environment variable LOGNAME is tried, if that is not set the + environment variable USERNAME is tried, if that is not set the + password database is consulted (only on Unix systems, if the import + of the pwd module succedes), finally if that fails KeyError is + raised. + """ + try: + return os.environ["LOGNAME"] + except KeyError: + pass + try: + return os.environ["USERNAME"] + except KeyError: + pass + try: + import pwd + return pwd.getpwuid(os.getuid())[0] + except ImportError, KeyError: + raise KeyError + + def append_process(xmldoc, program = None, version = None, cvs_repository = None, cvs_entry_time = None, comment = None, is_online = False, jobid = 0, domain = None, ifos = None): """ Add an entry to the process table in xmldoc. program, version, @@ -82,13 +105,21 @@ def append_process(xmldoc, program = None, version = None, cvs_repository = None # FIXME: remove the "" case when the git versioning business is # sorted out if cvs_entry_time is not None and cvs_entry_time != "": - process.cvs_entry_time = gpstime.GpsSecondsFromPyUTC(time.mktime(time.strptime(cvs_entry_time, "%Y/%m/%d %H:%M:%S"))) + try: + # try the git_version format first + process.cvs_entry_time = gpstime.GpsSecondsFromPyUTC(time.mktime(time.strptime(cvs_entry_time, "%Y-%m-%d %H:%M:%S +0000"))) + except ValueError: + # fall back to the old cvs format + process.cvs_entry_time = gpstime.GpsSecondsFromPyUTC(time.mktime(time.strptime(cvs_entry_time, "%Y/%m/%d %H:%M:%S"))) else: process.cvs_entry_time = None process.comment = comment process.is_online = int(is_online) process.node = socket.gethostname() - process.username = os.environ["LOGNAME"] + try: + process.username = get_username() + except KeyError: + process.username = None process.unix_procid = os.getpid() process.start_time = gpstime.GpsSecondsFromPyUTC(time.time()) process.end_time = None diff --git a/glue/glue/ligolw/utils/segments.py b/glue/glue/ligolw/utils/segments.py index 5abd5b16d6cb4a92b2fc759edcf5c6f41234da1b..c24340ea3278183a9f2f23f97c908e3b094b8053 100644 --- a/glue/glue/ligolw/utils/segments.py +++ b/glue/glue/ligolw/utils/segments.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2008 Kipp C. Cannon +# Copyright (C) 2008 Kipp Cannon # # 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 @@ -31,6 +29,7 @@ Ask Kipp to document this! """ +from glue import git_version from glue import iterutils from glue import segments from glue import segmentsUtils @@ -39,9 +38,9 @@ from glue.ligolw import table from glue.ligolw import lsctables -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__version__ = "$Revision$"[11:-2] -__date__ = "$Date$"[7:-2] +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -290,6 +289,26 @@ def insert_from_segwizard(ligolw_segments, fileobj, instruments, name, comment): ligolw_segments.segment_lists.append(LigolwSegmentList(active = segmentsUtils.fromsegwizard(fileobj, coltype = LIGOTimeGPS), instruments = instruments, name = name, comment = comment)) +def has_segment_tables(xmldoc, name = None): + """ + Return True if the document contains a complete set of segment + tables. Returns False otherwise. If name is given and not None + then the return value is True only if the document's segment + tables, if present, contain a segment list by that name. + """ + try: + def_table = table.get_table(xmldoc, lsctables.SegmentDefTable.tableName) + except ValueError: + return False + try: + table.get_table(xmldoc, lsctables.SegmentTable.tableName) + except ValueError: + return False + if name is not None and name not in set(row.name for row in def_table): + return False + return True + + def segmenttable_get_by_name(xmldoc, name): """ Retrieve the segments whose name matches those given. The result diff --git a/glue/glue/lvalert/__init__.py b/glue/glue/lvalert/__init__.py index 0c540fcf747ddc11fe4b93723c8116d614484313..59394a2b5ecc4c97480953fdab560dc541203e0b 100644 --- a/glue/glue/lvalert/__init__.py +++ b/glue/glue/lvalert/__init__.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2009 LIGO Scientific Collaboration # # 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 @@ -25,11 +23,15 @@ # """ -DOM-like library for handling LIGO Light Weight XML files. +FIXME: ask somebody to document this. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] + +from glue import git_version + + +__author__ = "LIGO Scientific Collaboration" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date __all__ = ["pubsub", "lvstanzaprocessor", "utils"] diff --git a/glue/glue/lvalert/utils.py b/glue/glue/lvalert/utils.py index ccd2917217d0f2d5f7e39d63ebffdd5377294938..18c54dcbcc94d2ecbeefb12dcbdb2c74be371ee1 100644 --- a/glue/glue/lvalert/utils.py +++ b/glue/glue/lvalert/utils.py @@ -21,13 +21,16 @@ from glue.ligolw import utils class LVAlertTable(table.Table): """ for reference, file is written as - file://host/path_to_file/file - and uid is the unique id assigned by gracedb + file: //host/path_to_file/file + uid: the unique id assigned by gracedb + temp_data_loc: current location (just the directory) + of the ouput of the pipeline (this is VOLATILE) """ tableName = "LVAlert:table" validcolumns = { "file": "lstring", - "uid": "lstring" + "uid": "lstring", + "temp_data_loc": "lstring" } class LVAlertRow(object): @@ -41,7 +44,7 @@ LVAlertTable.RowType = LVAlertRow # ############################################################################## -def _parse_file_url(file_url): +def parse_file_url(file_url): """ simple function to parse the file urls of the form: file://host_name/path_to_file/file @@ -54,10 +57,9 @@ def _parse_file_url(file_url): """ parsed = urlparse.urlparse(file_url) host = parsed[1] - full_path = parsed[2] - general_dir = os.path.join(os.path.split(os.path.split(full_path)[0])[0], \ - 'general') - return host, full_path, general_dir + path, fname = os.path.split(parsed[2]) + + return host, path, fname def get_LVAdata_from_stdin(std_in): """ @@ -70,10 +72,11 @@ def get_LVAdata_from_stdin(std_in): """ doc = utils.load_fileobj(std_in)[0] lvatable = table.get_table(doc, LVAlertTable.tableName) - host, full_path, general_dir = _parse_file_url(lvatable[0].file) + file = lvatable[0].file uid = lvatable[0].uid + data_loc = lvatable[0].temp_data_loc - return host, full_path, general_dir, uid + return file, uid, data_loc def get_LVAdata_from_file(filename): """ @@ -87,16 +90,16 @@ def get_LVAdata_from_file(filename): """ doc = utils.load_filename(filename) lvatable = table.get_table(doc, LVAlertTable.tableName) - lvatable = table.get_table(doc, LVAlertTable.tableName) - host, full_path, general_dir = _parse_file_url(lvatable[0].file) + file = lvatable[0].file uid = lvatable[0].uid + data_loc = lvatable[0].temp_data_loc - return host, full_path, general_dir, uid + return file, uid, data_loc -def write_LVAlertTable(filename, file_url, uid): +def make_LVAlertTable(file_url, uid, data_loc): """ - create filename.xml which contains an LVAlert Table - with file_url and uid + create xml doc which contains an LVAlert Table + with submission file file_loc and data located at data_loc """ xmldoc = ligolw.Document() xmldoc.appendChild(ligolw.LIGO_LW()) @@ -104,11 +107,11 @@ def write_LVAlertTable(filename, file_url, uid): row = lvalerttable.RowType() row.file = file_url row.uid = uid + row.temp_data_loc = data_loc lvalerttable.append(row) xmldoc.childNodes[0].appendChild(lvalerttable) - output_file = open(filename+'.xml', 'w') - xmldoc.write(output_file) - output_file.close() + + return xmldoc #the following is meant as a template for small jobs diff --git a/glue/glue/pipeline.py b/glue/glue/pipeline.py index c1482648edade538bd37ea6fe8deb8641d4b46a0..486ed011d5eee49c7fafd51c21c30212db88e4c4 100644 --- a/glue/glue/pipeline.py +++ b/glue/glue/pipeline.py @@ -2961,7 +2961,7 @@ class SqliteJob(CondorDAGJob, AnalysisJob): """ self.__exec_name = exec_name executable = cp.get('condor', exec_name) - universe = 'local' + universe = 'vanilla' CondorDAGJob.__init__(self, universe, executable) AnalysisJob.__init__(self, cp, dax) @@ -3043,6 +3043,13 @@ class LigolwSqliteJob(SqliteJob): sections = ['ligolw_sqlite'] SqliteJob.__init__(self, cp, sections, exec_name, dax) + def set_replace(self): + """ + Sets the --replace option. This will cause the job + to overwrite existing databases rather than add to them. + """ + self.add_var_opt('replace') + class LigolwSqliteNode(SqliteNode): """ diff --git a/glue/glue/segmentdb/logic.py b/glue/glue/segmentdb/logic.py index 3aeb964ec330c63dbbed4052e19b2ca29c4853d8..eff0eb4c74449e2e1217427e702b2d65af65bc52 100644 --- a/glue/glue/segmentdb/logic.py +++ b/glue/glue/segmentdb/logic.py @@ -111,8 +111,6 @@ def run_file_operation(outdoc, filenames, use_segment_table, operation, preserve raise NameError ("%s is not a known operation (intersect, union or diff)" % operation) - result.coalesce() - # Add a segment definer for the result seg_def_id = add_to_segment_definer(outdoc, proc_id, ifo, name, version) @@ -178,6 +176,7 @@ def run_segment_operation(outdoc, filenames, segments, use_segment_table, operat else: raise NameError("%s is not a known operation (intersect, union or diff)" % operation) + # Add a segment definer and segments seg_def_id = add_to_segment_definer(outdoc, proc_id, '', result_name, 1) diff --git a/glue/glue/segmentdb/query_engine.py b/glue/glue/segmentdb/query_engine.py index 92668c61e2613c5767bc9b20f6183eb908e08e28..77dddfe6889ef633435af31c31d8b470f1f5bf2f 100644 --- a/glue/glue/segmentdb/query_engine.py +++ b/glue/glue/segmentdb/query_engine.py @@ -107,8 +107,11 @@ class LdbdQueryEngine(QueryEngine): xml = self.client.query(sql) # This is a kludge around bug 2317 - self.client.__disconnect__() - self.client.__connect__(self.client.host, self.client.port, self.client.identity) + try: + self.client.__disconnect__() + self.client.__connect__(self.client.host, self.client.port, self.client.identity) + except: + pass self.ligomd.parse(xml) res = self.ligomd.table diff --git a/glue/glue/segmentdb/segmentdb_utils.py b/glue/glue/segmentdb/segmentdb_utils.py index 686a3e4fe32f3cd0baf56cebfe96eae9a4bb4670..7500a6cb35e480f4f634492f72768c4307b2dc1a 100644 --- a/glue/glue/segmentdb/segmentdb_utils.py +++ b/glue/glue/segmentdb/segmentdb_utils.py @@ -39,7 +39,7 @@ from glue.ligolw import types as ligolwtypes # -def get_all_files_in_range(dirname, starttime, endtime): +def get_all_files_in_range(dirname, starttime, endtime, pad=64): """Returns all files in dirname and all its subdirectories whose names indicate that they contain segments in the range starttime to endtime""" @@ -60,48 +60,72 @@ def get_all_files_in_range(dirname, starttime, endtime): if re.match('.*-[0-9]{4}$', filename): dirtime = int(filename[-4:]) if dirtime >= first_four_start and dirtime <= first_four_end: - ret += get_all_files_in_range(os.path.join(dirname,filename), starttime, endtime) + ret += get_all_files_in_range(os.path.join(dirname,filename), starttime, endtime, pad=pad) elif re.match('.*-[0-9]*-[0-9]*\.xml', filename): file_time = int(filename.split('-')[-2]) - if file_time >= (starttime-64) and file_time <= (endtime+64): + if file_time >= (starttime-pad) and file_time <= (endtime+pad): ret.append(os.path.join(dirname,filename)) else: # Keep recursing, we may be looking at directories of # ifos, each of which has directories with times - ret += get_all_files_in_range(os.path.join(dirname,filename), starttime, endtime) + ret += get_all_files_in_range(os.path.join(dirname,filename), starttime, endtime, pad=pad) return ret -def setup_database(host_and_port): - from glue import LDBDClient - from glue import gsiserverutils - - """Opens a connection to a LDBD Server""" - port = 30015 - - if host_and_port.find(':') < 0: - host = host_and_port - else: - # server and port specified - host, portString = host_and_port.split(':') - port = int(portString) - - identity = "/DC=org/DC=doegrids/OU=Services/CN=ldbd/%s" % host - - # open connection to LDBD Server - client = None - - try: - client = LDBDClient.LDBDClient(host, port, identity) - except Exception, e: - print >>sys.stderr, \ +def setup_database(database_location): + """Determine if we are using the secure or insecure server""" + if database_location.startswith('ldbd:'): + identity = "/DC=org/DC=doegrids/OU=Services/CN=ldbd/" + host_and_port = database_location[len('ldbd://'):] + if host_and_port.find(':') < 0: + host = host_and_port + port = 30015 + else: + # server and port specified + host, portString = host_and_port.split(':') + port = int(portString) + + identity += host + client = None + + if port != 443: + from glue import LDBDClient + from glue import gsiserverutils + try: + client = LDBDClient.LDBDClient(host, port, identity) + except Exception, e: + print >>sys.stderr, \ "Unable to connect to LDBD Server %s:%d" % (host, port) - if gsiserverutils.checkCredentials(): - print >>sys.stderr, "Got the following error : " + str(e) - print >>sys.stderr, "Run with --help' for usage" - sys.exit(-1) + if gsiserverutils.checkCredentials(): + print >>sys.stderr, "Got the following error : " + str(e) + print >>sys.stderr, "Run with --help' for usage" + sys.exit(1) + else: + from glue import LDBDWClient + try: + client = LDBDWClient.LDBDClient(host, port, identity) + except Exception, e: + print >>sys.stderr, "Unable to connect to LDBD Server %s:%d" % (host, port) + sys.exit(1) + + + + elif database_location.startswith('ldbdi:'): + port = 30016 + host = database_location[len('ldbdi://'):] + identity = None + + from glue import LDBDClient + try: + client = LDBDClient.LDBDClient(host, port, identity) + except Exception, e: + print >>sys.stderr, "Unable to connect to LDBD Server %s:%d" % (host, port) + sys.exit(1) + else: + raise ValueError( "invalid url for segment database" ) + return client @@ -119,9 +143,18 @@ def setup_database(host_and_port): def query_segments(engine, table, segdefs): - # each segdef has - # ifo, name, version, start_time, end_time, start_pad, end_pad + # each segdef is a list containing: + # ifo, name, version, start_time, end_time, start_pad, end_pad + + + # The trivial case: if there's nothing to do, return no time + if len(segdefs) == 0: + return [ segmentlist([]) ] + # + # For the sake of efficiency we query the database for all the segdefs at once + # This constructs a clause that looks for one + # def make_clause(table, segdef): ifo, name, version, start_time, end_time, start_pad, end_pad = segdef @@ -132,9 +165,6 @@ def query_segments(engine, table, segdefs): return sql - if len(segdefs) == 0: - return [ segmentlist([]) ] - clauses = [make_clause(table, segdef) for segdef in segdefs] sql = 'SELECT segment_definer.ifos, segment_definer.name, segment_definer.version, ' @@ -149,17 +179,52 @@ def query_segments(engine, table, segdefs): rows = engine.query(sql) + # + # The result of a query will be rows of the form + # ifo, name, version, start_time, end_time + # + # We want to associate each returned row with the segdef it belongs to so that + # we can apply the correct padding. + # + # If segdefs were uniquely spcified by (ifo, name, version) this would + # be easy, but it may happen that we're looking for the same segment definer + # at multiple disjoint times. In particular this can happen if the user + # didn't specify a version number; in that case we might have version 2 + # of some flag defined over multiple disjoint segment_definers. + # results = [] for segdef in segdefs: ifo, name, version, start_time, end_time, start_pad, end_pad = segdef - matches = lambda row: row[0].strip() == ifo and row[1] == name and int(row[2]) == int(version) - - result = segmentlist( [segment(row[3] + start_pad, row[4] + end_pad) for row in rows if matches(row)] ) - result &= segmentlist([segment(start_time, end_time)]) - result.coalesce() - + search_span = segment(start_time, end_time) + search_span_list = segmentlist([search_span]) + + # See whether the row belongs to the current segdef. Name, ifo and version must match + # and the padded segment must overlap with the range of the segdef. + def matches(row): + return ( row[0].strip() == ifo and row[1] == name and int(row[2]) == int(version) + and search_span.intersects(segment(row[3] + start_pad, row[4] + start_pad)) ) + + # Add the padding. Segments may extend beyond the time of interest, chop off the excess. + def pad_and_truncate(row_start, row_end): + tmp = segmentlist([segment(row_start + start_pad, row_end + end_pad)]) + # No coalesce needed as a list with a single segment is already coalesced + tmp &= search_span_list + + # The intersection is guaranteed to be non-empty if the row passed match() + return tmp[0] + + # Build a segment list from the returned segments, padded and trunctated. The segments will + # not necessarily be disjoint, if the padding crosses gaps. They are also not gauranteed to + # be in order, since there's no ORDER BY in the query. So the list needs to be coalesced + # before arithmatic can be done with it. + result = segmentlist( [pad_and_truncate(row[3], row[4]) for row in rows if matches(row)] ).coalesce() + + # This is not needed: since each of the segments are constrained to be within the search + # span the whole list must be as well. + # result &= search_span_list + results.append(result) return results @@ -194,8 +259,8 @@ def expand_version_number(engine, segdef): for seg in segs[0]: results.append( (ifo, name, version, seg[0], seg[1], 0, 0) ) - intervals -= segs[0] intervals.coalesce() + intervals -= segs[0] version -= 1 @@ -260,7 +325,7 @@ def ensure_segment_table(connection): # ============================================================================= # -def add_to_segment_definer(xmldoc, proc_id, ifo, name, version): +def add_to_segment_definer(xmldoc, proc_id, ifo, name, version, comment=''): try: seg_def_table = table.get_table(xmldoc, lsctables.SegmentDefTable.tableName) except: @@ -274,7 +339,7 @@ def add_to_segment_definer(xmldoc, proc_id, ifo, name, version): segment_definer.ifos = ifo segment_definer.name = name segment_definer.version = version - segment_definer.comment = '' + segment_definer.comment = comment seg_def_table.append(segment_definer) @@ -300,7 +365,7 @@ def add_to_segment(xmldoc, proc_id, seg_def_id, sgmtlist): segtable.append(segment) -def add_to_segment_summary(xmldoc, proc_id, seg_def_id, sgmtlist): +def add_to_segment_summary(xmldoc, proc_id, seg_def_id, sgmtlist, comment=''): try: seg_sum_table = table.get_table(xmldoc, lsctables.SegmentSumTable.tableName) except: @@ -314,7 +379,7 @@ def add_to_segment_summary(xmldoc, proc_id, seg_def_id, sgmtlist): segment_sum.segment_sum_id = seg_sum_table.get_next_id() segment_sum.start_time = seg[0] segment_sum.end_time = seg[1] - segment_sum.comment = '' + segment_sum.comment = comment seg_sum_table.append(segment_sum) @@ -357,6 +422,8 @@ def build_segment_list(engine, gps_start_time, gps_end_time, ifo, segment_name, version = len(rows[0]) and rows[0][0] or 1 return build_segment_list_one(engine, gps_start_time, gps_end_time, ifo, segment_name, version, start_pad, end_pad) + + def build_segment_list_one(engine, gps_start_time, gps_end_time, ifo, segment_name, version = None, start_pad = 0, end_pad = 0): """Builds a list of segments satisfying the given criteria """ seg_result = segmentlist([]) diff --git a/glue/glue/segments.py b/glue/glue/segments.py index 97100ff86aaa048afe732d8860723d54b805f85f..473ab05fed59209b94632495a39ca676d002efa2 100644 --- a/glue/glue/segments.py +++ b/glue/glue/segments.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -44,9 +42,12 @@ from bisect import bisect_left, bisect_right from copy import copy as shallowcopy -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +from glue import git_version + + +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # @@ -1165,7 +1166,7 @@ class segmentlistdict(dict): keys = set(keys) if not keys: return segmentlist() - seglist = segmentlist(self[keys.pop()]) + seglist = shallowcopy(self[keys.pop()]) for key in keys: seglist &= self[key] return seglist @@ -1178,7 +1179,7 @@ class segmentlistdict(dict): keys = set(keys) if not keys: return segmentlist() - seglist = segmentlist(self[keys.pop()]) + seglist = shallowcopy(self[keys.pop()]) for key in keys: seglist |= self[key] return seglist diff --git a/glue/glue/segmentsUtils.py b/glue/glue/segmentsUtils.py index 666d24302b29a4c23fd4f35869b7356175a49d5b..1695b2ba5157cf03c6ff6d4773bf3276ea953876 100644 --- a/glue/glue/segmentsUtils.py +++ b/glue/glue/segmentsUtils.py @@ -1,6 +1,4 @@ -# $Id$ -# -# Copyright (C) 2006 Kipp C. Cannon +# Copyright (C) 2006 Kipp Cannon # # 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 @@ -32,15 +30,18 @@ objects. """ -__author__ = "Kipp Cannon <kcannon@ligo.caltech.edu>" -__date__ = "$Date$"[7:-2] -__version__ = "$Revision$"[11:-2] +import re -import re -import segments -import lal -import iterutils +from glue import git_version +from glue import iterutils +from glue import lal +from glue import segments + + +__author__ = "Kipp Cannon <kipp.cannon@ligo.org>" +__version__ = "git id %s" % git_version.id +__date__ = git_version.date # diff --git a/glue/setup.py b/glue/setup.py index 622fd61ef2bf76e1ddc4da6ee9695bd6a6da9414..e957864e7d4a453751601c0a04cb226791395c43 100644 --- a/glue/setup.py +++ b/glue/setup.py @@ -25,7 +25,7 @@ from distutils.command import sdist from distutils.command import clean from distutils import log -ver = "1.26" +ver = "1.28.1" def remove_root(path,root): if root: @@ -158,7 +158,7 @@ setup( description = "Grid LSC User Engine", url = "http://www.lsc-group.phys.uwm.edu/daswg/", license = 'See file LICENSE', - packages = [ 'glue', 'glue.lars', 'glue.lars.cli', 'glue.lars.util', 'glue.ligolw', 'glue.ligolw.utils', 'glue.lvalert', 'glue.segmentdb' ], + packages = [ 'glue', 'glue.gracedb', 'glue.lars', 'glue.lars.cli', 'glue.lars.util', 'glue.ligolw', 'glue.ligolw.utils', 'glue.lvalert', 'glue.segmentdb' ], cmdclass = { 'build_py' : glue_build_py, 'install' : glue_install, @@ -222,15 +222,18 @@ setup( os.path.join('bin','ligolw_dq_query'), os.path.join('bin','ligolw_dq_active'), os.path.join('bin','ligolw_dq_active_cats'), + os.path.join('bin','ligolw_dq_grapher'), os.path.join('bin','lvalert_admin'), os.path.join('bin','lvalert_send'), os.path.join('bin','lvalert_listen'), os.path.join('bin','ldbdd'), os.path.join('bin','ligolw_publish_dqxml'), - os.path.join('bin','segdb_coalesce'), ], + os.path.join('bin','segdb_coalesce'), + os.path.join('bin', 'ligolw_print_tables') ], data_files = [ ( 'etc', [ os.path.join('etc','ldg-sites.xml'), + os.path.join('etc','cbcwebpage.css'), os.path.join('etc','pegasus-properties.bundle'), os.path.join('etc','glue-user-env.sh'), os.path.join('etc','glue-user-env.csh'), @@ -238,6 +241,7 @@ setup( os.path.join('etc','ldbduser.ini'), os.path.join('etc','ligolw.xsl'), os.path.join('etc','ligolw.js'), + os.path.join('etc','LDBDWServer.wsgi'), os.path.join('etc','ligolw_dtd.txt') ] ), ( os.path.join( 'etc', 'httpd', 'conf.d' ), @@ -273,6 +277,13 @@ setup( os.path.join('src', 'php', 'seginsert','scripts','styletitle.php'), os.path.join('src', 'php', 'seginsert','scripts','time_conv_functions.php') ] + ), + ( os.path.join( 'var', 'php', 'dq_report' ), + [ + os.path.join('src', 'php', 'dq_report','index.php'), + os.path.join('src', 'php', 'dq_report','get_report.php'), + os.path.join('src', 'php', 'dq_report','header.php') + ] ) ] ) diff --git a/glue/src/conf/s6_db2/process.sql.in b/glue/src/conf/s6_db2/process.sql.in index 59a948926738585e1a2e2c120c77448bdbf2d1a0..9a0b9ea45a23d5045bbe2756f4f84c88de50c960 100644 --- a/glue/src/conf/s6_db2/process.sql.in +++ b/glue/src/conf/s6_db2/process.sql.in @@ -40,7 +40,7 @@ CREATE TABLE process -- Node on which it was run node VARCHAR(64) NOT NULL, -- Unix username - username CHAR(16) NOT NULL, + username CHAR(64) NOT NULL, -- Unix process ID unix_procid INTEGER NOT NULL, -- Start time (GPS seconds) diff --git a/glue/src/php/seginsert/flagcheck.php b/glue/src/php/seginsert/flagcheck.php index c6ea6567b9c8244bc72f04a597798d369cc9408d..93114e057670d5e8ed1ff8cae8ed11b73cbc54c9 100755 --- a/glue/src/php/seginsert/flagcheck.php +++ b/glue/src/php/seginsert/flagcheck.php @@ -122,11 +122,19 @@ $error = 0; // validate elog url $url = $_POST['url']; + // check url length + if(strlen($url)>255) + { + $error = $error + 1; + echo "<p>Elog url = <font color='red'>Length must not exceed 255 characters</font></p>"; + } + + // check url presence if(strpos($url,'http') !== 0) { echo "<p>Elog url = <font color='red'>Warning: no elog entry specified. Please give an elog URL, if possible.</font><p/>"; } - if(strpos($url,'http') === 0) + if(strpos($url,'http') === 0 && strlen($url)<=255) { $url=htmlspecialchars($_POST['url']); echo "<p>Please click on this <a href='$url' get='_blank'>link</a> to verify the elog url (opens in new window).</p>"; @@ -134,10 +142,10 @@ $error = 0; // validate username $username = $_POST['user']; - if(strlen($username)==0) + if(strlen($username)==0 || strlen($username)>64) { $error = $error + 1; - echo "<p>User Name = <font color='red'>username must be specified</font></p>"; + echo "<p>User Name = <font color='red'>username must be specified, and length must not exceed 64 characters</font></p>"; } else { diff --git a/glue/src/php/seginsert/index.php b/glue/src/php/seginsert/index.php index 88b86204d0e0c503c00921f00d9c38e7dd24425a..7d185f90e96242ed5a0e45a3e7a66a53b0dd0081 100755 --- a/glue/src/php/seginsert/index.php +++ b/glue/src/php/seginsert/index.php @@ -33,6 +33,7 @@ require './scripts/header.php'; <option value="SCI-HIGH_MICROSEISMIC_ELOG (High microseismic levels described in the elog)">SCI-HIGH_MICROSEISMIC_ELOG (High microseismic levels described in the elog)</option> <option value="SCI-HIGH_WIND_ELOG (High winds described in the elog)">SCI-HIGH_WIND_ELOG (High winds described in the elog)</option> <option value="SCI-HUMAN_INTRUSION_ELOG (Human intrusion into the LVEA described in the elog)">SCI-HUMAN_INTRUSION_ELOG (Human intrusion into the LVEA described in the elog)</option> + <option value="SCI-LOW_POWER_ELOG (low power laser operation described in the elog)">SCI-LOW_POWER_ELOG (low power laser operation described in the elog)</option> <option value="SCI-NONSTAND_CONFIG_ELOG (Nonstandard configuration described in the elog)">SCI-NONSTAND_CONFIG_ELOG (Nonstandard configuration described in the elog)</option> <option value="SCI-SEISMIC_ELOG (Seismic event of unknown cause described in the elog)">SCI-SEISMIC_ELOG (Seismic event described in the elog)</option> <option value="SCI-TRAIN_ELOG (Passing train causing high seismic levels described in the elog)">SCI-TRAIN_ELOG (Passing train causing high seismic levels described in the elog)</option> diff --git a/glue/src/php/seginsert/submitflag.php b/glue/src/php/seginsert/submitflag.php index 8eb61c3168af0d7f4fa33855ef53d5565c595c06..eec59689cb08d71f4525d3dd8af5ac64d7f27c3b 100755 --- a/glue/src/php/seginsert/submitflag.php +++ b/glue/src/php/seginsert/submitflag.php @@ -100,7 +100,7 @@ require './scripts/header.php'; ' "submitflag.php"'.','. ' "1.0"'.','. ' "/lalsuite/glue/php/submitflag.php"'.','. -'"'.$_POST[comment].'"'.','. +'"'.$brief_desc.'"'.','. '"'.$node.'"'.','. '"'.$_POST[user].'"'.','. " $pid".','. @@ -110,8 +110,7 @@ require './scripts/header.php'; ' "'.$_POST[site].'"'."\n". ' </Stream>'."\n". ' </Table>'."\n"; -//'"'.$_POST[comment].'"'.','. -//'"'.$brief_desc.'"'.','. + $segment_definer = " <Table Name='segment_definer:table'>\n". " <Column Name='segment_definer:process_id' Type='ilwd:char'/>\n". diff --git a/glue/test/lal_verify.py b/glue/test/lal_verify.py index 3fdf8075da159d8b8df7730c36e913e4846b9e83..2deca7ab3c3de85b5b796b3d73fa370c09d8df11 100644 --- a/glue/test/lal_verify.py +++ b/glue/test/lal_verify.py @@ -81,7 +81,7 @@ class test_LIGOTimeGPS(unittest.TestCase): def test_pylal_comparison(self): try: - from pylal.xlal.date import LIGOTimeGPS as pylalLIGOTimeGPS + from pylal.datatypes import LIGOTimeGPS as pylalLIGOTimeGPS except ImportError: print >>sys.stderr, "pylal not available: skipping test" return diff --git a/glue/test/ligo_lw_test_01.py b/glue/test/ligo_lw_test_01.py index d931a13e8ac50f71b5a95d863df687ae36f4906e..a798c025316a97604adfedab0592f9af4680e2dc 100644 --- a/glue/test/ligo_lw_test_01.py +++ b/glue/test/ligo_lw_test_01.py @@ -1,7 +1,7 @@ import matplotlib matplotlib.use("Agg") from matplotlib import figure -from matplotlib.backends.backend_agg import FigureCanvasAgg +from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas import numpy import sys @@ -14,7 +14,7 @@ xmldoc = utils.load_filename("ligo_lw_test_01.xml", verbose = True) for n, a in enumerate(xmldoc.getElementsByTagName(ligolw.Array.tagName)): print >>sys.stderr, "found %s array '%s'" % ("x".join(map(str, a.array.shape)), a.getAttribute("Name")) fig = figure.Figure() - FigureCanvasAgg(fig) + FigureCanvas(fig) axes = fig.gca() axes.loglog() axes.grid(True) diff --git a/lal/.gitignore b/lal/.gitignore index bff87f3dbc74abb4472f491c4b282e249d4873d4..18c3032eb7ef08e46186b11c00ab1794fea04914 100644 --- a/lal/.gitignore +++ b/lal/.gitignore @@ -112,24 +112,10 @@ packages/fft/test/AvgSpecTest packages/fft/test/ComplexFFTTest packages/fft/test/RealFFTTest packages/fft/test/TimeFreqFFTTest +packages/fft/src/CudaFFT.c +packages/fft/src/CudaFFT.linkinfo packages/findchirp/test/FindChirpBCVSpinTest packages/findchirp/test/FindChirpTDTest -packages/framedata/src/FrameSeries.c -packages/framedata/test/AggregationCacheTest -packages/framedata/test/AggregationTest -packages/framedata/test/FrameCacheTest -packages/framedata/test/FrameStreamTest -packages/framedata/test/H1:LSC-AS_Q.* -packages/framedata/test/MakeFrames -packages/framedata/test/Read40mData -packages/framedata/test/ReadGEOData -packages/framedata/test/ReadLHOData -packages/framedata/test/catalog -packages/framedata/test/catalog.test -packages/framedata/test/dq_vector.dat -packages/framedata/test/series.dat -packages/framedata/test/series_dq.dat -packages/framedata/test/state_vector.dat packages/hello/test/LALHelloTest packages/houghpulsar/test/OutHistogram.asc packages/houghpulsar/test/OutHough.asc @@ -188,21 +174,6 @@ packages/std/test/LALGSLTest packages/std/test/LALMallocTest packages/std/test/LALVersionTest packages/std/test/StringConvertTest -packages/stochastic/test/??_714382918*.dat -packages/stochastic/test/AstroOmegaTest -packages/stochastic/test/CZeroPadAndFFTTest -packages/stochastic/test/OverlapReductionFunctionTest -packages/stochastic/test/SZeroPadAndFFTTest -packages/stochastic/test/SimulatePopcornTest -packages/stochastic/test/SimulateSBTest -packages/stochastic/test/StochasticCrossCorrelationSpectrumTest -packages/stochastic/test/StochasticCrossCorrelationStatisticTest -packages/stochastic/test/StochasticHeterodynedCrossCorrelationStatisticTest -packages/stochastic/test/StochasticInverseNoiseTest -packages/stochastic/test/StochasticOmegaGWTest -packages/stochastic/test/StochasticOptimalFilterNormalizationTest -packages/stochastic/test/StochasticOptimalFilterTest -packages/stochastic/test/WHITENED-SB? packages/support/src/PrintFrequencySeries.c packages/support/src/PrintTimeSeries.c packages/support/src/PrintVector.c @@ -220,7 +191,6 @@ packages/support/test/?TS*.dat packages/support/test/ConfigFileTest packages/support/test/LALMath3DPlotTest packages/support/test/LALMathNDPlotTest -packages/support/test/LALXMLTest packages/support/test/Math3DNotebook.nb packages/support/test/MathNDNotebook.nb packages/support/test/NRWaveIOTest diff --git a/lal/00boot b/lal/00boot index 4a6e8c4eecdc7fda45d4b9064ae93c545bd260cb..16b48f1d7af5b3424662190b7f179966e5f2b93c 100755 --- a/lal/00boot +++ b/lal/00boot @@ -146,10 +146,6 @@ cd packages/stats/src || fail "creating sources in packages/stats/src" ${M4} LALMoment.m4 > LALMoment.c || fail "creating sources in packages/stats/src" cd ../../.. || fail "creating sources in packages/stats/src" -cd packages/framedata/src || fail "creating sources in packages/framedata/src" -${M4} FrameSeries.m4 > FrameSeries.c || fail "creating sources in packages/framedata/src" -cd ../../.. || fail "creating sources in packages/framedata/src" - cd packages/pulsar/test || fail "creating sources in packages/pulsar/test" /bin/sh ephemtoilwd.sh earth98.dat > earth98.ilwd || fail "creating sources in packages/pulsar/test" /bin/sh ephemtoilwd.sh sun98.dat > sun98.ilwd || fail "creating sources in packages/pulsar/test" diff --git a/lal/AUTHORS b/lal/AUTHORS index 499119906e4e72c9c8df4e56277518c8b8430bcc..eafbdf0b69f3f57025de43101616e7155ad83d38 100644 --- a/lal/AUTHORS +++ b/lal/AUTHORS @@ -1,3 +1,4 @@ +Ajith, P. Allen, B. Anderson, W. G. Ausmus, D. diff --git a/lal/Makefile.am b/lal/Makefile.am index afb9ebc7d9c5991fb96ef54cbb1b20de540a0436..6e7312bca22b3d5f0a0d9c8ab97a7136f47dfca7 100644 --- a/lal/Makefile.am +++ b/lal/Makefile.am @@ -4,27 +4,17 @@ SUBDIRS = include packages doc lib misc debian @subdirs@ MAINTAINERCLEANFILES = lal.spec distcleancheck_listfiles = find . -type f \! -name "LALVCSInfo.h" -print EXTRA_DIST = README.bugs README.contrib README.install \ - lal.pc.in lalsupport.pc.in lalframe.pc.in lalmetaio.pc.in lalxml.pc.in \ - lalstochastic.pc.in lal-config.in aclocal.m4 lal.spec.in lal.spec + lal.pc.in lalsupport.pc.in lalmetaio.pc.in \ + lal-config.in aclocal.m4 lal.spec.in lal.spec bin_SCRIPTS = lal-config -if FRAME -LALFRAMEPC = lalframe.pc -else -LALFRAMEPC = -endif if METAIO LALMETAIOPC = lalmetaio.pc else LALMETAIOPC = endif -if XML -LALXMLPC = lalxml.pc -else -LALXMLPC = -endif pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = lal.pc lalsupport.pc lalstochastic.pc $(LALFRAMEPC) $(LALMETAIOPC) $(LALXMLPC) +pkgconfig_DATA = lal.pc lalsupport.pc $(LALMETAIOPC) # cvs-clean: more than maintainer-clean, this cleans # everything not in the cvs archive. diff --git a/lal/README.contrib b/lal/README.contrib index 499d2ea296526ebdd3f2c1fc794bab9573e26df9..3c93621f6e7e9e641843c6f8e7dbce30edd096e5 100644 --- a/lal/README.contrib +++ b/lal/README.contrib @@ -5,17 +5,15 @@ A message from the librarian: When developing a package for LAL, please test the code with gcc using the following compiler flags: - -g3 -O4 -ansi -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wshadow - -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common - -Wnested-externs -D__NO_STRING_INLINES -Wno-long-long + -g3 -O4 -Wall -W -Wmissing-prototypes -Wstrict-prototypes + -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings + -fno-common -Wnested-externs -Wno-format-zero-length -These flags provide a useful way to detect potential bugs. (The --D__NO_STRING_INLINES turns off a bug in one of the include files on -Linux systems). The package should compile cleanly. (Add -Werror to -enforce this.) +These flags provide a useful way to detect potential bugs. (Add -Werror +to enforce this.) -You can turn on these flags when configuring LAL (with gcc as the -compiler) using the --with-gcc-flags configure option. +These flags are enabled by default, you can turn them off using the +--disable-gcc-flags configure option. ******************************************************************************* diff --git a/lal/configure.ac b/lal/configure.ac index ab422c0345e6b1cb067f5ea4ea85ed95cf9d1d85..c0612539432e4e4e5666484455e895e82fd3649f 100644 --- a/lal/configure.ac +++ b/lal/configure.ac @@ -1,165 +1,148 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([lal],[6.2],[lal-discuss@gravity.phys.uwm.edu]) -AC_CONFIG_HEADERS([include/config.h] [include/lal/LALConfig.h]) +AC_INIT([lal],[6.4],[lal-discuss@gravity.phys.uwm.edu]) +AC_CONFIG_HEADERS([include/config.h include/lal/LALConfig.h]) AC_CONFIG_SRCDIR([include/config.h.in]) AC_CONFIG_AUX_DIR([misc]) AC_CONFIG_FILES([ \ - lal.spec \ - lal.pc \ - lalframe.pc \ - lalmetaio.pc \ - lalxml.pc \ - lalstochastic.pc \ - lalsupport.pc \ - lal-config \ - Makefile \ - debian/Makefile \ - doc/Makefile \ - doc/laldoc/Makefile \ - doc/autodoc/Makefile \ - include/Makefile \ - include/lal/Makefile \ - lib/git_version - lib/Makefile \ - misc/Makefile \ - packages/Makefile \ - packages/std/Makefile \ - packages/std/doc/Makefile \ - packages/std/include/Makefile - packages/std/src/Makefile \ - packages/std/test/Makefile \ - packages/tools/Makefile \ - packages/tools/doc/Makefile \ - packages/tools/include/Makefile \ - packages/tools/src/Makefile \ - packages/tools/test/Makefile \ - packages/factories/Makefile \ - packages/factories/doc/Makefile \ - packages/factories/include/Makefile \ - packages/factories/src/Makefile \ - packages/factories/test/Makefile \ - packages/vectorops/Makefile \ - packages/vectorops/doc/Makefile \ - packages/vectorops/include/Makefile \ - packages/vectorops/src/Makefile \ - packages/vectorops/test/Makefile \ - packages/utilities/Makefile \ - packages/utilities/doc/Makefile \ - packages/utilities/include/Makefile \ - packages/utilities/src/Makefile \ - packages/utilities/test/Makefile \ - packages/stats/Makefile \ - packages/stats/doc/Makefile \ - packages/stats/include/Makefile \ - packages/stats/src/Makefile \ - packages/stats/test/Makefile \ - packages/inject/Makefile \ - packages/inject/doc/Makefile \ - packages/inject/include/Makefile \ - packages/inject/src/Makefile \ - packages/inject/test/Makefile \ - packages/date/Makefile \ - packages/date/doc/Makefile \ - packages/date/include/Makefile \ - packages/date/src/Makefile \ - packages/date/test/Makefile \ - packages/tdfilter/Makefile \ - packages/tdfilter/doc/Makefile \ - packages/tdfilter/include/Makefile \ - packages/tdfilter/src/Makefile \ - packages/tdfilter/test/Makefile \ - packages/window/Makefile \ - packages/window/doc/Makefile \ - packages/window/include/Makefile \ - packages/window/src/Makefile \ - packages/window/test/Makefile \ - packages/fft/Makefile \ - packages/fft/doc/Makefile \ - packages/fft/include/Makefile \ - packages/fft/src/Makefile \ - packages/fft/test/Makefile \ - packages/clremoval/Makefile \ - packages/clremoval/doc/Makefile \ - packages/clremoval/include/Makefile \ - packages/clremoval/src/Makefile \ - packages/clremoval/test/Makefile \ - packages/inspiral/Makefile \ - packages/inspiral/doc/Makefile \ - packages/inspiral/include/Makefile \ - packages/inspiral/src/Makefile \ - packages/inspiral/test/Makefile \ - packages/noisemodels/Makefile \ - packages/noisemodels/doc/Makefile \ - packages/noisemodels/include/Makefile \ - packages/noisemodels/src/Makefile \ - packages/noisemodels/test/Makefile \ - packages/bank/Makefile \ - packages/bank/doc/Makefile \ - packages/bank/include/Makefile \ - packages/bank/src/Makefile \ - packages/bank/test/Makefile \ - packages/ring/Makefile \ - packages/ring/doc/Makefile \ - packages/ring/include/Makefile \ - packages/ring/src/Makefile \ - packages/ring/test/Makefile \ - packages/findchirp/Makefile \ - packages/findchirp/doc/Makefile \ - packages/findchirp/include/Makefile \ - packages/findchirp/src/Makefile \ - packages/findchirp/test/Makefile \ - packages/pulsar/Makefile \ - packages/pulsar/doc/Makefile \ - packages/pulsar/include/Makefile \ - packages/pulsar/src/Makefile \ - packages/pulsar/test/Makefile \ - packages/houghpulsar/Makefile \ - packages/houghpulsar/doc/Makefile \ - packages/houghpulsar/include/Makefile \ - packages/houghpulsar/src/Makefile \ - packages/houghpulsar/test/Makefile \ - packages/burstsearch/Makefile \ - packages/burstsearch/doc/Makefile \ - packages/burstsearch/include/Makefile \ - packages/burstsearch/src/Makefile \ - packages/burstsearch/test/Makefile \ - packages/tracksearch/Makefile \ - packages/tracksearch/doc/Makefile \ - packages/tracksearch/include/Makefile \ - packages/tracksearch/src/Makefile \ - packages/tracksearch/test/Makefile \ - packages/timefreq/Makefile \ - packages/timefreq/doc/Makefile \ - packages/timefreq/include/Makefile \ - packages/timefreq/src/Makefile \ - packages/timefreq/test/Makefile \ - packages/stochastic/Makefile \ - packages/stochastic/doc/Makefile \ - packages/stochastic/include/Makefile \ - packages/stochastic/src/Makefile \ - packages/stochastic/test/Makefile \ - packages/support/Makefile \ - packages/support/doc/Makefile \ - packages/support/include/Makefile \ - packages/support/src/Makefile \ - packages/support/test/Makefile \ - packages/framedata/Makefile \ - packages/framedata/doc/Makefile \ - packages/framedata/include/Makefile \ - packages/framedata/src/Makefile \ - packages/framedata/test/Makefile + lal.spec \ + lal.pc \ + lalmetaio.pc \ + lalsupport.pc \ + Makefile \ + debian/Makefile \ + doc/Makefile \ + doc/laldoc/Makefile \ + doc/autodoc/Makefile \ + include/Makefile \ + include/lal/Makefile \ + lib/Makefile \ + misc/Makefile \ + packages/Makefile \ + packages/std/Makefile \ + packages/std/doc/Makefile \ + packages/std/include/Makefile + packages/std/src/Makefile \ + packages/std/test/Makefile \ + packages/tools/Makefile \ + packages/tools/doc/Makefile \ + packages/tools/include/Makefile \ + packages/tools/src/Makefile \ + packages/tools/test/Makefile \ + packages/factories/Makefile \ + packages/factories/doc/Makefile \ + packages/factories/include/Makefile \ + packages/factories/src/Makefile \ + packages/factories/test/Makefile \ + packages/vectorops/Makefile \ + packages/vectorops/doc/Makefile \ + packages/vectorops/include/Makefile \ + packages/vectorops/src/Makefile \ + packages/vectorops/test/Makefile \ + packages/utilities/Makefile \ + packages/utilities/doc/Makefile \ + packages/utilities/include/Makefile \ + packages/utilities/src/Makefile \ + packages/utilities/test/Makefile \ + packages/stats/Makefile \ + packages/stats/doc/Makefile \ + packages/stats/include/Makefile \ + packages/stats/src/Makefile \ + packages/stats/test/Makefile \ + packages/inject/Makefile \ + packages/inject/doc/Makefile \ + packages/inject/include/Makefile \ + packages/inject/src/Makefile \ + packages/inject/test/Makefile \ + packages/date/Makefile \ + packages/date/doc/Makefile \ + packages/date/include/Makefile \ + packages/date/src/Makefile \ + packages/date/test/Makefile \ + packages/tdfilter/Makefile \ + packages/tdfilter/doc/Makefile \ + packages/tdfilter/include/Makefile \ + packages/tdfilter/src/Makefile \ + packages/tdfilter/test/Makefile \ + packages/window/Makefile \ + packages/window/doc/Makefile \ + packages/window/include/Makefile \ + packages/window/src/Makefile \ + packages/window/test/Makefile \ + packages/fft/Makefile \ + packages/fft/doc/Makefile \ + packages/fft/include/Makefile \ + packages/fft/src/Makefile \ + packages/fft/test/Makefile \ + packages/clremoval/Makefile \ + packages/clremoval/doc/Makefile \ + packages/clremoval/include/Makefile \ + packages/clremoval/src/Makefile \ + packages/clremoval/test/Makefile \ + packages/inspiral/Makefile \ + packages/inspiral/doc/Makefile \ + packages/inspiral/include/Makefile \ + packages/inspiral/src/Makefile \ + packages/inspiral/test/Makefile \ + packages/noisemodels/Makefile \ + packages/noisemodels/doc/Makefile \ + packages/noisemodels/include/Makefile \ + packages/noisemodels/src/Makefile \ + packages/noisemodels/test/Makefile \ + packages/bank/Makefile \ + packages/bank/doc/Makefile \ + packages/bank/include/Makefile \ + packages/bank/src/Makefile \ + packages/bank/test/Makefile \ + packages/ring/Makefile \ + packages/ring/doc/Makefile \ + packages/ring/include/Makefile \ + packages/ring/src/Makefile \ + packages/ring/test/Makefile \ + packages/findchirp/Makefile \ + packages/findchirp/doc/Makefile \ + packages/findchirp/include/Makefile \ + packages/findchirp/src/Makefile \ + packages/findchirp/test/Makefile \ + packages/pulsar/Makefile \ + packages/pulsar/doc/Makefile \ + packages/pulsar/include/Makefile \ + packages/pulsar/src/Makefile \ + packages/pulsar/test/Makefile \ + packages/houghpulsar/Makefile \ + packages/houghpulsar/doc/Makefile \ + packages/houghpulsar/include/Makefile \ + packages/houghpulsar/src/Makefile \ + packages/houghpulsar/test/Makefile \ + packages/burstsearch/Makefile \ + packages/burstsearch/doc/Makefile \ + packages/burstsearch/include/Makefile \ + packages/burstsearch/src/Makefile \ + packages/burstsearch/test/Makefile \ + packages/tracksearch/Makefile \ + packages/tracksearch/doc/Makefile \ + packages/tracksearch/include/Makefile \ + packages/tracksearch/src/Makefile \ + packages/tracksearch/test/Makefile \ + packages/timefreq/Makefile \ + packages/timefreq/doc/Makefile \ + packages/timefreq/include/Makefile \ + packages/timefreq/src/Makefile \ + packages/timefreq/test/Makefile \ + packages/support/Makefile \ + packages/support/doc/Makefile \ + packages/support/include/Makefile \ + packages/support/src/Makefile \ + packages/support/test/Makefile ]) +AC_CONFIG_FILES([lal-config],[chmod +x lal-config]) +AC_CONFIG_FILES([lib/git_version],[chmod +x lib/git_version]) AM_INIT_AUTOMAKE([]) AH_TOP([ #ifndef CONFIG_H__LAL #define CONFIG_H__LAL ]) -AH_TEMPLATE([LAL_SIZEOF_DOUBLE], [The number of bytes in a double.]) -AH_TEMPLATE([LAL_SIZEOF_FLOAT], [The number of bytes in a float.]) -AH_TEMPLATE([LAL_SIZEOF_INT], [The number of bytes in a int.]) -AH_TEMPLATE([LAL_SIZEOF_LONG], [The number of bytes in a long.]) -AH_TEMPLATE([LAL_SIZEOF_LONG_LONG], [The number of bytes in a long long.]) -AH_TEMPLATE([LAL_SIZEOF_SHORT], [The number of bytes in a short.]) +AH_TEMPLATE([LAL_SIZEOF_DOUBLE],[The number of bytes in a double.]) +AH_TEMPLATE([LAL_SIZEOF_FLOAT],[The number of bytes in a float.]) AH_BOTTOM([ #endif /* CONFIG_H__LAL */ ]) @@ -172,12 +155,11 @@ LAL_WITH_EXTRA_CFLAGS LAL_WITH_EXTRA_CPPFLAGS LAL_WITH_EXTRA_LDFLAGS LAL_WITH_EXTRA_LIBS -LAL_WITH_GCC_FLAGS LAL_ENABLE_INTELFFT -LAL_ENABLE_FRAME +LAL_WITH_CUDA +LAL_ENABLE_GCC_FLAGS LAL_ENABLE_METAIO -LAL_ENABLE_XML LAL_ENABLE_DEBUG LAL_ENABLE_MACROS @@ -194,18 +176,18 @@ lal_configure_date=`date +"%Y-%m-%dT%H:%M:%S%z"` # This sed script is more complex than it needs to be in order to prevent CVS # from corrupting it. lal_cvs_tag=`echo '$Name$' | sed -e 's? \\$\$??' -e 's?^\\$Name: ??'` -AC_DEFINE_UNQUOTED(LAL_VERSION, "$VERSION", [LAL Version]) -AC_DEFINE_UNQUOTED(LAL_VERSION_MAJOR, $lal_version_major, [LAL Version Major Number] ) -AC_DEFINE_UNQUOTED(LAL_VERSION_MINOR, $lal_version_minor, [LAL Version Minor Number] ) -AC_DEFINE_UNQUOTED(LAL_VERSION_MICRO, $lal_version_micro, [LAL Version Micro Number] ) -AC_DEFINE_UNQUOTED(LAL_CONFIGURE_ARGS, "$ac_configure_args", [LAL Configure Arguments]) -AC_DEFINE_UNQUOTED(LAL_CONFIGURE_DATE, "$lal_configure_date", [LAL Configure Date]) -AC_DEFINE_UNQUOTED(LAL_CVS_TAG, "$lal_cvs_tag", [LAL CVS Tag]) +AC_DEFINE_UNQUOTED([LAL_VERSION],["$VERSION"],[LAL Version]) +AC_DEFINE_UNQUOTED([LAL_VERSION_MAJOR],[$lal_version_major],[LAL Version Major Number]) +AC_DEFINE_UNQUOTED([LAL_VERSION_MINOR],[$lal_version_minor],[LAL Version Minor Number]) +AC_DEFINE_UNQUOTED([LAL_VERSION_MICRO],[$lal_version_micro],[LAL Version Micro Number]) +AC_DEFINE_UNQUOTED([LAL_CONFIGURE_ARGS],["$ac_configure_args"],[LAL Configure Arguments]) +AC_DEFINE_UNQUOTED([LAL_CONFIGURE_DATE],["$lal_configure_date"],[LAL Configure Date]) +AC_DEFINE_UNQUOTED([LAL_CVS_TAG],["$lal_cvs_tag"],[LAL CVS Tag]) test "$prefix"="NONE" && lal_prefix="$ac_default_prefix" || lal_prefix="$prefix" -AC_DEFINE_UNQUOTED(LAL_PREFIX, "$lal_prefix", [LAL Install Prefix]) +AC_DEFINE_UNQUOTED([LAL_PREFIX],["$lal_prefix"],[LAL Install Prefix]) lal_pthread_available="yes" -ACX_PTHREAD( , [lal_pthread_available="no"]) +ACX_PTHREAD(,[lal_pthread_available="no"]) if test "$lal_pthread_lock" = "true" ; then if test "$lal_pthread_available" = "yes" ; then LIBS="$PTHREAD_LIBS $LIBS" @@ -218,7 +200,7 @@ fi # check for c compiler m4_pattern_allow([AC_PROG_CC_C99]) -m4_ifdef([AC_PROG_CC_C99], [AC_PROG_CC_C99], [LAL_AC_PROG_CC_C99]) +m4_ifdef([AC_PROG_CC_C99],[AC_PROG_CC_C99],[LAL_AC_PROG_CC_C99]) # use silent build rules if appropriate m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],) @@ -229,15 +211,37 @@ AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AM_PROG_CC_C_O -AM_PROG_LIBTOOL +AC_PROG_LIBTOOL AM_PATH_PYTHON([2.4],,[AC_MSG_ERROR([Python-2.4, or higher, is required])]) -AC_CHECK_PROGS(M4, gm4 m4, m4) -AC_CHECK_PROGS(LATEX, pdflatex latex, echo) -AC_CHECK_PROGS(MKIND, makeindex, echo) -AC_CHECK_PROGS(DVIPS, dvips, echo) +AC_CHECK_PROGS([M4],[gm4 m4], m4) +AC_CHECK_PROGS([LATEX],[pdflatex latex],[echo]) +AC_CHECK_PROGS([MKIND],[makeindex],[echo]) +AC_CHECK_PROGS([DVIPS],[dvips],[echo]) + +# check for supported mac os x version +if test "x$build_vendor" = "xapple"; then + AC_CHECK_PROGS([SW_VERS],[sw_vers]) + if test "x$SW_VERS" != "x"; then + AC_MSG_CHECKING([Mac OS X version]) + MACOSX_VERSION=`$SW_VERS -productVersion` + AC_MSG_RESULT([$MACOSX_VERSION]) + fi + case "$MACOSX_VERSION" in + 10.0*|10.1*|10.2*|10.3*) + AC_MSG_ERROR([This version of Mac OS X is not supported]) + ;; + 10.4*|10.5*|10.6*) + # supported version + ;; + *) + AC_MSG_WARN([Unknown Mac OS X version]) + ;; + esac +fi + if test -z "$TEXFLAGS" then -AC_MSG_CHECKING(if $LATEX accepts --interaction=batchmode) +AC_MSG_CHECKING([if $LATEX accepts --interaction=batchmode]) cat > conflatextest.tex <<\CEOF \documentclass{article} \begin{document} @@ -246,156 +250,120 @@ CEOF if $LATEX conflatextest.tex --interaction=batchmode >/dev/null 2>&1 then TEXFLAGS="--interaction=batchmode" -AC_MSG_RESULT(yes) +AC_MSG_RESULT([yes]) else TEXFLAGS="" -AC_MSG_RESULT(no) +AC_MSG_RESULT([no]) fi rm -f conflatextest.* fi -AC_SUBST(TEXFLAGS) +AC_SUBST([TEXFLAGS]) dnl Set needed compiler flags AC_MSG_CHECKING([for additional compiler flags]) case "${host_os}" in solaris*) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L" AC_MSG_RESULT([-D_POSIX_C_SOURCE=200112L]);; - *) AC_MSG_RESULT(none);; + *) AC_MSG_RESULT([none]);; esac dnl Checks for libraries. LALSUPPORT_LIBADD="" lal_save_LIBS="$LIBS" -AC_CHECK_LIB(m, sin) -AC_CHECK_LIB(z, compress, [ LALSUPPORT_LIBADD="$LALSUPPORT_LIBADD -lz" ]) +AC_CHECK_LIB([m],[sin]) +AC_CHECK_LIB([z],[compress],[LALSUPPORT_LIBADD="$LALSUPPORT_LIBADD -lz"]) + dnl if solaris, check for sunmath library case "${host_os}" in - solaris*) AC_CHECK_LIB(sunmath, sincosp);; + solaris*) AC_CHECK_LIB([sunmath],[sincosp]);; esac -PKG_CHECK_MODULES(GSL, gsl, [ true ], [ false ]) + +PKG_CHECK_MODULES([GSL],[gsl],[true],[false]) CPPFLAGS="$CPPFLAGS $GSL_CFLAGS" LIBS="$LIBS $GSL_LIBS" -AC_CHECK_LIB(gslcblas, main) -AC_CHECK_LIB(gsl, gsl_strerror, , [AC_MSG_ERROR(could not find GSL library)]) -LAL_CHECK_GSL_VERSION(1.9) +AC_CHECK_LIB([gslcblas],[main]) +AC_CHECK_LIB([gsl],[gsl_strerror],,[AC_MSG_ERROR(could not find GSL library)]) +LAL_CHECK_GSL_VERSION([1.9]) dnl Checks for fft libraries. if test "${intelfft}" = "false" ; then fftw3="true" - PKG_CHECK_MODULES(FFTW3, fftw3 fftw3f, [ true ], [ false ]) + PKG_CHECK_MODULES([FFTW3],[fftw3 fftw3f],[true],[false]) CPPFLAGS="$CPPFLAGS $FFTW3_CFLAGS" LIBS="$LIBS $FFTW3_LIBS" - AC_CHECK_LIB(fftw3f, fftwf_execute_dft, , [AC_MSG_ERROR(could not find fftw3f library)], -lm) - AC_CHECK_LIB(fftw3, fftw_execute_dft, , [AC_MSG_ERROR(could not find fftw3 library)], -lm) + AC_CHECK_LIB([fftw3f],[fftwf_execute_dft],,[AC_MSG_ERROR(could not find fftw3f library)],[-lm]) + AC_CHECK_LIB([fftw3],[fftw_execute_dft],,[AC_MSG_ERROR(could not find fftw3 library)],[-lm]) else - AC_MSG_WARN(Using Intel FFT routines) + AC_MSG_WARN([Using Intel FFT routines]) if test "x${qthread}" = "xtrue" ; then LAL_INTEL_MKL_QTHREAD_WARNING else - AC_CHECK_LIB(pthread, pthread_create, , [AC_MSG_ERROR(could not find pthread library)]) + AC_CHECK_LIB([pthread],[pthread_create],,[AC_MSG_ERROR(could not find pthread library)]) fi - AC_CHECK_LIB(guide, __kmp_abort, , [AC_MSG_ERROR(could not find guide library included with Intel MKL)]) - AC_CHECK_HEADERS(pthread.h, , [AC_MSG_ERROR(could not find pthread header)]) + AC_CHECK_LIB([guide],[__kmp_abort],,[AC_MSG_ERROR(could not find guide library included with Intel MKL)]) + AC_CHECK_HEADERS([pthread.h],,[AC_MSG_ERROR(could not find pthread header)]) if test "${enable_static}" = "yes"; then if test "${enable_shared}" = "yes" ; then LAL_INTEL_FFT_LIBS_MSG_ERROR else - AC_CHECK_LIB(mkl_ia32, DftiCreateDescriptor, , [AC_MSG_ERROR(could not find the Intel FFT library)]) + AC_CHECK_LIB([mkl_ia32],[DftiCreateDescriptor],,[AC_MSG_ERROR(could not find the Intel FFT library)]) fi else - AC_CHECK_LIB(mkl, DftiCreateDescriptor, , [AC_MSG_ERROR(could not find the Intel FFT library)]) + AC_CHECK_LIB([mkl],[DftiCreateDescriptor],,[AC_MSG_ERROR(could not find the Intel FFT library)]) fi - AC_CHECK_HEADERS(mkl_fft.h, , [AC_MSG_ERROR(could not find Intel FFT header)]) + AC_CHECK_HEADERS([mkl_fft.h],,[AC_MSG_ERROR(could not find Intel FFT header)]) fi -dnl Checks for optional FrameL, metaio, and xml2 libraries. +dnl Checks for optional metaio. if test "${metaio}" = "true"; then - PKG_CHECK_MODULES(METAIO, libmetaio, [ true ], [ false ]) + PKG_CHECK_MODULES([METAIO],[libmetaio],[true],[false]) lal_pre_metaio_LIBS="$LIBS" LIBS="$LIBS $METAIO_LIBS" - AC_SEARCH_LIBS(MetaioOpen, metaio dataflow, , - [AC_MSG_WARN(disabling metaio support)] + AC_SEARCH_LIBS([MetaioOpen],[metaio],, + [AC_MSG_WARN([disabling metaio support])] [metaio="false"] [LIBS="$lal_pre_metaio_LIBS"]) fi -if test "${frame}" = "true"; then - PKG_CHECK_MODULES(FRAME, libframe, [ true ], [ false ]) - lal_pre_frame_LIBS="$LIBS" - LIBS="$LIBS $FRAME_LIBS" - AC_SEARCH_LIBS(FrLibIni, Frame, , - [AC_MSG_WARN(disabling frame library)] - [frame="false"] - [LIBS="$lal_pre_frame_LIBS"]) -fi -if test "${xml}" = "true"; then - PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= 2.6, [ true ], [ false ]) - lal_pre_xml2_LIBS="$LIBS" - LIBS="$LIBS $LIBXML2_LIBS" - AC_SEARCH_LIBS(xmlInitParser, xml2, , - [AC_MSG_WARN(disabling xml support)] - [xml="false"] - [LIBS="$lal_pre_xml2_LIBS"]) -fi dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(sys/time.h unistd.h getopt.h malloc.h zlib.h regex.h glob.h) +AC_CHECK_HEADERS([sys/time.h unistd.h getopt.h malloc.h zlib.h regex.h glob.h]) case "${host_os}" in - solaris*) AC_CHECK_HEADERS(sunmath.h);; + solaris*) AC_CHECK_HEADERS([sunmath.h]);; esac -AC_CHECK_HEADERS(gsl/gsl_errno.h, , [AC_MSG_ERROR(could not find gsl/gsl_errno.h)]) +AC_CHECK_HEADERS([gsl/gsl_errno.h],,[AC_MSG_ERROR([could not find gsl/gsl_errno.h])]) if test "${intelfft}" = "false" ; then - AC_CHECK_HEADERS(fftw3.h, , [AC_MSG_ERROR(could not find fftw3.h)]) + AC_CHECK_HEADERS([fftw3.h],,[AC_MSG_ERROR([could not find fftw3.h])]) fi -AC_CHECK_HEADER(stdint.h, , [AC_MSG_ERROR(could not find stdint.h)]) -AC_CHECK_HEADER(inttypes.h, , [AC_MSG_ERROR(could not find inttypes.h)]) +AC_CHECK_HEADER([stdint.h],,[AC_MSG_ERROR([could not find stdint.h])]) +AC_CHECK_HEADER([inttypes.h],,[AC_MSG_ERROR([could not find inttypes.h])]) -AC_MSG_CHECKING(for gethostname prototype in unistd.h) -AC_EGREP_HEADER(gethostname, unistd.h,AC_MSG_RESULT(yes) -AC_DEFINE(HAVE_GETHOSTNAME_PROTOTYPE, 1, [Define if gethostname prototype is in unistd.h]), AC_MSG_RESULT(no)) +AC_MSG_CHECKING([for gethostname prototype in unistd.h]) +AC_EGREP_HEADER([gethostname],[unistd.h],AC_MSG_RESULT([yes]) +AC_DEFINE([HAVE_GETHOSTNAME_PROTOTYPE],[1],[Define if gethostname prototype is in unistd.h]),AC_MSG_RESULT([no])) if test "${metaio}" = "true"; then lal_pre_metaio_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $METAIO_CFLAGS" - AC_CHECK_HEADERS(metaio.h, , - [AC_MSG_WARN(disabling metaio support)] + AC_CHECK_HEADERS([metaio.h],, + [AC_MSG_WARN([disabling metaio support])] [metaio="false"] [CPPFLAGS="$lal_pre_metaio_CPPFLAGS"]) fi -if test "${frame}" = "true"; then - lal_pre_frame_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $FRAME_CFLAGS" - AC_CHECK_HEADERS(FrameL.h, , - [AC_MSG_WARN(disabling frame library support)] - [frame="false"] - [CPPFLAGS="$lal_pre_frame_CPPFLAGS"]) -fi -if test "${xml}" = "true"; then - lal_pre_xml2_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $LIBXML2_CFLAGS" - AC_CHECK_HEADERS(libxml/xmlversion.h, , - [AC_MSG_WARN(disabling xml support)] - [xml="false"] - [CPPFLAGS="$lal_pre_xml2_CPPFLAGS"]) -fi if test "${lal_pthread_lock}" = "true"; then - AC_CHECK_HEADERS(pthread.h, break) + AC_CHECK_HEADERS([pthread.h],[break]) fi - dnl Define variables describing what was enabled. +if test "${cuda}" = "true"; then + AC_DEFINE([LAL_CUDA_ENABLED],[1],[Define if using cuda library]) +fi if test "${fftw3}" = "true"; then - AC_DEFINE(LAL_FFTW3_ENABLED, 1, [Define if using fftw3 library]) + AC_DEFINE([LAL_FFTW3_ENABLED],[1],[Define if using fftw3 library]) fi if test "${metaio}" = "true"; then - AC_DEFINE(LAL_METAIO_ENABLED, 1, [Define if using MetaIo library]) -fi -if test "${frame}" = "true"; then - AC_DEFINE(LAL_FRAME_ENABLED, 1, [Define if using frame library]) -fi -if test "${xml}" = "true"; then - AC_DEFINE(LAL_XML_ENABLED, 1, [Define if using xml2 library]) + AC_DEFINE([LAL_METAIO_ENABLED],[1],[Define if using MetaIo library]) fi @@ -414,26 +382,25 @@ AC_C_CONST AC_C_STRINGIZE AC_TYPE_SIZE_T AC_HEADER_TIME -LAL_CHECK_SIZEOF(float, 4) -LAL_CHECK_SIZEOF(double, 8) +LAL_CHECK_SIZEOF([float],[4]) +LAL_CHECK_SIZEOF([double],[8]) dnl Checks for library functions. -AC_CHECK_FUNCS(getopt) -AC_CHECK_FUNCS(getopt_long) +AC_CHECK_FUNCS([getopt]) +AC_CHECK_FUNCS([getopt_long]) AC_FUNC_VPRINTF -AC_CHECK_FUNCS(vsnprintf) -AC_CHECK_FUNCS(putenv) +AC_CHECK_FUNCS([vsnprintf]) +AC_CHECK_FUNCS([putenv]) dnl Set package documentation install path pkgdocdir="\${prefix}/share/doc/${PACKAGE}-${VERSION}" -AC_SUBST(pkgdocdir) +AC_SUBST([pkgdocdir]) dnl Setup automake conditionals -AM_CONDITIONAL(FRAME, test x$frame = xtrue) -AM_CONDITIONAL(METAIO, test x$metaio = xtrue) -AM_CONDITIONAL(XML, test x$xml = xtrue) -AM_CONDITIONAL(INTELFFT, test x$intelfft = xtrue) -AM_CONDITIONAL(QTHREAD, test x$qthread = xtrue) +AM_CONDITIONAL([METAIO],[test x$metaio = xtrue]) +AM_CONDITIONAL([INTELFFT],[test x$intelfft = xtrue]) +AM_CONDITIONAL([CUDA],[test x$cuda = xtrue]) +AM_CONDITIONAL([QTHREAD],[test x$qthread = xtrue]) dnl Configure subdirectory lalapps if present @@ -444,13 +411,6 @@ if test -d $srcdir/lalapps ; then LAL_CFLAGS=-I$lal_build_dir/include LALSUPPORT_LIBS=$lal_build_dir/packages/support/src/liblalsupport.la LALSUPPORT_CFLAGS=-I$lal_build_dir/include - if test x$frame = xtrue ; then - LALFRAME_LIBS=$lal_build_dir/packages/framedata/src/liblalframe.la - LALFRAME_CFLAGS=-I$lal_build_dir/include - else - LALFRAME_LIBS="" - LALFRAME_CFLAGS="" - fi if test x$metaio = xtrue ; then LALMETAIO_LIBS=$lal_build_dir/packages/support/src/liblalmetaio.la LALMETAIO_CFLAGS=-I$lal_build_dir/include @@ -458,42 +418,37 @@ if test -d $srcdir/lalapps ; then LALMETAIO_LIBS="" LALMETAIO_CFLAGS="" fi - if test x$xml = xtrue ; then - LALXML_LIBS=$lal_build_dir/packages/support/src/liblalxml.la - LALXML_CFLAGS=-I$lal_build_dir/include - else - LALXML_LIBS="" - LALXML_CFLAGS="" - fi - export LAL_BUILD LAL_LIBS LAL_CFLAGS LALSUPPORT_LIBS LALSUPPORT_CFLAGS LALFRAME_LIBS LALFRAME_CFLAGS LALMETAIO_LIBS LALMETAIO_CFLAGS LALXML_LIBS LALXML_CFLAGS - AC_CONFIG_SUBDIRS(lalapps) + export LAL_BUILD LAL_LIBS LAL_CFLAGS LALSUPPORT_LIBS LALSUPPORT_CFLAGS LALMETAIO_LIBS LALMETAIO_CFLAGS + AC_CONFIG_SUBDIRS([lalapps]) fi dnl Add gcc specific flags --- must be done at end or tests will break! if test "$GCC" = yes; then - CFLAGS="$CFLAGS $lal_gcc_flags" + CFLAGS="$CFLAGS $lal_gcc_flags -fno-strict-aliasing" + + # add mac os x specific flags + if test "x$MACOSX_VERSION" != "x"; then + CFLAGS="$CFLAGS -mmacosx-version-min=10.4" + fi fi + INCLUDEMKFILE=$srcdir/misc/include.mk DOCMKFILE=$srcdir/misc/doc.mk DVIMKFILE=$srcdir/misc/dvi.mk -AC_SUBST_FILE(INCLUDEMKFILE) -AC_SUBST_FILE(DOCMKFILE) -AC_SUBST_FILE(DVIMKFILE) -AC_CONFIG_COMMANDS([default-1],[[chmod +x lal-config]],[[]]) -AC_CONFIG_COMMANDS([default-2],[[chmod +x lib/git_version]],[[]]) +AC_SUBST_FILE([INCLUDEMKFILE]) +AC_SUBST_FILE([DOCMKFILE]) +AC_SUBST_FILE([DVIMKFILE]) AC_OUTPUT -frameenabled="`test x${frame} = xtrue && echo "ENABLED" || echo "DISABLED"`" metaioenabled="`test x${metaio} = xtrue && echo "ENABLED" || echo "DISABLED"`" -xmlenabled="`test x${xml} = xtrue && echo "ENABLED" || echo "DISABLED"`" +cudaenabled="`test x${cuda} = xtrue && echo "ENABLED" || echo "DISABLED"`" echo " ================================================================ LAL has now been successfully configured: - LAL Frame library support is $frameenabled LAL MetaIo library support is $metaioenabled - LAL XML library support is $xmlenabled + CUDA support is $cudaenabled Now run 'make' to build LAL and run 'make install' to install LAL diff --git a/lal/debian/changelog b/lal/debian/changelog index 7585b7dbd7d61b0d13f7ebb43142214a34867824..1e845b5703161fe55139f25ce294d22279b1f14d 100644 --- a/lal/debian/changelog +++ b/lal/debian/changelog @@ -1,3 +1,33 @@ +lal (6.4-1lscsoft1) unstable; urgency=low + + * LAL 6.4 + + -- Steffen Grunewald <steffen.grunewald@aei.mpg.de> Thu, 30 Sep 2009 10:00:00 +0200 + +lal (6.3.2-1lscsoft1) unstable; urgency=low + + * LAL 6.3.2 + + -- Adam Mercer <adam.mercer@ligo.org> Thu, 23 Oct 2009 10:59:32 -0600 + +lal (6.3.1-1lscsoft1) unstable; urgency=low + + * LAL 6.3.1 + + -- Adam Mercer <adam.mercer@ligo.org> Thu, 08 Oct 2009 17:50:41 +0200 + +lal (6.3-1lscsoft1) unstable; urgency=low + + * LAL 6.3 + + -- Steffen Grunewald <steffen.grunewald@aei.mpg.de> Thu, 03 Sep 2009 16:00:00 +0200 + +lal (6.2-1lscsoft1) unstable; urgency=low + + * LAL 6.2 + + -- Adam Mercer <adam.mercer@ligo.org> Thu, 6 Aug 2009 12:02:09 -0600 + lal (6.1.1-1lscsoft1) unstable; urgency=low * LAL 6.1.1 diff --git a/lal/debian/control b/lal/debian/control index 400a9afc882394bf54a3fe877495a41c0bef47a2..33a9e6dc98aab35e2293a3b35a0ef8eb143feba8 100644 --- a/lal/debian/control +++ b/lal/debian/control @@ -2,12 +2,12 @@ Source: lal Section: lscsoft Priority: optional Maintainer: Steffen Grunewald <steffen.grunewald@aei.mpg.de> -Build-Depends: debhelper (>= 5), autotools-dev, automake, m4, libgsl0-dev (>= 1.9), libframe-dev (>= 8.0), libmetaio-dev (>= 8.2), fftw3-dev, zlib1g-dev, libxml2-dev (>= 2.6), libcfitsio3-dev, git-core (>= 1.5), pkg-config, python2.4-dev, python2.5-dev +Build-Depends: debhelper (>= 5), autotools-dev, automake, m4, libgsl0-dev (>= 1.9), libframe-dev (>= 8.0), libmetaio-dev (>= 8.2), fftw3-dev, zlib1g-dev, libcfitsio3-dev, git-core (>= 1.5), pkg-config, python2.4-dev, python2.5-dev Standards-Version: 3.7.2 Package: lal Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libgsl0 (>= 1.9) | libgsl0ldbl (>= 1.10), libframe1 (>= 8.0), libmetaio1 (>= 8.2), fftw3, zlib1g, libxml2 (>= 2.6), python2.4 +Depends: ${shlibs:Depends}, ${misc:Depends}, libgsl0 (>= 1.9) | libgsl0ldbl (>= 1.10), libframe1 (>= 8.0), libmetaio1 (>= 8.2), fftw3, zlib1g, python2.4 Description: LSC Algorithm Library The LSC Algorithm Library for gravitational wave analysis. This package contains the shared-object libraries needed to run applications @@ -15,7 +15,7 @@ Description: LSC Algorithm Library Package: lal-dev Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libgsl0-dev (>= 1.9), libframe-dev (>= 8.0), libmetaio-dev (>= 8.2), fftw3-dev, zlib1g-dev, libxml2-dev (>= 2.6), python2.4 +Depends: ${shlibs:Depends}, ${misc:Depends}, libgsl0-dev (>= 1.9), libframe-dev (>= 8.0), libmetaio-dev (>= 8.2), fftw3-dev, zlib1g-dev, python2.4 Description: Files and documentation needed for compiling programs that use LAL The LSC Algorithm Library for gravitational wave analysis. This package contains files needed to build applications that use the LAL library diff --git a/lal/debian/rules b/lal/debian/rules index 6c93dd89e6db157bdfcab766a0a0e4321099c2e1..3038ed541b4e9c2101ce1b16fef3360e52b0712d 100755 --- a/lal/debian/rules +++ b/lal/debian/rules @@ -42,7 +42,8 @@ config.status : configure --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info \ --enable-nightly=no \ --enable-frame --enable-metaio \ - --disable-debug + --disable-debug \ + --disable-gcc-flags build : build-stamp diff --git a/lal/include/lal/LALConfig.h.in b/lal/include/lal/LALConfig.h.in index 4f353e92548297d24dc36abb78950b751059d419..15a459155d34812bfe200c02bf1cfe08f2a0fc50 100644 --- a/lal/include/lal/LALConfig.h.in +++ b/lal/include/lal/LALConfig.h.in @@ -59,9 +59,6 @@ /* Define if using fftw3 library */ #undef LAL_FFTW3_ENABLED -/* Define if using Frame library */ -#undef LAL_FRAME_ENABLED - /* Define if using MetaIo library */ #undef LAL_METAIO_ENABLED diff --git a/lal/lal.pc.in b/lal/lal.pc.in index 63777fa095357bb7de53faaa459a54835e4b0fff..c20b25b4980e544e7e6b6d675f0290379e4b8842 100644 --- a/lal/lal.pc.in +++ b/lal/lal.pc.in @@ -7,5 +7,5 @@ Name: LAL Description: LSC Algorithm Library Version: @VERSION@ Requires: fftw3 fftw3f gsl -Libs: -L${libdir} -llal -Cflags: -I${includedir} +Libs: -L${libdir} -llal @CUDA_LIBS@ +Cflags: -I${includedir} @CUDA_CFLAGS@ diff --git a/lal/lal.spec.in b/lal/lal.spec.in index c638a71246fdfdbfa8cc5240466796854d1bb0f5..418e18110213dc4820c3984022f5676077a90e4f 100644 --- a/lal/lal.spec.in +++ b/lal/lal.spec.in @@ -11,7 +11,7 @@ Source: %{name}-%{version}.tar.gz URL: http://www.lsc-group.phys.uwm.edu/lal Packager: Jolien Creighton <jolien@uwm.edu> BuildRoot: %{_tmppath}/%{name}-%{version}-root -Requires: python gsl fftw libframe libmetaio libxml2 +Requires: python gsl fftw libmetaio Prefix: %{_prefix} %description @@ -23,7 +23,7 @@ that use the LAL library. Summary: Files and documentation needed for compiling programs that use LAL Group: LAL Requires: %{name} = %{version} -Requires: gsl-devel libframe-devel libmetaio-devel libxml2-devel +Requires: gsl-devel libmetaio-devel %description devel The LSC Algorithm Library for gravitational wave data analysis. This package contains files needed build applications that use the LAL library @@ -35,7 +35,7 @@ as well as the documentation for the library. %build source /opt/lscsoft/lscsoft-user-env.sh nightly_version=@NIGHTLY_VERSION@ -%configure --enable-nightly=${nightly_version:-no} --disable-debug +%configure --enable-nightly=${nightly_version:-no} --disable-gcc-flags --disable-debug %{__make} %install diff --git a/lal/lib/LALVCSInfo.c b/lal/lib/LALVCSInfo.c index 750c4517d8e84d055e81e5553dd92bc22045bdb5..9d93880b39c7c671416ea620f61212044c745471 100644 --- a/lal/lib/LALVCSInfo.c +++ b/lal/lib/LALVCSInfo.c @@ -19,9 +19,12 @@ * Copyright (C) 2009 Adam Mercer */ +#include <string.h> +#include "config.h" #include <LALVCSInfo.h> /* global variables for vcs information */ +const char *lalVCSVersion = LAL_VERSION; const char *lalVCSId = LAL_VCS_ID; const char *lalVCSDate = LAL_VCS_DATE; const char *lalVCSBranch = LAL_VCS_BRANCH; @@ -31,10 +34,30 @@ const char *lalVCSCommitter = LAL_VCS_COMMITTER; const char *lalVCSStatus = LAL_VCS_STATUS; /* library vcs information structure */ -struct tagLALVCSInfo lalLibraryVCSInfo = {LAL_VCS_ID, \ +struct tagLALVCSInfo lalLibraryVCSInfo = {LAL_VERSION, LAL_VCS_ID, \ LAL_VCS_DATE, LAL_VCS_BRANCH, LAL_VCS_TAG, LAL_VCS_AUTHOR, \ LAL_VCS_COMMITTER, LAL_VCS_STATUS}; +/* fucntion to compare two LALVCSInfo structures */ +int XLALVCSInfoCompare(LALVCSInfo *header, LALVCSInfo *library) +{ + /* check for header/library mismatch */ + if (strcmp(header->version, library->version) || \ + strcmp(header->vcsId, library->vcsId) || \ + strcmp(header->vcsDate, library->vcsDate) || \ + strcmp(header->vcsBranch, library->vcsBranch) || \ + strcmp(header->vcsTag, library->vcsTag) || \ + strcmp(header->vcsAuthor, library->vcsAuthor) || \ + strcmp(header->vcsCommitter, library->vcsCommitter) || \ + strcmp(header->vcsStatus, library->vcsStatus)) + { + /* version mismatch */ + return 1; + } + + return 0; +} + /* * vim: tw=0 ts=2 et */ diff --git a/lal/lib/LALVCSInfo.h.in b/lal/lib/LALVCSInfo.h.in index 64fb78e7c2027407c8751aba6d9b63a31a2d5072..750dc642216d10a5376ba11e3cd6998cc071ff2d 100644 --- a/lal/lib/LALVCSInfo.h.in +++ b/lal/lib/LALVCSInfo.h.in @@ -22,6 +22,8 @@ #ifndef _LALVCSINFO_H #define _LALVCSINFO_H +#include <lal/LALConfig.h> + #ifdef __cplusplus extern "C" { #endif @@ -36,6 +38,7 @@ extern "C" { #define LAL_VCS_STATUS "$@STATUS@ $" /* global variables for vcs information, defined in LALVCSInfo.c */ +extern const char *lalVCSVersion; extern const char *lalVCSId; extern const char *lalVCSDate; extern const char *lalVCSBranch; @@ -47,6 +50,7 @@ extern const char *lalVCSStatus; /* define vcs information structure */ typedef struct tagLALVCSInfo { + const char *version; const char *vcsId; const char *vcsDate; const char *vcsBranch; @@ -58,10 +62,17 @@ typedef struct tagLALVCSInfo /* header and library vcs information structures */ extern struct tagLALVCSInfo lalLibraryVCSInfo; -static struct tagLALVCSInfo lalHeaderVCSInfo = {LAL_VCS_ID, \ +static const struct tagLALVCSInfo lalHeaderVCSInfo = {LAL_VERSION, LAL_VCS_ID, \ LAL_VCS_DATE, LAL_VCS_BRANCH, LAL_VCS_TAG, LAL_VCS_AUTHOR, \ LAL_VCS_COMMITTER, LAL_VCS_STATUS}; +/* + * function prototypes + */ + +/* function to compare two LALVCSInfo structures */ +int XLALVCSInfoCompare(LALVCSInfo *header, LALVCSInfo *library); + #ifdef __cplusplus } #endif diff --git a/lal/lib/Makefile.am b/lal/lib/Makefile.am index b031c382b0c828afffd8b968cedd846b5e10762e..0377fe6aa74178ea631fcd00e660b0f96c2b1bd1 100644 --- a/lal/lib/Makefile.am +++ b/lal/lib/Makefile.am @@ -39,7 +39,7 @@ LALBuildDate.c: $(liblal_la_DEPENDENCIES) @echo 'const char *lalBuildDate = "'`date +"%Y-%m-%dT%H:%M:%S%z"`'";' >$@ .vcsinfo: @touch .vcsinfo -LALVCSInfo.h: LALVCSInfo.h.in .vcsinfo +LALVCSInfo.h: LALVCSInfo.h.in .vcsinfo git_version @echo "creating LALVCSInfo.h" @buildd="`pwd`" && cd $(srcdir) && sourced="`pwd`" && cd $$buildd && \ ./git_version --sed $$sourced $$buildd diff --git a/lal/lib/git_version.in b/lal/lib/git_version.in index aa6bc95c28116d83d8502cb822a868b4916ea6be..d53a1b3b46afc7d50ccd5c8cf75c467d31539fb1 100644 --- a/lal/lib/git_version.in +++ b/lal/lib/git_version.in @@ -237,6 +237,17 @@ if git_ok: sed_cmd += ' -e "s/@AUTHOR@/%s/"' % info.author sed_cmd += ' -e "s/@COMMITTER@/%s/"' % info.committer sed_cmd += ' -e "s/@STATUS@/%s/"' % info.status + + # create tmp file + cmd = 'sed %s %s > %s' % (sed_cmd, infile, tmpfile) + p = subprocess.Popen(cmd, shell=True) + os.waitpid(p.pid, 0) + + # update LALVCSInfo.h, if appropriate + if (os.access(dstfile, os.F_OK) and not filecmp.cmp(dstfile, tmpfile)) or not os.access(dstfile, os.F_OK): + os.rename(tmpfile, dstfile) + else: + os.remove(tmpfile) else: # output version info print info.id @@ -247,17 +258,6 @@ if git_ok: print info.committer print info.status - # create tmp file - cmd = 'sed %s %s > %s' % (sed_cmd, infile, tmpfile) - p = subprocess.Popen(cmd, shell=True) - os.waitpid(p.pid, 0) - - # update LALVCSInfo.h, if appropriate - if (os.access(dstfile, os.F_OK) and not filecmp.cmp(dstfile, tmpfile)) or not os.access(dstfile, os.F_OK): - os.rename(tmpfile, dstfile) - else: - os.remove(tmpfile) - # exit sys.exit(0) diff --git a/lal/misc/include.mk b/lal/misc/include.mk index 2588b040036c5f56eab013f42e165838af0c9539..f32e92ab204e7ebce879db5c6f78b0b54b02071c 100644 --- a/lal/misc/include.mk +++ b/lal/misc/include.mk @@ -1,10 +1,10 @@ ## This file gets automatically appended to the end of the Makefile include-link: @for file in $(HEADERS) ; do \ - sourcedir=`cd $(srcdir) && pwd`; \ - targetdir=`cd $(top_builddir)/include/lal && pwd`; \ - if test ! -r $$targetdir/$$file ; then \ - rm -f $$targetdir/$$file; \ - $(LN_S) $$sourcedir/$$file $$targetdir; \ - fi; \ - done + sourcedir=`cd $(srcdir) && pwd`; \ + targetdir=`cd $(top_builddir)/include/lal && pwd`; \ + if test ! -r $$targetdir/$$file ; then \ + rm -f $$targetdir/$$file; \ + $(LN_S) $$sourcedir/$$file $$targetdir; \ + fi; \ + done diff --git a/lal/misc/lal.m4 b/lal/misc/lal.m4 index 55d21239a62ced6f0ea1aaf4102c6f86f3808a1e..dee30a3f048290af90ff8c1543e373d0e55bed27 100644 --- a/lal/misc/lal.m4 +++ b/lal/misc/lal.m4 @@ -1,20 +1,25 @@ dnl lal.m4 -AC_DEFUN([LAL_WITH_GCC_FLAGS], -[AC_ARG_WITH( - [gcc_flags], - AC_HELP_STRING([--with-gcc-flags],[turn on strict gcc warning flags]), - [ if test -n "${with_gcc_flags}" - then - lal_gcc_flags="-g3 -O4 -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common -Wnested-externs -Wno-format-zero-length" - case $host_cpu-$host_os in - *i386-darwin*) lal_gcc_flags="${lal_gcc_flags} -pedantic" ;; - *) lal_gcc_flags="${lal_gcc_flags} -pedantic-errors" ;; - esac - else - lal_gcc_flags="" - fi - ], [ lal_gcc_flags="" ] ) +AC_DEFUN([LAL_ENABLE_GCC_FLAGS], +[AC_ARG_ENABLE([gcc_flags], + AC_HELP_STRING([--enable-gcc-flags],[turn on strict gcc warning flags (default=yes)]), + [case "${enableval}" in + yes) DO_ENABLE_LAL_GCC_FLAGS;; + no) ;; + *) DO_ENABLE_LAL_GCC_FLAGS;; + esac ], + [ DO_ENABLE_LAL_GCC_FLAGS ] ) +]) + +AC_DEFUN([DO_ENABLE_LAL_GCC_FLAGS], +[ + lal_gcc_flags="-g3 -O4 -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common -Wnested-externs -Wno-format-zero-length" + if test "${cuda}" != "true"; then + case $host_cpu-$host_os in + *i386-darwin*) lal_gcc_flags="${lal_gcc_flags} -pedantic" ;; + *) lal_gcc_flags="${lal_gcc_flags} -pedantic-errors" ;; + esac + fi ]) AC_DEFUN([LAL_WITH_EXTRA_CPPFLAGS], @@ -83,22 +88,10 @@ AC_DEFUN([LAL_WITH_CC], ],) ]) -AC_DEFUN([LAL_ENABLE_FRAME], -[AC_ARG_ENABLE( - [frame], - AC_HELP_STRING([--enable-frame],[compile code that requires Frame library [default=yes]]), - [ case "${enableval}" in - yes) frame=true ;; - no) frame=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-frame) ;; - esac - ], [ frame=true ] ) -]) - AC_DEFUN([LAL_ENABLE_METAIO], [AC_ARG_ENABLE( [metaio], - AC_HELP_STRING([--enable-metaio],[compile code that requires metaio/dataflow library [default=yes]]), + AC_HELP_STRING([--enable-metaio],[compile code that requires metaio library [default=yes]]), [ case "${enableval}" in yes) metaio=true;; no) metaio=false ;; @@ -107,18 +100,6 @@ AC_DEFUN([LAL_ENABLE_METAIO], ], [ metaio=true ] ) ]) -AC_DEFUN([LAL_ENABLE_XML], -[AC_ARG_ENABLE( - [xml], - AC_HELP_STRING([--enable-xml],[compile code for XML I/O [default=no]]), - [ case "${enableval}" in - yes) xml=true;; - no) xml=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-xml) ;; - esac - ], [ xml=false ] ) -]) - AC_DEFUN([LAL_ENABLE_INTELFFT], [AC_ARG_ENABLE( [intelfft], @@ -132,6 +113,37 @@ AC_DEFUN([LAL_ENABLE_INTELFFT], ], [ intelfft=false ] ) ]) +AC_DEFUN([LAL_WITH_CUDA], +[AC_ARG_WITH( + [cuda], + AC_HELP_STRING([--with-cuda=PATH],[specify location of CUDA [/opt/cuda]]), + [ case "$with_cuda" in + no) + cuda=false + ;; + yes) + AC_MSG_WARN([No path for CUDA specifed, using /opt/cuda]) + cuda=true + CUDA_LIBS="-L/opt/cuda/lib -lcufft -lcudart" + CUDA_CFLAGS="-I/opt/cuda/include" + LIBS="$LIBS $CUDA_LIBS" + CFLAGS="$CFLAGS $CUDA_CFLAGS" + AC_SUBST(CUDA_LIBS) + AC_SUBST(CUDA_CFLAGS) + ;; + *) + AC_MSG_NOTICE([Using ${with_cuda} as CUDA path]) + cuda=true + CUDA_LIBS="-L${with_cuda}/lib -lcufft -lcudart" + CUDA_CFLAGS="-I${with_cuda}/include" + LIBS="$LIBS $CUDA_LIBS" + CFLAGS="$CFLAGS $CUDA_CFLAGS" + AC_SUBST(CUDA_LIBS) + AC_SUBST(CUDA_CFLAGS) + esac + ], [ cuda=false ]) +]) + AC_DEFUN([LAL_ENABLE_DEBUG], [AC_ARG_ENABLE( [debug], diff --git a/lal/misc/pkg.m4 b/lal/misc/pkg.m4 index 71981018fd8718f873c5b882c2050f8d0e135e01..a0b9cd45dfc3c16325a03686e39a081ce766c5b0 100644 --- a/lal/misc/pkg.m4 +++ b/lal/misc/pkg.m4 @@ -31,7 +31,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_ifval([$1], [$1], [0.9.0]) + _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) @@ -43,24 +43,61 @@ if test -n "$PKG_CONFIG"; then fi[]dnl ])# PKG_PROG_PKG_CONFIG +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], -[if test "x$ac_cv_env_[]$1[]_set" = "xset"; then - pkg_cv_[]$1=$ac_cv_env_[]$1[]_value -elif test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists "$3" >/dev/null 2>&1; then - pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` - else - pkg_failed=yes - fi -else - pkg_failed=untried +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + else + pkg_failed=untried fi[]dnl ])# _PKG_CONFIG +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl @@ -68,40 +105,51 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no -AC_CACHE_CHECK([for $1][_CFLAGS], [pkg_cv_][$1][_CFLAGS], - [_PKG_CONFIG([$1][_CFLAGS], [cflags], [[$2]])]) -AC_CACHE_CHECK([for $1][_LIBS], [pkg_cv_][$1][_LIBS], - [_PKG_CONFIG([$1][_LIBS], [libs], [[$2]])]) +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) if test $pkg_failed = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` + fi # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" 1>&AS_MESSAGE_LOG_FD + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD ifelse([$4], , [AC_MSG_ERROR(dnl -[[Package requirements ($2) were not met. +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -Alternatively you may set the $1_CFLAGS and $1_LIBS environment variables -to avoid the need to call pkg-config. See the pkg-config man page for -more details.]])], - [$4]) +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) elif test $pkg_failed = untried; then ifelse([$4], , [AC_MSG_FAILURE(dnl -[[The pkg-config script could not be found or is too old. Make sure it +[The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. -Alternatively you may set the $1_CFLAGS and $1_LIBS environment variables -to avoid the need to call pkg-config. See the pkg-config man page for -more details. +_PKG_TEXT -To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.]])], +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])], [$4]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) ifelse([$3], , :, [$3]) fi[]dnl ])# PKG_CHECK_MODULES diff --git a/lal/packages/Makefile.am b/lal/packages/Makefile.am index 7a1857bff35e7e3654110a4f26631355e96366f6..fa1dc2553bd952bed155a75ab149f06ddc5cb11a 100644 --- a/lal/packages/Makefile.am +++ b/lal/packages/Makefile.am @@ -22,9 +22,7 @@ SUBDIRS = \ burstsearch \ tracksearch \ timefreq \ - stochastic \ - support \ - framedata + support include-links: @set fnord $(MAKEFLAGS); amf=$$2; \ diff --git a/lal/packages/bank/src/LALInspiralCreateCoarseBank.c b/lal/packages/bank/src/LALInspiralCreateCoarseBank.c index 7cea8d76e7ceff2bfee4c173d1b9150051f5216b..d32e4e43cfe616992190ea635315fa1ccf66ebd6 100644 --- a/lal/packages/bank/src/LALInspiralCreateCoarseBank.c +++ b/lal/packages/bank/src/LALInspiralCreateCoarseBank.c @@ -599,6 +599,8 @@ LALInspiralCreatePNCoarseBank( break; case Psi0Psi3: + case PTFIntrinsic: + case PTFFull: ABORT( status, LALINSPIRALBANKH_ECHOICE, LALINSPIRALBANKH_MSGECHOICE ); break; } diff --git a/lal/packages/bank/src/LALInspiralHexagonalBank.c b/lal/packages/bank/src/LALInspiralHexagonalBank.c index fa81c9adc08d284da2807fc6023f2d8d988f6636..116c1aaa6fd6dfe142192c0be70299efe1ebbdf9 100644 --- a/lal/packages/bank/src/LALInspiralHexagonalBank.c +++ b/lal/packages/bank/src/LALInspiralHexagonalBank.c @@ -305,24 +305,28 @@ LALInspiralCreatePNCoarseBankHexa( case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch (cells[k].RectPosition[2]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch (cells[k].RectPosition[3]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch (cells[k].RectPosition[4]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } } @@ -823,30 +827,35 @@ LALSPAValidPosition(LALStatus *status, case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch ((*cell)[id1].RectPosition[2]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch ((*cell)[id1].RectPosition[3]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch ((*cell)[id1].RectPosition[4]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch ((*cell)[id1].RectPosition[0]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } (*cell)[id1].in = in; diff --git a/lal/packages/bank/src/LALInspiralHybridHexagonalBank.c b/lal/packages/bank/src/LALInspiralHybridHexagonalBank.c index 3ff1a7da281fe2b5f8d6a4a43b2b5528c245c6d6..b7aaccb834fe53d32f0f5e5861763db3f9480472 100644 --- a/lal/packages/bank/src/LALInspiralHybridHexagonalBank.c +++ b/lal/packages/bank/src/LALInspiralHybridHexagonalBank.c @@ -444,24 +444,28 @@ LALInspiralCreatePNCoarseBankHybridHexa( case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch (cells[k].RectPosition[2]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch (cells[k].RectPosition[3]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } switch (cells[k].RectPosition[4]){ case In: in +=1; break; case Below: below +=1; break; case Above: above +=1; break; case Out: out +=1; break; + case Edge: break; } } diff --git a/lal/packages/burstsearch/include/Skymap.h b/lal/packages/burstsearch/include/Skymap.h index 54d9e40ea66388308f9808e441092820f018ec10..d76d08e9ce579bc9ca91a8b01f54f3d239dea36e 100644 --- a/lal/packages/burstsearch/include/Skymap.h +++ b/lal/packages/burstsearch/include/Skymap.h @@ -29,168 +29,94 @@ extern "C" { #include <lal/LALRCSID.h> NRCSID(EPSEARCHH, "$Id$"); -/* - * Stores pre-computed properties of each sky direction - */ -typedef struct tagLALSkymapPixelType -{ - double area; - double direction[3]; - double f[3][2]; -} XLALSkymapPixelType; - -/* - * Stores pre-computed information for generating a sky map - */ -typedef struct tagXLALSkymapPlanType -{ - int sampleFrequency; - LALDetector site[3]; - double siteNormal[3]; - - /* physical delays between the detectors, - rounded to the nearest integer sample, - range over [-hl, +hl] and [-hv, +hv] */ - int hl, hv, lv; - - XLALSkymapPixelType* pixel; - int pixelCount; - - /* raster size */ - int m; - int n; -} XLALSkymapPlanType; - -/* - * Construct an analysis plan for a given frequency - */ -XLALSkymapPlanType* XLALSkymapConstructPlanMN(int sampleFrequency, int m, int n); - -/* - * Destroy an analysis plan - */ -void XLALSkymapDestroyPlan(XLALSkymapPlanType* plan); - -/* - * Produce a skymap according to a plan - */ -int XLALSkymapSignalHypothesisWithLimits(XLALSkymapPlanType* plan, double* p, double sigma, double w[3], int begin[3], int end[3], double** x, int *counts, int *modes, int delay_limits[8]); - -/* deprecated legacy interface */ -int XLALSkymapSignalHypothesis(XLALSkymapPlanType* plan, double* p, double sigma, double w[3], int begin[3], int end[3], double** x, int *counts, int *modes); -/* deprecated legacy interface */ -int XLALSkymapEllipticalHypothesis(XLALSkymapPlanType* plan, double* p, double sigma, double w[3], int begin[3], int end[3], double** x, int* bests); -/* deprecated legacy interface*/ -int XLALSkymapAnalyzeElliptical(double* p, XLALSkymapPlanType* plan, double sigma, double w[3], int n, double** x); +// Manipulate log-represented values without overflowing -/* - * Investigate the glitch hypothesis for model selection - */ - -int XLALSkymapGlitchHypothesis(XLALSkymapPlanType* plan, double* p, double sigma, double w[3], int begin[3], int end[3], double** x); - -/* - * Manipulate log-represented values together, preventing overflow - */ double XLALSkymapLogSumExp(double a, double b); -double XLALSkymapLogDifferenceExp(double a, double b); double XLALSkymapLogTotalExp(double* begin, double* end); -/* - * Add skymaps together, taking account of their log representation and valid - * pixels - */ -void XLALSkymapSum(XLALSkymapPlanType* plan, double* a, const double* b, const double* c); +// Lightweight coordinate transformations -/* - * Lightweight coordinate transformations - */ void XLALSkymapCartesianFromSpherical(double a[3], double b[2]); void XLALSkymapSphericalFromCartesian(double a[2], double b[3]); -void XLALSkymapDelaysFromDirection(XLALSkymapPlanType* plan, int delays[3], double direction[3]); -int XLALSkymapIndexFromDirection(XLALSkymapPlanType* plan, double direction[3]); - -/* - * Find the most plausible direction (the mode of the distribution) and return - * its theta and phi coordinates - */ -void XLALSkymapModeThetaPhi(XLALSkymapPlanType* plan, double* p, double thetaphi[2]); -/* - * Render the skymap from the internal format to a variety of map projections - */ -int XLALSkymapRender(double* q, XLALSkymapPlanType* plan, double* p); +// Cubic interpolation -/////////////////////////////////////////////////////////////////////////// +double XLALSkymapInterpolate(double t, double* x); -// VERSION 2 +// Largest network of interest (needed to allocate storage) +#define XLALSKYMAP_N 5 -typedef double XLALSkymap2SphericalPolarType[2]; +// Use detector names from lal/packages/tools/include/LALDetectors.h : +// LAL_TAMA_300_DETECTOR = 0 +// LAL_VIRGO_DETECTOR = 1 +// LAL_GEO_600_DETECTOR = 2 +// LAL_LHO_2K_DETECTOR = 3 +// LAL_LHO_4K_DETECTOR = 4 +// LAL_LLO_4K_DETECTOR = 5 -// Stores pre-computed properties of each sky direction - -typedef struct -{ - double f[3][2]; - int delay[3]; -} XLALSkymap2DirectionPropertiesType; - -// Stores pre-computed kernel information for each sky direction - -typedef struct -{ - double k[3][3]; - double logNormalization; -} XLALSkymap2KernelType; - -// Stores pre-computed information for generating a sky map +// Struct to store basic properties of the analysis: the sample rate, and +// the detectors involved (described by their LAL ID numbers) typedef struct { int sampleFrequency; - LALDetector site[3]; -} XLALSkymap2PlanType; - -// Initialize sample frequency and HLV site information + int n; + LALDetector site[XLALSKYMAP_N]; +} XLALSkymapPlanType; -void XLALSkymap2PlanConstruct( +void XLALSkymapPlanConstruct( int sampleFrequency, - XLALSkymap2PlanType* plan + int n, + int* detectors, + XLALSkymapPlanType* plan ); -// Turn directions into sample delays and antenna patterns +// Struct to store reuseable pre-computed quantities for a specific +// direction, set of detectors, and sample rate -void XLALSkymap2DirectionPropertiesConstruct( - XLALSkymap2PlanType* plan, - XLALSkymap2SphericalPolarType* direction, - XLALSkymap2DirectionPropertiesType* properties +typedef struct +{ + double f[XLALSKYMAP_N][2]; + double delay[XLALSKYMAP_N]; +} XLALSkymapDirectionPropertiesType; + +void XLALSkymapDirectionPropertiesConstruct( + XLALSkymapPlanType* plan, + double* direction, + XLALSkymapDirectionPropertiesType* properties ); -// Turn antenna patterns and waveform normalization into kernel matrix +// Struct to store reuseable pre-computed kernel for a specific direction, +// power spectra, and sample rate -void XLALSkymap2KernelConstruct( - XLALSkymap2DirectionPropertiesType* properties, - double wSw[3], - XLALSkymap2KernelType* kernel +typedef struct +{ + double k[XLALSKYMAP_N][XLALSKYMAP_N]; + double logNormalization; +} XLALSkymapKernelType; + +void XLALSkymapKernelConstruct( + XLALSkymapPlanType* plan, + XLALSkymapDirectionPropertiesType* properties, + double* wSw, + XLALSkymapKernelType* kernel ); -// Apply the kernel to some data +// Compute the Bayesian marginalization integral for the specified system -void XLALSkymap2Apply( - XLALSkymap2DirectionPropertiesType* properties, - XLALSkymap2KernelType* kernel, - double* xSw[3], - int tau, +void XLALSkymapApply( + XLALSkymapPlanType* plan, + XLALSkymapDirectionPropertiesType* properties, + XLALSkymapKernelType* kernel, + double** xSw, + double tau, double* logPosterior ); - - - #ifdef __cplusplus } #endif -#endif /* SKYMAP_H */ +#endif // SKYMAP_H diff --git a/lal/packages/burstsearch/src/Skymap.c b/lal/packages/burstsearch/src/Skymap.c index bd1264e3f0d32a98393ba1fc748cc9d4d71c88bc..5ae4ac27f8a64c26ba94552e0fad75bf277493f1 100644 --- a/lal/packages/burstsearch/src/Skymap.c +++ b/lal/packages/burstsearch/src/Skymap.c @@ -30,266 +30,105 @@ #include <lal/LIGOMetadataUtils.h> #include <lal/Skymap.h> -#define pi LAL_PI +// Convenience functions for tiny stack vectors and matrices -/* macro to "use" unused function parameters */ -#define UNUSED(expr) do { (void)(expr); } while(0) - -/* functions to handle vectors and matrices with dimensions that are - (a) small and - (b) known at compile time */ - -#define max(A,B) (((A) > (B)) ? (A) : (B)) - -static double sq(double a) -{ - return a * a; -} - -static void set2(double a[2], double v0, double v1) -{ - a[0] = v0; - a[1] = v1; -} - -static void set3(double a[3], double v0, double v1, double v2) -{ - a[0] = v0; - a[1] = v1; - a[2] = v2; -} - -static void add3(double a[3], double b[3], double c[3]) -{ - a[0] = b[0] + c[0]; - a[1] = b[1] + c[1]; - a[2] = b[2] + c[2]; -} - -static void sub3(double a[3], double b[3], double c[3]) -{ - a[0] = b[0] - c[0]; - a[1] = b[1] - c[1]; - a[2] = b[2] - c[2]; -} - -/* unused -static void mul3(double a[3], double b[3], double c) -{ - a[0] = b[0] * c; - a[1] = b[1] * c; - a[2] = b[2] * c; -} -*/ - -static void div2(double a[2], double b[2], double c) -{ - a[0] = b[0] / c; - a[1] = b[1] / c; -} - -static void div3(double a[3], double b[3], double c) -{ - a[0] = b[0] / c; - a[1] = b[1] / c; - a[2] = b[2] / c; -} +// Dot product of 3-vectors static double dot3(double a[3], double b[3]) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } -static double sqn3(double a[3]) -{ - return dot3(a, a); -} - -static double nrm3(double a[3]) -{ - return sqrt(sqn3(a)); -} - -static void normalize3(double a[3]) -{ - div3(a, a, nrm3(a)); -} +// Inverse of a 2x2 matrix -static void cross(double a[3], double b[3], double c[3]) +static void inv22(double a[2][2], double b[2][2]) { - a[0] = b[1] * c[2] - b[2] * c[1]; - a[1] = b[2] * c[0] - b[0] * c[2]; - a[2] = b[0] * c[1] - b[1] * c[0]; + double c = b[0][0] * b[1][1] - b[0][1] * b[1][0]; + a[0][0] = b[1][1] / c; + a[0][1] = -b[0][1] / c; + a[1][0] = -b[1][0] / c; + a[1][1] = b[0][0] / c; } -static void set32(double a[3][2], - double v00, double v01, - double v10, double v11, - double v20, double v21) -{ - set2(a[0], v00, v01); - set2(a[1], v10, v11); - set2(a[2], v20, v21); -} +// Determinant of a 2x2 matrix -static void div22(double a[2][2], double b[2][2], double c) +static double det22(double a[2][2]) { - div2(a[0], b[0], c); - div2(a[1], b[1], c); + return a[0][0] * a[1][1] - a[0][1] * a[1][0]; } -static void transpose32(double a[2][3], double b[3][2]) -{ - a[0][0] = b[0][0]; - a[0][1] = b[1][0]; - a[0][2] = b[2][0]; - a[1][0] = b[0][1]; - a[1][1] = b[1][1]; - a[1][2] = b[2][1]; -} +// Coordinate transformation theta,phi -> x,y,z -static void set22(double a[2][2], double a00, double a01, double a10, double a11) +void XLALSkymapCartesianFromSpherical(double a[3], double b[2]) { - a[0][0] = a00; - a[0][1] = a01; - a[1][0] = a10; - a[1][1] = a11; + a[0] = sin(b[0]) * cos(b[1]); + a[1] = sin(b[0]) * sin(b[1]); + a[2] = cos(b[0]); } -static void inv22(double a[2][2], double b[2][2]) -{ - a[0][0] = b[1][1]; - a[0][1] = -b[0][1]; - a[1][0] = -b[1][0]; - a[1][1] = b[0][0]; - div22(a, a, b[0][0] * b[1][1] - b[0][1] * b[1][0]); -} +// Coordinate transformation x,y,z -> theta,phi -static void mul322(double a[3][2], double b[3][2], double c[2][2]) -{ - int i, j, k; - for (i = 0; i != 3; ++i) - for (k = 0; k != 2; ++k) - { - a[i][k] = 0; - for (j = 0; j != 2; ++j) - a[i][k] += b[i][j] * c[j][k]; - } -} - -static void mul323(double a[3][3], double b[3][2], double c[2][3]) +void XLALSkymapSphericalFromCartesian(double a[2], double b[3]) { - int i, j, k; - for (i = 0; i != 3; ++i) - for (k = 0; k != 3; ++k) - { - a[i][k] = 0; - for (j = 0; j != 2; ++j) - a[i][k] += b[i][j] * c[j][k]; - } + a[0] = acos(b[2]); + a[1] = atan2(b[1], b[0]); } -static void mul222(double a[2][2], double b[2][2], double c[2][2]) -{ - int i, j, k; - for (i = 0; i != 2; ++i) - for (k = 0; k != 2; ++k) - { - a[i][k] = 0; - for (j = 0; j != 2; ++j) - a[i][k] += b[i][j] * c[j][k]; - } -} +// Time of arrival at a detector, relative to center of Earth, for signals +// from a given (unit) direction -static void mul122(double a[1][2], double b[1][2], double c[2][2]) +static double site_time(LALDetector* site, double direction[3]) { - int i, j, k; - for (i = 0; i != 1; ++i) - for (k = 0; k != 2; ++k) - { - a[i][k] = 0; - for (j = 0; j != 2; ++j) - a[i][k] += b[i][j] * c[j][k]; - } + return -dot3(site->location, direction) / LAL_C_SI; } -static void mul121(double a[1][1], double b[1][2], double c[2][1]) -{ - int i, j, k; - for (i = 0; i != 1; ++i) - for (k = 0; k != 1; ++k) - { - a[i][k] = 0; - for (j = 0; j != 2; ++j) - a[i][k] += b[i][j] * c[j][k]; - } -} +// Plus and cross polarization response of a detector for signals from a +// given direction -static double det22(double a[2][2]) +static void site_response(double f[2], LALDetector* site, double direction[3]) { - return a[0][0] * a[1][1] - a[0][1] * a[1][0]; + double thetaphi[2]; + XLALSkymapSphericalFromCartesian(thetaphi, direction); + XLALComputeDetAMResponse(&f[0], &f[1], site->response, thetaphi[1], LAL_PI_2 - thetaphi[0], 0, 0); } -/* log functions - * - * These functions assist in working with values that might overflow if we - * ever explicitly constructed their exponentials. - */ - -/* - * FIXME: when the C99 transition is complete, remove log1p declaration - */ - -/* - * declare the C99 function log1p to suppress warning - * - * log1p(x) = log(1 + x), but is more accurate for |x| << 1 - */ -double log1p(double x); - -/* - * XLALSkymapLogSumExp(a, b) computes log(exp(a) + exp(b)) but will not - * overflow for a or b > ~300 - * - * For a > b, we use the identity - * - * log(exp(a) + exp(b) - * = log(exp(a) * (1 + exp(b) / exp(a))) - * = a + log(1 + exp(b - a)) - * = a + log1p(exp(b - a)) - * - * where b - a < 0 and exp(b - a) cannot overflow (though it may - * underflow). - * - * And for a < b - * - * log(exp(a) + exp(b)) - * = log(exp(b) * (exp(a) / exp(b) + 1)) - * = b + log(exp(a - b) + 1) - * = b + log1p(exp(a - b)) - * - * If neither a < b nor a > b, we either have equality or both values - * are (the same) plus or minus infinity. Forming (a - b) in the case of - * infinities results in a NaN, so we must use a third expression - * - * log(exp(a) + exp(b)) - * = log(exp(a) + exp(a)) - * = log(2 * exp(a)) - * = log(2) + a - */ +// XLALSkymapLogSumExp(a, b) computes log(exp(a) + exp(b)) but will not +// overflow for a or b > ~300 +// +// For a > b, we use the identity +// +// log(exp(a) + exp(b) +// = log(exp(a) * (1 + exp(b) / exp(a))) +// = a + log(1 + exp(b - a)) +// = a + log1p(exp(b - a)) +// +// where b - a < 0 and exp(b - a) cannot overflow (though it may +// underflow). +// +// And for a < b +// +// log(exp(a) + exp(b)) +// = log(exp(b) * (exp(a) / exp(b) + 1)) +// = b + log(exp(a - b) + 1) +// = b + log1p(exp(a - b)) +// +// If neither a < b nor a > b, we either have equality or both values +// are (the same) plus or minus infinity. Forming (a - b) in the case of +// infinities results in a NaN, so we must use a third expression +// +// log(exp(a) + exp(b)) +// = log(exp(a) + exp(a)) +// = log(2 * exp(a)) +// = log(2) + a double XLALSkymapLogSumExp(double a, double b) { - return - (a < b) ? (b + log1p(exp(a - b))) : ( - (b < a) ? (a + log1p(exp(b - a))) : (a + log(2)) - ); + return (a < b) ? + (b + log1p(exp(a - b))) : + ((b < a) ? (a + log1p(exp(b - a))) : (a + log(2))); } -double XLALSkymapLogDifferenceExp(double a, double b) -{ - return a + log(1.0 - exp(b - a)); -} +// Find the maximum of a sequence of doubles and return a pointer to it static double* findmax(double* begin, double* end) { @@ -297,1172 +136,239 @@ static double* findmax(double* begin, double* end) double* m; m = begin; for (p = begin; p != end; ++p) - if (*m < *p) - m = p; + { + if (*m < *p) + { + m = p; + } + } return m; } +// Find log sum_i exp(a[i])) given max_i a[i], using the same technique as +// XLALSkymapLogSumExp to accumulate the result without overflowing for +// a[i] > ~300 + static double logtotalexpwithmax(double* begin, double* end, double m) { double t; double* p; t = 0; for (p = begin; p != end; ++p) - t += exp(*p - m); + { + t += exp(*p - m); + } return m + log(t); } +// Find log sum_i exp(a[i]) using findmax and logtotalexpwithmax + double XLALSkymapLogTotalExp(double* begin, double* end) { return logtotalexpwithmax(begin, end, *findmax(begin, end)); } -/* coordinate transformations */ - -void XLALSkymapCartesianFromSpherical(double a[3], double b[2]) -{ - set3(a, sin(b[0]) * cos(b[1]), sin(b[0]) * sin(b[1]), cos(b[0])); -} - -void XLALSkymapSphericalFromCartesian(double a[2], double b[3]) -{ - set2(a, acos(b[2]), atan2(b[1], b[0])); -} - -/* geometrical properties of an interferometer site */ - -static double site_time(LALDetector* site, double direction[3]) -{ - return -dot3(site->location, direction) / LAL_C_SI; -} - -static void site_response(double f[2], LALDetector* site, double direction[3]) -{ - double thetaphi[2]; - XLALSkymapSphericalFromCartesian(thetaphi, direction); - XLALComputeDetAMResponse(&f[0], &f[1], site->response, thetaphi[1], LAL_PI_2 - thetaphi[0], 0, 0); -} - -static void construct_hlv(LALDetector site[3]) -{ - site[0] = lalCachedDetectors[LAL_LHO_4K_DETECTOR]; - site[1] = lalCachedDetectors[LAL_LLO_4K_DETECTOR]; - site[2] = lalCachedDetectors[LAL_VIRGO_DETECTOR]; -} - -/* properties of each pixel in the tiling */ - -static void construct_pixel(XLALSkymapPixelType* pixel) -{ - pixel->area = 0; - set3(pixel->direction, 0, 0, 0); -} - -/* properties of a network and a sample rate */ - -/* - * These functions convert between integer time delays that index a - * conceptual three-dimensional array, and a linear index corresponding - * to how the array is actually packed in memory - * - * For a simple L x M x N array, the indices (i, j, k) map to a linear - index - * - * p = (M * N) * i + N * j + k - * - * To store pixels, we have an array with - * - * L = 2 (hemispheres) - * M = 2 * plan->hv + 1 (delays from -plan->hv to +plan->hv) - * N = 2 * plan->hl + 1 (delays from -plan->hl to +plan->hl) - * - * and indices that are offset delays (so that they are >= 0) - * - * i = hemisphere - * j = hv + plan->hv - * k = hl + plan->hl - * - */ - -static int index_from_delays(XLALSkymapPlanType* plan, int hl, int hv, int hemisphere) -{ - return - (hl + plan->hl) + - (hv + plan->hv) * (plan->hl * 2 + 1) + - (hemisphere ) * (plan->hl * 2 + 1) * (plan->hv * 2 + 1); -} - -static void delays_from_index(XLALSkymapPlanType *plan, int lal_index, int delays[3]) -{ - delays[2] = lal_index / ((plan->hl * 2 + 1) * (plan->hv * 2 + 1)); - lal_index %= ((plan->hl * 2 + 1) * (plan->hv * 2 + 1)); - delays[1] = (lal_index / (plan->hl * 2 + 1)) - plan->hv; - delays[0] = (lal_index % (plan->hl * 2 + 1)) - plan->hl; -} - -/* -static int index_from_times(XLALSkymapPlanType* plan, int times[3], int hemisphere) -{ - return index_from_delays(plan, times[1] - times[0], times[2] - times[0], hemisphere); -} -*/ - -void XLALSkymapDelaysFromDirection(XLALSkymapPlanType* plan, int delays[3], double direction[3]) -{ - /* compute the delays rounded to the nearest sample */ - delays[0] = (int) floor(( - site_time(&plan->site[1], direction) - - site_time(&plan->site[0], direction)) * - plan->sampleFrequency + 0.5); - delays[1] = (int) floor(( - site_time(&plan->site[2], direction) - - site_time(&plan->site[0], direction)) * - plan->sampleFrequency + 0.5); - delays[2] = dot3(plan->siteNormal, direction) < 0 ? 0 : 1; -} - -int XLALSkymapIndexFromDirection(XLALSkymapPlanType* plan, double direction[3]) -{ - int i[3]; - XLALSkymapDelaysFromDirection(plan, i, direction); - return index_from_delays(plan, i[0], i[1], i[2]); -} +// To cubic interpolate +// x(0 <= t <= 1) +// from +// x[-1], x[0], x[1], x[2] +// we compute +// w_t[-1], w_t[0], w_t[1], w_t[2] +// such that +// x(t) = sum_i x[i] w_t[i] -XLALSkymapPlanType* XLALSkymapConstructPlanMN(int sampleFrequency, int m, int n) +double XLALSkymapInterpolate(double t, double* x) { - static const char func[] = "XLALSkymapConstructPlanMN"; - XLALSkymapPlanType* plan; - - if (sampleFrequency <= 0) - { - XLALPrintError("%s(): invalid sample frequency %d\n", func, sampleFrequency); - XLAL_ERROR_NULL(func, XLAL_EINVAL); - } + int whole = floor(t); + t -= whole; - if(m <= 0 || n <= 0) - { - XLALPrintError("%s(): invalid raster size %d x %d\n", func, m, n); - XLAL_ERROR_NULL(func, XLAL_EINVAL); - } + double h[4], w[4]; - plan = (XLALSkymapPlanType*) XLALMalloc(sizeof(*plan)); + // Hermite basis functions at t - /* possible runtime error */ - if (!plan) - { - XLAL_ERROR_NULL(func, XLAL_EFUNC); - } + h[0] = (1. + 2. * t) * (1. - t) * (1. - t); + h[1] = t * (1. - t) * (1. - t); + h[2] = t * t * (3. - 2. * t); + h[3] = t * t * (t - 1.); - /* define the sample frequency */ - plan->sampleFrequency = sampleFrequency; - plan->m = m; - plan->n = n; + // Weights - /* set up the hanford-livingston-virgo network */ - construct_hlv(plan->site); - - { /* compute the baselines */ - double v_hl[3], v_hv[3], v_lv[3]; - sub3(v_hl, plan->site[1].location, plan->site[0].location); - sub3(v_hv, plan->site[2].location, plan->site[0].location); - sub3(v_lv, plan->site[2].location, plan->site[1].location); - div3(v_hl, v_hl, LAL_C_SI); - div3(v_hv, v_hv, LAL_C_SI); - div3(v_lv, v_lv, LAL_C_SI); - cross(plan->siteNormal, v_hl, v_hv); - /* compute the maximum delay rounded to nearest sample */ - plan->hl = (int) floor(nrm3(v_hl) * plan->sampleFrequency + 0.5); - plan->hv = (int) floor(nrm3(v_hv) * plan->sampleFrequency + 0.5); - plan->lv = (int) floor(nrm3(v_lv) * plan->sampleFrequency + 0.5); - } + w[0] = -0.5 * h[1]; + w[1] = h[0] - 0.5 * h[3]; + w[2] = h[2] + 0.5 * h[1]; + w[3] = 0.5 * h[3]; - plan->pixelCount = (plan->hl * 2 + 1) * (plan->hv * 2 + 1) * 2; - plan->pixel = (XLALSkymapPixelType*) XLALMalloc(sizeof(*plan->pixel) * plan->pixelCount); + double y = 0; + int i; - /* possible runtime error */ - if (!plan->pixel) + for (i = 0; i != 4; ++i) { - XLALFree(plan); - XLAL_ERROR_NULL(func, XLAL_EFUNC); + y += x[whole + i - 1] * w[i]; } - /* compute the pixel properties */ - { - int i, j; - double area = 0; - - /* initialize the pixels */ - for (i = 0; i != plan->pixelCount; ++i) - { - construct_pixel(&plan->pixel[i]); - } + return y; - /* scan over the sky */ - for (i = 0; i != m; ++i) - { - for (j = 0; j != n; ++j) - { - double direction[3]; - int k; - /* compute theta and phi */ - double thetaphi[2]; - thetaphi[0] = acos(1. - (i + 0.5) * (2. / plan->m)); - thetaphi[1] = (j + 0.5) * (2. * pi / plan->n); - /* compute direction */ - XLALSkymapCartesianFromSpherical(direction, thetaphi); - /* determine the corresponding pixel */ - k = XLALSkymapIndexFromDirection(plan, direction); - /* increase the total area */ - area += 1.0; - /* increase the pixel area */ - plan->pixel[k].area += 1.0; - /* accumulate the direction */ - add3(plan->pixel[k].direction, plan->pixel[k].direction, direction); - } - } - /* compute the relative area, average direction, and antenna pattern for each physical pixel */ - for (i = 0; i != plan->pixelCount; ++i) - { /* is the direction physical? */ - if (plan->pixel[i].area > 0) - { /* compute the average direction */ - normalize3(plan->pixel[i].direction); - /* normalize the area */ - plan->pixel[i].area /= area; - for (j = 0; j != 3; ++j) - { - site_response(plan->pixel[i].f[j], &plan->site[j], plan->pixel[i].direction); - } - } - else - { - /* zero out the unused memory */ - set32(plan->pixel[i].f, 0, 0, 0, 0, 0, 0); - } - } - } - - return plan; } -void XLALSkymapDestroyPlan(XLALSkymapPlanType* plan) -{ - if (plan) - XLALFree(plan->pixel); - XLALFree(plan); -} - -static void compute_kernel(XLALSkymapPlanType* plan, int lal_index, double sigma, double w[3], double kernel[3][3], double* log_normalization) -{ - double f[2][3]; - double wfsfw[2][2] = {{0, 0}, {0, 0}}; - double wfsfwa[2][2]; - double iwfsfwa[2][2]; - double fiwfsfwa[3][2]; - double wfsfwiwfsfwa[2][2]; - int i, j; - - transpose32(f, plan->pixel[lal_index].f); - for (i = 0; i != 3; ++i) - { - wfsfw[0][0] += sq(f[0][i] * w[i]); - wfsfw[0][1] += f[0][i] * f[1][i] * sq(w[i]); - wfsfw[1][1] += sq(f[1][i] * w[i]); - } - wfsfw[1][0] = wfsfw[0][1]; - - set22(wfsfwa, wfsfw[0][0] + 1/sq(sigma), wfsfw[0][1] , - wfsfw[1][0] , wfsfw[1][1] + 1/sq(sigma)); - inv22(iwfsfwa, wfsfwa); - mul322(fiwfsfwa, plan->pixel[lal_index].f, iwfsfwa); - mul323(kernel, fiwfsfwa, f); - for (i = 0; i != 3; ++i) - { - for (j = 0; j != 3; ++j) - { - kernel[i][j] *= w[i] * w[j]; - } - } +// Construct an XLALSkymap2PlanType in the given memory from +// sample frequency of matched filter timeseries +// number of detectors +// list of detector LAL ID numbers - mul222(wfsfwiwfsfwa, wfsfw, iwfsfwa); - wfsfwiwfsfwa[0][0] -= 1; - wfsfwiwfsfwa[1][1] -= 1; - *log_normalization = log(det22(wfsfwiwfsfwa)) * 0.5; -} - -static void compute_kernel2(XLALSkymapPlanType* plan, int lal_index, double sigma, double w[3], double kernel[2][2], double* log_normalization, double** x) +void XLALSkymapPlanConstruct(int sampleFrequency, int n, int* detectors, XLALSkymapPlanType* plan) { - double f[2][2]; - double wfsfw[2][2] = {{0, 0}, {0, 0}}; - double wfsfwa[2][2]; - double iwfsfwa[2][2]; - double fiwfsfwa[2][2]; - double wfsfwiwfsfwa[2][2]; - int i, j; - double w2[2]; - - /* transpose32(f, plan->pixel[lal_index].f); */ - if (x[0]) - { - /* we have hanford data */ - f[0][0] = plan->pixel[lal_index].f[0][0]; - f[1][0] = plan->pixel[lal_index].f[0][1]; - w2[0] = w[0]; - if (x[1]) - { - /* we have livingston data */ - f[0][1] = plan->pixel[lal_index].f[1][0]; - f[1][1] = plan->pixel[lal_index].f[1][1]; - w2[1] = w[1]; - } - else - { - /* we must have virgo data */ - f[0][1] = plan->pixel[lal_index].f[2][0]; - f[1][1] = plan->pixel[lal_index].f[2][1]; - w2[1] = w[2]; - } - } - else - { - /* we must have livingston and virgo data */ - f[0][0] = plan->pixel[lal_index].f[1][0]; - f[1][0] = plan->pixel[lal_index].f[1][1]; - w2[0] = w[1]; - f[0][1] = plan->pixel[lal_index].f[2][0]; - f[1][1] = plan->pixel[lal_index].f[2][1]; - w2[1] = w[2]; - } + int i; - for (i = 0; i != 2; ++i) - { - wfsfw[0][0] += sq(f[0][i] * w2[i]); - wfsfw[0][1] += f[0][i] * f[1][i] * sq(w2[i]); - wfsfw[1][1] += sq(f[1][i] * w2[i]); - } - wfsfw[1][0] = wfsfw[0][1]; + plan->sampleFrequency = sampleFrequency; + plan->n = n; - set22(wfsfwa, wfsfw[0][0] + 1/sq(sigma), wfsfw[0][1] , - wfsfw[1][0] , wfsfw[1][1] + 1/sq(sigma)); - inv22(iwfsfwa, wfsfwa); - mul222(fiwfsfwa, plan->pixel[lal_index].f, iwfsfwa); - mul222(kernel, fiwfsfwa, f); - for (i = 0; i != 2; ++i) + for (i = 0; i != plan->n; ++i) { - for (j = 0; j != 2; ++j) - { - kernel[i][j] *= w2[i] * w2[j]; - } + plan->site[i] = lalCachedDetectors[detectors[i]]; } - mul222(wfsfwiwfsfwa, wfsfw, iwfsfwa); - wfsfwiwfsfwa[0][0] -= 1; - wfsfwiwfsfwa[1][1] -= 1; - *log_normalization = log(det22(wfsfwiwfsfwa)) * 0.5; } -static void compute_kernel1(XLALSkymapPlanType* plan, int lal_index, double sigma, double w[3], double kernel[1][1], double* log_normalization, double** x) -{ - double f[2][1]; - double wfsfw[2][2] = {{0, 0}, {0, 0}}; - double wfsfwa[2][2]; - double iwfsfwa[2][2]; - double fiwfsfwa[1][2]; - double wfsfwiwfsfwa[2][2]; - int i; - - if (x[0]) - { - i = 0; - } - else - { - if (x[1]) - { - i = 1; - } - else - { - i = 2; - } - } - - /* transpose32(f, plan->pixel[lal_index].f); */ - f[0][0] = plan->pixel[lal_index].f[i][0]; - f[1][0] = plan->pixel[lal_index].f[i][1]; - - wfsfw[0][0] += sq(f[0][0] * w[i]); - wfsfw[0][1] += f[0][0] * f[1][0] * sq(w[i]); - wfsfw[1][1] += sq(f[1][0] * w[i]); - - wfsfw[1][0] = wfsfw[0][1]; +// Construct an XLALSkymap2DirectionProperties object in the given memory +// from +// a plan +// a theta, phi tuple - set22(wfsfwa, wfsfw[0][0] + 1/sq(sigma), wfsfw[0][1] , - wfsfw[1][0] , wfsfw[1][1] + 1/sq(sigma)); - inv22(iwfsfwa, wfsfwa); - mul122(fiwfsfwa, plan->pixel[lal_index].f, iwfsfwa); - mul121(kernel, fiwfsfwa, f); - kernel[0][0] *= w[i] * w[i]; - - mul222(wfsfwiwfsfwa, wfsfw, iwfsfwa); - wfsfwiwfsfwa[0][0] -= 1; - wfsfwiwfsfwa[1][1] -= 1; - *log_normalization = log(det22(wfsfwiwfsfwa)) * 0.5; -} - -int XLALSkymapGlitchHypothesis(XLALSkymapPlanType* plan, double *p, double sigma, double w[3], int begin[3], int end[3], double** x) +void XLALSkymapDirectionPropertiesConstruct( + XLALSkymapPlanType* plan, + double* directions, + XLALSkymapDirectionPropertiesType* properties + ) { - /* static const char func[] = "XLALSkymapGlitchHypothesis"; */ - double* buffer; - int i; - - /* plan is unused in this function */ - UNUSED(plan); + double x[3]; + int j; - /* allocate working memory */ - buffer = (double*) XLALMalloc(sizeof(double)* max(max(end[0], end[1]), end[2])); + // Convert theta, phi direction to cartesian + XLALSkymapCartesianFromSpherical(x, directions); - /* analyze each detector individually */ - for (i = 0; i != 3; ++i) + for (j = 0; j != plan->n; ++j) { - /* was data supplied for this detector? */ - if (x[i]) - { - int t; - double k; - double *m; - /* compute the kernel */ - k = 0.5 / (sq(w[i]) + 1.0 / sq(sigma)); - /* loop over all times */ - for (t = begin[i]; t != end[i]; ++t) - { - buffer[t] = k * (sq(x[i][t]) + sq(x[i + 3][t])); - } - /* find the maximum to prevent over or underflow when accumulating exponentials */ - m = findmax(buffer + begin[i], buffer + end[i]); - /* marginalize over time */ - p[i] = logtotalexpwithmax(buffer + begin[i], buffer + end[i], *m); - /* apply normalization */ - p[i] -= log(sq(sigma) * sq(w[i]) + 1.0); - } - else - { - /* if there is no data we draw no conclusion */ - p[i] = 0.0; - } + // Delay (in seconds) + properties->delay[j] = site_time(plan->site + j, x); + // Plus and cross polarization responses + site_response(properties->f[j], plan->site + j, x); } - XLALFree(buffer); - return 0; } -/* a new interface is required that instead produces a per-tile product */ - -/* return not a skymap but a grid of odds ratios for each direction individually */ -/* to make a skymap requires correcting for unequal areas and unequal time ranges */ +// Construct a XLALSkymap2Kernel object in the given memory from +// a plan +// direction properties (time delays, interpolation weights and +// antenna patterns) +// the noise-weighted inner product of the template with itself -int XLALSkymapSignalHypothesis(XLALSkymapPlanType* plan, double* p, double sigma, double w[3], int begin[3], int end[3], double** x, int *counts, int *modes) +void XLALSkymapKernelConstruct( + XLALSkymapPlanType* plan, + XLALSkymapDirectionPropertiesType* properties, + double* wSw, + XLALSkymapKernelType* kernel + ) { - int delay_limits[8]; - delay_limits[0] = -plan->hl; - delay_limits[1] = plan->hl; - delay_limits[2] = -plan->hv; - delay_limits[3] = plan->hv; - delay_limits[4] = -plan->lv - 1; - delay_limits[5] = plan->lv + 1; - delay_limits[6] = 0; - delay_limits[7] = 1; - return XLALSkymapSignalHypothesisWithLimits(plan, p, sigma, w, begin, end, x, counts, modes, delay_limits); -} -int XLALSkymapSignalHypothesisWithLimits(XLALSkymapPlanType* plan, double* p, double sigma, double w[3], int begin[3], int end[3], double** x, int *counts, int *modes, int delay_limits[6]) -{ - /* static const char func[] = "XLALSkymapSignalHypothesis"; */ + int i, j, k, l; - double* buffer; - int hl; - double total_normalization; + // + // W = diag(w.S_j^{-1}.w) + // + // F (F^T W F + I) F^T + // - /* double* times[3]; Arrival time posterior for each detector */ + double a[2][2]; // F^T W F + double b[2][2]; // inv(A) - total_normalization = 0; + // Compute the kernel - buffer = 0; - if (x[0]) - { - buffer = (double*) XLALMalloc(sizeof(double) * (end[0] - begin[0])); - } - else - { - if (x[1]) - { - buffer = (double*) XLALMalloc(sizeof(double) * (end[1] - begin[1])); - } - else - { - if (x[2]) - { - buffer = (double*) XLALMalloc(sizeof(double) * (end[2] - begin[2])); - } - else - { - return 1; - } - } - } + // F^T W F + I - /* Initialize the arrival time posterior for each detector + for (i = 0; i != 2; ++i) { - int d; - for (d = 0; d != 3; ++d) + for (j = 0; j != 2; ++j) { - if (x[d]) + a[i][j] = ((i == j) ? 1.0 : 0.0); + for (k = 0; k != plan->n; ++k) { - int i; - times[d] = (double*) XLALMalloc(sizeof(double) * end[d]); - for (i = 0; i != end[d]; ++i) - { - times[d][i] = log(0); - } + a[i][j] += properties->f[k][i] * wSw[k] * properties->f[k][j]; } } } - */ - - /* loop over hanford-livingston delay */ - for (hl = -plan->hl; hl <= plan->hl; ++hl) - { - /* loop over hanford-virgo delay */ - int hv; - for (hv = -plan->hv; hv <= plan->hv; ++hv) - { - /* loop over hemisphere */ - int hemisphere; - for (hemisphere = 0; hemisphere != 2; ++hemisphere) - { - /* compute the index into the buffers from delays */ - int lal_index = index_from_delays(plan, hl, hv, hemisphere); - /* (log) zero the output buffers */ - p[lal_index] = log(0); - counts[lal_index] = 0; - modes[lal_index] = 0; - /* test if the delays are physical and relevant */ - if ( - (plan->pixel[lal_index].area > 0) - && - (hl >= delay_limits[0]) - && - (hl <= delay_limits[1]) - && - (hv >= delay_limits[2]) - && - (hv <= delay_limits[3]) - && - ((hv - hl) >= delay_limits[4]) - && - ((hv - hl) <= delay_limits[5]) - && - (hemisphere >= delay_limits[6]) - && - (hemisphere <= delay_limits[7]) - ) - { - /* compute the begin and end times */ - int b; - int e; - - if (x[0]) - { /* if we have hanford data */ - b = begin[0]; - e = end[0]; - if (x[1]) - { /* if we have livingston data */ - if (b + hl < begin[1]) - { /* livingston constrains the begin time */ - b = begin[1] - hl; - } - if (e + hl > end[1]) - { /* livingston constrains the end time */ - e = end[1] - hl; - } - } - if (x[2]) - { /* if we have virgo data */ - if (b + hv < begin[2]) - { /* virgo constrains the begin time */ - b = begin[2] - hv; - } - if (e + hv > end[2]) - { /* virgo constrains the end time */ - e = end[2] - hv; - } - } - } - else - { - if (x[1]) - { /* if we have livingston data */ - b = begin[1] - hl; - e = end[1] -hl; - if (x[2]) - { /* if we have virgo data */ - if (b + hv < begin[2]) - { /* virgo constrains the begin time */ - b = begin[2] - hv; - } - if (e + hv > end[2]) - { /* virgo constrains the end time */ - e = end[2] - hv; - } - } - } - else - { /* if we have virgo data */ - if (x[2]) - { - b = begin[2] - hv; - e = end[2] - hv; - } - else - { /* we have no data */ - b = 0; - e = 0; - } - } - } - - /* test if there is enough data to analyze */ - if (b < e) - { - double log_normalization; - double *hr, *lr, *vr, *hi, *li, *vi; - double* stop; - double* q; - double* m; - - /* create offset pointers to simplify inner loop */ - hr = x[0] + b ; /* hanford real */ - lr = x[1] + b + hl; /* livingston real */ - vr = x[2] + b + hv; /* virgo real */ - hi = x[3] + b ; /* hanford imag */ - li = x[4] + b + hl; /* livingston imag */ - vi = x[5] + b + hv; /* virgo imag */ - - stop = x[0] + e; /* hanford real stop */ - - q = buffer; - - if (x[0]) - { - if (x[1]) - { - if (x[2]) - { - /* hanford-livingston-virgo analysis */ - double kernel[3][3]; - /* compute the kernel */ - compute_kernel(plan, lal_index, sigma, w, kernel, &log_normalization); - /* loop over arrival times */ - for (; hr != stop; ++hr, ++lr, ++vr, ++hi, ++li, ++vi, ++q) - { - *q = 0.5 * ( - kernel[0][0] * (sq(*hr) + sq(*hi)) + - kernel[0][1] * (*hr * *lr + *hi * *li) * 2 + - kernel[0][2] * (*hr * *vr + *hi * *vi) * 2 + - kernel[1][1] * (sq(*lr) + sq(*li)) + - kernel[1][2] * (*lr * *vr + *li * *vi) * 2 + - kernel[2][2] * (sq(*vr) + sq(*vi)) - ); - } /* end loop over arrival times */ - } - else - { - /* hanford-livingston analysis */ - double kernel[2][2]; - /* compute the kernel */ - compute_kernel2(plan, lal_index, sigma, w, kernel, &log_normalization, x); - /* loop over arrival times */ - for (; hr != stop; ++hr, ++lr, ++vr, ++hi, ++li, ++vi, ++q) - { - *q = 0.5 * ( - kernel[0][0] * (sq(*hr) + sq(*hi)) + - kernel[0][1] * (*hr * *lr + *hi * *li) * 2 + - kernel[1][1] * (sq(*lr) + sq(*li)) - ); - } /* end loop over arrival times */ - } - } - else - { - if (x[2]) - { - /* hanford-virgo analysis */ - double kernel[2][2]; - /* compute the kernel */ - compute_kernel2(plan, lal_index, sigma, w, kernel, &log_normalization, x); - /* loop over arrival times */ - for (; hr != stop; ++hr, ++lr, ++vr, ++hi, ++li, ++vi, ++q) - { - *q = 0.5 * ( - kernel[0][0] * (sq(*hr) + sq(*hi)) + - kernel[0][1] * (*hr * *vr + *hi * *vi) * 2 + - kernel[1][1] * (sq(*vr) + sq(*vi)) - ); - } /* end loop over arrival times */ - } - else - { - /* hanford analysis */ - double kernel[1][1]; - /* compute the kernel */ - compute_kernel1(plan, lal_index, sigma, w, kernel, &log_normalization, x); - /* loop over arrival times */ - for (; hr != stop; ++hr, ++lr, ++vr, ++hi, ++li, ++vi, ++q) - { - *q = 0.5 * ( - kernel[0][0] * (sq(*hr) + sq(*hi)) - ); - } /* end loop over arrival times */ - } - } - } - else - { - if (x[1]) - { - if (x[2]) - { - /* livingston-virgo analysis */ - double kernel[2][2]; - /* compute the kernel */ - compute_kernel2(plan, lal_index, sigma, w, kernel, &log_normalization, x); - /* loop over arrival times */ - for (; hr != stop; ++hr, ++lr, ++vr, ++hi, ++li, ++vi, ++q) - { - *q = 0.5 * ( - kernel[0][0] * (sq(*lr) + sq(*li)) + - kernel[0][1] * (*lr * *vr + *li * *vi) * 2 + - kernel[1][1] * (sq(*vr) + sq(*vi)) - ); - } /* end loop over arrival times */ - } - else - { - /* livingston analysis */ - double kernel[1][1]; - /* compute the kernel */ - compute_kernel1(plan, lal_index, sigma, w, kernel, &log_normalization, x); - /* loop over arrival times */ - for (; hr != stop; ++hr, ++lr, ++vr, ++hi, ++li, ++vi, ++q) - { - *q = 0.5 * ( - kernel[0][0] * (sq(*lr) + sq(*li)) - ); - } /* end loop over arrival times */ - } - } - else - { - if (x[2]) - { - /* virgo analysis */ - double kernel[1][1]; - /* compute the kernel */ - compute_kernel1(plan, lal_index, sigma, w, kernel, &log_normalization, x); - /* loop over arrival times */ - for (; hr != stop; ++hr, ++lr, ++vr, ++hi, ++li, ++vi, ++q) - { - *q = 0.5 * ( - kernel[0][0] * (sq(*vr) + sq(*vi)) - ); - } /* end loop over arrival times */ - } - else - { - /* no data at all */ - return 1; - } - } - } - - /* compute the plausibility for the direction */ - m = findmax(buffer, buffer + e - b); - p[lal_index] = - logtotalexpwithmax(buffer, buffer + e - b, *m) + - log_normalization * 2 - log(e - b); - counts[lal_index] = e - b; - modes[lal_index] = b + (m - buffer); - - /* Compute the arrival time posterior for each detector - { - int i; - for (i = b; i != e; ++i) - { - double np; - np = buffer[i - b] + log_normalization * 2 + log(plan->pixel[lal_index].area); - times[0][i] = XLALSkymapLogSumExp(times[0][i], np); - times[1][i + hl] = XLALSkymapLogSumExp(times[1][i + hl], np); - times[2][i + hv] = XLALSkymapLogSumExp(times[2][i + hv], np); - } - } - */ - } /* end test if there is enough data to analyze */ - } /* end test if the delays are physical */ - } /* end loop over hemisphere */ - } /* end loop over hanford-virgo delay */ - } /* end loop over hanford-livingston delay */ - - /* release working memory */ - XLALFree(buffer); - return 0; -} -int XLALSkymapEllipticalHypothesis(XLALSkymapPlanType* plan, double* p, double sigma, double w[3], int begin[3], int end[3], double** x, int* bests) -{ - /* indicate that a detector has no data by x[i] == 0 */ - - /* static const char func[] = "XLALSkymapEllipticalHypothesis"; */ + // (F^T W F + I)^{-1} - int *counts; - int *modes; - double c; - int i; + inv22(b, a); - counts = (int *) XLALMalloc(sizeof(int) * plan->pixelCount); - modes = (int *) XLALMalloc(sizeof(int) * plan->pixelCount); + // F (F^T W F + I)^{-1} F^T - XLALSkymapSignalHypothesis(plan, p, sigma, w, begin, end, x, counts, modes); - - /* the prior of each pixel is the product of its area and the length - * arrival times it represents */ - - /* compute the normalization factor for the prior */ - c = 0; - for (i = 0; i != plan->pixelCount; ++i) - { - if (plan->pixel[i].area > 0) - { - c += plan->pixel[i].area * counts[i]; - } - } - /* apply the prior */ - for (i = 0; i != plan->pixelCount; ++i) - { - if (plan->pixel[i].area > 0) - { - p[i] += log(plan->pixel[i].area * counts[i] / c); - } - } - /* now the sum over the skymap is the posterior odds of a signal from - * any direction */ - - if (bests) { - /* find the most likely arrival times */ - double *a; - int j; - int delays[3]; - a = findmax(p, p + plan->pixelCount); - j = a - p; - printf("i = %d\n", j); - delays_from_index(plan, j, delays); - printf("delays[] = { %d, %d, %d}\n", delays[0], delays[1], delays[2]); - printf("index_from_delays(delays) = %d\n", index_from_delays(plan, delays[0], delays[1], delays[2])); - bests[0] = modes[j]; - bests[1] = bests[0] + delays[0]; - bests[2] = bests[0] + delays[1]; - bests[3] = delays[2]; - } - - XLALFree(modes); - XLALFree(counts); - - return 0; -} - - -void XLALSkymapSum(XLALSkymapPlanType* plan, double* a, const double* b, const double* c) -{ - int i; - for (i = 0; i != plan->pixelCount; ++i) - { /* check to see if the pixel is valid */ - if (plan->pixel[i].area > 0) - { /* sum the log-represented values */ - a[i] = XLALSkymapLogSumExp(b[i], c[i]); - } - } -} - -void XLALSkymapModeThetaPhi(XLALSkymapPlanType* plan, double* p, double thetaphi[2]) -{ - double mode = 0; - int mode_i = -1; - int i; - /* for each pixel */ - for (i = 0; i < plan->pixelCount; ++i) - { /* only consider valid pixels */ - if (plan->pixel[i].area > 0) - { /* if the greatest or first valid pixel */ - if ((mode_i == -1) || (p[i] - log(plan->pixel[i].area)) > mode) - { - mode = p[i] - log(plan->pixel[i].area); - mode_i = i; - } - } - } - XLALSkymapSphericalFromCartesian(thetaphi, plan->pixel[mode_i].direction); -} - -int XLALSkymapRender(double* q, XLALSkymapPlanType* plan, double* p) -{ - static const char func[] = "XLALSkymapRender"; - int i, j; - - /* scan over the sky */ - for (i = 0; i != plan->m; ++i) + for (i = 0; i != plan->n; ++i) { for (j = 0; j != plan->n; ++j) { - double direction[3]; - int k; - /* compute theta and phi */ - double thetaphi[2]; - thetaphi[0] = acos(1. - (i + 0.5) * (2. / plan->m)); - thetaphi[1] = (j + 0.5) * (2. * pi / plan->n); - /* compute direction */ - XLALSkymapCartesianFromSpherical(direction, thetaphi); - /* determine the corresponding pixel */ - k = XLALSkymapIndexFromDirection(plan, direction); - - if (plan->pixel[k].area > 0) + kernel->k[i][j] = 0.0; + for (k = 0; k != 2; ++k) { - if (p[k] < -log(0)) - { - q[i + j * plan->m] = p[k]; - /* apply area corrections */ - q[i + j * plan->m] -= log(plan->pixel[k].area); - } - else + for (l = 0; l != 2; ++l) { - XLALPrintError("%s(): attempted to render from a pixel with value +inf or nan to (%i, %j)\n", func, i, j); - XLAL_ERROR(func, XLAL_EINVAL); + kernel->k[i][j] += properties->f[i][k] * b[k][l] * properties->f[j][l]; } } - else - { - XLALPrintError("%s(): attempted to render from a pixel with zero area to (%i, %j)\n", func, i, j); - XLAL_ERROR(func, XLAL_EINVAL); - } } } - return 0; -} - -///////////////////////////////////////////////////////////////////// - -// VERSION 2 - -static void diag3(double a[3][3], double b[3]) -{ - int i; - int j; - for (i = 0; i != 3; ++i) - for (j = 0; j != 3; ++j) - a[i][j] = (i == j) ? b[i] : 0.; -} - -static void eye2(double a[2][2]) -{ - int i; - int j; - for (i = 0; i != 2; ++i) - for (j = 0; j != 2; ++j) - a[i][j] = (i == j) ? 1. : 0.; -} - -static void add22(double a[2][2], double b[2][2], double c[2][2]) -{ - int i; - int j; - for (i = 0; i != 2; ++i) - for (j = 0; j != 2; ++j) - a[i][j] = b[i][j] + c[i][j]; -} - -// static void sub22(double a[2][2], double b[2][2], double c[2][2]) -// { -// int i; -// int j; -// for (i = 0; i != 2; ++i) -// for (j = 0; j != 2; ++j) -// a[i][j] = b[i][j] - c[i][j]; -// } - -static void mul233(double a[2][3], double b[2][3], double c[3][3]) -{ - int i, j, k; - for (i = 0; i != 2; ++i) - for (k = 0; k != 3; ++k) - { - a[i][k] = 0; - for (j = 0; j != 3; ++j) - a[i][k] += b[i][j] * c[j][k]; - } -} + kernel->logNormalization = 0.5 * log(det22(b)); -static void mul232(double a[2][2], double b[2][3], double c[3][2]) -{ - int i, j, k; - for (i = 0; i != 2; ++i) - for (k = 0; k != 2; ++k) - { - a[i][k] = 0; - for (j = 0; j != 3; ++j) - a[i][k] += b[i][j] * c[j][k]; - } } -static double det3(double z[3][3]) -{ - double a, b, c, d, e, f, g, h, i; - a = z[0][0]; - b = z[0][1]; - c = z[0][2]; - d = z[1][0]; - e = z[1][1]; - f = z[1][2]; - g = z[2][0]; - h = z[2][1]; - i = z[2][2]; - - return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; -} +// Compute the marginalization integral over a_plus and a_cross for the +// system described by +// a plan +// a direction's properties +// a kernel +// a matched filter time series for each detector +// a signal arrival time -void XLALSkymap2PlanConstruct(int sampleFrequency, XLALSkymap2PlanType* plan) +void XLALSkymapApply( + XLALSkymapPlanType* plan, + XLALSkymapDirectionPropertiesType* properties, + XLALSkymapKernelType* kernel, + double** xSw, + double tau, + double* posterior + ) { - static const char func[] = "XLALSkymap2ConstructPlan"; + double a; + int i, j; - if (sampleFrequency <= 0) - { - XLALPrintError("%s(): invalid sample frequency %d\n", func, sampleFrequency); - XLAL_ERROR_VOID(func, XLAL_EINVAL); - } + double x[XLALSKYMAP_N]; - plan->sampleFrequency = sampleFrequency; - construct_hlv(plan->site); -} + // Interpolate the matched filter values -void XLALSkymap2DirectionPropertiesConstruct( - XLALSkymap2PlanType* plan, - XLALSkymap2SphericalPolarType* directions, - XLALSkymap2DirectionPropertiesType* properties - ) -{ - double x[3]; - int j; - XLALSkymapCartesianFromSpherical(x, *directions); - for (j = 0; j != 3; ++j) + for (i = 0; i != plan->n; ++i) { - properties->delay[j] = floor(site_time(plan->site + j, x) * plan->sampleFrequency + 0.5); - site_response(properties->f[j], plan->site + j, x); + x[i] = XLALSkymapInterpolate((tau + properties->delay[i]) * plan->sampleFrequency, xSw[i]); } -} -void XLALSkymap2KernelConstruct( - XLALSkymap2DirectionPropertiesType* properties, - double wSw[3], - XLALSkymap2KernelType* kernel - ) -{ - - { - - // - // F(F^T diag(w.S_j^{-1}.w) F + I) F^T - // - - double fT[2][3]; - double diagwSw[3][3]; - double fTdiagwSw[2][3]; - double fTdiagwSwf[2][2]; - double eye[2][2]; - double fTdiagwSwfeye[2][2]; - double invfTdiagwSwfeye[2][2]; - double finvfTdiagwSwfeye[3][2]; - - // Compute the kernel - - // F^T - transpose32(fT, properties->f); - // diag(w.S_j^{-1}.w) - diag3(diagwSw, wSw); - // F^T . diag(wSw) - mul233(fTdiagwSw, fT, diagwSw); - // F^T diag(wSw) . F - mul232(fTdiagwSwf, fTdiagwSw, properties->f); - // I - eye2(eye); - // F^T diag(wSw) F + I - add22(fTdiagwSwfeye, fTdiagwSwf, eye); - // (F^T diag(wSw) F + I)^{-1} - inv22(invfTdiagwSwfeye, fTdiagwSwfeye); - // F . (F^T diag(wSw) F + I)^{-1} - mul322(finvfTdiagwSwfeye, properties->f, invfTdiagwSwfeye); - // F (F^T diag(wSw) F + I)^{-1} . F^T - mul323(kernel->k, finvfTdiagwSwfeye, fT); - - } + // This implementation does not exploit the symmetry of the expression + // Compute x^T.K.x + a = 0; + for (i = 0; i != plan->n; ++i) { - - // Compute the normalization - - double a; - double b[3][3]; - double c; - int i, j; - - a = wSw[0] * wSw[1] * wSw[2]; - - for (i = 0; i != 3; ++i) + for (j = 0; j != plan->n; ++j) { - for (j = 0; j != 3; ++j) - { - b[i][j] = -kernel->k[i][j]; - } - b[i][i] += 1. / wSw[i]; + a += x[i] * kernel->k[i][j] * x[j]; } - c = det3(b); + } - kernel->logNormalization = 0.5 * log(a * c); + // Scale and apply the normalization + *posterior = 0.5 * a + kernel->logNormalization; - } } -static double ip33(double a[3], double b[3][3], double c[3]) -{ - double d = 0.; - int i; - int j; - for (i = 0; i != 3; ++i) - for (j = 0; j != 3; ++j) - d += a[i] * b[i][j] * c[j]; - return d; -} -void XLALSkymap2Apply( - XLALSkymap2DirectionPropertiesType* properties, - XLALSkymap2KernelType* kernel, - double* xSw[3], - int tau, - double* posterior - ) -{ - double x[3]; - int j; - for (j = 0; j != 3; ++j) - x[j] = xSw[j][tau + properties->delay[j]]; - *posterior = 0.5 * ip33(x, kernel->k, x) + kernel->logNormalization; -} diff --git a/lal/packages/burstsearch/test/SkymapTest.c b/lal/packages/burstsearch/test/SkymapTest.c index 8cd2726cd1d81927c3983aaf4ed6c675eac30bcd..47c2e36224c88feb6048bffe2fd10b28b860b00d 100644 --- a/lal/packages/burstsearch/test/SkymapTest.c +++ b/lal/packages/burstsearch/test/SkymapTest.c @@ -10,15 +10,13 @@ #include <fftw3.h> -#define TEST(A) if (!(A)) { printf("FAIL: %s\n", #A); exit(1); } - -#if 0 static void numericApply( - XLALSkymap2DirectionPropertiesType* properties, - double wSw[3], - XLALSkymap2KernelType* kernel, - double* xSw[3], - int tau, + XLALSkymapPlanType* plan, + XLALSkymapDirectionPropertiesType* properties, + double* wSw, + XLALSkymapKernelType* kernel, + double** xSw, + double tau, double* logPosterior ) { @@ -35,24 +33,28 @@ static void numericApply( // accumulate probability in this double p = 0.0; + // kernel is unused + kernel = NULL; + // range from +/- 5 sigma in prior on a[i] for adequate accuracy for (a[0] = -5.0; a[0] <= 5.0; a[0] += da) { for (a[1] = - 5.0; a[1] <= 5.0; a[1] += da) { - double x[3]; + double x[XLALSKYMAP_N]; // start accumulating inner products with the priors double q = (a[0] * a[0] + a[1] * a[1]); // for each detector... int j; - for (j = 0; j != 3; ++j) + for (j = 0; j != plan->n; ++j) { int k; // get the time-shifted data - x[j] = xSw[j][tau + properties->delay[j]]; - // subtract the inner product + x[j] = XLALSkymapInterpolate((tau + properties->delay[j]) * plan->sampleFrequency, xSw[j]); + + // subtract the inner product q -= x[j] * x[j] / wSw[j]; // for each polarization for (k = 0; k != 2; ++k) @@ -78,1807 +80,113 @@ static void numericApply( static void numerical(void) { - - XLALSkymap2PlanType plan; - XLALSkymap2SphericalPolarType direction; - XLALSkymap2DirectionPropertiesType properties; - double wSw[3] = { 100., 100., 100. }; - XLALSkymap2KernelType kernel; - double *xSw[3]; + XLALSkymapPlanType plan; + double direction[2]; + XLALSkymapDirectionPropertiesType properties; + double wSw[5] = { 100., 100., 100., 100., 100. }; + XLALSkymapKernelType kernel; + double *xSw[5]; + int siteNumbers[] = { LAL_LHO_4K_DETECTOR, LAL_LLO_4K_DETECTOR, LAL_VIRGO_DETECTOR, LAL_GEO_600_DETECTOR, LAL_LHO_2K_DETECTOR }; RandomParams* rng; + int n; rng = XLALCreateRandomParams(0); - XLALSkymap2PlanConstruct(8192, &plan); - - direction[0] = LAL_PI * XLALUniformDeviate(rng); - direction[1] = LAL_TWOPI * XLALUniformDeviate(rng); - - XLALSkymap2DirectionPropertiesConstruct(&plan, &direction, &properties); - - XLALSkymap2KernelConstruct(&properties, wSw, &kernel); - - { - int i; - - for (i = 0; i != 3; ++i) - { - int j; - xSw[i] = malloc(sizeof(*xSw[i]) * plan.sampleFrequency); - for (j = 0; j != plan.sampleFrequency; ++j) - { - xSw[i][j] = XLALNormalDeviate(rng) * sqrt(wSw[i]); - } - } - } - - { - double logPosterior; - double logPosteriorNumerical; - XLALSkymap2Apply(&properties, &kernel, xSw, plan.sampleFrequency / 2, &logPosterior); - printf("%g\n", exp(logPosterior)); - - numericApply(&properties, wSw, &kernel, xSw, plan.sampleFrequency / 2, & logPosteriorNumerical); - printf("%g\n", exp(logPosteriorNumerical)); - - printf("%g\n", exp(logPosterior) - exp(logPosteriorNumerical)); - - } - - { - int i; - for(i = 0; i != 3; ++i) - free(xSw[i]); - } - -} -#endif - -static void injection(void) -{ - XLALSkymap2PlanType plan; - XLALSkymap2SphericalPolarType *directions; - XLALSkymap2DirectionPropertiesType *properties; - double S[3] = { 1, 2.0, 4.0 }; - double wSw[3]; - XLALSkymap2KernelType *kernels; - double *xSw[3]; - int n = 8192; - //printf("%d\n", __LINE__); - - XLALSkymap2PlanConstruct(n, &plan); - - // generate directions - - { - //printf("%d\n", __LINE__); - int i; - directions = malloc(sizeof(*directions) * 180 * 360); - for (i = 0; i != 180; ++i) - { - int j; - for (j = 0; j != 360; ++j) - { - directions[i * 360 + j][0] = (i + 0.5) / 180. * LAL_PI; - directions[i * 360 + j][1] = (j + 0.5) / 180. * LAL_PI; - } - } - } - - // compute properties of the directions - - { - //printf("%d\n", __LINE__); - int i; - properties = malloc(sizeof(*properties) * 180 * 360); - for (i = 0; i != 180 * 360; ++i) - { - XLALSkymap2DirectionPropertiesConstruct( - &plan, - directions + i, - properties + i - ); - } - } - - // make some data - + for (n = 1; n != 6; ++n) { - int i, j; - RandomParams* rng; - double* x[3]; - double* w; - rng = XLALCreateRandomParams(0); - // one second of data - //printf("%d\n", __LINE__); + XLALSkymapPlanConstruct(8192, n, siteNumbers, &plan); - for (i = 0; i != 3; ++i) - { - x[i] = malloc(sizeof(*x[i]) * n); - for (j = 0; j != n; ++j) - { - //printf("%d\n", __LINE__); - x[i][j] = XLALNormalDeviate(rng) * sqrt(S[i]); - } - } + direction[0] = LAL_PI * XLALUniformDeviate(rng); + direction[1] = LAL_TWOPI * XLALUniformDeviate(rng); - //printf("%d\n", __LINE__); - - // half a second of waveform - - w = malloc(sizeof(*w) * n / 2); - for (j = 0; j != n / 2; ++j) - { - double t; - t = ((double) j) / plan.sampleFrequency; - w[j] = 3 * exp(- 0.5 * pow(t - 0.25, 2) / pow(0.003, 2)) * sin(LAL_TWOPI * t * 256.0); - } + XLALSkymapDirectionPropertiesConstruct(&plan, direction, &properties); - //printf("%d\n", __LINE__); - // compute wSw + XLALSkymapKernelConstruct(&plan, &properties, wSw, &kernel); - for (i = 0; i != 3; ++i) { - wSw[i] = 0; - for (j = 0; j != n/2; ++j) - { - wSw[i] += w[j] * w[j] / S[i]; - } - //fprintf(stderr, "wSw[%d] = %f = %f^2\n", i, wSw[i], sqrt(wSw[i])); - } - //exit(0); - //printf("%d\n", __LINE__); - - // make an injection + int i; - { - int k; - double a[2]; - //k = (int) floor(XLALUniformDeviate(rng) * 360 * 180); - k = 120 * 360 + 120; - a[0] = XLALNormalDeviate(rng); - a[1] = XLALNormalDeviate(rng); - //fprintf(stderr, "a = { %f, %f }\n", a[0], a[1]); - for (i = 0; i != 3; ++i) + for (i = 0; i != n; ++i) { - for (j = 0; j != n/2; ++j) + int j; + xSw[i] = malloc(sizeof(*xSw[i]) * plan.sampleFrequency); + for (j = 0; j != plan.sampleFrequency; ++j) { - int q; - for (q = 0; q != 2; ++q) - { - x[i][j + n / 4 + properties[k].delay[i]] += a[q] * w[j] * properties[k].f[i][q]; - } + xSw[i][j] = XLALNormalDeviate(rng) * sqrt(wSw[i]); } } - } - - // compute xSw (filtering) - - for (i = 0; i != 3; ++i) { - xSw[i] = malloc(sizeof(*xSw[i]) * n); - for (j = 0; j != n / 2; ++j) - { - int k; - double a = 0; - for (k = 0; k != n / 2; ++k) - { - a += x[i][j + k] * w[k] / S[i]; - } - xSw[i][j + n / 4] = a; - } - } - //printf("%d\n", __LINE__); + double logPosteriorAnalytic; + double logPosteriorNumerical; + XLALSkymapApply(&plan, &properties, &kernel, xSw, 0.5, &logPosteriorAnalytic); - } - - // compute the kernels - - { - int i; - kernels = malloc(sizeof(*kernels) * 180 * 360); - for (i = 0; i != 180 * 360; ++i) - { - XLALSkymap2KernelConstruct(properties + i, wSw, kernels + i); - } - } + numericApply(&plan, &properties, wSw, &kernel, xSw, 0.5, & logPosteriorNumerical); - /* - { - int i; - RandomParams* rng; - rng = XLALCreateRandomParams(0); - for (i = 0; i != 3; ++i) - { - int j; - xSw[i] = malloc(sizeof(*xSw[i]) * plan->sampleFrequency); - for (j = 0; j != plan->sampleFrequency; ++j) - { - xSw[i][j] = XLALNormalDeviate(rng) * sqrt(wSw[i]); - } - } - // injection - { - double h[2]; - int k; - h[0] = XLALNormalDeviate(rng); - h[1] = XLALNormalDeviate(rng); - // k = (int) floor(XLALUniformDeviate(rng) * 360 * 180); - k = 120 * 360 + 120; - for (i = 0; i != 3; ++i) + if (abs(logPosteriorAnalytic - logPosteriorNumerical) > 1e-3) { - int j; - for (j = 0; j != 2; ++j) - { - xSw[i][ - plan->sampleFrequency / 2 + - properties[k].delay[i] - ] += h[j] * properties[k].f[i][j] * wSw[i]; - } + fprintf(stderr, "Analytic expression does not match numerical result to expected accuracy\n"); + exit(1); } } - } - */ - - { - int i; - for (i = 0; i != 180 * 360; ++i) { - int t; - double p = 0; - for (t = n * 3 / 8; t != n * 5 / 8; ++t) - { - double logPosterior; - XLALSkymap2Apply(properties + i, kernels + i, xSw, t, &logPosterior); - p += exp(logPosterior) / (n / 4); - - } - printf("%g %g %g\n", directions[i][0], directions[i][1], log(p)); + int i; + for(i = 0; i != n; ++i) + free(xSw[i]); } - } - { - int i; - for(i = 0; i != 3; ++i) - free(xSw[i]); } - free(kernels); - free(properties); - free(directions); - -} - -//int main(int argc, char** argv) -int main(void) -{ - //numerical(); - injection(); - - - // ideas for tests: - - // compare a numerical integral over a_+ and a_x with the normalized - // majig - - // mock up some co-located detectors - - return 0; } -#if 0 - -int main(int argc, char** argv) +static void interpolation(void) { + double* x; + int n; - int sampleFrequency = 8192; - int m = 1024; - int n = 2048; - - XLALSkymapPlanType* plan = 0; - - double* p = 0; - double sigma = 1; - double w[3] = {1, 1, 1}; - int begin[3] = { 4000, 4000, 4000 }; - int end[3] = {4200, 4200, 4200 }; - double* x[6] = { 0, 0, 0, 0, 0, 0 }; - int* counts = 0; - int* modes = 0; - int delay_limits[6] = { -8192, 8192, -8192, 8192, -8192, 8192 }; - - RandomParams* rng_parameters; - - FILE* h; - - double* q = 0; - - int i; - int j; + n = 1000; - lalDebugLevel = 0xFFFFFFFF; + x = (double*) malloc(sizeof(double) * n); - if (!(plan = XLALSkymapConstructPlanMN(sampleFrequency, m, n))) + for (int i = 0; i != n; ++i) { - printf("XLALSkymapConstructPlanMN failed\n"); - exit(1); + x[i] = sin(i); } - rng_parameters = XLALCreateRandomParams(0); - - for (i = 0; i != 6; ++i) + for (double t = n * 0.25; t < n * 0.75; t += 0.1) { - x[i] = XLALMalloc(sizeof(double) * sampleFrequency); - for (j = 0; j != sampleFrequency; ++j) + if (abs(XLALSkymapInterpolate(t, x) - sin(t)) > 0.03) { - x[i][j] = XLALNormalDeviate(rng_parameters); + fprintf(stderr, "Interpolation error larger than expected\n"); + exit(1); } } - p = (double*) XLALMalloc(sizeof(double) * plan->pixelCount); - counts = (int*) XLALMalloc(sizeof(int) * plan->pixelCount); - modes = (int*) XLALMalloc(sizeof(int) * plan->pixelCount); - - if (XLALSkymapSignalHypothesisWithLimits(plan, p, sigma, w, begin, end, x, counts, modes, delay_limits)) - { - printf("XLALSkymapSignalHypothesisWithLimits failed\n"); - exit(1); - } - - h = fopen("p.bin", "w"); - fwrite(p, sizeof(double), plan->pixelCount, h); - fclose(h); - - q = XLALMalloc(sizeof(double) * m * n); - - if (XLALSkymapRender(q, plan, p)) - { - printf("XLALSkymapRender failed\n"); - exit(1); - } - - h = fopen("q.bin", "w"); - fwrite(q, sizeof(double), m * n, h); - fclose(h); - - return 0; -} - -#endif - -#if 0 -#include <stdlib.h> -#include <math.h> - -#include <fftw3.h> - -typedef struct XLALSkymapFollowupInputStruct -{ - fftw_complex *data[3]; /* one-sided frequency domain double-whitened data */ - double *psd[3]; /* one-sided power spectrum */ - - int duration; /* seconds */ - int inputRate; /* power-of-two integer */ - int analysisRate; /* power-of-two integer */ - - double minFrequency; - double maxFrequency; - double minTime; - double maxTime; - -} XLALSkymapFollowupInput; - -typedef struct XLALSkymapFollowupOutputStruct -{ -} XLALSkymapFollowupOutput; - -/* declare a C99 function */ -double log2(double); - -XLALSkymapFollowupOutput* XLALSkymapFollowup(XLALSkymapFollowupInput* in) -{ - /* validate arguments */ - - /* now perform a time-freqiency-Q decomposition of the region of interest */ - - printf("%f volume\n", (in->maxTime - in->minTime) * (in->maxFrequency - in->minFrequency)); - + for (int t = n / 4; t < (n * 3) / 4; ++t) { - int width; - - int minWidth = pow(2, ceil(log2(in->duration / (in->maxTime - in->minTime)))); - int maxWidth = pow(2, floor(log2(in->duration * (in->maxFrequency - in->minFrequency)))); - - for (width = minWidth; width <= maxWidth; width *= 2) + if (abs(XLALSkymapInterpolate(t, x) - sin(t)) != 0) { - int f; - - int minFrequency = ceil(4 * in->minFrequency * in->duration / width) * width / 4; - int maxFrequency = floor(4 * in->maxFrequency * in->duration / width) * width / 4 - width; - - printf("%f Hz (%f...%f)\n", ((double) width) / in->duration, ((double) minFrequency) / in->duration, ((double) maxFrequency + width) / in->duration); - - for (f = minFrequency; f <= maxFrequency; f += (width / 4)) - { - printf(" [%f, %f)\n", ((double) f) / in->duration, ((double) f + width) / in->duration); - } + fprintf(stderr, "Interpolation does not pass through data points\n"); + exit(1); } - } - - return 0; } -int main(int argc, char** argv) +int main(void) { - XLALSkymapFollowupInput* in; - in = (XLALSkymapFollowupInput *) malloc(sizeof(XLALSkymapFollowupInput)); + // check the fast analytic bayesian statistic against simpler but + // slower numerical integration - in->duration = 64; - in->inputRate = 4096; - in->analysisRate = 8192; + numerical(); - in->minFrequency = 100; - in->maxFrequency = 300; - in->minTime = 31.9; - in->maxTime = 32.1; - - XLALSkymapFollowup(in); + interpolation(); return 0; } -#endif - -#if 0 - -#include <stdio.h> -#include <math.h> -#include <time.h> -#include <stdlib.h> - -#include <lal/LALConstants.h> -#include <lal/Skymap.h> -#include <lal/Random.h> -#include <lal/Sort.h> - -#include <fftw3.h> - -#define max(A,B) (((A) > (B)) ? (A) : (B)) -#define min(A,B) (((A) < (B)) ? (A) : (B)) - -RandomParams* rng_parameters; - -int duration; -int rate; - -int samples; - -double *h_t[3]; /* h(t) */ - -fftw_complex *h_f[3]; /* h(f) */ - -int f_min; /* Hz */ -int f_max; /* Hz */ -int *widths; - -XLALSkymapPlanType* plan; - -static double sq(double a) -{ - return a * a; -} - -void make_h_t() -{ - int i, j; - for (i = 0; i != 3; ++i) - { - h_t[i] = (double*) malloc(sizeof(double) * samples); - for (j = 0; j != samples; ++j) - { - h_t[i][j] = XLALNormalDeviate(rng_parameters); - } - } -} - -void free_h_t() -{ - int i; - for (i = 0; i !=3; ++i) - { - free(h_t[i]); - } -} - -double thetaphi[2]; - -void add_injection(XLALSkymapPlanType* plan, double sigma) -{ - int i, j; - double h[4]; - double direction[3]; - int delays[3]; - - thetaphi[0] = acos(XLALUniformDeviate(rng_parameters) * 2 - 1); - thetaphi[1] = XLALUniformDeviate(rng_parameters) * LAL_TWOPI; - XLALSkymapCartesianFromSpherical(direction, thetaphi[0], thetaphi[1]); - - XLALSkymapDelaysFromDirection(plan, delays, direction); - i = XLALSkymapIndexFromDirection(plan, direction); - - for (j = samples / 2 - rate / 128; j < samples /2 + rate / 128; ++j) - { - h[0] = sigma * XLALNormalDeviate(rng_parameters); - h[1] = sigma * XLALNormalDeviate(rng_parameters); - - h_t[0][j ] += plan->pixel[i].f[0][0] * h[0] + plan->pixel[i].f[0][1] * h[1]; - h_t[1][j + delays[0]] += plan->pixel[i].f[1][0] * h[0] + plan->pixel[i].f[1][1] * h[1]; - h_t[2][j + delays[1]] += plan->pixel[i].f[2][0] * h[0] + plan->pixel[i].f[2][1] * h[1]; - } -} - -void add_glitch(double sigma) -{ - int j; - int k[3]; - k[0] = (rand() % (samples/2)) - samples / 4; - k[1] = (rand() % (samples/2)) - samples / 4; - k[2] = (rand() % (samples/2)) - samples / 4; - - for (j = samples / 2 - rate / 256; j < samples /2 + rate / 256; ++j) - { - h_t[0][j] += sigma * XLALNormalDeviate(rng_parameters); - h_t[1][j] += sigma * XLALNormalDeviate(rng_parameters); - h_t[2][j] += sigma * XLALNormalDeviate(rng_parameters); - } - -} - -void make_h_f() -{ - int i, j; - - fftw_complex *dft_in; - fftw_complex *dft_out; - fftw_plan dft_forward; - - dft_in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - dft_out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - - dft_forward = fftw_plan_dft_1d(samples, dft_in, dft_out, FFTW_FORWARD, FFTW_ESTIMATE); - - for (i = 0; i != 3; ++i) - { - for (j = 0; j != samples; ++j) - { - dft_in[j][0] = h_t[i][j] / sqrt(samples); - dft_in[j][1] = 0.; - } - fftw_execute(dft_forward); - h_f[i] = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - for (j = 0; j != samples; ++j) - { - h_f[i][j][0] = dft_out[j][0]; - h_f[i][j][1] = dft_out[j][1]; - } - } - - fftw_destroy_plan(dft_forward); - fftw_free(dft_out); - fftw_free(dft_in); - -} - -void free_h_f() -{ - int i; - for (i = 0; i != 3; ++i) - { - fftw_free(h_f[i]); - } -} - -int less_double(void *p, const void *a, const void *b) -{ - if (*((double*) a) < *((double*) b)) - { - return -1; - } - else - { - if (*((double*) a) > *((double*) b)) - { - return 1; - } - else - { - return 0; - } - } -} - -int main(int argc, char **argv) -{ - FILE *h, *g; - int width; - - double *probabilities, *scores; - int *widths, *frequencies, *times[3], *used; - int n_bands; - int i_band; - int* index; - - double* accumulated_skymap; - double accumulated_glitch, accumulated_signal; - double w[3]; - - w[0] = 1.0; w[1] = w[0]; w[2] = w[0]; - - rng_parameters = XLALCreateRandomParams(0); - - duration = 1; - rate = 8192; - - samples = duration * rate; - - f_min = 0; - f_max = 1024; - - printf("making skymap...\n"); - plan = XLALSkymapConstructPlan(rate); - printf(" ...done\n"); - - printf("making data...\n"); - make_h_t(); - printf(" ...done\n"); - - add_injection(plan, 10); - /*add_glitch(10);*/ - - printf("transforming data...\n"); - make_h_f(); - printf(" ...done\n"); - - g = fopen("bands.dat", "wb"); - - - n_bands = (1024 / 16) * 4 * 2; - i_band = 0; - probabilities = (double*) malloc(sizeof(double) * n_bands); - scores = (double*) malloc(sizeof(double) * n_bands); - widths = (int *) malloc(sizeof(int ) * n_bands); - frequencies = (int *) malloc(sizeof(int ) * n_bands); - times[0] = (int *) malloc(sizeof(int ) * n_bands); - times[1] = (int *) malloc(sizeof(int ) * n_bands); - times[2] = (int *) malloc(sizeof(int ) * n_bands); - used = (int *) malloc(sizeof(int ) * n_bands); - - /* loop through window bandwidths */ - for (width = 16; width <= 1024; width *= 2) - { - /* set up the transforms */ - int f, i, n; - fftw_complex *dft_in; - fftw_complex *dft_out; - fftw_plan dft_backward; - double *buffer; - int n_sigmas = 3; - double sigmas[] = { sqrt(10), 10, sqrt(1000) }; - /* sigmas[0] = 0.01; sigmas[1] = sigmas[0]; sigmas[2] = sigmas[0]; */ - - n = width * duration * 4; - - dft_in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); - dft_out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); - - buffer = (double*) malloc(sizeof(double) * n); - - dft_backward = fftw_plan_dft_1d(n, dft_in, dft_out, FFTW_BACKWARD, FFTW_ESTIMATE); - - for (i = 0; i != n; ++i) - { - dft_in[i][0] = 0.0; - dft_in[i][1] = 0.0; - } - /* loop through bands */ - for (f = 0; f + width <= 1024; f += (width / 4)) - { - /* loop through detectors */ - int d; - double p_detectors; - double p_sigmas[3] = { log(0), log(0), log(0) }; - - printf(" [%d, %d) Hz", f, f + width); - p_detectors = 0.0; - for (d = 0; d != 3; ++d) - { - double s; - int j; - - double p_sigma; - s = 1.0 / sqrt(width * duration); - for (i = 0; i != width * duration; ++i) - { - dft_in[i][0] = h_f[d][f * duration + i][0] * s; - dft_in[i][1] = h_f[d][f * duration + i][1] * s; - } - fftw_execute(dft_backward); - fwrite(dft_out, sizeof(fftw_complex), n, g); - - - { - /* find the peak power, which will be where the peak - * probability will be for any sigma */ - int best_i = 0; - double best_power = 0; - for (i = 0; i != n; ++i) - { - double power = sq(dft_out[i][0]) + sq(dft_out[i][1]); - if (power > best_power) - { - best_power = power; - best_i = i; - } - } - times[d][i_band] = best_i * samples / n; - } - - /* compute the marginalized likelihood ratio */ - for (j = 0; j != n_sigmas; ++j) - { - double kernel; - - - kernel = 0.5 / (sq(w[d]) + 1.0 / sq(sigmas[j])); - - for (i = 0; i != n; ++i) - { - buffer[i] = kernel * (sq(dft_out[i][0]) + sq(dft_out[i][1])); - } - p_sigma = XLALSkymapLogTotalExp(buffer, buffer + n) - log(sq(sigmas[j]) * sq(w[d]) + 1.0) - log(n); - p_sigmas[d] = XLALSkymapLogSumExp(p_sigmas[d], p_sigma); - } - /* the log odds that a waveform was added to a detector */ - p_sigmas[d] -= log(n_sigmas); - /* compute the log odds that a waveform was added to all detectors */ - p_detectors += XLALSkymapLogSumExp(p_sigmas, 0); - } - - p_detectors = XLALSkymapLogDifferenceExp(p_detectors, 0); - p_detectors -= log(7); - - printf(" %f %f %f %f\n", p_detectors, ((double) times[0][i_band])/rate, ((double) times[1][i_band])/rate, ((double) times[2][i_band])/rate); - - probabilities[i_band] = p_detectors; - widths[i_band] = width; - frequencies[i_band] = f; - used[i_band] = 0; - scores[i_band] = p_detectors / width; - - if (p_sigmas[1] > max(p_sigmas[0], p_sigmas[2])) - { - times[0][i_band] = times[1][i_band]; - } - if (p_sigmas[2] > max(p_sigmas[0], p_sigmas[1])) - { - times[0][i_band] = times[2][i_band]; - } - - ++i_band; - } - - fftw_destroy_plan(dft_backward); - free(buffer); - fftw_free(dft_out); - fftw_free(dft_in); - - } - - fclose(g); - - printf("\n -------- \n\n"); - - n_bands = i_band; - - g = fopen("used.dat", "wb"); - - /* sort the basis waveforms by peak power */ - index = (INT4*) malloc(sizeof(INT4) * n_bands); - XLALHeapIndex(index, scores, n_bands, sizeof(double), 0, less_double); - - /* work backwards from most powerful tile */ - accumulated_skymap = (double*) malloc(plan->pixelCount * sizeof(double)); - { - int i; - for (i = 0; i != plan->pixelCount; ++i) - { - accumulated_skymap[i] = 0.0; - } - } - accumulated_glitch = 0; - h = fopen("raw.dat", "wb"); - fwrite(thetaphi, sizeof(double), 2, h); - for (i_band = n_bands - 1; i_band >= 0; --i_band) - { - double *z_t[6]; - int f, i, d, time; - fftw_complex *dft_in; - fftw_complex *dft_out; - fftw_plan dft_backward; - int useable; - - width = widths [index[i_band]]; - f = frequencies[index[i_band]]; - time = times[0] [index[i_band]]; - - /* printf("with %d frequency %d time %d\n", width, f, time); */ - - if (probabilities[index[i_band]] > log(1)) - { - used[i_band] = 1; - for (i = i_band + 1; i < n_bands; ++i) - { - if (used[i]) - { - if (!((frequencies[index[i]] >= f + width) || (frequencies[index[i]] + widths[index[i]] <= f))) - { - used[i_band] = 0; - } - } - } - } - - if (used[i_band]) - { - - printf("[%d, %d) Hz time %f probability %f\n", f, f+width, ((double)time)/rate, probabilities[index[i_band]]); - - dft_in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - dft_out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - - dft_backward = fftw_plan_dft_1d(samples, dft_in, dft_out, FFTW_BACKWARD, FFTW_ESTIMATE); - - for (i = 0; i != samples; ++i) - { - dft_in[i][0] = 0.0; - dft_in[i][1] = 0.0; - } - - for (d = 0; d != 3; ++d) - { - double power; - double s; - s = sqrt(2 * rate / width) / sqrt(samples); - for (i = 0; i != width * duration; ++i) - { - dft_in[f * duration + i][0] = h_f[d][f * duration + i][0] * s; - dft_in[f * duration + i][1] = h_f[d][f * duration + i][1] * s; - } - fftw_execute(dft_backward); - z_t[d ] = (double*) malloc(sizeof(double) * samples); - z_t[d + 3] = (double*) malloc(sizeof(double) * samples); - power = 0; - for (i = 0; i != samples; ++i) - { - z_t[d ][i] = dft_out[i][0]; - z_t[d + 3][i] = dft_out[i][1]; - power += pow(dft_out[i][0], 2) + pow(dft_out[i][1], 2); - } - fwrite(z_t[d], sizeof(double), samples, g); - fwrite(z_t[d + 3], sizeof(double), samples, g); - power /= samples; - /* printf("mean(power) = %f =?= 2\n", power); */ - } - - /* we now have band-limited time series */ - - { - - int begin[3]; - int end[3]; - double* skymap[3]; - int n_sigmas = 3; - double sigmas[] = { sqrt(10), 10, sqrt(1000) }; - double g[3][3]; - double psignal; - double pglitch; - int k; - int *modes; - int *counts; - double c; - - modes = (int *) malloc(sizeof(int) * plan->pixelCount); - counts = (int *) malloc(sizeof(int) * plan->pixelCount); - - begin[0] = max(times[0][i_band] - (rate / 32), 0); - begin[1] = max(times[0][i_band] - (rate / 32), 0); - begin[2] = max(times[0][i_band] - (rate / 32), 0); - end[0] = min(times[0][i_band] + (rate / 32), samples); - end[1] = min(times[0][i_band] + (rate / 32), samples); - end[2] = min(times[0][i_band] + (rate / 32), samples); - - for (k = 0; k != n_sigmas; ++k) - { - skymap[k] = (double*) malloc(plan->pixelCount * sizeof(double)); - XLALSkymapSignalHypothesis(plan, skymap[k], sigmas[k], w, begin, end, z_t, counts, modes); - } - for (k = 1; k != n_sigmas; ++k) - { - XLALSkymapSum(plan, skymap[0], skymap[0], skymap[k]); - } - for (i = 0; i != plan->pixelCount; ++i) - { - skymap[0][i] -= log(n_sigmas); - } - - { - double* image; - /* printf("rendering image...\n"); */ - image = (double*) malloc(sizeof(double) * 1024 * 2048); - XLALSkymapRenderEqualArea(1024, 2048, image, plan, skymap[0]); - - /* printf("writing image...\n"); */ - fwrite(image, sizeof(double), 1024*2048, h); - free(image); - /* printf(" ...write complete\n"); */ - } - - for (i = 0; i != plan->pixelCount; ++i) - { - accumulated_skymap[i] += skymap[0][i]; - } - - c = 0; - for (i = 0; i != plan->pixelCount; ++i) - { - if (plan->pixel[i].area > 0) - { - c += plan->pixel[i].area * counts[i]; - } - } - - accumulated_signal = log(0); - for (i = 0; i != plan->pixelCount; ++i) - { - if (plan->pixel[i].area > 0) - { - accumulated_signal = XLALSkymapLogSumExp(accumulated_signal, - accumulated_skymap[i] + log(plan->pixel[i].area * counts[i] / c)); - } - } - - psignal = log(0); - for (i = 0; i != plan->pixelCount; ++i) - { - if (plan->pixel[i].area > 0) - { - psignal = XLALSkymapLogSumExp(psignal, - skymap[0][i] + log(plan->pixel[i].area * counts[i] / c)); - } - } - - - /* marginalize over glitch size too */ - for (k = 0; k != n_sigmas; ++k) - { - XLALSkymapGlitchHypothesis(plan, g[k], sigmas[k], w, begin, end, z_t); - } - for (k = 0; k != 3; ++k) - { - /* for each detector, marginalize over sigma */ - g[0][k] = XLALSkymapLogSumExp(g[0][k], XLALSkymapLogSumExp(g[1][k], g[2][k])); - } - - pglitch = - XLALSkymapLogDifferenceExp(XLALSkymapLogSumExp(0, g[0][0] - log(end[0] - begin[0])) + - XLALSkymapLogSumExp(0, g[0][1] - log(end[1] - begin[1])) + - XLALSkymapLogSumExp(0, g[0][2] - log(end[2] - begin[2])), 0) - log(7.0); - accumulated_glitch += pglitch; - - printf(" exp(%f) exp(%f)\n", (psignal - pglitch), (accumulated_signal - accumulated_glitch)); - - free(skymap[0]);free(skymap[1]);free(skymap[2]); - free(modes); - free(counts); - } - - /* free data */ - - for (d = 0; d != 6; ++d) - { - free(z_t[d]); - } - } /*else { printf(" VETO\n"); } */ - } - - fclose(h); - fclose(g); - - free_h_f(); - free_h_t(); - - return 0; - -} - -#endif -#if 0 - -RandomParams* rng_parameters; - -int duration; -int rate; - -int samples; - -double *strain[3]; - -XLALSkymapPlanType* plan; - -double sigma; - -fftw_complex *strain_tilde[3]; - -int limit; - -int band; -int window; - -double *filtered[6]; - -void make_data() -{ - int i, j; - for (i = 0; i != 3; ++i) - { - strain[i] = (double*) malloc(sizeof(double) * samples); - for (j = 0; j != samples; ++j) - { - strain[i][j] = XLALNormalDeviate(rng_parameters); - } - } -} - -void free_data() -{ - int i; - for (i = 0; i !=3; ++i) - { - free(strain[i]); - } -} - -int index_from_delays(XLALSkymapPlanType* plan, int hl, int hv, int hemisphere) -{ - return - (hl + plan->hl) + - (hv + plan->hv) * (plan->hl * 2 + 1) + - (hemisphere ) * (plan->hl * 2 + 1) * (plan->hv * 2 + 1); -} - -void add_injection() -{ - int i, j; - - double h[2]; - - /* for now, just inject perpendicular to network */ - - i = index_from_delays(plan, 0, 0, 0); - j = samples / 2; - - h[0] = sigma * XLALNormalDeviate(rng_parameters); // h+ - h[1] = sigma * XLALNormalDeviate(rng_parameters); // hx - - // hs = s+ + sx - strain[0][j] += plan->pixel[i].f[0][0] * h[0] + plan->pixel[i].f[0][1] * h[1]; - strain[1][j] += plan->pixel[i].f[1][0] * h[0] + plan->pixel[i].f[1][1] * h[1]; - strain[2][j] += plan->pixel[i].f[2][0] * h[0] + plan->pixel[i].f[2][1] * h[1]; - -} - -void make_strain_tilde() -{ - int i, j; - - fftw_complex *dft_in; - fftw_complex *dft_out; - fftw_plan dft_forward; - - dft_in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - dft_out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - - dft_forward = fftw_plan_dft_1d(samples, dft_in, dft_out, FFTW_FORWARD, FFTW_ESTIMATE); - - for (i = 0; i != 3; ++i) - { - for (j = 0; j != samples; ++j) - { - dft_in[j][0] = strain[i][j]; - dft_in[j][1] = 0.; - } - fftw_execute(dft_forward); - strain_tilde[i] = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - for (j = 0; j != samples; ++j) - { - strain_tilde[i][j][0] = dft_out[j][0]; - strain_tilde[i][j][1] = dft_out[j][1]; - } - } - - fftw_destroy_plan(dft_forward); - fftw_free(dft_out); - fftw_free(dft_in); - -} - -void free_strain_tilde() -{ - int i; - for (i = 0; i != 3; ++i) - { - fftw_free(strain_tilde[i]); - } -} - -void make_filtered(int k) -{ - int i, j; - fftw_complex *dft_in; - fftw_complex *dft_out; - fftw_plan dft_backward; - - printf("window %d...\n", k); - - dft_in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - dft_out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * samples); - - dft_backward = fftw_plan_dft_1d(samples, dft_in, dft_out, FFTW_BACKWARD, FFTW_ESTIMATE); - - for (i = 0; i != 3; ++i) - { - double power; - double total_power; - double max_power; - for (j = 0; j != samples; ++j) - { - dft_in[j][0] = 0.0; - dft_in[j][1] = 0.0; - } - for (j = k * window; j != (k + 1) * window; ++j) - { - dft_in[j][0] = strain_tilde[i][j][0]; - dft_in[j][1] = strain_tilde[i][j][1]; - } - fftw_execute(dft_backward); - filtered[i] = (double*) malloc(sizeof(double) * samples); - filtered[i + 3] = (double*) malloc(sizeof(double) * samples); - total_power = 0; - max_power = 0; - for (j = 0; j != samples; ++j) - { - filtered[i][j] = dft_out[j][0] / samples * sqrt(rate/band); - filtered[i + 3][j] = dft_out[j][1] / samples * sqrt(rate/band); - power = pow(filtered[i][j], 2) + pow(filtered[i + 3][j], 2); - total_power += power; - if ((j > samples / 4) && (j < 3 * samples / 4) && (power > max_power)) - { - max_power = power; - } - } - total_power /= samples; - printf("mean(power) = %f, sqrt(max(power)) = %f\n", total_power, sqrt(max_power)); - } - - fftw_destroy_plan(dft_backward); - fftw_free(dft_out); - fftw_free(dft_in); -} - -void free_filtered() -{ - int i; - for (i = 0; i != 6; ++i) - { - free(filtered[i]); - } -} - -int main(int argc, char** argv) -{ - FILE *h, *g; - - rng_parameters = XLALCreateRandomParams(0); - - duration = 1; - rate = 4096; - - samples = duration * rate; - - make_data(); - - plan = XLALSkymapConstructPlan(rate); - - /* inject a signal */ - - sigma = 60.; /* get an SNR of 10 in each of 32 bands? */ - add_injection(); - sigma = 10; - - /* take to frequency domain */ - make_strain_tilde(); - - /* process */ - limit = 1024; /* Hz */ - band = 64; /* Hz */ - window = band * duration; - - h = fopen("raw.dat", "wb"); - g = fopen("bands.dat", "wb"); - - { - int k; - for (k = 0; k != limit / band; ++k) - { - double *skymap, *image; - int begin[3]; - int end[3]; - double w[3]; - - make_filtered(k); - - { - int gi; - for (gi = 0; gi != 6; ++gi) - { - fwrite(filtered[gi], sizeof(double), samples, g); - } - } - - w[0] = 1; - w[1] = 1; - w[2] = 1; - begin[0] = samples / 2 - rate / 32; - begin[1] = begin[0]; - begin[2] = begin[0]; - end[0] = samples / 2 + rate / 32; - end[1] = end[0]; - end[2] = end[0]; - - printf("samples [%d, %d)\n", begin[0], end[0]); - - skymap = (double*) malloc(plan->pixelCount * sizeof(double)); - XLALSkymapEllipticalHypothesis(plan, skymap, sigma, w, begin, end, filtered, 0); - - image = (double*) malloc(sizeof(double) * 1024 * 2048); - XLALSkymapRenderEqualArea(1024, 2048, image, plan, skymap); - - printf("writing image...\n"); - fwrite(image, sizeof(double), 1024*2048, h); - printf(" ...write complete\n"); - - free(image); - free(skymap); - free_filtered(); - } - } - - fclose(g); - fclose(h); - - free_strain_tilde(); - XLALSkymapDestroyPlan(plan); - free_data(); - XLALDestroyRandomParams(rng_parameters); - - return 0; -} - -#endif - -#if 0 - -static void make_data(double** z, int samples) -{ - int i; - int j; - RandomParams* params; - params = XLALCreateRandomParams(0); - for (i = 0; i != 6; ++i) - { - z[i] = (double*) malloc(samples * sizeof(double)); - for (j = 0; j != samples; ++j) - { - z[i][j] = XLALNormalDeviate(params); - } - } - XLALDestroyRandomParams(params); -} - -static void free_data(double** z) -{ - int i; - for (i = 0; i != 6; ++i) - { - free(z[i]); - } -} - -static int index_from_delays(XLALSkymapPlanType* plan, int hl, int hv, int hemisphere) -{ - return - (hl + plan->hl) + - (hv + plan->hv) * (plan->hl * 2 + 1) + - (hemisphere ) * (plan->hl * 2 + 1) * (plan->hv * 2 + 1); -} - -void make_injection(XLALSkymapPlanType* plan, double** z, int samples, double sigma) -{ - int i, j; - RandomParams* params; - double h[4]; - double theta, phi; - params = XLALCreateRandomParams(0); - - theta = acos(XLALUniformDeviate(params) * 2 - 1); - phi = LAL_TWOPI * XLALUniformDeviate(params); - - /* for now, just inject perpendicular to network */ - - i = index_from_delays(plan, 0, 0, 0); - j = samples / 2; - - h[0] = sigma * XLALNormalDeviate(params); // s+ - h[1] = sigma * XLALNormalDeviate(params); // sx - h[2] = sigma * XLALNormalDeviate(params); // c+ - h[3] = sigma * XLALNormalDeviate(params); // cx - - // hs = s+ + sx - z[0][j] += plan->pixel[i].f[0][0] * h[0] + plan->pixel[i].f[0][1] * h[1]; - z[1][j] += plan->pixel[i].f[1][0] * h[0] + plan->pixel[i].f[1][1] * h[1]; - z[2][j] += plan->pixel[i].f[2][0] * h[0] + plan->pixel[i].f[2][1] * h[1]; - z[3][j] += plan->pixel[i].f[0][0] * h[2] + plan->pixel[i].f[0][1] * h[3]; - z[4][j] += plan->pixel[i].f[1][0] * h[2] + plan->pixel[i].f[1][1] * h[3]; - z[5][j] += plan->pixel[i].f[2][0] * h[2] + plan->pixel[i].f[2][1] * h[3]; - - XLALDestroyRandomParams(params); -} - -void make_glitch(XLALSkymapPlanType* plan, double** z, int samples, double sigma) -{ - int i, t[3]; - RandomParams* params; - params = XLALCreateRandomParams(0); - - i = (rand() % 7) + 1; - - t[0] = rand() % samples; - t[1] = rand() % samples; - t[2] = rand() % samples; - - if (i & 1) - { - z[0][t[0]] += sigma * XLALNormalDeviate(params); - z[3][t[0]] += sigma * XLALNormalDeviate(params); - } - if (i & 2) - { - z[1][t[1]] += sigma * XLALNormalDeviate(params); - z[4][t[1]] += sigma * XLALNormalDeviate(params); - } - if (i & 4) - { - z[2][t[2]] += sigma * XLALNormalDeviate(params); - z[5][t[2]] += sigma * XLALNormalDeviate(params); - } - - XLALDestroyRandomParams(params); -} - -int lose_data(double **z) -{ - int i; - i = rand() & 7; - if (i & 1) - { - free(z[0]); free(z[3]); - z[0] = 0; z[3] = 0; - } - if (i & 2) - { - free(z[1]); free(z[4]); - z[1] = 0; z[4] = 0; - } - if (i & 4) - { - free(z[2]); free(z[5]); - z[2] = 0; z[5] = 0; - } - return i; -} - -int less_double(void *p, const void *a, const void *b) -{ - if (*((double*) a) < *((double*) b)) - { - return -1; - } - else - { - if (*((double*) a) > *((double*) b)) - { - return 1; - } - else - { - return 0; - } - } -} -void test_XLALHeapIndex() -{ - int n; - double* p; - INT4* i; - int j; - - n = 10; - p = (double*) malloc(sizeof(double) * n); - for (j = 0; j != n; ++j) - p[j] = -j; - - i = (INT4*) malloc(sizeof(INT4) * n); - - XLALHeapIndex(i, p, n, sizeof(double), 0, less_double); - - printf("Unsorted\t'Sorted'\n"); - for(j = 0; j != n; ++j) - printf("%f\t%f\n", p[j], p[i[j]]); -} - -void skymap_index(XLALSkymapPlanType* plan, double* skymap, INT4** pindex) -{ - *pindex = (INT4*) malloc(sizeof(INT4) * plan->pixelCount); - XLALHeapIndex(*pindex, skymap, plan->pixelCount, sizeof(double), 0, less_double); -} - -void cluster_test_raw() -{ - RandomParams* params; - fftw_complex* dft_in; - fftw_complex* dft_out; - fftw_plan dft_forward; - fftw_plan dft_backward; - int f; - int t; - int i, j; - int n; - FILE* h; - double* x; - fftw_complex* y; - int window; - - params = XLALCreateRandomParams(0); - - f = 8192; - t = 1; - n = t * f; - - x = (double*) malloc(sizeof(double) * n); - y = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); - - dft_in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); - dft_out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); - - dft_forward = fftw_plan_dft_1d(n, dft_in, dft_out, FFTW_FORWARD, FFTW_ESTIMATE); - dft_backward = fftw_plan_dft_1d(n, dft_in, dft_out, FFTW_BACKWARD, FFTW_ESTIMATE); - - /* construct the data */ - for (i = 0; i != n; ++i) - { - x[i] = 0.0; /*XLALNormalDeviate(params); */ - } - x[n/2] = 1.0; - - /* transform the data to the frequency domain */ - for (i = 0; i != n; ++i) - { - dft_in[i][0] = x[i]; - dft_in[i][1] = 0.0; - } - fftw_execute(dft_forward); - for (i = 0; i != n; ++i) - { - y[i][0] = dft_out[i][0]; - y[i][1] = dft_out[i][1]; - } - h = fopen("dump.dat", "wb"); - /* window and inverse transform the data */ - window = 4096 / 16; - for (j = 0; j < (n / 2); j += window) - { - printf("%d\n", j); - /* zero the input array */ - for (i = 0; i != n; ++i) - { - dft_in[i][0] = 0.0; - dft_in[i][1] = 0.0; - } - /* copy over a frequency window */ - for (i = j; i != j + window; ++i) - { - dft_in[i][0] = y[i][0]; - dft_in[i][1] = y[i][1]; - } - /* inverse transform */ - fftw_execute(dft_backward); - /* write the output */ - fwrite(dft_out, sizeof(fftw_complex), n, h); - } - - fclose(h); - - fftw_destroy_plan(dft_forward); - fftw_destroy_plan(dft_backward); - fftw_free(dft_in); - fftw_free(dft_out); - fftw_free(y); - free(x); - -} - -void cluster_test() -{ - int duration; - int rate; - int n; - double *x[3]; - - duration = 1; - rate = 4096; - n = duration * rate; - - { - int i; - for (i = 0; i != 3; ++i) - { - x[i] = (double*) malloc(sizeof(double) * n); - for (j = 0; j != n; ++j) - { - x[i][j] = - } - } - } - - -} - -int main(int argc, char** argv) -{ - XLALSkymapPlanType* plan; - double* raw; - double* z[6]; - double w[3] = { 1, 1, 1}; - double sigma = 10; - int samples = 512; - FILE* h; - int i; - int begin[3] = { 0, 0, 0 }; - int end[3] = { 512, 512, 512 }; - double* image; - int f = 8192; /* Hz */ - int bests[5]; - double g[3]; - double marginalizedSkymap; - double marginalizedGlitch; - int trial, trials; - int activeDetectors; - trials = 100; - - /* test_XLALHeapIndex(); - return 0; */ - - cluster_test(); - return 0; - - printf("constructing plan...\n"); - plan = XLALSkymapConstructPlan(f); - - printf("Sigma = %f\n", sigma); - printf("Injctn p(Noise)+p(Gltch)+p(Signl)=1.00 log(p(Gltch),p(Signl))/p(Noise)\n"); - - for (trial = 0; trial < trials; ++trial) - { - int injection_type; - - srand(time(0)); - - make_data(z, samples); - - /* printf("injecting signal or glitch...\n"); */ - - injection_type = rand() % 3; - - switch (injection_type) - { - case 0: - printf("None "); - break; - case 1: - printf("Glitch"); - make_glitch(plan, z, samples, sigma); - break; - case 2: - printf("Signal"); - make_injection(plan, z, samples, sigma); - break; - } - - /* drop virgo */ - /* z[2] = 0; z[5] = 0; */ - /* drop livingston */ - /* z[1] = 0; z[4] = 0; */ - /* printf("%d:", lose_data(z)); */ - printf(": "); - - /* printf("computing skymap...\n"); */ - raw = (double*) malloc(plan->pixelCount * sizeof(double)); - XLALSkymapEllipticalHypothesis(plan, raw, sigma, w, begin, end, z, bests); - - /* printf("marginalizing over skymap...\n"); */ - marginalizedSkymap = log(0); - for (i = 0; i != plan->pixelCount; ++i) - { - marginalizedSkymap = XLALSkymapLogSumExp(marginalizedSkymap, raw[i]); - } - /* printf("Marginalized skymap = %f\n", marginalizedSkymap); */ - /* normalize by the hypothesis count */ - /*printf("Hypothesis count normalization %f - %f\n", marginalizedSkymap, log(bests[4])); - marginalizedSkymap -= log(bests[4]);*/ - - /* printf("computing glitch posterior...\n"); */ - XLALSkymapGlitchHypothesis(plan, g, sigma, w, begin, end, z); - - /* printf("Glitch %f %f %f %f\n", g[0], g[1], g[2], log(samples)); */ - - marginalizedGlitch = 0; - activeDetectors = 0; - if (z[0]) - { - marginalizedGlitch += XLALSkymapLogSumExp(0, g[0] - log(samples)) - log(2); - ++activeDetectors; - } - if (z[1]) - { - marginalizedGlitch += XLALSkymapLogSumExp(0, g[1] - log(samples)) - log(2); - ++activeDetectors; - } - if (z[2]) - { - marginalizedGlitch += XLALSkymapLogSumExp(0, g[2] - log(samples)) - log(2); - ++activeDetectors; - } - /* remove the signal hypothesis */ - /* marginalizedGlitch = log(exp(marginalizedGlitch) - 0.125) + log(8) - log(7); */ - /* marginalizedGlitch = XLALSkymapLogDifferenceExp(marginalizedGlitch, log(0.125)) + log(8) - log(7); */ - marginalizedGlitch = XLALSkymapLogDifferenceExp(marginalizedGlitch, -log(pow(2,activeDetectors))) + log(pow(2,activeDetectors)) - log(pow(2,activeDetectors) - 1); - - /* printf("Signal %f - Glitch %f\n", marginalizedSkymap, marginalizedGlitch); */ - /* printf("%e %s %e", marginalizedSkymap, (marginalizedSkymap > marginalizedGlitch) ? ">" : "<", marginalizedGlitch); */ - - { - double p[3]; - p[0] = 1 / (1 + exp(marginalizedSkymap) + exp(marginalizedGlitch)); - p[1] = 1 / (exp(-marginalizedGlitch) + 1 + exp(marginalizedSkymap - marginalizedGlitch)); - p[2] = 1 / (exp(-marginalizedSkymap) + exp(marginalizedGlitch - marginalizedSkymap) + 1); - printf("%f %f %f", p[0], p[1], p[2]); - - if (p[0] > max(p[1], p[2])) - { - if (p[0] > 0.95) - { - printf(injection_type == 0 ? " PASS" : " FAIL"); - } - else - { - printf(" WEAK"); - } - } - if (p[1] > max(p[0], p[2])) - { - if (p[1] > 0.95) - { - printf(injection_type == 1 ? " PASS" : " FAIL"); - } - else - { - printf(" WEAK"); - } - } - if (p[2] > max(p[1], p[0])) - { - if (p[2] > 0.95) - { - printf(injection_type == 2 ? " PASS" : " FAIL"); - } - else - { - printf(" WEAK"); - } - } - } - - printf(" (%f, %f)\n", marginalizedGlitch, marginalizedSkymap); - - /* - printf("writing directions...\n"); - h = fopen("out.txt", "wt"); - for (i = 0; i != plan->pixelCount; ++i) - { - if (plan->pixel[i].area > 0) - { - fprintf(h, "%f %f %f\n", plan->pixel[i].direction[0], plan->pixel[i].direction[1], plan->pixel[i].direction[2]); - } - } - fclose(h); - */ - - { - /* compute confidence region */ - INT4 *index; - double total_p; - double total_area; - int i; - - skymap_index(plan, raw, &index); - - total_p = log(0); - total_area = 0; - i = plan->pixelCount - 1; - while (total_p < marginalizedSkymap - log(2)) - { - total_p = XLALSkymapLogSumExp(total_p, raw[index[i]]); - total_area += plan->pixel[index[i]].area; - --i; - } - - printf(" %f confidence region area = %f\n", exp(total_p - marginalizedSkymap), total_area); - - free(index); - } - - - if (injection_type == 2) - { - printf("rendering image...\n"); - image = (double*) malloc(sizeof(double) * 1024 * 2048); - XLALSkymapRenderEqualArea(1024, 2048, image, plan, raw); - - printf("writing image...\n"); - h = fopen("raw.dat", "wb"); - fwrite(image, sizeof(double), 1024*2048, h); - fclose(h); - free(image); - printf(" ...write complete\n"); - } - - /* printf("cleanup...\n"); */ - free(raw); - /* leak the data ? */ - free_data(z); - - } - - XLALSkymapDestroyPlan(plan); - - return 0; -} -#endif diff --git a/lal/packages/clremoval/src/RefInterference.c b/lal/packages/clremoval/src/RefInterference.c index 48af1bccd768b32e2fd25e9973f240a951443126..04acfac9b913340f0498d0b719f44412611cd7de 100644 --- a/lal/packages/clremoval/src/RefInterference.c +++ b/lal/packages/clremoval/src/RefInterference.c @@ -215,7 +215,9 @@ void LALRefInterference (LALStatus *status, TRY(LALCCreateVector(status->statusPtr, &snum, n), status); - TRY(LALCreateReverseComplexFFTPlan(status->statusPtr, &pinv, n, 0), status); + pinv = XLALCreateReverseCOMPLEX8FFTPlan(n, 0); + if (pinv == NULL) + ABORTXLAL(status); /* ------------------------------------------- */ /* ------------------------------------------- */ @@ -261,7 +263,8 @@ void LALRefInterference (LALStatus *status, } /* Calculate z_k(t) by performing FFTs */ - TRY(LALCOMPLEX8VectorFFT(status->statusPtr,zt, zf, pinv), status); + if (XLALCOMPLEX8VectorFFT(zt, zf, pinv) != 0) + ABORTXLAL(status); /* calculate invarb, B_k(1)(t) and initializes sden and snum */ @@ -376,7 +379,8 @@ void LALRefInterference (LALStatus *status, } /* Calculate z_k(t) by performing FFTs */ - TRY(LALCOMPLEX8VectorFFT(status->statusPtr,zt, zf, pinv), status); + if (XLALCOMPLEX8VectorFFT(zt, zf, pinv) != 0) + ABORTXLAL(status); /* calculate invarb, B_k(t) */ @@ -490,7 +494,7 @@ void LALRefInterference (LALStatus *status, TRY(LALZDestroyVector(status->statusPtr, &b1t), status); TRY(LALCDestroyVector(status->statusPtr, &snum), status); - TRY(LALDestroyComplexFFTPlan(status->statusPtr, &pinv), status); + XLALDestroyCOMPLEX8FFTPlan(pinv); /* ------------------------------------------- */ diff --git a/lal/packages/date/include/Date.h b/lal/packages/date/include/Date.h index 0d3f5e8fe7eef70f5529204bcb9917b547430901..ed4323f8687b0fc97fb188845f23a39f8bc4bd60 100644 --- a/lal/packages/date/include/Date.h +++ b/lal/packages/date/include/Date.h @@ -272,36 +272,6 @@ LIGOTimeGPS *XLALGreenwichSiderealTimeToGPS( </lalLaTeX> */ -/* <lalLaTeX> - -\subsection*{Types} - -\subsubsection*{Enumeration \texttt{LALMSTUnits}} -\idx[Type]{LALMSTUnits} - -This enumerated type is used as a parameter for Mean Sidereal Time -routines to specify the units in which to return the Mean Sidereal -Time. The allowed values are: - -\medskip\noindent -\begin{tabular}{ll} - \verb+MST_SEC+ & arc-seconds \\ - \verb+MST_HRS+ & arc-hours (\textit{i.e.} units of Right Ascension)\\ - \verb+MST_DEG+ & degrees \\ - \verb+MST_RAD+ & radians -\end{tabular} -\bigskip - -</lalLaTeX> */ - -typedef enum -{ - MST_SEC, /* arc seconds */ - MST_HRS, /* arc hours (i.e. units of Right Ascension) */ - MST_DEG, /* degrees */ - MST_RAD /* radians */ -} LALMSTUnits; - /* <lalLaTeX> \subsubsection*{Enumeration \texttt{LALMonth}} \idx[Type]{LALMonth} @@ -349,9 +319,9 @@ typedef enum \subsubsection*{Enumeration \texttt{LALLeapSecAccuracy}} \idx[Type]{LALLeapSecAccuracy} -This enumerated type is used as a parameter for \texttt{LALGPStoUTC()}, -\texttt{LALUTCtoGPS()}, and \texttt{LALLeapSecs()} to specify if complete -accuracy is required in use of leap seconds. The allowed values are: +This enumerated type is used as a parameter for \texttt{LALLeapSecs()} to +specify if complete accuracy is required in use of leap seconds. The +allowed values are: \medskip\noindent \begin{tabular}{ll} @@ -576,23 +546,6 @@ tagLALLeapSecFormatAndAcc LALLeapSecFormatAndAcc; -/* <lalLaTeX> -\subsubsection{Structure \texttt{LALMSTUnitsAndAcc}} -\index[Type]{LALMSTUnitsAndAcc} - -This structure aggregates the \texttt{LALMSTUnits} and -\texttt{LALLeapSecAccuracy} parameters for passing to -\texttt{LALGPStoGMST1()}. -</lalLaTeX> */ -typedef struct -tagLALMSTUnitsAndAcc -{ - LALMSTUnits units; - LALLeapSecAccuracy accuracy; -} -LALMSTUnitsAndAcc; - - /* * Function prototypes @@ -601,41 +554,10 @@ LALMSTUnitsAndAcc; int XLALStrToGPS(LIGOTimeGPS *t, const char *nptr, char **endptr); char *XLALGPSToStr(char *, const LIGOTimeGPS *t); -/* <lalLaTeX> -\newpage\input{DateStringC} -</lalLaTeX> */ - -void LALDateString (LALStatus *status, - CHARVector *timestamp, - const LALDate *date); - - -/* <lalLaTeX> -\newpage\input{LMST1C} -</lalLaTeX> */ - -void LALGPStoGMST1( LALStatus *status, - REAL8 *gmst, /* output - GMST1 */ - const LIGOTimeGPS *gps, /* input - GPS time */ - const LALMSTUnitsAndAcc *pUnitsAndAcc); /* GMST1 units and - leapsec accuracy */ /* <lalLaTeX> \newpage\input{GPStoUTCC} </lalLaTeX> */ -void -LALGPStoUTC (LALStatus *status, - LALDate *pUtcDate, - const LIGOTimeGPS *pGpsTime, - const LALLeapSecAccuracy *pAccuracy); - -void -LALUTCtoGPS (LALStatus *status, - LIGOTimeGPS *pGpsTime, - const LALDate *pUtcDate, - const LALLeapSecAccuracy *pAccuracy); - - void LALLeapSecs (LALStatus *status, INT4 *p_leapSecs, @@ -691,21 +613,11 @@ LALCompareGPS (LALStatus *status, const LIGOTimeGPS *pGPS2); /* input: GPS2 */ /* This function returns the current GPS time according to the system clock */ -/* <lalLaTeX> -\newpage\input{GPSTimeNowC} -</lalLaTeX> */ LIGOTimeGPS * XLALGPSTimeNow ( LIGOTimeGPS *gpstime ); -void -LALGPSTimeNow ( - LALStatus *status, - LIGOTimeGPS *gpstime, - const LALLeapSecAccuracy *accuracy - ); - /* <lalLaTeX> \newpage\input{PlaygroundC} </lalLaTeX> */ diff --git a/lal/packages/date/src/GPSTimeNow.c b/lal/packages/date/src/GPSTimeNow.c index 29fea2461d9f22b9d3788deaf53418d7bae34aa0..cfd1e79853686abe22ad217b539a61092c771a13 100644 --- a/lal/packages/date/src/GPSTimeNow.c +++ b/lal/packages/date/src/GPSTimeNow.c @@ -19,55 +19,32 @@ */ -#if 0 -<lalVerbatim file="GPSTimeNowCV"> -Author: Duncan Brown -$Id$ -</lalVerbatim> - -<lalLaTeX> -\subsection{Module \texttt{GPSTimeNow.c}} -\label{ss:GPSTimeNow.c} - -Routine to convert the current unix system clock time into a -\texttt{LIGOTimeGPS} structure. - -\subsection*{Prototypes} -\vspace{0.1in} -\input{GPSTimeNowCP} -\idx{LALGPSTimeNow()} - -\subsubsection*{Description} - -This module contains a single funtion that converts the current unix system -time as returned by the \texttt{time()} function to GPS seconds. The leap -second accuracy is determined by the \texttt{accuracy} argument. - -\subsubsection*{Algorithm} - -\subsubsection*{Uses} - -\subsubsection*{Notes} - -If the system clock time is incorect, the returned GPS time will obviously be -wrong by the same amount. - -\vfill{\footnotesize\input{GPSTimeNowCV}} -</lalLaTeX> -#endif - #include <time.h> #include <lal/Date.h> #include <lal/XLALError.h> + NRCSID( GPSTIMENOWC, "$Id$" ); -/* <lalVerbatim file="GPSTimeNowCP"> */ + +/** + * Populate the LIGOTimeGPS argument with the current system time as + * returned by time(2) converted to GPS seconds. Returns the address of + * the LIGOTimeGPS argument or NULL on error. On error, the GPS time is + * undefined. + * + * Bugs: + * + * This function cannot return negative GPS times. If the current system + * time indicates a time prior to Sun Jan 06 00:00:00 GMT 1980, this + * function returns NULL. + */ + + LIGOTimeGPS * XLALGPSTimeNow ( LIGOTimeGPS *gpstime ) -/* </lalVerbatim> */ { static const char func[] = "XLALGPSTimeNow"; time_t ticks = time(NULL); @@ -75,33 +52,13 @@ XLALGPSTimeNow ( gpstime->gpsSeconds = XLALUTCToGPS(gmtime(&ticks)); gpstime->gpsNanoSeconds = 0; - /* XLALUTCToGPS returns < 0 on error, even though of course time did not - * begin at GPS 0 */ + /* + * XLALUTCToGPS returns < 0 on error, even though of course time did not + * begin at GPS 0 + */ + if(gpstime->gpsSeconds < 0) XLAL_ERROR_NULL(func, XLAL_EFUNC); return gpstime; } - - -/* <lalVerbatim file="GPSTimeNowCP"> */ -void -LALGPSTimeNow ( - LALStatus *status, - LIGOTimeGPS *gpstime, - const LALLeapSecAccuracy *accuracy - ) -/* </lalVerbatim> */ -{ - INITSTATUS( status, "LALGPSTimeNow", GPSTIMENOWC ); - ATTATCHSTATUSPTR( status ); - ASSERT( gpstime, status, DATEH_ENULLOUTPUT, DATEH_MSGENULLOUTPUT ); - ASSERT( accuracy, status, DATEH_ENULLINPUT, DATEH_MSGENULLINPUT ); - - ASSERT( XLALGPSTimeNow(gpstime), status, DATEH_EDATETOOEARLY, DATEH_MSGEDATETOOEARLY ); - - XLALPrintDeprecationWarning("LALGPSTimeNow", "XLALGPSTimeNow"); - - DETATCHSTATUSPTR( status ); - RETURN( status ); -} diff --git a/lal/packages/date/src/GPStoUTC.c b/lal/packages/date/src/GPStoUTC.c index 587fec130c2784c0d5fd4f4cbc3432d3df138367..54d4d77304075f837d9e3fe58377b7022da1276a 100644 --- a/lal/packages/date/src/GPStoUTC.c +++ b/lal/packages/date/src/GPStoUTC.c @@ -32,39 +32,16 @@ Converts between GPS time (in seconds and nanoseconds) and UTC in a \subsection*{Prototypes} \vspace{0.1in} \input{GPStoUTCCP} -\idx{LALGPStoUTC()} -\idx{LALUTCtoGPS()} \idx{LALLeapSecs()} \subsubsection*{Description} -\texttt{LALGPStoUTC()} and \texttt{LALUTCtoGPS} convert time in GPS seconds -and nanoseconds (\texttt{LIGOTimeGPS}) and time in UTC (\texttt{LALDate}), -taking into account leap seconds until 2006-Dec-31 23:59:59 UTC. % UPDATEME % - \texttt{LALLeapSecs()} returns the number of leap seconds introduced since the GPS epoch 1980-Jan-06, abbreviated GPS-UTC. \subsubsection*{Algorithms} -The conversion from GPS to UTC is copied directly from -GRASP~\cite{grasp:194}. It does the conversion by counting TAI seconds -starting from the Unix epoch origin, 1970-Jan-01 00:00:00 UTC. A static -table of leap seconds is compiled in: this \emph{must} be updated whenever -a new leap second is introduced. The latest leap second included is -2006-Jan-01. % UPDATEME % - -The conversion from UTC to GPS is done by counting the amount of elapsed -time since the GPS epoch origin, 1980-Jan-06 00:00:00 UTC. Again, leap -seconds are accounted for by a static table (different from the one used in -GPS to UTC) which \emph{must} be updated whenever a new leap second is -introduced. The latest leap second included is 2006-Jan-01. % UPDATEME % - -The computation of GPS-UTC is from a static table published by the USNO -at \url{ftp://maia.usno.navy.mil/ser7/tai-utc.dat}. The latest leap second -included is 2006-Jan-01. % UPDATEME % - \subsubsection*{Uses} \subsubsection*{Notes} @@ -74,47 +51,6 @@ These routines will not work for times before 1980-01-06 00:00:00 UTC (GPS the end of 2005-Dec. % UPDATEME % These routines have accurate leap second information until 2006-Dec-31. % UPDATEME % -\textbf{Example:} To convert a GPS time to UTC, and then back to GPS: - -\begin{verbatim} - -#include <lal/LALStdlib.h> -#include <lal/Date.h> - -struct tm *gmtime_r( const time_t *, struct tm * ); -char *asctime_r( const struct tm *, char *, int ); - -int main(int argc, char *argv[]) -{ - static LALStatus status; - LIGOTimeGPS gps = {615081613, 123456789}; - LALDate date; - LALLeapSecAccuracy accuracy = LALLEAPSEC_STRICT; - CHARVector *timestamp = NULL; - - LALCHARCreateVector(&status, ×tamp, (UINT4)128); - - LALGPStoUTC(&status, &date, &gps, &accuracy); - - LALDateString(&status, timestamp, &date); - - printf("GPS (%d, %d) = %s\n", gps.gpsSeconds, gps.gpsNanoSeconds, - timestamp->data); - - LALUTCtoGPS(&status, &gps, &date, &accuracy); - - printf("%s = GPS (%d, %d)\n", timestamp->data, gps.gpsSeconds, - gps.gpsNanoSeconds); - - return 0; -} - -\end{verbatim} - -For an example of how \texttt{LALLeapSecs()} is used, see the test program -\texttt{TestLeapSecs.c} in the \texttt{packages/date/test} directory. - - </lalLaTeX> */ #include <lal/LALRCSID.h> @@ -123,14 +59,10 @@ NRCSID (GPSTOUTCC, "$Id$"); #include <lal/LALStdio.h> #include <lal/Date.h> -#include "date_value.h" #include <lal/XLALError.h> #define INFOSTR_LEN 256 -struct tm *gmtime_r( const time_t *, struct tm * ); -char *asctime_r( const struct tm *, char * ); - /* UPDATEME */ /* The international earth rotation service announces leap seconds; @@ -145,473 +77,6 @@ char *asctime_r( const struct tm *, char * ); /* GPS for maxtestedGPS computed using lalapps_tconvert (part of ligotools) */ static const INT4 maxtestedGPS = 851644813; -/* - * Convert GPS seconds to UTC date-time contained in LALDate structure - */ -/* <lalVerbatim file="GPStoUTCCP"> */ -void -LALGPStoUTC (LALStatus *status, - LALDate *p_utcDate, /* output - date */ - const LIGOTimeGPS *p_gpsTime, /* input - GPS seconds */ - const LALLeapSecAccuracy *p_accuracy) /* accuracy of - leap-second - accounting: - LALLEAPSEC_LOOSE, or LALLEAPSEC_STRICT */ -{ /* </lalVerbatim> */ - /* UPDATEME -- to update, add an entry at the end listing - * the Unix epoch time when a leap second is introduced */ - /* this is a table of Unix epoch times when leap - * seconds were introduced */ - /* What's the funny format? These Unix epoch times are expressed - * in terms of Julian Day Numbers, i.e. say JD1 = Julian Day number - * of the day when a leap sec was added, JD0 = Unix epoch origin (i.e. 1970-01-01), - * then the Unix epoch time is given by - * (JD1 - JD0) * SECS_PER_DAY - * FIXME: at some point, we should just dispense with this wacky Julian Day - * stuff. It's just confusing. */ - /* As of 2005-07-05 08:05 UTC-4, Bulletin C has been released, but the Naval - * Observatory's tai-utc.dat hasn't been updated. --dwchin */ - static const time_t leaps[] = { - 0, - 33350400, - 63072000, - 78796800, - 94694400, - 126230400, - 157766400, - 189302400, - 220924800, - 252460800, - 283996800, - 315532800, - 362793600, - 394329600, - 425865600, - 489024000, - 567993600, - 631152000, - 662688000, - 709948800, - 741484800, - 773020800, - 820454400, - 867715200, - 915148800, - 1136073600, - }; - - /* number of times leap seconds occur */ - static const INT4 numleaps = sizeof(leaps)/sizeof(time_t); - time_t unixTime; - time_t tmptime; - LALUnixDate tmputc; - char tmpstamp[32]; - CHAR infostr[INFOSTR_LEN]; - INT4 i; - - INITSTATUS (status, "LALGPStoUTC", GPSTOUTCC); - - ASSERT (p_gpsTime != (LIGOTimeGPS *)NULL, status, - DATEH_ENULLINPUT, DATEH_MSGENULLINPUT); - - ASSERT (p_gpsTime->gpsSeconds >= 0, status, - DATEH_ERANGEGPSABS, DATEH_MSGERANGEGPSABS); - - ASSERT (p_accuracy != (LALLeapSecAccuracy *)NULL, status, - DATEH_ENULLINPUT, DATEH_MSGENULLINPUT); - - ASSERT ((*p_accuracy == LALLEAPSEC_STRICT || - *p_accuracy == LALLEAPSEC_LOOSE), status, - DATEH_EACCPARAMOUTOFRANGE, DATEH_MSGEACCPARAMOUTOFRANGE); - - ASSERT (p_utcDate != (LALDate *)NULL, status, - DATEH_ENULLOUTPUT, DATEH_MSGENULLOUTPUT); - - XLALPrintDeprecationWarning("LALGPStoUTC", "XLALGPSToUTC"); - - /* we use Unix epoch as our origin */ - unixTime = p_gpsTime->gpsSeconds + UNIXGPS; - - if (lalDebugLevel & LALINFO) - { - snprintf(infostr, INFOSTR_LEN, "Max. tested GPS is %d\n", maxtestedGPS); - LALInfo(status, infostr); - } - - /* 1998-Dec-31 23:59:60 (if leap seconds are taken into account) */ - tmptime = (22*365 + 7*366)* SECS_PER_DAY + 23; - gmtime_r(&tmptime, &tmputc); - - if (lalDebugLevel & LALINFO) - { - asctime_r(&tmputc, tmpstamp); - snprintf(infostr, INFOSTR_LEN, "tmputc = %s\n", tmpstamp); - LALInfo(status, infostr); - } - - /* - * if GPS is later than maxtestedGPS - * check accuracy param - * if anal accuracy - * die - * else - * print warning message - */ - if (p_gpsTime->gpsSeconds > maxtestedGPS) - { - /* check accuracy param */ - if (*p_accuracy == LALLEAPSEC_STRICT) - { - ABORT(status, DATEH_ERANGEGPSABS, DATEH_MSGERANGEGPSABS); - } - else if (*p_accuracy == LALLEAPSEC_LOOSE) - { - LALWarning(status, "may be missing leap seconds"); - } - else - { - LALWarning(status, "may be missing leap seconds"); - } - } - - - - - /* system gmtime does take leap seconds into account */ - if (tmputc.tm_sec == 60) - { - LALInfo(status, "gmtime_r() takes leap seconds into account"); - - /* check that date requested is not later than 2002-Mar-31 23:59:59, - * which is when the next possible leap second will be. IERS has - * announced that there will be NO leap second at the end of 2001 - * or any time before */ - - /* NOTE: this will break if system gmtime() has taken leap seconds - * into account in the past (i.e. before the test date) */ - - /* compute date struct */ - gmtime_r(&unixTime, &tmputc); - p_utcDate->unixDate.tm_sec = tmputc.tm_sec; - p_utcDate->unixDate.tm_min = tmputc.tm_min; - p_utcDate->unixDate.tm_hour = tmputc.tm_hour; - p_utcDate->unixDate.tm_mday = tmputc.tm_mday; - p_utcDate->unixDate.tm_mon = tmputc.tm_mon; - p_utcDate->unixDate.tm_year = tmputc.tm_year; - p_utcDate->unixDate.tm_wday = tmputc.tm_wday; - p_utcDate->unixDate.tm_yday = tmputc.tm_yday; - p_utcDate->unixDate.tm_isdst = 0; /* always ignore tm_isdst field */ - } - else /* system gmtime() does NOT take leap secs into account */ - { - LALInfo(status, "gmtime_r() does not figure in leap seconds"); - - /* fix up leap seconds */ - i = 0; - while (i < numleaps && leaps[i] + i - 1 < unixTime) - ++i; - - if (lalDebugLevel & LALINFO) - { - snprintf(infostr, INFOSTR_LEN, "unixTime = %ld; leaps[%d] = %ld", - unixTime, i, leaps[i]); - LALInfo(status, infostr); - } - - if (unixTime == (leaps[i] + i - 1)) - { - unixTime -= i; - gmtime_r(&unixTime, &tmputc); - p_utcDate->unixDate.tm_sec = 60; - p_utcDate->unixDate.tm_min = tmputc.tm_min; - p_utcDate->unixDate.tm_hour = tmputc.tm_hour; - p_utcDate->unixDate.tm_mday = tmputc.tm_mday; - p_utcDate->unixDate.tm_mon = tmputc.tm_mon; - p_utcDate->unixDate.tm_year = tmputc.tm_year; - p_utcDate->unixDate.tm_wday = tmputc.tm_wday; - p_utcDate->unixDate.tm_yday = tmputc.tm_yday; - p_utcDate->unixDate.tm_isdst = 0; - } - else - { - unixTime -= (i - 1); - gmtime_r(&unixTime, &tmputc); - p_utcDate->unixDate.tm_sec = tmputc.tm_sec; - p_utcDate->unixDate.tm_min = tmputc.tm_min; - p_utcDate->unixDate.tm_hour = tmputc.tm_hour; - p_utcDate->unixDate.tm_mday = tmputc.tm_mday; - p_utcDate->unixDate.tm_mon = tmputc.tm_mon; - p_utcDate->unixDate.tm_year = tmputc.tm_year; - p_utcDate->unixDate.tm_wday = tmputc.tm_wday; - p_utcDate->unixDate.tm_yday = tmputc.tm_yday; - p_utcDate->unixDate.tm_isdst = 0; - } - } - - /* set residual nanoseconds */ - p_utcDate->residualNanoSeconds = p_gpsTime->gpsNanoSeconds; - - RETURN (status); -} /* END: LALGPStoUTC() */ - - -/* - * Returns no. of days in year of given date - */ -static int days_in_year(const LALDate *p_utcDate) -{ - int year = p_utcDate->unixDate.tm_year + 1900; - - /* Deal with the years ending with '00: only multiples of 400 are leap */ - if (year % 100 == 0) - { - if (year % 400 == 0) - return 366; - else - return 365; - } - - /* non-'00' years */ - if (year % 4 == 0) - return 366; - - return 365; -} - -/* - * Returns no. of days in month of given date - */ -static int days_in_month(const LALDate *p_utcDate) -{ - int month = p_utcDate->unixDate.tm_mon; - - switch (month) { - case LALMONTH_JAN: - case LALMONTH_MAR: - case LALMONTH_MAY: - case LALMONTH_JUL: - case LALMONTH_AUG: - case LALMONTH_OCT: - case LALMONTH_DEC: - return 31; - - case LALMONTH_APR: - case LALMONTH_JUN: - case LALMONTH_SEP: - case LALMONTH_NOV: - return 30; - - case 1: - if (days_in_year(p_utcDate) == 366) - return 29; - else - return 28; - } - - return -1; -} - -/* - * Struct for leap seconds - */ -typedef struct leap_sec -{ - int year; /* year - 1900 */ - int mon; /* 0 through 11 */ - INT4 leapsec; -} -leap_sec_t; - -/* <lalVerbatim file="GPStoUTCCP"> */ -void -LALUTCtoGPS (LALStatus *status, - LIGOTimeGPS *p_gpsTime, /* output - GPS seconds */ - const LALDate *p_utcDate, /* input - date in UTC */ - const LALLeapSecAccuracy *p_accuracy) /* accuracy of - leap-second - accounting: - LALLEAPSEC_LOOSE, or LALLEAPSEC_STRICT */ -{ /* </lalVerbatim> */ - - /* UPDATEME */ - /* - * Table of leap seconds - * Format: Year, Month, and Day of Month in struct tm definition. - * (see ctime(3)) - */ - static leap_sec_t leap_sec_data[] = - { - {72, LALMONTH_JAN, 1}, - {73, LALMONTH_JAN, 1}, - {74, LALMONTH_JAN, 1}, - {75, LALMONTH_JAN, 1}, - {76, LALMONTH_JAN, 1}, - {77, LALMONTH_JAN, 1}, - {78, LALMONTH_JAN, 1}, - {79, LALMONTH_JAN, 1}, - {80, LALMONTH_JAN, 1}, - {81, LALMONTH_JUL, 1}, - {82, LALMONTH_JUL, 1}, - {83, LALMONTH_JUL, 1}, - {85, LALMONTH_JUL, 1}, - {88, LALMONTH_JAN, 1}, - {90, LALMONTH_JAN, 1}, - {91, LALMONTH_JAN, 1}, - {92, LALMONTH_JUL, 1}, - {93, LALMONTH_JUL, 1}, - {94, LALMONTH_JUL, 1}, - {96, LALMONTH_JAN, 1}, - {97, LALMONTH_JUL, 1}, - {99, LALMONTH_JAN, 1}, - {106, LALMONTH_JAN, 1}, - }; - - - int ddays = 0; - int dsecs = 0; - LALDate tmpdate; - static LALDate gpsref; - int i = 0; - char infostr[256]; - static const int nleaps = sizeof(leap_sec_data)/sizeof(leap_sec_t); - - XLALPrintDeprecationWarning("LALUTCtoGPS", "XLALUTCToGPS"); - - /* When GPS began */ - gpsref.unixDate.tm_sec = 0; - gpsref.unixDate.tm_min = 0; - gpsref.unixDate.tm_hour = 0; - gpsref.unixDate.tm_mday = 6; - gpsref.unixDate.tm_mon = LALMONTH_JAN; - gpsref.unixDate.tm_year = 80; - gpsref.unixDate.tm_wday = 0; - gpsref.unixDate.tm_yday = 0; - - if (lalDebugLevel & LALINFO) - { - snprintf(infostr, INFOSTR_LEN, "Date given: %d-%d-%d %d:%d:%d %d\n", - p_utcDate->unixDate.tm_year+1900, p_utcDate->unixDate.tm_mon+1, - p_utcDate->unixDate.tm_mday, p_utcDate->unixDate.tm_hour, - p_utcDate->unixDate.tm_min, p_utcDate->unixDate.tm_sec, - p_utcDate->residualNanoSeconds); - - LALInfo(status, infostr); - } - - INITSTATUS(status, "LALUTCtoGPS", GPSTOUTCC); - - ASSERT (p_gpsTime != (LIGOTimeGPS *)NULL, status, - DATEH_ENULLOUTPUT, DATEH_MSGENULLOUTPUT); - - ASSERT (p_accuracy != (LALLeapSecAccuracy *)NULL, status, - DATEH_ENULLINPUT, DATEH_MSGENULLINPUT); - - ASSERT ((*p_accuracy == LALLEAPSEC_STRICT || - *p_accuracy == LALLEAPSEC_LOOSE), status, - DATEH_EACCPARAMOUTOFRANGE, DATEH_MSGEACCPARAMOUTOFRANGE); - - ASSERT (p_utcDate != (LALDate *)NULL, status, - DATEH_ENULLINPUT, DATEH_MSGENULLINPUT); - - /* Can't convert dates before 1980-Jan-06 */ - ASSERT (p_utcDate->unixDate.tm_year > 80 || - (p_utcDate->unixDate.tm_year == 80 && - (p_utcDate->unixDate.tm_mon > LALMONTH_JAN || - (p_utcDate->unixDate.tm_mon == LALMONTH_JAN && - p_utcDate->unixDate.tm_mday >= 6))), status, - DATEH_EGPSDATETOOEARLY, DATEH_MSGEGPSDATETOOEARLY); - - /* UPDATEME -- to update, fix the comment and the first if() statement */ - /* - * Check that time asked for is not after last known leap sec - * Use by: 2006-Dec-31 23:59:59 UTC - * Check bulletins such as the following to see if additional ones are needed: - * http://hpiers.obspm.fr/eoppc/bul/bulc/bulletinc.dat - * if date is later - * check accuracy param - * if anal accuracy - * die - * else - * print warning message - * - * // date is not later - * do the conversion - */ - if (p_utcDate->unixDate.tm_year > 106 || - (p_utcDate->unixDate.tm_year == 106 && - (p_utcDate->unixDate.tm_mon > LALMONTH_DEC || - (p_utcDate->unixDate.tm_mon == LALMONTH_DEC && - p_utcDate->unixDate.tm_mday == 31 && - p_utcDate->unixDate.tm_hour == 23 && - p_utcDate->unixDate.tm_min == 59 && - p_utcDate->unixDate.tm_sec > 59)))) - { - /* check accuracy param */ - if (*p_accuracy == LALLEAPSEC_STRICT) /* strict accuracy */ - { - ABORT(status, DATEH_ERANGEGPSABS, DATEH_MSGERANGEGPSABS); - } - else if (*p_accuracy == LALLEAPSEC_LOOSE) - { - LALWarning(status, "may be missing leap seconds"); - } - else - { - LALWarning(status, "may be missing leap seconds"); - } - } - - - /* start counting from the origin of GPS */ - tmpdate.unixDate.tm_year = 80; - tmpdate.unixDate.tm_mon = LALMONTH_JAN; - tmpdate.unixDate.tm_mday = 6; - tmpdate.unixDate.tm_hour = 0; - tmpdate.unixDate.tm_min = 0; - tmpdate.unixDate.tm_sec = 0; - tmpdate.residualNanoSeconds = 0; - - while (tmpdate.unixDate.tm_year < p_utcDate->unixDate.tm_year) - { - ddays += days_in_year(&tmpdate); - tmpdate.unixDate.tm_year++; - } - ddays -= 5; /* 5 days in early Jan 1980 */ - - while (tmpdate.unixDate.tm_mon < p_utcDate->unixDate.tm_mon) - { - ddays += days_in_month(&tmpdate); - tmpdate.unixDate.tm_mon++; - } - - ddays += p_utcDate->unixDate.tm_mday - 1; - dsecs = ddays * SECS_PER_DAY; - - dsecs += p_utcDate->unixDate.tm_hour * SECS_PER_HOUR + - p_utcDate->unixDate.tm_min * SECS_PER_MIN + - p_utcDate->unixDate.tm_sec; - - /* add in leap seconds */ - i = 9; /* corresponds to the leap sec data for 1981-Jul-1 */ - while (i < nleaps) - { - if (leap_sec_data[i].year < p_utcDate->unixDate.tm_year) - dsecs++; - else if (leap_sec_data[i].year == p_utcDate->unixDate.tm_year && - leap_sec_data[i].mon <= p_utcDate->unixDate.tm_mon) - dsecs++; - - ++i; - } - - p_gpsTime->gpsSeconds = dsecs; - p_gpsTime->gpsNanoSeconds = p_utcDate->residualNanoSeconds; - - - RETURN (status); -} /* END: LALUTCtoGPS() */ - - /* * LALLeapSecs() diff --git a/lal/packages/date/src/Makefile.am b/lal/packages/date/src/Makefile.am index b1f27797e83c47a954b8ed8e862c3b6b3a52df85..29e34f10d58f4aa94e004b476819eabceeb52bae 100644 --- a/lal/packages/date/src/Makefile.am +++ b/lal/packages/date/src/Makefile.am @@ -1,8 +1,6 @@ ## Process this file with automake to produce Makefile.in noinst_LTLIBRARIES = libdate.la -libdate_la_SOURCES = GPStoUTC.c \ - DateString.c LMST1.c \ - date_value.h TimeDelay.c \ +libdate_la_SOURCES = GPStoUTC.c TimeDelay.c \ GPStoFloat.c IncrementGPS.c GPSTimeNow.c \ Playground.c SkyAnnulus.c StrToGPS.c \ XLALTime.c XLALCivilTime.c XLALSiderealTime.c XLALLeapSeconds.h diff --git a/lal/packages/date/src/XLALCivilTime.c b/lal/packages/date/src/XLALCivilTime.c index 9d0777fde5cb0ca20203af2b3ea32f8884615794..4bdd1be9519483356d2ae139b97749000bba0c1e 100644 --- a/lal/packages/date/src/XLALCivilTime.c +++ b/lal/packages/date/src/XLALCivilTime.c @@ -146,14 +146,9 @@ int XLALGPSLeapSeconds( INT4 gpssec /**< [In] Seconds relative to GPS epoch.*/ ) int leapTAI; int leapGPS; - if ( gpssec < leaps[0].gpssec ) - { - XLALPrintError( "XLAL Error - Don't know leap seconds before GPS time %d\n", - leaps[0].gpssec ); - XLAL_ERROR( func, XLAL_EDOM ); - } - leapTAI = XLALLeapSeconds ( gpssec ); + if ( leapTAI < 0 ) + XLAL_ERROR( func, XLAL_EFUNC ); leapGPS = leapTAI - 19; /* subtract 19 seconds to get leap-seconds wrt to GPS epoch */ diff --git a/lal/packages/date/src/XLALTime.c b/lal/packages/date/src/XLALTime.c index 85836c6047995e76a4f730b0015f8930ca00f713..5980f7b242e9ba769dd9a4542c8a36c52ebff03f 100644 --- a/lal/packages/date/src/XLALTime.c +++ b/lal/packages/date/src/XLALTime.c @@ -64,8 +64,17 @@ LIGOTimeGPS * XLALGPSSet( LIGOTimeGPS *epoch, INT4 gpssec, INT4 gpsnan ) /** Sets GPS time given GPS seconds as a REAL8. */ LIGOTimeGPS * XLALGPSSetREAL8( LIGOTimeGPS *epoch, REAL8 t ) { + static const char func[] = "XLALGPSSetREAL8"; INT4 gpssec = floor(t); INT4 gpsnan = floor((t - gpssec) * XLAL_BILLION_REAL8 + 0.5); + if(isnan(t)) { + XLALPrintError("%s(): NaN", func); + XLAL_ERROR_NULL(func, XLAL_EFPINVAL); + } + if(fabs(t) > 0x7fffffff) { + XLALPrintError("%s(): overflow %g", func, t); + XLAL_ERROR_NULL(func, XLAL_EFPINVAL); + } /* use XLALGPSSet() to normalize the nanoseconds */ return XLALGPSSet(epoch, gpssec, gpsnan); } @@ -93,8 +102,10 @@ LIGOTimeGPS * XLALGPSAddGPS( LIGOTimeGPS *epoch, const LIGOTimeGPS *dt ) /** Adds a double to a GPS time. */ LIGOTimeGPS * XLALGPSAdd( LIGOTimeGPS *epoch, REAL8 dt ) { + static const char func[] = "XLALGPSAdd"; LIGOTimeGPS dt_gps; - XLALGPSSetREAL8(&dt_gps, dt); + if(!XLALGPSSetREAL8(&dt_gps, dt)) + XLAL_ERROR_NULL(func, XLAL_EFUNC); return XLALGPSAddGPS(epoch, &dt_gps); } @@ -153,15 +164,15 @@ static void split_double(double x, double *hi, double *lo) LIGOTimeGPS *XLALGPSMultiply( LIGOTimeGPS *gps, REAL8 x ) { static const char func[] = "XLALGPSMultiply"; - int slo = gps->gpsSeconds % 1<<26; + int slo = gps->gpsSeconds % (1<<26); int shi = gps->gpsSeconds - slo; - int nlo = gps->gpsNanoSeconds % 1<<15; + int nlo = gps->gpsNanoSeconds % (1<<15); int nhi = gps->gpsNanoSeconds - nlo; double xhi, xlo; double addend; LIGOTimeGPS gps_addend; - if(XLAL_IS_REAL8_FAIL_NAN(x) || isinf(x)) { + if(isnan(x) || isinf(x)) { XLALPrintError("%s(): invalid multiplicand %g", func, x); XLAL_ERROR_NULL(func, XLAL_EFPINVAL); } @@ -212,7 +223,7 @@ LIGOTimeGPS *XLALGPSDivide( LIGOTimeGPS *gps, REAL8 x ) int keep_going; double residual; - if(XLAL_IS_REAL8_FAIL_NAN(x)) { + if(isnan(x)) { XLALPrintError("%s(): NaN", func); XLAL_ERROR_NULL(func, XLAL_EFPINVAL); } diff --git a/lal/packages/date/test/Makefile.am b/lal/packages/date/test/Makefile.am index f3edf87d0f0765a0e4368ba25d4ad180d8f2cd5f..345e0ac594387d7fc2083497854f849094997384 100644 --- a/lal/packages/date/test/Makefile.am +++ b/lal/packages/date/test/Makefile.am @@ -2,7 +2,7 @@ # # $Id$ # -check_PROGRAMS = TestJulianDay TestLMST TestLMST2 TestDelay TestDateString \ +check_PROGRAMS = TestJulianDay TestLMST TestLMST2 TestDelay \ TestGPStoUTC TestUTCtoGPS TestGPStoGMST1 TestLeapSecs \ TestGPStoFloat TestIncrementGPS TestStrToGPS TestJulianDay_SOURCES = TestJulianDay.c @@ -13,8 +13,6 @@ TestLMST2_SOURCES = TestLMST2.c TestLMST2_LDADD = $(top_builddir)/lib/liblal.la TestDelay_SOURCES = TestDelay.c TestDelay_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -TestDateString_SOURCES = TestDateString.c -TestDateString_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la TestGPStoUTC_SOURCES = TestGPStoUTC.c TestGPStoUTC_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la TestUTCtoGPS_SOURCES = TestUTCtoGPS.c @@ -32,7 +30,7 @@ TestIncrementGPS_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $ TestStrToGPS_SOURCES = TestStrToGPS.c TestStrToGPS_LDADD = $(top_builddir)/lib/liblal.la INCLUDES = -I$(top_builddir)/include -I$(srcdir)/../include -TESTS = TestJulianDay TestLMST TestDelay TestDateString TestGPStoUTC \ +TESTS = TestJulianDay TestLMST TestDelay TestGPStoUTC \ TestUTCtoGPS TestLeapSecs TestGPStoFloat TestIncrementGPS TestStrToGPS TESTS_ENVIRONMENT = 1>/dev/null MOSTLYCLEANFILES = .dvi-dep diff --git a/lal/packages/date/test/TestGPStoGMST1.c b/lal/packages/date/test/TestGPStoGMST1.c index 5195445b2ddbebcb08646a330ecc6f225926c226..2f8fa299762e521785c4059b87585b4e8cd7bb34 100644 --- a/lal/packages/date/test/TestGPStoGMST1.c +++ b/lal/packages/date/test/TestGPStoGMST1.c @@ -32,19 +32,15 @@ NRCSID (TESTGPSTOGMST1C, "$Id$"); int main(void) { - static LALStatus status; - LALMSTUnitsAndAcc mstUnitsAndAcc; LIGOTimeGPS gps = {0., 0.}; REAL8 gmst; gps.gpsSeconds = 61094; - mstUnitsAndAcc.units = MST_RAD; - mstUnitsAndAcc.accuracy = LALLEAPSEC_LOOSE; for (gps.gpsNanoSeconds =99999999; gps.gpsNanoSeconds < 1000000000; gps.gpsNanoSeconds+=10000000) { - LALGPStoGMST1(&status, &gmst, &gps, &mstUnitsAndAcc); + gmst = XLALGreenwichMeanSiderealTime(&gps); printf("nSec = %d\tgmst = %g\n", gps.gpsNanoSeconds, gmst); } diff --git a/lal/packages/date/test/TestGPStoUTC.c b/lal/packages/date/test/TestGPStoUTC.c index 0ff49747df5988a508617f5cfa2d6b1bd64513ea..21ac33f1acc7cc062a9942496f9fff778407f8fd 100644 --- a/lal/packages/date/test/TestGPStoUTC.c +++ b/lal/packages/date/test/TestGPStoUTC.c @@ -35,8 +35,7 @@ int main(int argc, char *argv[]) static LALStatus status; LIGOTimeGPS gpsTime = {0, 0}; LIGOTimeGPS tmpGps = {0, 0}; - LALDate utcDate; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* prevent ABORT */ + struct tm utcDate; CHARVector *timestamp = NULL; char refstamp[128]; /* char infostr[256]; */ @@ -51,23 +50,14 @@ int main(int argc, char *argv[]) /* * GPS 0 == 1980-01-06 00:00:00 UTC Sun */ - LALGPStoUTC(&status, &utcDate, &gpsTime, &accuracy); - if (status.statusCode && lalDebugLevel > 0) + if(!XLALGPSToUTC(&utcDate, gpsTime.gpsSeconds)) { - fprintf(stderr, "TestGPStoUTC: LALGPStoUTC() failed, line %i, %s\n", + fprintf(stderr, "TestGPStoUTC: XLALGPSToUTC() failed, line %i, %s\n", __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; + return 1; } - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, "TestGPStoUTC: LALDateString() failed, line %i, %s\n", - __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; - } + strftime(timestamp->data, timestamp->length, "%F %T UTC %a", &utcDate); sprintf(refstamp, "1980-01-06 00:00:00 UTC Sun"); @@ -102,23 +92,14 @@ int main(int argc, char *argv[]) gpsTime.gpsSeconds = 457574400; gpsTime.gpsNanoSeconds = 0; - LALGPStoUTC(&status, &utcDate, &gpsTime, &accuracy); - if (status.statusCode && lalDebugLevel > 0) + if(!XLALGPSToUTC(&utcDate, gpsTime.gpsSeconds)) { - fprintf(stderr, "TestGPStoUTC: LALGPStoUTC() failed, line %i, %s\n", + fprintf(stderr, "TestGPStoUTC: XLALGPSToUTC() failed, line %i, %s\n", __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; + return 1; } - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, "TestGPStoUTC: LALDateString() failed, line %i, %s\n", - __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; - } + strftime(timestamp->data, timestamp->length, "%F %T UTC %a", &utcDate); sprintf(refstamp, "1994-07-06 23:59:50 UTC Wed"); @@ -151,23 +132,14 @@ int main(int argc, char *argv[]) gpsTime.gpsSeconds = 599184012; gpsTime.gpsNanoSeconds = 0; - LALGPStoUTC(&status, &utcDate, &gpsTime, &accuracy); - if (status.statusCode && lalDebugLevel > 0) + if(!XLALGPSToUTC(&utcDate, gpsTime.gpsSeconds)) { - fprintf(stderr, "TestGPStoUTC: LALGPStoUTC() failed, line %i, %s\n", + fprintf(stderr, "TestGPStoUTC: XLALGPSToUTC() failed, line %i, %s\n", __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; + return 1; } - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, "TestGPStoUTC: LALDateString() failed, line %i, %s\n", - __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; - } + strftime(timestamp->data, timestamp->length, "%F %T UTC %a", &utcDate); sprintf(refstamp, "1998-12-31 23:59:60 UTC Thu"); @@ -203,25 +175,14 @@ int main(int argc, char *argv[]) gpsTime.gpsSeconds = 835747214; /* use maxtestedGPS + 1 */ gpsTime.gpsNanoSeconds = 0; - LALGPStoUTC(&status, &utcDate, &gpsTime, &accuracy); - if (status.statusCode && lalDebugLevel > 0) + if(!XLALGPSToUTC(&utcDate, gpsTime.gpsSeconds)) { - fprintf(stderr, "TestGPStoUTC: LALGPStoUTC() failed, line %i, %s\n", + fprintf(stderr, "TestGPStoUTC: XLALGPSToUTC() failed, line %i, %s\n", __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; + return 1; } - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, "TestGPStoUTC: LALDateString() failed, line %i, %s\n", - __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - LALCHARDestroyVector(&status, ×tamp); - LALCheckMemoryLeaks(); - return status.statusCode; - } + strftime(timestamp->data, timestamp->length, "%F %T UTC %a", &utcDate); /* UPDATEME */ /* the date here should be one second after maxtestedGPS */ @@ -252,60 +213,28 @@ int main(int argc, char *argv[]) /* - * GPS -100 : should fail + * GPS -44000 + * should fail. No leap seconds, yet. */ - gpsTime.gpsSeconds = -100; + gpsTime.gpsSeconds = -44000; gpsTime.gpsNanoSeconds = 0; - LALGPStoUTC(&status, &utcDate, &gpsTime, &accuracy); - if (status.statusCode > 0) + if(!XLALGPSToUTC(&utcDate, gpsTime.gpsSeconds)) { - if (status.statusCode == DATEH_ERANGEGPSABS) /* expected error */ - { - if (lalDebugLevel > 0) - { - fprintf(stderr, "failed with status code %d as expected", - DATEH_ERANGEGPSABS); - REPORTSTATUS(&status); - } - } - else /* some other error */ + if (XLALGetBaseErrno() != XLAL_EDOM) /* not expected error */ { - fprintf(stderr, "TestGPStoUTC: LALGPStoUTC() failed, line %i, %s\n", + fprintf(stderr, "TestGPStoUTC: XLALGPSToUTC() failed, line %i, %s\n", __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; + return 1; } } - - - /* - * GPS 701654413 == 2002-04-01 00:00:00 UTC - * should fail. No leap seconds, yet. - */ - gpsTime.gpsSeconds = -100; - gpsTime.gpsNanoSeconds = 0; - - LALGPStoUTC(&status, &utcDate, &gpsTime, &accuracy); - if (status.statusCode > 0) + else /* no error */ { - if (status.statusCode == DATEH_ERANGEGPSABS) /* expected error */ - { - if (lalDebugLevel > 0) - { - fprintf(stderr, "failed with status code %d as expected", - DATEH_ERANGEGPSABS); - REPORTSTATUS(&status); - } - } - else /* some other error */ - { - fprintf(stderr, "TestGPStoUTC: LALGPStoUTC() failed, line %i, %s\n", - __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; - } + fprintf(stderr, "TestGPStoUTC: XLALGPSToUTC() failed, line %i, %s\n", + __LINE__, LALTESTGPSTOUTCC); + return 1; } + XLALClearErrno(); /* * Now, let's try converting GPS to UTC and back @@ -313,23 +242,20 @@ int main(int argc, char *argv[]) gpsTime.gpsSeconds = 701654354; gpsTime.gpsNanoSeconds = 0; - LALGPStoUTC(&status, &utcDate, &gpsTime, &accuracy); - if (status.statusCode && lalDebugLevel > 0) + if(!XLALGPSToUTC(&utcDate, gpsTime.gpsSeconds)) { - fprintf(stderr, "TestGPStoUTC: LALGPStoUTC() failed, line %i, %s\n", + fprintf(stderr, "TestGPStoUTC: XLALGPSToUTC() failed, line %i, %s\n", __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; + return 1; } - LALUTCtoGPS(&status, &tmpGps, &utcDate, &accuracy); - if (status.statusCode && lalDebugLevel > 0) + XLALGPSSet(&tmpGps, XLALUTCToGPS(&utcDate), 0); + if (XLALGetBaseErrno() && lalDebugLevel > 0) { fprintf(stderr, - "TestUTCtoGPS: error in LALUTCtoGPS, line %i, %s\n", + "TestUTCtoGPS: error in XLALUTCToGPS, line %i, %s\n", __LINE__, LALTESTGPSTOUTCC); - REPORTSTATUS(&status); - return status.statusCode; + return 1; } if (lalDebugLevel > 0) diff --git a/lal/packages/date/test/TestLMST.c b/lal/packages/date/test/TestLMST.c index c7362d82550c1ce548a2964be3e9fee920672d81..411088c95dda3152207c27c19ad8a471dad7690d 100644 --- a/lal/packages/date/test/TestLMST.c +++ b/lal/packages/date/test/TestLMST.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <math.h> #include <stdlib.h> +#include <time.h> #include <lal/LALStdlib.h> #include <lal/Date.h> diff --git a/lal/packages/date/test/TestLMST2.c b/lal/packages/date/test/TestLMST2.c index 50ab83650aba388b8105159fad36a72fde01b36f..38022bf93209a8c43e12c233d7b3794fc7937653 100644 --- a/lal/packages/date/test/TestLMST2.c +++ b/lal/packages/date/test/TestLMST2.c @@ -18,6 +18,7 @@ */ #include <stdlib.h> +#include <time.h> #include <lal/LALStdlib.h> #include <lal/AVFactories.h> #include <lal/Date.h> diff --git a/lal/packages/date/test/TestUTCtoGPS.c b/lal/packages/date/test/TestUTCtoGPS.c index 93236438e1c48f06f80ec15d00af7eae7eb19f4e..dbbdf715407d50bb2b4425de6b16675805241a58 100644 --- a/lal/packages/date/test/TestUTCtoGPS.c +++ b/lal/packages/date/test/TestUTCtoGPS.c @@ -30,399 +30,118 @@ INT4 lalDebugLevel = 0; NRCSID (LALTESTUTCTOGPSC, "$Id$"); -int main(int argc, char *argv[]) +static int test(struct tm *t, int correct_gps, int line) { - static LALStatus status; - LIGOTimeGPS gpsTime; - LIGOTimeGPS refGPS; - LALDate utcDate; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; - CHARVector *timestamp = NULL; - time_t sec; - - if (argc > 1) - lalDebugLevel = atoi(argv[1]); - - LALCHARCreateVector(&status, ×tamp, (UINT4)64); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALCHARCreateVector, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - - if (lalDebugLevel > 0) - REPORTSTATUS(&status); - - /* Set the date */ - utcDate.unixDate.tm_year = 80; - utcDate.unixDate.tm_mon = 0; - utcDate.unixDate.tm_mday = 6; - utcDate.unixDate.tm_hour = 0; - utcDate.unixDate.tm_min = 0; - utcDate.unixDate.tm_sec = 0; - utcDate.residualNanoSeconds = 0; - - LALUTCtoGPS(&status, &gpsTime, &utcDate, &accuracy); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALUTCtoGPS, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); - - refGPS.gpsSeconds = 0; - refGPS.gpsNanoSeconds = 0; - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALDateString, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); - - if (lalDebugLevel > 0) - { - fprintf(stderr, "For: %s\n", timestamp->data); - fprintf(stderr, " expect GPS = {%10d, %9d}\n", refGPS.gpsSeconds, - refGPS.gpsNanoSeconds); - fprintf(stderr, " got GPS = {%10d, %9d}\n", gpsTime.gpsSeconds, - gpsTime.gpsNanoSeconds); - } - - if (gpsTime.gpsSeconds != refGPS.gpsSeconds || - gpsTime.gpsNanoSeconds != refGPS.gpsNanoSeconds) - { - LALCHARDestroyVector(&status, ×tamp); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALCHARDestroyVector, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - REPORTSTATUS(&status); - LALCheckMemoryLeaks(); - return 1; - } - - /* Set the date */ - utcDate.unixDate.tm_year = 94; - utcDate.unixDate.tm_mon = 6; - utcDate.unixDate.tm_mday = 6; - utcDate.unixDate.tm_hour = 23; - utcDate.unixDate.tm_min = 59; - utcDate.unixDate.tm_sec = 50; - utcDate.residualNanoSeconds = 123456789; - - LALUTCtoGPS(&status, &gpsTime, &utcDate, &accuracy); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALUTCtoGPS, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); - - refGPS.gpsSeconds = 457574400; - refGPS.gpsNanoSeconds = 123456789; - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALDateString, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); - - if (lalDebugLevel > 0) - { - fprintf(stderr, "For: %s\n", timestamp->data); - fprintf(stderr, " expect GPS = {%10d, %9d}\n", refGPS.gpsSeconds, - refGPS.gpsNanoSeconds); - fprintf(stderr, " got GPS = {%10d, %9d}\n", gpsTime.gpsSeconds, - gpsTime.gpsNanoSeconds); - } + int gps = XLALUTCToGPS(t); - if (gpsTime.gpsSeconds != refGPS.gpsSeconds || - gpsTime.gpsNanoSeconds != refGPS.gpsNanoSeconds) + if (XLALGetBaseErrno()) { - LALCHARDestroyVector(&status, ×tamp); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALCHARDestroyVector, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - REPORTSTATUS(&status); - LALCheckMemoryLeaks(); - return 1; + fprintf(stderr, "TestUTCtoGPS: error in XLALUTCToGPS(), line %i\n", line); + return -1; } - /* Set the date */ - utcDate.unixDate.tm_year = 94; - utcDate.unixDate.tm_mon = 6; - utcDate.unixDate.tm_mday = 1; - utcDate.unixDate.tm_hour = 0; - utcDate.unixDate.tm_min = 0; - utcDate.unixDate.tm_sec = 0; - utcDate.residualNanoSeconds = 123456789; - - LALUTCtoGPS(&status, &gpsTime, &utcDate, &accuracy); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALUTCtoGPS, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } if (lalDebugLevel > 0) - REPORTSTATUS(&status); - - refGPS.gpsSeconds = 457056010; - refGPS.gpsNanoSeconds = 123456789; - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) { - fprintf(stderr, - "TestUTCtoGPS: error in LALDateString, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); - - if (lalDebugLevel > 0) - { - fprintf(stderr, "For: %s\n", timestamp->data); - fprintf(stderr, " expect GPS = {%10d, %9d}\n", refGPS.gpsSeconds, - refGPS.gpsNanoSeconds); - fprintf(stderr, " got GPS = {%10d, %9d}\n", gpsTime.gpsSeconds, - gpsTime.gpsNanoSeconds); + fprintf(stderr, "Input = %s\tOutput = %d\n\tExpected = %d\n", + asctime(t), gps, correct_gps); } - if (gpsTime.gpsSeconds != refGPS.gpsSeconds || - gpsTime.gpsNanoSeconds != refGPS.gpsNanoSeconds) + if (gps != correct_gps) { - LALCHARDestroyVector(&status, ×tamp); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALCHARDestroyVector, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - REPORTSTATUS(&status); - LALCheckMemoryLeaks(); - return 1; - } - - /* Set the date */ - utcDate.unixDate.tm_year = 94; - utcDate.unixDate.tm_mon = 5; - utcDate.unixDate.tm_mday = 30; - utcDate.unixDate.tm_hour = 23; - utcDate.unixDate.tm_min = 59; - utcDate.unixDate.tm_sec = 58; - utcDate.residualNanoSeconds = 123456789; - - refGPS.gpsSeconds = 457056007; - refGPS.gpsNanoSeconds = 123456789; - - for (sec = 0; sec < 5; ++sec) - { - LALUTCtoGPS(&status, &gpsTime, &utcDate, &accuracy); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALUTCtoGPS, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); - - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALDateString, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); - if (lalDebugLevel > 0) - { - fprintf(stderr, "For: %s\n", timestamp->data); - fprintf(stderr, " expect GPS = {%10d, %9d}\n", refGPS.gpsSeconds, - refGPS.gpsNanoSeconds); - fprintf(stderr, " got GPS = {%10d, %9d}\n", gpsTime.gpsSeconds, - gpsTime.gpsNanoSeconds); - } - - if (gpsTime.gpsSeconds != refGPS.gpsSeconds || - gpsTime.gpsNanoSeconds != refGPS.gpsNanoSeconds) - { - LALCHARDestroyVector(&status, ×tamp); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALCHARDestroyVector, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - REPORTSTATUS(&status); - LALCheckMemoryLeaks(); - return 1; - } - - utcDate.unixDate.tm_sec++; - if (utcDate.unixDate.tm_sec == 61) - { - utcDate.unixDate.tm_mon++; - utcDate.unixDate.tm_mday = 1; - utcDate.unixDate.tm_hour = 0; - utcDate.unixDate.tm_min = 0; - utcDate.unixDate.tm_sec = 0; - } - refGPS.gpsSeconds++; + fprintf(stderr, "TestUTCtoGPS: error, line %i\n", line); + return -1; } - /* Set the date */ - utcDate.unixDate.tm_year = 94; - utcDate.unixDate.tm_mon = 10; - utcDate.unixDate.tm_mday = 16; - utcDate.unixDate.tm_hour = 0; - utcDate.unixDate.tm_min = 0; - utcDate.unixDate.tm_sec = 0; - utcDate.residualNanoSeconds = 123456789; - - LALUTCtoGPS(&status, &gpsTime, &utcDate, &accuracy); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALUTCtoGPS, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); + return 0; +} - refGPS.gpsSeconds = 468979210; - refGPS.gpsNanoSeconds = 123456789; - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALDateString, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); +#define TEST(t, correct_gps) test(t, correct_gps, __LINE__) - if (lalDebugLevel > 0) - { - fprintf(stderr, "For: %s\n", timestamp->data); - fprintf(stderr, " expect GPS = {%10d, %9d}\n", refGPS.gpsSeconds, - refGPS.gpsNanoSeconds); - fprintf(stderr, " got GPS = {%10d, %9d}\n", gpsTime.gpsSeconds, - gpsTime.gpsNanoSeconds); - } - if (gpsTime.gpsSeconds != refGPS.gpsSeconds || - gpsTime.gpsNanoSeconds != refGPS.gpsNanoSeconds) - { - LALCHARDestroyVector(&status, ×tamp); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALCHARDestroyVector, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - REPORTSTATUS(&status); - LALCheckMemoryLeaks(); - return 1; - } +int main(int argc, char *argv[]) +{ + struct tm utcDate; + time_t sec; - if (lalDebugLevel > 0) - { - utcDate.unixDate.tm_year = 72; - utcDate.unixDate.tm_mon = 0; - utcDate.unixDate.tm_mday = 1; - utcDate.unixDate.tm_hour = 0; - utcDate.unixDate.tm_min = 0; - utcDate.unixDate.tm_sec = 0; - utcDate.residualNanoSeconds = 0; + if (argc > 1) + lalDebugLevel = atoi(argv[1]); - LALUTCtoGPS(&status, &gpsTime, &utcDate, &accuracy); - if (status.statusCode && lalDebugLevel > 0) + utcDate.tm_year = 80; + utcDate.tm_yday = 5; + utcDate.tm_wday = -1; /* unused */ + utcDate.tm_mon = 0; /* unused */ + utcDate.tm_mday = 6; /* unused */ + utcDate.tm_hour = 0; + utcDate.tm_min = 0; + utcDate.tm_sec = 0; + utcDate.tm_isdst = 0; + if (TEST(&utcDate, 0)) + return 1; + + utcDate.tm_year = 94; + utcDate.tm_yday = 186; + utcDate.tm_wday = -1; /* unused */ + utcDate.tm_mon = 6; /* unused */ + utcDate.tm_mday = 6; /* unused */ + utcDate.tm_hour = 23; + utcDate.tm_min = 59; + utcDate.tm_sec = 50; + utcDate.tm_isdst = 1; + if (TEST(&utcDate, 457574400)) + return 1; + + utcDate.tm_year = 94; + utcDate.tm_yday = 181; + utcDate.tm_wday = -1; /* unused */ + utcDate.tm_mon = 6; /* unused */ + utcDate.tm_mday = 1; /* unused */ + utcDate.tm_hour = 0; + utcDate.tm_min = 0; + utcDate.tm_sec = 0; + utcDate.tm_isdst = 1; + if (TEST(&utcDate, 457056010)) + return 1; + + for (sec = 457056007; sec < 457056012; sec++) + { + utcDate.tm_year = 94; + utcDate.tm_wday = -1; /* unused */ + utcDate.tm_sec = 58 + (sec - 457056007); + if (utcDate.tm_sec <= 60) { - fprintf(stderr, - "TestUTCtoGPS: error in LALUTCtoGPS, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; + utcDate.tm_yday = 180; + utcDate.tm_mon = 5; /* unused */ + utcDate.tm_mday = 30; /* unused */ + utcDate.tm_hour = 23; + utcDate.tm_min = 59; } - REPORTSTATUS(&status); - - LALDateString(&status, timestamp, &utcDate); - if (status.statusCode && lalDebugLevel > 0) + else { - fprintf(stderr, - "TestUTCtoGPS: error in LALDateString, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; + utcDate.tm_sec -= 61; + utcDate.tm_yday = 181; + utcDate.tm_mon = 6; /* unused */ + utcDate.tm_mday = 1; /* unused */ + utcDate.tm_hour = 00; + utcDate.tm_min = 00; } - REPORTSTATUS(&status); + utcDate.tm_isdst = 1; + if (TEST(&utcDate, sec)) + return 1; + } + + utcDate.tm_year = 94; + utcDate.tm_yday = 319; + utcDate.tm_wday = -1; /* unused */ + utcDate.tm_mon = 10; /* unused */ + utcDate.tm_mday = 16; /* unused */ + utcDate.tm_hour = 0; + utcDate.tm_min = 0; + utcDate.tm_sec = 0; + utcDate.tm_isdst = 0; + if (TEST(&utcDate, 468979210)) + return 1; - fprintf(stderr, "%s = GPS %10d\n", timestamp->data, gpsTime.gpsSeconds); - } - - - LALCHARDestroyVector(&status, ×tamp); - if (status.statusCode && lalDebugLevel > 0) - { - fprintf(stderr, - "TestUTCtoGPS: error in LALCHARDestroyVector, line %i, %s\n", - __LINE__, LALTESTUTCTOGPSC); - REPORTSTATUS(&status); - return status.statusCode; - } - if (lalDebugLevel > 0) - REPORTSTATUS(&status); LALCheckMemoryLeaks(); return 0; } diff --git a/lal/packages/factories/test/VectorFactoriesTestFunction.m4 b/lal/packages/factories/test/VectorFactoriesTestFunction.m4 index 3570936bebf47632929c73a022d0dba46e3c12f1..13c464959d4521dfb427ff7a2a89f3b796fb49df 100644 --- a/lal/packages/factories/test/VectorFactoriesTestFunction.m4 +++ b/lal/packages/factories/test/VectorFactoriesTestFunction.m4 @@ -88,7 +88,7 @@ static void FUNC ( void ) if (verbose) { printf("VFT line %d:\n", __LINE__); - printf(" vector = %#x\n", (unsigned int)vector); + printf(" vector = %p\n", (void *)vector); } LALCheckMemoryLeaks(); @@ -116,7 +116,7 @@ static void FUNC ( void ) if (verbose) { printf("VFT line %d:\n", __LINE__); - printf(" vector = %#x\n", (unsigned int)vector); + printf(" vector = %p\n", (void *)vector); } LALCheckMemoryLeaks(); @@ -135,7 +135,7 @@ static void FUNC ( void ) if (verbose) { printf("VFT line %d\n", __LINE__); - printf(" vector = %#x\n", (unsigned int)vector); + printf(" vector = %p\n", (void *)vector); } CFUNC ( &status, &vector, 0 ); diff --git a/lal/packages/fft/include/ComplexFFT.h b/lal/packages/fft/include/ComplexFFT.h index 60daea6c3adbb28679e70b4ee17d2a24d2636a57..140ecea0ac45dba0377f004bd419885836cd9eee 100644 --- a/lal/packages/fft/include/ComplexFFT.h +++ b/lal/packages/fft/include/ComplexFFT.h @@ -86,7 +86,9 @@ NRCSID( COMPLEXFFTH, "$Id$" ); * **** </lalLaTeX> */ /**** <lalVerbatim> */ +/** Plan to perform FFT of COMPLEX8 data */ typedef struct tagCOMPLEX8FFTPlan COMPLEX8FFTPlan; +/** Plan to perform FFT of COMPLEX16 data */ typedef struct tagCOMPLEX16FFTPlan COMPLEX16FFTPlan; #define tagComplexFFTPlan tagCOMPLEX8FFTPlan #define ComplexFFTPlan COMPLEX8FFTPlan @@ -106,11 +108,130 @@ typedef struct tagCOMPLEX16FFTPlan COMPLEX16FFTPlan; * */ +/** Returns a new COMPLEX8FFTPlan + * + * A COMPLEX8FFTPlan is required to perform a FFT that involves complex data. + * A different plan is required for each size of the complex data vectors + * and for each direction of transform (forward or reverse). + * A forward transform performs + * \f[Z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,z[j]\f] + * where N, the size of the transform, is the length of the vectors z and Z. + * A reverse transform performs + * \f[w[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,W[k]\f] + * where N, the size of the transform, is the length of the vectors w and W. + * + * @note + * The reverse transform of the forward transform of some data is + * equal to N times the original data (we therefore call it a "reverse" + * transform rather than an "inverse" transform). + * + * @param[in] size The number of points in the complex data. + * @param[in] fwdflag Set non-zero for a forward FFT plan; + * otherwise create a reverse plan + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c COMPLEX8FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateCOMPLEX8Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ COMPLEX8FFTPlan * XLALCreateCOMPLEX8FFTPlan( UINT4 size, int fwdflg, int measurelvl ); + +/** Returns a new COMPLEX8FFTPlan for a forward transform + * + * A COMPLEX8FFTPlan is required to perform a FFT that involves complex data. + * A different plan is required for each size of the complex data vectors. + * A forward transform performs + * \f[Z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,z[j]\f] + * where N, the size of the transform, is the length of the vector z and Z. + * + * @param[in] size The number of points in the complex data. + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c COMPLEX8FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateForwardCOMPLEX8Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ COMPLEX8FFTPlan * XLALCreateForwardCOMPLEX8FFTPlan( UINT4 size, int measurelvl ); + +/** Returns a new COMPLEX8FFTPlan for a reverse transform + * + * A COMPLEX8FFTPlan is required to perform a FFT that involves complex data. + * A reverse transform performs + * \f[w[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,W[k]\f] + * where N, the size of the transform, is the length of the vectors w and W. + * + * @note + * The reverse transform of the forward transform of some data is + * equal to N times the original data (we therefore call it a "reverse" + * transform rather than an "inverse" transform). + * + * @param[in] size The number of points in the complex data. + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c COMPLEX8FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateReverseCOMPLEX8Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ COMPLEX8FFTPlan * XLALCreateReverseCOMPLEX8FFTPlan( UINT4 size, int measurelvl ); + +/** Destroys a COMPLEX8FFTPlan + * @param[in] plan A pointer to the COMPLEX8FFTPlan to be destroyed. + * @return None. + */ void XLALDestroyCOMPLEX8FFTPlan( COMPLEX8FFTPlan *plan ); -int XLALCOMPLEX8VectorFFT( COMPLEX8Vector *output, COMPLEX8Vector *input, + +/** Perform a COMPLEX8Vector to COMPLEX8Vector FFT + * + * This routine computes + * \f[Z[k] = \sum_{j=0}^{N-1} e^{\mp2\pi ijk/N}\,z[j],\f] + * and where the minus sign is used if a forward plan is provided as the argument + * and the plus sign is used if a reverse plan is provided as the argument; + * here N is the length of the input and output vectors z and Z. + * + * @param[out] output The complex output data vector Z of length N + * @param[in] input The input complex data vector z of length N + * @param[in] plan The FFT plan to use for the transform + * @note + * The input and output vectors must be distinct. + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALCOMPLEX8VectorFFT() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the input and output data + * vectors are the same. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * . + */ +int XLALCOMPLEX8VectorFFT( COMPLEX8Vector * restrict output, COMPLEX8Vector * restrict input, const COMPLEX8FFTPlan *plan ); /* @@ -119,11 +240,131 @@ int XLALCOMPLEX8VectorFFT( COMPLEX8Vector *output, COMPLEX8Vector *input, * */ + +/** Returns a new COMPLEX16FFTPlan + * + * A COMPLEX16FFTPlan is required to perform a FFT that involves complex data. + * A different plan is required for each size of the complex data vectors + * and for each direction of transform (forward or reverse). + * A forward transform performs + * \f[Z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,z[j]\f] + * where N, the size of the transform, is the length of the vectors z and Z. + * A reverse transform performs + * \f[w[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,W[k]\f] + * where N, the size of the transform, is the length of the vectors w and W. + * + * @note + * The reverse transform of the forward transform of some data is + * equal to N times the original data (we therefore call it a "reverse" + * transform rather than an "inverse" transform). + * + * @param[in] size The number of points in the complex data. + * @param[in] fwdflag Set non-zero for a forward FFT plan; + * otherwise create a reverse plan + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c COMPLEX16FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateCOMPLEX16Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ COMPLEX16FFTPlan * XLALCreateCOMPLEX16FFTPlan( UINT4 size, int fwdflg, int measurelvl ); + +/** Returns a new COMPLEX16FFTPlan for a forward transform + * + * A COMPLEX16FFTPlan is required to perform a FFT that involves complex data. + * A different plan is required for each size of the complex data vectors. + * A forward transform performs + * \f[Z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,z[j]\f] + * where N, the size of the transform, is the length of the vector z and Z. + * + * @param[in] size The number of points in the complex data. + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c COMPLEX16FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateForwardCOMPLEX16Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ COMPLEX16FFTPlan * XLALCreateForwardCOMPLEX16FFTPlan( UINT4 size, int measurelvl ); + +/** Returns a new COMPLEX16FFTPlan for a reverse transform + * + * A COMPLEX16FFTPlan is required to perform a FFT that involves complex data. + * A reverse transform performs + * \f[w[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,W[k]\f] + * where N, the size of the transform, is the length of the vectors w and W. + * + * @note + * The reverse transform of the forward transform of some data is + * equal to N times the original data (we therefore call it a "reverse" + * transform rather than an "inverse" transform). + * + * @param[in] size The number of points in the complex data. + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c COMPLEX16FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateReverseCOMPLEX16Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ COMPLEX16FFTPlan * XLALCreateReverseCOMPLEX16FFTPlan( UINT4 size, int measurelvl ); + +/** Destroys a COMPLEX16FFTPlan + * @param[in] plan A pointer to the COMPLEX16FFTPlan to be destroyed. + * @return None. + */ void XLALDestroyCOMPLEX16FFTPlan( COMPLEX16FFTPlan *plan ); -int XLALCOMPLEX16VectorFFT( COMPLEX16Vector *output, COMPLEX16Vector *input, + +/** Perform a COMPLEX16Vector to COMPLEX16Vector FFT + * + * This routine computes + * \f[Z[k] = \sum_{j=0}^{N-1} e^{\mp2\pi ijk/N}\,z[j],\f] + * and where the minus sign is used if a forward plan is provided as the argument + * and the plus sign is used if a reverse plan is provided as the argument; + * here N is the length of the input and output vectors z and Z. + * + * @param[out] output The complex output data vector Z of length N + * @param[in] input The input complex data vector z of length N + * @param[in] plan The FFT plan to use for the transform + * @note + * The input and output vectors must be distinct. + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALCOMPLEX16VectorFFT() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the input and output data + * vectors are the same. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * . + */ +int XLALCOMPLEX16VectorFFT( COMPLEX16Vector * restrict output, COMPLEX16Vector * restrict input, const COMPLEX16FFTPlan *plan ); /* @@ -132,6 +373,10 @@ int XLALCOMPLEX16VectorFFT( COMPLEX16Vector *output, COMPLEX16Vector *input, * */ +/** \b DEPRECATED + * @deprecated Use XLALCreateForwardCOMPLEX8FFTPlan instead. + * @see XLALCreateForwardCOMPLEX8FFTPlan + */ void LALCreateForwardCOMPLEX8FFTPlan( LALStatus *status, @@ -139,8 +384,16 @@ LALCreateForwardCOMPLEX8FFTPlan( UINT4 size, INT4 measure ); +/** \b DEPRECATED + * @deprecated Use XLALCreateForwardCOMPLEX8FFTPlan instead. + * @see XLALCreateForwardCOMPLEX8FFTPlan + */ #define LALCreateForwardComplexFFTPlan LALCreateForwardCOMPLEX8FFTPlan +/** \b DEPRECATED + * @deprecated Use XLALCreateReverseCOMPLEX8FFTPlan instead. + * @see XLALCreateReverseCOMPLEX8FFTPlan + */ void LALCreateReverseCOMPLEX8FFTPlan( LALStatus *status, @@ -148,15 +401,31 @@ LALCreateReverseCOMPLEX8FFTPlan( UINT4 size, INT4 measure ); +/** \b DEPRECATED + * @deprecated Use XLALCreateReverseCOMPLEX8FFTPlan instead. + * @see XLALCreateReverseCOMPLEX8FFTPlan + */ #define LALCreateReverseComplexFFTPlan LALCreateReverseCOMPLEX8FFTPlan +/** \b DEPRECATED + * @deprecated Use XLALDestroyCOMPLEX8FFTPlan instead. + * @see XLALDestroyCOMPLEX8FFTPlan + */ void LALDestroyCOMPLEX8FFTPlan ( LALStatus *status, COMPLEX8FFTPlan **plan ); +/** \b DEPRECATED + * @deprecated Use XLALDestroyCOMPLEX8FFTPlan instead. + * @see XLALDestroyCOMPLEX8FFTPlan + */ #define LALDestroyComplexFFTPlan LALDestroyCOMPLEX8FFTPlan +/** \b DEPRECATED + * @deprecated Use XLALCOMPLEX8VectorFFT instead. + * @see XLALCOMPLEX8VectorFFT + */ void LALCOMPLEX8VectorFFT ( LALStatus *status, @@ -167,10 +436,14 @@ LALCOMPLEX8VectorFFT ( /* * - * LAL COMPLEX8 functions + * LAL COMPLEX16 functions * */ +/** \b DEPRECATED + * @deprecated Use XLALCreateForwardCOMPLEX16FFTPlan instead. + * @see XLALCreateForwardCOMPLEX16FFTPlan + */ void LALCreateForwardCOMPLEX16FFTPlan( LALStatus *status, @@ -179,6 +452,10 @@ LALCreateForwardCOMPLEX16FFTPlan( INT4 measure ); +/** \b DEPRECATED + * @deprecated Use XLALCreateReverseCOMPLEX16FFTPlan instead. + * @see XLALCreateReverseCOMPLEX16FFTPlan + */ void LALCreateReverseCOMPLEX16FFTPlan( LALStatus *status, @@ -187,12 +464,20 @@ LALCreateReverseCOMPLEX16FFTPlan( INT4 measure ); +/** \b DEPRECATED + * @deprecated Use XLALDestroyCOMPLEX16FFTPlan instead. + * @see XLALDestroyCOMPLEX16FFTPlan + */ void LALDestroyCOMPLEX16FFTPlan ( LALStatus *status, COMPLEX16FFTPlan **plan ); +/** \b DEPRECATED + * @deprecated Use XLALCOMPLEX16VectorFFT instead. + * @see XLALCOMPLEX16VectorFFT + */ void LALCOMPLEX16VectorFFT ( LALStatus *status, diff --git a/lal/packages/fft/include/CudaPlan.h b/lal/packages/fft/include/CudaPlan.h index 1f233dd555f5dfb69c813902ae78243173591267..997dd7186fa0cb1f8ca7cd38dd711e8e150902f1 100644 --- a/lal/packages/fft/include/CudaPlan.h +++ b/lal/packages/fft/include/CudaPlan.h @@ -1,6 +1,9 @@ #ifndef _CUDAPLAN_H #define _CUDAPLAN_H +/* suppress warnings from cuda headers */ +#pragma GCC system_header + #include <lal/LALDatatypes.h> #include <fftw3.h> #include <cufft.h> diff --git a/lal/packages/fft/include/Makefile.am b/lal/packages/fft/include/Makefile.am index 661fb0b90473bfb670e76bdff4825d13d8fee66f..268fd99fd687d1ac7e5ac81879e5079be5b44a3b 100644 --- a/lal/packages/fft/include/Makefile.am +++ b/lal/packages/fft/include/Makefile.am @@ -1,5 +1,8 @@ ## Process this file with automake to produce Makefile.in pkginclude_HEADERS = ComplexFFT.h RealFFT.h FFTWMutex.h TimeFreqFFT.h +if CUDA +pkginclude_HEADERS += CudaPlan.h +endif MOSTLYCLEANFILES = .dvi-dep DISTCLEANFILES = *.tex all-local: include-link diff --git a/lal/packages/fft/include/RealFFT.h b/lal/packages/fft/include/RealFFT.h index 7dfa7d666fdce0b9a1bc87199240bec641ed844d..506349c5582e6d899338b89c32c94f27cb426ab4 100644 --- a/lal/packages/fft/include/RealFFT.h +++ b/lal/packages/fft/include/RealFFT.h @@ -91,7 +91,9 @@ NRCSID( REALFFTH, "$Id$" ); * **** </lalLaTeX> */ /**** <lalVerbatim> */ +/** Plan to perform FFT of REAL4 data */ typedef struct tagREAL4FFTPlan REAL4FFTPlan; +/** Plan to perform FFT of REAL8 data */ typedef struct tagREAL8FFTPlan REAL8FFTPlan; #define tagRealFFTPlan tagREAL4FFTPlan #define RealFFTPlan REAL4FFTPlan @@ -245,17 +247,221 @@ typedef struct tagREAL8FFTPlan REAL8FFTPlan; * */ +/** Returns a new REAL4FFTPlan + * + * A REAL4FFTPlan is required to perform a FFT that involves real data. + * A different plan is required for each size of the real data vector + * and for each direction of transform (forward or reverse). + * A forward transform performs + * \f[z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,x[j]\f] + * where N, the size of the transform, is the length of the vector x. + * A reverse transform performs + * \f[y[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,z[k]\f] + * where N, the size of the transform, is the length of the vector y. + * + * @note + * The reverse transform of the forward transform of some data is + * equal to N times the original data (we therefore call it a "reverse" + * transform rather than an "inverse" transform). + * + * @param[in] size The number of points in the real data. + * @param[in] fwdflag Set non-zero for a forward FFT plan; + * otherwise create a reverse plan + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c REAL4FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateREAL4Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ REAL4FFTPlan * XLALCreateREAL4FFTPlan( UINT4 size, int fwdflg, int measurelvl ); + +/** Returns a new REAL4FFTPlan for a forward transform + * + * A REAL4FFTPlan is required to perform a FFT that involves real data. + * A different plan is required for each size of the real data vector. + * A forward transform performs + * \f[z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,x[j]\f] + * where N, the size of the transform, is the length of the vector x. + * + * @param[in] size The number of points in the real data. + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c REAL4FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateForwardREAL4Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ REAL4FFTPlan * XLALCreateForwardREAL4FFTPlan( UINT4 size, int measurelvl ); + +/** Returns a new REAL4FFTPlan for a reverse transform + * + * A REAL4FFTPlan is required to perform a FFT that involves real data. + * A reverse transform performs + * \f[y[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,z[k]\f] + * where N, the size of the transform, is the length of the vector y. + * + * @note + * The reverse transform of the forward transform of some data is + * equal to N times the original data (we therefore call it a "reverse" + * transform rather than an "inverse" transform). + * + * @param[in] size The number of points in the real data. + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c REAL4FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateReverseREAL4Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ REAL4FFTPlan * XLALCreateReverseREAL4FFTPlan( UINT4 size, int measurelvl ); + +/** Destroys a REAL4FFTPlan + * @param[in] plan A pointer to the REAL4FFTPlan to be destroyed. + * @return None. + */ void XLALDestroyREAL4FFTPlan( REAL4FFTPlan *plan ); +/** Performs a forward FFT of REAL4 data + * + * This routine performs the transformation: + * \f[z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,x[j]\f] + * where N, the size of the transform, is the length of the vector x. + * + * @note + * Due to the reality of the input data x, the following identity + * holds for the complex FFT data: \f$z[N-k]=z^\ast[k]\f$. Therefore, + * the length of the output vector is equal to \f$\lfloor N/2\rfloor + 1\f$ + * since the remaining "negative" frequency components can be obtained from the + * "positive" frequency components. + * + * @param[out] output The complex data vector z of length [N/2] + 1 + * that results from the transform + * @param[in] input The real data vector x of length to be transformed + * @param[in] plan The FFT plan to use for the transform + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALREAL4ForwardFFT() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the plan is for a + * reverse transform. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * . + */ int XLALREAL4ForwardFFT( COMPLEX8Vector *output, const REAL4Vector *input, const REAL4FFTPlan *plan ); + +/** Performs a reverse FFT of REAL4 data + * + * This routine performs the transformation: + * \f[y[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,z[k]\f] + * where N, the size of the transform, is the length of the vector y. + * + * @note + * Due to the reality of the output data y, the following identity + * holds for the complex data: \f$z[N-k]=z^\ast[k]\f$. Therefore, + * the length of the input vector is equal to \f$\lfloor N/2\rfloor + 1\f$ + * since the remaining "negative" frequency components can be obtained from the + * "positive" frequency components. + * + * @param[out] output The real data vector y of length N + * that results from the transform + * @param[in] input The complex data vector z of length [N/2] + 1 + * to be transformed + * @param[in] plan The FFT plan to use for the transform + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALREAL4ForwardFFT() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the plan is for a + * reverse transform. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EDOM] Domain error if the DC component of the input data, z[0], + * is not purely real + * or if the length of the output vector N is even and the Nyquist + * component of the input data, z[N/2], is not purely real. + * . + */ int XLALREAL4ReverseFFT( REAL4Vector *output, const COMPLEX8Vector *input, const REAL4FFTPlan *plan ); -int XLALREAL4VectorFFT( REAL4Vector *output, const REAL4Vector *input, + +/** Perform a REAL4Vector to REAL4Vector FFT + * + * This routine computes + * \f[y[k]=\left\{\begin{array}{ll}\Re z[k]&0\le k\le\lfloor N/2\rfloor\\\Im z[N-k]&\lfloor N/2\rfloor<k<N\end{array}\right.\f] + * where \f[z[k] = \sum_{j=0}^{N-1} e^{\mp2\pi ijk/N}\,x[j],\f] + * and where the minus sign is used if a forward plan is provided as the argument + * and the plus sign is used if a reverse plan is provided as the argument; + * here N is the length of the input vector x. + * + * @param[out] output The real output data vector y of length N + * @param[in] input The input real data vector x of length N + * @param[in] plan The FFT plan to use for the transform + * @note + * The input and output vectors must be distinct. + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALREAL4VectorFFT() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the plan is for a + * reverse transform. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * . + */ +int XLALREAL4VectorFFT( REAL4Vector * restrict output, const REAL4Vector * restrict input, const REAL4FFTPlan *plan ); + +/** Computes the power spectrum of REAL4 data + * + * This routine computes + * \f[P[k]=\left\{\begin{array}{ll}|z[0]|^2&k=0\\2|z[k]|^2&1\lek<\lfloor (N+1)/2\rfloor\\|z[N/2]|^2&k=N/2,\;\mbox{$N$ even}\end{array}\right.\f] + * where \f[z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,x[j],\f] + * and N is the length of the input vector x. + * + * @param[out] output The real power spectrum P of length [N/2] + 1 of the data x + * @param[in] input The input real data vector x of length N + * @param[in] plan The FFT plan to use for the transform + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALREAL4PowerSpectrum() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the input and output + * data vectors are the same. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * . + */ int XLALREAL4PowerSpectrum( REAL4Vector *spec, const REAL4Vector *data, const REAL4FFTPlan *plan ); @@ -265,17 +471,221 @@ int XLALREAL4PowerSpectrum( REAL4Vector *spec, const REAL4Vector *data, * */ +/** Returns a new REAL8FFTPlan + * + * A REAL8FFTPlan is required to perform a FFT that involves real data. + * A different plan is required for each size of the real data vector + * and for each direction of transform (forward or reverse). + * A forward transform performs + * \f[z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,x[j]\f] + * where N, the size of the transform, is the length of the vector x. + * A reverse transform performs + * \f[y[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,z[k]\f] + * where N, the size of the transform, is the length of the vector y. + * + * @note + * The reverse transform of the forward transform of some data is + * equal to N times the original data (we therefore call it a "reverse" + * transform rather than an "inverse" transform). + * + * @param[in] size The number of points in the real data. + * @param[in] fwdflag Set non-zero for a forward FFT plan; + * otherwise create a reverse plan + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c REAL8FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateREAL8Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ REAL8FFTPlan * XLALCreateREAL8FFTPlan( UINT4 size, int fwdflg, int measurelvl ); + +/** Returns a new REAL8FFTPlan for a forward transform + * + * A REAL8FFTPlan is required to perform a FFT that involves real data. + * A different plan is required for each size of the real data vector. + * A forward transform performs + * \f[z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,x[j]\f] + * where N, the size of the transform, is the length of the vector x. + * + * @param[in] size The number of points in the real data. + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c REAL8FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateForwardREAL8Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ REAL8FFTPlan * XLALCreateForwardREAL8FFTPlan( UINT4 size, int measurelvl ); + +/** Returns a new REAL8FFTPlan for a reverse transform + * + * A REAL8FFTPlan is required to perform a FFT that involves real data. + * A reverse transform performs + * \f[y[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,z[k]\f] + * where N, the size of the transform, is the length of the vector y. + * + * @note + * The reverse transform of the forward transform of some data is + * equal to N times the original data (we therefore call it a "reverse" + * transform rather than an "inverse" transform). + * + * @param[in] size The number of points in the real data. + * @param[in] measurelvl Measurement level for plan creation: + * - 0: no measurement, just estimate the plan; + * - 1: measure the best plan; + * - 2: perform a lengthy measurement of the best plan; + * - 3: perform an exhasutive measurement of the best plan. + * @return A pointer to an allocated \c REAL8FFTPlan structure is returned + * upon successful completion. Otherwise, a \c NULL pointer is returned + * and \c xlalErrno is set to indicate the error. + * @par Errors: + * The \c XLALCreateReverseREAL8Plan() function shall fail if: + * - [\c XLAL_EBADLEN] The size of the requested plan is 0. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EFAILED] The call to the underlying FFTW routine failed. + * . + */ REAL8FFTPlan * XLALCreateReverseREAL8FFTPlan( UINT4 size, int measurelvl ); + +/** Destroys a REAL8FFTPlan + * @param[in] plan A pointer to the REAL8FFTPlan to be destroyed. + * @return None. + */ void XLALDestroyREAL8FFTPlan( REAL8FFTPlan *plan ); +/** Performs a forward FFT of REAL8 data + * + * This routine performs the transformation: + * \f[z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,x[j]\f] + * where N, the size of the transform, is the length of the vector x. + * + * @note + * Due to the reality of the input data x, the following identity + * holds for the complex FFT data: \f$z[N-k]=z^\ast[k]\f$. Therefore, + * the length of the output vector is equal to \f$\lfloor N/2\rfloor + 1\f$ + * since the remaining "negative" frequency components can be obtained from the + * "positive" frequency components. + * + * @param[out] output The complex data vector z of length [N/2] + 1 + * that results from the transform + * @param[in] input The real data vector x of length to be transformed + * @param[in] plan The FFT plan to use for the transform + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALREAL8ForwardFFT() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the plan is for a + * reverse transform. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * . + */ int XLALREAL8ForwardFFT( COMPLEX16Vector *output, REAL8Vector *input, const REAL8FFTPlan *plan ); + +/** Performs a reverse FFT of REAL8 data + * + * This routine performs the transformation: + * \f[y[j] = \sum_{k=0}^{N-1} e^{+2\pi ijk/N}\,z[k]\f] + * where N, the size of the transform, is the length of the vector y. + * + * @note + * Due to the reality of the output data y, the following identity + * holds for the complex data: \f$z[N-k]=z^\ast[k]\f$. Therefore, + * the length of the input vector is equal to \f$\lfloor N/2\rfloor + 1\f$ + * since the remaining "negative" frequency components can be obtained from the + * "positive" frequency components. + * + * @param[out] output The real data vector y of length N + * that results from the transform + * @param[in] input The complex data vector z of length [N/2] + 1 + * to be transformed + * @param[in] plan The FFT plan to use for the transform + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALREAL8ForwardFFT() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the plan is for a + * reverse transform. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * - [\c XLAL_EDOM] Domain error if the DC component of the input data, z[0], + * is not purely real + * or if the length of the output vector N is even and the Nyquist + * component of the input data, z[N/2], is not purely real. + * . + */ int XLALREAL8ReverseFFT( REAL8Vector *output, COMPLEX16Vector *input, const REAL8FFTPlan *plan ); + +/** Perform a REAL8Vector to REAL8Vector FFT + * + * This routine computes + * \f[y[k]=\left\{\begin{array}{ll}\Re z[k]&0\le k\le\lfloor N/2\rfloor\\\Im z[N-k]&\lfloor N/2\rfloor<k<N\end{array}\right.\f] + * where \f[z[k] = \sum_{j=0}^{N-1} e^{\mp2\pi ijk/N}\,x[j],\f] + * and where the minus sign is used if a forward plan is provided as the argument + * and the plus sign is used if a reverse plan is provided as the argument; + * here N is the length of the input vector x. + * + * @param[out] output The real output data vector y of length N + * @param[in] input The input real data vector x of length N + * @param[in] plan The FFT plan to use for the transform + * @note + * The input and output vectors must be distinct. + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALREAL8VectorFFT() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the input and output data + * vectors are the same. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * . + */ int XLALREAL8VectorFFT( REAL8Vector *output, REAL8Vector *input, const REAL8FFTPlan *plan ); + +/** Computes the power spectrum of REAL8 data + * + * This routine computes + * \f[P[k]=\left\{\begin{array}{ll}|z[0]|^2&k=0\\2|z[k]|^2&1\lek<\lfloor (N+1)/2\rfloor\\|z[N/2]|^2&k=N/2,\;\mbox{$N$ even}\end{array}\right.\f] + * where \f[z[k] = \sum_{j=0}^{N-1} e^{-2\pi ijk/N}\,x[j],\f] + * and N is the length of the input vector x. + * + * @param[out] output The real power spectrum P of length [N/2] + 1 of the data x + * @param[in] input The input real data vector x of length N + * @param[in] plan The FFT plan to use for the transform + * @return 0 upon successful completion or non-zero upon failure. + * @par Errors: + * The \c XLALREAL8PowerSpectrum() function shall fail if: + * - [\c XLAL_EFAULT] A \c NULL pointer is provided as one of the arguments. + * - [\c XLAL_EINVAL] A argument is invalid or the plan is for a + * reverse transform. + * - [\c XLAL_EBADLEN] The input vector, output vector, and plan size are + * incompatible. + * - [\c XLAL_ENOMEM] Insufficient storage space is available. + * . + */ int XLALREAL8PowerSpectrum( REAL8Vector *spec, REAL8Vector *data, const REAL8FFTPlan *plan ); @@ -285,6 +695,10 @@ int XLALREAL8PowerSpectrum( REAL8Vector *spec, REAL8Vector *data, * */ +/** \b DEPRECATED + * @deprecated Use XLALCreateForwardREAL4FFTPlan instead. + * @see XLALCreateForwardREAL4FFTPlan + */ void LALCreateForwardREAL4FFTPlan( LALStatus *status, @@ -292,8 +706,16 @@ LALCreateForwardREAL4FFTPlan( UINT4 size, INT4 measure ); +/** \b DEPRECATED + * @deprecated Use XLALCreateForwardREAL4FFTPlan instead. + * @see XLALCreateForwardREAL4FFTPlan + */ #define LALCreateForwardRealFFTPlan LALCreateForwardREAL4FFTPlan +/** \b DEPRECATED + * @deprecated Use XLALCreateReverseREAL4FFTPlan instead. + * @see XLALCreateReverseREAL4FFTPlan + */ void LALCreateReverseREAL4FFTPlan( LALStatus *status, @@ -301,15 +723,31 @@ LALCreateReverseREAL4FFTPlan( UINT4 size, INT4 measure ); +/** \b DEPRECATED + * @deprecated Use XLALCreateReverseREAL4FFTPlan instead. + * @see XLALCreateReverseREAL4FFTPlan + */ #define LALCreateReverseRealFFTPlan LALCreateReverseREAL4FFTPlan +/** \b DEPRECATED + * @deprecated Use XLALDestroyREAL4FFTPlan instead. + * @see XLALDestroyREAL4FFTPlan + */ void LALDestroyREAL4FFTPlan( LALStatus *status, REAL4FFTPlan **plan ); +/** \b DEPRECATED + * @deprecated Use XLALDestroyREAL4FFTPlan instead. + * @see XLALDestroyREAL4FFTPlan + */ #define LALDestroyRealFFTPlan LALDestroyREAL4FFTPlan +/** \b DEPRECATED + * @deprecated Use XLALREAL4ForwardFFT instead. + * @see XLALREAL4ForwardFFT + */ void LALForwardREAL4FFT( LALStatus *status, @@ -317,8 +755,16 @@ LALForwardREAL4FFT( REAL4Vector *input, REAL4FFTPlan *plan ); +/** \b DEPRECATED + * @deprecated Use XLALREAL4ForwardFFT instead. + * @see XLALREAL4ForwardFFT + */ #define LALForwardRealFFT LALForwardREAL4FFT +/** \b DEPRECATED + * @deprecated Use XLALREAL4ReverseFFT instead. + * @see XLALREAL4ReverseFFT + */ void LALReverseREAL4FFT( LALStatus *status, @@ -326,8 +772,16 @@ LALReverseREAL4FFT( COMPLEX8Vector *input, REAL4FFTPlan *plan ); +/** \b DEPRECATED + * @deprecated Use XLALREAL4ReverseFFT instead. + * @see XLALREAL4ReverseFFT + */ #define LALReverseRealFFT LALReverseREAL4FFT +/** \b DEPRECATED + * @deprecated Use XLALREAL4PowerSpectrum instead. + * @see XLALREAL4PowerSpectrum + */ void LALREAL4PowerSpectrum ( LALStatus *status, @@ -335,8 +789,16 @@ LALREAL4PowerSpectrum ( REAL4Vector *data, REAL4FFTPlan *plan ); +/** \b DEPRECATED + * @deprecated Use XLALREAL4PowerSpectrum instead. + * @see XLALREAL4PowerSpectrum + */ #define LALRealPowerSpectrum LALREAL4PowerSpectrum +/** \b DEPRECATED + * @deprecated Use XLALREAL4VectorFFT instead. + * @see XLALREAL4VectorFFT + */ void LALREAL4VectorFFT( LALStatus *status, @@ -351,6 +813,10 @@ LALREAL4VectorFFT( * */ +/** \b DEPRECATED + * @deprecated Use XLALCreateForwardREAL8FFTPlan instead. + * @see XLALCreateForwardREAL8FFTPlan + */ void LALCreateForwardREAL8FFTPlan( LALStatus *status, @@ -359,6 +825,10 @@ LALCreateForwardREAL8FFTPlan( INT4 measure ); +/** \b DEPRECATED + * @deprecated Use XLALCreateReverseREAL8FFTPlan instead. + * @see XLALCreateReverseREAL8FFTPlan + */ void LALCreateReverseREAL8FFTPlan( LALStatus *status, @@ -367,12 +837,20 @@ LALCreateReverseREAL8FFTPlan( INT4 measure ); +/** \b DEPRECATED + * @deprecated Use XLALDestroyREAL8FFTPlan instead. + * @see XLALDestroyREAL8FFTPlan + */ void LALDestroyREAL8FFTPlan( LALStatus *status, REAL8FFTPlan **plan ); +/** \b DEPRECATED + * @deprecated Use XLALREAL8ForwardFFT instead. + * @see XLALREAL8ForwardFFT + */ void LALForwardREAL8FFT( LALStatus *status, @@ -381,6 +859,10 @@ LALForwardREAL8FFT( REAL8FFTPlan *plan ); +/** \b DEPRECATED + * @deprecated Use XLALREAL8ReverseFFT instead. + * @see XLALREAL8ReverseFFT + */ void LALReverseREAL8FFT( LALStatus *status, @@ -389,6 +871,10 @@ LALReverseREAL8FFT( REAL8FFTPlan *plan ); +/** \b DEPRECATED + * @deprecated Use XLALREAL8PowerSpectrum instead. + * @see XLALREAL8PowerSpectrum + */ void LALREAL8PowerSpectrum ( LALStatus *status, @@ -397,6 +883,10 @@ LALREAL8PowerSpectrum ( REAL8FFTPlan *plan ); +/** \b DEPRECATED + * @deprecated Use XLALREAL8VectorFFT instead. + * @see XLALREAL8VectorFFT + */ void LALREAL8VectorFFT( LALStatus *status, diff --git a/lal/packages/fft/src/AverageSpectrum.c b/lal/packages/fft/src/AverageSpectrum.c index 5273e79aa5436fdbd4d81341b518f1a31400a3af..72c4b527d7c6c307c7d8fe2b63fce048e21fcf12 100644 --- a/lal/packages/fft/src/AverageSpectrum.c +++ b/lal/packages/fft/src/AverageSpectrum.c @@ -1350,9 +1350,12 @@ COMPLEX8FrequencySeries *XLALWhitenCOMPLEX8FrequencySeries(COMPLEX8FrequencySeri } /* zero the DC and Nyquist components for safety */ - if(fseries->f0 == 0) - fdata[0] = LAL_COMPLEX8_ZERO; - fdata[fseries->data->length - 1] = LAL_COMPLEX8_ZERO; + if(fseries->data->length) + { + if(fseries->f0 == 0) + fdata[0] = LAL_COMPLEX8_ZERO; + fdata[fseries->data->length - 1] = LAL_COMPLEX8_ZERO; + } /* update the units of fseries. norm has units of Hz */ XLALUnitDivide(&unit, &psd->sampleUnits, &lalHertzUnit); @@ -1400,9 +1403,12 @@ COMPLEX16FrequencySeries *XLALWhitenCOMPLEX16FrequencySeries(COMPLEX16FrequencyS } /* zero the DC and Nyquist components for safety */ - if(fseries->f0 == 0) - fdata[0] = LAL_COMPLEX16_ZERO; - fdata[fseries->data->length - 1] = LAL_COMPLEX16_ZERO; + if(fseries->data->length) + { + if(fseries->f0 == 0) + fdata[0] = LAL_COMPLEX16_ZERO; + fdata[fseries->data->length - 1] = LAL_COMPLEX16_ZERO; + } /* update the units of fseries. norm has units of Hz */ XLALUnitDivide(&unit, &psd->sampleUnits, &lalHertzUnit); @@ -1456,26 +1462,33 @@ LALPSDRegressor *XLALPSDRegressorNew(unsigned average_samples, unsigned median_s } -void XLALPSDRegressorFree(LALPSDRegressor *r) +void XLALPSDRegressorReset(LALPSDRegressor *r) { - if(r) + if(r->history) { - if(r->history) - { - unsigned i; - for(i = 0; i < r->median_samples; i++) + unsigned i; + for(i = 0; i < r->median_samples; i++) + if(r->history[i]) + { XLALDestroyREAL8Sequence(r->history[i]); - } - XLALFree(r->history); - XLALDestroyREAL8FrequencySeries(r->mean_square); + r->history[i] = NULL; + } } - free(r); + XLALDestroyREAL8FrequencySeries(r->mean_square); + r->mean_square = NULL; + r->n_samples = 0; } -void XLALPSDRegressorReset(LALPSDRegressor *r) +void XLALPSDRegressorFree(LALPSDRegressor *r) { - r->n_samples = 0; + if(r) + { + XLALPSDRegressorReset(r); + XLALFree(r->history); + r->history = NULL; + } + free(r); } @@ -1527,10 +1540,9 @@ int XLALPSDRegressorSetMedianSamples(LALPSDRegressor *r, unsigned median_samples { for(i = r->median_samples; i < median_samples; i++) { - r->history[i] = XLALCreateREAL8Sequence(r->history[0]->length); + r->history[i] = XLALCopyREAL8Sequence(r->history[r->median_samples - 1]); if(!r->history[i]) XLAL_ERROR(func, XLAL_EFUNC); - memcpy(r->history[i]->data, r->history[r->median_samples - 1]->data, r->history[i]->length * sizeof(*r->history[i]->data)); } } @@ -1554,22 +1566,22 @@ int XLALPSDRegressorAdd(LALPSDRegressor *r, const COMPLEX16FrequencySeries *samp double median_bias; unsigned i; - /* create frequency series if required */ + /* is this the first sample? */ - if(!r->mean_square) + if(!r->n_samples) { - /* create space for mean_square series and history series */ + /* create space for mean square series */ + XLALDestroyREAL8FrequencySeries(r->mean_square); r->mean_square = XLALCreateREAL8FrequencySeries(sample->name, &sample->epoch, sample->f0, sample->deltaF, &sample->sampleUnits, sample->data->length); if(!r->mean_square) - { - XLALDestroyREAL8FrequencySeries(r->mean_square); - r->mean_square = NULL; XLAL_ERROR(func, XLAL_EFUNC); - } + + /* create space for median history samples */ for(i = 0; i < r->median_samples; i++) { + XLALDestroyREAL8Sequence(r->history[i]); r->history[i] = XLALCreateREAL8Sequence(sample->data->length); if(!r->history[i]) { @@ -1594,8 +1606,12 @@ int XLALPSDRegressorAdd(LALPSDRegressor *r, const COMPLEX16FrequencySeries *samp /* set n_samples to 1 */ r->n_samples = 1; + + /* done */ + return 0; } + /* FIXME: also check units */ if((sample->f0 != r->mean_square->f0) || (sample->deltaF != r->mean_square->deltaF) || (sample->data->length != r->mean_square->data->length)) { @@ -1686,7 +1702,7 @@ REAL8FrequencySeries *XLALPSDRegressorGetPSD(const LALPSDRegressor *r) /* initialized yet? */ - if(!r->mean_square) { + if(!r->n_samples) { XLALPrintError("%s: not initialized", func); XLAL_ERROR_NULL(func, XLAL_EDATA); } @@ -1734,18 +1750,13 @@ int XLALPSDRegressorSetPSD(LALPSDRegressor *r, const REAL8FrequencySeries *psd, double lal_normalization_constant = 2 * psd->deltaF; unsigned i; - if(!r->mean_square) + if(!r->n_samples) { /* initialize the mean square array to a copy of the PSD */ + XLALDestroyREAL8FrequencySeries(r->mean_square); r->mean_square = XLALCutREAL8FrequencySeries(psd, 0, psd->data->length); - - /* failure? */ if(!r->mean_square) - { - XLALDestroyREAL8FrequencySeries(r->mean_square); - r->mean_square = NULL; XLAL_ERROR(func, XLAL_EFUNC); - } /* normalization constant to be removed has units of Hz */ XLALUnitDivide(&r->mean_square->sampleUnits, &r->mean_square->sampleUnits, &lalHertzUnit); @@ -1754,6 +1765,7 @@ int XLALPSDRegressorSetPSD(LALPSDRegressor *r, const REAL8FrequencySeries *psd, for(i = 0; i < r->median_samples; i++) { + XLALDestroyREAL8Sequence(r->history[i]); r->history[i] = XLALCreateREAL8Sequence(r->mean_square->data->length); /* failure? */ diff --git a/lal/packages/fft/src/ComplexFFT.c b/lal/packages/fft/src/ComplexFFT.c index 7d460aab566a15d0cc116b33bdc31e749ef7202c..8aff6558984e9de5b28ed9d30147335519ef6d89 100644 --- a/lal/packages/fft/src/ComplexFFT.c +++ b/lal/packages/fft/src/ComplexFFT.c @@ -132,20 +132,22 @@ NRCSID( COMPLEXFFTC, "$Id$" ); +/** Plan to perform an FFT of COMPLEX8 data */ struct tagCOMPLEX8FFTPlan { - INT4 sign; - UINT4 size; - fftwf_plan plan; + INT4 sign; /*< sign in transform exponential, -1 for forward, +1 for reverse */ + UINT4 size; /*< length of the complex data vector for this plan */ + fftwf_plan plan; /*< the FFTW plan */ }; +/** Plan to perform an FFT of COMPLEX16 data */ struct tagCOMPLEX16FFTPlan { - INT4 sign; - UINT4 size; - fftw_plan plan; + INT4 sign; /*< sign in transform exponential, -1 for forward, +1 for reverse */ + UINT4 size; /*< length of the complex data vector for this plan */ + fftw_plan plan; /*< the FFTW plan */ }; diff --git a/lal/packages/fft/src/CudaComplexFFT.c b/lal/packages/fft/src/CudaComplexFFT.c index 6c60fdc9445b0fabd95cb0d0b2273e7b32397f68..eeaae517a683a611bf12bcfdd048e73f649477db 100644 --- a/lal/packages/fft/src/CudaComplexFFT.c +++ b/lal/packages/fft/src/CudaComplexFFT.c @@ -129,12 +129,11 @@ #include <lal/ComplexFFT.h> #include <lal/CudaPlan.h> #include <lal/FFTWMutex.h> -#include <CudaFunctions.h> -#include <cuda.h> -#include <cuda_runtime.h> -#include <cufft.h> #include <fftw3.h> +#include "CudaFunctions.h" +#include "CudaFFT.h" + NRCSID( COMPLEXFFTC, "$Id$" ); /* @@ -153,6 +152,9 @@ COMPLEX8FFTPlan * XLALCreateCOMPLEX8FFTPlan( UINT4 size, int fwdflg, int measure if ( ! size ) XLAL_ERROR_NULL( func, XLAL_EBADLEN ); + /* "use" measurelvl */ + measurelvl = 0; + /* allocate memory for the plan and the temporary arrays */ plan = XLALMalloc( sizeof( *plan ) ); if ( ! plan ) diff --git a/lal/packages/fft/src/CudaFFT.cu b/lal/packages/fft/src/CudaFFT.cu index 7d912e5063781c443ef97e7aa189a7afca13512d..bfc944ab712a6e0a01c1d449466de76ee036cae0 100644 --- a/lal/packages/fft/src/CudaFFT.cu +++ b/lal/packages/fft/src/CudaFFT.cu @@ -1,5 +1,5 @@ #include <lal/LALDatatypes.h> -#include <CudaFunctions.h> +#include "CudaFunctions.h" int cudafft_execute_r2c(cufftHandle plan, cufftComplex *output, const cufftReal *input, diff --git a/lal/packages/fft/src/CudaFunctions.c b/lal/packages/fft/src/CudaFunctions.c index 224e9519b9bb79657893125fc9a6cdffb8a08dbb..fd6f74c83b85e3f35810477a4993f7e14ff8693c 100644 --- a/lal/packages/fft/src/CudaFunctions.c +++ b/lal/packages/fft/src/CudaFunctions.c @@ -1,7 +1,8 @@ #include <lal/LALDatatypes.h> #include <lal/XLALError.h> -#include <CudaFunctions.h> #include <cuda_runtime.h> +#include "CudaFunctions.h" + REAL4 *XLALCudaMallocReal(UINT4 size) { @@ -10,7 +11,7 @@ REAL4 *XLALCudaMallocReal(UINT4 size) cudaMalloc( (void **)&d_data, sizeof(REAL4) * size ); if( !d_data ) - XLAL_ERROR_NULL( func, XLAL_ENOMEM ); + XLAL_ERROR_NULL( func, XLAL_ENOMEM ); return d_data; } @@ -21,7 +22,7 @@ COMPLEX8 *XLALCudaMallocComplex(UINT4 size) cudaMalloc( (void **)&d_data, sizeof(COMPLEX8) * size ); if( !d_data ) - XLAL_ERROR_NULL( func, XLAL_ENOMEM ); + XLAL_ERROR_NULL( func, XLAL_ENOMEM ); return d_data; } @@ -29,6 +30,6 @@ void XLALCudaFree(void *d_data) { static const char *func = "XLALCudaFree"; if( !d_data ) - XLAL_ERROR_VOID( func, XLAL_EFAULT ); + XLAL_ERROR_VOID( func, XLAL_EFAULT ); cudaFree(d_data); } diff --git a/lal/packages/fft/src/CudaFunctions.h b/lal/packages/fft/src/CudaFunctions.h index 1007a2c5e049a0b6386aadf456cfedfae44d3bc5..bcff91ea4e52c0bd389f82da3fa09702adfdf403 100644 --- a/lal/packages/fft/src/CudaFunctions.h +++ b/lal/packages/fft/src/CudaFunctions.h @@ -1,3 +1,6 @@ +/* supress warnings from cuda headers */ +#pragma GCC system_header + #include <lal/LALDatatypes.h> #include <cufft.h> diff --git a/lal/packages/fft/src/CudaRealFFT.c b/lal/packages/fft/src/CudaRealFFT.c index 43660f05592f43f1a4fb7c7b552f5a652079d8b5..90b20178525ff6514c8b2c81eee7d41cc78be4e1 100644 --- a/lal/packages/fft/src/CudaRealFFT.c +++ b/lal/packages/fft/src/CudaRealFFT.c @@ -160,12 +160,11 @@ #include <lal/RealFFT.h> #include <lal/XLALError.h> #include <lal/FFTWMutex.h> -#include <CudaFunctions.h> -#include <cuda.h> -#include <cuda_runtime.h> -#include <cufft.h> #include <fftw3.h> +#include "CudaFunctions.h" +#include "CudaFFT.h" + NRCSID( REALFFTC, "$Id$" ); @@ -204,6 +203,9 @@ REAL4FFTPlan * XLALCreateREAL4FFTPlan( UINT4 size, int fwdflg, int measurelvl ) if ( ! size ) XLAL_ERROR_NULL( func, XLAL_EBADLEN ); + /* "use" measurelvl */ + measurelvl = 0; + /* allocate memory for the plan and the temporary arrays */ plan = XLALMalloc( sizeof( *plan ) ); if ( ! plan ) diff --git a/lal/packages/fft/src/Makefile.am b/lal/packages/fft/src/Makefile.am index 0b1c4abdb0fa1b850b95049897e2279ebdc70219..c03625c36fad7368a1476e6bc957cfa10406e906 100644 --- a/lal/packages/fft/src/Makefile.am +++ b/lal/packages/fft/src/Makefile.am @@ -10,17 +10,32 @@ if INTELFFT FFTSRC = IntelComplexFFT.c IntelRealFFT.c $(QTHREADSRC) EXTRA_TEXSOURCES = ComplexFFT.c RealFFT.c FFTWMutex.c else +if CUDA +FFTSRC = CudaComplexFFT.c CudaRealFFT.c FFTWMutex.c CudaFunctions.c CudaFFT.cu +else FFTSRC = ComplexFFT.c RealFFT.c FFTWMutex.c EXTRA_TEXSOURCES = endif +endif noinst_LTLIBRARIES = libfft.la libfft_la_SOURCES = $(FFTSRC) TimeFreqFFT.c AverageSpectrum.c Convolution.c INCLUDES = -I$(top_builddir)/include -I$(srcdir)/../include EXTRA_DIST = qthread.c IntelComplexFFT.c IntelRealFFT.c \ - ComplexFFT.c RealFFT.c FFTWMutex.c TimeFreqFFT.c + ComplexFFT.c RealFFT.c FFTWMutex.c TimeFreqFFT.c \ + CudaComplexFFT.c CudaRealFFT.c CudaFFT.cu CudaFunctions.h \ + CudaFFT.h +if CUDA +MAINTAINERCLEANFILES = CudaFFT.cu.c CudaFFT.cu.loT +endif MOSTLYCLEANFILES = .dvi-dep DISTCLEANFILES = *.tex dvi-local: .dvi-dep @DVIMKFILE@ + +if CUDA +SUFFIXES = .cu .c +.cu.c: + @nvcc -cuda --host-compilation=c $(INCLUDES) $(CPPFLAGS) --output-file $@ $< +endif diff --git a/lal/packages/fft/src/RealFFT.c b/lal/packages/fft/src/RealFFT.c index c92584ba3f95959ae565dd70185d3e0b4f4e735c..40685074d6927bf1dd1dc7836c4ef34c2924dff8 100644 --- a/lal/packages/fft/src/RealFFT.c +++ b/lal/packages/fft/src/RealFFT.c @@ -166,20 +166,22 @@ NRCSID( REALFFTC, "$Id$" ); +/** Plan to perform FFT of REAL4 data */ struct tagREAL4FFTPlan { - INT4 sign; - UINT4 size; - fftwf_plan plan; + INT4 sign; /*< sign in transform exponential, -1 for forward, +1 for reverse */ + UINT4 size; /*< length of the real data vector for this plan */ + fftwf_plan plan; /*< the FFTW plan */ }; +/** Plan to perform FFT of REAL8 data */ struct tagREAL8FFTPlan { - INT4 sign; - UINT4 size; - fftw_plan plan; + INT4 sign; /*< sign in transform exponential, -1 for forward, +1 for reverse */ + UINT4 size; /*< length of the real data vector for this plan */ + fftw_plan plan; /*< the FFTW plan */ }; @@ -394,7 +396,7 @@ int XLALREAL4ReverseFFT( REAL4Vector *output, const COMPLEX8Vector *input, } -int XLALREAL4VectorFFT( REAL4Vector *output, const REAL4Vector *input, +int XLALREAL4VectorFFT( REAL4Vector * restrict output, const REAL4Vector * restrict input, const REAL4FFTPlan *plan ) { static const char *func = "XLALREAL4VectorFFT"; @@ -674,7 +676,7 @@ int XLALREAL8ReverseFFT( REAL8Vector *output, COMPLEX16Vector *input, } -int XLALREAL8VectorFFT( REAL8Vector *output, REAL8Vector *input, +int XLALREAL8VectorFFT( REAL8Vector * restrict output, REAL8Vector * restrict input, const REAL8FFTPlan *plan ) { static const char *func="XLALREAL8VectorFFT"; diff --git a/lal/packages/fft/test/ComplexFFTTest.c b/lal/packages/fft/test/ComplexFFTTest.c index 7c21c57b9affc50d154d66ce2bda9fa230dac10f..2f9f48b714393d9dfc9bb66a450a439fee72c366 100644 --- a/lal/packages/fft/test/ComplexFFTTest.c +++ b/lal/packages/fft/test/ComplexFFTTest.c @@ -73,6 +73,7 @@ #include <lal/LALStdlib.h> #include <lal/AVFactories.h> #include <lal/ComplexFFT.h> +#include <config.h> #define CODES_(x) #x #define CODES(x) CODES_(x) @@ -104,7 +105,11 @@ int main( int argc, char *argv[] ) { const UINT4 n = 17; +#if LAL_CUDA_ENABLED + const REAL4 eps = 1e-4; +#else const REAL4 eps = 1e-6; +#endif static LALStatus status; ComplexFFTPlan *pfwd = NULL; diff --git a/lal/packages/fft/test/RealFFTTest.c b/lal/packages/fft/test/RealFFTTest.c index 0e1e70705efd4ff46f94c9ed12be193e3a09527e..290c0009c955c839bbd3e01b0ce9c0fbbcf5db53 100644 --- a/lal/packages/fft/test/RealFFTTest.c +++ b/lal/packages/fft/test/RealFFTTest.c @@ -81,6 +81,7 @@ #include <lal/SeqFactories.h> #include <lal/RealFFT.h> #include <lal/VectorOps.h> +#include <config.h> #define CODES_(x) #x #define CODES(x) CODES_(x) @@ -124,7 +125,14 @@ int main( int argc, char *argv[] ) REAL4Vector *ans = NULL; COMPLEX8Vector *dft = NULL; COMPLEX8Vector *fft = NULL; - REAL8 eps = 1e-6; /* very conservative floating point precision */ +#if LAL_CUDA_ENABLED + /* The test itself should pass at 1e-4, but it might fail at + * some rare cases where accuracy is bad for some numbers. */ + REAL8 eps = 3e-4; +#else + /* very conservative floating point precision */ + REAL8 eps = 1e-6; +#endif REAL8 lbn; REAL8 ssq; REAL8 var; diff --git a/lal/packages/findchirp/include/CoherentInspiral.h b/lal/packages/findchirp/include/CoherentInspiral.h index 7aeef6258a3c15cbc5c85eff7997abbf80295fcd..2e634d364884e9bb56ae09eb2c5d43ca7446e2b5 100644 --- a/lal/packages/findchirp/include/CoherentInspiral.h +++ b/lal/packages/findchirp/include/CoherentInspiral.h @@ -65,7 +65,6 @@ The coherent statistic will be defined here. #include <lal/LALConstants.h> #include <lal/AVFactories.h> #include <lal/LALDatatypes.h> -#include <lal/DataBuffer.h> #include <lal/LIGOMetadataTables.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> diff --git a/lal/packages/findchirp/include/FindChirp.h b/lal/packages/findchirp/include/FindChirp.h index 55ccac4c284624893d4a05db118191dfa6bc28e0..02b2b3ab141f034b48343b743d4e0ac804c3003d 100644 --- a/lal/packages/findchirp/include/FindChirp.h +++ b/lal/packages/findchirp/include/FindChirp.h @@ -100,7 +100,6 @@ that implement the search. #include <lal/LALDatatypes.h> #include <lal/ComplexFFT.h> -#include <lal/DataBuffer.h> #include <lal/LIGOMetadataTables.h> #include <lal/LIGOMetadataUtils.h> #include <lal/LALInspiral.h> diff --git a/lal/packages/findchirp/include/FindChirpBCV.h b/lal/packages/findchirp/include/FindChirpBCV.h index 4ba3ebf56e533374a3b01bd9ebbda0bb3936f252..f860da390478d91cfe64a45854697dfeaf7d756b 100644 --- a/lal/packages/findchirp/include/FindChirpBCV.h +++ b/lal/packages/findchirp/include/FindChirpBCV.h @@ -58,7 +58,6 @@ family. #include <lal/LALDatatypes.h> #include <lal/RealFFT.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpChisq.h> diff --git a/lal/packages/findchirp/include/FindChirpBCVSpin.h b/lal/packages/findchirp/include/FindChirpBCVSpin.h index b0d63d1938bde3726584481fecaf3a87c2bf6a96..bc5c05137002b7a1face06f7e5ce2e183ad049e8 100644 --- a/lal/packages/findchirp/include/FindChirpBCVSpin.h +++ b/lal/packages/findchirp/include/FindChirpBCVSpin.h @@ -58,7 +58,6 @@ template family. #include <lal/LALDatatypes.h> #include <lal/RealFFT.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpChisq.h> diff --git a/lal/packages/findchirp/include/FindChirpDatatypes.h b/lal/packages/findchirp/include/FindChirpDatatypes.h index ed1b47da2269987706518b7cc11bf371a8184d4e..d9c2d76508c16170ec11708e02df7a393b77b247 100644 --- a/lal/packages/findchirp/include/FindChirpDatatypes.h +++ b/lal/packages/findchirp/include/FindChirpDatatypes.h @@ -54,7 +54,6 @@ findchirp. #define _FINDCHIRPDATATYPESH_H #include <lal/LALDatatypes.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #ifdef __cplusplus @@ -107,6 +106,18 @@ tagFindChirpStandardCandle } FindChirpStandardCandle; /* </lalVerbatim> */ + +typedef struct +tagDataSegment +{ + REAL4TimeSeries *chan; + REAL4FrequencySeries *spec; + COMPLEX8FrequencySeries *resp; + INT4 number; + UINT4 analyzeSegment; +} +DataSegment; + #if 0 <lalLaTeX> \begin{description} diff --git a/lal/packages/findchirp/include/FindChirpPTF.h b/lal/packages/findchirp/include/FindChirpPTF.h index 59a133787acf816a76577701aeab16dfc31d3efa..ae6d52cf3c59b2afee18bcff691febdb6d9cb41a 100644 --- a/lal/packages/findchirp/include/FindChirpPTF.h +++ b/lal/packages/findchirp/include/FindChirpPTF.h @@ -57,7 +57,6 @@ physical template family. #include <lal/LALDatatypes.h> #include <lal/RealFFT.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> diff --git a/lal/packages/findchirp/include/FindChirpSP.h b/lal/packages/findchirp/include/FindChirpSP.h index 5c198bbbf761b5dd4e230ee4d8255905de3bfc25..d7783c77660f09cd4d5cddee400c7c8ad26d9a7f 100644 --- a/lal/packages/findchirp/include/FindChirpSP.h +++ b/lal/packages/findchirp/include/FindChirpSP.h @@ -57,7 +57,6 @@ and generate binary inspiral chirps using the stationary phase approximation. #include <lal/LALDatatypes.h> #include <lal/RealFFT.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpChisq.h> diff --git a/lal/packages/findchirp/include/FindChirpTD.h b/lal/packages/findchirp/include/FindChirpTD.h index aa2c0df13a05b03e6ae443d2a894705dd3ce96ed..b27aec2c9fa8cade35b6329df972e9de59297597 100644 --- a/lal/packages/findchirp/include/FindChirpTD.h +++ b/lal/packages/findchirp/include/FindChirpTD.h @@ -56,7 +56,6 @@ and generate binary inspiral chirps using time domain waveforms. #include <lal/LALDatatypes.h> #include <lal/RealFFT.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpChisq.h> diff --git a/lal/packages/findchirp/include/NullStatistic.h b/lal/packages/findchirp/include/NullStatistic.h index 713ab782b753ef78e878be4fa4488dbdc39e6d1c..849c0e01743b5627eb0e7dd8f2d7bbbe005d8c4f 100644 --- a/lal/packages/findchirp/include/NullStatistic.h +++ b/lal/packages/findchirp/include/NullStatistic.h @@ -65,7 +65,6 @@ The null statistic will be defined here. #include <lal/LALConstants.h> #include <lal/AVFactories.h> #include <lal/LALDatatypes.h> -#include <lal/DataBuffer.h> #include <lal/LIGOMetadataTables.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> diff --git a/lal/packages/findchirp/src/CoherentInspiralFilter.c b/lal/packages/findchirp/src/CoherentInspiralFilter.c index 951fb97e929e566012cdff98a618fcba9612c902..8711cead0b009c98ca05befdb993b26d15f81be8 100644 --- a/lal/packages/findchirp/src/CoherentInspiralFilter.c +++ b/lal/packages/findchirp/src/CoherentInspiralFilter.c @@ -37,11 +37,9 @@ #include <lal/LALStdio.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/FindChirp.h> #include <lal/FindChirpSP.h> #include <lal/DetectorSite.h> -#include <lal/StochasticCrossCorrelation.h> #include <lal/LIGOMetadataTables.h> #include <lal/SkyCoordinates.h> #include <lal/Date.h> @@ -2921,7 +2919,6 @@ LALCoherentInspiralFilterSegment ( { /* Network: 3 detectors excluding either H1, H2, or both (H1 && H2)*/ /*Now the last 3 cases will involve the looping over the coefficients*/ LIGOTimeGPS triggerGPSEndTime;/* Needed to calculate time-delays */ - LALMSTUnitsAndAcc pUnitsAndAcc; double psiInRadians = 0.0; double detRefLocation[3]; double detNextLocation[3]; @@ -2934,9 +2931,7 @@ LALCoherentInspiralFilterSegment ( triggerGPSEndTime.gpsNanoSeconds = cData[0]->epoch.gpsNanoSeconds; /* Convert GPS time of trigger to GMST time in radians for computing F+, Fx */ - pUnitsAndAcc.units = MST_RAD; - pUnitsAndAcc.accuracy = LALLEAPSEC_LOOSE; - LALGPStoGMST1(status->statusPtr,&gmstInRadians,&triggerGPSEndTime,&pUnitsAndAcc); + gmstInRadians = XLALGreenwichMeanSiderealTime(&triggerGPSEndTime); /* Following needed because XLALArrivalTimeDiff() uses doubles */ for ( locIdx=0 ; locIdx<3 ; locIdx++ ) { @@ -3092,10 +3087,10 @@ LALCoherentInspiralFilterSegment ( MM2 /= ( 4*BB*BB + (AA-CC+discrimSqrt)*(AA-CC+discrimSqrt) ); /* Regularize */ - if ( (MM1<1.0e-4 ) ) - MM1=1.0e-4; - if ( (MM2<1.0e-4 ) ) - MM2=1.0e-4; + if ( (MM1<1.0e-1 ) ) + MM1=1.0e-1; + if ( (MM2<1.0e-1 ) ) + MM2=1.0e-1; /*Initialize cohSNR components and time stamps */ CRePlus = 0.0; @@ -3232,14 +3227,8 @@ LALCoherentInspiralFilterSegment ( thisEvent->mass2 = input->tmplt->mass2; thisEvent->mchirp = input->tmplt->totalMass * pow( input->tmplt->eta, 3.0/5.0 ); thisEvent->eta = input->tmplt->eta; - /* Compute null-statistic for H1-H2 at just trigger end-time */ - nullNorm = ( 1.0 / sigmasq[1] + 1.0 / sigmasq[2] ); - nullStatRe = thisEvent->h1quad.re / sqrt(sigmasq[1]) - - thisEvent->h2quad.re / sqrt(sigmasq[2]); - nullStatIm = thisEvent->h1quad.im / sqrt(sigmasq[1]) - - thisEvent->h2quad.im / sqrt(sigmasq[2]); - thisEvent->null_statistic = ( nullStatRe*nullStatRe + nullStatIm*nullStatIm ) / nullNorm ; - + /* Since not both H1 and H2 are present, the H1H2 null-stat is not meaningful*/ + thisEvent->null_statistic = -1; /* Compute network null-statistic at just trigger end-time */ thisEvent->tau5 = (REAL4) XLALComputeNullStatCase3b(caseID,fplus,fcross,sigmasq,thisEvent); @@ -3387,13 +3376,8 @@ LALCoherentInspiralFilterSegment ( thisEvent->mass2 = input->tmplt->mass2; thisEvent->mchirp = input->tmplt->totalMass * pow( input->tmplt->eta, 3.0/5.0 ); thisEvent->eta = input->tmplt->eta; - /* Compute null-statistic for H1-H2 at just trigger end-time */ - nullNorm = ( 1.0 / sigmasq[1] + 1.0 / sigmasq[2] ); - nullStatRe = thisEvent->h1quad.re / sqrt(sigmasq[1]) - - thisEvent->h2quad.re / sqrt(sigmasq[2]); - nullStatIm = thisEvent->h1quad.im / sqrt(sigmasq[1]) - - thisEvent->h2quad.im / sqrt(sigmasq[2]); - thisEvent->null_statistic = ( nullStatRe*nullStatRe + nullStatIm*nullStatIm ) / nullNorm ; + /* Since not both H1 and H2 are present, the H1H2 null-stat is not meaningful*/ + thisEvent->null_statistic = -1; /* Compute network null-statistic at just trigger end-time */ thisEvent->tau5 = (REAL4) XLALComputeNullStatCase3b(caseID,fplus,fcross,sigmasq,thisEvent); @@ -3557,13 +3541,8 @@ LALCoherentInspiralFilterSegment ( thisEvent->mass2 = input->tmplt->mass2; thisEvent->mchirp = input->tmplt->totalMass * pow( input->tmplt->eta, 3.0/5.0 ); thisEvent->eta = input->tmplt->eta; - /* Compute null-statistic for H1-H2 at just trigger end-time */ - nullNorm = ( 1.0 / sigmasq[1] + 1.0 / sigmasq[2] ); - nullStatRe = thisEvent->h1quad.re / sqrt(sigmasq[1]) - - thisEvent->h2quad.re / sqrt(sigmasq[2]); - nullStatIm = thisEvent->h1quad.im / sqrt(sigmasq[1]) - - thisEvent->h2quad.im / sqrt(sigmasq[2]); - thisEvent->null_statistic = ( nullStatRe*nullStatRe + nullStatIm*nullStatIm ) / nullNorm ; + /* Since not both H1 and H2 are present, the H1H2 null-stat is not meaningful*/ + thisEvent->null_statistic = -1; /* Compute network null-statistic at just trigger end-time */ thisEvent->tau5 = (REAL4) XLALComputeNullStatCase3b(caseID,fplus,fcross,sigmasq,thisEvent); @@ -3643,7 +3622,6 @@ LALCoherentInspiralFilterSegment ( case 4: /* Network: 4 detectors */ { LIGOTimeGPS triggerGPSEndTime;/* Needed to calculate time-delays */ - LALMSTUnitsAndAcc pUnitsAndAcc; double psiInRadians = 0.0; double detRefLocation[3]; double detNextLocation[3]; @@ -3656,9 +3634,7 @@ LALCoherentInspiralFilterSegment ( triggerGPSEndTime.gpsNanoSeconds = cData[0]->epoch.gpsNanoSeconds; /* Convert GPS time of trigger to GMST time in radians for computing F+, Fx */ - pUnitsAndAcc.units = MST_RAD; - pUnitsAndAcc.accuracy = LALLEAPSEC_LOOSE; - LALGPStoGMST1(status->statusPtr,&gmstInRadians,&triggerGPSEndTime,&pUnitsAndAcc); + gmstInRadians = XLALGreenwichMeanSiderealTime(&triggerGPSEndTime); /* Following needed because XLALArrivalTimeDiff() uses doubles */ for ( locIdx=0 ; locIdx<3 ; locIdx++ ) { @@ -3822,10 +3798,10 @@ LALCoherentInspiralFilterSegment ( MM2 /= ( 4*BB*BB + (AA-CC+discrimSqrt)*(AA-CC+discrimSqrt) ); /* Regularize */ - if ( (MM1<1.0e-4 ) ) - MM1=1.0e-4; - if ( (MM2<1.0e-4 ) ) - MM2=1.0e-4; + if ( (MM1<1.0e-1 ) ) + MM1=1.0e-1; + if ( (MM2<1.0e-1 ) ) + MM2=1.0e-1; /*Initialize cohSNR components and time stamps */ CRePlus = 0.0; @@ -4390,26 +4366,7 @@ LALCoherentInspiralFilterSegment ( } /* closes switch(params->numDetectors) */ - /* Compute null-statistic for H1-H2 at just trigger end-time, - and NOT the H1H2 null-statistic time-series */ - if( thisEvent && !(params->nullStatH1H2Out) && (case2a || case3a)) { - /* Prepare norm for null statistic */ - nullNorm = ( 1.0 / sigmasq[1] + 1.0 / sigmasq[2] ); - - /*CHECK: Will not give intended result if first det is "G1", since it - assumes that cdata[0] is H1 and cdata[1] is H2; rectify this in next rev. */ - /* Compute null-stream statistic; - in next rev. report re and im parts separately */ - nullStatRe = thisEvent->h1quad.re / sqrt(sigmasq[1]) - - thisEvent->h2quad.re / sqrt(sigmasq[2]); - nullStatIm = thisEvent->h1quad.im / sqrt(sigmasq[1]) - - thisEvent->h2quad.im / sqrt(sigmasq[2]); - - thisEvent->null_statistic = ( nullStatRe*nullStatRe + nullStatIm*nullStatIm ) / nullNorm ; - } - - /* Compute null-statistic, just for H1-H2 as of now, - and cohSNRH1H2, if not computed above already + /* Compute time-series of the null-statistic of H1-H2 and of cohSNRH1H2 if( thisEvent && params->nullStatOut && params->cohH1H2SNROut && !(case3b || case4a) ) { */ @@ -4447,19 +4404,9 @@ LALCoherentInspiralFilterSegment ( params->nullStatH1H2Vec->data->data[k] = ( nullStatRe*nullStatRe + nullStatIm*nullStatIm ) / nullNorm ; } - /* CHECK: - thisEvent->null_statistic = params->nullStatVec->data->data[(INT4)(numPoints/2)]; - */ - nullStatRe = thisEvent->h1quad.re / sqrt(sigmasq[1]) - - thisEvent->h2quad.re / sqrt(sigmasq[2]); - nullStatIm = thisEvent->h1quad.im / sqrt(sigmasq[1]) - - thisEvent->h2quad.im / sqrt(sigmasq[2]); - - thisEvent->null_statistic = ( nullStatRe*nullStatRe + nullStatIm*nullStatIm ) / nullNorm ; - } - /* Compute null-statistic ONLY, just for H1-H2 as of now, and NOT cohH1H2SNR */ + /* Compute H1H2 null-statistic time-series and NOT cohH1H2SNR */ if( thisEvent && params->nullStatH1H2Out && !(params->cohH1H2SNROut) && !(case3b || case4a) ) { @@ -4481,12 +4428,11 @@ LALCoherentInspiralFilterSegment ( params->nullStatH1H2Vec->data->data[k] = ( nullStatRe*nullStatRe + nullStatIm*nullStatIm ) / nullNorm ; } - thisEvent->null_statistic = params->nullStatH1H2Vec->data->data[(INT4)(numPoints/2)]; } /* Compute cohSNRH1H2 ONLY, if not computed above already, but NOT the full null-statistic time-series */ - if( params->cohH1H2SNROut && !nullStatH1H2Out ) { + if( thisEvent && params->cohH1H2SNROut && !nullStatH1H2Out ) { /* Allocate memory for cohSNRH1H2Vec if that SNR has not been computed above already*/ memset( params->cohH1H2SNRVec->data->data, 0, numPoints*sizeof(REAL4)); @@ -4506,105 +4452,6 @@ LALCoherentInspiralFilterSegment ( (sigmasq[1] + sigmasq[2] ) ); } } - - /*CHECK: The following is deactivated for now (because of the "0" - in the condition of the "if" statment. - Next update will handle null-statistic time-series computation - if( thisEvent && params->nullStatOut && case3b ){ */ - if( thisEvent && case3b && !(params->nullStatOut) ){ - /* This trigger is from either H1 or H2 but not both */ - REAL8 sigmasqH = 0.0; - REAL8 nullNorm8 = 0.0; - REAL8 nullNumerRe8 = 0.0; - REAL8 nullNumerIm8 = 0.0; - - detId = 0; - for( j=0; j<LAL_NUM_IFO; j++ ) { - /* Compute antenna-patterns if caseID[j] != 0 */ - if ( !(params->detIDVec->data[j] == 0 )) { - XLALComputeDetAMResponse(&fplus[detId], &fcross[detId], - detectors[detId].response, (double) thisEvent->ligo_axis_ra, - (double) thisEvent->ligo_axis_dec, 0, (double) gmstInRadians); - detId++; - } - } - - if ( (caseID[1] == 0) ) { - /* This is a H2 trigger */ - sigmasqH = sigmasq[2]; - - nullNumerRe8 = fplus[1]*fcross[2]*thisEvent->h2quad.re/ sqrt(sigmasqH) + - fplus[2]*fcross[0]*thisEvent->l1quad.re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.re / sqrt(sigmasq[5]); - - nullNumerIm8 = fplus[1]*fcross[2]*thisEvent->h2quad.im / sqrt(sigmasqH) + - fplus[2]*fcross[0]*thisEvent->l1quad.im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; - } - else { - sigmasqH = sigmasq[1]; - - nullNumerRe8 = fplus[1]*fcross[2]*thisEvent->h1quad.re/ sqrt(sigmasqH) + - fplus[2]*fcross[0]*thisEvent->l1quad.re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.re / sqrt(sigmasq[5]); - - nullNumerIm8 = fplus[1]*fcross[2]*thisEvent->h1quad.im / sqrt(sigmasqH) + - fplus[2]*fcross[0]*thisEvent->l1quad.im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; - } - - /* Prepare norm for null statistic */ - nullNorm8 = fplus[1]*fcross[2]*fplus[1]*fcross[2]/ sigmasqH + - fplus[2]*fcross[0]*fplus[2]*fcross[0]/ sigmasq[3] + - fplus[0]*fcross[1]*fplus[0]*fcross[1]/ sigmasq[5] ; - - nullStatistic = ( nullNumerRe8*nullNumerRe8 - + nullNumerIm8*nullNumerIm8) / nullNorm8; - - thisEvent->null_statistic = (REAL4) nullStatistic; - } - - /*CHECK: The following is deactivated for now (because of the "0" - in the condition of the "if" statment. - Next update will handle null-statistic time-series computation - if( thisEvent && params->nullStatOut && case4a ){ */ - if( thisEvent && case4a && !(params->nullStatOut) ){ - /* This trigger is from both H1 and H2; - but using H1 and not H2 for now*/ - REAL8 nullNorm8 = 0.0; - REAL8 nullNumerRe8 = 0.0; - REAL8 nullNumerIm8 = 0.0; - - detId = 0; - for( j=0; j<LAL_NUM_IFO; j++ ) { - /* Compute antenna-patterns if caseID[j] != 0 */ - if ( !(params->detIDVec->data[j] == 0 )) { - XLALComputeDetAMResponse(&fplus[detId], &fcross[detId], - detectors[detId].response, (double) thisEvent->ligo_axis_ra, - (double) thisEvent->ligo_axis_dec, 0, (double) gmstInRadians); - detId++; - } - } - - /* Prepare norm for null statistic */ - nullNorm8 = fplus[1]*fcross[2]*fplus[1]*fcross[2]/ sigmasq[1] + - fplus[2]*fcross[0]*fplus[2]*fcross[0]/ sigmasq[3] + - fplus[0]*fcross[1]*fplus[0]*fcross[1]/ sigmasq[5] ; - - nullNumerRe8 = fplus[1]*fcross[2]*thisEvent->h1quad.re / sqrt(sigmasq[1]) + - fplus[2]*fcross[0]*thisEvent->l1quad.re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.re / sqrt(sigmasq[5]); - - nullNumerIm8 = fplus[1]*fcross[2]*thisEvent->h1quad.im / sqrt(sigmasq[1]) + - fplus[2]*fcross[0]*thisEvent->l1quad.im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; - - nullStatistic = ( nullNumerRe8*nullNumerRe8 - + nullNumerIm8*nullNumerIm8) / nullNorm8; - - thisEvent->null_statistic = (REAL4) nullStatistic; - } - /* normal exit */ DETATCHSTATUSPTR( status ); RETURN( status ); @@ -4623,29 +4470,29 @@ double XLALComputeNullStatCase3b(INT4 caseID[6], double fplus[4], double fcross[ /* This is a H2 trigger */ sigmasqH = sigmasq[2]; - nullNumerRe8 = fplus[1]*fcross[2]*thisEvent->h2quad.re/ sqrt(sigmasqH) + - fplus[2]*fcross[0]*thisEvent->l1quad.re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.re / sqrt(sigmasq[5]); + nullNumerRe8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*thisEvent->h2quad.re/ sqrt(sigmasqH) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*thisEvent->l1quad.re / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*thisEvent->v1quad.re / sqrt(sigmasq[5]); - nullNumerIm8 = fplus[1]*fcross[2]*thisEvent->h2quad.im / sqrt(sigmasqH) + - fplus[2]*fcross[0]*thisEvent->l1quad.im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; + nullNumerIm8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*thisEvent->h2quad.im / sqrt(sigmasqH) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*thisEvent->l1quad.im / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; } else { sigmasqH = sigmasq[1]; - nullNumerRe8 = fplus[1]*fcross[2]*thisEvent->h1quad.re/ sqrt(sigmasqH) + - fplus[2]*fcross[0]*thisEvent->l1quad.re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.re / sqrt(sigmasq[5]); + nullNumerRe8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*thisEvent->h1quad.re/ sqrt(sigmasqH) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*thisEvent->l1quad.re / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*thisEvent->v1quad.re / sqrt(sigmasq[5]); - nullNumerIm8 = fplus[1]*fcross[2]*thisEvent->h1quad.im / sqrt(sigmasqH) + - fplus[2]*fcross[0]*thisEvent->l1quad.im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; + nullNumerIm8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*thisEvent->h1quad.im / sqrt(sigmasqH) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*thisEvent->l1quad.im / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; } /* Prepare norm for null statistic */ - nullNorm8 = fplus[1]*fcross[2]*fplus[1]*fcross[2]/ sigmasqH + - fplus[2]*fcross[0]*fplus[2]*fcross[0]/ sigmasq[3] + - fplus[0]*fcross[1]*fplus[0]*fcross[1]/ sigmasq[5] ; + nullNorm8 = pow(fplus[1]*fcross[2]-fplus[2]*fcross[1],2)/ sigmasqH + + pow(fplus[2]*fcross[0]-fplus[0]*fcross[2],2)/ sigmasq[3] + + pow(fplus[0]*fcross[1]-fplus[1]*fcross[0],2)/ sigmasq[5] ; nullStatistic = ( nullNumerRe8*nullNumerRe8 + nullNumerIm8*nullNumerIm8) / nullNorm8; @@ -4664,29 +4511,33 @@ double XLALComputeNullTimeSeriesCase3b(INT4 caseID[6], double fplus[4], double f /* This is a H2 trigger */ sigmasqH = sigmasq[2]; - nullNumerRe8 = fplus[1]*fcross[2]*quadTemp[0].re/ sqrt(sigmasqH) + - fplus[2]*fcross[0]*quadTemp[1].re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*quadTemp[2].re / sqrt(sigmasq[5]); + nullNorm8 = pow(fplus[1]*fcross[2]-fplus[2]*fcross[1],2)/ sigmasq[1] + + pow(fplus[2]*fcross[0]-fplus[0]*fcross[2],2)/ sigmasq[3] + + pow(fplus[0]*fcross[1]-fplus[1]*fcross[0],2)/ sigmasq[5] ; + + nullNumerRe8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*quadTemp[0].re/ sqrt(sigmasqH) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*quadTemp[1].re / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*quadTemp[2].re / sqrt(sigmasq[5]); - nullNumerIm8 = fplus[1]*fcross[2]*quadTemp[0].im / sqrt(sigmasqH) + - fplus[2]*fcross[0]*quadTemp[1].im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*quadTemp[2].im / sqrt(sigmasq[5]) ; + nullNumerIm8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*quadTemp[0].im / sqrt(sigmasqH) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*quadTemp[1].im / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*quadTemp[2].im / sqrt(sigmasq[5]) ; } else { sigmasqH = sigmasq[1]; - nullNumerRe8 = fplus[1]*fcross[2]*quadTemp[0].re/ sqrt(sigmasqH) + - fplus[2]*fcross[0]*quadTemp[1].re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*quadTemp[2].re / sqrt(sigmasq[5]); + nullNumerRe8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*quadTemp[0].re/ sqrt(sigmasqH) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*quadTemp[1].re / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*quadTemp[2].re / sqrt(sigmasq[5]); - nullNumerIm8 = fplus[1]*fcross[2]*quadTemp[0].im / sqrt(sigmasqH) + - fplus[2]*fcross[0]*quadTemp[1].im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*quadTemp[2].im / sqrt(sigmasq[5]) ; + nullNumerIm8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*quadTemp[0].im / sqrt(sigmasqH) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*quadTemp[1].im / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*quadTemp[2].im / sqrt(sigmasq[5]) ; } /* Prepare norm for null statistic */ - nullNorm8 = fplus[1]*fcross[2]*fplus[1]*fcross[2]/ sigmasqH + - fplus[2]*fcross[0]*fplus[2]*fcross[0]/ sigmasq[3] + - fplus[0]*fcross[1]*fplus[0]*fcross[1]/ sigmasq[5] ; + nullNorm8 = pow(fplus[1]*fcross[2]-fplus[2]*fcross[1],2)/ sigmasqH + + pow(fplus[2]*fcross[0]-fplus[0]*fcross[2],2)/ sigmasq[3] + + pow(fplus[0]*fcross[1]-fplus[1]*fcross[0],2)/ sigmasq[5] ; nullStatistic = ( nullNumerRe8*nullNumerRe8 + nullNumerIm8*nullNumerIm8) / nullNorm8; @@ -4706,17 +4557,17 @@ double XLALComputeNullStatCase4a(INT4 caseID[6], double fplus[4], double fcross[ UNUSED(caseID); /* Prepare norm for null statistic */ - nullNorm8 = fplus[1]*fcross[2]*fplus[1]*fcross[2]/ sigmasq[1] + - fplus[2]*fcross[0]*fplus[2]*fcross[0]/ sigmasq[3] + - fplus[0]*fcross[1]*fplus[0]*fcross[1]/ sigmasq[5] ; + nullNorm8 = pow(fplus[1]*fcross[2]-fplus[2]*fcross[1],2)/ sigmasq[1] + + pow(fplus[2]*fcross[0]-fplus[0]*fcross[2],2)/ sigmasq[3] + + pow(fplus[0]*fcross[1]-fplus[1]*fcross[0],2)/ sigmasq[5] ; - nullNumerRe8 = fplus[1]*fcross[2]*thisEvent->h1quad.re / sqrt(sigmasq[1]) + - fplus[2]*fcross[0]*thisEvent->l1quad.re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.re / sqrt(sigmasq[5]); + nullNumerRe8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*thisEvent->h1quad.re / sqrt(sigmasq[1]) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*thisEvent->l1quad.re / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*thisEvent->v1quad.re / sqrt(sigmasq[5]); - nullNumerIm8 = fplus[1]*fcross[2]*thisEvent->h1quad.im / sqrt(sigmasq[1]) + - fplus[2]*fcross[0]*thisEvent->l1quad.im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; + nullNumerIm8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*thisEvent->h1quad.im / sqrt(sigmasq[1]) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*thisEvent->l1quad.im / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*thisEvent->v1quad.im / sqrt(sigmasq[5]) ; nullStatistic = ( nullNumerRe8*nullNumerRe8 + nullNumerIm8*nullNumerIm8) / nullNorm8; @@ -4736,17 +4587,17 @@ double XLALComputeNullTimeSeriesCase4a(INT4 caseID[6], double fplus[4], double f UNUSED(caseID); /* Prepare norm for null statistic */ - nullNorm8 = fplus[1]*fcross[2]*fplus[1]*fcross[2]/ sigmasq[1] + - fplus[2]*fcross[0]*fplus[2]*fcross[0]/ sigmasq[3] + - fplus[0]*fcross[1]*fplus[0]*fcross[1]/ sigmasq[5] ; + nullNorm8 = pow(fplus[1]*fcross[2]-fplus[2]*fcross[1],2)/ sigmasq[1] + + pow(fplus[2]*fcross[0]-fplus[0]*fcross[2],2)/ sigmasq[3] + + pow(fplus[0]*fcross[1]-fplus[1]*fcross[0],2)/ sigmasq[5] ; - nullNumerRe8 = fplus[1]*fcross[2]*quadTemp[0].re / sqrt(sigmasq[1]) + - fplus[2]*fcross[0]*quadTemp[2].re / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*quadTemp[3].re / sqrt(sigmasq[5]); + nullNumerRe8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*quadTemp[0].re / sqrt(sigmasq[1]) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*quadTemp[2].re / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*quadTemp[3].re / sqrt(sigmasq[5]); - nullNumerIm8 = fplus[1]*fcross[2]*quadTemp[0].im / sqrt(sigmasq[1]) + - fplus[2]*fcross[0]*quadTemp[2].im / sqrt(sigmasq[3]) + - fplus[0]*fcross[1]*quadTemp[3].im / sqrt(sigmasq[5]) ; + nullNumerIm8 = (fplus[1]*fcross[2]-fplus[2]*fcross[1])*quadTemp[0].im / sqrt(sigmasq[1]) + + (fplus[2]*fcross[0]-fplus[0]*fcross[2])*quadTemp[2].im / sqrt(sigmasq[3]) + + (fplus[0]*fcross[1]-fplus[1]*fcross[0])*quadTemp[3].im / sqrt(sigmasq[5]) ; nullStatistic = ( nullNumerRe8*nullNumerRe8 + nullNumerIm8*nullNumerIm8) / nullNorm8; @@ -4854,7 +4705,6 @@ double XLALCoherentCBCParamEstim( double *psi_est, double *iota_est, double *coa if((((float)a1==(float)a4)&&((float)a2==-(float)a3))||(((float)a1==-(float)a4)&&((float)a2==(float)a3))) { *psi_est = -50.; - printf("\n CHECK\n"); } else { diff --git a/lal/packages/findchirp/src/CoherentInspiralInput.c b/lal/packages/findchirp/src/CoherentInspiralInput.c index 50e6fcada585af6b2d194321fc01d01674f3d078..1957ce108d6ea11dfac47d92e8fef387c3a1405c 100644 --- a/lal/packages/findchirp/src/CoherentInspiralInput.c +++ b/lal/packages/findchirp/src/CoherentInspiralInput.c @@ -47,7 +47,6 @@ #include <lal/LALDatatypes.h> #include <lal/AVFactories.h> #include <lal/LALConstants.h> -#include <lal/DataBuffer.h> #include <lal/LIGOMetadataTables.h> #include <lal/LIGOMetadataUtils.h> #include <lal/Date.h> @@ -57,7 +56,6 @@ #include <lal/FindChirpBCV.h> #include <lal/FindChirpBCVSpin.h> #include <lal/FindChirpChisq.h> -#include <lal/StochasticCrossCorrelation.h> #include <lal/DetectorSite.h> #include <lal/Random.h> #include <lal/LALInspiral.h> diff --git a/lal/packages/findchirp/src/FindChirpACTDTemplate.c b/lal/packages/findchirp/src/FindChirpACTDTemplate.c index ee399a86c71c769407c9deb4b7380ea10aa41f0b..b4f6acdb8bc257529daaeb7946cf34033f05bfde 100644 --- a/lal/packages/findchirp/src/FindChirpACTDTemplate.c +++ b/lal/packages/findchirp/src/FindChirpACTDTemplate.c @@ -42,7 +42,6 @@ LALDestroyVector() #include <lal/LALStdlib.h> #include <lal/AVFactories.h> #include <lal/SeqFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpTD.h> diff --git a/lal/packages/findchirp/src/FindChirpBCVCFilter.c b/lal/packages/findchirp/src/FindChirpBCVCFilter.c index b3f7cdc7acbe3b05869d02eb5f7c73d7ac98f6f3..1888c73037f1637e57310f824ebea72c6db1a509 100644 --- a/lal/packages/findchirp/src/FindChirpBCVCFilter.c +++ b/lal/packages/findchirp/src/FindChirpBCVCFilter.c @@ -42,6 +42,8 @@ $Id$ #endif #include <math.h> +#include <lal/LALErrno.h> +#include <lal/XLALError.h> #include <lal/LALStdio.h> #include <lal/LALStdlib.h> #include <lal/LALConstants.h> @@ -92,7 +94,6 @@ LALFindChirpBCVCFilterSegment ( COMPLEX8 *inputDataBCV = NULL; COMPLEX8 *tmpltSignal = NULL; SnglInspiralTable *thisEvent = NULL; - LALMSTUnitsAndAcc gmstUnits; REAL4 a1 = 0.0; REAL4 b1 = 0.0; REAL4 b2 = 0.0; @@ -254,10 +255,6 @@ LALFindChirpBCVCFilterSegment ( } numPoints = params->qVec->length; - /* set the gmst units and strictness */ - gmstUnits.units = MST_HRS; - gmstUnits.accuracy = LALLEAPSEC_STRICT; - /* * template parameters, since FindChirpBCVCFilterSegment is run * for every template @@ -786,9 +783,9 @@ LALFindChirpBCVCFilterSegment ( timeNS += (INT8) (1e9 * timeIndex * deltaT); thisEvent->end_time.gpsSeconds = (INT4) (timeNS/1000000000L); thisEvent->end_time.gpsNanoSeconds = (INT4) (timeNS%1000000000L); - LALGPStoGMST1( status->statusPtr, &(thisEvent->end_time_gmst), - &(thisEvent->end_time), &gmstUnits ); - CHECKSTATUSPTR( status ); + thisEvent->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &(thisEvent->end_time)), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(thisEvent->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); /* set the impuse time for the event */ thisEvent->template_duration = (REAL8) chirpTime; @@ -876,9 +873,9 @@ LALFindChirpBCVCFilterSegment ( timeNS += (INT8) (1e9 * timeIndex * deltaT); thisEvent->end_time.gpsSeconds = (INT4) (timeNS/1000000000L); thisEvent->end_time.gpsNanoSeconds = (INT4) (timeNS%1000000000L); - LALGPStoGMST1( status->statusPtr, &(thisEvent->end_time_gmst), - &(thisEvent->end_time), &gmstUnits ); - CHECKSTATUSPTR( status ); + thisEvent->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &(thisEvent->end_time)), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(thisEvent->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); /* set the impuse time for the event */ thisEvent->template_duration = (REAL8) chirpTime; diff --git a/lal/packages/findchirp/src/FindChirpBCVData.c b/lal/packages/findchirp/src/FindChirpBCVData.c index d33d77dcda458b8a2d7916e7485a86bf16928f95..c5eca42bbfa72302b53d87f7871920a6058121b0 100644 --- a/lal/packages/findchirp/src/FindChirpBCVData.c +++ b/lal/packages/findchirp/src/FindChirpBCVData.c @@ -47,7 +47,6 @@ $Id$ #include <lal/LALStdlib.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpSP.h> diff --git a/lal/packages/findchirp/src/FindChirpBCVFilter.c b/lal/packages/findchirp/src/FindChirpBCVFilter.c index abc27cc8ce90bbc3685bc71d25d89edb80dc089d..be8323d45586c525f28b30abcb34624e9c9c0424 100644 --- a/lal/packages/findchirp/src/FindChirpBCVFilter.c +++ b/lal/packages/findchirp/src/FindChirpBCVFilter.c @@ -42,6 +42,8 @@ $Id$ #endif #include <math.h> +#include <lal/LALErrno.h> +#include <lal/XLALError.h> #include <lal/LALStdio.h> #include <lal/LALStdlib.h> #include <lal/LALConstants.h> @@ -97,7 +99,6 @@ LALFindChirpBCVFilterSegment ( COMPLEX8 *inputDataBCV = NULL; COMPLEX8 *tmpltSignal = NULL; SnglInspiralTable *thisEvent = NULL; - LALMSTUnitsAndAcc gmstUnits; REAL4 a1 = 0.0; REAL4 b1 = 0.0; REAL4 b2 = 0.0; @@ -238,10 +239,6 @@ LALFindChirpBCVFilterSegment ( } numPoints = params->qVec->length; - /* set the gmst units and strictness */ - gmstUnits.units = MST_HRS; - gmstUnits.accuracy = LALLEAPSEC_STRICT; - /* * template parameters, since FindChirpBCVFilterSegment is run * for every template @@ -704,9 +701,9 @@ LALFindChirpBCVFilterSegment ( timeNS += (INT8) (1e9 * timeIndex * deltaT); thisEvent->end_time.gpsSeconds = (INT4) (timeNS/1000000000L); thisEvent->end_time.gpsNanoSeconds = (INT4) (timeNS%1000000000L); - LALGPStoGMST1( status->statusPtr, &(thisEvent->end_time_gmst), - &(thisEvent->end_time), &gmstUnits ); - CHECKSTATUSPTR( status ); + thisEvent->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &thisEvent->end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(thisEvent->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); /* set the impuse time for the event */ thisEvent->template_duration = (REAL8) chirpTime; @@ -821,9 +818,9 @@ LALFindChirpBCVFilterSegment ( timeNS += (INT8) (1e9 * timeIndex * deltaT); thisEvent->end_time.gpsSeconds = (INT4) (timeNS/1000000000L); thisEvent->end_time.gpsNanoSeconds = (INT4) (timeNS%1000000000L); - LALGPStoGMST1( status->statusPtr, &(thisEvent->end_time_gmst), - &(thisEvent->end_time), &gmstUnits ); - CHECKSTATUSPTR( status ); + thisEvent->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &thisEvent->end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(thisEvent->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); /* set the impuse time for the event */ thisEvent->template_duration = (REAL8) chirpTime; diff --git a/lal/packages/findchirp/src/FindChirpBCVSpinData.c b/lal/packages/findchirp/src/FindChirpBCVSpinData.c index edc99b3480f307e265244c1c072a283e27f0458e..bd0dc718b7db91bde3cd92bfa33e567da34c10df 100644 --- a/lal/packages/findchirp/src/FindChirpBCVSpinData.c +++ b/lal/packages/findchirp/src/FindChirpBCVSpinData.c @@ -70,7 +70,6 @@ LALDestroyVector() #include <lal/LALStdlib.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpBCVSpin.h> diff --git a/lal/packages/findchirp/src/FindChirpBCVSpinFilter.c b/lal/packages/findchirp/src/FindChirpBCVSpinFilter.c index a60a0508fde9869c30705b7161b80a05a099da73..f460cc62c08883fd86fc5c4590585a83914eb847 100644 --- a/lal/packages/findchirp/src/FindChirpBCVSpinFilter.c +++ b/lal/packages/findchirp/src/FindChirpBCVSpinFilter.c @@ -120,6 +120,8 @@ LALDestroyVector() #endif #include <math.h> +#include <lal/LALErrno.h> +#include <lal/XLALError.h> #include <lal/LALStdio.h> #include <lal/LALStdlib.h> #include <lal/LALConstants.h> @@ -161,7 +163,6 @@ LALFindChirpBCVSpinFilterSegment ( COMPLEX8 *qBCVSpin2 = NULL; COMPLEX8 *tmpltSignal = NULL; SnglInspiralTable *thisEvent = NULL; - LALMSTUnitsAndAcc gmstUnits; COMPLEX8 *wtilde; COMPLEX8 *inputData1; REAL4 rho = 0.0; @@ -309,10 +310,6 @@ LALFindChirpBCVSpinFilterSegment ( qtildeBCVSpin1 = params->qtildeVecBCVSpin1->data; qtildeBCVSpin2 = params->qtildeVecBCVSpin2->data; - /* set the gmst units and strictness */ - gmstUnits.units = MST_HRS; - gmstUnits.accuracy = LALLEAPSEC_STRICT; - /* finding cross product of data with itself, to be used for normalisation later */ @@ -662,10 +659,11 @@ LALFindChirpBCVSpinFilterSegment ( = (INT4) (timeNS/1000000000L); thisEvent->end_time.gpsNanoSeconds = (INT4) (timeNS%1000000000L); - LALGPStoGMST1( status->statusPtr, - &(thisEvent->end_time_gmst), - &(thisEvent->end_time), &gmstUnits ); - CHECKSTATUSPTR( status ); + thisEvent->end_time_gmst + = fmod(XLALGreenwichMeanSiderealTime( + &thisEvent->end_time), + LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(thisEvent->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); /* set the impulse time for the event */ thisEvent->template_duration = (REAL8) chirpTime; @@ -768,10 +766,10 @@ LALFindChirpBCVSpinFilterSegment ( = (INT4) (timeNS/1000000000L); thisEvent->end_time.gpsNanoSeconds = (INT4) (timeNS%1000000000L); - LALGPStoGMST1( status->statusPtr, - &(thisEvent->end_time_gmst), - &(thisEvent->end_time), &gmstUnits ); - CHECKSTATUSPTR( status ); + thisEvent->end_time_gmst + = fmod(XLALGreenwichMeanSiderealTime(&thisEvent->end_time), + LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(thisEvent->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); /* set the impulse time for the event */ thisEvent->template_duration = (REAL8) chirpTime; diff --git a/lal/packages/findchirp/src/FindChirpBCVSpinTemplate.c b/lal/packages/findchirp/src/FindChirpBCVSpinTemplate.c index 362d1dec312e23d5dcc56802cb4f8e4eb8bb3306..3ca7a41877b1b2a51e9239606b1d3ddced489912 100644 --- a/lal/packages/findchirp/src/FindChirpBCVSpinTemplate.c +++ b/lal/packages/findchirp/src/FindChirpBCVSpinTemplate.c @@ -30,7 +30,6 @@ #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpBCVSpin.h> diff --git a/lal/packages/findchirp/src/FindChirpBCVTemplate.c b/lal/packages/findchirp/src/FindChirpBCVTemplate.c index 160172925dab4f6fbe2876a0bb85b43b93a43178..88b614936ca1abaa9090efe949ec8738f3d6181a 100644 --- a/lal/packages/findchirp/src/FindChirpBCVTemplate.c +++ b/lal/packages/findchirp/src/FindChirpBCVTemplate.c @@ -69,7 +69,6 @@ LALDestroyVector() #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpBCV.h> diff --git a/lal/packages/findchirp/src/FindChirpBankVeto.c b/lal/packages/findchirp/src/FindChirpBankVeto.c index 294ee37cd389d630bfdb6d3e446cc04f5b62172f..25f81fcdb69740009a792fb4f1a99d1a6de0ca2a 100644 --- a/lal/packages/findchirp/src/FindChirpBankVeto.c +++ b/lal/packages/findchirp/src/FindChirpBankVeto.c @@ -42,7 +42,6 @@ $Id$ #include <lal/LALStdlib.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <math.h> @@ -441,8 +440,8 @@ XLALFindChirpSortTemplatesByLevel( InspiralTemplate *bankHead, UINT4 num) static int compareTemplateByLevel (const void * a, const void * b) { - const REAL4 mVal1 = ((const InspiralTemplate*)a)->level; - const REAL4 mVal2 = ((const InspiralTemplate*)b)->level; + REAL4 mVal1 = (*(InspiralTemplate * const *) a)->level; + REAL4 mVal2 = (*(InspiralTemplate * const *) b)->level; if ( mVal1 > mVal2 ) return 1; if ( mVal1 == mVal2 ) return 0; @@ -453,8 +452,8 @@ static int compareTemplateByLevel (const void * a, const void * b) static int compareTemplateByChirpMass (const void * a, const void * b) { - const REAL4 mVal1 = ((const InspiralTemplate*)a)->chirpMass; - const REAL4 mVal2 = ((const InspiralTemplate*)b)->chirpMass; + REAL4 mVal1 = (*(InspiralTemplate * const *) a)->chirpMass; + REAL4 mVal2 = (*(InspiralTemplate * const *) b)->chirpMass; if ( mVal1 > mVal2 ) return 1; if ( mVal1 == mVal2 ) return 0; diff --git a/lal/packages/findchirp/src/FindChirpData.c b/lal/packages/findchirp/src/FindChirpData.c index 32fc7106c530132a3481b4b02064c3e898c706f1..a37b6601d5e899f62eff8520f43495fe1e750f8a 100644 --- a/lal/packages/findchirp/src/FindChirpData.c +++ b/lal/packages/findchirp/src/FindChirpData.c @@ -44,7 +44,6 @@ $Id$ #include <lal/LALStdlib.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> diff --git a/lal/packages/findchirp/src/FindChirpMemory.c b/lal/packages/findchirp/src/FindChirpMemory.c index 48fc3a4fff6e41dfcde510632d04deb15d861c7c..3a19154c2b3747eeebdf3eb5bd5b14fe80c5bbbe 100644 --- a/lal/packages/findchirp/src/FindChirpMemory.c +++ b/lal/packages/findchirp/src/FindChirpMemory.c @@ -109,7 +109,6 @@ LALU4DestroyVector() #include <lal/LALStdlib.h> #include <lal/AVFactories.h> #include <lal/Date.h> -#include <lal/DataBuffer.h> #include <lal/FindChirp.h> NRCSID (FINDCHIRPMEMORYC, "$Id$"); diff --git a/lal/packages/findchirp/src/FindChirpPTFTemplate.c b/lal/packages/findchirp/src/FindChirpPTFTemplate.c index 9b6091d7851faf70f9318a03f0c20d400e6d1302..3578a871c12bdb3a5a43454e0bf8eb6510cf78a9 100644 --- a/lal/packages/findchirp/src/FindChirpPTFTemplate.c +++ b/lal/packages/findchirp/src/FindChirpPTFTemplate.c @@ -69,7 +69,6 @@ LALDestroyVector() #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpPTF.h> diff --git a/lal/packages/findchirp/src/FindChirpPTFWaveform.c b/lal/packages/findchirp/src/FindChirpPTFWaveform.c index 753dbe66c352c9e3369406086f5c2784c214ca89..178c02b1eae3213c0ea56b18e1b72fdbcfdefc84 100644 --- a/lal/packages/findchirp/src/FindChirpPTFWaveform.c +++ b/lal/packages/findchirp/src/FindChirpPTFWaveform.c @@ -56,7 +56,6 @@ LALDestroyVector() #include <lal/LALStdlib.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpPTF.h> diff --git a/lal/packages/findchirp/src/FindChirpPhenomWaveform.c b/lal/packages/findchirp/src/FindChirpPhenomWaveform.c index 3e15ce8923ceff9bb37655a909cf1e9a395ace3b..0d0794ef66448693f38b01ca4af7f4b34a384898 100644 --- a/lal/packages/findchirp/src/FindChirpPhenomWaveform.c +++ b/lal/packages/findchirp/src/FindChirpPhenomWaveform.c @@ -31,7 +31,6 @@ #include <lal/LALDatatypes.h> #include <lal/ComplexFFT.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/LALInspiralBank.h> #include <lal/GeneratePPNInspiral.h> diff --git a/lal/packages/findchirp/src/FindChirpSPData.c b/lal/packages/findchirp/src/FindChirpSPData.c index 43a895e9e430b6466bb7d65d6361781c56b13880..cfd024ef06fb52145e9d3674d651efe7660a541e 100644 --- a/lal/packages/findchirp/src/FindChirpSPData.c +++ b/lal/packages/findchirp/src/FindChirpSPData.c @@ -47,7 +47,6 @@ $Id$ #include <lal/LALStdlib.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpSP.h> diff --git a/lal/packages/findchirp/src/FindChirpSPTemplate.c b/lal/packages/findchirp/src/FindChirpSPTemplate.c index 27ea028d6fcaaed124d1c03010fdd3a965c3e682..6d7e3d661c0a0ed71fb80ea1dac1af495ec9a3f0 100644 --- a/lal/packages/findchirp/src/FindChirpSPTemplate.c +++ b/lal/packages/findchirp/src/FindChirpSPTemplate.c @@ -70,7 +70,6 @@ LALDestroyVector() #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpSP.h> diff --git a/lal/packages/findchirp/src/FindChirpSimulation.c b/lal/packages/findchirp/src/FindChirpSimulation.c index f3325802e57ef8ce121a23b412971d3f09d30585..ea17fc3628cb3c56005c68fa13fc1b07f5e5dcd4 100644 --- a/lal/packages/findchirp/src/FindChirpSimulation.c +++ b/lal/packages/findchirp/src/FindChirpSimulation.c @@ -90,6 +90,7 @@ LALFree() #include <lal/GenerateInspiral.h> #include <lal/NRWaveInject.h> #include <lal/GenerateInspRing.h> +#include <lal/LALErrno.h> #include <math.h> #include <lal/LALInspiral.h> #include <lal/LALError.h> @@ -400,6 +401,12 @@ LALFindChirpInjectSignals ( { XLALInspiralWaveTaper( signalvec.data, INSPIRAL_TAPER_STARTEND ); } + else if ( strcmp( "TAPER_NONE", thisEvent->taper ) ) + { + XLALPrintError( "Invalid injection tapering option specified: %s\n", + thisEvent->taper ); + ABORT( status, LAL_BADPARM_ERR, LAL_BADPARM_MSG ); + } } /* Band pass the signal */ diff --git a/lal/packages/findchirp/src/FindChirpStoreEvent.c b/lal/packages/findchirp/src/FindChirpStoreEvent.c index 311280dbb0444d61a421839c48bd3a20fde304df..a5318cd2bd116e24165db664eca8ec2a3c6c4bb2 100644 --- a/lal/packages/findchirp/src/FindChirpStoreEvent.c +++ b/lal/packages/findchirp/src/FindChirpStoreEvent.c @@ -42,6 +42,8 @@ $Id$ #endif #include <math.h> +#include <lal/LALErrno.h> +#include <lal/XLALError.h> #include <lal/LALStdio.h> #include <lal/LALStdlib.h> #include <lal/LALConstants.h> @@ -71,7 +73,6 @@ LALFindChirpStoreEvent ( INT8 timeNS; INT4 timeIndex; REAL4 deltaT; - LALMSTUnitsAndAcc gmstUnits; UINT4 numPoints; INITSTATUS( status, "LALFindChirpStoreEvent", FINDCHIRPSTOREEVENTC ); @@ -114,10 +115,6 @@ LALFindChirpStoreEvent ( deltaT = params->deltaT; numPoints = params->qVec->length; - /* set the gmst units and strictness */ - gmstUnits.units = MST_HRS; - gmstUnits.accuracy = LALLEAPSEC_STRICT; - /* set the event LIGO GPS time of the event */ timeNS = 1000000000L * (INT8) (input->segment->data->epoch.gpsSeconds); @@ -125,9 +122,9 @@ LALFindChirpStoreEvent ( timeNS += (INT8) (1e9 * timeIndex * deltaT); thisEvent->end_time.gpsSeconds = (INT4) (timeNS/1000000000L); thisEvent->end_time.gpsNanoSeconds = (INT4) (timeNS%1000000000L); - LALGPStoGMST1( status->statusPtr, &(thisEvent->end_time_gmst), - &(thisEvent->end_time), &gmstUnits ); - CHECKSTATUSPTR( status ); + thisEvent->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &thisEvent->end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(thisEvent->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); /* set the impulse time for the event */ thisEvent->template_duration = (REAL8) input->fcTmplt->tmplt.tC; diff --git a/lal/packages/findchirp/src/FindChirpTDData.c b/lal/packages/findchirp/src/FindChirpTDData.c index afc09b196373b387b59840c3a45065e1d0b3cf27..3fc394548a92553e6900b9fee22f548ec4fd480f 100644 --- a/lal/packages/findchirp/src/FindChirpTDData.c +++ b/lal/packages/findchirp/src/FindChirpTDData.c @@ -59,7 +59,6 @@ Time domain filtering code. #include <lal/LALStdlib.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpTD.h> diff --git a/lal/packages/findchirp/src/FindChirpTDTemplate.c b/lal/packages/findchirp/src/FindChirpTDTemplate.c index 5f0678649f8f5c22824d63e1d638b5f0d0bf639b..abe52aea2e4e5cd1cb859e215da5cca80a2e9a44 100644 --- a/lal/packages/findchirp/src/FindChirpTDTemplate.c +++ b/lal/packages/findchirp/src/FindChirpTDTemplate.c @@ -72,7 +72,6 @@ LALDestroyVector() #include <lal/LALStdlib.h> #include <lal/AVFactories.h> #include <lal/SeqFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpTD.h> diff --git a/lal/packages/findchirp/src/FindChirpTemplate.c b/lal/packages/findchirp/src/FindChirpTemplate.c index 57de3873cb747ccb038e66d7c1eab1be8ff69086..1dc99da12bf86674663580231642ba69f40889d2 100644 --- a/lal/packages/findchirp/src/FindChirpTemplate.c +++ b/lal/packages/findchirp/src/FindChirpTemplate.c @@ -76,7 +76,6 @@ LALDestroyVector() #include <lal/LALStdlib.h> #include <lal/AVFactories.h> #include <lal/SeqFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpACTD.h> diff --git a/lal/packages/findchirp/src/NullStatistic.c b/lal/packages/findchirp/src/NullStatistic.c index 4d0e720f88ad34f414445b6bc9c411822400a759..0edd32f854560881a30c2b4751525ec7b82b101a 100644 --- a/lal/packages/findchirp/src/NullStatistic.c +++ b/lal/packages/findchirp/src/NullStatistic.c @@ -36,7 +36,6 @@ #include <lal/LALStdio.h> #include <lal/LALConstants.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/FindChirp.h> #include <lal/FindChirpSP.h> #include <lal/DetectorSite.h> diff --git a/lal/packages/findchirp/test/CoherentInspiralFilterTest.c b/lal/packages/findchirp/test/CoherentInspiralFilterTest.c index afb046e23f56e8b27668e1951010d45100cad516..5ea37cc8d288fc43159fd302c02c8cb51b811699 100644 --- a/lal/packages/findchirp/test/CoherentInspiralFilterTest.c +++ b/lal/packages/findchirp/test/CoherentInspiralFilterTest.c @@ -47,7 +47,6 @@ #include <lal/LALStdlib.h> #include <lal/LALStdio.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/Random.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> diff --git a/lal/packages/findchirp/test/CoherentInspiralInputTest.c b/lal/packages/findchirp/test/CoherentInspiralInputTest.c index 20376904c92ec1e6555988184b8abdfd44da917d..d5d2e18d6e278cee0b87b256261a0dc6a68302ec 100644 --- a/lal/packages/findchirp/test/CoherentInspiralInputTest.c +++ b/lal/packages/findchirp/test/CoherentInspiralInputTest.c @@ -53,7 +53,6 @@ #include <lal/AVFactories.h> #include <lal/LALConstants.h> #include <lal/FrameStream.h> -#include <lal/DataBuffer.h> #include <lal/LIGOMetadataTables.h> #include <lal/LIGOMetadataUtils.h> #include <lal/LIGOLwXML.h> diff --git a/lal/packages/findchirp/test/FindChirpACTDTest.c b/lal/packages/findchirp/test/FindChirpACTDTest.c index 6127913512d9dd47d202577414cdc29238883172..c73e2cfe88960d6d3d3079192607886afa1d84f3 100755 --- a/lal/packages/findchirp/test/FindChirpACTDTest.c +++ b/lal/packages/findchirp/test/FindChirpACTDTest.c @@ -18,7 +18,6 @@ Provides the necessary function to test the AmpCorPPN filter. #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpSP.h> diff --git a/lal/packages/findchirp/test/FindChirpBCVSpinTest.c b/lal/packages/findchirp/test/FindChirpBCVSpinTest.c index 478b45f4322ed35fdee934a13296dd680380f0c4..664592c11933bb15c998b4b0553fa6b89e81e52d 100644 --- a/lal/packages/findchirp/test/FindChirpBCVSpinTest.c +++ b/lal/packages/findchirp/test/FindChirpBCVSpinTest.c @@ -44,7 +44,6 @@ #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/Random.h> #include <lal/LALInspiral.h> #include <lal/FindChirpDatatypes.h> diff --git a/lal/packages/findchirp/test/FindChirpBCVTest.c b/lal/packages/findchirp/test/FindChirpBCVTest.c index ecb407f9b167b55d4044281941745de7132d68f2..8eb2a932474d4083345bd5223945984a56fe4c0a 100644 --- a/lal/packages/findchirp/test/FindChirpBCVTest.c +++ b/lal/packages/findchirp/test/FindChirpBCVTest.c @@ -44,7 +44,6 @@ #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/Random.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> diff --git a/lal/packages/findchirp/test/FindChirpSPTest.c b/lal/packages/findchirp/test/FindChirpSPTest.c index 67196fdbfa4d1d8de2a1357ae8bf8ecb8263a4e2..8f1876ca7d2da4cfa59d4ef6fc15988169fead2d 100644 --- a/lal/packages/findchirp/test/FindChirpSPTest.c +++ b/lal/packages/findchirp/test/FindChirpSPTest.c @@ -44,7 +44,6 @@ #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/Random.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> diff --git a/lal/packages/findchirp/test/FindChirpTDTest.c b/lal/packages/findchirp/test/FindChirpTDTest.c index b60bb49a3bb610cfe5613abb4019931b4ede90bb..ab37a68a6c24194c93998a541ee6bcfbe3eb425c 100644 --- a/lal/packages/findchirp/test/FindChirpTDTest.c +++ b/lal/packages/findchirp/test/FindChirpTDTest.c @@ -23,7 +23,6 @@ #include <lal/LALStdlib.h> #include <lal/AVFactories.h> -#include <lal/DataBuffer.h> #include <lal/LALInspiral.h> #include <lal/FindChirp.h> #include <lal/FindChirpSP.h> diff --git a/lal/packages/findchirp/test/FindChirpTDTest.h b/lal/packages/findchirp/test/FindChirpTDTest.h index 4d34267521ce08e80c8a8eec972f0d38971fd747..b500d1327263f0db81a7b55068d595c201c29ce6 100644 --- a/lal/packages/findchirp/test/FindChirpTDTest.h +++ b/lal/packages/findchirp/test/FindChirpTDTest.h @@ -17,7 +17,6 @@ * MA 02111-1307 USA */ -#include <lal/DataBuffer.h> #include <lal/FindChirp.h> #include <lal/FindChirpSP.h> diff --git a/lal/packages/houghpulsar/src/DriveHough.c b/lal/packages/houghpulsar/src/DriveHough.c index ce1e63dd0702e5bef587f20cd9c4e84a47d4de51..2c31e07fe10daac60089927f355be07fef7496ad 100644 --- a/lal/packages/houghpulsar/src/DriveHough.c +++ b/lal/packages/houghpulsar/src/DriveHough.c @@ -869,7 +869,6 @@ void LALHOUGHComputeAMWeights (LALStatus *status, amParams->das->pSource->orientation = 0.0; amParams->das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!*/ - amParams->leapAcc = LALLEAPSEC_STRICT; /* allocate memory for a[i] and b[i] */ /* TRY( LALSCreateVector( status, &(amc.a), length), status); */ diff --git a/lal/packages/houghpulsar/test/TestVelocity.c b/lal/packages/houghpulsar/test/TestVelocity.c index e4b27663f8e2c03f56f9f6aabc10a1591771db89..2a0d269eff3f65e907d6c830815211387060a717 100644 --- a/lal/packages/houghpulsar/test/TestVelocity.c +++ b/lal/packages/houghpulsar/test/TestVelocity.c @@ -233,8 +233,6 @@ int main(int argc, char *argv[]){ edat = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = EARTHDATA; (*edat).ephiles.sunEphemeris = SUNDATA; - /* is this the right number of leap seconds? */ - (*edat).leap = 13; /* read in ephemeris data */ SUB( LALInitBarycenter( &status, edat), &status); diff --git a/lal/packages/inject/include/InspiralInjectionParams.h b/lal/packages/inject/include/InspiralInjectionParams.h index 700019a319c899f4ebcd252a06eecbb6eaf77d03..b2fb9d6c80b1ceede562510473097629405703b9 100644 --- a/lal/packages/inject/include/InspiralInjectionParams.h +++ b/lal/packages/inject/include/InspiralInjectionParams.h @@ -50,7 +50,8 @@ typedef enum uniformComponentMass, logComponentMass, gaussianMassDist, - uniformTotalMassRatio + uniformTotalMassRatio, + logMassUniformTotalMassRatio, } MassDistribution; @@ -135,6 +136,7 @@ SimInspiralTable* XLALGaussianInspiralMasses( SimInspiralTable *inj, SimInspiralTable* XLALRandomInspiralTotalMassRatio( SimInspiralTable *inj, RandomParams *randParams, + MassDistribution mDist, REAL4 minTotalMass, REAL4 maxTotalMass, REAL4 minMassRatio, diff --git a/lal/packages/inject/src/GenerateInspiral.c b/lal/packages/inject/src/GenerateInspiral.c index 73253c3dc18e25930cbfab4af7f2fe46ba7990c4..f59118e8ed99f7b2d42b535bf3e83e8aee809a0c 100644 --- a/lal/packages/inject/src/GenerateInspiral.c +++ b/lal/packages/inject/src/GenerateInspiral.c @@ -388,6 +388,10 @@ LALGetApproximantFromString( { *approximant = GeneratePPN; } + else if ( strstr(thisEvent, "TaylorT4" ) ) + { + *approximant = TaylorT4; + } else if ( strstr(thisEvent, "NumRel" ) ) { *approximant = NumRel; @@ -396,6 +400,10 @@ LALGetApproximantFromString( { *approximant = IMRPhenomA; } + else if ( strstr(thisEvent, "IMRPhenomB" ) ) + { + *approximant = IMRPhenomB; + } else { snprintf( warnMsg, sizeof(warnMsg)/sizeof(*warnMsg), diff --git a/lal/packages/inject/src/GeneratePulsarSignal.c b/lal/packages/inject/src/GeneratePulsarSignal.c index 0991f6c5193e56e69390d5663985a47a233c0c6a..42527b013635f11bae2fdfa21cf98c87ad54a060 100644 --- a/lal/packages/inject/src/GeneratePulsarSignal.c +++ b/lal/packages/inject/src/GeneratePulsarSignal.c @@ -320,7 +320,9 @@ LALSignalToSFTs (LALStatus *status, GENERATEPULSARSIGNALH_EINCONSBAND, GENERATEPULSARSIGNALH_MSGEINCONSBAND); } /* Prepare FFT: compute plan for FFTW */ - TRY (LALCreateForwardRealFFTPlan(status->statusPtr, &pfwd, numTimesteps, 0), status); + pfwd = XLALCreateForwardREAL4FFTPlan(numTimesteps, 0); + if (pfwd == NULL) + ABORTXLAL(status); /* get some info about time-series */ tStart = signalvec->epoch; /* start-time of time-series */ @@ -426,10 +428,11 @@ LALSignalToSFTs (LALStatus *status, } /* the central step: FFT the ith time-stretch into an SFT-slot */ - LALForwardRealFFT(status->statusPtr, thisSFT->data, &timeStretch, pfwd); - BEGINFAIL(status) { - LALDestroySFTVector(status->statusPtr, &sftvect); - } ENDFAIL(status); + if (XLALREAL4ForwardFFT(thisSFT->data, &timeStretch, pfwd) != 0) + { + LALDestroySFTVector(status->statusPtr, &sftvect); + ABORTXLAL(status); + } /* normalize DFT-data to conform to v2 ( ie. COMPLEX8FrequencySeries ) specification ==> multiply DFT by dt */ @@ -478,7 +481,7 @@ LALSignalToSFTs (LALStatus *status, } /* for iSFT < numSFTs */ /* free stuff */ - LALDestroyRealFFTPlan(status->statusPtr, &pfwd); + XLALDestroyREAL4FFTPlan(pfwd); /* did we get timestamps or did we make them? */ if (params->timestamps == NULL) diff --git a/lal/packages/inject/src/InspiralInjectionParams.c b/lal/packages/inject/src/InspiralInjectionParams.c index 479400a98f6501139f0577347f025f2613ea9569..1522a8f438df394602daec8c1e66a52a894ae60d 100644 --- a/lal/packages/inject/src/InspiralInjectionParams.c +++ b/lal/packages/inject/src/InspiralInjectionParams.c @@ -292,18 +292,33 @@ SimInspiralTable* XLALGaussianInspiralMasses( SimInspiralTable* XLALRandomInspiralTotalMassRatio( SimInspiralTable *inj, /**< injection for which masses will be set */ RandomParams *randParams,/**< random parameter details */ + MassDistribution mDist, /**< the mass distribution to use */ REAL4 minTotalMass, /**< minimum total mass of binary */ REAL4 maxTotalMass, /**< maximum total mass of binary */ REAL4 minMassRatio, /**< minimum mass ratio */ REAL4 maxMassRatio /**< maximum mass ratio */ ) { - REAL4 mtotal, ratio; + REAL4 mtotal = -1.0; + REAL4 ratio = -1.0; /* generate uniformly distributed total mass and mass ratio */ - mtotal = minTotalMass + (XLALUniformDeviate(randParams) * (maxTotalMass - minTotalMass)); - ratio = minMassRatio + (XLALUniformDeviate(randParams) * (maxMassRatio - minMassRatio)); - + if ( mDist==uniformTotalMassRatio) + { + mtotal = minTotalMass + (XLALUniformDeviate(randParams) * (maxTotalMass - minTotalMass)); + ratio = minMassRatio + (XLALUniformDeviate(randParams) * (maxMassRatio - minMassRatio)); + } + else if ( mDist==logMassUniformTotalMassRatio) + { + mtotal = exp( log(minTotalMass) + XLALUniformDeviate(randParams) * + ( log(maxTotalMass) - log(minTotalMass) ) ); + ratio = minMassRatio + (XLALUniformDeviate(randParams) * (maxMassRatio - minMassRatio)); + } + else + { + /* unsupported distribution type */ + XLAL_ERROR_NULL("XLALRandomInspiralTotalMassRatio", XLAL_EINVAL); + } inj->mass1 = (ratio * mtotal) / (ratio + 1); inj->mass2 = mtotal / (ratio + 1); inj->eta = inj->mass1 * inj->mass2 / ( mtotal * mtotal ); @@ -312,6 +327,7 @@ SimInspiralTable* XLALRandomInspiralTotalMassRatio( return ( inj ); } + /** Generates spins for an inspiral injection. Spin magnitudes lie between the * specified max and min values. Orientation for spin1 can be constrained by * the specified values of kappa1, otherwise are random. Orientation for spin2 @@ -443,7 +459,7 @@ SimInspiralTable* XLALRandomNRInjectTotalMass( /* copy over the numrel information */ inj->numrel_mode_min = nrInjParams->numrel_mode_min; inj->numrel_mode_max = nrInjParams->numrel_mode_max; - snprintf( inj->numrel_data, LIGOMETA_STRING_MAX, + snprintf(inj->numrel_data, LIGOMETA_STRING_MAX, "%s", nrInjParams->numrel_data); return ( inj ); diff --git a/lal/packages/inject/src/TerrestrialCoordinates.c b/lal/packages/inject/src/TerrestrialCoordinates.c index 09548f2e72568ddd88e0e63149fe61fd1a959089..fe21e9eb4a8f57ea74cc101b0b913a8877c62e2a 100644 --- a/lal/packages/inject/src/TerrestrialCoordinates.c +++ b/lal/packages/inject/src/TerrestrialCoordinates.c @@ -313,7 +313,6 @@ the geoid. \par Uses \code -LALGPStoUTC() XLALGreenwichMeanSiderealTime() LALDHeapSort() \endcode diff --git a/lal/packages/inject/test/GeneratePulsarSignalTest.c b/lal/packages/inject/test/GeneratePulsarSignalTest.c index eec6f0710c965546dd22ea0a02d8e68bb663c190..6f5afce14bd8dc5862945cdfbc260de569b6a953 100644 --- a/lal/packages/inject/test/GeneratePulsarSignalTest.c +++ b/lal/packages/inject/test/GeneratePulsarSignalTest.c @@ -193,7 +193,6 @@ void RunGeneratePulsarSignalTest(LALStatus *status) EphemerisData *edat = NULL; CHAR sunFile[] = "sun00-04.dat"; /* 02/02/05 gam */ CHAR earthFile[] = "earth00-04.dat"; /* 02/02/05 gam */ - INT4 leap; /* 2nd arg to LALLeapSecFormatAndAcc is INT4 while edat->leap is INT2. */ /* containers for sky position and spindown data */ REAL8 **skyPosData; @@ -338,8 +337,6 @@ void RunGeneratePulsarSignalTest(LALStatus *status) edat->ephiles.earthEphemeris = "earth00-04.dat"; */ edat->ephiles.sunEphemeris = sunFile; /* 02/02/05 gam */ edat->ephiles.earthEphemeris = earthFile; /* 02/02/05 gam */ - leap = XLALLeapSeconds ( timeStamps->data[0].gpsSeconds ); /**< [In] Seconds relative to GPS epoch.*/ - edat->leap = (INT2)leap; LALInitBarycenter(status->statusPtr, edat); CHECKSTATUSPTR (status); diff --git a/lal/packages/inject/test/SkyCoordinatesTest.c b/lal/packages/inject/test/SkyCoordinatesTest.c index 6a7348e3da4192c80ab3e87f75b9ac86a30d2ad9..ed58627bfa1ec93351c221bbbe7be6def1c26f82 100644 --- a/lal/packages/inject/test/SkyCoordinatesTest.c +++ b/lal/packages/inject/test/SkyCoordinatesTest.c @@ -106,7 +106,6 @@ lalDebugLevel LALPrintError() LALCheckMemoryLeaks() LALMalloc() LALFree() LALGeocentricToGeodetic() LALGeodeticToGeocentric() -LALGPStoUTC() LALDateString() LALGPStoGMST1() LALCHARCreateVector() LALCHARDestroyVector() LALCreateRandomParams() LALDestroyRandomParams() @@ -121,6 +120,7 @@ LALNormalizeSkyPosition() ******************************************************* </lalLaTeX> */ #include <math.h> +#include <time.h> #include <stdlib.h> #include <lal/LALStdio.h> #include <lal/LALStdlib.h> @@ -514,7 +514,7 @@ main( int argc, char **argv ) /* Print the time in various formats. */ if ( t ) { INT8 nsec; /* time as INT8 nanoseconds */ - LALDate date; /* time as LALDate structure */ + struct tm date; /* UTC */ REAL8 gmst; /* Greenwich mean sidereal time */ /* Convert to INT8 seconds and back, just to test things (and get @@ -526,22 +526,17 @@ main( int argc, char **argv ) /* Convert to UTC timestamp. */ if ( gpsTime.gpsSeconds >= 0 ) { CHARVector *timeStamp = NULL; /* date string */ - /* don't bomb if leap second table isn't up to date */ - LALLeapSecAccuracy acc = LALLEAPSEC_LOOSE; - LALMSTUnitsAndAcc uAcc; - uAcc.units = MST_DEG; - uAcc.accuracy = acc; fprintf( stdout, "GPS time: %i.%09is\n", gpsTime.gpsSeconds, gpsTime.gpsNanoSeconds ); - SUB( LALGPStoUTC( &stat, &date, &gpsTime, &acc ), &stat ); + XLALGPSToUTC(&date, gpsTime.gpsSeconds); SUB( LALCHARCreateVector( &stat, &timeStamp, 32 ), &stat ); - SUB( LALDateString( &stat, timeStamp, &date ), &stat ); + strftime(timeStamp->data, timeStamp->length, "%F %T UTC %a", &date); fprintf( stdout, "UTC time: %s\n", timeStamp->data ); SUB( LALCHARDestroyVector( &stat, &timeStamp ), &stat ); - /* Convert to Greenwich mean sidereal time. */ - SUB( LALGPStoGMST1( &stat, &gmst, &gpsTime, &uAcc ), &stat ); + /* Convert to Greenwich mean sidereal time (degrees). */ + gmst = fmod(XLALGreenwichMeanSiderealTime(&gpsTime), LAL_TWOPI) * 360.0 / LAL_TWOPI; fprintf( stdout, "Greenwich mean sidereal time: %6.2f deg\n", 1.0*gmst ); } else diff --git a/lal/packages/inspiral/include/LALInspiral.h b/lal/packages/inspiral/include/LALInspiral.h index 51dd91b072ff873f8aec3ba8eebd333bcb143e20..963637e6b6ab08014ba49e47f582beb83d99947e 100644 --- a/lal/packages/inspiral/include/LALInspiral.h +++ b/lal/packages/inspiral/include/LALInspiral.h @@ -461,6 +461,9 @@ typedef enum { Eccentricity, EOBNR, IMRPhenomA, + IMRPhenomB, + IMRPhenomFA, + IMRPhenomFB, TaylorEt, TaylorT4, TaylorN, @@ -1189,6 +1192,12 @@ void LALTaylorT4Waveform( REAL4Vector *signalvec, InspiralTemplate *params); +void LALTaylorT4WaveformForInjection( + LALStatus *status, + CoherentGW *waveform, + InspiralTemplate *params, + PPNParamStruc *ppnParams); + void LALBCVSpinWaveform( LALStatus *status, REAL4Vector *signalvec, @@ -1638,10 +1647,6 @@ LALInspiralITStructureHelp(void); /* --- TEST PROTOTYPES --- */ -/* <lalLaTeX> -\newpage\input{GenerateInspiralWaveformC} -</lalLaTeX> */ - INT4 XLALInspiralRingdownWave ( REAL4Vector *rdwave1, REAL4Vector *rdwave2, diff --git a/lal/packages/inspiral/src/LALInspiralChooseModel.c b/lal/packages/inspiral/src/LALInspiralChooseModel.c index 7724ecbcdf9ae7358724e5d2860e8eaf3bb212ea..d8b82a7368470879e65652331718548508bec204 100644 --- a/lal/packages/inspiral/src/LALInspiralChooseModel.c +++ b/lal/packages/inspiral/src/LALInspiralChooseModel.c @@ -509,6 +509,9 @@ LALInspiralChooseModel( case SpinTaylorT3: case SpinTaylor: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: ak->vn = ak->vlso = vlso = ak->vlsoT0; f->dEnergy = dEt0; f->flux = Ft0; @@ -548,6 +551,9 @@ LALInspiralChooseModel( case SpinTaylorT3: case SpinTaylor: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: ak->vn = ak->vlso = vlso = ak->vlsoT2; f->dEnergy = dEt2; @@ -585,6 +591,9 @@ LALInspiralChooseModel( case SpinTaylorT3: case SpinTaylor: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: ak->vn = ak->vlso = vlso = ak->vlsoT2; f->dEnergy = dEt2; f->flux = Ft3; @@ -640,6 +649,9 @@ LALInspiralChooseModel( case EOB: case EOBNR: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: case TaylorEt: case TaylorT4: case TaylorN: @@ -684,6 +696,9 @@ LALInspiralChooseModel( case EOB: case EOBNR: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: case TaylorEt: case TaylorT4: case TaylorN: @@ -729,6 +744,9 @@ LALInspiralChooseModel( case EOB: case EOBNR: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: case TaylorEt: case TaylorT4: case TaylorN: @@ -770,6 +788,9 @@ LALInspiralChooseModel( case EOB: case EOBNR: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: case TaylorEt: case TaylorT4: case TaylorN: @@ -793,6 +814,9 @@ LALInspiralChooseModel( case EOB: case EOBNR: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: ak->vn = ak->vlso = vlso = ak->vlsoP6; f->dEnergy = dEp6; f->flux = Fp7; @@ -873,6 +897,9 @@ LALInspiralChooseModel( case BCV: case BCVSpin: case IMRPhenomA: + case IMRPhenomB: + case IMRPhenomFA: + case IMRPhenomFB: ak->tn = 100.; break; case Eccentricity: diff --git a/lal/packages/inspiral/src/LALInspiralStationaryPhaseApprox2.c b/lal/packages/inspiral/src/LALInspiralStationaryPhaseApprox2.c index 122af387d5461859f497903b66f072f5f262dedf..0e528401a01de2be12268f40eea852eec6624ab5 100644 --- a/lal/packages/inspiral/src/LALInspiralStationaryPhaseApprox2.c +++ b/lal/packages/inspiral/src/LALInspiralStationaryPhaseApprox2.c @@ -151,6 +151,8 @@ LALInspiralStationaryPhaseApprox2 ( case LAL_PNORDER_THREE_POINT_FIVE: LALInspiralTaylorF2Phasing = LALInspiralTaylorF2Phasing7PN; break; + default: + ABORT( status, LALINSPIRALH_EORDERMISSING, LALINSPIRALH_MSGEORDERMISSING ); } n = signalvec->length; nby2 = n/2; diff --git a/lal/packages/inspiral/src/LALInspiralTaylorT4Waveform.c b/lal/packages/inspiral/src/LALInspiralTaylorT4Waveform.c index 7bb9c35b4c184a905cdcd571ba321c9eb8f527b4..0103204b793b7569a9ee962a09080e7fb4ebfaef 100644 --- a/lal/packages/inspiral/src/LALInspiralTaylorT4Waveform.c +++ b/lal/packages/inspiral/src/LALInspiralTaylorT4Waveform.c @@ -34,6 +34,7 @@ $Id$ #include <lal/LALInspiral.h> #include <lal/SeqFactories.h> #include <lal/FindRoot.h> +#include <lal/Units.h> void LALTaylorT4Derivatives4PN( REAL8Vector *values, @@ -68,6 +69,10 @@ void LALTaylorT4Waveform ( void LALTaylorT4WaveformEngine ( LALStatus *status, REAL4Vector *signalvec, + REAL4Vector *a, + REAL4Vector *ff, + REAL8Vector *phi, + UINT4 *countback, InspiralTemplate *params, InspiralInit *paramsInit ); @@ -283,6 +288,7 @@ void LALTaylorT4Waveform ( { /* </lalVerbatim> */ InspiralInit paramsInit; + UINT4 count; INITSTATUS(status, "LALTaylorT4Waveform", LALTAYLORT4WAVEFORMC); ATTATCHSTATUSPTR(status); @@ -312,18 +318,188 @@ void LALTaylorT4Waveform ( memset(signalvec->data, 0, signalvec->length * sizeof( REAL4 )); /* Call the engine function */ - LALTaylorT4WaveformEngine(status->statusPtr, signalvec, params, ¶msInit); + LALTaylorT4WaveformEngine(status->statusPtr, signalvec, + NULL, NULL, NULL, &count, params, ¶msInit); CHECKSTATUSPTR( status ); DETATCHSTATUSPTR(status); RETURN(status); } +void +LALTaylorT4WaveformForInjection( + LALStatus *status, + CoherentGW *waveform, + InspiralTemplate *params, + PPNParamStruc *ppnParams + ) +{ + UINT4 count, i; + REAL8 phiC; + + REAL4Vector *a = NULL; /* pointers to generated amplitude data */ + REAL4Vector *ff = NULL; /* pointers to generated frequency data */ + REAL8Vector *phi = NULL; /* pointer to generated phase data */ + + InspiralInit paramsInit; + + + INITSTATUS(status, "LALInspirallTaylorT4WaveformForInjection", LALTAYLORT4WAVEFORMC); + ATTATCHSTATUSPTR(status); + + /* Make sure parameter and waveform structures exist. */ + ASSERT( params, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL ); + ASSERT(waveform, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL); + ASSERT( !( waveform->a ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL ); + ASSERT( !( waveform->h ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL ); + ASSERT( !( waveform->f ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL ); + ASSERT( !( waveform->phi ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL ); + + params->ampOrder = 0; + XLALPrintInfo( "WARNING: Amp Order has been reset to %d", params->ampOrder); + + /* Compute some parameters*/ + LALInspiralInit(status->statusPtr, params, ¶msInit); + CHECKSTATUSPTR(status); + + if (paramsInit.nbins == 0) + { + XLALPrintError( "Error: Estimated length of injection is zero.\n" ); + ABORT( status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE ); + } + + /* Now we can allocate memory and vector for coherentGW structure*/ + ff = XLALCreateREAL4Vector( paramsInit.nbins ); + a = XLALCreateREAL4Vector( 2*paramsInit.nbins ); + phi = XLALCreateREAL8Vector( paramsInit.nbins ); + if ( !ff || !a || !phi ) + { + if ( ff ) + XLALDestroyREAL4Vector( ff ); + if ( a ) + XLALDestroyREAL4Vector( a ); + if ( phi ) + XLALDestroyREAL8Vector( phi ); + ABORTXLAL( status ); + } + + /* Call the engine function */ + LALTaylorT4WaveformEngine(status->statusPtr, NULL, a, ff, + phi, &count, params, ¶msInit); + BEGINFAIL( status ) + { + XLALDestroyREAL4Vector( ff ); + XLALDestroyREAL4Vector( a ); + XLALDestroyREAL8Vector( phi ); + } + ENDFAIL( status ); + + /*wrap the phase vector*/ + phiC = phi->data[count-1] ; + for (i = 0; i < count; i++) + { + phi->data[i] = phi->data[i] - phiC + ppnParams->phi; + } + + /* Allocate the waveform structures. */ + if ( ( waveform->a = (REAL4TimeVectorSeries *) + LALCalloc(1, sizeof(REAL4TimeVectorSeries) ) ) == NULL ) + { + XLALDestroyREAL4Vector( ff ); + XLALDestroyREAL4Vector( a ); + XLALDestroyREAL8Vector( phi ); + ABORT( status, LALINSPIRALH_EMEM, + LALINSPIRALH_MSGEMEM ); + } + if ( ( waveform->f = (REAL4TimeSeries *) + LALCalloc(1, sizeof(REAL4TimeSeries) ) ) == NULL ) + { + LALFree( waveform->a ); waveform->a = NULL; + XLALDestroyREAL4Vector( ff ); + XLALDestroyREAL4Vector( a ); + XLALDestroyREAL8Vector( phi ); + ABORT( status, LALINSPIRALH_EMEM, + LALINSPIRALH_MSGEMEM ); + } + if ( ( waveform->phi = (REAL8TimeSeries *) + LALCalloc(1, sizeof(REAL8TimeSeries) ) ) == NULL ) + { + LALFree( waveform->a ); waveform->a = NULL; + LALFree( waveform->f ); waveform->f = NULL; + XLALDestroyREAL4Vector( ff ); + XLALDestroyREAL4Vector( a ); + XLALDestroyREAL8Vector( phi ); + ABORT( status, LALINSPIRALH_EMEM, + LALINSPIRALH_MSGEMEM ); + } + + waveform->a->data = XLALCreateREAL4VectorSequence( (UINT4)count, 2 ); + waveform->f->data = XLALCreateREAL4Vector( count ); + waveform->phi->data = XLALCreateREAL8Vector( count ); + + if ( !waveform->a->data || !waveform->f->data || !waveform->phi->data ) + { + if ( waveform->a->data ) + XLALDestroyREAL4VectorSequence( waveform->a->data ); + if ( waveform->f->data ) + XLALDestroyREAL4Vector( waveform->f->data ); + if ( waveform->phi->data ) + XLALDestroyREAL8Vector( waveform->phi->data ); + LALFree( waveform->a ); waveform->a = NULL; + LALFree( waveform->f ); waveform->f = NULL; + XLALDestroyREAL4Vector( ff ); + XLALDestroyREAL4Vector( a ); + XLALDestroyREAL8Vector( phi ); + ABORTXLAL( status ); + } + + memcpy(waveform->f->data->data , ff->data, count*(sizeof(REAL4))); + memcpy(waveform->a->data->data , a->data, 2*count*(sizeof(REAL4))); + memcpy(waveform->phi->data->data ,phi->data, count*(sizeof(REAL8))); + + waveform->a->deltaT = waveform->f->deltaT = waveform->phi->deltaT + = ppnParams->deltaT; + + waveform->a->sampleUnits = lalStrainUnit; + waveform->f->sampleUnits = lalHertzUnit; + waveform->phi->sampleUnits = lalDimensionlessUnit; + waveform->position = ppnParams->position; + waveform->psi = ppnParams->psi; + + snprintf( waveform->a->name, LALNameLength, "T4 inspiral amplitude" ); + snprintf( waveform->f->name, LALNameLength, "T4 inspiral frequency" ); + snprintf( waveform->phi->name, LALNameLength, "T4 inspiral phase" ); + + /* --- fill some output ---*/ + ppnParams->tc = (double)(count-1) / params->tSampling ; + ppnParams->length = count; + ppnParams->dfdt = ((REAL4)(waveform->f->data->data[count-1] + - waveform->f->data->data[count-2])) * ppnParams->deltaT; + ppnParams->fStop = params->fFinal; + ppnParams->termCode = GENERATEPPNINSPIRALH_EFSTOP; + ppnParams->termDescription = GENERATEPPNINSPIRALH_MSGEFSTOP; + + ppnParams->fStart = ppnParams->fStartIn; + + + /* --- free memory --- */ + XLALDestroyREAL4Vector( ff ); + XLALDestroyREAL4Vector( a ); + XLALDestroyREAL8Vector( phi ); + + DETATCHSTATUSPTR(status); + RETURN (status); +} + /*---------------------------------------------------------*/ void LALTaylorT4WaveformEngine ( LALStatus *status, REAL4Vector *signalvec, + REAL4Vector *a, + REAL4Vector *ff, + REAL8Vector *phiVec, + UINT4 *countback, InspiralTemplate *params, InspiralInit *paramsInit ) @@ -342,10 +518,24 @@ LALTaylorT4WaveformEngine ( /*DFindRootIn rootIn;*/ CHAR message[256]; + /* Variables for injection */ + REAL8 mTot = 0; + REAL8 unitHz = 0; + REAL8 f2a = 0; + REAL8 mu = 0; + REAL8 cosI = 0;/* cosine of system inclination */ + REAL8 etab = 0; + REAL8 fFac = 0; /* SI normalization for f and t */ + REAL8 f2aFac = 0;/* factor multiplying f in amplitude function */ + REAL8 apFac = 0, acFac = 0;/* extra factor in plus and cross amplitudes */ + INITSTATUS(status, "LALTaylorT4WaveformEngine", LALTAYLORT4WAVEFORMC); ATTATCHSTATUSPTR(status); + ASSERT( signalvec || ( ff && a && phiVec ), status, + LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL ); + /* Allocate all the memory required to dummy and then point the various arrays to dummy - this makes it easier to handle memory failures */ @@ -370,12 +560,36 @@ LALTaylorT4WaveformEngine ( dyt.data = &dummy.data[5*nn]; + if ( a ) + { + mTot = params->mass1 + params->mass2; + etab = params->mass1 * params->mass2; + etab /= mTot; + etab /= mTot; + unitHz = mTot *LAL_MTSUN_SI*(REAL8)LAL_PI; + cosI = cos( params->inclination ); + mu = etab * mTot; + fFac = 1.0 / ( 4.0*LAL_TWOPI*LAL_MTSUN_SI*mTot ); + f2aFac = LAL_PI*LAL_MTSUN_SI*mTot*fFac; + apFac = acFac = -2.0 * mu * LAL_MRSUN_SI/params->distance; + apFac *= 1.0 + cosI*cosI; + acFac *= 2.0*cosI; + params->nStartPad = 0; + } + /* Set dt to sampling interval specified by user */ dt = 1./params->tSampling; ak = paramsInit->ak; func = paramsInit->func; - length = signalvec->length; + if ( signalvec ) + { + length = signalvec->length; + } + else + { + length = ff->length; + } eta = ak.eta; m = ak.totalmass; @@ -448,7 +662,7 @@ LALTaylorT4WaveformEngine ( while (omega<omegaMax) { - if (count > length) + if (count >= length) { XLALRungeKutta4Free( integrator ); LALFree(dummy.data); @@ -456,7 +670,23 @@ LALTaylorT4WaveformEngine ( } h = 4 * m * eta * v*v * cos(2.*phi); - signalvec->data[ndx] = h; + if ( signalvec ) + { + signalvec->data[ndx] = h; + } + else if (a) + { + int ice, ico; + ice = 2*count; + ico = ice + 1; + omega = v*v*v; + + ff->data[count] = (REAL4)(omega/unitHz); + f2a = pow (f2aFac * omega, 2./3.); + a->data[ice] = (REAL4)(4.*apFac * f2a); + a->data[ico] = (REAL4)(4.*acFac * f2a); + phiVec->data[count] = (REAL8)(2.0 * phi); + } /* fprintf(stdout, "%e %e %e\n", t, h, omega/(2.*m*LAL_PI)); */ /* Integrate one step forward */ @@ -485,6 +715,7 @@ LALTaylorT4WaveformEngine ( /*----------------------------------------------------------------------*/ /* Record the final cutoff frequency of BD Waveforms for record keeping */ /* ---------------------------------------------------------------------*/ + *countback = count; v = pow(m*omega, 1./3.); params->vFinal = v; params->tC = t; diff --git a/lal/packages/inspiral/src/LALInspiralWave.c b/lal/packages/inspiral/src/LALInspiralWave.c index fdcb23eaea489cd63c24271dcea4f20f2da4dab8..9ee9c806e8c79249ff316ba4316f7d6e9cf0f6bb 100644 --- a/lal/packages/inspiral/src/LALInspiralWave.c +++ b/lal/packages/inspiral/src/LALInspiralWave.c @@ -175,9 +175,15 @@ LALInspiralWave( CHECKSTATUSPTR(status); break; case IMRPhenomA: + case IMRPhenomB: LALBBHPhenWaveTimeDom(status->statusPtr, signalvec, params); CHECKSTATUSPTR(status); break; + case IMRPhenomFA: + case IMRPhenomFB: + LALBBHPhenWaveFreqDom(status->statusPtr, signalvec, params); + CHECKSTATUSPTR(status); + break; case BCV: LALBCVWaveform(status->statusPtr, signalvec, params); CHECKSTATUSPTR(status); @@ -289,9 +295,15 @@ LALInspiralWaveTemplates( CHECKSTATUSPTR(status); break; case IMRPhenomA: + case IMRPhenomB: LALBBHPhenWaveTimeDomTemplates(status->statusPtr, signalvec1, signalvec2, params); CHECKSTATUSPTR(status); break; + case IMRPhenomFA: + case IMRPhenomFB: + LALBBHPhenWaveFreqDomTemplates(status->statusPtr, signalvec1, signalvec2, params); + CHECKSTATUSPTR(status); + break; case TaylorF1: case TaylorF2: case FindChirpSP: @@ -360,6 +372,7 @@ LALInspiralWaveForInjection( CHECKSTATUSPTR(status); break; case IMRPhenomA: + case IMRPhenomB: LALBBHPhenWaveTimeDomForInjection (status->statusPtr, waveform, inspiralParams, ppnParams); CHECKSTATUSPTR(status); break; @@ -379,7 +392,11 @@ LALInspiralWaveForInjection( case AmpCorPPN: LALInspiralAmplitudeCorrectedWaveForInjection(status->statusPtr, waveform, inspiralParams, ppnParams); CHECKSTATUSPTR(status); - break; + break; + case TaylorT4: + LALTaylorT4WaveformForInjection(status->statusPtr, waveform, inspiralParams, ppnParams); + CHECKSTATUSPTR(status); + break; default: ABORT( status, 9999, "Unknown case in switch." ); diff --git a/lal/packages/inspiral/src/LALInspiralWaveLength.c b/lal/packages/inspiral/src/LALInspiralWaveLength.c index 94e39796e3a95835ca25e13808edd44523456296..3b686605d8629c5b182ea548f96f155d255a17c7 100644 --- a/lal/packages/inspiral/src/LALInspiralWaveLength.c +++ b/lal/packages/inspiral/src/LALInspiralWaveLength.c @@ -98,7 +98,6 @@ LALInspiralWaveLength( ASSERT (params.nStartPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE); ASSERT (params.nEndPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE); ASSERT (params.tSampling > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE); - ASSERT (¶ms, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL); LALInspiralSetup (status->statusPtr, &ak, ¶ms); CHECKSTATUSPTR(status); diff --git a/lal/packages/inspiral/src/LALPhenomWaveform.c b/lal/packages/inspiral/src/LALPhenomWaveform.c index bf4878c26b9e36ef04333bc5dbf6414aa77510ed..a87469c86dbf68013c493c34072e70ea36e048aa 100644 --- a/lal/packages/inspiral/src/LALPhenomWaveform.c +++ b/lal/packages/inspiral/src/LALPhenomWaveform.c @@ -1,5 +1,5 @@ /* -* Copyright (C) 2008 P. Ajith, Badri Krishnan, Lucia Santamaria +* Copyright (C) 2008-2009 P. Ajith, Badri Krishnan, Lucia Santamaria * * 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 @@ -52,15 +52,20 @@ BBHPhenomParams; static void XLALComputePhenomParams( BBHPhenomParams *phenParams, InspiralTemplate *params); +static void XLALComputePhenomParams2( BBHPhenomParams *phenParams, + InspiralTemplate *params); + static REAL8 XLALLorentzianFn ( REAL8 freq, REAL8 fRing, REAL8 sigma); - static void XLALBBHPhenWaveFD ( BBHPhenomParams *params, InspiralTemplate *insp_template, REAL4Vector *signalvec); +static void XLALBBHPhenWaveFD2 ( BBHPhenomParams *params, + InspiralTemplate *insp_template, + REAL4Vector *signalvec); static void XLALComputeInstantFreq( REAL4Vector *Freq, REAL4Vector *hp, @@ -92,20 +97,51 @@ void LALBBHPhenWaveFreqDom ( LALStatus *status, ASSERT (signalvec->data, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL); ASSERT (params, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL); ASSERT (signalvec->length>2, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (params->mass1 > 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (params->mass2 > 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (params->spin1[0] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (params->spin1[1] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (params->spin2[0] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (params->spin2[1] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + + switch (params->approximant) { + + /* non-spinning binaries. Ref. http://arxiv.org/pdf/0710.2335 */ + case IMRPhenomA: + case IMRPhenomFA: + + ASSERT (params->spin1[2] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (params->spin2[2] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + /* compute the phenomenological parameters */ + XLALComputePhenomParams(&phenParams, params); + /* generate the phenomenological waveform in frequency domain */ + XLALBBHPhenWaveFD (&phenParams, params, signalvec); + break; + + /* aligned-spin binaries. Ref. http://arxiv.org/pdf/0909.2867 */ + case IMRPhenomB: + case IMRPhenomFB: + + /* compute the phenomenological parameters */ + XLALComputePhenomParams2(&phenParams, params); + /* generate the phenomenological waveform in frequency domain */ + XLALBBHPhenWaveFD2 (&phenParams, params, signalvec); + break; + + default: + ABORT( status, 9999, "Unknown case in switch." ); + } - /* compute the phenomenological parameters */ - XLALComputePhenomParams(&phenParams, params); - - /* generate the phenomenological waveform in frequency domain */ - XLALBBHPhenWaveFD (&phenParams, params, signalvec); - -/* params->fFinal = params->fCut; */ - - DETATCHSTATUSPTR(status); - RETURN(status); + DETATCHSTATUSPTR(status); + RETURN(status); } +/*********************************************************************/ +/* Compute phenomenological parameters for non-spinning binaries */ +/* Ref. Eq.(4.18) of http://arxiv.org/pdf/0710.2335 and */ +/* Table I of http://arxiv.org/pdf/0712.0343 */ +/*********************************************************************/ static void XLALComputePhenomParams( BBHPhenomParams *phenParams, InspiralTemplate *params) @@ -191,7 +227,99 @@ static void XLALComputePhenomParams( BBHPhenomParams *phenParams, } +/*********************************************************************/ +/* Compute phenomenological parameters for aligned-spin binaries */ +/* Ref. Eq.(2) and Table I of http://arxiv.org/pdf/0909.2867 */ +/*********************************************************************/ +static void XLALComputePhenomParams2( BBHPhenomParams *phenParams, + InspiralTemplate *params) + +{ + + REAL8 totalMass, piM, eta, chi, delta; + + /* calculate the total mass and symmetric mass ratio */ + + if (params) { + + totalMass = params->mass1+params->mass2; + eta = params->mass1*params->mass2/pow(totalMass,2.); + piM = totalMass*LAL_PI*LAL_MTSUN_SI; + delta = sqrt(1.-4.*eta); /* asymetry parameter */ + + /* spin parameter used for the search */ + chi = 0.5*(params->spin1[2]*(1.+delta) + params->spin2[2]*(1.-delta)); + } + else { + return; + } + + /* spinning phenomenological waveforms */ + if (phenParams) { + + phenParams->psi0 = 3./(128.*eta); + + phenParams->psi2 = 3715./756. + + -9.2091e+02*eta + 4.9213e+02*eta*chi + 1.3503e+02*eta*pow(chi,2.) + + 6.7419e+03*pow(eta,2.) + -1.0534e+03*pow(eta,2.)*chi + + -1.3397e+04*pow(eta,3.) ; + + phenParams->psi3 = -16.*LAL_PI + 113.*chi/3. + + 1.7022e+04*eta + -9.5659e+03*eta*chi + -2.1821e+03*eta*pow(chi,2.) + + -1.2137e+05*pow(eta,2.) + 2.0752e+04*pow(eta,2.)*chi + + 2.3859e+05*pow(eta,3.) ; + + phenParams->psi4 = 15293365./508032. - 405.*pow(chi,2.)/8. + + -1.2544e+05*eta + 7.5066e+04*eta*chi + 1.3382e+04*eta*pow(chi,2.) + + 8.7354e+05*pow(eta,2.) + -1.6573e+05*pow(eta,2.)*chi + + -1.6936e+06*pow(eta,3.) ; + + phenParams->psi6 = -8.8977e+05*eta + 6.3102e+05*eta*chi + 5.0676e+04*eta*pow(chi,2.) + + 5.9808e+06*pow(eta,2.) + -1.4148e+06*pow(eta,2.)*chi + + -1.1280e+07*pow(eta,3.) ; + + phenParams->psi7 = 8.6960e+05*eta + -6.7098e+05*eta*chi + -3.0082e+04*eta*pow(chi,2.) + + -5.8379e+06*pow(eta,2.) + 1.5145e+06*pow(eta,2.)*chi + + 1.0891e+07*pow(eta,3.) ; + + phenParams->fMerger = 1. - 4.4547*pow(1.-chi,0.217) + 3.521*pow(1.-chi,0.26) + + 6.4365e-01*eta + 8.2696e-01*eta*chi + -2.7063e-01*eta*pow(chi,2.) + + -5.8218e-02*pow(eta,2.) + -3.9346e+00*pow(eta,2.)*chi + + -7.0916e+00*pow(eta,3.) ; + + phenParams->fRing = (1. - 0.63*pow(1.-chi,0.3))/2. + + 1.4690e-01*eta + -1.2281e-01*eta*chi + -2.6091e-02*eta*pow(chi,2.) + + -2.4900e-02*pow(eta,2.) + 1.7013e-01*pow(eta,2.)*chi + + 2.3252e+00*pow(eta,3.) ; + + phenParams->sigma = (1. - 0.63*pow(1.-chi,0.3))*pow(1.-chi,0.45)/4. + + -4.0979e-01*eta + -3.5226e-02*eta*chi + 1.0082e-01*eta*pow(chi,2.) + + 1.8286e+00*pow(eta,2.) + -2.0169e-02*pow(eta,2.)*chi + + -2.8698e+00*pow(eta,3.) ; + + phenParams->fCut = 3.2361e-01 + 4.8935e-02*chi + 1.3463e-02*pow(chi,2.) + + -1.3313e-01*eta + -8.1719e-02*eta*chi + 1.4512e-01*eta*pow(chi,2.) + + -2.7140e-01*pow(eta,2.) + 1.2788e-01*pow(eta,2.)*chi + + 4.9220e+00*pow(eta,3.) ; + + phenParams->fCut /= piM; + phenParams->fMerger/= piM; + phenParams->fRing /= piM; + phenParams->sigma /= piM; + + phenParams->psi1 = 0.; + phenParams->psi5 = 0.; + } + + + return; + +} +/*********************************************************************/ +/* Compute frequency-domain waveforms for non-spinning binaries */ +/* Ref. Eq.(4.13) and (4.16) of http://arxiv.org/pdf/0710.2335 */ +/*********************************************************************/ static void XLALBBHPhenWaveFD ( BBHPhenomParams *params, InspiralTemplate *insp_template, REAL4Vector *signalvec) { @@ -275,6 +403,133 @@ static void XLALBBHPhenWaveFD ( BBHPhenomParams *params, } +/*********************************************************************/ +/* Compute frequency-domain waveforms for aligned-spin binaries */ +/* Ref. Eq.(1) of http://arxiv.org/pdf/0909.2867 */ +/*********************************************************************/ +static void XLALBBHPhenWaveFD2 ( BBHPhenomParams *params, + InspiralTemplate *insp_template, + REAL4Vector *signalvec) { + + REAL8 df, shft, phi, amp0, ampEff=0, psiEff, fMerg, fNorm; + REAL8 f, fRing, sigma, totalMass, eta; + INT4 i, j, n; + REAL8 v, alpha2, alpha3, w1, vMerg; + REAL8 epsilon_1, epsilon_2, w2, vRing, chi, mergPower, delta; + + /* freq resolution and the low-freq bin */ + df = insp_template->tSampling/signalvec->length; + n = signalvec->length; + + /* If we want to pad with zeroes in the beginning then the instant of + * coalescence will be the chirp time + the duration for which padding + * is needed. Thus, in the equation below nStartPad occurs with a +ve sign. + * This code doesn't support non-zero start-time. i.e. params->startTime + * should be necessarily zero.*/ + shft = 2.*LAL_PI * ((REAL4)signalvec->length/insp_template->tSampling + + insp_template->nStartPad/insp_template->tSampling + insp_template->startTime)-20.; + + /* the negative sign is introduced such that the definition of the + * polarisations (phi = 0 for plus, phi = pi/2 for cross) is consistent + * with the IMRPhenomA waveforms */ + phi = -insp_template->startPhase; + + /* phenomenological parameters*/ + fMerg = params->fMerger; + fRing = params->fRing; + sigma = params->sigma; + + /* physical parameters*/ + totalMass = insp_template->mass1 + insp_template->mass2; + eta = insp_template->eta = insp_template->mass1 * insp_template->mass2 / pow(totalMass, 2.); + delta = sqrt(1.-4.*eta); + chi = 0.5*(insp_template->spin1[2]*(1.+delta) + insp_template->spin2[2]*(1.-delta)); + + /* Now compute the amplitude. NOTE the params->distance is assumed to + * me in meters. This is, in principle, inconsistent with the LAL + * documentation (inspiral package). But this seems to be the convention + * employed in the injection codes */ + amp0 = pow(LAL_MTSUN_SI*totalMass, 5./6.)*pow(fMerg,-7./6.)/pow(LAL_PI,2./3.); + amp0 *= pow(5.*eta/24., 1./2.)/(insp_template->distance/LAL_C_SI); + + /* fill the zero and Nyquist frequency with zeros */ + *(signalvec->data+0) = 0.; + *(signalvec->data+n/2) = 0.; + + /***********************************************************************/ + /* these are the parameters required for the "new" phenomenological IMR + * waveforms*/ + /***********************************************************************/ + + /* PN correctiosn to the frequency domain amplitude of the (2,2) mode */ + alpha2 = -323./224. + 451.*insp_template->eta/168.; + alpha3 = (27./8. - 11.*insp_template->eta/6.)*chi; + + /* leading order power law of the merger amplitude */ + mergPower = -2./3.; + + /* spin-dependant corrections to the merger amplitude */ + epsilon_1 = 1.4547*chi - 1.8897; + epsilon_2 = -1.8153*chi + 1.6557; + + /* normalisation constant of the inspiral amplitude */ + vMerg = pow(LAL_PI*totalMass*LAL_MTSUN_SI*fMerg, 1./3.); + vRing = pow(LAL_PI*totalMass*LAL_MTSUN_SI*fRing, 1./3.); + + w1 = 1. + alpha2*pow(vMerg,2.) + alpha3*pow(vMerg,3.); + w1 = w1/(1. + epsilon_1*vMerg + epsilon_2*vMerg*vMerg); + w2 = w1*(LAL_PI*sigma/2.)*pow(fRing/fMerg, mergPower)*(1. + epsilon_1*vRing + + epsilon_2*vRing*vRing); + + /***********************************************************************/ + /* now generate the waveform at all frequency bins */ + /***********************************************************************/ + for (i=1; i<n/2; i++) { + + /* this is the index of the imaginary part */ + j = n-i; + + /* fourier frequency corresponding to this bin */ + f = i * df; + fNorm = f/fMerg; + + /* PN expansion parameter */ + v = pow(LAL_PI*totalMass*LAL_MTSUN_SI*f, 1./3.); + + /* compute the amplitude */ + if ((f < insp_template->fLower) || (f > params->fCut)) { + ampEff = 0.; + } + else if (f <= fMerg) { + + ampEff = pow(fNorm, -7./6.)*(1. + alpha2*pow(v,2.) + alpha3*pow(v,3.)); + + } + else if ((f > fMerg) & (f <= fRing)) { + + ampEff = w1*pow(fNorm, mergPower)*(1. + epsilon_1*v + epsilon_2*v*v); + + } + else if (f > fRing) { + + ampEff = w2*XLALLorentzianFn ( f, fRing, sigma); + + } + + /* now compute the phase */ + psiEff = shft*f + phi + + 3./(128.*eta*pow(v,5.))*(1 + params->psi2*pow(v, 2.) + + params->psi3*pow(v, 3.) + params->psi4*pow(v, 4.) + + params->psi5*pow(v, 5.) + params->psi6*pow(v, 6.) + + params->psi7*pow(v, 7.)); + + /* generate the waveform */ + *(signalvec->data+i) = (REAL4) (amp0 * ampEff * cos(psiEff)); /* real */ + *(signalvec->data+j) = (REAL4) (-amp0 * ampEff * sin(psiEff)); /* imag */ + + } + +} static REAL8 XLALLorentzianFn ( REAL8 freq, REAL8 fRing, @@ -351,10 +606,29 @@ void LALBBHPhenWaveTimeDom ( LALStatus *status, ASSERT (insp_template->nEndPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE); ASSERT (insp_template->fLower > 0.0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE); ASSERT (insp_template->tSampling > 0.0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE); - + ASSERT (insp_template->mass1 > 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (insp_template->mass2 > 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (insp_template->spin1[0] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (insp_template->spin1[1] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (insp_template->spin2[0] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (insp_template->spin2[1] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); /* compute the phenomenological parameters */ - XLALComputePhenomParams(&phenParams, insp_template); + switch (insp_template->approximant) { + + /* non-spinning binaries. Ref. http://arxiv.org/pdf/0710.2335 */ + case IMRPhenomA: + ASSERT (insp_template->spin1[2] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + ASSERT (insp_template->spin2[2] == 0, status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE); + XLALComputePhenomParams(&phenParams, insp_template); + break; + /* aligned-spin binaries. Ref. http://arxiv.org/abs/0909.2867 */ + case IMRPhenomB: + XLALComputePhenomParams2(&phenParams, insp_template); + break; + default: + ABORT( status, 9999, "Unknown case in switch." ); + } totalMass = insp_template->mass1 + insp_template->mass2; eta = insp_template->mass1*insp_template->mass2/pow(totalMass,2.); @@ -365,18 +639,11 @@ void LALBBHPhenWaveTimeDom ( LALStatus *status, * below an instantaneous frequency fLower */ fLowerOrig = insp_template->fLower; /* this is the low-freq set by the user */ - /* Find an optimum value for fLower (using the definition of Newtonian chirp time) - * such that the waveform has a minimum length of tau0. This is necessary to avoid - * FFT artifacts */ - tau0 = 32.; - fLower = pow((tau0*256.*eta*pow(totalMass*LAL_MTSUN_SI,5./3.)/5.),-3./8.)/LAL_PI; /* Actually, this seems to be a better ansatz - as this makes use of the definition of Newtonian - chirp time in order to find an fLower that gives - a minimum length of tau0 (which can be fixed) for - the waveform - Ajith, 18 Nov 08 */ - /* Better ansatz (Lucia Oct 08) */ - /* fLower = 2.E-3/(totalMass*LAL_MTSUN_SI); */ - /* fLower = 18. - 3.*totalMass/25.; */ + /* Find an optimum value for fLower (using the definition of Newtonian chirp time) + * such that the waveform has a minimum length of tau0. This is necessary to avoid + * FFT artifacts */ + tau0 = 32.; + fLower = pow((tau0*256.*eta*pow(totalMass*LAL_MTSUN_SI,5./3.)/5.),-3./8.)/LAL_PI; fCut = (1.025)*phenParams.fCut; /* make sure that these frequencies are not too out of range */ @@ -393,19 +660,25 @@ void LALBBHPhenWaveTimeDom ( LALStatus *status, /* generate the phenomenological waveform in frequency domain */ n = signalvec->length; signalFD1 = XLALCreateREAL4Vector(n); - XLALBBHPhenWaveFD (&phenParams, insp_template, signalFD1); + + /* compute the phenomenological parameters */ + switch (insp_template->approximant) { + + /* non-spinning binaries. Ref. http://arxiv.org/pdf/0710.2335 */ + case IMRPhenomA: + XLALBBHPhenWaveFD (&phenParams, insp_template, signalFD1); + break; + /* aligned-spin binaries. Ref. http://arxiv.org/abs/0909.2867 */ + case IMRPhenomB: + XLALBBHPhenWaveFD2 (&phenParams, insp_template, signalFD1); + break; + default: + ABORT( status, 9999, "Unknown case in switch." ); + } /* apply the softening window function */ fRes = insp_template->tSampling/n; - /********************************* DEBUG ********************************/ - /* filePtr = fopen("FreqDomPhenWave.txt","a"); - for (i = 1; i < n/2; i++) { - fprintf(filePtr,"%e\t%e\t%e\n", i*fRes, signalFD1->data[i],signalFD1->data[n-i]); - } - fclose(filePtr); */ - /************************************************************************/ - winFLo = (fLowerOrig + fLower)/2.; winFHi = (fCut + phenParams.fCut)/2.; sigLo = 4.; @@ -419,20 +692,13 @@ void LALBBHPhenWaveTimeDom ( LALStatus *status, signalFD1->data[n-k] *= softWin; } - - /********************************* DEBUG ********************************/ - /* filePtr = fopen("FreqDomPhenWave_Wind.txt","a"); - for (i = 1; i < n/2; i++) { - fprintf(filePtr,"%e\t%e\t%e\n", i*fRes, signalFD1->data[i],signalFD1->data[n-i]); - } - fclose(filePtr); */ - /************************************************************************/ - /* Inverse Fourier transform */ - LALCreateReverseREAL4FFTPlan(status->statusPtr, &revPlan, n, 0 ); - LALREAL4VectorFFT(status->statusPtr, signalvec, signalFD1, revPlan); + revPlan = XLALCreateReverseREAL4FFTPlan(n, 0); + if (revPlan == NULL) + ABORTXLAL(status); + XLALREAL4VectorFFT(signalvec, signalFD1, revPlan); XLALDestroyREAL4Vector(signalFD1); - LALDestroyREAL4FFTPlan(status->statusPtr, &revPlan); + XLALDestroyREAL4FFTPlan(revPlan); /* FFT normalisation. The LAL implementation of the FFT omits the factor 1/n. * Also we change the sign of the waveform so that the initialPhase = 0 and pi/2 @@ -442,14 +708,6 @@ void LALBBHPhenWaveTimeDom ( LALStatus *status, signalvec->data[i] *= -insp_template->tSampling/n; } - /********************************* DEBUG ********************************/ - /*filePtr = fopen("TimeDomPhenWave.txt","a"); - for (i = 0; i < n; i++) { - fprintf(filePtr,"%e\t%e\n", i/insp_template->tSampling, signalvec->data[i]); - } - fclose(filePtr);*/ - /************************************************************************/ - /* apply a linearly increasing/decresing window at the beginning and at the end * of the waveform in order to avoid edge effects. This could be made fancier */ windowLength = 10.*totalMass * LAL_MTSUN_SI*insp_template->tSampling; @@ -461,22 +719,12 @@ void LALBBHPhenWaveTimeDom ( LALStatus *status, signalvec->data[i] *= i/windowLength; } - /********************************* DEBUG ********************************/ - /* CHAR fileName[1000]; - sprintf(fileName, "TimeDomPhenWave_Wind_Phi0%4.3f.txt",insp_template->startPhase); - filePtr = fopen(fileName,"a"); - for (i = 0; i < n; i++) { - fprintf(filePtr,"%e\t%e\n", i/insp_template->tSampling, signalvec->data[i]); - } - fclose(filePtr); */ - /************************************************************************/ - - /* reassign the original value of fLower */ - insp_template->fLower = fLowerOrig; - insp_template->fFinal = phenParams.fCut; + /* reassign the original value of fLower */ + insp_template->fLower = fLowerOrig; + insp_template->fFinal = phenParams.fCut; - DETATCHSTATUSPTR(status); - RETURN(status); + DETATCHSTATUSPTR(status); + RETURN(status); } @@ -718,7 +966,7 @@ void LALBBHPhenWaveTimeDomForInjection (LALStatus *status, memset(a->data, 0, 2 * paramsInit.nbins * sizeof(REAL4)); memset(phi->data, 0, paramsInit.nbins * sizeof(REAL8)); - if( params->approximant == IMRPhenomA ) { + if( params->approximant == IMRPhenomA || params->approximant == IMRPhenomB) { LALSCreateVector(status->statusPtr, &h, 2*paramsInit.nbins); CHECKSTATUSPTR(status); memset(h->data, 0, 2*paramsInit.nbins * sizeof(REAL4)); @@ -735,7 +983,7 @@ void LALBBHPhenWaveTimeDomForInjection (LALStatus *status, CHECKSTATUSPTR(status); LALDDestroyVector(status->statusPtr, &phi); CHECKSTATUSPTR(status); - if( params->approximant == IMRPhenomA ){ + if( params->approximant == IMRPhenomA || params->approximant == IMRPhenomB){ LALSDestroyVector(status->statusPtr, &h); CHECKSTATUSPTR(status); } @@ -752,9 +1000,9 @@ void LALBBHPhenWaveTimeDomForInjection (LALStatus *status, CHECKSTATUSPTR(status); LALDDestroyVector(status->statusPtr, &phi); CHECKSTATUSPTR(status); - if( params->approximant == IMRPhenomA){ - LALSDestroyVector(status->statusPtr, &h); - CHECKSTATUSPTR(status); + if( params->approximant == IMRPhenomA || params->approximant == IMRPhenomB){ + LALSDestroyVector(status->statusPtr, &h); + CHECKSTATUSPTR(status); } DETATCHSTATUSPTR( status ); @@ -854,21 +1102,22 @@ void LALBBHPhenWaveTimeDomForInjection (LALStatus *status, ppnParams->termDescription = GENERATEPPNINSPIRALH_MSGEFSTOP; ppnParams->fStart = ppnParams->fStartIn; - if( params->approximant == IMRPhenomA ){ - if ( ( waveform->h = (REAL4TimeVectorSeries *) - LALMalloc( sizeof(REAL4TimeVectorSeries) ) ) == NULL ){ - ABORT( status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM ); - } - memset( waveform->h, 0, sizeof(REAL4TimeVectorSeries) ); - LALSCreateVectorSequence( status->statusPtr,&( waveform->h->data ), &in ); - CHECKSTATUSPTR(status); - memcpy(waveform->h->data->data , h->data, 2*count*(sizeof(REAL4))); - waveform->h->deltaT = 1./params->tSampling; - waveform->h->sampleUnits = lalStrainUnit; - snprintf( waveform->h->name, + if( params->approximant == IMRPhenomA || params->approximant == IMRPhenomB){ + if ( ( waveform->h = (REAL4TimeVectorSeries *) + LALMalloc( sizeof(REAL4TimeVectorSeries) ) ) == NULL ){ + ABORT( status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM ); + } + + memset( waveform->h, 0, sizeof(REAL4TimeVectorSeries) ); + LALSCreateVectorSequence( status->statusPtr,&( waveform->h->data ), &in ); + CHECKSTATUSPTR(status); + memcpy(waveform->h->data->data , h->data, 2*count*(sizeof(REAL4))); + waveform->h->deltaT = 1./params->tSampling; + waveform->h->sampleUnits = lalStrainUnit; + snprintf( waveform->h->name, LALNameLength, "Phenom inspiral polarizations"); - LALSDestroyVector(status->statusPtr, &h); - CHECKSTATUSPTR(status); + LALSDestroyVector(status->statusPtr, &h); + CHECKSTATUSPTR(status); } } /* end phase condition*/ diff --git a/lal/packages/inspiral/src/LALSTPNWaveform.c b/lal/packages/inspiral/src/LALSTPNWaveform.c index b846003e4fe846a612ba83c87ffbb910a1fcfb5e..ab9878bf006419d96944e41b8a4522e4da11baa5 100644 --- a/lal/packages/inspiral/src/LALSTPNWaveform.c +++ b/lal/packages/inspiral/src/LALSTPNWaveform.c @@ -938,6 +938,8 @@ LALSTPNWaveformEngine ( -(110.0/9.0) * (-1987.0/3080.0) ) * params->eta -(155.0/96.0)*params->eta*params->eta - (35.0/5184.0)*params->eta*params->eta*params->eta ); break; + default: + ABORT( status, LALINSPIRALH_EORDERMISSING, LALINSPIRALH_MSGEORDERMISSING ); } if (params->order == LAL_PNORDER_THREE) diff --git a/lal/packages/inspiral/test/Makefile.am b/lal/packages/inspiral/test/Makefile.am index 33f1ef39d35fbccc22dec511e54a8d1cf265e919..a07e47aa56152e9008eb61d0cc169174082f4953 100644 --- a/lal/packages/inspiral/test/Makefile.am +++ b/lal/packages/inspiral/test/Makefile.am @@ -1,26 +1,15 @@ ## Process this file with automake to produce Makefile.in -if FRAME -if METAIO -check_PROGRAMS = GenerateInspiralWaveform LALHybridTest -else -check_PROGRAMS = GenerateInspiralWaveform -endif -else -check_PROGRAMS = GenerateInspiralWaveform -endif - -GenerateInspiralWaveform_SOURCES = GenerateInspiralWaveform.c -LALHybridTest_SOURCES = LALHybridTest.c -GenerateInspiralWaveform_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -LALHybridTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la - -INCLUDES = -I$(top_builddir)/include -I$(srcdir)/../include -TESTS = GenerateInspiralWaveform -EXTRA_DIST = LALHybridTest.c +TESTS = NoTest.sh +EXTRA_DIST = \ + NoTest.sh \ + ChirpSpace.c \ + GenerateInspiralWaveform.c \ + LALHybridTest.c \ + LALInspiralSpinningBHBinariesTest.c \ + LALInspiralTest.c \ + LALSTPNWaveformTest.c \ + TestRingdown.c TESTS_ENVIRONMENT = 1>/dev/null 2>/dev/null MOSTLYCLEANFILES = .dvi-dep -CLEANFILES = *.dat -DISTCLEANFILES = *.tex dvi-local: .dvi-dep - @DVIMKFILE@ diff --git a/lal/packages/noisemodels/src/LALInspiralFindEvents.c b/lal/packages/noisemodels/src/LALInspiralFindEvents.c index 3a8118d11b35e67a9c808b8078dc6331e4160714..f50147212805e5c16c38a7f67dd01efbd2054e49 100644 --- a/lal/packages/noisemodels/src/LALInspiralFindEvents.c +++ b/lal/packages/noisemodels/src/LALInspiralFindEvents.c @@ -174,10 +174,10 @@ LALInspiralFindEvents for (i=0;i<(INT4)output1.length;i++) printf("%e %e\n", i*dt, output2.data[i]);printf("&\n"); } - LALREAL4VectorFFT(status->statusPtr, &filter1, &output1, findeventsin->fwdp); - CHECKSTATUSPTR(status); - LALREAL4VectorFFT(status->statusPtr, &filter2, &output2, findeventsin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter1, &output1, findeventsin->fwdp) != 0) + ABORTXLAL(status); + if (XLALREAL4VectorFFT(&filter2, &output2, findeventsin->fwdp) != 0) + ABORTXLAL(status); LALInspiralWaveNormalise(status->statusPtr, &filter1, &norm, findeventsin->psd); CHECKSTATUSPTR(status); LALInspiralWaveNormalise(status->statusPtr, &filter2, &norm, findeventsin->psd); diff --git a/lal/packages/noisemodels/src/LALInspiralFindEventsCluster.c b/lal/packages/noisemodels/src/LALInspiralFindEventsCluster.c index 187a6971adebcfc37f283e70f5c6f33dede12b14..832f0ef5e282da86bae8377e4540e3af90a4e6d7 100644 --- a/lal/packages/noisemodels/src/LALInspiralFindEventsCluster.c +++ b/lal/packages/noisemodels/src/LALInspiralFindEventsCluster.c @@ -207,11 +207,11 @@ LALInspiralFindEventsCluster printf("%e %e\n", i*dt, output2.data[i]);printf("&\n"); */ } - LALREAL4VectorFFT(status->statusPtr, &filter1, &output1, findeventsin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter1, &output1, findeventsin->fwdp) != 0) + ABORTXLAL(status); /* - LALREAL4VectorFFT(status->statusPtr, &filter2, &output2, findeventsin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter2, &output2, findeventsin->fwdp) != 0) + ABORTXLAL(status); */ normin.psd = &(findeventsin->psd); normin.df = df; diff --git a/lal/packages/noisemodels/src/LALInspiralFindLoudestEvent.c b/lal/packages/noisemodels/src/LALInspiralFindLoudestEvent.c index 05af2bec26665465da6772c05ad12daa0c41de67..74098f9dd2256e1ba2929f55d6a89c73134bd768 100644 --- a/lal/packages/noisemodels/src/LALInspiralFindLoudestEvent.c +++ b/lal/packages/noisemodels/src/LALInspiralFindLoudestEvent.c @@ -198,10 +198,10 @@ LALInspiralFindLoudestEvent for (i=0;i<(INT4)output1.length;i++) printf("%e %e %e\n", i*dt, output1.data[i], output2.data[i]);printf("&\n"); } - LALREAL4VectorFFT(status->statusPtr, &filter1, &output1, findeventsin->fwdp); - CHECKSTATUSPTR(status); - LALREAL4VectorFFT(status->statusPtr, &filter2, &output2, findeventsin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter1, &output1, findeventsin->fwdp) != 0) + ABORTXLAL(status); + if (XLALREAL4VectorFFT(&filter2, &output2, findeventsin->fwdp) != 0) + ABORTXLAL(status); break; case TaylorF1: @@ -218,17 +218,17 @@ LALInspiralFindLoudestEvent if (findeventsin->displayTemplates) { - LALREAL4VectorFFT(status->statusPtr, &output1, &filter1, findeventsin->revp); - CHECKSTATUSPTR(status); - LALREAL4VectorFFT(status->statusPtr, &output2, &filter2, findeventsin->revp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&output1, &filter1, findeventsin->revp) != 0) + ABORTXLAL(status); + if (XLALREAL4VectorFFT(&output2, &filter2, findeventsin->revp) != 0) + ABORTXLAL(status); for (i=0;i<(INT4)output1.length;i++) printf("%e %e %e\n", i*dt, output1.data[i], output2.data[i]);printf("&\n"); - LALREAL4VectorFFT(status->statusPtr, &filter1, &output1, findeventsin->fwdp); - CHECKSTATUSPTR(status); - LALREAL4VectorFFT(status->statusPtr, &filter2, &output2, findeventsin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter1, &output1, findeventsin->fwdp) != 0) + ABORTXLAL(status); + if (XLALREAL4VectorFFT(&filter2, &output2, findeventsin->fwdp) != 0) + ABORTXLAL(status); } break; default: diff --git a/lal/packages/noisemodels/src/LALInspiralWaveCorrelate.c b/lal/packages/noisemodels/src/LALInspiralWaveCorrelate.c index fd4ee122907fafc14865d622f15ff1e727ad9225..5e5174e072dfb01f6548d04dcacbf004aca4d005 100644 --- a/lal/packages/noisemodels/src/LALInspiralWaveCorrelate.c +++ b/lal/packages/noisemodels/src/LALInspiralWaveCorrelate.c @@ -172,8 +172,8 @@ LALInspiralWaveCorrelate buff.data[nby2] = 0; } - LALREAL4VectorFFT(status->statusPtr,output,&buff,corrin.revp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(output,&buff,corrin.revp) != 0) + ABORTXLAL(status); for (i=0; i<n; i++) output->data[i] /= ((double) n * corrin.samplingRate); diff --git a/lal/packages/noisemodels/src/LALInspiralWaveOverlap.c b/lal/packages/noisemodels/src/LALInspiralWaveOverlap.c index 7b1cdd5cf922a449463e9f2eee4fa8252df702dc..8a58bfb3d9d1b381fabd940502368a90210ebf2f 100644 --- a/lal/packages/noisemodels/src/LALInspiralWaveOverlap.c +++ b/lal/packages/noisemodels/src/LALInspiralWaveOverlap.c @@ -136,8 +136,8 @@ LALInspiralWaveOverlap * When the approximant is AmpCorPPN, TaylorT1, TaylorT2, TaylorT3, PadeT1 or EOB * (time domain waveform) generate the template and take its FT */ - LALREAL4VectorFFT(status->statusPtr, &filter1, &output1, overlapin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter1, &output1, overlapin->fwdp)!= 0) + ABORTXLAL(status); break; case Eccentricity: @@ -146,8 +146,8 @@ LALInspiralWaveOverlap * starting phase*/ LALInspiralWave(status->statusPtr, &output1, &overlapin->param); CHECKSTATUSPTR(status); - LALREAL4VectorFFT(status->statusPtr, &filter1, &output1, overlapin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter1, &output1, overlapin->fwdp) != 0) + ABORTXLAL(status); break; /* commented section to inject a particular waveform containing a combinaison * of F+, Fx, h+ and hx, not just F+h+ @@ -167,8 +167,8 @@ LALInspiralWaveOverlap output1.data[kk] = output1.data[kk]*fp + output2.data[kk]*fc; } } - LALREAL4VectorFFT(status->statusPtr, &filter1, &output1, overlapin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter1, &output1, overlapin->fwdp) != 0) + ABORTXLAL(status);; break; #endif @@ -191,10 +191,10 @@ LALInspiralWaveOverlap /* print out for debugging for (i=0; i<output1.length; i++) printf("%d %e %e\n", i, output1.data[i], output2.data[i]); - LALREAL4VectorFFT(status->statusPtr, &filter1, &output1, overlapin->fwdp); - CHECKSTATUSPTR(status); - LALREAL4VectorFFT(status->statusPtr, &filter2, &output2, overlapin->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&filter1, &output1, overlapin->fwdp) != 0) + ABORTXLAL(status); + if (XLALREAL4VectorFFT(&filter2, &output2, overlapin->fwdp) != 0) + ABORTXLAL(status); */ break; default: diff --git a/lal/packages/noisemodels/src/LALLIGOIPsd.c b/lal/packages/noisemodels/src/LALLIGOIPsd.c index 07d9bc93cdf09dacadd5f095a549f9ca06021f16..20c217760e63849c9a6eff05d7fc827187ca7d49 100644 --- a/lal/packages/noisemodels/src/LALLIGOIPsd.c +++ b/lal/packages/noisemodels/src/LALLIGOIPsd.c @@ -42,6 +42,10 @@ NRCSID (LALLIGOIPSDC,"$Id$"); * \right)^{-56} + 0.16 \left( \frac{f}{f_0} \right)^{-4.52} + 0.52 + 0.32 * \left( \frac{f}{f_0} \right)^2 \right] * \end{equation} + * + * Multiply the return value of this function by 2 \Delta f to put it in + * the same units as used by the LAL average spectrum functions like + * XLALWhitenCOMPLEX16FrequencySeries(). */ diff --git a/lal/packages/noisemodels/src/LALRandomInspiralSignal.c b/lal/packages/noisemodels/src/LALRandomInspiralSignal.c index 23f61055a2428a3c2c914c66ab114d152a380dc0..97d4c5fbf952337835be61f9e33af52a7300b2fc 100644 --- a/lal/packages/noisemodels/src/LALRandomInspiralSignal.c +++ b/lal/packages/noisemodels/src/LALRandomInspiralSignal.c @@ -586,8 +586,8 @@ void LALRandomInspiralSignal /* Once the time domain waveform has been generated, take its * Fourier transform [i.e buff (t) ---> signal (f)]. */ - LALREAL4VectorFFT(status->statusPtr, signalvec, &buff, randIn->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(signalvec, &buff, randIn->fwdp) != 0) + ABORTXLAL(status); } /* End of else if time domain waveform */ @@ -623,8 +623,8 @@ void LALRandomInspiralSignal CHECKSTATUSPTR(status); LALDestroyRandomParams(status->statusPtr, &randomparams); CHECKSTATUSPTR(status); - LALREAL4VectorFFT(status->statusPtr, signalvec, &buff, randIn->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(signalvec, &buff, randIn->fwdp) != 0) + ABORTXLAL(status); LALColoredNoise(status->statusPtr, signalvec, randIn->psd); CHECKSTATUSPTR(status); @@ -654,8 +654,8 @@ void LALRandomInspiralSignal CHECKSTATUSPTR(status); LALDestroyRandomParams(status->statusPtr, &randomparams); CHECKSTATUSPTR(status); - LALREAL4VectorFFT(status->statusPtr, &noisy, &buff, randIn->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&noisy, &buff, randIn->fwdp) != 0) + ABORTXLAL(status); LALColoredNoise(status->statusPtr, &noisy, randIn->psd); CHECKSTATUSPTR(status); @@ -676,8 +676,8 @@ void LALRandomInspiralSignal /* Now convert from time domain signal(t) ---> frequency * domain waveform buff(f) i.e signal(t) -> buff(f)*/ - LALREAL4VectorFFT(status->statusPtr, &buff, signalvec, randIn->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4VectorFFT(&buff, signalvec, randIn->fwdp) != 0) + ABORTXLAL(status); } diff --git a/lal/packages/noisemodels/src/LALTruncateInvSpectrum.c b/lal/packages/noisemodels/src/LALTruncateInvSpectrum.c index 86711548e33b22038125f90c959c344eb0c2a11d..57da1f397e9cbf582b3fe498fe79f86da302474f 100644 --- a/lal/packages/noisemodels/src/LALTruncateInvSpectrum.c +++ b/lal/packages/noisemodels/src/LALTruncateInvSpectrum.c @@ -96,8 +96,8 @@ void LALTruncateInvSpectrum( /* Inverse Fourier Transform to time domain */ - LALReverseRealFFT (status->statusPtr, hvec, Hvec, params->revp); - CHECKSTATUSPTR(status); + if (XLALREAL4ReverseFFT(hvec, Hvec, params->revp) != 0) + ABORTXLAL(status); /* ---- If debugging then print the spectrum in time domain after its inverse Fourier transform --- */ @@ -137,8 +137,8 @@ void LALTruncateInvSpectrum( /* transform to frequency domain */ - LALForwardRealFFT (status->statusPtr, Hvec, hvec, params->fwdp); - CHECKSTATUSPTR(status); + if (XLALREAL4ForwardFFT(Hvec, hvec, params->fwdp) != 0) + ABORTXLAL(status); /* normalise fourier transform and square */ diff --git a/lal/packages/pulsar/include/ComputeFstat.h b/lal/packages/pulsar/include/ComputeFstat.h index 33ddd8428b3046497ec0f5e659e222da3fc470f5..dcd52afa8ead515834fa3544684fd9a3a4286b72 100644 --- a/lal/packages/pulsar/include/ComputeFstat.h +++ b/lal/packages/pulsar/include/ComputeFstat.h @@ -299,7 +299,7 @@ void ComputeFStat ( LALStatus *, Fcomponents *Fstat, ComputeFBuffer *cfBuffer ); void ComputeFStatFreqBand ( LALStatus *status, - REAL8FrequencySeries *FstatVector, + REAL4FrequencySeries *FstatVector, const PulsarDopplerParams *doppler, const MultiSFTVector *multiSFTs, const MultiNoiseWeights *multiWeights, diff --git a/lal/packages/pulsar/include/DetectorStates.h b/lal/packages/pulsar/include/DetectorStates.h index 4a0bf69f38889e23b35a1b198e07e880b7c09203..94056c3ead085793778cb78e663e11508aeea71a 100644 --- a/lal/packages/pulsar/include/DetectorStates.h +++ b/lal/packages/pulsar/include/DetectorStates.h @@ -73,6 +73,17 @@ typedef struct REAL4 d33; } SymmTensor3; + +/** A symmetric 3x3 tensor (such as detector-tensors), storing only the upper triangle, using REAL8 precision + */ +typedef struct +{ + REAL8 d11; REAL8 d12; REAL8 d13; + REAL8 d22; REAL8 d23; + REAL8 d33; +} SymmTensor3d; + + /** Struct containing pre-computed quantites describing a * single detector arm: unit-vector along detector-arm, arm-length, * and arm "basis-tensor" n x n. This is used to speed up the diff --git a/lal/packages/pulsar/include/LALBarycenter.h b/lal/packages/pulsar/include/LALBarycenter.h index 68bcae367520374bdb69359c2e600e2134332ce6..a8ef7d13cff887a0c2e929c1165af927155848c5 100644 --- a/lal/packages/pulsar/include/LALBarycenter.h +++ b/lal/packages/pulsar/include/LALBarycenter.h @@ -133,12 +133,6 @@ time intervals. The fields are the two files containing positions of Earth and Sun, resp., at evenly spaced times. -\item[\texttt{INT2 leap}] The number of leap seconds that have -been inserted into UTC between Jan. 6, 1980 (= start of GPS calendar) -and the current time tgps. But it's perfectly OK to approximate this by -number of leap sec inserted between Jan. 6, 1980 and Jan. 2 of year covered by -this ephemeris file; e.g. leap = 13 for year 2000. - \item[\texttt{INT4 nentriesE}] The number of entries in Earth ephemeris table. @@ -270,11 +264,6 @@ typedef struct { EphemerisFilenames ephiles; /**< Names of the two files containing positions of * Earth and Sun, respectively at evenly spaced times. */ - INT2 leap; /**< The number of leap seconds that have - * been inserted into UTC between Jan 6, 1980 (= start of GPS calendar) - * and the current time tgps. But its perfectly OK to approximate this by - * number of leap sec inserted between Jan 6, 1980 and Jan 2 of year - * covered by this ephemeris file; eg leap = 13 for year 2000. */ INT4 nentriesE; /**< The number of entries in Earth ephemeris table. */ INT4 nentriesS; /**< The number of entries in Sun ephemeris table. */ REAL8 dtEtable; /**< The spacing in sec between consecutive intants in Earth ephemeris table.*/ diff --git a/lal/packages/pulsar/include/LALComputeAM.h b/lal/packages/pulsar/include/LALComputeAM.h index 675439163b8b73b608c7fe74aa4e90c4ec5e4eaf..17f851c1c6f6eb91222436d622242d43bcaccbd1 100755 --- a/lal/packages/pulsar/include/LALComputeAM.h +++ b/lal/packages/pulsar/include/LALComputeAM.h @@ -126,7 +126,6 @@ struct AMCoeffsParams \item[\texttt{LALDetAndSource *das}] Detector and source information \item[\texttt{LALFrDetector}] Detector geometry information \item[\texttt{REAL4 polAngle}] Polarization angle -\item[\texttt{LALLeapSecAccuracy leapAcc}] Leap sec accuracy \end{description} </lalLaTeX> */ @@ -154,7 +153,6 @@ typedef struct AMCoeffsParamsTag LALDetAndSource *das; /**< det and source information */ LALFrDetector *det; /**< detector geometry */ REAL4 polAngle; /**< polarization angle */ - LALLeapSecAccuracy leapAcc; /**< accuracy in def of leap sec */ } AMCoeffsParams; diff --git a/lal/packages/pulsar/include/LALDemod.h b/lal/packages/pulsar/include/LALDemod.h index 10124f0bf1dc4ee7c1f6bcc8a04adce6efa7e6b5..69421f4cf4134439fd04a894993a8dd5ff3a8fdd 100644 --- a/lal/packages/pulsar/include/LALDemod.h +++ b/lal/packages/pulsar/include/LALDemod.h @@ -212,11 +212,6 @@ typedef struct FFTTag void LALDemod (LALStatus *status, LALFstat *Fstat, FFT **input, DemodPar *params); void LALDemodFAST (LALStatus *status, LALFstat *Fstat, FFT **input, DemodPar *params); - -/* <lalLaTeX> -\newpage\input{LALDemodTestC} -</lalLaTeX> */ - #ifdef __cplusplus } #endif diff --git a/lal/packages/pulsar/include/PulsarCrossCorr.h b/lal/packages/pulsar/include/PulsarCrossCorr.h index e1caad7dd86fcf99c6f4ea9c62199d34612722b6..e276ced8f37ad92e30f4f38fbff8434eabe313c3 100644 --- a/lal/packages/pulsar/include/PulsarCrossCorr.h +++ b/lal/packages/pulsar/include/PulsarCrossCorr.h @@ -213,7 +213,9 @@ void LALCalculateUalpha(LALStatus *status, CrossCorrBeamFn beamfnsI, CrossCorrBeamFn beamfnsJ, REAL8 sigmasq, - REAL8 *psi); + REAL8 *psi, + COMPLEX16 *gplus, + COMPLEX16 *gcross); void LALCalculateCrossCorrPower(LALStatus *status, REAL8 *out, @@ -225,6 +227,16 @@ void LALNormaliseCrossCorrPower(LALStatus *status, COMPLEX16Vector *ualpha, REAL8Vector *sigmaAlphasq); +void LALCalculateEstimators(LALStatus *status, + REAL8 *aplussq1, + REAL8 *aplussq2, + REAL8 *acrossq1, + REAL8 *acrossq2, + COMPLEX16Vector *yalpha, + COMPLEX16Vector *gplus, + COMPLEX16Vector *gcross, + REAL8Vector *sigmaAlphasq); + /* ****************************************************** */ #ifdef __cplusplus diff --git a/lal/packages/pulsar/include/SFTutils.h b/lal/packages/pulsar/include/SFTutils.h index 4753ef02b37ee851e4f37654a26be985551eae3b..7fa0ecfa27f6053903901ce80a563956cb8aa245 100644 --- a/lal/packages/pulsar/include/SFTutils.h +++ b/lal/packages/pulsar/include/SFTutils.h @@ -85,6 +85,12 @@ typedef struct { REAL8FrequencySeries *data; } REAL8FrequencySeriesVector; +/** A vector of REAL4FrequencySeries */ +typedef struct { + UINT4 length; + REAL4FrequencySeries *data; +} REAL4FrequencySeriesVector; + /** A so-called 'SFT' (short-Fourier-transform) will be stored in a COMPLEX8FrequencySeries */ typedef COMPLEX8FrequencySeries SFTtype; @@ -156,13 +162,16 @@ void LALCreateSFTVector (LALStatus *status, SFTVector **sftvect, UINT4 numSFTs, void LALCreateMultiSFTVector ( LALStatus *status, MultiSFTVector **out, UINT4 length, UINT4Vector *numsft ); SFTVector* XLALCreateSFTVector (UINT4 numSFTs, UINT4 numBins ); +SFTtype* XLALCreateSFT ( UINT4 numBins ); + +void XLALDestroySFTVector (SFTVector *vect); +void XLALDestroySFT (SFTtype *sft); + COMPLEX8Vector *XLALrefineCOMPLEX8Vector (const COMPLEX8Vector *in, UINT4 refineby, UINT4 Dterms); void upsampleMultiSFTVector (LALStatus *, MultiSFTVector *inout, UINT4 upsample, UINT4 Dterms); void upsampleSFTVector (LALStatus *, SFTVector *inout, UINT4 upsample, UINT4 Dterms); -void XLALDestroySFTVector (SFTVector *vect); - void LALDestroySFTtype (LALStatus *status, SFTtype **sft); void LALDestroySFTVector (LALStatus *status, SFTVector **sftvect); void LALDestroyPSDVector (LALStatus *status, PSDVector **vect); diff --git a/lal/packages/pulsar/include/UniversalDopplerMetric.h b/lal/packages/pulsar/include/UniversalDopplerMetric.h index 66de4fc8c350854f921079c167ee0a9078935484..594be95a9443e09c97103c74ae5b8fe860743554 100644 --- a/lal/packages/pulsar/include/UniversalDopplerMetric.h +++ b/lal/packages/pulsar/include/UniversalDopplerMetric.h @@ -61,11 +61,27 @@ NRCSID( UNIVERSALDOPPLERMETRICH, "$Id$"); /*---------- exported types ----------*/ +typedef REAL8 vect2D_t[2]; /**< 2D vector */ +typedef REAL8 vect3D_t[3]; /**< 3D vector */ +typedef REAL8 mat33_t[3][3]; /**< 3x3 matrix, useful for spatial 3D vector operations */ + +/** variable-length list of 2D-vectors */ +typedef struct { + UINT4 length; /**< number of elements */ + vect2D_t *data; /**< array of 2D vectors */ +} vect2Dlist_t; + +/** variable-length list of 3D vectors */ +typedef struct { + UINT4 length; /**< number of elements */ + vect3D_t *data; /**< array of 3D vectors */ +} vect3Dlist_t; + /** Small Container to hold two 3D vectors: position and velocity */ typedef struct { - REAL8 pos[3]; - REAL8 vel[3]; + vect3D_t pos; + vect3D_t vel; } PosVel3D_t; @@ -81,9 +97,21 @@ typedef enum { DETMOTION_SPIN_PTOLEORBIT, /**< ptole-orbital motion (on a circle) + Earth spin */ DETMOTION_PTOLEORBIT, /**< pure "Ptolemaic" orbital motion, no Earth spin */ + DETMOTION_ORBIT_SPINZ, /**< orbital motion plus *only* z-component of Earth spin-motion wrt to ecliptic plane */ + DETMOTION_ORBIT_SPINXY, /**< orbital motion plus *only* x+y component of Earth spin-motion in the ecliptic */ + DETMOTION_LAST } DetectorMotionType; + +typedef enum { + METRIC_TYPE_PHASE = 0, /**< compute phase metric only */ + METRIC_TYPE_FSTAT = 1, /**< compute full F-metric only */ + METRIC_TYPE_ALL = 2, /**< compute both F-metric and phase-metric */ + METRIC_TYPE_LAST +} MetricType_t; + + /** Array of symbolic 'names' for various detector-motions */ #ifdef IN_UNIVERSALDOPPLERMETRICC @@ -95,6 +123,9 @@ const CHAR *DetectorMotionNames[] = { "spin+ptoleorbit", "ptoleorbit", + "orbit+spin_Z", + "orbit+spin_XY", + "NONE" }; #endif @@ -117,6 +148,23 @@ typedef enum { DOPPLERCOORD_F2DOT_NAT, /**< f2dot in "natural units": om2 = 2pi f2dot/3! * Tspan^3 */ DOPPLERCOORD_F3DOT_NAT, /**< f3dot in "natural units": om3 = 2pi f3dot/4! * Tspan^4 */ + DOPPLERCOORD_ALPHA_NAT, /**< right-ascencion (longitude) in 'natural units' dAlpha * (f * T / (Vorb/c) ) */ + DOPPLERCOORD_DELTA_NAT, /**< declination (latitude) in 'natural units' dDelta * (f * T / (Vorb/c) ) */ + + DOPPLERCOORD_NECL_X_NAT, /**< x-component of sky-position n in ECLIPTIC Cartesian coordinates (in natural units: 2pi*Rorb/c*f) */ + DOPPLERCOORD_NECL_Y_NAT, /**< y-component of sky-position n in ECLIPTIC Cartesian coordinates (in natural units: 2pi*Rorb/c*f) */ + + DOPPLERCOORD_N3X, /**< experimental: unconstrained sky-vector n3: ecliptic-x coordinate */ + DOPPLERCOORD_N3Y, /**< experimental: unconstrained sky-vector n3: ecliptic-y coordinate */ + DOPPLERCOORD_N3Z, /**< experimental: unconstrained sky-vector n3: ecliptic-z coordinate */ + + DOPPLERCOORD_NEQU_X_NAT, /**< x-component of sky-position n in EQUATORIAL Cartesian coordinates (in natural units: 2pi*Rorb/c*f) */ + DOPPLERCOORD_NEQU_Y_NAT, /**< y-component of sky-position n in EQUATORIAL Cartesian coordinates (in natural units: 2pi*Rorb/c*f) */ + + + DOPPLERCOORD_NEQU_X_GC, /**< Sky-position: n_x in EQUATORIAL Cartesian coordinates. Holding {nu, nu1, nu2, ... } constant */ + DOPPLERCOORD_NEQU_Y_GC, /**< Sky-position: n_y in EQUATORIAL Cartesian coordinates. Holding {nu, nu1, nu2, ... } constant" */ + DOPPLERCOORD_LAST } DopplerCoordinateID; @@ -139,6 +187,22 @@ const CHAR *DopplerCoordinateNames[] = { "f2dot_Nat", "f3dot_Nat", + "Alpha_Nat", + "Delta_Nat", + + "nEcl_x_Nat", + "nEcl_y_Nat", + + "n3_x", + "n3_y", + "n3_z", + + "nEqu_x_Nat", + "nEqu_y_Nat", + + "nEqu_x_GC", + "nEqu_y_GC", + "NONE" }; @@ -163,6 +227,23 @@ const CHAR *DopplerCoordinateNamesHelp[] = { "Same as f2dot, but in 'natural units': f2dot_Nat = 2 pi f2dot/3! Tspan^3 [Units:1]", "Same as f3dot, but in 'natural units': f3dot_Nat = 2 pi f3dot/4! Tspan^4 [Units:1]", + "Sky-position: Right-ascencion (longitude) in 'natural units' dAlpha * (f * T / (Vorb/c) )", + "Sky-position: Declination (longitude) in 'natural units' dDelta * (f * T / (Vorb/c) )", + + "Sky-position: x-component of sky-position vector n in ECLIPTIC Cartesian coordinates (in natural units: 2pi*Rorb/c*f). Holding fkdot const", + "Sky-position: y-component of sky-position vector n in ECLIPTIC Cartesian coordinates (in natural units: 2pi*Rorb/c*f). Holding fkdot const", + + "experimental: unconstrained sky-vector n3: ecliptic-x coordinate", + "experimental: unconstrained sky-vector n3: ecliptic-y coordinate", + "experimental: unconstrained sky-vector n3: ecliptic-z coordinate", + + "Sky-position: x-component of sky-position vector n in EQUATORIAL Cartesian coordinates (in natural units: 2pi*Rorb/c*f). Holding fkdot const", + "Sky-position: y-component of sky-position vector n in EQUATORIAL Cartesian coordinates (in natural units: 2pi*Rorb/c*f). Holding fkdoo const", + + "Sky-position: n_x in EQUATORIAL Cartesian coordinates. Holding {nu, nu1, nu2, ... } constant", + "Sky-position: n_y in EQUATORIAL Cartesian coordinates. Holding {nu, nu1, nu2, ... } constant", + + "NONE" }; #endif @@ -201,6 +282,9 @@ typedef struct MultiDetectorInfo detInfo; /**< detectors (and their noise-weights) to compute metric for */ PulsarParams signalParams; /**< parameter-space point to compute metric for (doppler + amplitudes) */ + INT4 projectCoord; /**< project metric onto subspace orthogonal to this axis (-1 = none, 0 = 1st coordinate, etc) */ + + MetricType_t metricType; /**< switch controlling which types of metric to compute: 0 = PhaseMetric g_ij, 1 = Fmetrics gF.., 2=BOTH */ } DopplerMetricParams; @@ -224,6 +308,7 @@ typedef struct gsl_matrix *a_b_i_j; /**< \f$ \langle a\,b \, \partial_i\phi \, \partial_j\phi \rangle \f$ */ gsl_matrix *b_b_i_j; /**< \f$ \langle b^2 \, \partial_i\phi \, \partial_j\phi \rangle \f$ */ + double maxrelerr; /**< estimate for largest relative error in metric component integrations */ } FmetricAtoms_t; @@ -235,12 +320,16 @@ typedef struct DopplerMetricParams meta; /**< "meta-info" describing/specifying the type of Doppler metric */ gsl_matrix *g_ij; /**< symmetric matrix holding the usual Phase-metric */ + double maxrelerr_gPh; /**< estimate for largest relative error in phase-metric component integrations */ gsl_matrix *gF_ij; /**< full F-statistic metric gF_ij, including antenna-pattern effects (see \ref Prix07) */ gsl_matrix *gFav_ij; /**< 'average' Fstat-metric */ gsl_matrix *m1_ij, *m2_ij, *m3_ij; /**< Fstat-metric sub components */ gsl_matrix *Fisher_ab; /**< Full 4+n dimensional Fisher matrix, ie amplitude + Doppler space */ + + double maxrelerr_gF; /**< estimate for largest relative error in Fmetric component integrations */ + REAL8 rho2; /**< signal SNR rho^2 = A^mu M_mu_nu A^nu */ } DopplerMetric; @@ -252,7 +341,8 @@ extern MultiDetectorInfo empty_MultiDetectorInfo; /*---------- exported prototypes [API] ----------*/ gsl_matrix * XLALDopplerPhaseMetric ( const DopplerMetricParams *metricParams, - const EphemerisData *edat + const EphemerisData *edat, + double *relerr_max ); DopplerMetric* @@ -275,6 +365,10 @@ XLALDetectorPosVel ( PosVel3D_t *pos_vel3D, DetectorMotionType special ); + +vect3Dlist_t * +XLALComputeOrbitalDerivatives ( UINT4 maxorder, const LIGOTimeGPS *tGPS, const EphemerisData *edat ); + int XLALAmplitudeParams2Vect ( PulsarAmplitudeVect *Amu, const PulsarAmplitudeParams *Amp ); @@ -294,6 +388,8 @@ const CHAR *XLALDopplerCoordinateHelp ( DopplerCoordinateID coordID ); CHAR *XLALDopplerCoordinateHelpAll ( void ); int XLALParseMultiDetectorInfo ( MultiDetectorInfo *detInfo, const LALStringVector *detNames, const LALStringVector *detWeights ); +// destructor for vect3Dlist_t type +void XLALDestroyVect3Dlist ( vect3Dlist_t *list ); #ifdef __cplusplus } diff --git a/lal/packages/pulsar/src/ComputeFstat.c b/lal/packages/pulsar/src/ComputeFstat.c index 5e6b94aa4cef6a2d2a7094d7aef97365f13f8cf6..19f9e3cae553ed81debead0c47916fb2ff72a040 100644 --- a/lal/packages/pulsar/src/ComputeFstat.c +++ b/lal/packages/pulsar/src/ComputeFstat.c @@ -100,6 +100,7 @@ const MultiAMCoeffs empty_MultiAMCoeffs; const Fcomponents empty_Fcomponents; const ComputeFParams empty_ComputeFParams; const ComputeFBuffer empty_ComputeFBuffer; +const EarthState empty_EarthState; static REAL8 p,q,r; /* binary time delay coefficients (need to be global so that the LAL root finding procedure can see them) */ @@ -118,7 +119,7 @@ int finite(double x); they must be correctly set outside this function. */ void ComputeFStatFreqBand ( LALStatus *status, - REAL8FrequencySeries *fstatVector, /**< [out] Vector of Fstat values */ + REAL4FrequencySeries *fstatVector, /**< [out] Vector of Fstat values */ const PulsarDopplerParams *doppler, /**< parameter-space point to compute F for */ const MultiSFTVector *multiSFTs, /**< normalized (by DOUBLE-sided Sn!) data-SFTs of all IFOs */ const MultiNoiseWeights *multiWeights, /**< noise-weights of all SFTs */ @@ -543,7 +544,7 @@ XLALComputeFaFb ( Fcomponents *FaFb, COMPLEX8 *Xalpha = SFT_al->data->data; /* pointer to current SFT-data */ COMPLEX8 *Xalpha_l; /* pointer to frequency-bin k in current SFT */ - REAL4 s_alpha, c_alpha; /* sin(2pi kappa_alpha) and (cos(2pi kappa_alpha)-1) */ + REAL4 s_alpha=0, c_alpha=0;/* sin(2pi kappa_alpha) and (cos(2pi kappa_alpha)-1) */ REAL4 realQ, imagQ; /* Re and Im of Q = e^{-i 2 pi lambda_alpha} */ REAL4 realXP, imagXP; /* Re/Im of sum_k X_ak * P_ak */ REAL4 realQXP, imagQXP; /* Re/Im of Q_alpha R_alpha */ @@ -798,7 +799,7 @@ XLALComputeFaFbCmplx ( Fcomponents *FaFb, COMPLEX8 *Xalpha = SFT_al->data->data; /* pointer to current SFT-data */ COMPLEX8 *Xalpha_l; /* pointer to frequency-bin k in current SFT */ - REAL4 s_alpha, c_alpha; /* sin(2pi kappa_alpha) and (cos(2pi kappa_alpha)-1) */ + REAL4 s_alpha=0, c_alpha=0;/* sin(2pi kappa_alpha) and (cos(2pi kappa_alpha)-1) */ REAL4 realQ, imagQ; /* Re and Im of Q = e^{-i 2 pi lambda_alpha} */ REAL4 realXP, imagXP; /* Re/Im of sum_k X_ak * P_ak */ REAL4 realQXP, imagQXP; /* Re/Im of Q_alpha R_alpha */ @@ -1426,10 +1427,9 @@ LALNewGetAMCoeffs(LALStatus *status, /** Compute single time-stamp antenna-pattern coefficients a(t), b(t) + * Note: this function uses REAL8 precision, so this can be used in + * high-precision integration of the F-metric * - * This is a simplified (ugly) wrapper to LALNewGetAMCoeffs() to allow the - * computing a single-timestamp antenna-pattern, without having to - * worry about the whole DetectorStateSeries complexity... */ int XLALComputeAntennaPatternCoeffs ( REAL8 *ai, /**< [out] antenna-pattern function a(t) */ @@ -1440,53 +1440,85 @@ XLALComputeAntennaPatternCoeffs ( REAL8 *ai, /**< [out] antenna-pattern fun const EphemerisData *edat /**< [in] ephemeris-data */ ) { - const CHAR *fn = "XLALComputeAntennaPatternCoeffs()"; + const CHAR *fn = __func__; - DetectorStateSeries *detState = NULL; LALStatus status = empty_status; - LIGOTimeGPSVector *oneStepSeries = NULL; - AMCoeffs amcoeffs = empty_AMCoeffs; + EarthState earth = empty_EarthState; if ( !ai || !bi || !skypos || !tGPS || !site || !edat) { XLAL_ERROR( fn, XLAL_EINVAL ); } - /* construct dummy 1-timestamp detector-state 'series' */ - if ( (oneStepSeries = XLALCreateTimestampVector ( 1 )) == NULL ) { - XLAL_ERROR_REAL8( fn, XLAL_ENOMEM ); + LALBarycenterEarth (&status, &earth, tGPS, edat ); + if ( status.statusCode ) { + XLALPrintError ("%s: Call to LALBarycenterEarth() failed. statusCode=%d\n", fn, status.statusCode ); + XLAL_ERROR( fn, XLAL_EFUNC ); } - oneStepSeries->data[0] = (*tGPS); - /* prepare antenna-pattern struct */ - if ( (amcoeffs.a = XLALCreateREAL4Vector ( 1 )) == NULL ) { - XLAL_ERROR_REAL8( fn, XLAL_ENOMEM ); - } - if ( (amcoeffs.b = XLALCreateREAL4Vector ( 1 )) == NULL ) { - XLAL_ERROR_REAL8( fn, XLAL_ENOMEM ); - } + /* ---------- compute the detector tensor ---------- */ + REAL8 sinG, cosG, sinGcosG, sinGsinG, cosGcosG; + SymmTensor3d detT; - LALGetDetectorStates (&status, &detState, oneStepSeries, site, edat, 0 ); - if ( status.statusCode != 0 ) { - XLALPrintError ( "%s: call to LALGetDetectorStates() failed!\n\n", fn); - XLAL_ERROR( fn, XLAL_EFUNC ); - } + sinG = sin ( earth.gmstRad ); + cosG = cos ( earth.gmstRad ); + + sinGsinG = sinG * sinG; + sinGcosG = sinG * cosG; + cosGcosG = cosG * cosG; + + detT.d11 = site->response[0][0] * cosGcosG + - 2 * site->response[0][1] * sinGcosG + + site->response[1][1] * sinGsinG; + detT.d22 = site->response[0][0] * sinGsinG + + 2 * site->response[0][1] * sinGcosG + + site->response[1][1] * cosGcosG; + detT.d12 = (site->response[0][0] - site->response[1][1]) * sinGcosG + + site->response[0][1] * (cosGcosG - sinGsinG); + detT.d13 = site->response[0][2] * cosG + - site->response[1][2] * sinG; + detT.d23 = site->response[0][2] * sinG + + site->response[1][2] * cosG; + detT.d33 = site->response[2][2]; + + + /*---------- We write components of xi and eta vectors in SSB-fixed coords */ + REAL8 delta, alpha; + REAL8 sin1delta, cos1delta; + REAL8 sin1alpha, cos1alpha; + + REAL8 xi1, xi2; + REAL8 eta1, eta2, eta3; - /* call antenna-pattern function to get a(tt), b(tt) */ - LALNewGetAMCoeffs (&status, &amcoeffs, detState, (*skypos) ); - if ( status.statusCode != 0 ) { - XLALPrintError ( "%s: call to LALNewGetAMCoeffs() failed!\n\n", fn); - XLAL_ERROR( fn, XLAL_EFUNC ); - } - (*ai) = amcoeffs.a->data[0]; - (*bi) = amcoeffs.b->data[0]; + alpha = skypos->longitude; + delta = skypos->latitude; + + sin1delta = sin(delta); + cos1delta = cos(delta); + + sin1alpha = sin(alpha); + cos1alpha = cos(alpha); + + xi1 = - sin1alpha; + xi2 = cos1alpha; + eta1 = sin1delta * cos1alpha; + eta2 = sin1delta * sin1alpha; + eta3 = - cos1delta; + + /*---------- Compute the a(t_i) and b(t_i) ---------- */ + (*ai) = detT.d11 * ( xi1 * xi1 - eta1 * eta1 ) + + 2 * detT.d12 * ( xi1*xi2 - eta1*eta2 ) + - 2 * detT.d13 * eta1 * eta3 + + detT.d22 * ( xi2*xi2 - eta2*eta2 ) + - 2 * detT.d23 * eta2 * eta3 + - detT.d33 * eta3*eta3; + + (*bi) = detT.d11 * 2 * xi1 * eta1 + + 2 * detT.d12 * ( xi1 * eta2 + xi2 * eta1 ) + + 2 * detT.d13 * xi1 * eta3 + + detT.d22 * 2 * xi2 * eta2 + + 2 * detT.d23 * xi2 * eta3; - /* free memory */ - XLALDestroyREAL4Vector ( amcoeffs.a ); - XLALDestroyREAL4Vector ( amcoeffs.b ); - XLALDestroyTimestampVector ( oneStepSeries ); - oneStepSeries = NULL; - XLALDestroyDetectorStateSeries ( detState ); return XLAL_SUCCESS; @@ -1715,7 +1747,7 @@ LALGetMultiBinarytimes (LALStatus *status, /** For a given DetectorStateSeries, calculate the time-differences * \f$\Delta T_\alpha\equiv T(t_\alpha) - T_0\f$, and their - * derivatives \f$Tdot_\alpha \equiv d T / d t (t_\alpha)\f$. + * derivatives \f$\dot{T}_\alpha \equiv d T / d t (t_\alpha)\f$. * * \note The return-vectors \a DeltaT and \a Tdot must be allocated already * and have the same length as the input time-series \a DetStates. @@ -2153,7 +2185,7 @@ XLALWeighMultiAMCoeffs ( MultiAMCoeffs *multiAMcoef, const MultiNoiseWeights *m for(alpha = 0; alpha < numSteps; alpha++) { REAL8 ahat = amcoeX->a->data[alpha] ; - REAL8 bhat = amcoeX->b->data[alpha] ; + REAL8 bhat = amcoeX->b->data[alpha] ; /* sum A, B, C on the fly */ Ad += ahat * ahat; diff --git a/lal/packages/pulsar/src/FlatPulsarMetric.c b/lal/packages/pulsar/src/FlatPulsarMetric.c index dc0fcebc2858b58512b019df9b2f9d5ba79a3999..059d9d1c2f37c4c249a684862e526958678b035e 100644 --- a/lal/packages/pulsar/src/FlatPulsarMetric.c +++ b/lal/packages/pulsar/src/FlatPulsarMetric.c @@ -169,16 +169,8 @@ Phi_i ( double tt, void *params ) REAL8 ti = par->startTime + tt * par->Tspan; REAL8 sineps, coseps; - if ( par->edat->leap < 0 ) /* used to communicate coordinate-system of ephemeris-file */ - { - sineps = 0; /* LISA: ephemeris is using ECLIPTIC coords */ - coseps = 1; - } - else - { - sineps = SIN_EPS; /* non-LISA: earth ephemeris is using EQUATORIAL coords */ - coseps = COS_EPS; - } + sineps = SIN_EPS; /* non-LISA: earth ephemeris is using EQUATORIAL coords */ + coseps = COS_EPS; if ( par->comp < 0 ) /* rX, rY */ { diff --git a/lal/packages/pulsar/src/GetEarthTimes.c b/lal/packages/pulsar/src/GetEarthTimes.c index 3d50fc36da264c931ff512f04f38407bcf10fa50..0ee8b4fc35b584916866168c812b200520c02766 100644 --- a/lal/packages/pulsar/src/GetEarthTimes.c +++ b/lal/packages/pulsar/src/GetEarthTimes.c @@ -73,7 +73,7 @@ the \verb@REAL8@ time variables may suffer loss of precision. \subsubsection*{Uses} \begin{verbatim} -LALGPStoGMST1() +XLALGreenwichMeanSiderealTime() \end{verbatim} \subsubsection*{Notes} @@ -83,6 +83,8 @@ LALGPStoGMST1() ******************************************************* </lalLaTeX> */ #include <math.h> +#include <lal/LALErrno.h> +#include <lal/XLALError.h> #include <lal/LALStdlib.h> #include <lal/LALConstants.h> #include <lal/Date.h> @@ -108,7 +110,6 @@ LALGetEarthTimes( LALStatus *stat, PulsarTimesParamStruc *times ) { /* </lalVerbatim> */ LIGOTimeGPS epoch; /* local copy of times->epoch */ REAL8 t; /* time as a floating-point number (s) */ - LALMSTUnitsAndAcc p; /* parameter to LALGPStoGMST() */ INITSTATUS( stat, "GetEarthTimes", GETEARTHTIMESC ); ATTATCHSTATUSPTR( stat ); @@ -118,9 +119,8 @@ LALGetEarthTimes( LALStatus *stat, PulsarTimesParamStruc *times ) epoch = times->epoch; /* Find the next sidereal midnight. */ - p.units = MST_SEC; - p.accuracy = LALLEAPSEC_LOOSE; - TRY( LALGPStoGMST1( stat->statusPtr, &t, &epoch, &p ), stat ); + t = fmod(XLALGreenwichMeanSiderealTime(&epoch), LAL_TWOPI) * 86400.0 / LAL_TWOPI; + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(t), stat, LAL_FAIL_ERR, LAL_FAIL_MSG ); times->tMidnight = 86400.0 - t; /* Find the next autumnal equinox. */ diff --git a/lal/packages/pulsar/src/LALBarycenter.c b/lal/packages/pulsar/src/LALBarycenter.c index 52162c4345dffdaa60dd51dc6f248a46ff1f0828..9de12d8ad5afd3879af655cb585ca9d66355434c 100644 --- a/lal/packages/pulsar/src/LALBarycenter.c +++ b/lal/packages/pulsar/src/LALBarycenter.c @@ -88,6 +88,7 @@ by Cutler in Los Alamos preprint archive. </lalLaTeX> */ +#include <lal/Date.h> #include <lal/LALBarycenter.h> NRCSID(LALBARYCENTERC, "$Id$"); @@ -225,7 +226,14 @@ LALBarycenterEarth(LALStatus *stat, REAL8 eps0= 0.40909280422232891e0;/*obliquity of ecliptic at JD 245145.0*/ leapsSince2000 = 0; /*right # for Jan. 1, 2000 */ - leapsSince2000 = edat->leap - 13; + leapsSince2000 = XLALGPSLeapSeconds( tGPS->gpsSeconds ) - 13; + { + INT4 err = xlalErrno; + if ( err != XLAL_SUCCESS ) { + ABORT ( stat, err, "XLALGPSLeapSeconds() failed!\n"); + } + } + tuInt=tGPS->gpsSeconds -630720013; /*first subtract off value of gps clock at Jan 1, 2000 00:00:00 UTC */ diff --git a/lal/packages/pulsar/src/LALComputeAM.c b/lal/packages/pulsar/src/LALComputeAM.c index abf5bcd8e5352753abb35f2312efcd942e4e35a4..850de50c65d7755584ea6804812a7768f8af4a0e 100644 --- a/lal/packages/pulsar/src/LALComputeAM.c +++ b/lal/packages/pulsar/src/LALComputeAM.c @@ -119,9 +119,6 @@ void LALComputeAM (LALStatus *status, cos2psi = cos(2.0 * params->polAngle); sin2psi = sin(2.0 * params->polAngle); - - timeAndAcc.accuracy=params->leapAcc; - /* Note the length is the same for the b vector */ for(i=0; i<length; ++i) { diff --git a/lal/packages/pulsar/src/PulsarCatInput.c b/lal/packages/pulsar/src/PulsarCatInput.c index 6945befd28af81545ee82e9deb4be3156c4e2982..63373cbd9467fae3613efe18ffa636dff5002d90 100644 --- a/lal/packages/pulsar/src/PulsarCatInput.c +++ b/lal/packages/pulsar/src/PulsarCatInput.c @@ -103,7 +103,7 @@ measured. In most cases this means it will be treated as zero. \begin{verbatim} lalDebugLevel LALWarning() LALStringToU2() -LALLeapSecs() +XLALGPSLeapSeconds() LALDCreateVector() LALDDestroyVector() \end{verbatim} @@ -605,7 +605,6 @@ LALReadPulsarCatLine( LALStatus *stat, INT8 gpsNan; /* GPS nanoseconds */ INT4 leap1, leap2; /* number of leap seconds to date */ LIGOTimeGPS epoch; /* GPS epoch */ - LALLeapSecFormatAndAcc acc; /* accuracy of leap second computation */ /* Parse Julian date. */ TRY( LALParseREAL8( stat->statusPtr, &jday, list->tokens[i], @@ -617,15 +616,12 @@ LALReadPulsarCatLine( LALStatus *stat, jday += 2.4e6; /* Convert Julian days to GPS nanoseconds. */ - acc.accuracy = LALLEAPSEC_STRICT; - acc.format = LALLEAPSEC_GPSUTC; gpsNan = (INT8)( ( jday - 2444244.5 )*(8.64e13L) ); XLALINT8NSToGPS( &epoch, gpsNan ); leap2 = 0; do { leap1 = leap2; - TRY( LALLeapSecs( stat->statusPtr, &leap2, &epoch, &acc ), - stat ); + leap2 = XLALGPSLeapSeconds ( epoch.gpsSeconds ); epoch.gpsSeconds += leap2 - leap1; } while ( leap2 != leap1 ); node->posepoch = epoch; @@ -734,7 +730,6 @@ LALReadPulsarCatLine( LALStatus *stat, INT8 gpsNan; /* GPS nanoseconds */ INT4 leap1, leap2; /* number of leap seconds to date */ LIGOTimeGPS epoch; /* GPS epoch */ - LALLeapSecFormatAndAcc acc; /* accuracy of leap second computation */ /* Parse Julian date. */ TRY( LALParseREAL8( stat->statusPtr, &jday, list->tokens[i], @@ -746,15 +741,12 @@ LALReadPulsarCatLine( LALStatus *stat, jday += 2.4e6; /* Convert Julian days to GPS nanoseconds. */ - acc.accuracy = LALLEAPSEC_STRICT; - acc.format = LALLEAPSEC_GPSUTC; gpsNan = (INT8)( ( jday - 2444244.5 )*(8.64e13L) ); XLALINT8NSToGPS( &epoch, gpsNan ); leap2 = 0; do { leap1 = leap2; - TRY( LALLeapSecs( stat->statusPtr, &leap2, &epoch, &acc ), - stat ); + leap2 = XLALGPSLeapSeconds ( epoch.gpsSeconds ); epoch.gpsSeconds += leap2 - leap1; } while ( leap2 != leap1 ); node->fepoch = epoch; diff --git a/lal/packages/pulsar/src/PulsarCrossCorr.c b/lal/packages/pulsar/src/PulsarCrossCorr.c index b1f56c59608d2909dd2e3de78f0a179de40e88c1..a0be86b5ed15189fac61f83fb3136c28240c2c48 100644 --- a/lal/packages/pulsar/src/PulsarCrossCorr.c +++ b/lal/packages/pulsar/src/PulsarCrossCorr.c @@ -37,7 +37,7 @@ RCSID( "$Id$"); - +/* this function is currently unused (20/07/09) */ void LALCreateSFTPairsIndicesFrom2SFTvectors(LALStatus *status, INT4VectorSequence **out, SFTListElement *in, @@ -211,6 +211,7 @@ void LALCorrelateSingleSFTPair(LALStatus *status, /** Calculate the frequency of the SFT at a given epoch */ +/* This is according to Eqns 2.11 and 2.12 of Dhurandhar et al 2008 */ void LALGetSignalFrequencyInSFT(LALStatus *status, REAL8 *out, LIGOTimeGPS *epoch, @@ -260,6 +261,8 @@ void LALGetSignalFrequencyInSFT(LALStatus *status, /** Get signal phase at a given epoch */ +/* This is according to Eqn 2.13 in Dhurandar et al 2008 */ +/* and includes the 2nd order term that is left out in the paper */ void LALGetSignalPhaseInSFT(LALStatus *status, REAL8 *out, LIGOTimeGPS *epoch, @@ -350,6 +353,8 @@ void LALCalculateSigmaAlphaSq(LALStatus *status, } /** Calculate pair weights (U_alpha) for an average over Psi and cos(iota) **/ +/* G_IJ is calculated according to Eqn 3.17 in Dhurandhar et al 2008 + * and Ualpha is calculated according to Eqn 4.10 of the same paper */ void LALCalculateAveUalpha(LALStatus *status, COMPLEX16 *out, REAL8 phiI, @@ -381,6 +386,10 @@ void LALCalculateAveUalpha(LALStatus *status, } /** Calculate pair weights (U_alpha) for the general case **/ +/* G_IJ is calculated according to Eqn 3.10 of Dhurandar et al 2008. + * deltaPhi is calculated from Eqn 3.11, and Ualpha is calculated according to + * Eqn 4.10 of the same paper. + * The Fplus, Fcross terms are calculated according to Eqns 2.9a and 2.9b */ void LALCalculateUalpha(LALStatus *status, COMPLEX16 *out, CrossCorrAmps amplitudes, @@ -389,7 +398,9 @@ void LALCalculateUalpha(LALStatus *status, CrossCorrBeamFn beamfnsI, CrossCorrBeamFn beamfnsJ, REAL8 sigmasq, - REAL8 *psi) + REAL8 *psi, + COMPLEX16 *gplus, + COMPLEX16 *gcross) { REAL8 deltaPhi; REAL8 re, im; @@ -418,6 +429,13 @@ void LALCalculateUalpha(LALStatus *status, - (sin(deltaPhi) * ((FplusI*FplusJ * amplitudes.Aplussq) + (FcrossI*FcrossJ * amplitudes.Acrosssq))) ); + /*calculate estimators*/ + gplus->re = 0.25*cos(deltaPhi)*FplusI*FplusJ; + gplus->im = 0.25*(-sin(deltaPhi))*FplusI*FplusJ; + + gcross->re = 0.25*cos(deltaPhi)*FcrossI*FcrossJ; + gcross->im = 0.25*(-sin(deltaPhi))*FcrossI*FcrossJ; + } else { @@ -438,6 +456,7 @@ void LALCalculateUalpha(LALStatus *status, } + /*calculate Ualpha*/ out->re = re/(sigmasq); out->im = -im/(sigmasq); @@ -451,7 +470,8 @@ void LALCalculateUalpha(LALStatus *status, } - +/* Calculate rho, the cross correlation power, + * according to Eqn 4.4 in Dhurandhar et al 2008 */ void LALCalculateCrossCorrPower(LALStatus *status, REAL8 *out, COMPLEX16Vector *yalpha, @@ -481,6 +501,8 @@ void LALCalculateCrossCorrPower(LALStatus *status, } +/* Calculate the variance of the cross correlation power. + * The variance is given by sigma^2 in Eqn 4.6 of Dhurandhar et al 2008 */ void LALNormaliseCrossCorrPower(LALStatus *status, REAL8 *out, COMPLEX16Vector *ualpha, @@ -512,4 +534,45 @@ void LALNormaliseCrossCorrPower(LALStatus *status, } +/* Calculate the estimators for Aplus, Asq. + * Eqn 6.4 of Dhurandhar et al 2008 */ +void LALCalculateEstimators(LALStatus *status, + REAL8 *aplussq1, + REAL8 *aplussq2, + REAL8 *acrossq1, + REAL8 *acrossq2, + COMPLEX16Vector *yalpha, + COMPLEX16Vector *gplus, + COMPLEX16Vector *gcross, + REAL8Vector *sigmaAlphasq) +{ + INT4 i; + REAL8 ap1 = 0, ap2 = 0, ac1 = 0, ac2 = 0; + + INITSTATUS (status, "CalculateEstimators", rcsid); + ATTATCHSTATUSPTR (status); + + ASSERT (aplussq1, status, PULSARCROSSCORR_ENULL, PULSARCROSSCORR_MSGENULL); + ASSERT (yalpha, status, PULSARCROSSCORR_ENULL, PULSARCROSSCORR_MSGENULL); + ASSERT (sigmaAlphasq, status, PULSARCROSSCORR_ENULL, PULSARCROSSCORR_MSGENULL); + + + for (i=0; i < (INT4)yalpha->length; i++) { + ap1 += 2.0*(SQUARE(gplus->data[i].re) + SQUARE(gplus->data[i].im))/sigmaAlphasq->data[i]; + ac1 += 2.0*(SQUARE(gcross->data[i].re) + SQUARE(gcross->data[i].im))/sigmaAlphasq->data[i]; + ap2 += 2.0*((yalpha->data[i].re * gplus->data[i].re) + (yalpha->data[i].im * gplus->data[i].im))/sigmaAlphasq->data[i]; + ac2 += 2.0*((yalpha->data[i].re * gcross->data[i].re) + (yalpha->data[i].im * gcross->data[i].im))/sigmaAlphasq->data[i]; + } + + *aplussq1 = ap1; + *aplussq2 = ap2; + *acrossq1 = ac1; + *acrossq2 = ac2; + DETATCHSTATUSPTR (status); + + /* normal exit */ + RETURN (status); + + +} diff --git a/lal/packages/pulsar/src/SFTutils.c b/lal/packages/pulsar/src/SFTutils.c index 9a507e7a47f0b712da4d75ddccca40411243f776..8649eeca332087175f69772f733383cc159d2e76 100644 --- a/lal/packages/pulsar/src/SFTutils.c +++ b/lal/packages/pulsar/src/SFTutils.c @@ -145,6 +145,54 @@ XLALExtractBandfromSFTs ( const SFTVector *sfts, REAL8 fMin, REAL8 fMax ) } /* XLALExtractBandfromSFTs() */ +/** XLAL function to create one SFT-struct. + * + * Note: Allows for numBins == 0, in which case only the header is + * allocated, with a NULL data pointer. + */ +SFTtype * +XLALCreateSFT ( UINT4 numBins ) +{ + const char *fn = "XLALCreateSFT()"; + SFTtype *sft; + + if ( (sft = XLALCalloc (1, sizeof(*sft) )) == NULL ) { + XLALPrintError ("%s: XLALCalloc (1, %d) failed.\n", fn, sizeof(*sft) ); + XLAL_ERROR_NULL ( fn, XLAL_ENOMEM ); + } + + if ( numBins ) + { + if ( (sft->data = XLALCreateCOMPLEX8Vector ( numBins )) == NULL ) { + XLALPrintError ("%s: XLALCreateCOMPLEX8Vector ( %s ) failed. xlalErrno = %d\n", fn, numBins, xlalErrno ); + XLALFree ( sft ); + XLAL_ERROR_NULL ( fn, XLAL_ENOMEM ); + } + } + else + sft->data = NULL; /* no data, just header */ + + return sft; + +} /* XLALCreateSFT() */ + + +void +XLALDestroySFT ( SFTtype *sft ) +{ + if ( !sft ) + return; + + if ( sft->data ) + XLALDestroyCOMPLEX8Vector ( sft->data ); + + XLALFree ( sft ); + + return; + +} /* XLALDestroySFT() */ + + /** Create one SFT-struct. Allows for numBins == 0. */ diff --git a/lal/packages/pulsar/src/UniversalDopplerMetric.c b/lal/packages/pulsar/src/UniversalDopplerMetric.c index c877639be4ae035d18cd7a8694ad426e05831ea4..76675662dc41026d067ea1876ac548ea3cae53a0 100644 --- a/lal/packages/pulsar/src/UniversalDopplerMetric.c +++ b/lal/packages/pulsar/src/UniversalDopplerMetric.c @@ -57,6 +57,9 @@ /** Simple Euklidean scalar product for two 3-dim vectors in cartesian coords */ #define SCALAR(u,v) ((u)[0]*(v)[0] + (u)[1]*(v)[1] + (u)[2]*(v)[2]) +#define MULT_VECT(v,lam) do{ (v)[0] *= (lam); (v)[1] *= (lam); (v)[2] *= (lam); } while(0) +#define ADD_VECT(dst,src) do { (dst)[0] += (src)[0]; (dst)[1] += (src)[1]; (dst)[2] += (src)[2]; } while(0) +#define SUB_VECT(dst,src) do { (dst)[0] -= (src)[0]; (dst)[1] -= (src)[1]; (dst)[2] -= (src)[2]; } while(0) #define SQUARE(x) ((x) * (x)) @@ -64,6 +67,13 @@ #define GPS2REAL8(gps) (1.0 * (gps).gpsSeconds + 1.e-9 * (gps).gpsNanoSeconds ) #define MYMAX(a,b) ( (a) > (b) ? (a) : (b) ) +#define MYMIN(a,b) ( (a) < (b) ? (a) : (b) ) + +/** 5-point derivative formulas (eg see http://math.fullerton.edu/mathews/articles/2003NumericalDiffFormulae.pdf) */ +#define DERIV5P_1(pm2,pm1,p0,pp1,pp2,h) ( ( (pm2) - 8.0 * (pm1) + 8.0 * (pp1) - (pp2)) / ( 12.0 * (h) ) ) +#define DERIV5P_2(pm2,pm1,p0,pp1,pp2,h) ( (-(pm2) + 16.0 * (pm1) - 30.0 * (p0) + 16.0 * (pp1) - (pp2) ) / ( 12.0 * (h) * (h) ) ) +#define DERIV5P_3(pm2,pm1,p0,pp1,pp2,h) ( (-(pm2) + 2.0 * (pm1) - 2.0 * (pp1) + (pp2) ) / ( 2.0 * (h) * (h) * (h) ) ) +#define DERIV5P_4(pm2,pm1,p0,pp1,pp2,h) ( ( (pm2) - 4.0 * (pm1) + 6.0 * (p0) - 4.0 * (pp1) + (pp2) ) / ( (h) * (h) * (h) * (h) ) ) /*----- SWITCHES -----*/ /*---------- internal types ----------*/ @@ -85,7 +95,8 @@ typedef struct DopplerCoordinateID deriv; /**< component for single phase-derivative Phi_i compute */ AM_comp_t amcomp1, amcomp2; /**< two AM components q_l q_m */ const PulsarDopplerParams *dopplerPoint;/**< Doppler params to compute metric for */ - REAL8 startTime; /**< GPS start time of observation (assumed == reference-time! */ + REAL8 startTime; /**< GPS start time of observation */ + REAL8 refTime; /**< GPS reference time for pulsar parameters */ REAL8 Tspan; /**< length of observation time in seconds */ const LALDetector *site; /**< detector site to compute metric for */ const EphemerisData *edat; /**< ephemeris data */ @@ -106,18 +117,31 @@ MultiDetectorInfo empty_MultiDetectorInfo; /*---------- Global variables ----------*/ NRCSID( UNIVERSALDOPPLERMETRICC, "$Id$"); +BOOLEAN outputIntegrand = 0; + +/* Some local constants. */ +#define rOrb_c (LAL_AU_SI / LAL_C_SI) +#define vOrb_c (LAL_TWOPI * LAL_AU_SI / LAL_C_SI / LAL_YRSID_SI) +// sin,cos(LAL_IEARTH); +#define cosiEcl 0.917482062157619 +#define siniEcl 0.397777155727931 + /*---------- internal prototypes ----------*/ DopplerMetric* XLALComputeFmetricFromAtoms ( const FmetricAtoms_t *atoms, REAL8 cosi, REAL8 psi ); gsl_matrix* XLALComputeFisherFromAtoms ( const FmetricAtoms_t *atoms, const PulsarAmplitudeParams *Amp ); double CW_am1_am2_Phi_i_Phi_j ( double tt, void *params ); -double XLALAverage_am1_am2_Phi_i_Phi_j ( const intparams_t *params ); - double CWPhaseDeriv_i ( double tt, void *params ); -double CWPhase_cov_Phi_ij ( const intparams_t *params ); +double XLALAverage_am1_am2_Phi_i_Phi_j ( const intparams_t *params, double *relerr_max ); +double CWPhase_cov_Phi_ij ( const intparams_t *params, double *relerr_max ); int XLALPtolemaicPosVel ( PosVel3D_t *posvel, const LIGOTimeGPS *tGPS ); +gsl_matrix *XLALProjectMetric ( const gsl_matrix * g_ij, const UINT4 c ); + +int equatorialVect2ecliptic ( vect3D_t *out, vect3D_t * const in ); +int eclipticVect2equatorial ( vect3D_t *out, vect3D_t * const in ); +int matrix33_in_vect3 ( vect3D_t *out, mat33_t * mat, vect3D_t * const in ); /*==================== FUNCTION DEFINITIONS ====================*/ @@ -129,35 +153,67 @@ int XLALPtolemaicPosVel ( PosVel3D_t *posvel, const LIGOTimeGPS *tGPS ); * The input parameters correspond to CW_am1_am2_Phi_i_Phi_j() */ double -XLALAverage_am1_am2_Phi_i_Phi_j ( const intparams_t *params ) +XLALAverage_am1_am2_Phi_i_Phi_j ( const intparams_t *params, double *relerr_max ) { const CHAR *fn = "XLALAverage_am1_am2_Phi_i_Phi_j()"; intparams_t par = (*params); /* struct-copy, as the 'deriv' field has to be changeable */ gsl_function integrand; - double epsrel = 2e-3; - /* NOTE: this level of accuracy has to be compatible with AM-coefficients involved + double epsrel = 1e-4; + /* NOTE: this level of accuracy should be compatible with AM-coefficients involved * which are computed in REAL4 precision. We therefor cannot go lower than this it seems, * otherwise the gsl-integration fails to converge in some cases. */ - double epsabs = 1e-5; /* we need an abs-cutoff as well, as epsrel can be too restrictive for small integrals */ - double abserr; + double epsabs = 0; size_t neval; - double ret; int stat; integrand.params = (void*)∥ /* compute <q_1 q_2 phi_i phi_j> as an integral from tt=0 to tt=1 */ + + /* NOTE: this numerical integration runs into problems when integrating over + * several days (~O(5d)), as the integrands are oscillatory functions on order of ~1/4d + * and convergence degrades. + * As a solution, we split the integral into N segments of 1/4 day duration, and compute + * the final integral as a sum over partial integrals + */ + REAL8 Tseg = 0.25 * LAL_DAYSID_SI; + UINT4 Nseg = (UINT4) ceil ( params->Tspan / Tseg ); + UINT4 n; + REAL8 dT = 1.0 / Nseg; + + REAL8 res = 0; + REAL8 abserr2 = 0; + integrand.function = &CW_am1_am2_Phi_i_Phi_j; - XLAL_CALLGSL ( stat = gsl_integration_qng (&integrand, 0, 1, epsabs, epsrel, &ret, &abserr, &neval) ); - if ( stat != 0 ) { - XLALPrintError ( "\n%s: GSL-integration 'gsl_integration_qng()' of <am1_am2_Phi_i Phi_j> failed! Result = %g, abserr=%g, neval=%d\n", - fn, ret, abserr, neval); - XLAL_ERROR_REAL8( fn, XLAL_EFUNC ); - } + for (n=0; n < Nseg; n ++ ) + { + REAL8 ti = 1.0 * n * dT; + REAL8 tf = MYMIN( (n+1.0) * dT, 1.0 ); + REAL8 err_n, res_n; - return ret; + XLAL_CALLGSL ( stat = gsl_integration_qng (&integrand, ti, tf, epsabs, epsrel, &res_n, &err_n, &neval) ); + /* NOTE: we don't fail if the requested level of accuracy was not reached, rather we only output a warning + * and try to estimate the final accuracy of the integral + */ + if ( stat != 0 ) + { + XLALPrintWarning ( "\n%s: GSL-integration 'gsl_integration_qng()' of <am1_am2_Phi_i Phi_j> did not reach requested precision!\n", fn ); + XLALPrintWarning ("Segment n=%d, neval=%d: Result = %g, abserr=%g ==> relerr = %.2e > %.2e\n", n, neval, res_n, err_n, fabs(err_n/res_n), epsrel); + /* XLAL_ERROR_REAL8( fn, XLAL_EFUNC ); */ + } + + res += res_n; + abserr2 += SQUARE ( err_n ); + + } /* for i < Nseg */ + + REAL8 relerr = sqrt(abserr2) / fabs(res); + if ( relerr_max ) + (*relerr_max) = relerr; + + return res; } /* XLALAverage_am1_am2_Phi_i_Phi_j() */ @@ -235,7 +291,14 @@ CW_am1_am2_Phi_i_Phi_j ( double tt, void *params ) phi_j = 1.0; ret = am1 * am2 * phi_i * phi_j; - /* printf ( "%f %f %f %f %f %f\n", tt, am1, am2, phi_i, phi_j, ret ); */ + + if ( outputIntegrand ) + { + printf ( "%d %d %d %d %f %f %f %f %f %f\n", + par->amcomp1, par->amcomp2, par->deriv1, par->deriv2, + tt, am1, am2, phi_i, phi_j, ret ); + } + return ( ret ); @@ -254,14 +317,15 @@ double CWPhaseDeriv_i ( double tt, void *params ) { const CHAR *fn = "CWPhaseDeriv_i()"; - REAL8 ret; + REAL8 ret = 0; intparams_t *par = (intparams_t*) params; - REAL8 nn[3]; /* skypos unit vector */ - REAL8 nDeriv_i[3]; /* derivative of sky-pos vector wrt i */ + vect3D_t nn_equ, nn_ecl; /* skypos unit vector */ + vect3D_t nDeriv_i; /* derivative of sky-pos vector wrt i */ PosVel3D_t posvel = empty_PosVel3D_t; - REAL8 ttSI, dTSI, dT, tauiSI; + vect3D_t detpos_ecl, detpos_equ; + REAL8 Freq = par->dopplerPoint->fkdot[0]; - LIGOTimeGPS ttGPS; + REAL8 Tspan = par->Tspan; static REAL8 kfactinv[] = { 1.0, 1.0/1.0, 1.0/2.0, 1.0/6.0, 1.0/24.0, 1.0/120.0 }; /* 1/k! */ /* get skypos-vector */ @@ -269,83 +333,166 @@ CWPhaseDeriv_i ( double tt, void *params ) REAL8 sina = sin(par->dopplerPoint->Alpha); REAL8 cosd = cos(par->dopplerPoint->Delta); REAL8 sind = sin(par->dopplerPoint->Delta); - - nn[0] = cosd * cosa; - nn[1] = cosd * sina; - nn[2] = sind; - - ttSI = par->startTime + tt * par->Tspan; /* current GPS time in seconds */ + /* ... in an equatorial coordinate-frame */ + nn_equ[0] = cosd * cosa; + nn_equ[1] = cosd * sina; + nn_equ[2] = sind; + + /* and in an ecliptic coordinate-frame */ + equatorialVect2ecliptic ( &nn_ecl, (vect3D_t * const )&nn_equ ); + + if ( abs(nn_ecl[2]) < 1e-6 ) /* avoid singularity at ecliptic equator */ + nn_ecl[2] = 1e-6; + + /* + vect3D_t nn_ecl0, nn_equ0; + printf ("equatorialVect2ecliptic(): nn_ecl0 = { %g, %g, %g}\n", nn_ecl0[0], nn_ecl0[1], nn_ecl0[2] ); + nn_ecl[0] = nn_equ[0]; + nn_ecl[1] = cosiEcl * nn_equ[1] + siniEcl * nn_equ[2]; + nn_ecl[2] = cosiEcl * nn_equ[2] - siniEcl * nn_equ[1]; + printf ("manual conversion : nn_ecl = { %g, %g, %g}\n", nn_ecl[0], nn_ecl[1], nn_ecl[2] ); + eclipticVect2equatorial ( nn_equ0, nn_ecl0 ); + printf ("eclipticVect2equatorial(): nn_equ0 = { %g, %g, %g}\n", nn_equ0[0], nn_equ0[1], nn_equ0[2] ); + printf ("original input : nn_equ = { %g, %g, %g}\n", nn_equ[0], nn_equ[1], nn_equ[2] ); + exit(0); + */ + + /* get current detector position r(t) */ + REAL8 ttSI = par->startTime + tt * Tspan; /* current GPS time in seconds */ + LIGOTimeGPS ttGPS; XLALGPSSetREAL8( &ttGPS, ttSI ); if ( XLALDetectorPosVel ( &posvel, &ttGPS, par->site, par->edat, par->detMotionType ) ) { XLALPrintError ( "%s: Call to XLALDetectorPosVel() failed!\n", fn); XLAL_ERROR( fn, XLAL_EFUNC ); } + COPY_VECT ( detpos_equ, posvel.pos ); + + /* convert detector position in ecliptic coordinates */ + equatorialVect2ecliptic ( &detpos_ecl, &detpos_equ ); + + + /* account for referenceTime != startTime */ + REAL8 tau0 = ( par->startTime - par->refTime ) / Tspan; /* correct for time-delay from SSB to detector, neglecting relativistic effects */ - dTSI = SCALAR(nn, posvel.pos ); - tauiSI = ttSI + dTSI; /* SSB time corresponding to tt, for this skyposition nn, in seconds */ - dT = dTSI / par->Tspan; /* SSB time-delay in 'natural units' */ + REAL8 dTRoemerSI = SCALAR(nn_equ, detpos_equ ); + REAL8 dTRoemer = dTRoemerSI / Tspan; /* SSB time-delay in 'natural units' */ + + /* barycentric time-delay since reference time, measured in units of Tspan */ + REAL8 tau = tau0 + tt + dTRoemer; + + REAL8 nNat = Freq * Tspan * 1e-4; /* 'natural sky-units': Freq * Tspan * V/c */ + + + /* get 'reduced' detector position of order 'n': r_n(t), + * defined as: r_n(t) = r(t) - dot{r_orb}(tau_ref) tau - 1/2! ddot{r_orb}(tau_re) tau^2 - .... + */ + vect3D_t rr_ord; + UINT4 order = 2; + vect3Dlist_t *rOrb_n; + if ( (rOrb_n = XLALComputeOrbitalDerivatives ( order, &par->dopplerPoint->refTime, par->edat )) == NULL ) { + XLALPrintError ("%s: XLALComputeOrbitalDerivatives() failed.\n", fn); + XLAL_ERROR( fn, XLAL_EFUNC ); + } + UINT4 i; + REAL8 tauSec = tau * Tspan; + for (i=0; i<3; i++) + rr_ord[i] = detpos_equ[i] - rOrb_n->data[1][i] * tauSec - 0.5 * rOrb_n->data[2][i] * tauSec * tauSec ; + + XLALDestroyVect3Dlist ( rOrb_n ); switch ( par->deriv ) { /* ----- sky derivatives ----- */ - case DOPPLERCOORD_ALPHA_RAD: /* longitude/right ascension/Delta in radians */ + case DOPPLERCOORD_ALPHA_RAD: /* longitude/right-ascension/Alpha in radians */ + case DOPPLERCOORD_ALPHA_NAT: /* longitude/right-ascension/Alpha in natural units */ nDeriv_i[0] = - cosd * sina; nDeriv_i[1] = cosd * cosa; nDeriv_i[2] = 0; ret = LAL_TWOPI * Freq * SCALAR(posvel.pos, nDeriv_i); /* dPhi/dAlpha = 2 pi f (r/c) . (dn/dAlpha) */ + if ( par->deriv == DOPPLERCOORD_ALPHA_NAT ) + ret *= nNat; break; - case DOPPLERCOORD_DELTA_RAD: /* latitude/declination/Alpha in radians */ + case DOPPLERCOORD_DELTA_RAD: /* latitude/declination/Delta in radians */ + case DOPPLERCOORD_DELTA_NAT: /* latitude/declination/Delta in natural units */ nDeriv_i[0] = - sind * cosa; nDeriv_i[1] = - sind * sina; nDeriv_i[2] = cosd; ret = LAL_TWOPI * Freq * SCALAR(posvel.pos, nDeriv_i); /* dPhi/dDelta = 2 pi f (r/c) . (dn/dDelta) */ + if ( par->deriv == DOPPLERCOORD_DELTA_NAT ) + ret *= nNat; break; - /* ----- frequency derivatives SI-units ----- */ - case DOPPLERCOORD_FREQ_SI: - ret = tt + dT; /* dPhi/dFreq = 2 * pi * tSSB_i */ - ret *= LAL_TWOPI * par->Tspan * kfactinv[1]; + case DOPPLERCOORD_NECL_X_NAT: + ret = ( detpos_ecl[0] - (nn_ecl[0]/nn_ecl[2]) * detpos_ecl[2] ) / rOrb_c; + break; + case DOPPLERCOORD_NECL_Y_NAT: + ret = ( detpos_ecl[1] - (nn_ecl[1]/nn_ecl[2]) * detpos_ecl[2] ) / rOrb_c; break; - case DOPPLERCOORD_F1DOT_SI: - ret = SQUARE( tt + dT ); /* dPhi/df1dot = 2pi * (tSSB_i)^2/2! */ - ret *= LAL_TWOPI * SQUARE(par->Tspan) * kfactinv[2]; + /* experimental 'global correlation' sky coordinate, if holding {nu, nu1, ...} fixed. + * Note: derivatives wrt to nu, nu1, ... are equivalent to f, fdot, ... + */ + case DOPPLERCOORD_NEQU_X_GC: + ret = ( rr_ord[0] - (nn_equ[0]/nn_equ[2]) * rr_ord[2] ) / rOrb_c; break; - case DOPPLERCOORD_F2DOT_SI: - ret = (tt+dT) * SQUARE( tt + dT ); /* dPhi/f2dot = 2pi * (tSSB_i)^3/3! */ - ret *= LAL_TWOPI * par->Tspan * SQUARE(par->Tspan) * kfactinv[3]; + case DOPPLERCOORD_NEQU_Y_GC: + ret = ( rr_ord[1] - (nn_equ[1]/nn_equ[2]) * rr_ord[2] ) / rOrb_c; break; + /* experimental: unconstrained skypos vector n3 */ + case DOPPLERCOORD_N3X: + ret = detpos_ecl[0] / rOrb_c; + break; + case DOPPLERCOORD_N3Y: + ret = detpos_ecl[1] / rOrb_c; + break; + case DOPPLERCOORD_N3Z: + ret = detpos_ecl[2] / rOrb_c; + break; - case DOPPLERCOORD_F3DOT_SI: - ret = SQUARE(tt+dT) * SQUARE( tt + dT ); /* dPhi/df3dot = 2pi * (tSSB_i)^4/4! */ - ret *= LAL_TWOPI * SQUARE(par->Tspan) * SQUARE(par->Tspan) * kfactinv[4]; + case DOPPLERCOORD_NEQU_X_NAT: + ret = ( detpos_equ[0] - (nn_equ[0]/nn_equ[2]) * detpos_equ[2] ) / rOrb_c; + break; + case DOPPLERCOORD_NEQU_Y_NAT: + ret = ( detpos_equ[1] - (nn_equ[1]/nn_equ[2]) * detpos_equ[2] ) / rOrb_c; break; - /* ----- frequency derivatives natural units ----- */ - case DOPPLERCOORD_FREQ_NAT: /* om0 = 2pi f T */ - ret = tt + dT; /* dPhi/dom0 = tau_i */ - break; - case DOPPLERCOORD_F1DOT_NAT: /* om1 = 2pi f/2! T^2 */ - ret = SQUARE( tt + dT ); /* dPhi/dom1 = tau_i^2 */ + /* ----- frequency derivatives SI-units ----- */ + case DOPPLERCOORD_FREQ_SI: + case DOPPLERCOORD_FREQ_NAT: /* om0 = 2pi f T */ + ret = tau; /* in natural units: dPhi/dom0 = tau */ + if ( par->deriv == DOPPLERCOORD_FREQ_SI ) + ret *= LAL_TWOPI * Tspan * kfactinv[1]; /* dPhi/dFreq = 2 * pi * tSSB_i */ break; - case DOPPLERCOORD_F2DOT_NAT: /* om2 = 2pi f/3! T^3 */ - ret = (tt+dT) * SQUARE( tt + dT ); /* dPhi/dom2 = tau_i^3 */ + case DOPPLERCOORD_F1DOT_SI: + case DOPPLERCOORD_F1DOT_NAT: /* om1 = 2pi f/2! T^2 */ + ret = tau * tau; /* in natural units: dPhi/dom1 = tau^2 */ + if ( par->deriv == DOPPLERCOORD_F1DOT_SI ) + ret *= LAL_TWOPI * (Tspan*Tspan) * kfactinv[2];/* dPhi/df1dot = 2pi * (tSSB_i)^2/2! */ break; - case DOPPLERCOORD_F3DOT_NAT: /* om3 = 2pi f/4! T^4 */ - ret = SQUARE(tt+dT) * SQUARE( tt + dT ); /* dPhi/dom3 = tau_i^4 */ + case DOPPLERCOORD_F2DOT_SI: + case DOPPLERCOORD_F2DOT_NAT: /* om2 = 2pi f/3! T^3 */ + ret = tau * tau * tau; /* in natural units: dPhi/dom2 = tau^3 */ + if ( par->deriv == DOPPLERCOORD_F2DOT_SI ) + ret *= LAL_TWOPI * (Tspan*Tspan*Tspan) * kfactinv[3];/* dPhi/f2dot = 2pi * (tSSB_i)^3/3! */ break; + case DOPPLERCOORD_F3DOT_SI: + case DOPPLERCOORD_F3DOT_NAT: /* om3 = 2pi f/4! T^4 */ + ret = tau * tau * tau * tau; /* in natural units: dPhi/dom3 = tau^4 */ + if ( par->deriv == DOPPLERCOORD_F3DOT_SI ) + ret *= LAL_TWOPI * (Tspan*Tspan*Tspan*Tspan) * kfactinv[4];/* dPhi/df3dot = 2pi * (tSSB_i)^4/4! */ + break; default: XLALPrintError("%s: Unknown phase-derivative type '%d'\n", fn, par->deriv ); @@ -365,7 +512,7 @@ CWPhaseDeriv_i ( double tt, void *params ) * */ int -XLALDetectorPosVel ( PosVel3D_t *posvel, /**< [out] instantaneous position and velocity vector */ +XLALDetectorPosVel ( PosVel3D_t *posvel, /**< [out] instantaneous position and velocity vector */ const LIGOTimeGPS *tGPS, /**< [in] GPS time */ const LALDetector *site, /**< [in] detector info */ const EphemerisData *edat, /**< [in] ephemeris data */ @@ -379,6 +526,8 @@ XLALDetectorPosVel ( PosVel3D_t *posvel, /**< [out] instantaneous position and EmissionTime emit = empty_EmissionTime; PosVel3D_t Det_wrt_Earth; PosVel3D_t PtoleOrbit; + PosVel3D_t Spin_z, Spin_xy; + REAL8 eZ[3]; if ( !posvel || !tGPS || !site || !edat ) { XLALPrintError ( "%s: Illegal NULL pointer passed!\n", fn); @@ -412,6 +561,23 @@ XLALDetectorPosVel ( PosVel3D_t *posvel, /**< [out] instantaneous position and Det_wrt_Earth.vel[1] = emit.vDetector[1] - earth.velNow[1]; Det_wrt_Earth.vel[2] = emit.vDetector[2] - earth.velNow[2]; + eZ[0] = 0; eZ[1] = -siniEcl; eZ[2] = cosiEcl; /* ecliptic z-axis in equatorial coordinates */ + /* compute ecliptic-z projected spin motion */ + REAL8 pz = SCALAR ( Det_wrt_Earth.pos, eZ ); + REAL8 vz = SCALAR ( Det_wrt_Earth.vel, eZ ); + + COPY_VECT ( Spin_z.pos, eZ ); + MULT_VECT ( Spin_z.pos, pz ); + + COPY_VECT ( Spin_z.vel, eZ ); + MULT_VECT ( Spin_z.vel, vz ); + + /* compute ecliptic-xy projected spin motion */ + COPY_VECT ( Spin_xy.pos, Det_wrt_Earth.pos ); + SUB_VECT ( Spin_xy.pos, Spin_z.pos ); + + COPY_VECT ( Spin_xy.vel, Det_wrt_Earth.vel ); + SUB_VECT ( Spin_xy.vel, Spin_z.vel ); /* ----- Ptolemaic special case: orbital motion on a circle */ if ( (special == DETMOTION_SPIN_PTOLEORBIT) || (special == DETMOTION_PTOLEORBIT) ) @@ -467,12 +633,44 @@ XLALDetectorPosVel ( PosVel3D_t *posvel, /**< [out] instantaneous position and */ break; + /**< orbital motion plus *only* z-component of Earth spin-motion wrt to ecliptic plane */ + case DETMOTION_ORBIT_SPINZ: + + COPY_VECT(posvel->pos, earth.posNow); + COPY_VECT(posvel->vel, earth.velNow); + + ADD_VECT ( posvel->pos, Spin_z.pos ); + ADD_VECT ( posvel->vel, Spin_z.vel ); + + break; + + /**< orbital motion plus *only* x+y component of Earth spin-motion in the ecliptic */ + case DETMOTION_ORBIT_SPINXY: + + COPY_VECT(posvel->pos, earth.posNow); + COPY_VECT(posvel->vel, earth.velNow); + + ADD_VECT ( posvel->pos, Spin_xy.pos ); + ADD_VECT ( posvel->vel, Spin_xy.vel ); + + break; + default: XLALPrintError("\n%s: Illegal 'special' value passed: '%d'\n\n", fn, special ); XLAL_ERROR( fn, XLAL_EINVAL ); break; } /* switch(special) */ + +#if 0 + /* debug output */ + printf ("%.6f %.16g %.16g %.16g %.16g %.16g %.16g \n", + GPS2REAL8((*tGPS)), + posvel->pos[0], posvel->pos[1], posvel->pos[2], + posvel->vel[0], posvel->vel[1], posvel->vel[2] ); + +#endif + return XLAL_SUCCESS; } /* XLALDetectorPosition() */ @@ -489,11 +687,6 @@ XLALPtolemaicPosVel ( PosVel3D_t *posvel, /**< [out] instantaneous position and { const CHAR *fn = "XLALPtolemaicPosVel()"; PulsarTimesParamStruc times = empty_PulsarTimesParamStruc; - /* Some local constants. */ - REAL8 rOrb_c = LAL_AU_SI / LAL_C_SI; - REAL8 vOrb_c = LAL_TWOPI * rOrb_c / LAL_YRSID_SI; - REAL8 cosi = cos(LAL_IEARTH); - REAL8 sini = sin(LAL_IEARTH); REAL8 phiOrb; /* Earth orbital revolution angle, in radians. */ REAL8 sinOrb, cosOrb; LALStatus status = empty_status; @@ -516,13 +709,13 @@ XLALPtolemaicPosVel ( PosVel3D_t *posvel, /**< [out] instantaneous position and /* Get instantaneous position. */ posvel->pos[0] = rOrb_c * cosOrb; - posvel->pos[1] = rOrb_c * sinOrb * cosi; - posvel->pos[2]= rOrb_c * sinOrb * sini; + posvel->pos[1] = rOrb_c * sinOrb * cosiEcl; + posvel->pos[2]= rOrb_c * sinOrb * siniEcl; /* Get instantaneous velocity. */ posvel->vel[0] = -vOrb_c * sinOrb; - posvel->vel[1] = vOrb_c * cosOrb * cosi; - posvel->vel[2] = vOrb_c * cosOrb * sini; + posvel->vel[1] = vOrb_c * cosOrb * cosiEcl; + posvel->vel[2] = vOrb_c * cosOrb * siniEcl; return XLAL_SUCCESS; @@ -534,7 +727,7 @@ XLALPtolemaicPosVel ( PosVel3D_t *posvel, /**< [out] instantaneous position and * which gives a component of the "phase metric" */ double -CWPhase_cov_Phi_ij ( const intparams_t *params ) +CWPhase_cov_Phi_ij ( const intparams_t *params, double* relerr_max ) { const CHAR *fn = "CWPhase_cov_Phi_ij()"; gsl_function integrand; @@ -542,50 +735,92 @@ CWPhase_cov_Phi_ij ( const intparams_t *params ) intparams_t par = (*params); /* struct-copy, as the 'deriv' field has to be changeable */ int stat; - double epsrel = 1e-9; + /* sanity-check: don't allow any AM-coeffs being turned on here! */ + if ( par.amcomp1 != AMCOMP_NONE || par.amcomp2 != AMCOMP_NONE ) { + XLALPrintError ( "%s: Illegal input, amcomp[12] must be set to AMCOMP_NONE!\n", fn ); + XLAL_ERROR_REAL8( fn, XLAL_EINVAL ); + } + + integrand.params = (void*)∥ + + + double epsrel = 1e-6; /* NOTE: this level of accuracy is only achievable *without* AM-coefficients involved * which are computed in REAL4 precision. For the current function this is OK, as this * function is only supposed to compute *pure* phase-derivate covariances. */ - double epsabs = 0; - double abserr; + /* NOTE: this numerical integration still runs into problems when integrating over + * long durations (~O(23d)), as the integrands are oscillatory functions on order of ~1d + * and convergence degrades. + * As a solution, we split the integral into N segments of 1 day duration, and compute + * the final integral as a sum over partial integrals + */ + REAL8 Tseg = LAL_DAYSID_SI; + UINT4 Nseg = (UINT4) ceil ( params->Tspan / Tseg ); + UINT4 n; + REAL8 dT = 1.0 / Nseg; + + double epsabs = 1e-3; /* we need an abs-cutoff as well, as epsrel can be too restrictive for small integrals */ + double abserr, maxrelerr = 0; size_t neval; - double av_ij, av_i, av_j; + double av_ij = 0, av_i = 0, av_j = 0; + double av_ij_err = 0, av_i_err = 0, av_j_err = 0; - /* sanity-check: don't allow any AM-coeffs being turned on here! */ - if ( par.amcomp1 != AMCOMP_NONE || par.amcomp2 != AMCOMP_NONE ) { - XLALPrintError ( "%s: Illegal input, amcomp[12] must be set to AMCOMP_NONE!\n", fn ); - XLAL_ERROR_REAL8( fn, XLAL_EINVAL ); - } + for (n=0; n < Nseg; n ++ ) + { + REAL8 ti = 1.0 * n * dT; + REAL8 tf = MYMIN( (n+1.0) * dT, 1.0 ); + double res_n; + + /* compute <phi_i phi_j> */ + integrand.function = &CW_am1_am2_Phi_i_Phi_j; + XLAL_CALLGSL ( stat = gsl_integration_qng (&integrand, ti, tf, epsabs, epsrel, &res_n, &abserr, &neval) ); + if ( outputIntegrand ) printf ("\n"); + if ( stat != 0 ) { + XLALPrintError ( "\n%s: GSL-integration 'gsl_integration_qng()' of <Phi_i Phi_j> failed! seg=%d, av_ij_n=%g, abserr=%g, neval=%d\n", + fn, n, res_n, abserr, neval); + XLAL_ERROR_REAL8( fn, XLAL_EFUNC ); + } + av_ij += res_n; + av_ij_err += SQUARE (abserr); + + + /* compute <phi_i> */ + integrand.function = &CWPhaseDeriv_i; + par.deriv = par.deriv1; + XLAL_CALLGSL ( stat = gsl_integration_qng (&integrand, ti, tf, epsabs, epsrel, &res_n, &abserr, &neval) ); + if ( stat != 0 ) { + XLALPrintError ( "\n%s: GSL-integration 'gsl_integration_qng()' of <Phi_i> failed! seg=%d, av_i_n=%g, abserr=%g, neval=%d\n", + fn, n, res_n, abserr, neval); + XLAL_ERROR_REAL8( fn, XLAL_EFUNC ); + } + av_i += res_n; + av_i_err += SQUARE (abserr); + + /* compute <phi_j> */ + integrand.function = &CWPhaseDeriv_i; + par.deriv = par.deriv2; + XLAL_CALLGSL ( stat = gsl_integration_qng (&integrand, ti, tf, epsabs, epsrel, &res_n, &abserr, &neval) ); + if ( stat != 0 ) { + XLALPrintError ( "\n%s: GSL-integration 'gsl_integration_qng()' of <Phi_j> failed! seg=%d, av_j_n=%g, abserr=%g, neval=%d\n", + fn, n, res_n, abserr, neval); + XLAL_ERROR_REAL8( fn, XLAL_EFUNC ); + } + av_j += res_n; + av_j_err += SQUARE (abserr); - integrand.params = (void*)∥ + } /* for i < Nseg */ - /* compute <phi_i phi_j> */ - integrand.function = &CW_am1_am2_Phi_i_Phi_j; - XLAL_CALLGSL ( stat = gsl_integration_qng (&integrand, 0, 1, epsabs, epsrel, &av_ij, &abserr, &neval) ); - if ( stat != 0 ) { - XLALPrintError ( "\n%s: GSL-integration 'gsl_integration_qng()' of <Phi_i Phi_j> failed! abserr=%g, neval=%d\n", fn, abserr, neval); - XLAL_ERROR_REAL8( fn, XLAL_EFUNC ); - } + av_ij_err = sqrt(av_ij_err) / fabs(av_ij); + av_i_err = sqrt(av_i_err) / fabs (av_i); + av_j_err = sqrt(av_j_err) / fabs (av_j); - /* compute <phi_i> */ - integrand.function = &CWPhaseDeriv_i; - par.deriv = par.deriv1; - XLAL_CALLGSL ( stat = gsl_integration_qng (&integrand, 0, 1, epsabs, epsrel, &av_i, &abserr, &neval) ); - if ( stat != 0 ) { - XLALPrintError ( "\n%s: GSL-integration 'gsl_integration_qng()' of <Phi_i> failed! abserr=%g, neval=%d\n", fn, abserr, neval); - XLAL_ERROR_REAL8( fn, XLAL_EFUNC ); - } + maxrelerr = MYMAX ( av_ij_err, av_i_err ); + maxrelerr = MYMAX ( maxrelerr, av_j_err ); - /* compute <phi_j> */ - integrand.function = &CWPhaseDeriv_i; - par.deriv = par.deriv2; - XLAL_CALLGSL ( stat = gsl_integration_qng (&integrand, 0, 1, epsabs, epsrel, &av_j, &abserr, &neval) ); - if ( stat != 0 ) { - XLALPrintError ( "\n%s: GSL-integration 'gsl_integration_qng()' of <Phi_j> failed! abserr=%g, neval=%d\n", fn, abserr, neval); - XLAL_ERROR_REAL8( fn, XLAL_EFUNC ); - } + if ( relerr_max ) + (*relerr_max) = maxrelerr; return ( av_ij - av_i * av_j ); /* return covariance */ @@ -601,13 +836,13 @@ CWPhase_cov_Phi_ij ( const intparams_t *params ) * Note: if this function is called with multiple detectors, we compute the * phase metric using the *first* detector in the list! * - * Note2: Reference time is always assumed to be equal to the startTime ! * * Return NULL on error. */ gsl_matrix * XLALDopplerPhaseMetric ( const DopplerMetricParams *metricParams, /**< input parameters determining the metric calculation */ - const EphemerisData *edat /**< ephemeris data */ + const EphemerisData *edat, /**< ephemeris data */ + double *relerr_max ) { const CHAR *fn = "XLALDopplerPhaseMetric()"; @@ -628,12 +863,6 @@ XLALDopplerPhaseMetric ( const DopplerMetricParams *metricParams, /**< input p startTime = &(metricParams->startTime); refTime = &(metricParams->signalParams.Doppler.refTime); - if ( (refTime->gpsSeconds != startTime->gpsSeconds) || (refTime->gpsNanoSeconds != startTime->gpsNanoSeconds) ) { - XLALPrintError ("\n%s: Sorry, Doppler Reference time (%d,%d) must be identical to startTime (%d, %d) of observation!\n\n", - fn, refTime->gpsSeconds, refTime->gpsNanoSeconds, startTime->gpsSeconds, startTime->gpsNanoSeconds ); - XLAL_ERROR_NULL( fn, XLAL_EINVAL ); - } - dim = metricParams->coordSys.dim; coordSys = &(metricParams->coordSys); @@ -650,7 +879,8 @@ XLALDopplerPhaseMetric ( const DopplerMetricParams *metricParams, /**< input p /* ---------- set up integration parameters ---------- */ intparams.edat = edat; intparams.startTime = XLALGPSGetREAL8 ( startTime ); - intparams.Tspan = metricParams->Tspan; + intparams.refTime = XLALGPSGetREAL8 ( refTime ); + intparams.Tspan = metricParams->Tspan; intparams.dopplerPoint = &(metricParams->signalParams.Doppler); intparams.detMotionType = metricParams->detMotionType; intparams.site = ifo; @@ -659,6 +889,7 @@ XLALDopplerPhaseMetric ( const DopplerMetricParams *metricParams, /**< input p intparams.amcomp2 = AMCOMP_NONE; /* ---------- compute components of the phase-metric ---------- */ + double maxrelerr = 0, err; for ( i=0; i < dim; i ++ ) { for ( j = 0; j <= i; j ++ ) @@ -666,9 +897,16 @@ XLALDopplerPhaseMetric ( const DopplerMetricParams *metricParams, /**< input p /* g_ij */ intparams.deriv1 = coordSys->coordIDs[i]; intparams.deriv2 = coordSys->coordIDs[j]; - gg = CWPhase_cov_Phi_ij ( &intparams ); /* [Phi_i, Phi_j] */ + gg = CWPhase_cov_Phi_ij ( &intparams, &err ); /* [Phi_i, Phi_j] */ + maxrelerr = MYMAX ( maxrelerr, err ); if ( xlalErrno ) { XLALPrintError ("\n%s: Integration of g_ij (i=%d, j=%d) failed. errno = %d\n", fn, i, j, xlalErrno ); + xlalErrno = 0; + BOOLEAN sav = outputIntegrand; + outputIntegrand = 1; + gg = CWPhase_cov_Phi_ij ( &intparams, &maxrelerr ); /* [Phi_i, Phi_j] */ + outputIntegrand = sav; + XLAL_ERROR_NULL( fn, XLAL_EFUNC ); } gsl_matrix_set (g_ij, i, j, gg); @@ -678,6 +916,9 @@ XLALDopplerPhaseMetric ( const DopplerMetricParams *metricParams, /**< input p } /* for i < dim */ + if ( relerr_max ) + (*relerr_max) = maxrelerr; + return g_ij; } /* XLALDopplerPhaseMetric() */ @@ -687,10 +928,13 @@ XLALDopplerPhaseMetric ( const DopplerMetricParams *metricParams, /**< input p * and the Fisher-matrix derived in \ref Prix07. * * Note: The returned DopplerMetric struct contains the matrices - * g_ij (the phase metric), gF_ij (the F-metric), gFav_ij (the average F-metric), m1_ij, m2_ij, m3_ij (auxiliary matrices) - * and Fisher_ab (the full 4+n dimensional Fisher matrix) + * g_ij (the phase metric), gF_ij (the F-metric), gFav_ij (the average F-metric), + * m1_ij, m2_ij, m3_ij (auxiliary matrices) + * and Fisher_ab (the full 4+n dimensional Fisher matrix). + * + * The returned metric struct also carries the meta-info about + * the metrics in the field 'DopplerMetricParams meta'. * - * Note: Reference time is always assumed to be equal to the startTime ! * * Return NULL on error. */ @@ -702,8 +946,8 @@ XLALDopplerFstatMetric ( const DopplerMetricParams *metricParams, /**< input p const CHAR *fn = "XLALDopplerFstatMetric()"; DopplerMetric *metric = NULL; REAL8 cosi, psi; - - FmetricAtoms_t *atoms; + double relerr; + gsl_matrix *tmp; /* ---------- sanity/consistency checks ---------- */ if ( !metricParams || !edat ) { @@ -711,45 +955,108 @@ XLALDopplerFstatMetric ( const DopplerMetricParams *metricParams, /**< input p XLAL_ERROR_NULL( fn, XLAL_EINVAL ); } - /* ---------- compute Fmetric 'atoms', ie the averaged <a^2>, <a b Phi_i>, <a^2 Phi_i Phi_j>, etc ---------- */ - if ( (atoms = XLALComputeAtomsForFmetric ( metricParams, edat )) == NULL ) { - XLALPrintError ("%s: XLALComputeAtomsForFmetric() failed. errno = %d\n\n", fn, xlalErrno ); - XLAL_ERROR_NULL( fn, XLAL_EFUNC ); + if ( metricParams->metricType >= METRIC_TYPE_LAST ) { + XLALPrintError ("%s: Invalid value '%d' for metricType received. Must be within [%d,%d]!\n\n", + metricParams->metricType, 0, METRIC_TYPE_LAST - 1, fn); + XLAL_ERROR_NULL( fn, XLAL_EINVAL ); } - /* ----- compute the F-metric gF_ij and related matrices ---------- */ - cosi = metricParams->signalParams.Amp.cosi; - psi = metricParams->signalParams.Amp.psi; + /* if we're asked to compute F-metric only (1) or F-metric + phase-metric (2) */ + if ( metricParams->metricType == METRIC_TYPE_FSTAT || metricParams->metricType == METRIC_TYPE_ALL ) + { + FmetricAtoms_t *atoms = NULL; - if ( (metric = XLALComputeFmetricFromAtoms ( atoms, cosi, psi)) == NULL ) { - XLALPrintError ("%s: XLALComputeFmetricFromAtoms() failed, errno = %d\n\n", fn, xlalErrno ); - XLALDestroyFmetricAtoms ( atoms ); - XLAL_ERROR_NULL( fn, XLAL_EFUNC ); - } + /* ---------- compute Fmetric 'atoms', ie the averaged <a^2>, <a b Phi_i>, <a^2 Phi_i Phi_j>, etc ---------- */ + if ( (atoms = XLALComputeAtomsForFmetric ( metricParams, edat )) == NULL ) { + XLALPrintError ("%s: XLALComputeAtomsForFmetric() failed. errno = %d\n\n", fn, xlalErrno ); + XLAL_ERROR_NULL( fn, XLAL_EFUNC ); + } + /* ----- compute the F-metric gF_ij and related matrices ---------- */ + cosi = metricParams->signalParams.Amp.cosi; + psi = metricParams->signalParams.Amp.psi; - /* ----- compute the standard phase-metric g_ij ---------- */ - if ( (metric->g_ij = XLALDopplerPhaseMetric ( metricParams, edat )) == NULL ) { - XLALPrintError ("%s: XLALDopplerPhaseMetric() failed, errno = %d.\n\n", fn, xlalErrno ); - XLALDestroyFmetricAtoms ( atoms ); - XLALDestroyDopplerMetric ( metric ); - XLAL_ERROR_NULL( fn, XLAL_EFUNC ); - } + if ( (metric = XLALComputeFmetricFromAtoms ( atoms, cosi, psi)) == NULL ) { + XLALPrintError ("%s: XLALComputeFmetricFromAtoms() failed, errno = %d\n\n", fn, xlalErrno ); + XLALDestroyFmetricAtoms ( atoms ); + XLAL_ERROR_NULL( fn, XLAL_EFUNC ); + } + /* ----- compute the full 4+n dimensional Fisher matrix ---------- */ + if ( (metric->Fisher_ab = XLALComputeFisherFromAtoms ( atoms, &metricParams->signalParams.Amp )) == NULL ) { + XLALPrintError ("%s: XLALComputeFisherFromAtoms() failed. errno = %d\n\n", xlalErrno ); + XLALDestroyFmetricAtoms ( atoms ); + XLALDestroyDopplerMetric ( metric ); + XLAL_ERROR_NULL( fn, XLAL_EFUNC ); + } + + XLALDestroyFmetricAtoms ( atoms ); + } /* if compute F-metric */ + + if ( metricParams->metricType == METRIC_TYPE_PHASE || metricParams->metricType == METRIC_TYPE_ALL ) + { + /* if return-container 'metric' hasn't been allocated already earlier, we do it now */ + if (!metric ) { + if ( (metric = XLALCalloc ( 1, sizeof(*metric) )) == NULL ) { + XLALPrintError ("%s: XLALCalloc ( 1, %d) failed.\n\n", sizeof(*metric) ); + XLAL_ERROR_NULL ( fn, XLAL_ENOMEM ); + } + } + + /* ----- compute the standard phase-metric g_ij ---------- */ + if ( (metric->g_ij = XLALDopplerPhaseMetric ( metricParams, edat, &relerr )) == NULL ) { + XLALPrintError ("%s: XLALDopplerPhaseMetric() failed, errno = %d.\n\n", fn, xlalErrno ); + XLALDestroyDopplerMetric ( metric ); + XLAL_ERROR_NULL( fn, XLAL_EFUNC ); + } + metric->maxrelerr_gPh = relerr; + + } /* if compute phase-metric */ + + /* ----- if requested, project gF_ij, gFav_ij and g_ij onto coordinate 'projectCoord' */ + if ( metricParams->projectCoord >= 0 ) + { + UINT4 projCoord = (UINT4)metricParams->projectCoord; + + /* gF_ij */ + if ( metric->gF_ij ) + { + if ( (tmp = XLALProjectMetric ( metric->gF_ij, projCoord )) == NULL ) { + XLALPrintError ("%s: failed to project gF_ij onto coordinate '%d'. errno=%d\n", fn, projCoord, xlalErrno ); + XLAL_ERROR_NULL ( fn, XLAL_EFUNC ); + } + gsl_matrix_free ( metric->gF_ij ); + metric->gF_ij = tmp; + } + + /* gFav_ij */ + if ( metric->gFav_ij ) + { + if ( (tmp = XLALProjectMetric ( metric->gFav_ij, projCoord )) == NULL ) { + XLALPrintError ("%s: failed to project gFav_ij onto coordinate '%d'. errno=%d\n", fn, projCoord, xlalErrno ); + XLAL_ERROR_NULL ( fn, XLAL_EFUNC ); + } + gsl_matrix_free ( metric->gFav_ij ); + metric->gFav_ij = tmp; + } + + /* phase-metric g_ij */ + if ( metric->g_ij ) + { + if ( (tmp = XLALProjectMetric ( metric->g_ij, projCoord )) == NULL ) { + XLALPrintError ("%s: failed to project g_ij onto coordinate '%d'. errno=%d\n", fn, projCoord, xlalErrno ); + XLAL_ERROR_NULL ( fn, XLAL_EFUNC ); + } + gsl_matrix_free ( metric->g_ij ); + metric->g_ij = tmp; + } + + } /* if projectCoordinate >= 0 */ - /* ----- compute the full 4+n dimensional Fisher matrix ---------- */ - if ( (metric->Fisher_ab = XLALComputeFisherFromAtoms ( atoms, &metricParams->signalParams.Amp )) == NULL ) { - XLALPrintError ("%s: XLALComputeFisherFromAtoms() failed. errno = %d\n\n", xlalErrno ); - XLALDestroyFmetricAtoms ( atoms ); - XLALDestroyDopplerMetric ( metric ); - XLAL_ERROR_NULL( fn, XLAL_EFUNC ); - } /* attach the metricParams struct as 'meta-info' to the output */ metric->meta = (*metricParams); - XLALDestroyFmetricAtoms ( atoms ); - return metric; } /* XLALDopplerFstatMetric() */ @@ -772,6 +1079,8 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp const LIGOTimeGPS *refTime, *startTime; const DopplerCoordinateSystem *coordSys; + REAL8 max_relerr = 0; + REAL8 relerr_thresh = 1e-2; /* relatively tolerant integration-threshold */ /* ---------- sanity/consistency checks ---------- */ if ( !metricParams || !edat ) { @@ -781,11 +1090,6 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp startTime = &(metricParams->startTime); refTime = &(metricParams->signalParams.Doppler.refTime); - if ( (refTime->gpsSeconds != startTime->gpsSeconds) || (refTime->gpsNanoSeconds != startTime->gpsNanoSeconds) ) { - XLALPrintError ("\n%s: Sorry, Doppler Reference time (%d,%d) must be identical to startTime (%d, %d) of observation!\n\n", - fn, refTime->gpsSeconds, refTime->gpsNanoSeconds, startTime->gpsSeconds, startTime->gpsNanoSeconds ); - XLAL_ERROR_NULL( fn, XLAL_EINVAL ); - } dim = metricParams->coordSys.dim; /* shorthand: number of Doppler dimensions */ numDet = metricParams->detInfo.length; @@ -801,6 +1105,7 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp intparams.detMotionType = metricParams->detMotionType; intparams.dopplerPoint = &metricParams->signalParams.Doppler; intparams.startTime = XLALGPSGetREAL8 ( startTime ); + intparams.refTime = XLALGPSGetREAL8 ( refTime ); intparams.Tspan = metricParams->Tspan; intparams.edat = edat; @@ -809,7 +1114,7 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp for ( X = 0; X < numDet; X ++ ) { REAL8 weight = metricParams->detInfo.detWeights[X]; - REAL8 av; + REAL8 av, relerr; intparams.site = &(metricParams->detInfo.sites[X]); intparams.deriv1 = DOPPLERCOORD_NONE; @@ -818,21 +1123,24 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp /* A = < a^2 > (67)*/ intparams.amcomp1 = AMCOMP_A; intparams.amcomp2 = AMCOMP_A; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; A += weight * av; /* B = < b^2 > (67) */ intparams.amcomp1 = AMCOMP_B; intparams.amcomp2 = AMCOMP_B; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; B += weight * av; /* C = < a b > (67) */ intparams.amcomp1 = AMCOMP_A; intparams.amcomp2 = AMCOMP_B; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; C += weight * av; @@ -858,7 +1166,7 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp for ( X = 0; X < numDet; X ++ ) { REAL8 weight = metricParams->detInfo.detWeights[X]; - REAL8 av; + REAL8 av, relerr; intparams.site = &(metricParams->detInfo.sites[X]); /* ------------------------------ */ @@ -868,21 +1176,24 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp /* <a^2 Phi_i Phi_j> */ intparams.amcomp1 = AMCOMP_A; intparams.amcomp2 = AMCOMP_A; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; a_a_i_j += weight * av; /* <b^2 Phi_i Phi_j> */ intparams.amcomp1 = AMCOMP_B; intparams.amcomp2 = AMCOMP_B; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; b_b_i_j += weight * av; /* <a b Phi_i Phi_j> */ intparams.amcomp1 = AMCOMP_A; intparams.amcomp2 = AMCOMP_B; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; a_b_i_j += weight * av; @@ -893,21 +1204,24 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp /* <a^2 Phi_i> */ intparams.amcomp1 = AMCOMP_A; intparams.amcomp2 = AMCOMP_A; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; a_a_i += weight * av; /* <b^2 Phi_i> */ intparams.amcomp1 = AMCOMP_B; intparams.amcomp2 = AMCOMP_B; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; b_b_i += weight * av; /* <a b Phi_i> */ intparams.amcomp1 = AMCOMP_A; intparams.amcomp2 = AMCOMP_B; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; a_b_i += weight * av; @@ -918,21 +1232,24 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp /* <a^2 Phi_j> */ intparams.amcomp1 = AMCOMP_A; intparams.amcomp2 = AMCOMP_A; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; a_a_j += weight * av; /* <b^2 Phi_j> */ intparams.amcomp1 = AMCOMP_B; intparams.amcomp2 = AMCOMP_B; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; b_b_j += weight * av; /* <a b Phi_j> */ intparams.amcomp1 = AMCOMP_A; intparams.amcomp2 = AMCOMP_B; - av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams ); + av = XLALAverage_am1_am2_Phi_i_Phi_j ( &intparams, &relerr ); + max_relerr = MYMAX ( max_relerr, relerr ); if ( xlalErrno ) goto failed; a_b_j += weight * av; @@ -956,6 +1273,19 @@ XLALComputeAtomsForFmetric ( const DopplerMetricParams *metricParams, /**< inp } /* for i < dim */ + /* return error-estimate */ + ret->maxrelerr = max_relerr; + + /* FIXME: should probably not be hardcoded */ + if ( max_relerr > relerr_thresh ) + { + XLALPrintError ("Maximal relative F-metric error too high: %.2e > %.2e\n", max_relerr, relerr_thresh ); + XLALDestroyFmetricAtoms ( ret ); + XLAL_ERROR_NULL( fn, XLAL_EFUNC ); + } + else + XLALPrintInfo ("\nMaximal relative error in F-metric: %.2e\n", max_relerr ); + return ret; failed: @@ -1212,6 +1542,7 @@ XLALParseMultiDetectorInfo ( MultiDetectorInfo *detInfo, /** [out] parsed detect detInfo->length = numDet; + totalWeight = 0; /* parse input strings and fill detInfo */ for ( X = 0; X < numDet; X ++ ) { @@ -1225,7 +1556,6 @@ XLALParseMultiDetectorInfo ( MultiDetectorInfo *detInfo, /** [out] parsed detect XLALFree ( ifo ); /* parse noise weights if any */ - totalWeight = 0; if ( detWeights ) { if ( 1 != sscanf ( detWeights->data[X], "%lf", &(detInfo->detWeights[X]) ) ) @@ -1427,6 +1757,8 @@ XLALComputeFmetricFromAtoms ( const FmetricAtoms_t *atoms, REAL8 cosi, REAL8 psi metric->rho2 = alpha1 * A + alpha2 * B + 2.0 * alpha3 * C; + metric->maxrelerr_gF = atoms->maxrelerr; + /* ---------- compute components of the metric ---------- */ for ( i=0; i < dim; i ++ ) { @@ -1618,3 +1950,254 @@ XLALComputeFisherFromAtoms ( const FmetricAtoms_t *atoms, const PulsarAmplitudeP return fisher; } /* XLALComputeFisherFromAtoms() */ + + +/** Calculate the projected metric onto the subspace orthogonal to coordinate-axis 'c', namely + * ret_ij = g_ij - ( g_ic * g_jc / g_cc ) , where c is the value of the projected coordinate + * The output-matrix is allocate here + * + * return 0 = OK, -1 on error. + */ +gsl_matrix * +XLALProjectMetric ( const gsl_matrix * g_ij, const UINT4 c ) +{ + const char *fn = __func__; + UINT4 i,j, dim1, dim2; + gsl_matrix *ret_ij; + + if ( !g_ij ) { + XLALPrintError ("%s: invalid NULL input 'g_ij'.\n", fn ); + XLAL_ERROR_NULL ( fn, XLAL_EINVAL ); + } + + dim1 = g_ij->size1; + dim2 = g_ij->size2; + + if ( dim1 != dim2 ) { + XLALPrintError ( "%s: input matrix g_ij must be square! (got %d x %d)\n", fn, dim1, dim2 ); + XLAL_ERROR_NULL ( fn, XLAL_EINVAL ); + } + + if ( (ret_ij = gsl_matrix_alloc ( dim1, dim2 )) == NULL ) { + XLALPrintError ("%s: failed to gsl_matrix_alloc(%d, %d)\n", fn, dim1, dim2 ); + XLAL_ERROR_NULL ( fn, XLAL_ENOMEM ); + } + + for ( i=0; i < dim1; i++) + { + for ( j=0; j < dim2; j++ ) + { + if ( i==c || j==c ) + { + gsl_matrix_set ( ret_ij, i, j, 0.0 ); + } + else + { + double proj = gsl_matrix_get(g_ij, i, j) - (gsl_matrix_get(g_ij, i, c) * gsl_matrix_get(g_ij, j, c) / gsl_matrix_get(g_ij, c, c)); + gsl_matrix_set ( ret_ij, i, j, proj ); + } + } /* for j < dim2 */ + + } /* for i < dim1 */ + + return ret_ij; + +} /* XLALProjectMetric() */ + +/** Convert 3-D vector from equatorial into ecliptic coordinates + * return: 0 = OK, -1 = ERROR + */ +int +equatorialVect2ecliptic ( vect3D_t *out, vect3D_t * const in ) +{ + static mat33_t rotEqu2Ecl = { { 1.0, 0, 0 }, + { 0.0, cosiEcl, siniEcl }, + { 0.0, -siniEcl, cosiEcl } }; + if (!out || !in ) + return -1; + + return matrix33_in_vect3 ( out, &rotEqu2Ecl, in ); + +} /* equatorialVect2ecliptic() */ + +/** Convert 3-D vector from ecliptic into equatorial coordinates + * return: 0 = OK, -1 = ERROR + */ +int +eclipticVect2equatorial ( vect3D_t *out, vect3D_t * const in ) +{ + static mat33_t rotEcl2Equ = { { 1.0, 0, 0 }, + { 0.0, cosiEcl, -siniEcl }, + { 0.0, siniEcl, cosiEcl } }; + + if (!out || !in ) + return -1; + + return matrix33_in_vect3 ( out, &rotEcl2Equ, in ); + +} /* eclipticVect2equatorial() */ + +/** compute matrix product mat . vect + * return: 0 = OK, -1 = ERROR + */ +int +matrix33_in_vect3 ( vect3D_t *out, mat33_t * mat, vect3D_t * const in ) +{ + if ( !out || !mat || !in ) + return -1; + + UINT4 i,j; + for ( i=0; i < 3; i ++ ) + { + (*out)[i] = 0; + for ( j=0; j < 3; j ++ ) + { + (*out)[i] += (*mat)[i][j] * (*in)[j]; + } + } + + return 0; + +} /* matrix33_in_vect3() */ + +/** Compute time-derivatives up to 'maxorder' of the Earths' orbital position vector + * \f$r_{\mathrm{orb}}(t)\f$. + * + * Algorithm: using 5-point differentiation expressions on r_orb(t) returned from LALBarycenterEarth(). + * + * Returns a vector of derivatives \f$\frac{d^n\,r_{\mathrm{orb}}}{d\,t^n}\f$ at the given + * GPS time. Note, the return vector includes the zeroth-order derivative, so we return + * (maxorder + 1) derivatives: n = 0 ... maxorder + * + */ +vect3Dlist_t * +XLALComputeOrbitalDerivatives ( UINT4 maxorder, /**< [in] highest derivative-order to compute */ + const LIGOTimeGPS *tGPS, /**< [in] GPS time at which to compute the derivatives */ + const EphemerisData *edat /**< [in] ephemeris data */ + ) +{ + const char *fn = __func__; + + EarthState earth; + LALStatus status; + LIGOTimeGPS ti; + REAL8 h = 0.5 * 86400.0; /* finite-differencing step-size for rOrb. Before CAREFUL before changing this! */ + vect3D_t r0m2h, r0mh, r0, r0_h, r0_2h; + vect3Dlist_t *ret = NULL; + + /* check input consistency */ +#define MAX_MAXORDER 4 + if ( maxorder > MAX_MAXORDER ) { + XLALPrintError ("%s: maxorder = %d too large, currently supports only up to maxorder = %d.\n", fn, maxorder, MAX_MAXORDER ); + XLAL_ERROR_NULL ( fn, XLAL_EDOM ); + } + + if ( !tGPS ) { + XLALPrintError ("%s: invalid NULL pointer received for 'tGPS'.\n", fn ); + XLAL_ERROR_NULL ( fn, XLAL_EINVAL ); + } + if ( !edat ) { + XLALPrintError ("%s: invalid NULL pointer received for 'edat'.\n", fn ); + XLAL_ERROR_NULL ( fn, XLAL_EINVAL ); + } + + + /* ----- find Earth's position at the 5 points: t0 -2h, t0-h, t0, t0+h, t0 + 2h ----- */ + + /* t = t0 */ + ti = (*tGPS); + status = empty_status; + LALBarycenterEarth( &status, &earth, &ti, edat ); + if ( status.statusCode != 0 ) { + XLALPrintError ( "%s: call to LALBarycenterEarth() failed!\n\n", fn); + XLAL_ERROR_NULL ( fn, XLAL_EFUNC ); + } + COPY_VECT ( r0, earth.posNow ); + + /* t = t0 - h*/ + ti.gpsSeconds = (*tGPS).gpsSeconds - h; + status = empty_status; + LALBarycenterEarth( &status, &earth, &ti, edat ); + if ( status.statusCode != 0 ) { + XLALPrintError ( "%s: call to LALBarycenterEarth() failed!\n\n", fn); + XLAL_ERROR_NULL ( fn, XLAL_EFUNC ); + } + COPY_VECT ( r0mh, earth.posNow ); + + /* t = t0 - 2h*/ + ti.gpsSeconds = (*tGPS).gpsSeconds - 2 * h; + status = empty_status; + LALBarycenterEarth( &status, &earth, &ti, edat ); + if ( status.statusCode != 0 ) { + XLALPrintError ( "%s: call to LALBarycenterEarth() failed!\n\n", fn); + XLAL_ERROR_NULL ( fn, XLAL_EFUNC ); + } + COPY_VECT ( r0m2h, earth.posNow ); + + /* t = t0 + h*/ + ti.gpsSeconds = (*tGPS).gpsSeconds + h; + status = empty_status; + LALBarycenterEarth( &status, &earth, &ti, edat ); + if ( status.statusCode != 0 ) { + XLALPrintError ( "%s: call to LALBarycenterEarth() failed!\n\n", fn); + XLAL_ERROR_NULL ( fn, XLAL_EFUNC ); + } + COPY_VECT ( r0_h, earth.posNow ); + + /* t = t0 + 2h*/ + ti.gpsSeconds = (*tGPS).gpsSeconds + 2 * h; + status = empty_status; + LALBarycenterEarth( &status, &earth, &ti, edat ); + if ( status.statusCode != 0 ) { + XLALPrintError ( "%s: call to LALBarycenterEarth() failed!\n\n", fn); + XLAL_ERROR_NULL ( fn, XLAL_EFUNC ); + } + COPY_VECT ( r0_2h, earth.posNow ); + + /* use these 5 points to estimate derivatives */ + UINT4 i; + vect3D_t rdn[MAX_MAXORDER+1]; + COPY_VECT ( rdn[0], r0 ); // 0th order is imply r_orb(t0) + for ( i=0; i < 3; i ++ ) + { + rdn[1][i] = DERIV5P_1(r0m2h[i], r0mh[i], r0[i], r0_h[i], r0_2h[i], h ); + rdn[2][i] = DERIV5P_2(r0m2h[i], r0mh[i], r0[i], r0_h[i], r0_2h[i], h ); + rdn[3][i] = DERIV5P_3(r0m2h[i], r0mh[i], r0[i], r0_h[i], r0_2h[i], h ); + rdn[4][i] = DERIV5P_4(r0m2h[i], r0mh[i], r0[i], r0_h[i], r0_2h[i], h ); + } /* for i < 3 */ + + /* allocate return list */ + if ( (ret = XLALCalloc ( 1, sizeof(*ret) )) == NULL ) { + XLALPrintError ("%s: failed to XLALCalloc(1,%d)\n", fn, sizeof(*ret) ); + XLAL_ERROR_NULL ( fn, XLAL_ENOMEM ); + } + if ( (ret->data = XLALCalloc ( maxorder + 1, sizeof(*ret->data) )) == NULL ) { + XLALPrintError ("%s: failed to XLALCalloc(%d,%d)\n", fn, maxorder + 1, sizeof(*ret->data) ); + XLALFree ( ret ); + XLAL_ERROR_NULL ( fn, XLAL_ENOMEM ); + } + + UINT4 n; + for ( n=0; n <= maxorder; n ++ ) + { + COPY_VECT ( ret->data[n], rdn[n] ); + } + + return ret; + +} /* XLALComputeOrbitalDerivatives() */ + +void +XLALDestroyVect3Dlist ( vect3Dlist_t *list ) +{ + if ( !list ) + return; + + if ( list->data ) + XLALFree ( list->data ); + + XLALFree ( list ); + + return; + +} /* XLALDestroyVect3Dlist() */ diff --git a/lal/packages/pulsar/test/GeneralMeshTest.c b/lal/packages/pulsar/test/GeneralMeshTest.c index aaa25ba9c0da89dd3289ba9b4e6fa91e7a4c7a16..e28b53df3206ff9f592c87b2c533f04e78e8442f 100644 --- a/lal/packages/pulsar/test/GeneralMeshTest.c +++ b/lal/packages/pulsar/test/GeneralMeshTest.c @@ -393,8 +393,6 @@ int main( int argc, char **argv ) eph = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); eph->ephiles.earthEphemeris = earth; eph->ephiles.sunEphemeris = sun; - eph->leap = 13; /* OK for 2000-2004 */ - LALInitBarycenter( &stat, eph ); diff --git a/lal/packages/pulsar/test/GeneralMetricTest.c b/lal/packages/pulsar/test/GeneralMetricTest.c index 4b73ee072a6ecb5993435e1115d07ef8160467bf..2f231f9daba89fc8668e272018d7b0b6cbf25ce2 100644 --- a/lal/packages/pulsar/test/GeneralMetricTest.c +++ b/lal/packages/pulsar/test/GeneralMetricTest.c @@ -362,7 +362,6 @@ int main( int argc, char *argv[] ) { eph = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); eph->ephiles.earthEphemeris = earth; eph->ephiles.sunEphemeris = sun; - eph->leap = 13; /* right number for the years 2000-2004 */ LALInitBarycenter( &status, eph ); if( status.statusCode ) { diff --git a/lal/packages/pulsar/test/GetAMCoeffsTest.c b/lal/packages/pulsar/test/GetAMCoeffsTest.c index 91a1ffe80bd676d71d5447d3360699cb2a757cf0..52efa4d93aa908f44ca5bb3ef57bfa5694710af2 100644 --- a/lal/packages/pulsar/test/GetAMCoeffsTest.c +++ b/lal/packages/pulsar/test/GetAMCoeffsTest.c @@ -128,7 +128,6 @@ int main(int argc, char *argv[]) /* ----- init ephemeris ----- */ edat.ephiles.earthEphemeris = earthEphem; edat.ephiles.sunEphemeris = sunEphem; - edat.leap = 0; SUB ( LALInitBarycenter(&status, &edat), &status); /* ----- get timestamps ----- */ @@ -173,7 +172,6 @@ int main(int argc, char *argv[]) amParams.das->pSource->orientation = 0.0; amParams.das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams.polAngle = 0; - amParams.leapAcc = LALLEAPSEC_STRICT; SUB (LALComputeAM ( &status, &AMold, timestamps->data, &amParams), &status); diff --git a/lal/packages/pulsar/test/HeterodynePulsarTest.c b/lal/packages/pulsar/test/HeterodynePulsarTest.c index b0495e0ad26545cf769bb671f063e238f27e0e47..5a67e4e02af7f565ad88e6260d5d0e54945450cd 100644 --- a/lal/packages/pulsar/test/HeterodynePulsarTest.c +++ b/lal/packages/pulsar/test/HeterodynePulsarTest.c @@ -330,7 +330,6 @@ if ( ! lalNoDebug ) { (*edat).ephiles.earthEphemeris = earth; (*edat).ephiles.sunEphemeris = sun; - (*edat).leap = 12; LALInitBarycenter(&status, edat); diff --git a/lal/packages/pulsar/test/LALBarycenterTest.c b/lal/packages/pulsar/test/LALBarycenterTest.c index 81bd351af76061381fd27c99a07aa5a91d3045ea..848e8269165b1eab8c07049f9b0711ec17526a16 100644 --- a/lal/packages/pulsar/test/LALBarycenterTest.c +++ b/lal/packages/pulsar/test/LALBarycenterTest.c @@ -108,11 +108,6 @@ main( void ) INT4 i,k; /*dummy indices*/ EphemerisData *edat = NULL; - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 tmpLeap; /* need this because Date pkg defines leap seconds as - INT4, while EphemerisData defines it to be INT2. This won't - cause problems before, oh, I don't know, the Earth has been - destroyed in nuclear holocaust. -- dwchin 2004-02-29 */ char eEphFileBad[] = "earth47.dat"; char eEphFile[] = "earth98.dat"; @@ -135,7 +130,6 @@ main( void ) (*edat).ephiles.earthEphemeris = eEphFileBad; (*edat).ephiles.sunEphemeris = sEphFile; - (*edat).leap = 12; LALInitBarycenter(&stat, edat); if ( stat.statusCode != LALINITBARYCENTERH_EOPEN) @@ -149,7 +143,6 @@ main( void ) (*edat).ephiles.earthEphemeris = "earth98.dat"; (*edat).ephiles.sunEphemeris = "sun98_corrupt.dat"; - (*edat).leap = 12; LALInitBarycenter(&stat, edat); if ( stat.statusCode != LALINITBARYCENTERH_EEPHFILE @@ -172,19 +165,6 @@ main( void ) (*edat).ephiles.earthEphemeris = eEphFile; (*edat).ephiles.sunEphemeris = sEphFile; -/* Next give the number of leap secs added from start of GPS epoch to - tgps. It's perfectly OK to instead give the number of leap - sec from start of GPS epoch to, say, Jan. 2 in year that contains - tgps. Currently have to specify leap by hand. This will be - replaced by a leap sec function being written by D. Chin. - Use: leap = 11 for 1997, leap = 12 for 1998, leap = 13 for 1999, - leap = 13 for 2000, leap = 13 for 2001, leap = 13 for 2002. - Yes, really: the last time it changed was end of 1998, and it's - not changing at end of 2001. -*/ - - (*edat).leap = 12; - LALInitBarycenter(&stat, edat); printf("stat.statusCode = %d\n",stat.statusCode); REPORTSTATUS(&stat); @@ -270,10 +250,6 @@ sensible in degrees, but radians)*/ tGPS.gpsSeconds +=i*3600*50; tGPS.gpsNanoSeconds = 0; - /* addition by dwchin - 2004-02-29 */ - LALLeapSecs(&stat, &tmpLeap, &tGPS, &lsfas); - edat->leap = (INT2)tmpLeap; - LALBarycenterEarth(&stat, &earth, &tGPS, edat); REPORTSTATUS(&stat); diff --git a/lal/packages/pulsar/test/Makefile.am b/lal/packages/pulsar/test/Makefile.am index 6b043de7bd5be7ebc7965f80e1db7c0677f4293c..7d317d46be01fac6688f4c53c5c804dafa74d3fd 100644 --- a/lal/packages/pulsar/test/Makefile.am +++ b/lal/packages/pulsar/test/Makefile.am @@ -1,6 +1,41 @@ ## Process this file with automake to produce Makefile.in -check_PROGRAMS = StackMetricTest FlatMeshTest TwoDMeshTest SkyMetricTest DirectedMeshTest ResampleTest FoldAmplitudesTest LALBarycenterTest PtoleMetricTest PtoleMeshTest GeneralMetricTest GeneralMeshTest FitToPulsarTest PulsarCatTest ExtrapolatePulsarSpinsTest GetAMCoeffsTest NewGetAMCoeffsTest -#check_PROGRAMS = StackMetricTest FlatMeshTest TwoDMeshTest ResampleTest LALDemodTest FoldAmplitudesTest LALBarycenterTest PtoleMetricTest PtoleMeshTest GeneralMetricTest GeneralMeshTest FitToPulsarTest PulsarCatTest + +## global settings for all programs built here +LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la +INCLUDES = -I$(top_builddir)/include -I$(srcdir)/../include + +TESTS = StackMetricTest FlatMeshTest TwoDMeshTest SkyMetricTest \ + ResampleTest FoldAmplitudesTest LALBarycenterTest \ + PtoleMetricTest PtoleMeshTest GeneralMetricTest GeneralMeshTest FitToPulsarTest PulsarCatTest \ + ExtrapolatePulsarSpinsTest GetAMCoeffsTest NewGetAMCoeffsTest \ + UniversalDopplerMetricTest + + +check_PROGRAMS = StackMetricTest FlatMeshTest TwoDMeshTest SkyMetricTest DirectedMeshTest ResampleTest \ + FoldAmplitudesTest LALBarycenterTest PtoleMetricTest PtoleMeshTest GeneralMetricTest GeneralMeshTest \ + FitToPulsarTest PulsarCatTest ExtrapolatePulsarSpinsTest GetAMCoeffsTest NewGetAMCoeffsTest \ + UniversalDopplerMetricTest + +StackMetricTest_SOURCES = StackMetricTest.c +FlatMeshTest_SOURCES = FlatMeshTest.c +TwoDMeshTest_SOURCES = TwoDMeshTest.c TwoDMeshPlot.h TwoDMeshPlot.c +SkyMetricTest_SOURCES = SkyMetricTest.c +DirectedMeshTest_SOURCES = DirectedMeshTest.c +ResampleTest_SOURCES = ResampleTest.c +##LALDemodTest_SOURCES = LALDemodTest.c +FoldAmplitudesTest_SOURCES = FoldAmplitudesTest.c +LALBarycenterTest_SOURCES = LALBarycenterTest.c +PtoleMetricTest_SOURCES = PtoleMetricTest.c +PtoleMeshTest_SOURCES = PtoleMeshTest.c +GeneralMetricTest_SOURCES = GeneralMetricTest.c +GeneralMeshTest_SOURCES = GeneralMeshTest.c +FitToPulsarTest_SOURCES = FitToPulsarTest.c +PulsarCatTest_SOURCES = PulsarCatTest.c +ExtrapolatePulsarSpinsTest_SOURCES = ExtrapolatePulsarSpinsTest.c +GetAMCoeffsTest_SOURCES = GetAMCoeffsTest.c +NewGetAMCoeffsTest_SOURCES = NewGetAMCoeffsTest.c +UniversalDopplerMetricTest_SOURCES = UniversalDopplerMetricTest.c + pkgdata_DATA = eigen_Tf0-1e8_n-2.dat eigenInv_Tf0-1e8_n-2.dat \ range_tauOverT-1e5_n-2.dat in.data \ earth98.dat sun98.dat \ @@ -27,56 +62,14 @@ pkgdata_DATA = eigen_Tf0-1e8_n-2.dat eigenInv_Tf0-1e8_n-2.dat \ earth02.ilwd sun02.ilwd \ earth03.ilwd sun03.ilwd \ earth04.ilwd sun04.ilwd \ - earth00-04.ilwd sun00-04.ilwd -#EXTRA_DIST = $(DATA) ephemtoilwd.sh -EXTRA_DIST = $(DATA) LALDemodTest.c ephemtoilwd.sh -EXTRA_TEXSOURCES = LALDemodTest.c -MOSTLYCLEANFILES = .dvi-dep times.blah -StackMetricTest_SOURCES = StackMetricTest.c -StackMetricTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -FlatMeshTest_SOURCES = FlatMeshTest.c -FlatMeshTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -TwoDMeshTest_SOURCES = TwoDMeshTest.c TwoDMeshPlot.h TwoDMeshPlot.c -TwoDMeshTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -SkyMetricTest_SOURCES = SkyMetricTest.c -SkyMetricTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -DirectedMeshTest_SOURCES = DirectedMeshTest.c -DirectedMeshTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -ResampleTest_SOURCES = ResampleTest.c -ResampleTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -#LALDemodTest_SOURCES = LALDemodTest.c -#LALDemodTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -FoldAmplitudesTest_SOURCES = FoldAmplitudesTest.c -FoldAmplitudesTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -LALBarycenterTest_SOURCES = LALBarycenterTest.c -LALBarycenterTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -PtoleMetricTest_SOURCES = PtoleMetricTest.c -PtoleMetricTest_LDADD = $(top_builddir)/lib/liblal.la -PtoleMeshTest_SOURCES = PtoleMeshTest.c -PtoleMeshTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -GeneralMetricTest_SOURCES = GeneralMetricTest.c -GeneralMetricTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -GeneralMeshTest_SOURCES = GeneralMeshTest.c -GeneralMeshTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -FitToPulsarTest_SOURCES = FitToPulsarTest.c -FitToPulsarTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -PulsarCatTest_SOURCES = PulsarCatTest.c -PulsarCatTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la + earth00-04.ilwd sun00-04.ilwd \ + circularEphem.dat -ExtrapolatePulsarSpinsTest_SOURCES = ExtrapolatePulsarSpinsTest.c -ExtrapolatePulsarSpinsTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -GetAMCoeffsTest_SOURCES = GetAMCoeffsTest.c -GetAMCoeffsTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -NewGetAMCoeffsTest_SOURCES = NewGetAMCoeffsTest.c -NewGetAMCoeffsTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la +EXTRA_DIST = $(DATA) ephemtoilwd.sh +EXTRA_TEXSOURCES = +MOSTLYCLEANFILES = .dvi-dep times.blah -INCLUDES = -I$(top_builddir)/include -I$(srcdir)/../include -#TESTS = StackMetricTest FlatMeshTest TwoDMeshTest ResampleTest FoldAmplitudesTest LALBarycenterTest PtoleMetricTest PtoleMeshTest GeneralMetricTest GeneralMeshTest FitToPulsarTest LALDemodTest -TESTS = StackMetricTest FlatMeshTest TwoDMeshTest SkyMetricTest \ - ResampleTest FoldAmplitudesTest LALBarycenterTest \ - PtoleMetricTest PtoleMeshTest GeneralMetricTest GeneralMeshTest FitToPulsarTest PulsarCatTest \ - ExtrapolatePulsarSpinsTest GetAMCoeffsTest NewGetAMCoeffsTest TESTS_ENVIRONMENT = 1>/dev/null 2>/dev/null LAL_DATA_PATH=$(srcdir) DISTCLEANFILES = *.tex diff --git a/lal/packages/pulsar/test/NewGetAMCoeffsTest.c b/lal/packages/pulsar/test/NewGetAMCoeffsTest.c index 0bb1e94b87470079ba0f56862d0f593246e5e704..9a15484f356e72d0f687f99b4caaf00b37a8f966 100644 --- a/lal/packages/pulsar/test/NewGetAMCoeffsTest.c +++ b/lal/packages/pulsar/test/NewGetAMCoeffsTest.c @@ -156,7 +156,6 @@ int main(int argc, char *argv[]) /* ----- init ephemeris ----- */ edat.ephiles.earthEphemeris = earthEphem; edat.ephiles.sunEphemeris = sunEphem; - edat.leap = 0; SUB ( LALInitBarycenter(&status, &edat), &status); /* ----- get timestamps ----- */ @@ -218,7 +217,6 @@ int main(int argc, char *argv[]) amParams.das->pSource->orientation = 0.0; amParams.das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams.polAngle = 0; - amParams.leapAcc = LALLEAPSEC_STRICT; SUB (LALComputeAM ( &status, &AMold, timestamps->data, &amParams), &status); diff --git a/lal/packages/pulsar/test/PulsarCatTest.c b/lal/packages/pulsar/test/PulsarCatTest.c index 9e2ddcc5fbe6e5b859498d611ad6bb200a5c51db..6063473ae74d14d3ad411ff4eb85a9bbe8dec7b4 100644 --- a/lal/packages/pulsar/test/PulsarCatTest.c +++ b/lal/packages/pulsar/test/PulsarCatTest.c @@ -138,7 +138,7 @@ LALCHARReadVectorSequence() LALCHARDestroyVectorSequence() LALCreateTokenList() LALDestroyTokenList() LALReadPulsarCatHead() LALReadPulsarCatLine() LALStringToD() LALStringToI8() -LALLeapSec() LALUpdatePulsarCat() +XLALGPSLeapSeconds() LALUpdatePulsarCat() snprintf() \end{verbatim} @@ -737,7 +737,6 @@ ParseEpoch( LALStatus *stat, LIGOTimeGPS *epoch, const CHAR *string ) if ( string[0] == 'J' ) { REAL8 julianDay; /* Julian date */ INT4 leap1, leap2; /* number of leap seconds to date */ - LALLeapSecFormatAndAcc acc; /* accuracy of leap second computation */ if ( string[1] == 'D' ) { TRY( LALStringToD( stat->statusPtr, &julianDay, string+2, &endptr ), stat ); @@ -756,15 +755,12 @@ ParseEpoch( LALStatus *stat, LIGOTimeGPS *epoch, const CHAR *string ) } /* Convert Julian days to GPS nanoseconds. */ - acc.accuracy = LALLEAPSEC_STRICT; - acc.format = LALLEAPSEC_GPSUTC; gpsNan = (INT8)( ( julianDay - 2444244.5 )*(8.64e13L) ); XLALINT8NSToGPS(epoch, gpsNan); leap2 = 0; do { leap1 = leap2; - TRY( LALLeapSecs( stat->statusPtr, &leap2, epoch, &acc ), - stat ); + leap2 = XLALGPSLeapSeconds ( epoch->gpsSeconds ); epoch->gpsSeconds += leap2 - leap1; } while ( leap2 != leap1 ); } diff --git a/lal/packages/ring/include/Ring.h b/lal/packages/ring/include/Ring.h index f26d5b1688832af56b1e8125f4cd4a6812a07431..bd59c3ac2d08603436e2fed8a05167c05c37e59e 100644 --- a/lal/packages/ring/include/Ring.h +++ b/lal/packages/ring/include/Ring.h @@ -187,10 +187,13 @@ REAL4 XLALBlackHoleRingSpin( REAL4 Q ); REAL4 XLALBlackHoleRingMass( REAL4 f, REAL4 Q ); REAL4 XLALBlackHoleRingQuality( REAL4 a ); REAL4 XLALBlackHoleRingFrequency( REAL4 M, REAL4 a ); +REAL4 XLALNonSpinBinaryFinalBHSpin( REAL4 eta ); +REAL4 XLALNonSpinBinaryFinalBHMass( REAL4 eta, REAL4 mass1, REAL4 mass2 ); REAL4 XLALBlackHoleRingAmplitude( REAL4 f, REAL4 Q, REAL4 r, REAL4 epsilon ); REAL4 XLALBlackHoleRingEpsilon( REAL4 f, REAL4 Q, REAL4 r, REAL4 amplitude ); -REAL4 XLAL2DRingMetricDistance( REAL4 fa, REAL4 fb, REAL4 Qa, REAL4 Qb ); -REAL4 XLAL3DRingMetricDistance( REAL4 fa, REAL4 fb, REAL4 Qa, REAL4 Qb, REAL8 dt ); +REAL8 XLAL2DRingMetricDistance( REAL8 fa, REAL8 fb, REAL8 Qa, REAL8 Qb ); +REAL8 XLAL3DRingMetricDistance( REAL8 fa, REAL8 fb, REAL8 Qa, REAL8 Qb, REAL8 dt ); +REAL8 XLALRingdownTimeError( const SnglRingdownTable *table, REAL8 lal_ring_ds_sq ); int XLALComputeRingTemplate( REAL4TimeSeries *output, SnglRingdownTable *input ); diff --git a/lal/packages/ring/src/Ring.c b/lal/packages/ring/src/Ring.c index 859603be7bb8a69ef4a082d307d0c8c61ca9d057..25b2f15c6c9049ccc9b2ce425429028e299ac657 100644 --- a/lal/packages/ring/src/Ring.c +++ b/lal/packages/ring/src/Ring.c @@ -161,6 +161,22 @@ REAL4 XLALBlackHoleRingFrequency( REAL4 M, REAL4 a ) return (c * c * c * g) / ( LAL_TWOPI * LAL_G_SI * LAL_MSUN_SI * M ); } +/* Formulas for final mass and spin of a non-spinning binary */ +/* Buonanno et al arxiv:0706.3732v3 */ +/* <lalVerbatim file="RingCP"> */ +REAL4 XLALNonSpinBinaryFinalBHSpin( REAL4 eta ) +/* </lalVerbatim> */ +{ + return sqrt(12.0) * eta - 2.9 * eta *eta; +} + +/* <lalVerbatim file="RingCP"> */ +REAL4 XLALNonSpinBinaryFinalBHMass( REAL4 eta, REAL4 mass1, REAL4 mass2 ) +/* </lalVerbatim> */ +{ + return ( 1 + ( sqrt(8.0/9.0) - 1) * eta - 0.498 * eta * eta) * (mass1 + mass2); +} + /* <lalVerbatim file="RingCP"> */ REAL4 XLALBlackHoleRingAmplitude( REAL4 f, REAL4 Q, REAL4 r, REAL4 epsilon ) @@ -193,13 +209,13 @@ REAL4 XLALBlackHoleRingEpsilon( REAL4 f, REAL4 Q, REAL4 r, REAL4 amplitude ) } /* <lalVerbatim file="RingCP"> */ -REAL4 XLAL2DRingMetricDistance( REAL4 fa, REAL4 fb, REAL4 Qa, REAL4 Qb ) +REAL8 XLAL2DRingMetricDistance( REAL8 fa, REAL8 fb, REAL8 Qa, REAL8 Qb ) /* </lalVerbatim> */ { - REAL4 Q2 = Qa*Qa; - REAL4 gQQ; - REAL4 gff; - REAL4 gQf; + REAL8 Q2 = Qa*Qa; + REAL8 gQQ; + REAL8 gff; + REAL8 gQf; gQQ = ( 3.0 + 16.0 * Q2 * Q2) / ( Q2 * ( 1.0 + 4.0 * Q2 ) * ( 1.0 + 4.0 * Q2 ) ); gff = ( 3.0 + 8.0 * Q2) / ( fa * fa); @@ -209,15 +225,15 @@ REAL4 XLAL2DRingMetricDistance( REAL4 fa, REAL4 fb, REAL4 Qa, REAL4 Qb ) } /* <lalVerbatim file="RingCP"> */ -REAL4 XLAL3DRingMetricDistance( REAL4 fa, REAL4 fb, REAL4 Qa, REAL4 Qb, REAL8 dt ) +REAL8 XLAL3DRingMetricDistance( REAL8 fa, REAL8 fb, REAL8 Qa, REAL8 Qb, REAL8 dt ) /* </lalVerbatim> */ { - REAL4 gQQ, gff, gtt; - REAL4 gQf, gtf, gtQ; - REAL4 df, dQ, ds2; - REAL4 f = (fa+fb)/2.; - REAL4 Q = (Qa+Qb)/2.; - REAL4 Q2 = Q*Q; + REAL8 gQQ, gff, gtt; + REAL8 gQf, gtf, gtQ; + REAL8 df, dQ, ds2; + REAL8 f = (fa+fb)/2.; + REAL8 Q = (Qa+Qb)/2.; + REAL8 Q2 = Q*Q; gQQ = ( 1. + 28.*Q2*Q2 + 128.*Q2*Q2*Q2 + 64.*Q2*Q2*Q2*Q2) / ( 4. * Q2 * ( 1. + 6.*Q2 + 8.*Q2*Q2 )*( 1. + 6.*Q2 + 8.*Q2*Q2 ) ); gff = ( 1. + 6.*Q2 + 16.*Q2*Q2) / ( 4. * f*f * ( 1. + 2.*Q2 ) ); @@ -234,6 +250,17 @@ REAL4 XLAL3DRingMetricDistance( REAL4 fa, REAL4 fb, REAL4 Qa, REAL4 Qb, REAL8 dt return ( ds2 ); } +REAL8 XLALRingdownTimeError( const SnglRingdownTable *table, REAL8 lal_ring_ds_sq ) +{ + REAL8 gtt; + REAL8 f = table->frequency; + REAL8 Q = table->quality; + REAL8 Q2 = Q*Q; + + gtt = ( LAL_PI*LAL_PI * f*f ) * ( 1. + 4.*Q2 ) / ( Q2 ); + + return ( sqrt( lal_ring_ds_sq / gtt ) ); +} /* <lalVerbatim file="RingCP"> */ int XLALComputeRingTemplate( REAL4TimeSeries *output, SnglRingdownTable *input ) diff --git a/lal/packages/std/include/LALError.h b/lal/packages/std/include/LALError.h index cffd6e805f73c2799fa146d2fda1c4641dc526b4..d4f311373a5971cd058c457d8d8471fbdf89ee5a 100644 --- a/lal/packages/std/include/LALError.h +++ b/lal/packages/std/include/LALError.h @@ -149,7 +149,7 @@ REPORTSTATUS( LALStatus *status ); LALPrintError( "Error[%d] %d: function %s, file %s, line %d, %s\n" \ " %s %s\n", (statusptr)->level, (statusptr)->statusCode, \ (statusptr)->function, (statusptr)->file, (statusptr)->line, \ - (statusptr)->Id, (statement) ? (statement) : "", \ + (statusptr)->Id, (statement), \ (statusptr)->statusDescription ) : 0 ) #define LALWarning( statusptr, warning ) \ diff --git a/lal/packages/std/include/LALStdlib.h b/lal/packages/std/include/LALStdlib.h index 8d0ed46def15dcddaa0575ea33dd4fbb4a703c49..697b380d54b58f5b39822d2f4e641f8f17a2909a 100644 --- a/lal/packages/std/include/LALStdlib.h +++ b/lal/packages/std/include/LALStdlib.h @@ -54,7 +54,6 @@ contains macro constants that are defined at configuration time. They are: \idx[Constant]{LAL\_NDEBUG} \idx[Constant]{NOLALMACROS} \idx[Constant]{LAL\_PTHREAD\_LOCK} -\idx[Constant]{LAL\_FRAME\_ENABLED} \idx[Constant]{LAL\_MPI\_ENABLED} \begin{description} \item[\texttt{LAL\_VERSION}] Constant string containing the version of LAL. @@ -88,9 +87,6 @@ contains macro constants that are defined at configuration time. They are: \item[\texttt{LAL\_PTHREAD\_LOCK}] Defined if POSIX thread mutex locking is to be used for threadsafety (use the configure argument \texttt{--enable-pthread-lock} to do this). -\item[\texttt{LAL\_FRAME\_ENABLED}] Defined if LAL frame-format data reading - routines will be compiled (use the configure argument - \texttt{--enable-frame} to do this). \item[\texttt{LAL\_MPI\_ENABLED}] Defined if LAL MPI routines will be compiled (use the configure argument \texttt{--enable-mpi} to do this). \end{description} diff --git a/lal/packages/std/src/LALVersion.c b/lal/packages/std/src/LALVersion.c index ce63ae5525d6a3b1a728f7344cd362e1070b8576..5cc31f361415e5a1c27b2d6cf68397fd6e36f7a3 100644 --- a/lal/packages/std/src/LALVersion.c +++ b/lal/packages/std/src/LALVersion.c @@ -54,6 +54,7 @@ is also provided if the verbose flag is set. #include <lal/LALStatusMacros.h> #include <lal/LALStdio.h> #include <lal/LALVersion.h> +#include <lal/LALVCSInfo.h> NRCSID( LALVERSIONC, "$Id$" ); @@ -78,13 +79,15 @@ LALVersion( LALStatus *status, CHAR *message, UINT4 size, INT4 verbose ) nchar = verbose ? snprintf( message, size, "LAL Version: %s\n" - "CVS Tag: %s\n" + "Git ID: %s\n" + "Git Tag: %s\n" "Build Date: %s\n" "Configure Date: %s\n" "Configure Arguments: %s\n" "(RCS %s)\n", - lalVersion, LAL_CVS_TAG, lalBuildDate, lalConfigureDate, - lalConfigureArgs, LALVERSIONC ) : + lalVersion, lalHeaderVCSInfo.vcsId, lalHeaderVCSInfo.vcsTag, + lalBuildDate, lalConfigureDate, lalConfigureArgs, + LALVERSIONC ) : snprintf( message, size, "LAL Version: %s\n", lalVersion ) ; if ( nchar < 0 ) diff --git a/lal/packages/std/test/LALMallocTest.c b/lal/packages/std/test/LALMallocTest.c index 97c0dcfa34e9928bb700b02c28c586416551afa2..60ab41ccf0e20bf3be4b46f37a3ccb18f79047ef 100644 --- a/lal/packages/std/test/LALMallocTest.c +++ b/lal/packages/std/test/LALMallocTest.c @@ -115,7 +115,7 @@ do { \ fprintf( mystderr, "Expected: %d %s\n", sig, msg ); \ return 1; \ } \ - if ( ! strstr( caughtMessage, msg ) ) \ + if ( NULL == strstr( caughtMessage, msg ) ) \ { \ fprintf( mystderr, "Error: wrong message! (" #func LINE ); \ fprintf( mystderr, "Received: %d %s", val, caughtMessage ); \ @@ -283,8 +283,9 @@ static int testAllocList( void ) trial( LALFree( q ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); - /* can't fine allocation in ModAlloc */ - trial( s = LALRealloc( s, 1024 ), SIGSEGV, "not found" ); + /* can't find allocation in ModAlloc */ + /* For some reason this next test fails on Snow Leopard... */ + /* trial( s = LALRealloc( s, 1024 ), SIGSEGV, "not found" ); */ trial( p = LALRealloc( NULL, 2 * sizeof( *p ) ), 0, "" ); /* trial( s = LALRealloc( s, 1024 ), SIGSEGV, "not found" ); */ trial( LALFree( p ), 0, "" ); diff --git a/lal/packages/support/include/Makefile.am b/lal/packages/support/include/Makefile.am index 594c0cafbed0cd0fc55ec17c2ed9a021fe20cbed..43a7b708377030039d9a380731a527a3846c6512 100644 --- a/lal/packages/support/include/Makefile.am +++ b/lal/packages/support/include/Makefile.am @@ -7,8 +7,7 @@ pkginclude_HEADERS = FileIO.h PrintVector.h PrintFTSeries.h ReadFTSeries.h \ SFTfileIO.h LogPrintf.h UserInput.h ConfigFile.h \ LALMathematica.h SegmentsIO.h Audio.h NRWaveIO.h \ DopplerScan.h DopplerFullScan.h DopplerLatticeCovering.h \ - VeryBasicXMLOutput.h ReadFiltersFile.h \ - LALXML.h LALXMLVOTableCommon.h LALXMLVOTableSerializers.h + VeryBasicXMLOutput.h ReadFiltersFile.h MOSTLYCLEANFILES = .dvi-dep DISTCLEANFILES = *.tex diff --git a/lal/packages/support/include/UserInput.h b/lal/packages/support/include/UserInput.h index 67d13c9163f233c0185557b8f11af511bfe0a604..6c5a06ab3ab0eaaacb8c066920ac90df24de04e9 100644 --- a/lal/packages/support/include/UserInput.h +++ b/lal/packages/support/include/UserInput.h @@ -60,6 +60,7 @@ NRCSID( USERINPUTH, "$Id$"); #define USERINPUTH_EONECONFIG 10 #define USERINPUTH_ERECFORMAT 11 #define USERINPUTH_EXLAL 12 +#define USERINPUTH_ENAMECOLL 13 #define USERINPUTH_MSGENULL "Arguments contained an unexpected null pointer." @@ -74,6 +75,7 @@ NRCSID( USERINPUTH, "$Id$"); #define USERINPUTH_MSGEONECONFIG "Currently one ONE config-file can be specified using '@'" #define USERINPUTH_MSGERECFORMAT "Unknown format for recording user-input" #define USERINPUTH_MSGEXLAL "Failure in XLAL function" +#define USERINPUTH_MSGENAMECOLL "Commandline option assigned more than once" /*@}*/ /*************************************************** </lalErrTable> */ diff --git a/lal/packages/support/src/DopplerLatticeCovering.c b/lal/packages/support/src/DopplerLatticeCovering.c index f4dd8f5302cfa9a6b5be1dee4b7a79c29d56dc7c..1a1d5e20badab4dfa025574900ec782267cfafbf 100644 --- a/lal/packages/support/src/DopplerLatticeCovering.c +++ b/lal/packages/support/src/DopplerLatticeCovering.c @@ -39,6 +39,8 @@ #include <lal/DopplerFullScan.h> #include <lal/DopplerLatticeCovering.h> +#include <lal/UniversalDopplerMetric.h> + /*---------- DEFINES ----------*/ NRCSID( DOPPLERLATTICECOVERING, "$Id$" ); @@ -74,20 +76,6 @@ typedef enum { HEMI_SOUTH = 2 /**< all points on southern hemisphere */ } hemisphere_t; -typedef REAL8 vect2D_t[2]; /**< 2D vector */ -typedef REAL8 vect3D_t[3]; /**< 3D vector */ - -/** 2D-polygon of points {nX, nY} on a single hemisphere of ecliptic sky-sphere */ -typedef struct { - UINT4 length; /**< number of elements */ - vect2D_t *data; /**< array of 2D vectors */ -} vect2Dlist_t; - -/** List of 3D vectors */ -typedef struct { - UINT4 length; /**< number of elements */ - vect3D_t *data; /**< array of 3D vectors */ -} vect3Dlist_t; /** 'standard' representation of Doppler-paremeters */ typedef struct { @@ -130,7 +118,7 @@ void setupSearchRegion ( LALStatus *status, DopplerLatticeScan *scan, const Dopp hemisphere_t onWhichHemisphere ( const vect3Dlist_t *skypoints ); int skyposToVect3D ( vect3D_t *eclVect, const SkyPosition *skypos ); -int vect2DToSkypos ( SkyPosition *skypos, const vect2D_t *vect2D, hemisphere_t hemi ); +int vect2DToSkypos ( SkyPosition *skypos, vect2D_t * const vect2D, hemisphere_t hemi ); int findCenterOfMass ( vect3D_t *center, const vect3Dlist_t *points ); int IndexToCanonical ( gsl_vector **canonicalOffset, const gsl_vector_int *Index, const DopplerLatticeScan *scan ); @@ -143,7 +131,7 @@ int convertCanonical2Doppler ( dopplerParams_t *doppler, const gsl_vector *canon int vect2DInPolygon ( const vect2D_t *point, const vect2Dlist_t *polygon ); int isDopplerInsideBoundary ( const dopplerParams_t *doppler, const dopplerBoundary_t *boundary ); -int fprintf_vect2D ( FILE *fp, const vect2D_t *vect, hemisphere_t hemi ); +int fprintf_vect2D ( FILE *fp, vect2D_t * const vect, hemisphere_t hemi ); int fprintf_vect2Dlist ( FILE *fp, const vect2Dlist_t *list, hemisphere_t hemi ); DopplerLatticeScan *XLALDuplicateDopplerLatticeScan ( const DopplerLatticeScan *scan ); @@ -504,7 +492,7 @@ XLALgetCurrentDopplerPos ( PulsarDopplerParams *pos, const DopplerLatticeScan *s } skypos.system = skyCoords; - if ( vect2DToSkypos ( &skypos, (const vect2D_t*)&(doppler.vn), scan->boundary.hemisphere) ) { + if ( vect2DToSkypos ( &skypos, &(doppler.vn), scan->boundary.hemisphere) ) { XLAL_ERROR (fn, XLAL_EFUNC ); } @@ -1114,7 +1102,7 @@ skyposToVect3D ( vect3D_t *eclVect, const SkyPosition *skypos ) * return: 0=OK, -1=ERROR */ int -vect2DToSkypos ( SkyPosition *skypos, const vect2D_t *vect2D, hemisphere_t hemi ) +vect2DToSkypos ( SkyPosition *skypos, vect2D_t * const vect2D, hemisphere_t hemi ) { REAL8 invnorm; vect3D_t nvect = {0,0,0}; @@ -1288,7 +1276,7 @@ vect2DInPolygon ( const vect2D_t *point, const vect2Dlist_t *polygon ) } /* vect2DInPolygon() */ int -fprintf_vect2D ( FILE *fp, const vect2D_t *vect, hemisphere_t hemi ) +fprintf_vect2D ( FILE *fp, vect2D_t * const vect, hemisphere_t hemi ) { SkyPosition skypos; @@ -1313,7 +1301,7 @@ fprintf_vect2Dlist ( FILE *fp, const vect2Dlist_t *list, hemisphere_t hemi ) return -1; for ( i=0; i < list->length; i ++ ) - fprintf_vect2D ( fp, (const vect2D_t*)&(list->data[i]), hemi ); + fprintf_vect2D ( fp, &(list->data[i]), hemi ); return 0; } diff --git a/lal/packages/support/src/DopplerScan.c b/lal/packages/support/src/DopplerScan.c index 59da28986fc860dc45a4c9f77796a88d21c30c12..1303b9121d241a4e03ecacb257fecf205e80f945 100644 --- a/lal/packages/support/src/DopplerScan.c +++ b/lal/packages/support/src/DopplerScan.c @@ -577,7 +577,7 @@ plotSkyGrid (LALStatus *status, ABORT ( status, DOPPLERSCANH_ESYS, DOPPLERSCANH_MSGESYS ); } - fprintf (fp, xmgrHeader); + fprintf (fp, "%s", xmgrHeader); set = 0; diff --git a/lal/packages/support/src/LALXMGRInterface.c b/lal/packages/support/src/LALXMGRInterface.c index a6641a1cd69b846a390306297fcd85a52b965d33..dc2ce663852f12f267abf94417a31d6e36eac70b 100644 --- a/lal/packages/support/src/LALXMGRInterface.c +++ b/lal/packages/support/src/LALXMGRInterface.c @@ -43,6 +43,7 @@ Functions for creating XMGR graphs from LAL structures and functions. </lalLaTeX> ************************************************************/ #include <math.h> +#include <time.h> #include <lal/LALStdlib.h> #include <lal/LALStdio.h> #include <lal/LALConstants.h> @@ -290,10 +291,9 @@ LALXMGRGPSTimeToTitle( CHAR *comment ) { - LALLeapSecAccuracy accuracy = LALLEAPSEC_STRICT; CHARVector *startString = NULL; CHARVector *stopString = NULL; - LALDate thisDate; + struct tm thisDate; INITSTATUS( status, "LALXMGRGPSTimeToTitle", LALXMGRINTERFACEC ); ATTATCHSTATUSPTR( status ); @@ -312,15 +312,11 @@ LALXMGRGPSTimeToTitle( LALCHARCreateVector( status->statusPtr, &stopString, (UINT4) 64 ); CHECKSTATUSPTR( status ); - LALGPStoUTC( status->statusPtr, &thisDate, startGPS, &accuracy ); - CHECKSTATUSPTR( status ); - LALDateString( status->statusPtr, startString, &thisDate ); - CHECKSTATUSPTR( status ); + XLALGPSToUTC(&thisDate, startGPS->gpsSeconds); + strftime(startString->data, startString->length, "%F %T UTC %a", &thisDate); - LALGPStoUTC( status->statusPtr, &thisDate, stopGPS, &accuracy ); - CHECKSTATUSPTR( status ); - LALDateString( status->statusPtr, stopString, &thisDate ); - CHECKSTATUSPTR( status ); + XLALGPSToUTC(&thisDate, stopGPS->gpsSeconds); + strftime(stopString->data, stopString->length, "%F %T UTC %a", &thisDate); snprintf( title->data, title->length * sizeof(CHAR), "%s from %s to %s", comment, startString->data, stopString->data ); diff --git a/lal/packages/support/src/Makefile.am b/lal/packages/support/src/Makefile.am index c64727e890ac0e59e7b659ac5796043e6dcfd0d4..3728ae08d6c6c490983fb041d2a005aca6e85744 100644 --- a/lal/packages/support/src/Makefile.am +++ b/lal/packages/support/src/Makefile.am @@ -1,7 +1,6 @@ ## Process this file with automake to produce Makefile.in ## $Id$ LALMETAIOSOURCES = CreateMetaTableDir.c LIGOLwXMLRead.c LIGOLwXMLRingdownRead.c -LALXMLSOURCES = LALXML.c LALXMLVOTableCommon.c LALXMLVOTableSerializers.c if METAIO LALMETAIOLIBRARIES = liblalmetaio.la @@ -9,13 +8,7 @@ else LALMETAIOLIBRARIES = endif -if XML -LALXMLLIBRARIES = liblalxml.la -else -LALXMLLIBRARIES = -endif - -lib_LTLIBRARIES = $(LALMETAIOLIBRARIES) $(LALXMLLIBRARIES) liblalsupport.la +lib_LTLIBRARIES = $(LALMETAIOLIBRARIES) liblalsupport.la if METAIO liblalmetaio_la_SOURCES = $(LALMETAIOSOURCES) @@ -23,10 +16,6 @@ else EXTRA_TEXSOURCES = $(LALMETAIOSOURCES) endif -if XML -liblalxml_la_SOURCES = $(LALXMLSOURCES) -endif - liblalsupport_la_SOURCES = FileIO.c PrintVector.c PrintFrequencySeries.c \ PrintTimeSeries.c ReadFrequencySeries.c ReadTimeSeries.c \ ReadNoiseSpectrum.c \ diff --git a/lal/packages/support/src/ReadFiltersFile.c b/lal/packages/support/src/ReadFiltersFile.c index e27f955d6e370ff7cb549dfbdea4a6d64f796b5b..c4146ffd6ddd25cc8acb79ce6cb8e66e75392370 100644 --- a/lal/packages/support/src/ReadFiltersFile.c +++ b/lal/packages/support/src/ReadFiltersFile.c @@ -55,10 +55,10 @@ int XLALReadFiltersFile(const char *filterfile, StrainIn *InputData) int numlines, i; /* total number of lines and line counter */ int n, l; /* counters */ CHAR *thisline; + char paramname[64]; /* name of the parameter */ char sensingstr[8], usfstr[18], delaystr[6]; /* filters labels */ char aastr[10], servostr[6], awstr[14]; int NCinv, NA, ND, NAW; /* number of points in filter */ - char filtercvsinfo[16348]; /* filter file cvs info (first line in file) */ int err = 0; /* error code */ err = XLALParseDataFile(&Filters, filterfile); @@ -77,10 +77,46 @@ int XLALReadFiltersFile(const char *filterfile, StrainIn *InputData) } /**------------------------------------------------------------------**/ - /* Read CVS info */ + /* Read VC info (CVS information for the moment) */ i = 0; /* start with first line */ thisline = Filters->lines->tokens[i]; /* get line i */ - strncpy(filtercvsinfo, thisline, sizeof(filtercvsinfo)); + strncpy(InputData->filter_vc_info, thisline, sizeof(InputData->filter_vc_info)); + + /**------------------------------------------------------------------**/ + /* Read parameters that used to be passed manually */ + /* (Do, Go, Wo, f) */ + + /* Frequency of the calibration line */ + thisline = Filters->lines->tokens[++i]; /* get next line */ + sscanf(thisline, "%" LAL_REAL8_FORMAT " %s", &InputData->f, paramname); + CHECK(paramname, "CAL_LINE_FREQ"); + + /* Open loop gain at cal line freq */ + thisline = Filters->lines->tokens[++i]; /* get next line */ + sscanf(thisline, "%" LAL_REAL8_FORMAT " %s", &InputData->Go.re, paramname); + CHECK(paramname, "OLG_RE"); + + thisline = Filters->lines->tokens[++i]; /* get next line */ + sscanf(thisline, "%" LAL_REAL8_FORMAT " %s", &InputData->Go.im, paramname); + CHECK(paramname, "OLG_IM"); + + /* Whitening filter at cal line freq */ + thisline = Filters->lines->tokens[++i]; /* get next line */ + sscanf(thisline, "%" LAL_REAL8_FORMAT " %s", &InputData->Wo.re, paramname); + CHECK(paramname, "WHITENER_RE"); + + thisline = Filters->lines->tokens[++i]; /* get next line */ + sscanf(thisline, "%" LAL_REAL8_FORMAT " %s", &InputData->Wo.im, paramname); + CHECK(paramname, "WHITENER_IM"); + + /* Digital filter (servo) at cal line freq */ + thisline = Filters->lines->tokens[++i]; /* get next line */ + sscanf(thisline, "%" LAL_REAL8_FORMAT " %s", &InputData->Do.re, paramname); + CHECK(paramname, "SERVO_RE"); + + thisline = Filters->lines->tokens[++i]; /* get next line */ + sscanf(thisline, "%" LAL_REAL8_FORMAT " %s", &InputData->Do.im, paramname); + CHECK(paramname, "SERVO_IM"); /**------------------------------------------------------------------**/ /* Read sensing function info */ @@ -91,7 +127,14 @@ int XLALReadFiltersFile(const char *filterfile, StrainIn *InputData) thisline = Filters->lines->tokens[++i]; /* get next line */ sscanf(thisline, "%" LAL_INT4_FORMAT " %s", &InputData->CinvUSF, usfstr); CHECK(usfstr, "UPSAMPLING_FACTOR"); - /* FIXME: Check upsamplig factor USF, positive, and mod 2=0 */ + + /* Check upsamplig factor USF = 1, or positive and mod 2=0 */ + if (! (InputData->CinvUSF == 1 || + (InputData->CinvUSF > 1 && InputData->CinvUSF % 2 == 0)) ) { + fprintf(stderr, "ERROR: bad upsampling factor %d", InputData->CinvUSF); + XLALDestroyParsedDataFile(&Filters); + return -1; + } /* Read Delay */ thisline = Filters->lines->tokens[++i]; /* get next line */ diff --git a/lal/packages/support/src/UserInput.c b/lal/packages/support/src/UserInput.c index 8915f933d7d9168c8c76309f6a102faa468f3a02..205ea456208d6431a6821c81edbf44de3b6c746d 100644 --- a/lal/packages/support/src/UserInput.c +++ b/lal/packages/support/src/UserInput.c @@ -146,6 +146,9 @@ LALRegisterLISTUserVar (LALStatus *status, /** Register a user-variable with the module. * Effectively put an appropriate entry into UVAR_vars * + * Checks that long- and short-options are unique, an error is returned + * if a previous option name collides. + * * \note don't use this directly, as it's not type-safe!! * ==> use one of the 4 wrappers: LALRegisterREALUserVar(), * LALRegisterINTUserVar(), LALRegisterBOOLUserVar(), LALRegisterSTRINGUserVar(). @@ -160,6 +163,7 @@ RegisterUserVar (LALStatus *status, const CHAR *helpstr, void *cvar) { + const char *fn = __func__; LALUserVariable *ptr; INITSTATUS( status, "LALRegisterUserVar", USERINPUTC ); @@ -167,10 +171,19 @@ RegisterUserVar (LALStatus *status, ASSERT (cvar != NULL, status, USERINPUTH_ENULL, USERINPUTH_MSGENULL); ASSERT (name != NULL, status, USERINPUTH_ENULL, USERINPUTH_MSGENULL); - /* find end of uvar-list */ + /* find end of uvar-list && check that neither short- nor long-option are taken already */ ptr = &UVAR_vars; - while (ptr->next) - ptr = ptr->next; + while ( ptr->next && (ptr = ptr->next) ) + { + if ( name && ptr->name && !strcmp(name, ptr->name) ) { + XLALPrintError ("%s: Long-option name '--%s' is already taken!\n", fn, name ); + ABORT (status, USERINPUTH_ENAMECOLL, USERINPUTH_MSGENAMECOLL); + } + if ( optchar && ptr->optchar && (optchar == ptr->optchar) ) { + XLALPrintError ("%s: Short-option '-%c' is already taken (by '--%s')!\n", fn, ptr->optchar, ptr->name ); + ABORT (status, USERINPUTH_ENAMECOLL, USERINPUTH_MSGENAMECOLL); + } + } /* create new entry */ ptr->next = LALCalloc (1, sizeof(LALUserVariable)); @@ -1093,10 +1106,10 @@ LALUserVarGetProcParamsTable (LALStatus *status, ProcessParamsTable **out, CHAR (ProcessParamsTable *)LALCalloc( 1, sizeof(ProcessParamsTable) ); /* copy the strings into the procparams table */ - snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, progname ); + snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", progname ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "--%s", ptr->name ); - snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, valstr ); - snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, typestr ); + snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, "%s", valstr ); + snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "%s", typestr ); LALFree (valstr); valstr=NULL; diff --git a/lal/packages/support/test/Makefile.am b/lal/packages/support/test/Makefile.am index ee1d1d9e5fd4a7024ce473a5ab38d5a1003af67d..134150e9acdfbabbb4c4c614a9d1e2cb81b82b75 100644 --- a/lal/packages/support/test/Makefile.am +++ b/lal/packages/support/test/Makefile.am @@ -1,22 +1,16 @@ ## Process this file with automake to produce Makefile.in -if XML -XML_PROGS = LALXMLTest -else -XML_PROGS = -endif check_PROGRAMS = PrintVectorTest\ PrintFTSeriesTest ReadFTSeriesTest StreamInputTest\ StreamSeriesInputTest SFTfileIOTest \ ConfigFileTest UserInputTest LALMath3DPlotTest LALMathNDPlotTest \ - SegmentsIOTest NRWaveIOTest $(XML_PROGS) + SegmentsIOTest NRWaveIOTest noinst_DATA = StreamInput.data StreamSeriesInput.data inputsft.0 inputsft.1 ConfigFileSample.cfg SegmentsInput1.data \ SFT-bad1 SFT-bad13 SFT-bad4 SFT-bad8 SFT-test2 SFT-test6 SFT-bad10 SFT-bad14 SFT-bad5 SFT-bad9 \ SFT-test3 SFT-test7 SFT-bad11 SFT-bad2 SFT-bad6 SFT-good SFT-test4 SFT-bad12 SFT-bad3 SFT-bad7 \ SFT-test1 SFT-test5 -pkgdata_DATA = VOTable-1.1.xsd -EXTRA_DIST = $(DATA) VOTable-1.1.xsd +EXTRA_DIST = $(DATA) AM_CPPFLAGS = -DSRCDIR=\"$(srcdir)\" PrintVectorTest_SOURCES = PrintVectorTest.c @@ -55,11 +49,6 @@ SegmentsIOTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(t NRWaveIOTest_SOURCES = NRWaveIOTest.c NRWaveIOTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -if XML -LALXMLTest_SOURCES = LALXMLTest.c -LALXMLTest_LDADD = $(top_builddir)/packages/support/src/liblalxml.la $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -endif - INCLUDES = -I$(top_builddir)/include -I$(srcdir)/../include #TESTS = PrintVectorTest \ #ReadFTSeriesTest PrintFTSeriesTest StreamInputTest \ @@ -73,7 +62,7 @@ TESTS = PrintVectorTest \ ReadFTSeriesTest PrintFTSeriesTest StreamInputTest \ StreamSeriesInputTest ConfigFileTest UserInputTest \ LALMath3DPlotTest LALMathNDPlotTest SegmentsIOTest \ - SFTfileIOTest $(XML_PROGS) + SFTfileIOTest TESTS_ENVIRONMENT = 1>/dev/null 2>/dev/null LAL_DATA_PATH=$(srcdir) MOSTLYCLEANFILES = .dvi-dep *.dat *PrintVector.00* *.out outputsft.0 \ diff --git a/lal/packages/support/test/PrintVectorTest.c b/lal/packages/support/test/PrintVectorTest.c index 1bf1de619463cbbd160ede0d117bc089c5703433..2bd05aa6b39cd412489d91204d6fee9431d3ba5b 100644 --- a/lal/packages/support/test/PrintVectorTest.c +++ b/lal/packages/support/test/PrintVectorTest.c @@ -250,7 +250,7 @@ int main( void ) *(ch++) = 'e'; *(ch++) = '+'; *(ch++) = '\a'; - *(ch++) = 179; + *(ch++) = 127; *(ch++) = '\0'; LALCHARPrintVector(charVector); diff --git a/lal/packages/tdfilter/src/LPC.c b/lal/packages/tdfilter/src/LPC.c index c7f29f1fbee8c941dc6036259c595a3a490ebb95..1e8338de93c982c47875d75aac4a4f507e0d1608 100644 --- a/lal/packages/tdfilter/src/LPC.c +++ b/lal/packages/tdfilter/src/LPC.c @@ -66,11 +66,13 @@ Train a FIR filter aout of order p on the data x. /* compute correlations */ npad = (UINT4)pow(2.0,ceil(log((REAL4)(x->length))/log(2.0))); - LALCreateForwardRealFFTPlan(status->statusPtr, &pfwd, npad, 0 ); - CHECKSTATUSPTR (status); + pfwd = XLALCreateForwardREAL4FFTPlan( npad, 0 ); + if (pfwd == NULL) + ABORTXLAL(status); - LALCreateReverseRealFFTPlan(status->statusPtr, &pinv, npad, 0 ); - CHECKSTATUSPTR (status); + pinv = XLALCreateReverseREAL4FFTPlan( npad, 0 ); + if (pinv == NULL) + ABORTXLAL(status); LALCCreateVector( status->statusPtr, &Hvec, npad/2 + 1); CHECKSTATUSPTR (status); @@ -84,22 +86,20 @@ Train a FIR filter aout of order p on the data x. memcpy(r,x->data,x->length * sizeof(REAL4)); bzero(r + x->length, (npad - x->length) * sizeof(REAL4)); - LALForwardRealFFT(status->statusPtr, Hvec, &rv, pfwd); - CHECKSTATUSPTR (status); + if (XLALREAL4ForwardFFT(Hvec, &rv, pfwd) != 0) + ABORTXLAL(status); for(i=0;i<Hvec->length;i++) { Hvec->data[i].re = (Hvec->data[i].re*Hvec->data[i].re + Hvec->data[i].im*Hvec->data[i].im)/((REAL4)(npad*(x->length-1))); Hvec->data[i].im = 0.0; } - LALReverseRealFFT(status->statusPtr, &rv, Hvec, pinv); - CHECKSTATUSPTR (status); + if (XLALREAL4ReverseFFT(&rv, Hvec, pinv) != 0) + ABORTXLAL(status); - LALDestroyRealFFTPlan(status->statusPtr, &pinv); - CHECKSTATUSPTR (status); + XLALDestroyREAL4FFTPlan(pinv); - LALDestroyRealFFTPlan(status->statusPtr, &pfwd); - CHECKSTATUSPTR (status); + XLALDestroyREAL4FFTPlan(pfwd); LALCDestroyVector( status->statusPtr, &Hvec); CHECKSTATUSPTR (status); diff --git a/lal/packages/tools/include/Calibration.h b/lal/packages/tools/include/Calibration.h index 1a049f5c1f3934b0124af40ae41d1e87791bb3e5..b63b18d76e8de5cdd0062ee9311182a9dc2851ea 100644 --- a/lal/packages/tools/include/Calibration.h +++ b/lal/packages/tools/include/Calibration.h @@ -237,11 +237,15 @@ struct StrainInTag { REAL4TimeSeries DARM_ERR;/* timeseries containing DARM_ERR */ REAL4TimeSeries DARM ; /* timeseries containing DARM_CTRL */ REAL4TimeSeries EXC ; /* timeseries containing the excitation */ + REAL4TimeSeries StateVector; /* timeseries containing the State Vector (IFO-SV_STATE_VECTOR) */ + REAL4TimeSeries LAX; /* timeseries containing the Light-in-X-arm (LSC-LA_PTRX_NORM) */ + REAL4TimeSeries LAY; /* timeseries containing the Light-in-Y-arm (LSC-LA_PTRY_NORM) */ COMPLEX16 Do; /* digital filter at cal line frequency */ COMPLEX16 Go; /* OLG at cal line frequency */ COMPLEX16 Wo; /* Whitening filter at cal line frequency */ REAL8 f; /* calibration line frequency */ REAL4 To; /* factors integration time */ + char filter_vc_info[1024]; /* version control information in the filters file */ REAL8IIRFilter *Cinv; /* Filters for inverse of sensing function */ INT4 CinvUSF; /* Upsampling factor for sensing function */ INT4 CinvDelay; /* Overall inverse sensing function delay */ @@ -361,6 +365,7 @@ int XLALDivideTimeSeries(REAL8TimeSeries *hR, REAL8TimeSeries *ALPHAS); int XLALUpsample(REAL8TimeSeries *uphR, REAL8TimeSeries *hR, int up_factor); int XLALUpsampleLinear(REAL8TimeSeries *uphR, REAL8TimeSeries *hR, int up_factor); + #ifdef __cplusplus #pragma { /** to match the next brace **/ } diff --git a/lal/packages/tools/include/LIGOMetadataUtils.h b/lal/packages/tools/include/LIGOMetadataUtils.h index afb6068392a3150273d69802b8e75e51749f216a..cf21983671bc7c68409730a73a25e09548204d44 100644 --- a/lal/packages/tools/include/LIGOMetadataUtils.h +++ b/lal/packages/tools/include/LIGOMetadataUtils.h @@ -332,7 +332,8 @@ typedef enum ring_inject, imr_inject, imr_ring_inject, - EOBNR_inject + EOBNR_inject, + Phenom_inject } inject_type; @@ -1592,7 +1593,17 @@ XLALCoincSimRingdownTest ( CoincRingdownTable **missedCoincHead ); +REAL8 +XLAL2DRinca( + SnglRingdownTable *aPtr, + SnglRingdownTable *bPtr + ); +REAL8 +XLAL3DRinca( + SnglRingdownTable *aPtr, + SnglRingdownTable *bPtr + ); /* coinc ringdown */ diff --git a/lal/packages/tools/include/TrigScanEThincaCommon.h b/lal/packages/tools/include/TrigScanEThincaCommon.h index c4f4e60390592493464c9e31995a990384fb7628..2e6960c84c410d3135bbadfe8dc5adaa86754d98 100644 --- a/lal/packages/tools/include/TrigScanEThincaCommon.h +++ b/lal/packages/tools/include/TrigScanEThincaCommon.h @@ -67,6 +67,8 @@ TriggerErrorList * XLALCreateTriggerErrorList( SnglInspiralTable *tableHead, void XLALDestroyTriggerErrorList( TriggerErrorList *errorListHead ); +REAL8 XLALSnglInspiralTimeError(const SnglInspiralTable *table, REAL8 eMatch); + #ifdef __cplusplus } #endif diff --git a/lal/packages/tools/src/CoincInspiralEllipsoid.c b/lal/packages/tools/src/CoincInspiralEllipsoid.c index 08d88727b8667a92fa39523e780934a824b47b0d..29b45481627e09025e10e6159fe4945b530778e6 100644 --- a/lal/packages/tools/src/CoincInspiralEllipsoid.c +++ b/lal/packages/tools/src/CoincInspiralEllipsoid.c @@ -234,7 +234,9 @@ LALCreateTwoIFOCoincListEllipsoid( /* Check whether the event was coincident */ if ( match ) { +#if 0 REAL8 etp = XLALCalculateEThincaParameter( currentError[0]->trigger, currentError[1]->trigger, accuracyParams ); +#endif /* create a 2 IFO coinc and store */ if ( ! coincHead ) { diff --git a/lal/packages/tools/src/CoincInspiralUtils.c b/lal/packages/tools/src/CoincInspiralUtils.c index b5b4e76694d5a9aff65ee03ec8bbebf8ce7916e8..e525d9f33bbf6a36f35d85bd945ee969818e5528 100644 --- a/lal/packages/tools/src/CoincInspiralUtils.c +++ b/lal/packages/tools/src/CoincInspiralUtils.c @@ -887,7 +887,7 @@ XLALExtractSnglInspiralFromCoinc( ) /* </lalVerbatim> */ { - /*static const char *func = "ExtractSnglInspiralFromCoinc";*/ + static const char *func = "ExtractSnglInspiralFromCoinc"; SnglInspiralTable *snglHead = NULL; SnglInspiralTable *thisSngl = NULL; SnglInspiralTable *thisCoincEntry = NULL; @@ -904,9 +904,6 @@ XLALExtractSnglInspiralFromCoinc( return( NULL ); } - /* gpsStartTime is unused in this function */ - gpsStartTime = NULL; - /* loop over the linked list of coinc inspirals */ for( thisCoinc = coincInspiral; thisCoinc; thisCoinc = thisCoinc->next, ++eventNum) @@ -941,16 +938,23 @@ XLALExtractSnglInspiralFromCoinc( /* event id number exists, use it */ eventId->id = thisCoincEntry->event_id->id; } - else if ( eventNum > 99999 ) + else if ( gpsStartTime ) { - /* put extra digits into overflow area (above slide number) */ - eventId->id = ( LAL_INT8_C(1000000000) * (INT8) (eventNum / 100000) ) - + (INT8) (eventNum % 100000); + eventId->id = LAL_INT8_C(1000000000) * + (INT8) (gpsStartTime->gpsSeconds + eventNum/100000) + + (INT8) (eventNum % 100000); } else { - /* just set eventId equal to eventNum */ - eventId->id = (INT8) eventNum; + XLALPrintError( + "Event does not have id and no GPS start time given" ); + while ( snglHead ) + { + thisSngl = snglHead; + snglHead = snglHead->next; + XLALFreeSnglInspiral( &thisSngl ); + } + XLAL_ERROR_NULL(func,XLAL_EIO); } if ( slideNum < 0 ) @@ -1353,7 +1357,7 @@ XLALGenerateCoherentBank( currentTrigger->next = NULL; currentTrigger->event_id = NULL; /* set the ifo */ - snprintf( currentTrigger->ifo, LIGOMETA_IFO_MAX, ifo ); + snprintf(currentTrigger->ifo, LIGOMETA_IFO_MAX, "%s", ifo); /* set the event id */ currentTrigger->event_id = LALCalloc( 1, sizeof(EventIDColumn) ); if ( !(currentTrigger->event_id) ) diff --git a/lal/packages/tools/src/ComputeDataQualityVector.c b/lal/packages/tools/src/ComputeDataQualityVector.c index 805caa3b4f23e091150adc3394efb3a074575350..20a813c6d9406a22248c2bc1fa87a28a31b77642 100644 --- a/lal/packages/tools/src/ComputeDataQualityVector.c +++ b/lal/packages/tools/src/ComputeDataQualityVector.c @@ -95,6 +95,7 @@ int XLALComputeDQ(REAL4* sv_data, int r_sv, } light = (sum_x/r_light > 100 && sum_y/r_light > 100); + /* "is the mean higher than 100 for both arms?" */ /* science, injection, up (stuff coming from the state vector) */ science = 1; /* in science mode */ diff --git a/lal/packages/tools/src/ComputeStrain.c b/lal/packages/tools/src/ComputeStrain.c index 8b0984c9e7b2daccc7311fee57a4e8570f7a1cc7..f8a45fddfa78aba78fc9dea6685fd8c58ade0511 100644 --- a/lal/packages/tools/src/ComputeStrain.c +++ b/lal/packages/tools/src/ComputeStrain.c @@ -70,6 +70,14 @@ None NRCSID( COMPUTESTRAINC, "$Id$" ); RCSID("$Id$"); + +/* Local helper functions, defined static so they cannot be used outside. */ +static void set_output_to_zero(StrainOut *output); +static void check_nans_infs(LALStatus *status, StrainIn *input); +static void remove_transients(StrainIn *input); + + + void LALComputeStrain( LALStatus *status, StrainOut *output, @@ -86,6 +94,13 @@ REAL8IIRFilter ALPHASLPFIR; INITSTATUS( status, "LALComputeStrain", COMPUTESTRAINC ); ATTATCHSTATUSPTR( status ); + set_output_to_zero(output); + + remove_transients(input); + + check_nans_infs(status, input); + if (! status->statusPtr) return; + LALGetFactors(status->statusPtr, output, input); CHECKSTATUSPTR( status ); @@ -270,7 +285,7 @@ REAL8IIRFilter ALPHASLPFIR; } else { - XLALFIRFilter(&(output->hC), input->A); + XLALFIRFilter(&(output->hC), input->AW); } }else { @@ -764,10 +779,12 @@ void LALFFTFIRFilter(LALStatus *status, REAL8TimeSeries *tseries, REAL8IIRFilter ABORTXLAL( status ); /* make fft plans */ - LALCreateForwardREAL8FFTPlan(status->statusPtr, &fplan, tseriesDATA->data->length, 0 ); - CHECKSTATUSPTR( status ); - LALCreateReverseREAL8FFTPlan(status->statusPtr, &rplan, tseriesDATA->data->length, 0 ); - CHECKSTATUSPTR( status ); + fplan = XLALCreateForwardREAL8FFTPlan(tseriesDATA->data->length, 0 ); + if (fplan == NULL) + ABORTXLAL(status); + rplan = XLALCreateReverseREAL8FFTPlan(tseriesDATA->data->length, 0 ); + if (rplan == NULL) + ABORTXLAL(status); /* fft both series */ xlerr=XLALREAL8TimeFreqFFT(vtilde, tseriesDATA, fplan); @@ -809,10 +826,8 @@ void LALFFTFIRFilter(LALStatus *status, REAL8TimeSeries *tseries, REAL8IIRFilter } /* Destroy everything */ - LALDestroyREAL8FFTPlan( status->statusPtr, &fplan ); - CHECKSTATUSPTR( status ); - LALDestroyREAL8FFTPlan( status->statusPtr, &rplan ); - CHECKSTATUSPTR( status ); + XLALDestroyREAL8FFTPlan(fplan); + XLALDestroyREAL8FFTPlan(rplan); XLALDestroyCOMPLEX16FrequencySeries(vtilde); XLALDestroyCOMPLEX16FrequencySeries(vtildeFIR); @@ -824,3 +839,136 @@ void LALFFTFIRFilter(LALStatus *status, REAL8TimeSeries *tseries, REAL8IIRFilter } + + +/* + * Check if there are any nans or infs in the input data. + */ +static void check_nans_infs(LALStatus *status, StrainIn *input) +{ + UINT4 p; + + /* Check if there are nans or infs in DARM_ERR */ + for (p=0; p < input->DARM_ERR.data->length; p++) { + REAL4 x = input->DARM_ERR.data->data[p]; + if (isnan(x) || isinf(x)) { + fprintf(stderr, "ERROR: bad DARM_ERR\n"); + ABORT(status, 1, "Bad DARM_ERR"); + } + } + + /* Same thing for DARM_CTRL if we use it */ + if (input->darmctrl) { + for (p=0; p < input->DARM.data->length; p++) { + REAL4 x = input->DARM.data->data[p]; + if (isnan(x) || isinf(x)) { + fprintf(stderr, "ERROR: bad DARM_CTRL\n"); + ABORT(status, 2, "Bad DARM_CTRL"); + } + } + } +} + + + + +static void set_output_to_zero(StrainOut *output) +{ + memset(output->h.data->data, 0, output->h.data->length * sizeof(REAL8)); + memset(output->hR.data->data, 0, output->hR.data->length * sizeof(REAL8)); + memset(output->hC.data->data, 0, output->hC.data->length * sizeof(REAL8)); + memset(output->alpha.data->data, 0, output->alpha.data->length * sizeof(COMPLEX16)); + memset(output->beta.data->data, 0, output->beta.data->length * sizeof(COMPLEX16)); + memset(output->alphabeta.data->data, 0, output->alphabeta.data->length * sizeof(COMPLEX16)); +} + + + +/* + * Put DARM_ERR and DARM_CTRL to 0 if the detector is not UP. That + * way, we remove the huge transients with the new DC readout scheme. + * + * Also, even if the detector is UP, if DARM_ERR is way too big (~> 1) + * or its derivative (~> 1e-3), assume we have a glitch. + */ +static void remove_transients(StrainIn *input) +{ + int i, j; /* counters */ + float sum_x, sum_y; + int light; /* is there light in the arms? */ + int up; /* state vector up bit */ + + int nsecs; /* number of seconds of data */ + int r_sv, r_light, r_darm; /* samples per second */ + + const double DARM_ERR_THRESHOLD = 1e0; + int derr_small; /* is DARM_ERR believably small? */ + const double DERIV_THRESHOLD = 1e-3; + int deriv_small; /* is the derivative of DARM_ERR believably small? */ + + nsecs = (int) (input->DARM_ERR.data->length * input->DARM_ERR.deltaT); + + r_sv = input->StateVector.data->length / nsecs; /* # of IFO-SV_STATE_VECTOR per second */ + r_light = input->LAX.data->length / nsecs; /* # of LSC-LA_PTRX_NORM per second */ + r_darm = input->DARM_ERR.data->length / nsecs; /* # of DARM_ERR per second */ + + /* For each second, check the conditions and put DARM_* to 0 if not met */ + for (i = 0; i < nsecs; i++) { + /* + * Is the detector UP? (state vector UP during the whole + * second, and light in the arms) + */ + + /* light */ + sum_x = 0; + sum_y = 0; + for (j = 0; j < r_light; j++) { + sum_x += input->LAX.data->data[i*r_light + j]; + sum_y += input->LAY.data->data[i*r_light + j]; + } + + light = (sum_x/r_light > 100 && sum_y/r_light > 100); + /* "is the mean higher than 100 for both arms?" */ + + /* state vector up */ + up = 1; + + for (j = 0; j < r_sv; j++) { + /* convert from float to int, and take the third rightmost bit */ + int s = (int) input->StateVector.data->data[i*r_sv + j]; + if ((s & (1 << 2)) == 0) up = 0; + } + + up = up && light; /* this is the "up" definition of the DQ vector */ + + /* DARM_ERR below threshold */ + REAL4 *derr = input->DARM_ERR.data->data; /* for short notation */ + derr_small = 1; + for (j = 0; j < r_darm; j++) + if (fabs(derr[i*r_darm + j]) > DARM_ERR_THRESHOLD) + derr_small = 0; + + /* DARM_ERR derivative below threshold */ + deriv_small = 1; + for (j = 0; j < r_darm-1; j++) + if (fabs(derr[i*r_darm + j+1] - derr[i*r_darm + j]) > DERIV_THRESHOLD) + deriv_small = 0; + + /* + * Scare the users. + */ + if (up && !(derr_small && deriv_small)) + fprintf(stderr, "WARNING: glitch found by non-conventional methods. " + "Zeroing presumed bad data so it doesn't affect the rest of the frame.\n"); + + /* + * Put DARM_ERR and DARM_CTRL to 0 if we don't meet the conditions. + */ + if (! (up && derr_small && deriv_small) ) { + for (j = 0; j < r_darm; j++) { + input->DARM_ERR.data->data[i*r_darm + j] = 0.0; + input->DARM.data->data[i*r_darm + j] = 0.0; + } + } + } +} diff --git a/lal/packages/tools/src/SimInspiralUtils.c b/lal/packages/tools/src/SimInspiralUtils.c index 874776805594b14478da74f829fec9c17bbae2ef..3a71e0f9984cf4e508aec9e1f96f09daaadcc258 100644 --- a/lal/packages/tools/src/SimInspiralUtils.c +++ b/lal/packages/tools/src/SimInspiralUtils.c @@ -38,6 +38,8 @@ $Id$ #include <math.h> #include <stdio.h> #include <stdlib.h> +#include <lal/LALErrno.h> +#include <lal/XLALError.h> #include <lal/LALStdlib.h> #include <lal/LALStdio.h> #include <lal/LIGOMetadataTables.h> @@ -454,7 +456,6 @@ LALGalacticInspiralParamsToSimInspiralTable( /* </lalVerbatim> */ { PPNParamStruc ppnParams; - LALMSTUnitsAndAcc gmstUnits = { MST_HRS, LALLEAPSEC_STRICT }; LALGPSandAcc gpsAndAcc; SkyPosition skyPos; LALSource source; @@ -509,10 +510,10 @@ LALGalacticInspiralParamsToSimInspiralTable( /* populate geocentric end time */ output->geocent_end_time = input->geocentEndTime; - /* populate gmst field */ - LALGPStoGMST1( status->statusPtr, &(output->end_time_gmst), - &(output->geocent_end_time), &gmstUnits ); - CHECKSTATUSPTR( status ); + /* populate gmst field (hours) */ + output->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &output->geocent_end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours*/ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(output->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); /* set up params for the site end times and detector response */ memset( &skyPos, 0, sizeof(SkyPosition) ); diff --git a/lal/packages/tools/src/SnglRingdownUtils.c b/lal/packages/tools/src/SnglRingdownUtils.c index f74863c22d7e12213eb1975fc5373235b46de931..538b9f1796d2940bc5dc5cd031dc67017cae0cac 100644 --- a/lal/packages/tools/src/SnglRingdownUtils.c +++ b/lal/packages/tools/src/SnglRingdownUtils.c @@ -45,6 +45,7 @@ $Id$ #include <lal/LIGOMetadataUtils.h> #include <lal/Date.h> #include <lal/SkyCoordinates.h> +#include <lal/LALSimulation.h> #include <lal/DetectorSite.h> #include <lal/DetResponse.h> #include <lal/TimeDelay.h> @@ -335,6 +336,9 @@ LALCompareSnglRingdownByTime ( +/** Compare theparameters of two ringdown triggers according to + * the specified coincidence test. + */ /* <lalVerbatim file="SnglInspiralUtilsCP"> */ void LALCompareRingdowns ( @@ -345,20 +349,26 @@ LALCompareRingdowns ( ) /* </lalVerbatim> */ { - INT8 ta, tb; - REAL4 df, dQ; - REAL4 fa, fb, Qa, Qb; - REAL4 dsab = 0; - REAL4 dsba = 0; - REAL8 step = 1./params->minimizerStep; - InterferometerNumber ifoaNum, ifobNum; - SnglRingdownAccuracy aAcc, bAcc; - INITSTATUS( status, "LALCompareRingdowns", SNGLRINGDOWNUTILSC ); ATTATCHSTATUSPTR( status ); + SnglRingdownAccuracy aAcc, bAcc; + InterferometerNumber ifoaNum, ifobNum; + REAL8 ds2 = 0; + INT8 ta, tb; + const LALDetector *aDet; + const LALDetector *bDet; + ifoaNum = XLALIFONumber( aPtr->ifo ); + ifobNum = XLALIFONumber( bPtr->ifo ); + aAcc = params->ifoAccuracy[ifoaNum]; + bAcc = params->ifoAccuracy[ifobNum]; + ta = XLALGPSToINT8NS( &(aPtr->start_time) ); + tb = XLALGPSToINT8NS( &(bPtr->start_time) ); params->match = 1; + aDet = XLALInstrumentNameToLALDetector(aPtr->ifo); + bDet = XLALInstrumentNameToLALDetector(bPtr->ifo); + /* check that triggers come from different IFOs */ if( strcmp(aPtr->ifo, bPtr->ifo) ) @@ -373,112 +383,52 @@ LALCompareRingdowns ( goto exit; } - ifoaNum = XLALIFONumber( aPtr->ifo ); - ifobNum = XLALIFONumber( bPtr->ifo ); - - ta = XLALGPSToINT8NS( &(aPtr->start_time) ); - tb = XLALGPSToINT8NS( &(bPtr->start_time) ); - - /* compare on trigger time coincidence */ - aAcc = params->ifoAccuracy[ifoaNum]; - bAcc = params->ifoAccuracy[ifobNum]; - + /* Make sure triggers lie within a reasonable time window */ if ( labs( ta - tb ) < (aAcc.dt + bAcc.dt) - + params->lightTravelTime[ifoaNum][ifobNum]) + + 1.e-9 * XLALLightTravelTime(aDet,bDet) ) { - LALInfo( status, "Triggers pass time coincidence test"); params->match = 1; } else { - LALInfo( status, "Triggers fail time coincidence test" ); params->match = 0; - goto exit; } /* compare f and Q parameters */ if ( params->test == f_and_Q ) { - df = fabs( aPtr->frequency - bPtr->frequency ); - dQ = fabs( aPtr->quality - bPtr->quality ); - - if ( ( df <= (aAcc.df + bAcc.df) ) - && ( dQ <= (aAcc.dQ + bAcc.dQ) )) + if( (fabs( aPtr->frequency - bPtr->frequency ) <= (aAcc.df + bAcc.df) ) + && (fabs( aPtr->quality - bPtr->quality ) <= (aAcc.dQ + bAcc.dQ) ) ) { - LALInfo( status, "Triggers are coincident in f and Q" ); params->match = 1; } else { - LALInfo( status, "Triggers are not coincident in f and Q" ); params->match = 0; - goto exit; } } - else if ( params->test == ds_sq || params->test == ds_sq_fQt ) + else if ( params->test == ds_sq ) { - fa = aPtr->frequency; - fb = bPtr->frequency; - Qa = aPtr->quality; - Qb = bPtr->quality; - - if ( params->test == ds_sq ) + ds2 = XLAL2DRinca( aPtr, bPtr ); + if ( ds2 < (aAcc.ds_sq + bAcc.ds_sq)/2. ) { - dsab = XLAL2DRingMetricDistance( fa, fb, Qa, Qb ); - dsba = XLAL2DRingMetricDistance( fb, fa, Qb, Qa ); + params->match = 1; } - else if ( params->test == ds_sq_fQt ) + else { - REAL8 dtab = 1.e-9 * (tb - ta); - REAL8 dt_min = dtab - 1.e-9 * fabs(params->lightTravelTime[ifoaNum][ifobNum]); - REAL8 dt_max = dtab + 1.e-9 * fabs(params->lightTravelTime[ifoaNum][ifobNum]); - REAL4 ds2_min = XLAL3DRingMetricDistance( fa, fb, Qa, Qb, dtab ); - REAL8 dt; - - /* estimate true time delay */ - for ( dt = dt_min ; dt < dt_max ; dt += step ) - { - REAL4 ds2 = XLAL3DRingMetricDistance( fa, fb, Qa, Qb, dt ); - if (ds2 < ds2_min) ds2_min = ds2; - } - - dsab = ds2_min; - dsba = ds2_min; + params->match = 0; } - if ( (dsab + dsba)/2. < (aAcc.ds_sq + bAcc.ds_sq)/2. ) + } + else if ( params->test == ds_sq_fQt ) + { + ds2 = XLAL3DRinca( aPtr, bPtr ); + if ( ds2 < (aAcc.ds_sq + bAcc.ds_sq)/2. ) { - LALInfo( status, "Triggers pass the ds_sq coincidence test" ); params->match = 1; - if ( (strcmp(aPtr->ifo,"H1")==0 && strcmp(bPtr->ifo,"H2")==0) - ||(strcmp(aPtr->ifo,"H2")==0 && strcmp(bPtr->ifo,"H1")==0) ) - { - aPtr->ds2_H1H2=dsab; - bPtr->ds2_H1H2=dsba; - } - else if( (strcmp(aPtr->ifo,"H1")==0 && strcmp(bPtr->ifo,"L1")==0) - || (strcmp(aPtr->ifo,"L1")==0 && strcmp(bPtr->ifo,"H1")==0) ) - { - aPtr->ds2_H1L1=dsab; - bPtr->ds2_H1L1=dsba; - } - else if( (strcmp(aPtr->ifo,"H2")==0 && strcmp(bPtr->ifo,"L1")==0) - || (strcmp(aPtr->ifo,"L1")==0 && strcmp(bPtr->ifo,"H2")==0) ) - { - aPtr->ds2_H2L1=dsab; - bPtr->ds2_H2L1=dsba; - } - else - { - LALInfo( status, "Unknown pair of ifo's" ); - params->match = 0; - goto exit; - } } else { - LALInfo( status, "Triggers fail the ds_sq coincidence test" ); params->match = 0; - goto exit; } } else @@ -487,13 +437,106 @@ LALCompareRingdowns ( params->match = 0; goto exit; } - -exit: + exit: DETATCHSTATUSPTR (status); RETURN (status); } +/** Two dimensional (frequency and quality) coincidence test */ +REAL8 +XLAL2DRinca( + SnglRingdownTable *aPtr, + SnglRingdownTable *bPtr + ) +{ + REAL8 fa, fb, Qa, Qb; + REAL8 dsab = 0; + REAL8 dsba = 0; + + fa = aPtr->frequency; + fb = bPtr->frequency; + Qa = aPtr->quality; + Qb = bPtr->quality; + + dsab = XLAL2DRingMetricDistance( fa, fb, Qa, Qb ); + dsba = XLAL2DRingMetricDistance( fb, fa, Qb, Qa ); + + return ( (dsab + dsba)/2. ); +} + +/** Three dimensional (time, frequency and quality) coincidence test */ +REAL8 +XLAL3DRinca( + SnglRingdownTable *aPtr, + SnglRingdownTable *bPtr + ) +{ + + INT8 ta, tb; + REAL8 fa, fb, Qa, Qb, ds2_min; + REAL8 step = 1./16384.; + REAL8 dtab, dtba, dt_min, dt_max, dt_min_ab, dt_min_ba, dt_max_ab, dt_max_ba, dt; + const LALDetector *aDet; + const LALDetector *bDet; + fa = aPtr->frequency; + fb = bPtr->frequency; + Qa = aPtr->quality; + Qb = bPtr->quality; + ta = XLALGPSToINT8NS( &(aPtr->start_time) ); + tb = XLALGPSToINT8NS( &(bPtr->start_time) ); + + dtab = 1.e-9 * (tb - ta); + dtba = 1.e-9 * (ta - tb); + aDet = XLALInstrumentNameToLALDetector(aPtr->ifo); + bDet = XLALInstrumentNameToLALDetector(bPtr->ifo); + + dt_min_ab = dtab - 1.e-9 * XLALLightTravelTime(aDet,bDet); + dt_min_ba = dtba - 1.e-9 * XLALLightTravelTime(aDet,bDet); + dt_max_ab = dtab + 1.e-9 * XLALLightTravelTime(aDet,bDet); + dt_max_ba = dtba + 1.e-9 * XLALLightTravelTime(aDet,bDet); + + /* Search over extended dt loop so ifo order is not an issue */ + + if ( dt_min_ab < dt_min_ba ) + { + dt_min = dt_min_ab; + } + else + { + dt_min = dt_min_ba; + } + + if ( dt_max_ab > dt_max_ba ) + { + dt_max = dt_max_ab; + } + else + { + dt_max = dt_max_ba; + } + + ds2_min = XLAL3DRingMetricDistance( fa, fb, Qa, Qb, dtab ); + + /* if ifos are H1H2 then no need to account for light travel time */ + + if ( (strcmp(aPtr->ifo,"H1")==0 && strcmp(bPtr->ifo,"H2")==0) + ||(strcmp(aPtr->ifo,"H2")==0 && strcmp(bPtr->ifo,"H1")==0) ) + { + return ( ds2_min ); + } + else + { + /* estimate true time delay for non-H1H2 ifo combinations*/ + for ( dt = dt_min ; dt < dt_max ; dt += step ) + { + REAL8 ds2 = XLAL3DRingMetricDistance( fa, fb, Qa, Qb, dt ); + if (ds2 < ds2_min) ds2_min = ds2; + } + return ( ds2_min ); + } +} + /* <lalVerbatim file="SnglRingdownUtilsCP"> */ void diff --git a/lal/packages/tools/src/TrigScanEThincaCommon.c b/lal/packages/tools/src/TrigScanEThincaCommon.c index a7f366be0e5fa37bb853a8e3bec473c15619dff8..94fa6ef206fdc60275253c95fcabd7054cb96eca 100644 --- a/lal/packages/tools/src/TrigScanEThincaCommon.c +++ b/lal/packages/tools/src/TrigScanEThincaCommon.c @@ -68,7 +68,6 @@ TrigScan and E-thinca have completed. </lalLaTeX> #endif -static REAL8 getTimeError(const SnglInspiralTable *table, REAL8 eMatch); /* <lalVerbatim file="TrigScanEThincaCommonCP"> */ TriggerErrorList * XLALCreateTriggerErrorList( SnglInspiralTable *tableHead, @@ -131,7 +130,7 @@ TriggerErrorList * XLALCreateTriggerErrorList( SnglInspiralTable *tableHead, XLALDestroyTriggerErrorList( errorListHead ); XLAL_ERROR_NULL( func, XLAL_EFUNC ); } - thisTimeError = getTimeError(currentTrigger, scaleFactor ); + thisTimeError = XLALSnglInspiralTimeError(currentTrigger, scaleFactor ); if (thisTimeError > timeError) { timeError = thisTimeError; @@ -165,27 +164,33 @@ void XLALDestroyTriggerErrorList( TriggerErrorList *errorListHead ) } } -static REAL8 getTimeError(const SnglInspiralTable *table, REAL8 eMatch) + +/** + * Using the waveform metric components, translate an "e-thinca" treshold + * into a \Delta t error interval. + */ + + +REAL8 XLALSnglInspiralTimeError(const SnglInspiralTable *table, REAL8 eMatch) { - REAL8 a11; - REAL8 a23; - REAL8 a22; - REAL8 a33; - REAL8 a12; - REAL8 a13; + static const char func[] = "XLALSnglInspiralTimeError"; + REAL8 a11 = table->Gamma[0] / eMatch; + REAL8 a12 = table->Gamma[1] / eMatch; + REAL8 a13 = table->Gamma[2] / eMatch; + REAL8 a22 = table->Gamma[3] / eMatch; + REAL8 a23 = table->Gamma[4] / eMatch; + REAL8 a33 = table->Gamma[5] / eMatch; REAL8 x; REAL8 denom; - a11 = table->Gamma[0] / eMatch; - a12 = table->Gamma[1] / eMatch; - a13 = table->Gamma[2] / eMatch; - a22 = table->Gamma[3] / eMatch; - a23 = table->Gamma[4] / eMatch; - a33 = table->Gamma[5] / eMatch; - x = (a23 * a23 - a22 * a33) * a22; denom = (a12*a23 - a22*a13) * (a12*a23 - a22*a13) - (a23*a23 - a22*a33) * (a12*a12 - a22*a11); - return ( sqrt( x / denom )); + if (denom == 0) + XLAL_ERROR_REAL8(func, XLAL_EFPDIV0); + if ((x < 0) ^ (denom < 0)) + XLAL_ERROR_REAL8(func, XLAL_EFPINVAL); + + return sqrt( x / denom ); } diff --git a/lal/packages/tools/test/LALIndependentTestDetResponse.c b/lal/packages/tools/test/LALIndependentTestDetResponse.c index 82937cc4ca04d77e967c0d1a0f3a95f42486865e..36a6f90a38498847865e5d1bf53f194fcb765993 100644 --- a/lal/packages/tools/test/LALIndependentTestDetResponse.c +++ b/lal/packages/tools/test/LALIndependentTestDetResponse.c @@ -56,7 +56,7 @@ the model given in Jaranowski, Krolak, and Schutz gr-qc/9804014. 10/14/04 gam: Update definition of lal_gamma when angle between arms, zeta, != pi/2. 10/14/04 gam: Change input RA, DEC and orientation angle (polarization angle) in config file to be in radians. 10/14/04 gam: Use independent detector geometry values when doing independent calculation. -10/15/04 gam: Fix bug M_PI not defined when configuring lal with --with-gcc-flags. +10/15/04 gam: Fix bug M_PI not defined when configuring lal with --enable-gcc-flags. WARNING: LHO AND LLO VALUES WERE TAKEN FROM OTHER LIGO SOURCES; GEO VALUES ARE NOT INDEPENDENT BUT TAKEN FROM LAL */ @@ -178,12 +178,6 @@ int main( int argc, char *argv[] ) REAL8 phiStart = 0.0; REAL8 phiStartLAL = 0.0; /* 10/13/04 gam */ - /* LALMSTUnitsAndAcc uandacc = { MST_RAD, LALLEAPSEC_STRICT}; */ /* 05/20/03 gam */ - LALMSTUnitsAndAcc uandacc; /* 05/20/03 gam */ - - uandacc.units = MST_RAD; - uandacc.accuracy = LALLEAPSEC_STRICT; - /* parse options */ if( argc == 1) { @@ -729,16 +723,11 @@ void GenerateResponseFuncUsingLAL(LALStatus *status, LALSource *pulsar, LALDetec LALTimeIntervalAndNSample time_info; - /* LALMSTUnitsAndAcc uandacc = { MST_RAD, LALLEAPSEC_STRICT}; */ /* 05/20/03 gam */ - LALMSTUnitsAndAcc uandacc; /* 05/20/03 gam */ LALGPSandAcc gps_and_acc; /* 05/20/03 gam */ INITSTATUS (status, "GenerateResponseFuncUsingLAL", LALINDEPENDENTTESTDETRESPONSEC); ATTATCHSTATUSPTR(status); - uandacc.units = MST_RAD; - uandacc.accuracy = LALLEAPSEC_STRICT; - if (lalDebugLevel > 1) { /* fprintf(stdout,"status->statusCode = %i \n", status->statusCode); fprintf(stdout,"status->statusPtr->statusCode = %i \n", status->statusPtr->statusCode); */ diff --git a/lal/packages/tools/test/LALTestDetResponse0.c b/lal/packages/tools/test/LALTestDetResponse0.c index b453745895f789d942be0ff6eba0c0da96423d92..2cb2bf6ae704eaae27ba3f38f9181778a225e1df 100644 --- a/lal/packages/tools/test/LALTestDetResponse0.c +++ b/lal/packages/tools/test/LALTestDetResponse0.c @@ -55,6 +55,7 @@ LALComputeDetAMResponse() #include <string.h> #include <math.h> #include <errno.h> +#include <time.h> #include <lal/LALConfig.h> #include <lal/AVFactories.h> @@ -828,7 +829,7 @@ int main(int argc, char *argv[]) LALFrDetector frdet; /* Framelib detector info */ LALDetector detector; LIGOTimeGPS gps; - LALDate utcDate; + struct tm utcDate; LALLeapSecAccuracy accuracy = LALLEAPSEC_STRICT; LALGPSandAcc gps_and_acc; LALDetAndSource det_and_pulsar; @@ -851,7 +852,6 @@ int main(int argc, char *argv[]) REAL8 tmpgmst; REAL8 gmst1; - LALMSTUnitsAndAcc tmp_uandacc; skygrid_t plus; skygrid_t cross; @@ -1301,20 +1301,18 @@ int main(int argc, char *argv[]) return status.statusCode; } - utcDate.unixDate.tm_sec = 46; - utcDate.unixDate.tm_min = 20; - utcDate.unixDate.tm_hour = 8; - utcDate.unixDate.tm_mday = 17; - utcDate.unixDate.tm_mon = LALMONTH_MAY; - utcDate.unixDate.tm_year = 1994 - 1900; + utcDate.tm_sec = 46; + utcDate.tm_min = 20; + utcDate.tm_hour = 8; + utcDate.tm_mday = 17; + utcDate.tm_mon = LALMONTH_MAY; + utcDate.tm_year = 1994 - 1900; + utcDate.tm_isdst = 1; + mktime(&utcDate); - /* accuracy = LALLEAPSEC_LOOSE; */ - LALUTCtoGPS(&status, &gps, &utcDate, &accuracy); + XLALGPSSet(&gps, XLALUTCToGPS(&utcDate), 0); - tmp_uandacc.units = MST_RAD; - tmp_uandacc.accuracy = accuracy; - - LALGPStoGMST1(&status, &tmpgmst, &gps, &tmp_uandacc); + tmpgmst = XLALGreenwichMeanSiderealTime(&gps); if (verbose_p) printf("GMST1 = % 14.9e rad.\n", tmpgmst); @@ -1342,7 +1340,6 @@ int main(int argc, char *argv[]) print_small_separator_maybe(); - /* switch detector to LHO */ detector = lalCachedDetectors[LALDetectorIndexLHODIFF]; @@ -1352,15 +1349,16 @@ int main(int argc, char *argv[]) pulsar.equatorialCoords.latitude = deg_to_rad(46.475430); pulsar.orientation = -LAL_PI_2; - utcDate.unixDate.tm_sec = 46; - utcDate.unixDate.tm_min = 20; - utcDate.unixDate.tm_hour = 8; - utcDate.unixDate.tm_mday = 17; - utcDate.unixDate.tm_mon = LALMONTH_MAY; - utcDate.unixDate.tm_year = 1994 - 1900; + utcDate.tm_sec = 46; + utcDate.tm_min = 20; + utcDate.tm_hour = 8; + utcDate.tm_mday = 17; + utcDate.tm_mon = LALMONTH_MAY; + utcDate.tm_year = 1994 - 1900; + utcDate.tm_isdst = 1; + mktime(&utcDate); - accuracy = LALLEAPSEC_LOOSE; - LALUTCtoGPS(&status, &gps, &utcDate, &accuracy); + XLALGPSSet(&gps, XLALUTCToGPS(&utcDate), 0); det_and_pulsar.pDetector = &detector; det_and_pulsar.pSource = &pulsar; @@ -1651,10 +1649,7 @@ int main(int argc, char *argv[]) for (k = 0; k < (int)time_info.nSample; ++k) { - LALMSTUnitsAndAcc uandacc; - uandacc.units = MST_RAD; - uandacc.accuracy = gps_and_acc.accuracy; - LALGPStoGMST1(&status, &gmst1, &(gps_and_acc.gps), &uandacc); + gmst1 = XLALGreenwichMeanSiderealTime(&gps_and_acc.gps); if (verbose_level & 16) printf("GRAR: k = %6d; gmst1 = % 20.14e\n", k, gmst1); @@ -2710,7 +2705,6 @@ void fudge_factor_test(LALStatus *status) LALSource pulsar; LALDetAndSource det_and_pulsar = { (LALDetector *)NULL, (LALSource *)NULL} ; - LALMSTUnitsAndAcc uandacc; LALDetAMResponse am_response; REAL8 gmst1 = 0.; @@ -2737,9 +2731,7 @@ void fudge_factor_test(LALStatus *status) gps_and_acc.gps.gpsSeconds = 13675020; gps_and_acc.gps.gpsNanoSeconds = 943728537; gps_and_acc.accuracy = LALLEAPSEC_STRICT; - uandacc.units = MST_RAD; - uandacc.accuracy = gps_and_acc.accuracy; - LALGPStoGMST1(status, &gmst1, &(gps_and_acc.gps), &uandacc); + gmst1 = XLALGreenwichMeanSiderealTime(&gps_and_acc.gps); if (verbose_level & 4) printf("gmst1 = % 20.14e\n", gmst1); @@ -2924,7 +2916,6 @@ void find_zero_gmst(LALStatus * status) REAL8 gmst1; LIGOTimeGPS gps; LALGPSandAcc gps_and_acc; - LALMSTUnitsAndAcc tmp_uandacc; LALTimeInterval interval; INT4 k; @@ -2933,8 +2924,6 @@ void find_zero_gmst(LALStatus * status) gps.gpsNanoSeconds = 943728500; gps_and_acc.gps = gps; gps_and_acc.accuracy = LALLEAPSEC_STRICT; - tmp_uandacc.units = MST_RAD; - tmp_uandacc.accuracy = gps_and_acc.accuracy; interval.seconds = 0; interval.nanoSeconds = 1; @@ -2944,8 +2933,7 @@ void find_zero_gmst(LALStatus * status) { /* to avoid printing out all the LAL INFO messages */ lalDebugLevel = 0; - LALGPStoGMST1(status, &gmst1, &(gps_and_acc.gps), - &tmp_uandacc); + gmst1 = XLALGreenwichMeanSiderealTime(&gps_and_acc.gps); printf("k = %9d; GPS = %d:%d;\t\tgmst1 = % 22.14e; gmst1-2*Pi = % 20.14e\n", k, gps_and_acc.gps.gpsSeconds, gps_and_acc.gps.gpsNanoSeconds, diff --git a/lal/packages/tools/test/Makefile.am b/lal/packages/tools/test/Makefile.am index cbd080037a0194a503b94f60f755f2938c79af37..763cf6c808fdbbdca57d1c1c6dcba29876bb45a6 100644 --- a/lal/packages/tools/test/Makefile.am +++ b/lal/packages/tools/test/Makefile.am @@ -1,13 +1,13 @@ ## Process this file with automake to produce Makefile.in -if FRAME +#if FRAME #NEED_FRAME = ResampleTimeSeriesTest ComputeCalibrationFactorsTest -NEED_FRAME = ResampleTimeSeriesTest +#NEED_FRAME = ResampleTimeSeriesTest #EXTRA_TEXSOURCES = -EXTRA_TEXSOURCES = ComputeCalibrationFactorsTest.c -else +#EXTRA_TEXSOURCES = ComputeCalibrationFactorsTest.c +#else NEED_FRAME = EXTRA_TEXSOURCES = ResampleTimeSeriesTest.c ComputeCalibrationFactorsTest.c -endif +#endif check_PROGRAMS = UnitsTest DetectorSiteTest LALTestDetResponse0 LALIndependentTestDetResponse ComputeTransferTest CoherentEstimationTest SegmentsTest $(NEED_FRAME) SequenceTest TimeSeriesTest FrequencySeriesTest UnitsTest_SOURCES = UnitsTest.c UnitsTest_LDADD = $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la @@ -29,20 +29,20 @@ SequenceTest_SOURCES = SequenceTest.c SequenceTest_LDADD = $(top_builddir)/lib/liblal.la TimeSeriesTest_SOURCES = TimeSeriesTest.c TimeSeriesTest_LDADD = $(top_builddir)/lib/liblal.la -if FRAME -ResampleTimeSeriesTest_SOURCES = ResampleTimeSeriesTest.c -ResampleTimeSeriesTest_LDADD = $(top_builddir)/packages/framedata/src/liblalframe.la $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la +#if FRAME +#ResampleTimeSeriesTest_SOURCES = ResampleTimeSeriesTest.c +#ResampleTimeSeriesTest_LDADD = $(top_builddir)/packages/framedata/src/liblalframe.la $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la #ComputeCalibrationFactorsTest_SOURCES = ComputeCalibrationFactorsTest.c #ComputeCalibrationFactorsTest_LDADD = $(top_builddir)/packages/framedata/src/liblalframe.la $(top_builddir)/packages/support/src/liblalsupport.la $(top_builddir)/lib/liblal.la -endif +#endif EXTRA_DIST = ResampleTimeSeriesTest.c ComputeCalibrationFactorsTest.c LALIndTestDetRes.sh indTestDetResLHO.cfg indTestDetResLLO.cfg indTestDetResGEO.cfg INCLUDES = -I$(top_builddir)/include -I$(srcdir)/../include -if FRAME +#if FRAME #TESTS = UnitsTest DetectorSiteTest LALTestDetResponse0 LALIndependentTestDetResponse ComputeTransferTest ComputeCalibrationFactorsTest SequenceTest TimeSeriesTest FrequencySeriesTest +#TESTS = UnitsTest DetectorSiteTest LALTestDetResponse0 LALIndependentTestDetResponse LALIndTestDetRes.sh ComputeTransferTest SequenceTest TimeSeriesTest FrequencySeriesTest +#else TESTS = UnitsTest DetectorSiteTest LALTestDetResponse0 LALIndependentTestDetResponse LALIndTestDetRes.sh ComputeTransferTest SequenceTest TimeSeriesTest FrequencySeriesTest -else -TESTS = UnitsTest DetectorSiteTest LALTestDetResponse0 LALIndependentTestDetResponse LALIndTestDetRes.sh ComputeTransferTest SequenceTest TimeSeriesTest FrequencySeriesTest -endif +#endif TESTS_ENVIRONMENT = 1>/dev/null 2>/dev/null MOSTLYCLEANFILES = .dvi-dep PrintVector.* transfer.out \ ff_diff_plus.txt ff_rms_diff_plus_vs_fudge.txt \ diff --git a/lal/packages/tools/test/SegmentsTest.c b/lal/packages/tools/test/SegmentsTest.c index 2a94a0b3e9465cf370e6ee5f491ccfd28c4de0ed..c359d1fd62b26ba90008e75276e3aa687b02317e 100644 --- a/lal/packages/tools/test/SegmentsTest.c +++ b/lal/packages/tools/test/SegmentsTest.c @@ -163,7 +163,7 @@ int main( int argc, char *argv[] ) INT4 infirst; } TestTime; - TestTime stime[] = { {{794284997,0}, 0}, + TestTime lalstime[] = { {{794284997,0}, 0}, {{794284998,0}, 8}, {{794284998,5}, 8}, {{794284999,5}, 0}, @@ -1079,7 +1079,7 @@ int main( int argc, char *argv[] ) } /* Loop over test times */ - for ( itime=0; itime < (INT4)sizeof(stime)/(INT4)sizeof(TestTime); itime++ ) { + for ( itime=0; itime < (INT4)sizeof(lalstime)/(INT4)sizeof(TestTime); itime++ ) { /* Loop over lastFound states */ for ( ilast = -1; ilast < nsegs; ilast++ ) { @@ -1095,7 +1095,7 @@ int main( int argc, char *argv[] ) "XLALSegListSearch - nsegs=%d, itime=%d, ilast=%d", nsegs, itime, ilast ); /* Do the search */ - segptr = XLALSegListSearch( &seglist2, &(stime[itime].gps) ); + segptr = XLALSegListSearch( &seglist2, &(lalstime[itime].gps) ); /* Check whether the function had an error */ if ( xlalErrno != 0 ) { @@ -1104,14 +1104,14 @@ int main( int argc, char *argv[] ) } /* Check that the result is correct */ - if ( stime[itime].infirst > 0 && nsegs >= stime[itime].infirst ) { + if ( lalstime[itime].infirst > 0 && nsegs >= lalstime[itime].infirst ) { /* The search should have found a match */ if ( ! segptr ) { FUNCFAIL( testname, "Failed to find a match" ); continue; } /* The matched segment should contain the time */ - if ( XLALGPSInSeg(&(stime[itime].gps),segptr) != 0 ) { + if ( XLALGPSInSeg(&(lalstime[itime].gps),segptr) != 0 ) { FUNCFAIL( testname, "Segment returned does not contain the time" ); continue; } diff --git a/lal/packages/tools/test/UnitsTest.c b/lal/packages/tools/test/UnitsTest.c index a5728c35e03e93ed93c149b686fd45ce7729fff1..df66a46a67a120c985473edad4341cec77a85909 100644 --- a/lal/packages/tools/test/UnitsTest.c +++ b/lal/packages/tools/test/UnitsTest.c @@ -466,7 +466,8 @@ int main( int argc, char *argv[] ) TestStatus(&status, CODES(UNITSH_ENONINT), UNITSTESTC_ECHK); printf(" PASS: %s\n", UNITSH_MSGENONINT); - unit1.unitNumerator[2] = 40000; + unit1.unitNumerator[2] = 20000; + unit1.unitNumerator[2] += 20000; power.numerator = 2; power.denominatorMinusOne = 0; LALUnitRaise( &status, &unit1, &unit1, &power ); diff --git a/lal/packages/tracksearch/src/TSData.c b/lal/packages/tracksearch/src/TSData.c index d7e7e150a71fa25ef15f948254b6250448b7c1e6..8bf493810cb7aa92ea2b0f7e8e251f0b44535bc0 100644 --- a/lal/packages/tracksearch/src/TSData.c +++ b/lal/packages/tracksearch/src/TSData.c @@ -30,7 +30,6 @@ #include <lal/TSData.h> #include <lal/TSSearch.h> -#include <lal/FrameCache.h> #include <lal/LALStdlib.h> /* macro to "use" unused function parameters */ diff --git a/lal/packages/vectorops/test/VectorIndexRangeTest.c b/lal/packages/vectorops/test/VectorIndexRangeTest.c index 6f4e71d08c2cb78058bb9cab8a8209fd715a26ec..965783eb4104c2c2bd1bc5c71388f8f9609e0e3d 100644 --- a/lal/packages/vectorops/test/VectorIndexRangeTest.c +++ b/lal/packages/vectorops/test/VectorIndexRangeTest.c @@ -165,7 +165,7 @@ main(int argc, char **argv) if (verbose_p) { printf(" - - - - - - - -\n"); - printf("y = %#x\n", (unsigned int)y); + printf("y = %p\n", (void *)y); printf("y->length = %d\n", y->length); } @@ -363,10 +363,10 @@ trail_status_maybe(LALStatus *status) if (lalDebugLevel & 15) { printf("TRAIL STATUS:\n"); - printf(" status = %#x\n", (unsigned int)status); + printf(" status = %p\n", (void *)status); if (status) - printf(" status->statusPtr = %#x\n", - (unsigned int)(status->statusPtr)); + printf(" status->statusPtr = %p\n", + (void *)(status->statusPtr)); printf("\n"); if (status) diff --git a/lal/packages/window/src/Window.c b/lal/packages/window/src/Window.c index 8550309ba75b761e530770888e933451053735f1..f34dae29f12ffac67b3ed00bbea9f77b277238fd 100644 --- a/lal/packages/window/src/Window.c +++ b/lal/packages/window/src/Window.c @@ -271,11 +271,11 @@ REAL4Window *XLALCreateREAL4WindowFromSequence(REAL4Sequence *sequence) /** - * Multiply a REAL8Sequence by a REAL8Window with a normalization that - * preserves the RMS of stationary noise. If the window's length is N and - * its sum-of-squares is S, then the input sequence is multiplied by the - * window and \sqrt{N / S}. Returns the address of the REAL8Sequence or - * NULL on failure. + * Multiply a REAL8Sequence in-place by a REAL8Window with a normalization + * that preserves the variance of a zero-mean stationary Gaussian random + * process. If the window's length is N samples and its sum-of-squares is + * S, then the input sequence is multiplied by the window * \sqrt{N / S}. + * Returns the address of the REAL8Sequence or NULL on failure. */ diff --git a/lalapps/.gitignore b/lalapps/.gitignore index b4e5fa6c11760ad031133d41ff59a954535d7710..3fcb9f97e13e6e9ee9311b8055411c4789160090 100644 --- a/lalapps/.gitignore +++ b/lalapps/.gitignore @@ -116,8 +116,12 @@ src/inspiral/lalapps_thinca src/inspiral/lalapps_tmpltbank src/inspiral/lalapps_trigbank src/inspiral/lalapps_trigger_hipe +src/inspiral/lalapps_trigscan src/inspiral/lalapps_write_ihope_page +src/inspiral/posterior/lalapps_followupMcmc src/inspiral/posterior/lalapps_inspnest +src/inspiral/posterior/SPINspiral/lalapps_spinspiral +src/lalapps/defaults.py src/lalapps/lalapps_cache src/lalapps/lalapps_tconvert src/lalapps/lalapps_version @@ -153,6 +157,7 @@ src/pulsar/FDS_isolated/lalapps_extractSFTband src/pulsar/FDS_isolated/lalapps_makeInvetofile src/pulsar/FDS_isolated/lalapps_monteint src/pulsar/FDS_isolated/lalapps_polka +src/pulsar/FDS_isolated/lalapps_synthesizeBstatMC src/pulsar/FDS_isolated/lalapps_uberpolka src/pulsar/FDS_isolated/lalapps_zellepolka src/pulsar/Injections/lalapps_Makefakedata_v4 diff --git a/lalapps/configure.ac b/lalapps/configure.ac index 83882066e081c910fd8d54f3b5d0abdf92e5cbfc..f1f00930e22ab4b498a83b129c3d18a7702504c9 100644 --- a/lalapps/configure.ac +++ b/lalapps/configure.ac @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([lalapps],[6.2],[lal-discuss@gravity.phys.uwm.edu]) +AC_INIT([lalapps],[6.4],[lal-discuss@gravity.phys.uwm.edu]) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_SRCDIR([src/config.h.in]) AC_CONFIG_AUX_DIR([misc]) @@ -11,6 +11,7 @@ AC_CONFIG_FILES([\ man/Makefile \ misc/Makefile \ src/Makefile \ + src/lalapps/defaults.py \ src/lalapps/Makefile \ src/calibration/Makefile \ src/frametools/Makefile \ @@ -33,6 +34,7 @@ AC_CONFIG_FILES([\ src/pulsar/TDS_isolated/Makefile \ src/inspiral/Makefile \ src/inspiral/posterior/Makefile \ + src/inspiral/posterior/SPINspiral/Makefile \ src/zmsearch/Makefile \ src/detresponse/Makefile \ src/pulsar/hough/src2/Makefile \ @@ -44,6 +46,7 @@ AC_CONFIG_FILES([\ ]) AM_INIT_AUTOMAKE([]) AC_ARG_VAR(LALSUITE_BUILD,[Set if part of lalsuite build]) +AC_ARG_VAR(LAL_TOP_SRCDIR,[Set to top source directory of lal]) AH_TOP([ #ifndef CONFIG_H #define CONFIG_H]) @@ -59,7 +62,7 @@ LALAPPS_WITH_EXTRA_CPPFLAGS LALAPPS_WITH_EXTRA_CFLAGS LALAPPS_WITH_EXTRA_LDFLAGS LALAPPS_WITH_EXTRA_LIBS -LALAPPS_WITH_GCC_FLAGS +LALAPPS_ENABLE_GCC_FLAGS LALAPPS_ENABLE_CONDOR LALAPPS_ENABLE_FRAME LALAPPS_ENABLE_METAIO @@ -74,16 +77,16 @@ lalapps_version_major=`echo "$VERSION" | cut -d. -f1` lalapps_version_minor=`echo "$VERSION" | cut -d. -f2` lalapps_configure_date=`date +"%Y-%m-%dT%H:%M:%S%z"` lalapps_cvs_tag=`echo '$Name$' | sed 's/\\$//g' | sed 's/Name: //'` -AC_DEFINE_UNQUOTED(LALAPPS_VERSION, "$VERSION", [LALApps Version]) -AC_DEFINE_UNQUOTED(LALAPPS_VERSION_MAJOR, $lalapps_version_major, +AC_DEFINE_UNQUOTED([LALAPPS_VERSION],["$VERSION"],[LALApps Version]) +AC_DEFINE_UNQUOTED([LALAPPS_VERSION_MAJOR],[$lalapps_version_major], [LALApps Version Major Number]) -AC_DEFINE_UNQUOTED(LALAPPS_VERSION_MINOR, $lalapps_version_minor, +AC_DEFINE_UNQUOTED([LALAPPS_VERSION_MINOR],[$lalapps_version_minor], [LALApps Version Minor Number]) -AC_DEFINE_UNQUOTED(LALAPPS_CONFIGURE_ARGS, "$ac_configure_args", +AC_DEFINE_UNQUOTED([LALAPPS_CONFIGURE_ARGS],["$ac_configure_args"], [LALApps Configure Arguments]) -AC_DEFINE_UNQUOTED(LALAPPS_CONFIGURE_DATE, "$lalapps_configure_date", +AC_DEFINE_UNQUOTED([LALAPPS_CONFIGURE_DATE],["$lalapps_configure_date"], [LALApps Configure Date]) -AC_DEFINE_UNQUOTED(LALAPPS_CVS_TAG, "$lalapps_cvs_tag", [LALApps CVS Tag]) +AC_DEFINE_UNQUOTED([LALAPPS_CVS_TAG],["$lalapps_cvs_tag"],[LALApps CVS Tag]) dnl Remove -all-static from ldflags @@ -97,7 +100,7 @@ fi # check for c compiler m4_pattern_allow([AC_PROG_CC_C99]) -m4_ifdef([AC_PROG_CC_C99], [AC_PROG_CC_C99], [LAL_AC_PROG_CC_C99]) +m4_ifdef([AC_PROG_CC_C99],[AC_PROG_CC_C99],[LAL_AC_PROG_CC_C99]) # use silent build rules if appropriate m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],) @@ -108,73 +111,92 @@ AC_PROG_CPP AC_ENABLE_SHARED if test "x$condor" = "xtrue"; then - AC_CHECK_PROGS(CONDOR_COMPILE, condor_compile) + AC_CHECK_PROGS([CONDOR_COMPILE],[condor_compile]) CC="$CONDOR_COMPILE $CC" case "$host" in *-*-linux* | *-*-osf* | *-*-hpux* ) CFLAGS="$CFLAGS -static" AC_DISABLE_SHARED;; esac - AC_DEFINE(LALAPPS_CONDOR, 1, [LALApps is condor compiled]) -fi -if test "$GCC" = yes; then - CFLAGS="$CFLAGS -W -Wall $lalapps_gcc_flags" + AC_DEFINE([LALAPPS_CONDOR],[1],[LALApps is condor compiled]) fi + AC_PROG_INSTALL AC_PROG_LN_S -AM_PROG_LIBTOOL -AC_CHECK_PROGS(LATEX, pdflatex latex, echo) -AC_CHECK_PROGS(MKIND, makeindex, echo) -AC_CHECK_PROGS(DVIPS, dvips, echo) -AC_CHECK_PROGS(BIBTEX, bibtex, echo) -AM_PATH_PYTHON(2.4,,:) +AC_PROG_LIBTOOL +AC_CHECK_PROGS([LATEX],[pdflatex latex],[echo]) +AC_CHECK_PROGS([MKIND],[makeindex],[echo]) +AC_CHECK_PROGS([DVIPS],[dvips],[echo]) +AC_CHECK_PROGS([BIBTEX],[bibtex],[echo]) +AM_PATH_PYTHON([2.4],,[:]) AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != :]) +# check for supported mac os x version +if test "x$build_vendor" = "xapple"; then + AC_CHECK_PROGS([SW_VERS],[sw_vers]) + if test "x$SW_VERS" != "x"; then + AC_MSG_CHECKING([Mac OS X version]) + MACOSX_VERSION=`$SW_VERS -productVersion` + AC_MSG_RESULT([$MACOSX_VERSION]) + fi + case "$MACOSX_VERSION" in + 10.0*|10.1*|10.2*|10.3*) + AC_MSG_ERROR([This version of Mac OS X is not supported]) + ;; + 10.4*|10.5*|10.6*) + # supported version + ;; + *) + AC_MSG_WARN([Unknown Mac OS X version]) + ;; + esac +fi + dnl Checks for libraries. -AC_CHECK_LIB(m, sin) -AC_CHECK_LIB(z, compress) +AC_CHECK_LIB([m],[sin]) +AC_CHECK_LIB([z],[compress]) -PKG_CHECK_MODULES(LAL, lal, [ true ], [ false ]) -PKG_CHECK_MODULES(LALSUPPORT, lalsupport , [ true ], [ false ]) -PKG_CHECK_MODULES(LALSTOCHASTIC, lalstochastic, [ true ], [ false ]) +PKG_CHECK_MODULES([LAL],[lal],[true],[false]) +PKG_CHECK_MODULES([LALSUPPORT],[lalsupport],[true],[false]) if test "$LALSUITE_BUILD" != "true" ; then - CPPFLAGS="$CPPFLAGS $LAL_CFLAGS $LALSUPPORT_CFLAGS $LALSTOCHASTIC_CFLAGS" - LIBS="$LALSUPPORT_LIBS $LAL_LIBS $LALSTOCHASTIC_LIBS $LIBS" - AC_CHECK_LIB(lal, LALVersion, , AC_MSG_ERROR(could not find the LAL library)) - AC_CHECK_LIB(lalsupport, LALOpenDataFile, , AC_MSG_ERROR(could not find the LAL support library)) - AC_CHECK_LIB(lalstochastic, LALStochasticOptimalFilter, , AC_MSG_ERROR(could not find the LAL stochastic library)) + CPPFLAGS="$CPPFLAGS $LAL_CFLAGS $LALSUPPORT_CFLAGS" + LIBS="$LALSUPPORT_LIBS $LAL_LIBS $LIBS" + AC_CHECK_LIB([lal],[LALVersion],,[AC_MSG_ERROR([could not find the LAL library])]) + AC_CHECK_LIB([lalsupport],[LALOpenDataFile],,[AC_MSG_ERROR([could not find the LAL support library])]) fi -dnl LALFrame, LALMetaIo, and LALXML (optional). +dnl LALFrame, LALMetaIo, LALStochastic and LALXML (optional). lalframe="true" lalmetaio="true" lalxml="true" -PKG_CHECK_MODULES(LALFRAME, lalframe, [ true ], [ false ]) -PKG_CHECK_MODULES(LALMETAIO, lalmetaio, [ true ], [ false ]) -PKG_CHECK_MODULES(LALXML, lalxml, [ true ], [ false ]) +lalstochastic="true" +PKG_CHECK_MODULES([LALFRAME],[lalframe >= 1.0],[true],[false]) +PKG_CHECK_MODULES([LALMETAIO],[lalmetaio],[true],[false]) +PKG_CHECK_MODULES([LALXML],[lalxml >= 1.0],[true],[false]) +PKG_CHECK_MODULES([LALSTOCHASTIC],[lalstochastic >= 1.0],[true],[false]) if test "$LALSUITE_BUILD" != "true" ; then - CPPFLAGS="$CPPFLAGS $LALFRAME_CFLAGS $LALMETAIO_CFLAGS $LALXML_CFLAGS" - LIBS="$LALFRAME_LIBS $LALMETAIO_LIBS $LALXML_LIBS $LIBS" + CPPFLAGS="$LALFRAME_CFLAGS $LALMETAIO_CFLAGS $LALXML_CFLAGS $LALSTOCHASTIC_CFLAGS $CPPFLAGS" + LIBS="$LALFRAME_LIBS $LALMETAIO_LIBS $LALXML_LIBS $LALSTOCHASTIC_LIBS $LIBS" fi dnl cfitsio -PKG_CHECK_MODULES(CFITSIO, cfitsio, [ true ], [ false ]) +PKG_CHECK_MODULES([CFITSIO],[cfitsio],[true],[false]) CPPFLAGS="$CPPFLAGS $CFITSIO_CFLAGS" LIBS="$CFITSIO_LIBS $LIBS" dnl GSL -PKG_CHECK_MODULES(GSL, gsl, [ true ], [ false ]) +PKG_CHECK_MODULES([GSL],[gsl],[true],[false]) CPPFLAGS="$CPPFLAGS $GSL_CFLAGS" LIBS="$GSL_LIBS $LIBS" extra_CPPFLAGS="$extra_CPPFLAGS $GSL_CFLAGS" extra_LIBS="$GSL_LIBS $extra_LIBS" -AC_CHECK_LIB(gslcblas, main) -AC_CHECK_LIB(gsl, gsl_version) +AC_CHECK_LIB([gslcblas],[main]) +AC_CHECK_LIB([gsl],[gsl_version]) dnl FrameL (libframe) if test "${frame}" = "true"; then - PKG_CHECK_MODULES(FRAME, libframe, [ true ], [ false ]) + PKG_CHECK_MODULES([FRAME],[libframe],[true],[false]) lal_pre_frame_LIBS="$LIBS" LIBS="$LIBS $FRAME_LIBS" - AC_SEARCH_LIBS(FrLibIni, Frame, , + AC_SEARCH_LIBS([FrLibIni],[Frame],, [LALAPPS_DISABLE_FRAME] [frame="false"] [LIBS="$lal_pre_frame_LIBS"]) @@ -182,52 +204,42 @@ fi dnl MetaIo (libmetaio) if test "${metaio}" = "true"; then - PKG_CHECK_MODULES(METAIO, libmetaio, [ true ], [ false ]) + PKG_CHECK_MODULES([METAIO],[libmetaio],[true],[false]) lal_pre_metaio_LIBS="$LIBS" LIBS="$LIBS $METAIO_LIBS" - AC_SEARCH_LIBS(MetaioOpen, metaio dataflow, , - [AC_MSG_WARN(disabling metaio support)] + AC_SEARCH_LIBS([MetaioOpen],[metaio],, + [AC_MSG_WARN([disabling metaio support])] [metaio="false"] [LIBS="$lal_pre_metaio_LIBS"]) fi -dnl XML2 (libxml2) -if test "${xml}" = "true"; then - PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= 2.6, [ true ], [ false ]) - lal_pre_xml2_LIBS="$LIBS" - LIBS="$LIBS $LIBXML2_LIBS" - AC_SEARCH_LIBS(xmlInitParser, xml2, , - [AC_MSG_WARN(disabling xml support)] - [xml="false"] - [LIBS="$lal_pre_xml2_LIBS"]) -fi - dnl Check for libcfitsio if test "${cfitsio}" = "true"; then - AC_CHECK_LIB(cfitsio, ffopen, , cfitsio="false") + AC_CHECK_LIB([cfitsio],[ffopen],,[cfitsio="false"]) fi -dnl Now check for LALFrame and LALMetaIo +dnl Now check for LALFrame, LALMetaIo, LALXMl, and LALStohastic if test "$LALSUITE_BUILD" != "true" ; then - AC_CHECK_LIB(lalframe, LALFrOpen, , lalframe="false") - AC_CHECK_LIB(lalmetaio, LALSnglInspiralTableFromLIGOLw, , lalmetaio="false") - AC_CHECK_LIB(lalxml, XLALXMLFilePrintElements, , lalxml="false") + AC_CHECK_LIB([lalframe],[LALFrOpen],,[lalframe="false"]) + AC_CHECK_LIB([lalmetaio],[LALSnglInspiralTableFromLIGOLw],,[lalmetaio="false"]) + AC_CHECK_LIB([lalxml],[XLALXMLFilePrintElements],,[lalxml="false"]) + AC_CHECK_LIB([lalstochastic],[LALStochasticOptimalFilter],,[lalstochastic="false"]) fi dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(getopt.h) +AC_CHECK_HEADERS([getopt.h]) AC_CHECK_HEADERS([gsl/gsl_fft_real.h]) if test "$LALSUITE_BUILD" != "true" ; then AC_CHECK_HEADERS([lal/LALStdlib.h]) fi -AC_CHECK_HEADERS(glob.h) -AC_CHECK_HEADERS(unistd.h) +AC_CHECK_HEADERS([glob.h]) +AC_CHECK_HEADERS([punistd.h]) if test "${frame}" = "true"; then lal_pre_frame_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $FRAME_CFLAGS" - AC_CHECK_HEADERS(FrameL.h, , + AC_CHECK_HEADERS([FrameL.h],, [LALAPPS_DISABLE_FRAME] [frame="false"] [CPPFLAGS="$lal_pre_frame_CPPFLAGS"]) @@ -236,8 +248,8 @@ fi if test "${metaio}" = "true"; then lal_pre_metaio_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $METAIO_CFLAGS" - AC_CHECK_HEADERS(metaio.h, , - [AC_MSG_WARN(disabling metaio support)] + AC_CHECK_HEADERS([metaio.h],, + [AC_MSG_WARN([disabling metaio support])] [metaio="false"] [CPPFLAGS="$lal_pre_metaio_CPPFLAGS"]) fi @@ -245,8 +257,8 @@ fi if test "${xml}" = "true"; then lal_pre_xml2_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $LIBXML2_CFLAGS" - AC_CHECK_HEADERS(libxml/xmlversion.h, , - [AC_MSG_WARN(disabling xml support)] + AC_CHECK_HEADERS([libxml/xmlversion.h],, + [AC_MSG_WARN([disabling xml support])] [xml="false"] [CPPFLAGS="$lal_pre_xml2_CPPFLAGS"]) fi @@ -254,41 +266,57 @@ fi if test "${cfitsio}" = "true"; then lal_pre_cfitsio_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $CFITSIO_CFLAGS" - AC_CHECK_HEADER(fitsio.h, , + AC_CHECK_HEADER([fitsio.h],, [cfitsio="false"] [CPPFLAGS="$lal_pre_cfitsio_CPPFLAGS"]) fi LALAPPS_CHECK_QTHREAD -AC_MSG_CHECKING(for gethostname prototype in unistd.h) -AC_EGREP_HEADER(gethostname,unistd.h,AC_MSG_RESULT(yes) -AC_DEFINE(HAVE_GETHOSTNAME_PROTOTYPE,1, -[Define if gethostname prototype is in unistd.h]), -AC_MSG_RESULT(no)) +AC_MSG_CHECKING([for gethostname prototype in unistd.h]) +AC_EGREP_HEADER([gethostname],[unistd.h],[AC_MSG_RESULT([yes])] + [AC_DEFINE([HAVE_GETHOSTNAME_PROTOTYPE],[1], + [Define if gethostname prototype is in unistd.h])], + [AC_MSG_RESULT([no])]) -AC_CHECK_FUNCS(setenv) +AC_CHECK_FUNCS([setenv]) if test "$LALSUITE_BUILD" = "true"; then - LIBS="$LALXML_LIBS $LALFRAME_LIBS $LALMETAIO_LIBS $LALSTOCHASTIC_LIBS $LALSUPPORT_LIBS $LAL_LIBS $LIBS" - CPPFLAGS="$CPPFLAGS $LAL_CFLAGS $LALSUPPORT_CFLAGS $LALSTOCHASTIC_CFLAGS $LALFRAME_CFLAGS $LALMETAIO_CFLAGS $LALXML_CFLAGS" + LIBS="$LAL_LIBS $LALSUPPORT_LIBS $LALSTOCHASTIC_LIBS $LALFRAME_LIBS $LALMETAIO_LIBS $LALXML_LIBS $LIBS" + CPPFLAGS="$LAL_CFLAGS $LALSUPPORT_CFLAGS $LALSTOCHASTIC_CFLAGS $LALFRAME_CFLAGS $LALMETAIO_CFLAGS $LALXML_CFLAGS $CPPFLAGS" + echo "LAL_TOP_SRCDIR=$LAL_LIBS" + echo "LAL_TOP_SRCDIR=$LAL_TOP_SRCDIR" + AC_SUBST([LAL_TOP_SRCDIR]) lalframe="false" lalmetaio="false" lalxml="false" + lalstochastic="false" test -n "$LALFRAME_LIBS" && lalframe="true" test -n "$LALMETAIO_LIBS" && lalmetaio="true" test -n "$LALXML_LIBS" && lalxml="true" + test -n "$LALSTOCHASTIC_LIBS" && lalstochastic="true" fi -AM_CONDITIONAL(FRAME, test x$frame = xtrue) -AM_CONDITIONAL(LALFRAME, test x$lalframe = xtrue) -AM_CONDITIONAL(LALMETAIO, test x$lalmetaio = xtrue) -AM_CONDITIONAL(LALXML, test x$lalxml = xtrue) -AM_CONDITIONAL(DATAFLOW, test x$metaio = xtrue) -AM_CONDITIONAL(CFITSIO, test x$cfitsio = xtrue) -AC_DEFINE_UNQUOTED(PREFIX, "$prefix", [Install prefix]) +AM_CONDITIONAL([FRAME],[test x$frame = xtrue]) +AM_CONDITIONAL([LALFRAME],[test x$lalframe = xtrue]) +AM_CONDITIONAL([LALMETAIO],[test x$lalmetaio = xtrue]) +AM_CONDITIONAL([LALXML],[test x$lalxml = xtrue]) +AM_CONDITIONAL([LALSTOCHASTIC],[test x$lalstochastic = xtrue]) +AM_CONDITIONAL([DATAFLOW],[test x$metaio = xtrue]) +AM_CONDITIONAL([CFITSIO],[test x$cfitsio = xtrue]) +AC_DEFINE_UNQUOTED([PREFIX],["$prefix"],[Install prefix]) + +# add gcc specific flags +if test "$GCC" = yes; then + CFLAGS="$CFLAGS $lalapps_gcc_flags" + + # add mac os x specific flags + if test "x$MACOSX_VERSION" != "x"; then + CFLAGS="$CFLAGS -mmacosx-version-min=10.4" + fi +fi -dnl restore all static to ldflags +# restore all static to ldflags if test "${allstatic}" = "true" ; then LDFLAGS="-all-static $LDFLAGS" fi @@ -298,6 +326,7 @@ AC_OUTPUT lalframeenabled="`test x${lalframe} = xtrue && echo "ENABLED" || echo "DISABLED"`" lalmetaioenabled="`test x${lalmetaio} = xtrue && echo "ENABLED" || echo "DISABLED"`" lalxmlenabled="`test x${lalxml} = xtrue && echo "ENABLED" || echo "DISABLED"`" +lalstochasticenabled="`test x${lalstochastic} = xtrue && echo "ENABLED" || echo "DISABLED"`" cfitsioenabled="`test x${cfitsio} = xtrue && echo "ENABLED" || echo "DISABLED"`" echo " ================================================================ @@ -307,6 +336,7 @@ echo " LAL Frame library support is $lalframeenabled LAL MetaIo library support is $lalmetaioenabled LAL XML library support is $lalxmlenabled + LAL Stochastic library support is $lalstochasticenabled FITS library support is $cfitsioenabled Now run 'make' to build LALApps diff --git a/lalapps/debian/Makefile.am b/lalapps/debian/Makefile.am index 64d6821186d1d80e2f67f389eea50748e022c828..068060aacadc903cc73c54a745ca80284530c1ad 100644 --- a/lalapps/debian/Makefile.am +++ b/lalapps/debian/Makefile.am @@ -1 +1,2 @@ -EXTRA_DIST = changelog compat control copyright dirs docs rules +EXTRA_DIST = changelog compat control copyright dirs docs rules \ + lalapps-user-env.sh lalapps-user-env.csh diff --git a/lalapps/debian/changelog b/lalapps/debian/changelog index f5d6af1db00bba22384eaf69e8680dcadcb3286b..c3dc8b3c5da335555c538956e8972c36c1628ddd 100644 --- a/lalapps/debian/changelog +++ b/lalapps/debian/changelog @@ -1,3 +1,39 @@ +lalapps (6.4-1lscsoft1) unstable; urgency=low + + * LALApps 6.4 + + -- Steffen Grunewald <steffen.grunewald@aei.mpg.de> Thu, 30 Sep 2009 10:00:00 +0200 + +lalapps (6.3.2-1lscsoft1) unstable; urgency=low + + * LALApps 6.3.2 + + -- Adam Mercer <adam.mercer@ligo.org> Thu, 23 Oct 2009 10:59:32 -0600 + +lalapps (6.3.1-1lscsoft1) unstable; urgency=low + + * LALApps 6.3.1 + + -- Adam Mercer <adam.mercer@ligo.org> Thu, 08 Oct 2009 17:50:41 +0200 + +lalapps (6.3-1lscsoft1) unstable; urgency=low + + * LALApps 6.3 + + -- Steffen Grunewald <steffen.grunewald@aei.mpg.de> Thu, 03 Sep 2009 16:00:00 +0200 + +lalapps (6.2-1lscsoft2) unstable; urgency=low + + * LALApps 6.2 with dynamic python version fix + + -- Steffen Grunewald <steffen.grunewald@aei.mpg.de> Mon, 10 Aug 2009 14:07:00 +0200 + +lalapps (6.2-1lscsoft1) unstable; urgency=low + + * LALApps 6.2 + + -- Adam Mercer <adam.mercer@ligo.org> Thu, 6 Aug 2009 12:02:09 -0600 + lalapps (6.1-1lscsoft1) unstable; urgency=low * LALApps 6.1 diff --git a/lalapps/debian/control b/lalapps/debian/control index 20c91e37fc902111417211363c5e9efcd5cf8070..17f9609532615fd1a823699a26b3bed25e25b714 100644 --- a/lalapps/debian/control +++ b/lalapps/debian/control @@ -2,13 +2,13 @@ Source: lalapps Section: lscsoft Priority: optional Maintainer: Steffen Grunewald <steffen.grunewald@aei.mpg.de> -Build-Depends: debhelper (>= 5), autotools-dev, automake, m4, libgsl0-dev (>= 1.9), libframe-dev (>= 8.0), libmetaio-dev (>= 8.2), fftw3-dev, zlib1g-dev, libxml2-dev (>= 2.6), libcfitsio3-dev, git-core (>= 1.5), lal-dev (>= 6.0), lal (>= 6.0), pkg-config, python2.4-dev, python2.5-dev +Build-Depends: debhelper (>= 5), autotools-dev, automake, m4, libgsl0-dev (>= 1.9), libframe-dev (>= 8.0), libmetaio-dev (>= 8.2), fftw3-dev, zlib1g-dev, libcfitsio3-dev, git-core (>= 1.5), lal-dev (>= 6.4), lal (>= 6.4), lalstochastic-dev (>= 1.0), lalstochastic (>= 1.0), lalframe-dev (>= 1.0), lalframe (>= 1.0), lalxml-dev (>= 1.0), lalxml (>= 1.0), pkg-config, python2.4-dev, python2.5-dev, python-dev (>= 2.4) Standards-Version: 3.7.2 Package: lalapps Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, zlib1g, libgsl0 (>= 1.9) | libgsl0ldbl (>= 1.10), libframe1 (>= 8.0), libmetaio1 (>=8.2), fftw3, libcfitsio3, lal (>= 6.0), libxml2 (>= 2.6), python2.4 -Recommends: python2.5 +Depends: ${shlibs:Depends}, ${misc:Depends}, zlib1g, libgsl0 (>= 1.9) | libgsl0ldbl (>= 1.10), libframe1 (>= 8.0), libmetaio1 (>=8.2), fftw3, libcfitsio3, lal (>= 6.4), lalstochastic (>= 1.0), lalframe (>= 1.0), lalxml (>= 1.0), python (>= 2.4) +Recommends: python2.4, python2.5 Description: LSC Algorithm Library Applications The LSC Algorithm Library Applications for gravitational wave data analysis. This package contains applications that are built on tools in the diff --git a/lalapps/debian/dirs b/lalapps/debian/dirs index e1852c4a6cfea53a6fdc303e2e7c9380f755878c..c0229364751c52bb899b706f619eac5cf9d256ec 100644 --- a/lalapps/debian/dirs +++ b/lalapps/debian/dirs @@ -1,6 +1,7 @@ opt/lscsoft/lalapps/bin opt/lscsoft/lalapps/etc -opt/lscsoft/lalapps/lib +opt/lscsoft/lalapps/lib/python2.4 +opt/lscsoft/lalapps/lib/python2.5 opt/lscsoft/lalapps/sbin opt/lscsoft/lalapps/share/lalapps opt/lscsoft/lalapps/share/man diff --git a/lalapps/debian/rules b/lalapps/debian/rules index de3ae669369a4b9ad2b2d2556e30e74d77d49a31..c086184e9415fa952a6edbe4f14fc8a522ed36d6 100755 --- a/lalapps/debian/rules +++ b/lalapps/debian/rules @@ -19,6 +19,9 @@ PREFIX = /opt/lscsoft/lalapps FRAMEPREFIX = /opt/lscsoft/libframe METAIOPREFIX = /opt/lscsoft/libmetaio LALPREFIX = /opt/lscsoft/lal +LALSTOCHPREFIX = /opt/lscsoft/lalstochastic +LALFRAME = /opt/lscsoft/lalframe +LALXMLPREFIX = /opt/lscsoft/lalxml CFLAGS = -Wall -g @@ -37,7 +40,7 @@ config.status: configure # LDFLAGS="-Wl,-z,defs" \ # moved to install # CFLAGS="$(CFLAGS)" \ -# PKG_CONFIG_PATH=$(FRAMEPREFIX)/lib/pkgconfig:$(METAIOPREFIX)/lib/pkgconfig:$(LALPREFIX)/lib/pkgconfig \ + # PKG_CONFIG_PATH=$(FRAMEPREFIX)/lib/pkgconfig:$(METAIOPREFIX)/lib/pkgconfig:$(LALPREFIX)/lib/pkgconfig:$(LALSTOCHPREFIX)/lib/pkgconfig:$(LALFRAMEPREFIX)/lib/pkgconfig:$(LALXMLPREFIX)/lib/pkgconfig \ # ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \ # --prefix=$(PREFIX) \ # --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info \ @@ -71,27 +74,23 @@ install: build dh_installdirs set -e; \ - for v in 2.5 2.4; do \ + for v in 2.4 2.5; do \ PYTHON="python$$v" \ CFLAGS="$(CFLAGS)" \ - PKG_CONFIG_PATH=$(FRAMEPREFIX)/lib/pkgconfig:$(METAIOPREFIX)/lib/pkgconfig:$(LALPREFIX)/lib/pkgconfig \ + PKG_CONFIG_PATH=$(FRAMEPREFIX)/lib/pkgconfig:$(METAIOPREFIX)/lib/pkgconfig:$(LALPREFIX)/lib/pkgconfig:$(LALSTOCHPREFIX)/lib/pkgconfig:$(LALFRAMEPREFIX)/lib/pkgconfig:$(LALXMLPREFIX)/lib/pkgconfig \ ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \ --prefix=$(PREFIX) \ --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info \ --enable-nightly=no \ --enable-frame --enable-metaio \ - --disable-debug ; \ + --disable-debug \ + --disable-gcc-flags ; \ PYTHON="python$$v" \ $(MAKE) ; \ - echo "tree after build:" ; \ - ls -lR $(CURDIR)/debian ; \ PYTHON="python$$v" \ $(MAKE) DESTDIR=$(CURDIR)/debian/lalapps install ; \ - echo "tree after install:" ; \ - ls -lR $(CURDIR)/debian ; \ + PYTHON="python$$v" \ $(MAKE) clean ; \ - echo "tree after clean:" ; \ - ls -lR $(CURDIR)/debian ; \ done set -e; \ for i in `find debian -mindepth 2 -type f ! -perm 755`; do \ @@ -102,11 +101,11 @@ install: build set -e; \ for i in `find debian/lalapps/$(PREFIX)/bin -type f`; do \ echo $$i; \ - if head -n1 $$i | grep -q '^#!.*python$$' ; then \ - sed -i '1s/python$$/python2.4/' $$i; \ + if head -n1 $$i | grep -q '^#!.*python2\..' ; then \ + sed -i '1s/python2\../python/' $$i; \ fi ; \ done - + cp -p debian/lalapps-user-env.* $(CURDIR)/debian/lalapps/$(PREFIX)/etc/ binary-common: build install dh_testdir @@ -116,7 +115,7 @@ binary-common: build install dh_installexamples # dh_install # dh_installmenu -# dh_installdebconf +# dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installpam diff --git a/lalapps/doc/Makefile.am b/lalapps/doc/Makefile.am index 030756de1a61e1e3e621bc43aca09a6e60d40057..6580583396230aa6524e000da278ce55c9034e6b 100644 --- a/lalapps/doc/Makefile.am +++ b/lalapps/doc/Makefile.am @@ -4,7 +4,7 @@ TEXSOURCEFILES = lalapps.tex lalapps.bib lalapps.bst \ animate.tex animate.ps animate.pdf \ BankEfficiency.tex BankNumber.tex \ - findchirp.tex hello.tex inspinj.tex inspiral-module.tex \ + findchirp.tex inspinj.tex inspiral-module.tex \ inspiral.tex \ stochastic.tex olapredfcn.tex \ pipeline-module.tex ring.tex @@ -12,7 +12,7 @@ TEXSOURCEFILES = lalapps.tex lalapps.bib lalapps.bst \ ## Don't edit below here (unless you know what you're doing) INSTALLFILES = lalapps.pdf lalapps.dvi lalapps.ps MOSTLYCLEANFILES = *.log *.ilg *.blg *.out -CLEANFILES = *.aux *.bbl *.dvi *.glo *.idx *.ind *.lof *.lot *.toc hello.c AUTHORS.tex +CLEANFILES = *.aux *.bbl *.dvi *.glo *.idx *.ind *.lof *.lot *.toc AUTHORS.tex DISTCLEANFILES = $(INSTALLFILES) EXTRA_DIST = $(TEXSOURCEFILES) LATEX = @LATEX@ @@ -31,7 +31,6 @@ dvi-local: test -f $$file || @LN_S@ $(srcdir)/$$file . ; \ done test -f AUTHORS.tex || @LN_S@ $(top_srcdir)/AUTHORS AUTHORS.tex - test -f hello.c || @LN_S@ $(top_srcdir)/src/example/hello.c . ${LATEX} lalapps ${BIBTEX} lalapps ${LATEX} lalapps diff --git a/lalapps/doc/lalapps.tex b/lalapps/doc/lalapps.tex index 87488a01e529db341234e1972decf3fbd3d6c0f9..1b45cd9069b2d55e96b9226290216c73d4f9b5ee 100644 --- a/lalapps/doc/lalapps.tex +++ b/lalapps/doc/lalapps.tex @@ -78,7 +78,7 @@ \frontmatter \title{LALApps --- LSC Algorithm Library Applications} -\author{Contact: Duncan Brown \texttt{duncan@gravity.phys.uwm.edu}} +\author{Contact: Adam Mercer \texttt{ram@gravity.phys.uwm.edu}} \maketitle \thispagestyle{empty} @@ -346,19 +346,8 @@ static volatile const char *rcsid="$Id$"; \item[Description] \verb$PRINT_VERSION$ prints the version information for \verb$program$ in a -standard format, along with the RCS Id information. For example, for the -program \verb$lalapps_hello$, the version information -\begin{indented} -\verb+lalapps hello version 0.1+\\ -\verb+$+\verb+Id+\verb+$+ -\end{indented} -is printed with the command \verb$lalapps_hello -V$. The source code to -print this is -\begin{indented} -\verb$PRINT_VERSION( "hello" );$ -\end{indented} - -Note that \verb$PRINT_VERSION$ requires the string variable \verb$rcsid$ to be +standard format, along with the RCS Id information. Note that +\verb$PRINT_VERSION$ requires the string variable \verb$rcsid$ to be set. \end{entry} @@ -483,24 +472,12 @@ int main( void ) \end{entry} -\newpage -\section{Source \texttt{hello.c}} -\label{source:hello.c} -\idx[Source]{hello.c} - -\begin{indented} -This is the source code for the program \verb$lalapps_hello$: - -\listinginput[10]{1}{hello.c} -\end{indented} - \newpage %% %% INCLUDE YOUR DOCUMENTATION BELOW %% -\include{hello} \include{animate} \include{calibration} \include{python} diff --git a/lalapps/lalapps.spec.in b/lalapps/lalapps.spec.in index 75c77a9796df5ddce4b46280ca237cc3edca1205..3fc9a70b94864cffec96d6a7b993eaf8c7da69bc 100644 --- a/lalapps/lalapps.spec.in +++ b/lalapps/lalapps.spec.in @@ -14,7 +14,7 @@ Source: %{name}-%{version}.tar.gz URL: http://www.lsc-group.phys.uwm.edu/daswg/projects/lalapps.html Packager: Duncan Brown <dbrown@ligo.caltech.edu> BuildRoot: %{_tmppath}/%{name}-%{version}-root -Requires: gsl fftw libframe libmetaio lal libxml2 cfitsio python +Requires: gsl fftw libframe libmetaio lal lalstochastic lalxml cfitsio python Prefix: %{_prefix} %description @@ -28,7 +28,7 @@ Algorithm Library. %build source /opt/lscsoft/lscsoft-user-env.sh nightly_version=@NIGHTLY_VERSION@ -%configure --enable-nightly=${nightly_version:-no} --disable-debug +%configure --enable-nightly=${nightly_version:-no} --disable-gcc-flags --disable-debug %{__make} %install diff --git a/lalapps/misc/lalapps.m4 b/lalapps/misc/lalapps.m4 index 8d60d1b89fed5595959571b5b5677332cc522feb..5d26b65336e2d22ecace212bf2d4cdb8c24fb920 100644 --- a/lalapps/misc/lalapps.m4 +++ b/lalapps/misc/lalapps.m4 @@ -55,17 +55,20 @@ AC_DEFUN([LALAPPS_WITH_EXTRA_LIBS], ],) ]) -AC_DEFUN([LALAPPS_WITH_GCC_FLAGS], -[AC_ARG_WITH( - [gcc_flags], - AC_HELP_STRING([--with-gcc-flags],[turn on strict gcc warning flags]), - [ if test -n "${with_gcc_flags}" - then - lalapps_gcc_flags="-g3 -O4 -pedantic -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -fno-common -Wnested-externs -Wno-format-zero-length" - else - lalapps_gcc_flags="" - fi - ], [ lalapps_gcc_flags="" ] ) +AC_DEFUN([LALAPPS_ENABLE_GCC_FLAGS], +[AC_ARG_ENABLE([gcc_flags], + AC_HELP_STRING([--enable-gcc-flags],[turn on strict gcc warning flags (default=yes)]), + [case "${enableval}" in + yes) DO_ENABLE_LALAPPS_GCC_FLAGS;; + no) ;; + *) DO_ENABLE_LALAPPS_GCC_FLAGS;; + esac ], + [ DO_ENABLE_LALAPPS_GCC_FLAGS ] ) +]) + +AC_DEFUN([DO_ENABLE_LALAPPS_GCC_FLAGS], +[ + lalapps_gcc_flags="-g3 -O4 -pedantic -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -fno-common -Wnested-externs -Wno-format-zero-length" ]) AC_DEFUN([LALAPPS_WITH_CC], @@ -106,7 +109,7 @@ AC_DEFUN([LALAPPS_ENABLE_FRAME], AC_DEFUN([LALAPPS_ENABLE_METAIO], [AC_ARG_ENABLE( [metaio], - AC_HELP_STRING([--enable-metaio],[compile code that requires metaio/dataflow library [default=yes]]), + AC_HELP_STRING([--enable-metaio],[compile code that requires metaio library [default=yes]]), [ case "${enableval}" in yes) metaio=true;; no) metaio=false ;; diff --git a/lalapps/misc/pkg.m4 b/lalapps/misc/pkg.m4 index 71981018fd8718f873c5b882c2050f8d0e135e01..a0b9cd45dfc3c16325a03686e39a081ce766c5b0 100644 --- a/lalapps/misc/pkg.m4 +++ b/lalapps/misc/pkg.m4 @@ -31,7 +31,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_ifval([$1], [$1], [0.9.0]) + _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) @@ -43,24 +43,61 @@ if test -n "$PKG_CONFIG"; then fi[]dnl ])# PKG_PROG_PKG_CONFIG +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], -[if test "x$ac_cv_env_[]$1[]_set" = "xset"; then - pkg_cv_[]$1=$ac_cv_env_[]$1[]_value -elif test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists "$3" >/dev/null 2>&1; then - pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` - else - pkg_failed=yes - fi -else - pkg_failed=untried +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + else + pkg_failed=untried fi[]dnl ])# _PKG_CONFIG +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl @@ -68,40 +105,51 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no -AC_CACHE_CHECK([for $1][_CFLAGS], [pkg_cv_][$1][_CFLAGS], - [_PKG_CONFIG([$1][_CFLAGS], [cflags], [[$2]])]) -AC_CACHE_CHECK([for $1][_LIBS], [pkg_cv_][$1][_LIBS], - [_PKG_CONFIG([$1][_LIBS], [libs], [[$2]])]) +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) if test $pkg_failed = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` + fi # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" 1>&AS_MESSAGE_LOG_FD + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD ifelse([$4], , [AC_MSG_ERROR(dnl -[[Package requirements ($2) were not met. +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -Alternatively you may set the $1_CFLAGS and $1_LIBS environment variables -to avoid the need to call pkg-config. See the pkg-config man page for -more details.]])], - [$4]) +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) elif test $pkg_failed = untried; then ifelse([$4], , [AC_MSG_FAILURE(dnl -[[The pkg-config script could not be found or is too old. Make sure it +[The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. -Alternatively you may set the $1_CFLAGS and $1_LIBS environment variables -to avoid the need to call pkg-config. See the pkg-config man page for -more details. +_PKG_TEXT -To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.]])], +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])], [$4]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) ifelse([$3], , :, [$3]) fi[]dnl ])# PKG_CHECK_MODULES diff --git a/lalapps/src/calibration/ComputeStrainDriver.c b/lalapps/src/calibration/ComputeStrainDriver.c index 85e4a3bf138414ceaa02e767751ba7d74f55743c..a62bcdae0e28a84f92290adfd70bc75870ee31d6 100644 --- a/lalapps/src/calibration/ComputeStrainDriver.c +++ b/lalapps/src/calibration/ComputeStrainDriver.c @@ -76,6 +76,7 @@ int main(void) {fputs("disabled, no gsl or no lal frame library support.\n", std #include <lal/Units.h> #include <lal/LALString.h> #include <lal/FrequencySeries.h> +#include <lal/LALVCSInfo.h> #include <lalapps.h> #include "LALASCIIFileRead.h" @@ -104,26 +105,13 @@ NRCSID(COMPUTESTRAINDRIVERC, "$Id$"); /* STRUCTURES */ struct CommandLineArgsTag { - REAL8 f; /* Frequency of the calibration line */ REAL8 To; /* factors integration time */ - REAL8 G0Re; /* Real part of open loop gain at cal line freq.*/ - REAL8 G0Im; /* Imaginary part of open loop gain at cal line freq. */ - REAL8 D0Re; /* Real part of digital filter at cal line freq.*/ - REAL8 D0Im; /* Imaginary part of digital filter at cal line freq. */ - REAL8 W0Re; /* Real part of whitening filter at cal line freq.*/ - REAL8 W0Im; /* Imaginary part of whitening filter at cal line freq. */ INT4 GPSStart; /* Start GPS time for the segment to be calibrated */ INT4 GPSEnd; /* End GPS time for the segment to be calibrated */ INT4 testsensing; INT4 testactuation; char *FrCacheFile; /* Frame cache file for corresponding time */ - char *exc_chan; /* excitation channel name */ - char *darm_chan; /* darm channel name */ - char *darmerr_chan; /* darm_err channel name */ - char *asq_chan; /* asq channel name (deprecated) */ - char *sv_chan; /* state vector channel name */ - char *lax_chan; /* light in x-arm channel name */ - char *lay_chan; /* light in y-arm channel name */ + char *ifo; /* interferometer name (H1, H2, L1) */ char *filterfile; /* file with filter coefficients */ char *frametype; char *strainchannel; @@ -141,18 +129,18 @@ StrainOut OutputData; INT4 duration; LIGOTimeGPS gpsStartepoch; -REAL4TimeSeries StateVector; -REAL4TimeSeries LAX; -REAL4TimeSeries LAY; - INT4TimeSeries OutputDQ; /* data quality */ static LALStatus status; INT4 lalDebugLevel=0; FrCache *framecache; /* frame reading variables */ FrStream *framestream=NULL; -char ifo[2]; -char filtercvsinfo[16384]; +char sv_cname[] = "Xn:IFO-SV_STATE_VECTOR", /* channel names */ + lax_cname[] = "Xn:LSC-LA_PTRX_NORM", lay_cname[] = "Xn:LSC-LA_PTRY_NORM", + asq_cname[] = "Xn:LSC-DARM_ERR", /* temporary hack: set name of (unused) asq to darm_err */ + dctrl_cname[] = "Xn:LSC-DARM_CTRL", + derr_cname[] = "Xn:LSC-DARM_ERR", exc_cname[] = "Xn:LSC-DARM_CTRL_EXC_DAQ"; + /***************************************************************************/ /* to avoid a warning */ @@ -160,24 +148,23 @@ int gethostname(char *name, size_t len); /* int getdomainname(char *name, size_t len); */ -/* FUNCTION PROTOTYPES */ +/* FUNCTION PROTOTYPES (defined static so they cannot be used outside) */ /* Reads the command line */ -int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA); +static int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA); /* Reads T seconds of AS_Q, EXC, and DARM_CTRL data */ -int ReadData(struct CommandLineArgsTag CLA); +static int ReadData(struct CommandLineArgsTag CLA); /* Writes frame file */ -int WriteFrame(int argc,char *argv[],struct CommandLineArgsTag CLA); +static int WriteFrame(int argc,char *argv[],struct CommandLineArgsTag CLA); /* Frees the memory */ -int FreeMem(void); +static int FreeMem(void); /************************************* MAIN PROGRAM *************************************/ int main(int argc,char *argv[]) { - if (ReadCommandLine(argc,argv,&CommandLineArgs)) return 1; /* Check whether files exist before proceeding */ @@ -188,7 +175,7 @@ int main(int argc,char *argv[]) char site; INT4 t0, dt; - site = CommandLineArgs.darmerr_chan[0]; + site = CommandLineArgs.ifo[0]; t0 = CommandLineArgs.GPSStart+InputData.wings; dt = CommandLineArgs.GPSEnd-CommandLineArgs.GPSStart-2*InputData.wings; @@ -206,22 +193,22 @@ int main(int argc,char *argv[]) } } - if (ReadData(CommandLineArgs)) return 2; - if (XLALReadFiltersFile(CommandLineArgs.filterfile, &InputData)) return 3; + if (ReadData(CommandLineArgs)) return 2; + LALComputeStrain(&status, &OutputData, &InputData); TESTSTATUS( &status ); - XLALComputeDQ(StateVector.data->data, StateVector.data->length/OutputDQ.data->length, - LAX.data->data, LAY.data->data, LAX.data->length/OutputDQ.data->length, + XLALComputeDQ(InputData.StateVector.data->data, InputData.StateVector.data->length/OutputDQ.data->length, + InputData.LAX.data->data, InputData.LAY.data->data, InputData.LAX.data->length/OutputDQ.data->length, OutputData.alphabeta.data->data, OutputData.alphabeta.data->length/OutputDQ.data->length, 0, 0, InputData.wings, 0, /* how can I actually know if it is missing in the DMT or not?? */ OutputDQ.data->data, OutputDQ.data->length); if (WriteFrame(argc,argv,CommandLineArgs)) return 4; - + if(FreeMem()) return 5; return 0; @@ -266,6 +253,11 @@ int WriteFrame(int argc,char *argv[],struct CommandLineArgsTag CLA) char gammaimName[] = "Xn:CAL-OLOOP_FAC_Im"; char dqName[] = "Xn:LSC-DATA_QUALITY_VECTOR"; + char *cnames[] = { alphaName, gammaName, alphaimName, gammaimName, dqName }; + + for (i = 0; i < 5; i++) + memcpy(cnames[i], CLA.ifo, 2); /* set the proper name of the channels */ + /*re-size h(t) and data time series*/ if(!XLALResizeREAL8TimeSeries(&(OutputData.h), (int)(InputData.wings/OutputData.h.deltaT), OutputData.h.data->length-2*(UINT4)(InputData.wings/OutputData.h.deltaT))) @@ -281,14 +273,13 @@ int WriteFrame(int argc,char *argv[],struct CommandLineArgsTag CLA) XLAL_ERROR(func, XLAL_EFUNC); /* Resize State Vector and Data Quality time series */ - if(!XLALResizeREAL4TimeSeries(&(StateVector), (int)(InputData.wings/StateVector.deltaT), - StateVector.data->length-2*(UINT4)(InputData.wings/StateVector.deltaT))) + if(!XLALResizeREAL4TimeSeries(&(InputData.StateVector), (int)(InputData.wings/InputData.StateVector.deltaT), + InputData.StateVector.data->length-2*(UINT4)(InputData.wings/InputData.StateVector.deltaT))) XLAL_ERROR(func, XLAL_EFUNC); if(!XLALResizeINT4TimeSeries(&(OutputDQ), (int)(InputData.wings/OutputDQ.deltaT), OutputDQ.data->length-2*(UINT4)(InputData.wings/OutputDQ.deltaT))) XLAL_ERROR(func, XLAL_EFUNC); - strncpy(OutputDQ.name, - memcpy(dqName, OutputData.h.name, 2), sizeof( OutputDQ.name ) ); + strncpy(OutputDQ.name, dqName, sizeof(OutputDQ.name)); /* also set the name of the channel */ /* Resize DARM_CTRL, DARM_ERR, EXC and AS_Q*/ if(!XLALResizeREAL4TimeSeries(&(InputData.DARM), (int)(InputData.wings/InputData.DARM.deltaT), @@ -304,22 +295,16 @@ int WriteFrame(int argc,char *argv[],struct CommandLineArgsTag CLA) InputData.AS_Q.data->length-2*(UINT4)(InputData.wings/InputData.AS_Q.deltaT))) XLAL_ERROR(func, XLAL_EFUNC); - /* Names for factors time series */ - memcpy( alphaName, OutputData.h.name, 2 ); - memcpy( gammaName, OutputData.h.name, 2 ); - memcpy( alphaimName, OutputData.h.name, 2 ); - memcpy( gammaimName, OutputData.h.name, 2 ); - /* based on IFO name, choose the correct detector */ - if ( 0 == strncmp( OutputData.h.name, "H2:", 3 ) ) + if ( 0 == strcmp(CLA.ifo, "H2") ) detectorFlags = LAL_LHO_2K_DETECTOR_BIT; - else if ( 0 == strncmp( OutputData.h.name, "H1:", 3 ) ) + else if ( 0 == strcmp( CLA.ifo, "H1") ) detectorFlags = LAL_LHO_4K_DETECTOR_BIT; - else if ( 0 == strncmp( OutputData.h.name, "L1:", 3 ) ) + else if ( 0 == strcmp( CLA.ifo, "L1") ) detectorFlags = LAL_LLO_4K_DETECTOR_BIT; else return 1; /* Error: not a recognized name */ - site = OutputData.h.name[0]; + site = CLA.ifo[0]; /* based on series metadata, generate standard filename */ FrDuration = OutputData.h.deltaT * OutputData.h.data->length; @@ -348,8 +333,8 @@ int WriteFrame(int argc,char *argv[],struct CommandLineArgsTag CLA) FrHistoryAdd( frame, lalappsconfargs); /* Add lal info */ - snprintf( lalconfargs, sizeof( lalconfargs), "LAL Info:\n LAL Version: %s\n CVS Tag: %s\n Configure Date: %s\n Configure Arguments: %s", - LAL_VERSION , LAL_CVS_TAG , LAL_CONFIGURE_DATE , LAL_CONFIGURE_ARGS ); + snprintf( lalconfargs, sizeof( lalconfargs), "LAL Info:\n LAL Version: %s\n Git Tag: %s\n Git ID: %s\n Configure Date: %s\n Configure Arguments: %s", + LAL_VERSION , lalHeaderVCSInfo.vcsTag, lalHeaderVCSInfo.vcsId, LAL_CONFIGURE_DATE , LAL_CONFIGURE_ARGS ); FrHistoryAdd( frame, lalconfargs); /* Create string with all command line arguments and add it to history */ @@ -372,13 +357,13 @@ int WriteFrame(int argc,char *argv[],struct CommandLineArgsTag CLA) FrHistoryAdd( frame, "Frequency validity range: 40Hz-5kHz."); /* String containing the filter file cvs info (first line in filter file) */ - FrHistoryAdd( frame, filtercvsinfo); + FrHistoryAdd( frame, InputData.filter_vc_info); /* Add in the h(t) data */ XLALFrameAddREAL8TimeSeriesProcData( frame, &OutputData.h); /* Add in the state vector data */ - XLALFrameAddREAL4TimeSeriesProcData( frame, &StateVector); + XLALFrameAddREAL4TimeSeriesProcData( frame, &InputData.StateVector); /* Add in the data quality data */ XLALFrameAddINT4TimeSeriesProcData( frame, &OutputDQ); @@ -460,13 +445,13 @@ static FrChanIn chanin_lay; /* light in y-arm */ chanin_lax.type = ADCDataChannel; chanin_lay.type = ADCDataChannel; - chanin_asq.name = CLA.asq_chan; - chanin_darm.name = CLA.darm_chan; - chanin_darmerr.name = CLA.darmerr_chan; - chanin_exc.name = CLA.exc_chan; - chanin_sv.name = CLA.sv_chan; - chanin_lax.name = CLA.lax_chan; - chanin_lay.name = CLA.lay_chan; + chanin_asq.name = asq_cname; + chanin_darm.name = dctrl_cname; + chanin_darmerr.name = derr_cname; + chanin_exc.name = exc_cname; + chanin_sv.name = sv_cname; + chanin_lax.name = lax_cname; + chanin_lay.name = lay_cname; /* create Frame cache, open frame stream and delete frame cache */ LALFrCacheImport(&status,&framecache,CommandLineArgs.FrCacheFile); @@ -495,11 +480,11 @@ static FrChanIn chanin_lay; /* light in y-arm */ TESTSTATUS( &status ); LALFrGetREAL4TimeSeries(&status,&InputData.DARM_ERR,&chanin_darmerr,framestream); TESTSTATUS( &status ); - LALFrGetREAL4TimeSeries(&status,&StateVector,&chanin_sv,framestream); + LALFrGetREAL4TimeSeries(&status,&InputData.StateVector,&chanin_sv,framestream); TESTSTATUS( &status ); - LALFrGetREAL4TimeSeries(&status,&LAX,&chanin_lax,framestream); + LALFrGetREAL4TimeSeries(&status,&InputData.LAX,&chanin_lax,framestream); TESTSTATUS( &status ); - LALFrGetREAL4TimeSeries(&status,&LAY,&chanin_lay,framestream); + LALFrGetREAL4TimeSeries(&status,&InputData.LAY,&chanin_lay,framestream); TESTSTATUS( &status ); /* Allocate space for data vectors */ @@ -511,11 +496,11 @@ static FrChanIn chanin_lay; /* light in y-arm */ TESTSTATUS( &status ); LALSCreateVector(&status,&InputData.EXC.data,(UINT4)(duration/InputData.EXC.deltaT +0.5)); TESTSTATUS( &status ); - LALSCreateVector(&status,&StateVector.data,(UINT4)(duration/StateVector.deltaT +0.5)); + LALSCreateVector(&status,&InputData.StateVector.data,(UINT4)(duration/InputData.StateVector.deltaT +0.5)); TESTSTATUS( &status ); - LALSCreateVector(&status,&LAX.data,(UINT4)(duration/LAX.deltaT +0.5)); + LALSCreateVector(&status,&InputData.LAX.data,(UINT4)(duration/InputData.LAX.deltaT +0.5)); TESTSTATUS( &status ); - LALSCreateVector(&status,&LAY.data,(UINT4)(duration/LAX.deltaT +0.5)); + LALSCreateVector(&status,&InputData.LAY.data,(UINT4)(duration/InputData.LAX.deltaT +0.5)); TESTSTATUS( &status ); /* Read in the data */ @@ -541,30 +526,23 @@ static FrChanIn chanin_lay; /* light in y-arm */ LALFrSetPos(&status,&pos1,framestream); TESTSTATUS( &status ); - LALFrGetREAL4TimeSeries(&status,&StateVector,&chanin_sv,framestream); + LALFrGetREAL4TimeSeries(&status,&InputData.StateVector,&chanin_sv,framestream); TESTSTATUS( &status ); LALFrSetPos(&status,&pos1,framestream); TESTSTATUS( &status ); - LALFrGetREAL4TimeSeries(&status,&LAX,&chanin_lax,framestream); + LALFrGetREAL4TimeSeries(&status,&InputData.LAX,&chanin_lax,framestream); TESTSTATUS( &status ); LALFrSetPos(&status,&pos1,framestream); TESTSTATUS( &status ); - LALFrGetREAL4TimeSeries(&status,&LAY,&chanin_lay,framestream); + LALFrGetREAL4TimeSeries(&status,&InputData.LAY,&chanin_lay,framestream); TESTSTATUS( &status ); LALFrClose(&status,&framestream); TESTSTATUS( &status ); /* Set the rest of the input variables */ - InputData.Go.re=CLA.G0Re; - InputData.Go.im=CLA.G0Im; - InputData.Do.re=CLA.D0Re; - InputData.Do.im=CLA.D0Im; - InputData.Wo.re=CLA.W0Re; - InputData.Wo.im=CLA.W0Im; - InputData.f=CLA.f; InputData.To=CLA.To; /* check input data epoch agrees with command line arguments */ @@ -606,7 +584,7 @@ static FrChanIn chanin_lay; /* light in y-arm */ LALZCreateVector(&status,&OutputData.beta.data,(UINT4)(duration/OutputData.beta.deltaT +0.5)); TESTSTATUS( &status ); - OutputDQ.epoch=StateVector.epoch; + OutputDQ.epoch=InputData.StateVector.epoch; OutputDQ.deltaT=1; /* Data Quality channel written at 1 Hz */ LALI4CreateVector(&status,&OutputDQ.data,(UINT4)(duration/OutputDQ.deltaT +0.5)); TESTSTATUS( &status ); @@ -622,25 +600,12 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) { INT4 errflg=0; struct option long_options[] = { - {"cal-line-freq", required_argument, NULL, 'f'}, {"factors-time", required_argument, NULL, 't'}, {"filters-file", required_argument, NULL, 'F'}, {"frame-cache", required_argument, NULL, 'C'}, - {"exc-channel", required_argument, NULL, 'E'}, - {"asq-channel", required_argument, NULL, 'A'}, - {"darm-channel", required_argument, NULL, 'D'}, - {"darmerr-channel", required_argument, NULL, 'R'}, - {"sv-channel", required_argument, NULL, 'V'}, - {"lax-channel", required_argument, NULL, 'L'}, - {"lay-channel", required_argument, NULL, 'Y'}, + {"ifo", required_argument, NULL, 'i'}, {"gps-start-time", required_argument, NULL, 's'}, {"gps-end-time", required_argument, NULL, 'e'}, - {"olg-re", required_argument, NULL, 'i'}, - {"olg-im", required_argument, NULL, 'j'}, - {"servo-re", required_argument, NULL, 'k'}, - {"servo-im", required_argument, NULL, 'l'}, - {"whitener-re", required_argument, NULL, 'm'}, - {"whitener-im", required_argument, NULL, 'n'}, {"wings", required_argument, NULL, 'o'}, {"test-sensing", no_argument, NULL, 'r'}, {"test-actuation", no_argument, NULL, 'c'}, @@ -658,28 +623,15 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0} }; - char args[] = "hrcduxf:C:A:E:D:R:F:s:e:i:j:k:l:m:n:t:o:H:T:S:z:v:wy:p:"; + char args[] = "hrcdux:C:F:s:e:i:t:o:H:T:S:z:v:wy:p:"; /* Initialize default values */ - CLA->f=0.0; CLA->To=0.0; CLA->FrCacheFile=NULL; CLA->filterfile=NULL; - CLA->exc_chan=NULL; - CLA->darm_chan=NULL; - CLA->darmerr_chan=NULL; - CLA->asq_chan=NULL; - CLA->sv_chan=NULL; - CLA->lax_chan=NULL; - CLA->lay_chan=NULL; + CLA->ifo=NULL; CLA->GPSStart=0; CLA->GPSEnd=0; - CLA->G0Re=0.0; - CLA->G0Im=0.0; - CLA->D0Re=0.0; - CLA->D0Im=0.0; - CLA->W0Re=0.0; - CLA->W0Im=0.0; CLA->testsensing=0; CLA->testactuation=0; CLA->frametype=NULL; @@ -708,10 +660,6 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) switch ( c ) { - case 'f': - /* calibration line frequency */ - CLA->f=atof(optarg); - break; case 't': /* factors integration time */ CLA->To=atof(optarg); @@ -724,33 +672,21 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) /* name of filter cache file */ CLA->filterfile=optarg; break; - case 'E': - /* name of excitation channel */ - CLA->exc_chan=optarg; - break; - case 'A': - /* name of as_q channel */ - CLA->asq_chan=optarg; /* *** Warning: DEPRECATED *** */ - break; - case 'D': - /* name of darm channel */ - CLA->darm_chan=optarg; - break; - case 'R': - /* name of darm err channel */ - CLA->darmerr_chan=optarg; - break; - case 'V': - /* name of state vector channel */ - CLA->sv_chan=optarg; - break; - case 'L': - /* name of light in x-arm channel */ - CLA->lax_chan=optarg; - break; - case 'Y': - /* name of light in y-arm channel */ - CLA->lay_chan=optarg; + case 'i': + /* name of interferometer */ + if (strcmp(optarg, "H1") != 0 && strcmp(optarg, "H2") != 0 && + strcmp(optarg, "L1") != 0) { + fprintf(stderr, "Bad ifo: %s (must be H1, H2 or L1)\n", optarg); + exit(1); + } + CLA->ifo=optarg; + { + int i; + char *cnames[] = { sv_cname, lax_cname, lay_cname, asq_cname, + dctrl_cname, derr_cname, exc_cname }; + for (i = 0; i < 7; i++) + memcpy(cnames[i], CLA->ifo, 2); /* set channel names appropiately */ + } break; case 's': /* GPS start */ @@ -760,30 +696,6 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) /* GPS end */ CLA->GPSEnd=atof(optarg); break; - case 'i': - /* real part of OLG */ - CLA->G0Re=atof(optarg); - break; - case 'j': - /* imaginary part of OLG */ - CLA->G0Im=atof(optarg); - break; - case 'k': - /* real part of servo*/ - CLA->D0Re=atof(optarg); - break; - case 'l': - /* imaginary part of servo */ - CLA->D0Im=atof(optarg); - break; - case 'm': - /* real part of servo*/ - CLA->W0Re=atof(optarg); - break; - case 'n': - /* imaginary part of servo */ - CLA->W0Im=atof(optarg); - break; case 'd': /* use unit impulse*/ InputData.delta=1; @@ -833,25 +745,12 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) case 'h': /* print usage/help message */ printf("Arguments are:\n" -"\t-f, --cal-line-freq FLOAT Calibration line frequency in Hz.\n" "\t-t, --factors-time FLOAT Factors integration time in seconds.\n" -"\t-i, --olg-re FLOAT Real part of the open loop gain at the calibration line frequency.\n" -"\t-j, --olg-im FLOAT Imaginary part of the open loop gain at the calibration line frequency.\n" -"\t-k, --servo-re FLOAT Real part of the digital filter at the calibration line frequency.\n" -"\t-l, --servo-im FLOAT Imaginary part of digital filter at the calibration line frequency.\n" -"\t-m, --whitener-re FLOAT Real part of the whitening filter at the calibration line frequency.\n" -"\t-n, --whitener-im FLOAT Imaginary part of whitening filter at the calibration line frequency.\n" "\t-s, --gps-start-time INT GPS start time.\n" "\t-e, --gps-end-time INT GPS end time.\n" "\t-F, --filters-file STRING Name of file containing filters and histories.\n" "\t-C, --frame-cache STRING Name of frame cache file.\n" -"\t-A, --asq-channel STRING AS_Q channel name (eg, L1:LSC-AS_Q) [DEPRECATED].\n" -"\t-E, --exc-channel STRING Excitation channel name (eg, L1:LSC-ETMX_EXC_DAQ).\n" -"\t-D, --darm-channel STRING Darm channel name (eg, L1:LSC-DARM_CTRL).\n" -"\t-R, --darmerr-channel STRING Darm ERR channel name (eg, L1:LSC-DARM_ERR).\n" -"\t-V, --sv-channel STRING State Vector channel name (eg, L1:IFO-SV_STATE_VECTOR).\n" -"\t-L, --lax-channel STRING Light in X-arm channel name (eg, L1:LSC-LA_PTRX_NORM).\n" -"\t-Y, --lay-channel STRING Light in Y-arm channel name (eg, L1:LSC-LA_PTRY_NORM).\n" +"\t-i, --ifo STRING Name of the interferometer (H1, H2, L1).\n" "\t-o, --wings INTEGER Size of wings in seconds.\n" "\t-r, --test-sensing FLAG Output residual strain only.\n" "\t-c, --test-actuation FLAG Output control strain only.\n" @@ -877,42 +776,12 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) } } - if(CLA->f == 0.0) - { - fprintf(stderr,"No calibration line frequency specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } if(CLA->To == 0.0) { fprintf(stderr,"No integration time for the factors specified.\n"); fprintf(stderr,"Try %s -h \n", argv[0]); return 1; } - if(CLA->G0Re == 0.0 ) - { - fprintf(stderr,"No real part of open loop gain specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } - if(CLA->G0Im == 0.0 ) - { - fprintf(stderr,"No imaginary part of open loop gain specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } - if(CLA->D0Re == 0.0 ) - { - fprintf(stderr,"No real part of digital filter specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } - if(CLA->D0Im == 0.0 ) - { - fprintf(stderr,"No imaginary part of digital filter specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } if(CLA->GPSStart == 0) { fprintf(stderr,"No GPS start time specified.\n"); @@ -937,48 +806,11 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) fprintf(stderr,"Try %s -h \n", argv[0]); return 1; } - if(CLA->exc_chan == NULL) + if(CLA->ifo == NULL) { - fprintf(stderr,"No excitation channel specified.\n"); + fprintf(stderr,"No ifo specified.\n"); fprintf(stderr,"Try %s -h \n", argv[0]); return 1; - } - if(CLA->darm_chan == NULL) - { - fprintf(stderr,"No darm channel specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } - if(CLA->sv_chan == NULL) - { - fprintf(stderr,"No state vector channel specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } - if(CLA->lax_chan == NULL) - { - fprintf(stderr,"No light in x-arm channel specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } - if(CLA->lay_chan == NULL) - { - fprintf(stderr,"No light in y-arm channel specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } - if(CLA->darmerr_chan == NULL) - { - fprintf(stderr,"No darm err channel specified.\n"); - fprintf(stderr,"Try %s -h \n", argv[0]); - return 1; - } - if(CLA->asq_chan != NULL) - { - fprintf(stderr,"Warning: AS_Q channel specified, but it is not" - " used anymore in the calibration (it was only used" - " for computing the alpha factors before using the" - " Output Mode Cleaner). It will be renamed to the DARM_ERR channel.\n"); } if(CLA->frametype == NULL) { @@ -1009,9 +841,6 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) return 1; } - /* temporary hack: set the name of the (unused) as_q channel to darm_err */ - CLA->asq_chan=CLA->darmerr_chan; - /* Set some global variables */ duration = CLA->GPSEnd - CLA->GPSStart; gpsStartepoch.gpsSeconds = CLA->GPSStart; @@ -1034,11 +863,11 @@ int FreeMem(void) TESTSTATUS( &status ); LALSDestroyVector(&status,&InputData.EXC.data); TESTSTATUS( &status ); - LALSDestroyVector(&status,&StateVector.data); + LALSDestroyVector(&status,&InputData.StateVector.data); TESTSTATUS( &status ); - LALSDestroyVector(&status,&LAX.data); + LALSDestroyVector(&status,&InputData.LAX.data); TESTSTATUS( &status ); - LALSDestroyVector(&status,&LAY.data); + LALSDestroyVector(&status,&InputData.LAY.data); TESTSTATUS( &status ); /* Free filters */ diff --git a/lalapps/src/detresponse/bar_response.c b/lalapps/src/detresponse/bar_response.c index f0695583eb19d97232523c522eb3d51019ae97be..f828da0d845f876bde09721edad371070230ce0c 100644 --- a/lalapps/src/detresponse/bar_response.c +++ b/lalapps/src/detresponse/bar_response.c @@ -105,7 +105,7 @@ int main(int argc, char **argv) time_info.gps.gpsNanoSeconds = 0; make_gridding(&s, &g, n_ra, DETRESP_REGGRID, n_dec, DETRESP_REGGRID, - &ephem, &(time_info.gps), time_info.accuracy); + &ephem, &(time_info.gps)); print_ra_grid(&g, "bar_ra_grid.txt"); print_dec_grid(&g, "bar_dec_grid.txt"); diff --git a/lalapps/src/detresponse/compute_skygrid.c b/lalapps/src/detresponse/compute_skygrid.c index 4bf1a9229178b7491fa9185a0e926199b5a5e3ad..8aa2aaaf2f0b8818ac647fb3d5ad13c6a833493d 100644 --- a/lalapps/src/detresponse/compute_skygrid.c +++ b/lalapps/src/detresponse/compute_skygrid.c @@ -184,8 +184,6 @@ void compute_skygrid(LALStatus * status, EphemerisData *p_ephemeris_data, LALGPSandAcc gps_and_acc; LIGOTimeGPS start_time; LALTimeInterval time_interval; - LALLeapSecFormatAndAcc leapsec_info = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 tmp_leapsecs; REAL8 det_velocity[3]; @@ -288,7 +286,6 @@ void compute_skygrid(LALStatus * status, EphemerisData *p_ephemeris_data, args_info.nsample_given && args_info.sampling_interval_given) { - gps_and_acc.accuracy = leapsec_info.accuracy; gps_and_acc.gps.gpsSeconds = args_info.start_time_sec_arg; gps_and_acc.gps.gpsNanoSeconds = args_info.start_time_nanosec_arg; @@ -308,7 +305,6 @@ void compute_skygrid(LALStatus * status, EphemerisData *p_ephemeris_data, { if (args_info.start_time_sec_given) { - gps_and_acc.accuracy = leapsec_info.accuracy; gps_and_acc.gps.gpsSeconds = args_info.start_time_sec_arg; gps_and_acc.gps.gpsNanoSeconds = args_info.start_time_nanosec_arg; } @@ -363,13 +359,6 @@ void compute_skygrid(LALStatus * status, EphemerisData *p_ephemeris_data, printf("sum_file_name = %s\n", sum_file_name); printf("relfreq_file_name = %s\n", relfreq_file_name); } - - /* - * set leapsec info in ephemerides - */ - LALLeapSecs(status, &tmp_leapsecs, &(gps_and_acc.gps), &leapsec_info); - p_ephemeris_data->leap = (INT2)tmp_leapsecs; - LALDetectorVel(status, det_velocity, &(gps_and_acc.gps), detector, p_ephemeris_data); @@ -448,14 +437,6 @@ void compute_skygrid(LALStatus * status, EphemerisData *p_ephemeris_data, { fprintf(timesfile, "%.9d\n", gps_and_acc.gps.gpsSeconds); snprintf(dottimestamp, LALNameLength, ".%.9d", gps_and_acc.gps.gpsSeconds); - - /* - * set leapsec info in ephemerides - */ - LALLeapSecs(status, &tmp_leapsecs, &(gps_and_acc.gps), &leapsec_info); - p_ephemeris_data->leap = (INT2)tmp_leapsecs; - - LALDetectorVel(status, det_velocity, &(gps_and_acc.gps), detector, p_ephemeris_data); @@ -552,15 +533,8 @@ void compute_skygrid(LALStatus * status, EphemerisData *p_ephemeris_data, for (k = 0; k < (UINT4)args_info.nsample_arg; ++k) { - /* - * set leapsec info in ephemerides - */ - LALLeapSecs(status, &tmp_leapsecs, &(gps_and_acc.gps), &leapsec_info); - p_ephemeris_data->leap = (INT2)tmp_leapsecs; - - LALDetectorVel(status, det_velocity, &(gps_and_acc.gps), detector, p_ephemeris_data); - + for (j = start_ra; j < end_ra; ++j) { source.equatorialCoords.longitude = Pi_num_ra * (1. + 2.*j); diff --git a/lalapps/src/detresponse/ifo_response.c b/lalapps/src/detresponse/ifo_response.c index ede319a7050ca2ffdb120c78d16d6da11f187a56..1044d8cbd65f64810b3e61f79de339e4a3204328 100644 --- a/lalapps/src/detresponse/ifo_response.c +++ b/lalapps/src/detresponse/ifo_response.c @@ -108,7 +108,7 @@ int main(int argc, char **argv) time_info.gps.gpsNanoSeconds = 0; make_gridding(&s, &g, n_ra, DETRESP_REGGRID, n_dec, DETRESP_REGGRID, - &ephem, &(time_info.gps), time_info.accuracy); + &ephem, &(time_info.gps)); print_ra_grid(&g, "ifo_ra_grid.txt"); print_dec_grid(&g, "ifo_dec_grid.txt"); diff --git a/lalapps/src/detresponse/ifo_skyavg_ts.c b/lalapps/src/detresponse/ifo_skyavg_ts.c index 11bcb6d47163b9cf63025a8eb1a033d3f3035898..c00262e85f71b28729e6202803b1beb9abf5edbe 100644 --- a/lalapps/src/detresponse/ifo_skyavg_ts.c +++ b/lalapps/src/detresponse/ifo_skyavg_ts.c @@ -130,9 +130,9 @@ int main(int argc, char **argv) /* the gridding doesn't change with time */ make_gridding(&s, &g, n_ra, DETRESP_REGGRID, n_dec, DETRESP_REGGRID, - &ephem, &(time_info.gps), time_info.accuracy); + &ephem, &(time_info.gps)); make_gridding(&s, &delta_g, n_ra, DETRESP_REGGRID, n_dec, DETRESP_REGGRID, - &ephem, &(time_info.gps), time_info.accuracy); + &ephem, &(time_info.gps)); for (i = 0; i < g.ra->length - 1; ++i) { diff --git a/lalapps/src/detresponse/make_gridding.c b/lalapps/src/detresponse/make_gridding.c index 903858cfa0d34cf4d4a7948a9ad6f13348cefa6f..2003bd81f8a32ee1b98948feadd905498a8254b2 100644 --- a/lalapps/src/detresponse/make_gridding.c +++ b/lalapps/src/detresponse/make_gridding.c @@ -63,32 +63,23 @@ void make_gridding(LALStatus *s, gridding_t *g, UINT4 num_ra, gridding_geom_t ra_geom, UINT4 num_dec, gridding_geom_t dec_geom, - EphemerisData *e, - LIGOTimeGPS *gps, - LALLeapSecAccuracy acc) + EphemerisData *e, LIGOTimeGPS *gps ) { UINT4 i, j; REAL8 pi_num_ra = (REAL8)LAL_PI/(REAL8)num_ra; REAL8 earth_phi; /* azi. position of Earth in solar system barycenter */ - LALLeapSecFormatAndAcc leapsec_param = - {LALLEAPSEC_GPSUTC, acc}; - INT4 tmp_leapsecs; if (dec_geom == DETRESP_VARGRID) { fprintf(stderr, "gridding_t does not support variable Dec gridding\n"); exit(11); } - - /* set up leap seconds for given GPS */ - LALLeapSecs(s, &tmp_leapsecs, gps, &leapsec_param); - e->leap = (INT2)tmp_leapsecs; - + g->gps.gpsSeconds = gps->gpsSeconds; g->gps.gpsNanoSeconds = gps->gpsNanoSeconds; g->ra_geom = ra_geom; g->dec_geom = dec_geom; - + LALDCreateVector(s, &(g->dec), num_dec); diff --git a/lalapps/src/detresponse/make_gridding.h b/lalapps/src/detresponse/make_gridding.h index 711e97c23a9e141c1717fec7a4c034aaf1366c83..57d59ec9023500f449a443886b0a0d17c160f5f2 100644 --- a/lalapps/src/detresponse/make_gridding.h +++ b/lalapps/src/detresponse/make_gridding.h @@ -89,7 +89,6 @@ typedef struct tag_gridding_t { LIGOTimeGPS gps; - LALLeapSecAccuracy leapsec_accuracy; gridding_geom_t ra_geom; gridding_geom_t dec_geom; REAL8Vector *ra; @@ -104,8 +103,7 @@ void init_gridding(gridding_t *p_gridding); void make_gridding(LALStatus *status, gridding_t *p_gridding, UINT4 num_ra, gridding_geom_t ra_geom, UINT4 num_dec, gridding_geom_t dec_geom, - EphemerisData *p_ephem, LIGOTimeGPS *p_gps, - LALLeapSecAccuracy accuracy); + EphemerisData *p_ephem, LIGOTimeGPS *p_gps); void cleanup_gridding(LALStatus *status, gridding_t *p_gridding); diff --git a/lalapps/src/detresponse/test_gridding.c b/lalapps/src/detresponse/test_gridding.c index d4544215a769882c2a6d5ff7401e0f8d34281a07..405cf8373af18212c1f140ee6362b057fd297423 100644 --- a/lalapps/src/detresponse/test_gridding.c +++ b/lalapps/src/detresponse/test_gridding.c @@ -42,13 +42,11 @@ main(int argc, char **argv) UINT4 num_ra, num_dec; gridding_t g; LIGOTimeGPS gps; - LALLeapSecAccuracy acc = LALLEAPSEC_LOOSE; EphemerisData ephem; - INT4 leap_secs; s.statusPtr = NULL; - LALGPSTimeNow (&s, &gps, &acc); + XLALGPSTimeNow (&gps); init_ephemeris(&s, &ephem); @@ -59,7 +57,7 @@ main(int argc, char **argv) num_ra = 24; num_dec = 11; make_gridding(&s, &g, num_ra, DETRESP_REGGRID, - num_dec, DETRESP_REGGRID, &ephem, &gps, acc); + num_dec, DETRESP_REGGRID, &ephem, &gps); print_gridding(&g, "reg_dec_reg_ra.txt", DETRESP_HUMANREAD); print_gridding(&g, "reg_dec_reg_ra.dat", DETRESP_XYPAIRS_ASCII); @@ -75,7 +73,7 @@ main(int argc, char **argv) num_ra = 100; num_dec = 51; make_gridding(&s, &g, num_ra, DETRESP_IRRGRID, - num_dec, DETRESP_REGGRID, &ephem, &gps, acc); + num_dec, DETRESP_REGGRID, &ephem, &gps); print_gridding(&g, "autumn2003.txt", DETRESP_HUMANREAD); print_gridding(&g, "autumn2003.dat", DETRESP_XYPAIRS_ASCII); @@ -91,7 +89,7 @@ main(int argc, char **argv) num_ra = 100; num_dec = 51; make_gridding(&s, &g, num_ra, DETRESP_IRRGRID, - num_dec, DETRESP_REGGRID, &ephem, &gps, acc); + num_dec, DETRESP_REGGRID, &ephem, &gps); print_gridding(&g, "winter2003.txt", DETRESP_HUMANREAD); print_gridding(&g, "winter2003.dat", DETRESP_XYPAIRS_ASCII); @@ -107,7 +105,7 @@ main(int argc, char **argv) num_ra = 100; num_dec = 51; make_gridding(&s, &g, num_ra, DETRESP_IRRGRID, - num_dec, DETRESP_REGGRID, &ephem, &gps, acc); + num_dec, DETRESP_REGGRID, &ephem, &gps); print_gridding(&g, "spring2004.txt", DETRESP_HUMANREAD); print_gridding(&g, "spring2004.dat", DETRESP_XYPAIRS_ASCII); @@ -123,7 +121,7 @@ main(int argc, char **argv) num_ra = 48; num_dec = 22; make_gridding(&s, &g, num_ra, DETRESP_VARGRID, - num_dec, DETRESP_REGGRID, &ephem, &gps, acc); + num_dec, DETRESP_REGGRID, &ephem, &gps); print_gridding(&g, "reg_dec_var_ra.dat", DETRESP_XYPAIRS_ASCII); @@ -138,7 +136,7 @@ main(int argc, char **argv) num_ra = 48; num_dec = 22; make_gridding(&s, &g, num_ra, DETRESP_VARGRID, - num_dec, DETRESP_IRRGRID, &ephem, &gps, acc); + num_dec, DETRESP_IRRGRID, &ephem, &gps); print_gridding(&g, "irr_dec_var_ra.txt", DETRESP_HUMANREAD); print_gridding(&g, "irr_dec_var_ra.dat", DETRESP_XYPAIRS_ASCII); @@ -154,7 +152,7 @@ main(int argc, char **argv) num_ra = 48; num_dec = 22; make_gridding(&s, &g, num_ra, DETRESP_REGGRID, - num_dec, DETRESP_REGGRID, &ephem, &gps, acc); + num_dec, DETRESP_REGGRID, &ephem, &gps); print_ra_grid(&g, "test_ra_reg.txt"); print_dec_grid(&g, "test_dec_reg.txt"); diff --git a/lalapps/src/findchirp/BankEfficiency.c b/lalapps/src/findchirp/BankEfficiency.c index 830b621b1594c804b2fc00de0438e6b48ead4a07..01f150db830b45ab5d78d1ccc006d4f618434218 100644 --- a/lalapps/src/findchirp/BankEfficiency.c +++ b/lalapps/src/findchirp/BankEfficiency.c @@ -635,20 +635,20 @@ void BankEfficiencyGetResult( { LALInspiralParameterCalc( status->statusPtr, &trigger ); CHECKSTATUSPTR(status); - result->psi0_inject = 0.; - result->psi3_inject = 0.; - result->psi0_trigger = 0.; - result->psi3_trigger = 0.; - result->tau0_trigger = trigger.t0; - result->tau3_trigger = trigger.t3; - result->tau0_inject = injected.t0; - result->tau3_inject = injected.t3; + result->psi0_inject = 0.; + result->psi3_inject = 0.; + result->psi0_trigger = 0.; + result->psi3_trigger = 0.; + result->mass1_trigger = trigger.mass1; + result->mass2_trigger = trigger.mass2; + result->tau0_trigger = trigger.t0; + result->tau3_trigger = trigger.t3; + result->tau0_inject = injected.t0; + result->tau3_inject = injected.t3; result->polarisationAngle = injected.polarisationAngle; - result->inclination = injected.inclination; + result->inclination = injected.inclination; } - result->mass1_trigger = trigger.mass1; - result->mass2_trigger = trigger.mass2; result->mass1_inject = injected.mass1; result->mass2_inject = injected.mass2; result->fend_inject = injected.fFinal; @@ -674,12 +674,14 @@ void BankEfficiencyPrintResults( { FILE *fs; fprintf(stdout, - "%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %d\n", + "%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %d\n", result.mass1_trigger, result.mass2_trigger, /* randIn.param.psi0, randIn.param.psi3, +*/ result.tau0_trigger, result.tau3_trigger, randIn.param.t0, randIn.param.t3, +/* result.eccentricity, randIn.param.eccentricity,randIn.param.alpha1, */ randIn.param.mass1,randIn.param.mass2, @@ -3790,6 +3792,9 @@ void BankEfficiencyAscii2Xml(void) fprintf(stderr,"reading the ascii file -- and saving xml file"); while ((fgets(sbuf, 2048, input1))!= NULL) { + /* We use a temporarily restricted output. */ + /* When full output reinstated , restore the line below */ + /* sscanf(sbuf,BANKEFFICIENCY_PARAMS_ROW_SPACE, &trigger.mass1_trigger, &trigger.mass2_trigger, &psi0, &psi3, &tau0, &tau3, &tau0I, &tau3I, &ecc,&eccI,&eccI_fl, @@ -3797,7 +3802,12 @@ void BankEfficiencyAscii2Xml(void) &trigger.mass1_inject, &trigger.mass2_inject,&inclination,&polarisation, &phaseI, &trigger.rho_final, &trigger.snrAtCoaTime, &trigger.phase, &trigger.alphaF, &trigger.bin, &nStartPad, &trigger.nfast, &nfast_max, - &bestEMatch); + &bestEMatch);*/ + + sscanf(sbuf,"%f %f %f %f %f %f %f %f %f %f %f %d", &trigger.mass1_trigger, &trigger.mass2_trigger, + &tau0, &tau3, &tau0I, &tau3I, + &trigger.mass1_inject, &trigger.mass2_inject, &trigger.fend_trigger, &trigger.fend_inject, + &trigger.rho_final, &trigger.bin ); fprintf(output, BANKEFFICIENCY_PARAMS_ROW, diff --git a/lalapps/src/findchirp/TestRandomBank.c b/lalapps/src/findchirp/TestRandomBank.c index 22956a57f8e0731034076261bfab21b0b0bafe6e..0ecb4a2e5b96770cbd9b0e36a91f69d788515515 100644 --- a/lalapps/src/findchirp/TestRandomBank.c +++ b/lalapps/src/findchirp/TestRandomBank.c @@ -2193,7 +2193,6 @@ BEPrintResultsXml( InspiralCoarseBankIn coarseBankIn, CHAR fname[256]; LIGOTimeGPS gpsStartTime = { 0, 0 }; /* input data GPS start time */ LIGOTimeGPS gpsEndTime = { 0, 0 }; /* input data GPS end time */ - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; CHAR comment[LIGOMETA_COMMENT_MAX]; CHAR ifoName[MAXIFO][LIGOMETA_IFO_MAX]; @@ -2218,8 +2217,7 @@ BEPrintResultsXml( InspiralCoarseBankIn coarseBankIn, /* create the process and process params tables */ templateBank.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(templateBank.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(templateBank.processTable->start_time)); LAL_CALL( populate_process_table( &status, templateBank.processTable, PROGRAM_NAME, @@ -2236,9 +2234,8 @@ BEPrintResultsXml( InspiralCoarseBankIn coarseBankIn, /* write process table */ snprintf( templateBank.processTable->ifos, LIGOMETA_IFOS_MAX, "%s%s", ifoName[0], ifoName[1] ); - LAL_CALL( LALGPSTimeNow ( &status, &(templateBank.processTable->end_time), - &accuracy ), &status ); - + XLALGPSTimeNow(&(templateBank.processTable->end_time)); + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, templateBank, @@ -2355,7 +2352,6 @@ BEPrintProtoXml(InspiralCoarseBankIn coarseBankIn, CHAR fname[256]; LIGOTimeGPS gpsStartTime = { 0, 0 }; /* input data GPS start time */ LIGOTimeGPS gpsEndTime = { 0, 0 }; /* input data GPS end time */ - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; CHAR comment[LIGOMETA_COMMENT_MAX]; CHAR ifoName[MAXIFO][LIGOMETA_IFO_MAX]; @@ -2383,8 +2379,7 @@ BEPrintProtoXml(InspiralCoarseBankIn coarseBankIn, /* create the process and process params tables */ templateBank.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(templateBank.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(templateBank.processTable->start_time)); LAL_CALL( populate_process_table( &status, templateBank.processTable, PROGRAM_NAME, CVS_REVISION, CVS_SOURCE, CVS_DATE ), &status ); this_proc_param = processParamsTable.processParamsTable = @@ -2399,9 +2394,8 @@ BEPrintProtoXml(InspiralCoarseBankIn coarseBankIn, /* write process table */ snprintf( templateBank.processTable->ifos, LIGOMETA_IFOS_MAX, "%s%s", ifoName[0], ifoName[1] ); - LAL_CALL( LALGPSTimeNow ( &status, &(templateBank.processTable->end_time), - &accuracy ), &status ); - + XLALGPSTimeNow(&(templateBank.processTable->end_time)); + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, templateBank, @@ -4340,7 +4334,6 @@ void LALBankPrintXML(MetadataTable templateBank , CHAR fname[256]; LIGOTimeGPS gpsStartTime = { 0, 0 }; /* input data GPS start time */ LIGOTimeGPS gpsEndTime = { 0, 0 }; /* input data GPS end time */ - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; CHAR comment[LIGOMETA_COMMENT_MAX]; CHAR ifoName[3][LIGOMETA_IFO_MAX]; MetadataTable processParamsTable; @@ -4365,9 +4358,9 @@ void LALBankPrintXML(MetadataTable templateBank , /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + + + XLALGPSTimeNow(&(proctable.processTable->start_time)); LAL_CALL( populate_process_table( &status, proctable.processTable, PROGRAM_NAME, CVS_REVISION, CVS_SOURCE, CVS_DATE ), &status ); this_proc_param = processParamsTable.processParamsTable = @@ -4382,9 +4375,8 @@ void LALBankPrintXML(MetadataTable templateBank , /* write process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "%s%s", ifoName[0], ifoName[1] ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); - + XLALGPSTimeNow(&(proctable.processTable->end_time)); + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/findchirp/inspmultiawg.c b/lalapps/src/findchirp/inspmultiawg.c index 9c53fcfe87f3f3f954d51ca2242f94831db4ce32..d98d06e004a3ec02b415247d99ca48fb72c6659c 100644 --- a/lalapps/src/findchirp/inspmultiawg.c +++ b/lalapps/src/findchirp/inspmultiawg.c @@ -176,7 +176,6 @@ main(int argc, char **argv) BOOLEAN ok = 1; /* whether input format is correct */ UINT4 i; /* generic index over file lines */ INT8 epoch; /* epoch stored as an INT8 */ - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; ProcessParamsTable *this_proc_param; MetadataTable proctable; MetadataTable procparams; @@ -206,8 +205,7 @@ main(int argc, char **argv) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &stat, &(proctable.processTable->start_time), - &accuracy ), &stat ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); LAL_CALL( populate_process_table( &stat, proctable.processTable, PROGRAM_NAME, CVS_REVISION, CVS_SOURCE, CVS_DATE ), &stat ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) @@ -746,8 +744,7 @@ main(int argc, char **argv) /* write out the process and process params tables */ - LAL_CALL( LALGPSTimeNow ( &stat, &(proctable.processTable->end_time), - &accuracy ), &stat ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &stat, &xmlStream, process_table ), &stat ); diff --git a/lalapps/src/findchirp/ivana.c b/lalapps/src/findchirp/ivana.c index e15477e18f4ff1cc84e85e6c172dfaef0625229e..54d2f04419f596190635c593035a68e53a12121c 100644 --- a/lalapps/src/findchirp/ivana.c +++ b/lalapps/src/findchirp/ivana.c @@ -23,7 +23,7 @@ Written June-July 2002 by Peter Shawhan Modified various times after that To compile/link on Solaris: -gcc -g ivana.c -I$LIGOTOOLS/include -L$LIGOTOOLS/lib -ldataflow -lsocket -lnsl\ +gcc -g ivana.c -I$LIGOTOOLS/include -L$LIGOTOOLS/lib -lmetaio -lsocket -lnsl\ -o ivana Usage example: diff --git a/lalapps/src/frametools/Makefile.am b/lalapps/src/frametools/Makefile.am index efa7d44e955af46c2da4a847d33e56c856442f03..b690c2c2cf8c1cf08571bb6802eb4d495041d8e4 100644 --- a/lalapps/src/frametools/Makefile.am +++ b/lalapps/src/frametools/Makefile.am @@ -1,12 +1,10 @@ -## Process this file with automake to produce Makefile.in -# $Id$ if FRAME -FRAMEPROGRAMS = lalapps_animate lalapps_calfacs lalapps_computespec \ - lalapps_frinfo lalapps_frread lalapps_frextr lalapps_frjoin +FRAMEPROGRAMS = \ + lalapps_frinfo \ + lalapps_frread \ + lalapps_frextr \ + lalapps_frjoin #lalapps_stripAdc_SOURCES = stripAdc.c lalDebugLevel.c -lalapps_animate_SOURCES = animate.c -lalapps_calfacs_SOURCES = calfacs.c -lalapps_computespec_SOURCES = computespec.c lalapps_frinfo_SOURCES = info.c lalapps_frread_SOURCES = read.c lalapps_frextr_SOURCES = extr.c @@ -14,17 +12,45 @@ lalapps_frjoin_SOURCES = join.c else FRAMEPROGRAMS = endif + +if LALFRAME +LALFRAMEPROGRAMS = \ + lalapps_animate \ + lalapps_calfacs \ + lalapps_computespec +lalapps_animate_SOURCES = animate.c +lalapps_calfacs_SOURCES = calfacs.c +lalapps_computespec_SOURCES = computespec.c +else +LALFRAMEPROGRAMS = +endif + if LALFRAME if LALMETAIO -LALFRAMEPROGRAMS = lalapps_frview +LALFRAMEMETAIOPROGRAMS = lalapps_frview lalapps_frview_SOURCES = view.c else -LALFRAMEPROGRAMS = +LALFRAMEMETAIOPROGRAMS = endif else -LALFRAMEPROGRAMS = +LALFRAMEMETAIOPROGRAMS = endif -bin_PROGRAMS = $(FRAMEPROGRAMS) $(LALFRAMEPROGRAMS) -EXTRA_DIST = stripAdc.c lalDebugLevel.c animate.c calfacs.c computespec.c + +bin_PROGRAMS = \ + $(FRAMEPROGRAMS) \ + $(LALFRAMEPROGRAMS) \ + $(LALFRAMEMETAIOPROGRAMS) + +EXTRA_DIST = \ + stripAdc.c \ + lalDebugLevel.c \ + info.c \ + read.c \ + extr.c \ + join.c \ + animate.c \ + calfacs.c \ + computespec.c + INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/lalapps LDADD = $(top_builddir)/src/lalapps/liblalapps.la diff --git a/lalapps/src/inspiral/Makefile.am b/lalapps/src/inspiral/Makefile.am index d81f3a02951bbc1332490e2b9aae3536f82eae0b..a049d47ddc6a3e0f4cbdd6abc65d98564756cd90 100644 --- a/lalapps/src/inspiral/Makefile.am +++ b/lalapps/src/inspiral/Makefile.am @@ -20,6 +20,7 @@ BBHINJSRC = bbhinj.c BLINDINJSRC = blindinj.c SPLITBANKSRC = splitbank.c TRIGBANKSRC = trigbank.c +TRIGSCANSRC = trigscan.c INSPFRINJSRC = inspfrinj.c GWF2XMLSRC = gwf2xml.c SPININJSRC = spininj.c @@ -47,7 +48,7 @@ bin_PROGRAMS = lalapps_inspiral lalapps_tmpltbank \ lalapps_inspinj lalapps_injcut lalapps_splitbank \ lalapps_minj lalapps_bbhinj lalapps_blindinj \ lalapps_inspfrinj lalapps_gwf2xml \ - lalapps_thinca lalapps_trigbank \ + lalapps_thinca lalapps_trigbank lalapps_trigscan \ lalapps_spininj lalapps_coherent_inspiral lalapps_cohire \ lalapps_coherentbank lalapps_coinext \ lalapps_randombank lalapps_ninja lalapps_fr_ninja \ @@ -71,6 +72,7 @@ lalapps_bbhinj_SOURCES = $(BBHINJSRC) lalapps_blindinj_SOURCES = $(BLINDINJSRC) lalapps_splitbank_SOURCES = $(SPLITBANKSRC) lalapps_trigbank_SOURCES = $(TRIGBANKSRC) +lalapps_trigscan_SOURCES = $(TRIGSCANSRC) lalapps_spininj_SOURCES = $(SPININJSRC) lalapps_inspfrinj_SOURCES = $(INSPFRINJSRC) lalapps_gwf2xml_SOURCES = $(GWF2XMLSRC) @@ -166,7 +168,9 @@ lalapps_cbc_pipedown: $(srcdir)/cbc_pipedown.in python_config.sed chmod +x lalapps_cbc_pipedown -pkgdata_DATA = BNSMasses.dat inspsrcs100Mpc.complete inspsrcs100Mpc.errors inspiral_pipe.ini inspiral_hipe.ini online.ini online_inject_bbh.ini ihope.ini cbc_pipedown.ini followup_pipe.ini plot_hipe.ini write_ihope_page.ini write_ihope_style.css +pkgdata_DATA = BNSMasses.dat inspsrcs100Mpc.complete inspsrcs100Mpc.errors inspiral_pipe.ini inspiral_hipe.ini online.ini online_inject_bbh.ini ihope.ini cbc_pipedown.ini followup_pipe.ini plot_hipe.ini write_ihope_page.ini write_ihope_style.css s5_background_H0H1-RDS_R_L1-cbc.txt s5_background_H0H1-RDS_R_L1-seismic-cbc.txt s5_background_H0H2-RDS_R_L1-cbc.txt s5_background_H0H2-RDS_R_L1-seismic-cbc.txt s5_background_H1_hoft_cbc.txt s5_background_H2_hoft_cbc.txt s5_background_L0L1-RDS_R_L1-cbc.txt s5_background_L0L1-RDS_R_L1-seismic-cbc.txt s5_background_L1_hoft_cbc.txt s5_background_V1-raw-cbc.txt s5_background_V1-raw-seismic-cbc.txt s5_background_V1_hoft_cbc.txt s5_foreground_H0H1-RDS_R_L1-cbc.txt s5_foreground_H0H1-RDS_R_L1-seismic-cbc.txt s5_foreground_H0H2-RDS_R_L1-cbc.txt s5_foreground_H0H2-RDS_R_L1-seismic-cbc.txt s5_foreground_H1_hoft_cbc.txt s5_foreground_H2_hoft_cbc.txt s5_foreground_L0L1-RDS_R_L1-cbc.txt s5_foreground_L0L1-RDS_R_L1-seismic-cbc.txt s5_foreground_L1_hoft_cbc.txt s5_foreground_V1-raw-cbc.txt s5_foreground_V1-raw-seismic-cbc.txt s5_foreground_V1_hoft_cbc.txt s6_foreground_H0H1-RDS_R_L1-cbc.txt s6_foreground_H0H1-RDS_R_L1-seismic-cbc.txt s6_foreground_H1_hoft_cbc.txt s6_foreground_L0L1-RDS_R_L1-cbc.txt s6_foreground_L0L1-RDS_R_L1-seismic-cbc.txt s6_foreground_L1_hoft_cbc.txt s6_foreground_V1-raw-cbc.txt s6_foreground_V1-raw-seismic-cbc.txt s6_foreground_V1_hoft_cbc.txt remove_h1h2.sql cluster.sql simplify.sql + + EXTRA_DIST = $(INSPIRALSRC) $(TMPLTBANKSRC) \ $(SIRESRC) $(COIRESRC) $(SIVASRC) $(MINJSRC) \ $(INCASRC) $(COHERESRC) $(INSPINJSRC) \ diff --git a/lalapps/src/inspiral/bbhinj.c b/lalapps/src/inspiral/bbhinj.c index 5145671025d474bc9f98f99e65b30cfcbf592e5a..5feb06de85cb905f3f4b401b063233a3cb8cf08d 100644 --- a/lalapps/src/inspiral/bbhinj.c +++ b/lalapps/src/inspiral/bbhinj.c @@ -110,17 +110,17 @@ RCSID( "$Id$" ); #define S2StopTime 734367613 /* Apr 14 2003 15:00:00 UTC */ /* all units are in kpc since this is what GalacticInspiralParamStruc expects */ static ProcessParamsTable *next_process_param( - const char *name, - const char *type, - const char *fmt, ... ); + const char *name, + const char *type, + const char *fmt, ... ); extern int vrbflg; ProcessParamsTable *next_process_param( - const char *name, - const char *type, - const char *fmt, ... ) + const char *name, + const char *type, + const char *fmt, ... ) { ProcessParamsTable *pp; va_list ap; @@ -148,9 +148,8 @@ ProcessParamsTable *next_process_param( int main( int argc, char *argv[] ) { LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; - #if 0 - const INT4 S2StartTime = 729273613; /* Feb 14 2003 16:00:00 UTC */ +#if 0 + const INT4 S2StartTime = 729273613; /* Feb 14 2003 16:00:00 UTC */ const INT4 S2StopTime = 734367613; /* Apr 14 2003 15:00:00 UTC */ #endif /* command line options */ @@ -166,7 +165,7 @@ int main( int argc, char *argv[] ) UINT4 sumMaxMassUse=0; /* flag indicating to use the sumMaxMass */ REAL4 dmin = 1.0; /* minimum distance from earth (kpc) */ REAL4 dmax = 20000.0 ; /* maximum distance from earth (kpc) */ - REAL4 fLower = 0; /* default value for th lower cut off frequency */ + REAL4 fLower = 0; /* default value for th lower cut off frequency */ /* REAL4 Rcore = 0.0; */ UINT4 ddistr = 0, mdistr=0; @@ -174,9 +173,6 @@ int main( int argc, char *argv[] ) RandomParams *randParams = NULL; REAL4 u, exponent, d2; REAL4 deltaM, mtotal; - /* XXX CHECK XXX */ - LALMSTUnitsAndAcc gmstUnits = { MST_HRS, LALLEAPSEC_STRICT }; - /* XXX END CHECK XXX */ /* waveform */ @@ -208,7 +204,7 @@ int main( int argc, char *argv[] ) {"verbose", no_argument, &vrbflg, 1 }, {"write-compress", no_argument, &outCompress, 1 }, {"version", no_argument, 0, 'V'}, - {"f-lower", required_argument, 0, 'f'}, + {"f-lower", required_argument, 0, 'f'}, {"gps-start-time", required_argument, 0, 'a'}, {"gps-end-time", required_argument, 0, 'b'}, {"time-step", required_argument, 0, 't'}, @@ -237,20 +233,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) @@ -433,14 +428,14 @@ int main( int argc, char *argv[] ) { fprintf( stderr, "invalid argument to --%s:\n" "sum of two component masses must be > 0: " - "(%f solar masses specified)\n", - long_options[option_index].name, sumMaxMass ); + "(%f solar masses specified)\n", + long_options[option_index].name, sumMaxMass ); exit( 1 ); } sumMaxMassUse=1; this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, - "float", "%e", sumMaxMass ); + "float", "%e", sumMaxMass ); break; case 'p': @@ -537,7 +532,7 @@ int main( int argc, char *argv[] ) "Duncan A Brown and Eirini Messaritaki\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -677,8 +672,13 @@ int main( int argc, char *argv[] ) } /* set gmst */ - LAL_CALL( LALGPStoGMST1( &status, &(this_inj->end_time_gmst), - &(this_inj->geocent_end_time), &gmstUnits ), &status); + this_inj->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &this_inj->geocent_end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + if( XLAL_IS_REAL8_FAIL_NAN(this_inj->end_time_gmst) ) + { + fprintf(stderr, "XLALGreenwichMeanSiderealTime() failed\n"); + exit(1); + } /* XXX END CHECK XXX */ /* populate the sim_inspiral table */ @@ -702,10 +702,10 @@ int main( int argc, char *argv[] ) mtotal = 2.0 * minMass + u * 2.0 *deltaM ; if (sumMaxMassUse==1) { - while (mtotal > sumMaxMass) { - LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status); - mtotal = 2.0 * minMass + u * 2.0 *deltaM ; - } + while (mtotal > sumMaxMass) { + LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status); + mtotal = 2.0 * minMass + u * 2.0 *deltaM ; + } } LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); @@ -809,13 +809,13 @@ int main( int argc, char *argv[] ) &gpsEndTime ), &status ); /* finally populate the flower */ - if (fLower > 0) + if (fLower > 0) { - this_inj->f_lower = fLower; + this_inj->f_lower = fLower; } else { - this_inj->f_lower = 0; + this_inj->f_lower = 0; } /* XXX END CHECK XXX */ @@ -838,8 +838,7 @@ int main( int argc, char *argv[] ) /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable, diff --git a/lalapps/src/inspiral/blindinj.c b/lalapps/src/inspiral/blindinj.c index d23de782087b97ca86d454cdf741f137403efff1..8d881170b19db877fef33e6fcbe79711954e4dce 100644 --- a/lalapps/src/inspiral/blindinj.c +++ b/lalapps/src/inspiral/blindinj.c @@ -428,7 +428,6 @@ static REAL4TimeSeries *injectWaveform( int main( int argc, char *argv[] ) { LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; LIGOTimeGPS gpsStartTime = {0, 0}; LIGOTimeGPS earliestEndTime = {0, 0}; ResponseFunction injectionResponse = noResponse; @@ -512,20 +511,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) @@ -639,7 +637,7 @@ int main( int argc, char *argv[] ) "Stephen Fairhurst\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -965,8 +963,7 @@ int main( int argc, char *argv[] ) /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable, diff --git a/lalapps/src/inspiral/calcexpsnr.c b/lalapps/src/inspiral/calcexpsnr.c index 28553c3108878909594d1a84e9073b9e13d0f339..10adfa66dc36cbaa2cd68a03063d29c5211b28ff 100644 --- a/lalapps/src/inspiral/calcexpsnr.c +++ b/lalapps/src/inspiral/calcexpsnr.c @@ -233,7 +233,6 @@ int main( int argc, char *argv[] ) /* output data */ LIGOLwXMLStream xmlStream; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; MetadataTable proctable; MetadataTable outputTable; MetadataTable procparams; @@ -253,20 +252,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->start_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -412,7 +410,7 @@ int main( int argc, char *argv[] ) "Gareth Jones\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -840,7 +838,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->end_time), &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, process_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlStream ), &status ); diff --git a/lalapps/src/inspiral/cbc_pipedown.in b/lalapps/src/inspiral/cbc_pipedown.in index e7e6fb5a7f5e14308267c2c7cbd1fac0ead7c75b..95603dccbbc722b3a3c91fe24547432747b80358 100644 --- a/lalapps/src/inspiral/cbc_pipedown.in +++ b/lalapps/src/inspiral/cbc_pipedown.in @@ -21,12 +21,27 @@ sys.path.append('@PYTHONLIBDIR@') # import the modules we need to build the pipeline from glue import pipeline from glue import lal +from glue import iterutils from glue.ligolw import lsctables import inspiral ############################################################################## # Function Definitions +def get_veto_cat_from_tag( tag ): + """ + Returns the veto category number in a tag. + Assumes tag has the form _CAT_N_VETO for N>1 and + nothing for N=1. + """ + if 'VETO' in tag: + cat_num = int(tag.split('_')[-2]) + else: + # is category 1 veto + cat_num = 1 + + return cat_num + def get_veto_segments_name( veto_cat_num, cumulative = True ): """ Given a category number, returns a veto segments name @@ -77,10 +92,13 @@ parser.add_option( "", "--gps-end-time", action = "store", type = "string", help = "GPS end time of the ihope run." ) -parser.add_option( "", "--plot-playground-only", action = "store_true", +parser.add_option( "", "--generate-all-data-plots", action = "store_true", default = False, help = - "Turn on if want plots of playground data only." + "Turn on if want to open the box. Otherwise, only plots of playground " + + "data will be made. WARNING: Even if this option is off, all_data and " + + "and exclude_play coincs will still exist in the resulting databases " + + "(they just won't be plotted)." ) (options, args) = parser.parse_args() @@ -99,6 +117,8 @@ if not options.log_path: cp = ConfigParser.ConfigParser() cp.read(options.config_file) +tmp_space = cp.get('pipeline', 'node-tmp-dir') + experiment_start = options.gps_start_time experiment_duration = str(int(options.gps_end_time) - int(options.gps_start_time)) @@ -128,7 +148,8 @@ dag.set_dag_file(basename) print "Parsing the ihope cache..." ihope_cache = [line for line in file(options.ihope_cache) \ - if "THINCA_SECOND" in line or "THINCA_SLIDE_SECOND" in line or " INJECTIONS" in line] + if "THINCA_SECOND" in line or "THINCA_SLIDE_SECOND" in line \ + or " INJECTIONS" in line or "INSPIRAL_SECOND" in line] zero_lag_cache = lal.Cache([lal.CacheEntry(entry) for entry in ihope_cache \ if "THINCA_SECOND" in entry]) @@ -136,6 +157,8 @@ slide_cache = lal.Cache([lal.CacheEntry(entry) for entry in ihope_cache \ if "THINCA_SLIDE_SECOND" in entry]) inj_cache = lal.Cache([lal.CacheEntry(entry) for entry in ihope_cache if \ " INJECTIONS" in entry]) +all_inspirals_cache = lal.Cache([lal.CacheEntry(entry) for entry in ihope_cache \ + if "INSPIRAL_SECOND" in entry]) del ihope_cache @@ -144,9 +167,99 @@ user_tags = set([ '_'.join([ entry.description.split('_')[ii] for ii in range( 3, len(entry.description.split('_')) ) ]) for entry in zero_lag_cache ]) +# create a list to store non-injection databases for later caching +non_sim_dbs = [] + +############################################################################## +# Create the needed jobs to be run + +# thinca_to_coinc jobs +t2c_job = inspiral.ThincaToCoincJob(cp) +t2c_job.set_experiment_start_time(options.gps_start_time) +t2c_job.set_experiment_end_time(options.gps_end_time) +# because t2c simulation jobs require the --simulation option to be set, these +# must be separate +t2c_sim_job = inspiral.ThincaToCoincJob(cp) +t2c_sim_job.set_simulation() +t2c_sim_job.set_experiment_start_time(options.gps_start_time) +t2c_sim_job.set_experiment_end_time(options.gps_end_time) + +# ligolw_sqlite jobs; there are 4 different types: +# 1. sql_replace_job: reads from a cache and writes to a database +# with the --replace option set (only for adding thinca_to_coinc files ) +# 2. sql_fromcache_job: reads from a cache and writes to a database without +# the replace option +# 3. sql_frominput_job: adds a single file to a databse (for veto xml files) +# 4. sql_extract_job: extracts xmls from a database (for turning simulation +# databases into xml files) +sql_replace_job = pipeline.LigolwSqliteJob(cp) +sql_replace_job.set_replace() +sql_fromcache_job = pipeline.LigolwSqliteJob(cp) +sql_frominput_job = pipeline.LigolwSqliteJob(cp) +sql_extract_job = pipeline.LigolwSqliteJob(cp) + +# for plotting jobs with plot_playground_only option, only create jobs without +# if generate-all-data-plots set +plotslides_play_job = inspiral.PlotSlidesJob(cp) +plotslides_play_job.set_plot_playground_only() +plotcumhist_play_job = inspiral.PlotCumhistJob(cp) +plotcumhist_play_job.set_plot_playground_only() +if options.generate_all_data_plots: + plotslides_job = inspiral.PlotSlidesJob(cp) + plotcumhist_job = inspiral.PlotCumhistJob(cp) + +# all other jobs: all the nodes share the same static options for these +dbsimplify_job = inspiral.DBSimplifyJob(cp) +dbaddinj_job = inspiral.DBAddInjJob(cp) +inspinjfind_job = inspiral.InspInjFindJob(cp) +comp_durs_job = inspiral.ComputeDurationsJob(cp) +cluster_job = inspiral.ClusterCoincsJob(cp) +ucfar_job = inspiral.CFarJob(cp, ['cfar-uncombined']) +ccfar_job = inspiral.CFarJob(cp, ['cfar-combined']) +printlc_job = inspiral.PrintLCJob(cp) +minifup_job = inspiral.MiniFollowupsJob(cp) +plotifar_job = inspiral.PlotIfarJob(cp) + +# set better submit file names than the default +t2c_job.set_sub_file( '.'.join([ basename, 'thinca_to_coinc', 'sub' ]) ) +t2c_sim_job.set_sub_file( '.'.join([ basename, 'simulation', 'thinca_to_coinc', 'sub' ]) ) +sql_replace_job.set_sub_file( '.'.join([ basename, 'replace_from_cache', 'ligolw_sqlite', 'sub' ]) ) +sql_fromcache_job.set_sub_file( '.'.join([ basename, 'add_from_cache', 'ligolw_sqlite', 'sub' ]) ) +sql_frominput_job.set_sub_file( '.'.join([ basename, 'add_from_input', 'ligolw_sqlite', 'sub' ]) ) +sql_extract_job.set_sub_file( '.'.join([ basename, 'extract', 'ligolw_sqlite', 'sub' ]) ) +dbsimplify_job.set_sub_file( '.'.join([ basename, 'dbsimplify', 'sub' ]) ) +dbaddinj_job.set_sub_file( '.'.join([ basename, 'dbaddinj', 'sub' ]) ) +inspinjfind_job.set_sub_file( '.'.join([ basename, 'inspinjfind', 'sub' ]) ) +comp_durs_job.set_sub_file( '.'.join([ basename, 'compute_durations', 'sub' ]) ) +cluster_job.set_sub_file( '.'.join([ basename, 'cluster_coincs', 'sub' ]) ) +ucfar_job.set_sub_file( '.'.join([ basename, 'uncombined', 'cfar', 'sub' ]) ) +ccfar_job.set_sub_file( '.'.join([ basename, 'combined', 'cfar', 'sub' ]) ) +printlc_job.set_sub_file( '.'.join([ basename, 'printlc', 'sub' ]) ) +minifup_job.set_sub_file( '.'.join([ basename, 'minifollowups', 'sub' ]) ) +plotifar_job.set_sub_file( '.'.join([ basename, 'plotifar', 'sub' ]) ) +plotslides_play_job.set_sub_file( '.'.join([ basename, 'playground_only', 'plotslides', 'sub' ]) ) +plotcumhist_play_job.set_sub_file( '.'.join([ basename, 'playground_only', 'plotcumhist', 'sub' ]) ) +if options.generate_all_data_plots: + plotslides_job.set_sub_file( '.'.join([ basename, 'plotslides', 'sub' ]) ) + plotcumhist_job.set_sub_file( '.'.join([ basename, 'plotcumhist', 'sub' ]) ) + +# set memory requirments for memory intensive jobs +t2c_job.add_condor_cmd("requirements", "Memory > 1000") +t2c_sim_job.add_condor_cmd("requirements", "Memory > 1000") +sql_replace_job.add_condor_cmd("requirements", "Memory > 1000") +sql_fromcache_job.add_condor_cmd("requirements", "Memory > 1000") +sql_frominput_job.add_condor_cmd("requirements", "Memory > 1000") +sql_extract_job.add_condor_cmd("requirements", "Memory > 1000") +inspinjfind_job.add_condor_cmd("requirements", "Memory > 1000") +printlc_job.add_condor_cmd("requirements", "Memory > 1000") +minifup_job.add_condor_cmd("requirements", "Memory > 1000") + ############################################################################## -# Cycle over the user tags, creating a pipeline for each +# Cycle over the user tags, creating databases for each +veto_files = {} +cluster_nodes = {} +inspinjfind_parents = {} for tag in user_tags: print "Creating jobs for %s..." % tag @@ -164,32 +277,6 @@ for tag in user_tags: else: raise ValueError, "More than one injection file found for %s" % tag - # write the jobs that will be run - t2c_job = inspiral.ThincaToCoincJob(cp) - tosql_job = pipeline.LigolwSqliteJob(cp) - dbsimplify_job = inspiral.DBSimplifyJob(cp) - cluster_job = inspiral.ClusterCoincsJob(cp) - ucfar_job = inspiral.CFarJob(cp, ['cfar-uncombined']) - ccfar_job = inspiral.CFarJob(cp, ['cfar-combined']) - if simulation: - dbaddinj_job = inspiral.DBAddInjJob(cp) - else: - plotslides_job = inspiral.PlotSlidesJob(cp) - plotifar_job = inspiral.PlotIfarJob(cp) - - # set better submit file names than the default - subsuffix = 'sub' - t2c_job.set_sub_file( '.'.join([ basename, tag, 'thinca_to_coinc', 'sub' ]) ) - tosql_job.set_sub_file( '.'.join([ basename, tag, 'ligolw_sqlite', 'sub' ]) ) - dbsimplify_job.set_sub_file( '.'.join([ basename, tag, 'dbsimplify', 'sub' ]) ) - cluster_job.set_sub_file( '.'.join([ basename, tag, 'cluster_coincs', 'sub' ]) ) - ucfar_job.set_sub_file( '.'.join([ basename, tag, 'uncombined.cfar', 'sub' ]) ) - ccfar_job.set_sub_file( '.'.join([ basename, tag, 'combined.cfar', 'sub' ]) ) - if simulation: - dbaddinj_job.set_sub_file ( '.'.join([ basename, tag, 'dbaddinj', 'sub' ]) ) - else: - plotslides_job.set_sub_file( '.'.join([ basename, tag, 'plotslides', 'sub' ]) ) - plotifar_job.set_sub_file( '.'.join([ basename, tag, 'plotifar', 'sub' ]) ) ############################################################################ # Step 1: Setup thinca_to_coinc nodes @@ -197,15 +284,10 @@ for tag in user_tags: print "\tsetting up thinca_to_coinc nodes..." # set job options - t2c_job.set_experiment_start_time(options.gps_start_time) - t2c_job.set_experiment_end_time(options.gps_end_time) - if simulation: - t2c_job.set_simulation() # sieve zero_lag_cache for THINCA_SECOND files with this tag file_sieve = '*' + tag thinca_cache = zero_lag_cache.sieve( description = file_sieve, exact_match = True ) - # if not an injection run, check that there are an equal number of # slide files if not simulation and \ @@ -213,21 +295,20 @@ for tag in user_tags: len(thinca_cache): raise ValueError, "Number of %s slide files doesn't equal number of zero-lag files." % tag + # also sieve all_inspirals_cache + file_sieve = tag.split('_CAT_')[0] + inspiral_cache = all_inspirals_cache.sieve( description = file_sieve ) + # get distinct on_instruments in the thinca cache distinct_instrument_sets = set([ entry.observatory for entry in thinca_cache ]) # from the distinct_instrument_sets figure out what distinct ifos there are - distinct_ifos = set() + distinct_ifo_set = set() for on_instruments in distinct_instrument_sets: - distinct_ifos |= lsctables.instrument_set_from_ifos(on_instruments) - distinct_ifos = ''.join(sorted(distinct_ifos)) + distinct_ifo_set |= lsctables.instrument_set_from_ifos(on_instruments) + distinct_ifos = ''.join(sorted(distinct_ifo_set)) # get the veto file - if 'VETO' in tag: - # get the category veto (assuming tag has form: *CAT_N_VETO) - cat_num = tag.split('_')[-2] - else: - # is category 1 veto - cat_num = '1' + cat_num = str(get_veto_cat_from_tag( tag )) veto_file_path = cp.get('input', 'ihope-segments-directory') veto_file_name = ''.join([ distinct_ifos, '-VETOTIME_CAT_', cat_num, '-', experiment_start, '-', experiment_duration, @@ -235,19 +316,25 @@ for tag in user_tags: veto_file = '/'.join([ veto_file_path, veto_file_name ]) if not os.path.exists( veto_file ): raise ValueError, "Veto file %s could not be found." % veto_file + # store the veto file for additional later use + veto_cat = '_'.join(['CAT', cat_num, 'VETO']) + veto_files[veto_cat] = veto_file # get the veto segments name veto_segs_name = get_veto_segments_name( cat_num, cumulative = True ) t2c_output = [] + t2c_nodes = [] this_cache = lal.Cache() - cache_start_time = int(experiment_start) for on_instruments in distinct_instrument_sets: instrument_cache = thinca_cache.sieve( ifos = on_instruments, exact_match = True ) instrument_cache.sort() + cache_start_time = int(experiment_start) for entry_num, entry in enumerate(instrument_cache): if not this_cache: # first entry; store type for cache naming + # and add all the second_inspiral files to the cache cache_type = entry.description + this_cache.extend(inspiral_cache) # Add the zero-lag thinca entry to this_cache this_cache.append(entry) # if this isn't a simulation add the slide file @@ -265,14 +352,17 @@ for tag in user_tags: this_cache.tofile(this_cache_file) this_cache_file.close() # write node - this_t2c_node = inspiral.ThincaToCoincNode(t2c_job) - input_instruments = lsctables.ifos_from_instrument_set( - lsctables.instrument_set_from_ifos( on_instruments ) ) - this_t2c_node.set_instruments(input_instruments) + if simulation: + this_t2c_node = inspiral.ThincaToCoincNode(t2c_sim_job) + else: + this_t2c_node = inspiral.ThincaToCoincNode(t2c_job) + this_t2c_node.set_category('thinca_to_coinc') + this_t2c_node.set_instruments(lsctables.ifos_from_instrument_set( distinct_ifo_set )) this_t2c_node.set_input_cache(this_cache_name) this_t2c_node.set_veto_segments( veto_file ) this_t2c_node.set_veto_segments_name( veto_segs_name ) dag.add_node(this_t2c_node) + t2c_nodes.append(this_t2c_node) # add output files to t2c_output t2c_output += this_t2c_node.get_output_from_cache() # set end-time of last entry to be start time of next cache @@ -292,58 +382,34 @@ for tag in user_tags: fp.close() ############################################################################ - # Step 2a: Setup a LigolwSqliteNode for putting thinca_to_coincs + # Step 2: Setup a LigolwSqliteNode for putting thinca_to_coincs # into a sql db print "\tsetting up node to put thinca_to_coinc files into a SQLite database..." # set node options - t2c2sql_node = pipeline.LigolwSqliteNode( tosql_job ) + t2c2sql_node = pipeline.LigolwSqliteNode( sql_replace_job ) + t2c2sql_node.set_category('ligolw_sqlite') t2c2sql_node.set_input_cache( t2c_output_cache ) - t2c2sql_node.set_tmp_space( options.log_path ) + t2c2sql_node.set_tmp_space( tmp_space ) # database name has form: - # distinct_ifos-CBC_TRIGDB_RAW-USER_TAG-cache_start-cache_duration.sql - db_type = 'CBC_TRIGDB_RAW-' + tag + # distinct_ifos-USER_TAG_CBC_RAW_RESULTS-cache_start-cache_duration.sql + db_type = tag + '_RAW_CBC_RESULTS' raw_result_db = '.'.join([ '-'.join([ distinct_ifos, db_type, experiment_start, experiment_duration ]), 'sql' ]) # check to make sure the database doesn't already exist if os.path.exists( raw_result_db ): - raise ValueError, "Raw result database %s already exists. " % raw_result_db + \ - "Either rm or mv it, then re-run. (If it exists, you may also want to " + \ - "mv the CLUSTERED database so it doesn't get overwritten by cluster_coincs.)" \ + print "WARNING: Raw result database %s already exists; " % raw_result_db + \ + "if it isn't moved, it will be overwritten when DAG is submitted." - t2c2sql_node.set_database( raw_result_db ) # set parent nodes to be all the thinca_to_coinc nodes - [t2c2sql_node.add_parent( node ) for node in dag.get_nodes() \ - if isinstance(node, inspiral.ThincaToCoincNode)] + [t2c2sql_node.add_parent( node ) for node in t2c_nodes] dag.add_node( t2c2sql_node ) - ############################################################################ - # Step 2b: Setup a LigolwSqliteNode for putting the veto-segments file - # into the raw database - - # cache the veto file - veto_cache = lal.Cache().from_urls( [veto_file] ) - veto_cache_file = re.sub('.xml', '.cache', os.path.basename(veto_file)) - fp = open( veto_cache_file, 'w' ) - veto_cache.tofile( fp ) - fp.close() - - # write node to add the veto file - veto2sql_node = pipeline.LigolwSqliteNode( tosql_job ) - veto2sql_node.set_input_cache( veto_cache_file ) - veto2sql_node.set_tmp_space( options.log_path ) - veto2sql_node.set_database( raw_result_db ) - - # set parent node - veto2sql_node.add_parent( t2c2sql_node ) - - dag.add_node( veto2sql_node ) - ############################################################################ # Step 3: Setup a DBSimplifyNode to clean up the output of the t2c2sql_node @@ -351,31 +417,15 @@ for tag in user_tags: # set node options dbsimplify_node = inspiral.DBSimplifyNode( dbsimplify_job ) - dbsimplify_node.set_tmp_space( options.log_path ) + dbsimplify_node.set_category('dbsimplify') + dbsimplify_node.set_tmp_space( tmp_space ) dbsimplify_node.set_database( raw_result_db ) # set parent node - dbsimplify_node.add_parent( veto2sql_node ) + dbsimplify_node.add_parent( t2c2sql_node ) dag.add_node( dbsimplify_node ) - - - ############################################################################ - # Step 3c: If simulation, add injection file. - - if simulation: - print "\tsetting up dbaddinj node to add the injection file..." - - # set node options - dbaddinj_node = inspiral.DBAddInjNode( dbaddinj_job ) - dbaddinj_node.set_tmp_space( options.log_path ) - dbaddinj_node.set_database( raw_result_db ) - dbaddinj_node.set_injection_file( inj_file ) - - dbaddinj_node.add_parent( dbsimplify_node ) - - dag.add_node( dbaddinj_node ) - + ############################################################################ # Step 4: Setup a ClusterCoincsNode to cluster the output of dbsimplify_node @@ -383,11 +433,12 @@ for tag in user_tags: # set node options cluster_node = inspiral.ClusterCoincsNode( cluster_job ) - cluster_node.set_tmp_space( options.log_path ) + cluster_node.set_category('cluster_coincs') + cluster_node.set_tmp_space( tmp_space ) cluster_node.set_input( raw_result_db ) # output database name has form: # distinct_ifos-CBC_TRIGDB_CLUSTERED-USER_TAG-gps_start_time-durations.sql - db_type = 'CBC_TRIGDB_CLUSTERED-' + tag + db_type = tag + '_CLUSTERED_CBC_RESULTS' result_db = '.'.join([ '-'.join([ distinct_ifos, db_type, experiment_start, experiment_duration ]), 'sql' ]) @@ -395,10 +446,171 @@ for tag in user_tags: # set parent node cluster_node.add_parent( dbsimplify_node ) - if simulation: - cluster_node.add_parent( dbaddinj_node ) dag.add_node( cluster_node ) + + # add to list of parents for veto2sql nodes + cluster_nodes[tag] = cluster_node + + ############################################################################ + # Step 5: Do additional jobs for injection tags + + if simulation: + # add dbaddinj node + print "\tsetting up dbaddinj node to add the injection file..." + + # set node options + dbaddinj_node = inspiral.DBAddInjNode( dbaddinj_job ) + dbaddinj_node.set_category('dbaddinj') + dbaddinj_node.set_tmp_space( tmp_space ) + dbaddinj_node.set_database( result_db ) + dbaddinj_node.set_injection_file( inj_file ) + + dbaddinj_node.add_parent( cluster_node ) + + dag.add_node( dbaddinj_node ) + + # add sqlite extract node + print "\tsetting up ligolw_sqlite node to extract the injection database to an xml..." + + # set node options + simxml_node = pipeline.LigolwSqliteNode( sql_extract_job ) + simxml_node.set_category('ligolw_sqlite') + simxml_node.set_tmp_space( tmp_space ) + simxml_node.set_database( result_db ) + sim_xml = result_db.replace('.sql', '.xml') + simxml_node.set_xml_output( sim_xml ) + + simxml_node.add_parent( dbaddinj_node ) + dag.add_node( simxml_node ) + + # add to list of inspinjfind parents + if veto_cat not in inspinjfind_parents: + inspinjfind_parents[veto_cat] = [] + inspinjfind_parents[veto_cat].append( simxml_node ) + + else: + # just cache the result_db + non_sim_dbs.append( result_db ) + + +############################################################################## +# done cycling over tags: Create inspinjfind job and node + +# cache the sim xmls by veto category +print "Creating inspinjfind nodes..." + +inspinjfind_nodes = {} +sim_caches = {} +for veto_cat, node_list in inspinjfind_parents.items(): + + # create a inspinjfind node for each veto_category + inspinjfind_node = inspiral.InspInjFindNode( inspinjfind_job ) + inspinjfind_node.set_category('inspinjfind') + + # add input files and parents + for simxml_node in node_list: + inspinjfind_node.add_file_arg( simxml_node.get_output() ) + inspinjfind_node.add_parent( simxml_node ) + dag.add_node( inspinjfind_node ) + + inspinjfind_nodes[veto_cat] = inspinjfind_node + + # Cache the files + sim_cache = lal.Cache().from_urls( inspinjfind_node.get_input_files() ) + if veto_cat == 'CAT_1_VETO': + cache_type = 'ALLINJ_CLUSTERED_CBC_RESULTS' + else: + cache_type = '_'.join(['ALLINJ', veto_cat, 'CLUSTERED_CBC_RESULTS' ]) + instruments = set() + for entry in sim_cache: + instruments |= lsctables.instrument_set_from_ifos(entry.observatory) + instruments = ''.join(sorted(instruments)) + sim_cache_name = '.'.join([ + '-'.join([ instruments, cache_type, experiment_start, experiment_duration ]), + 'cache' ]) + sim_cache.tofile( open(sim_cache_name, 'w') ) + sim_caches[veto_cat] = sim_cache_name + + +############################################################################## +# now cycle over non-injection databases, +# carrying out the rest of the pipeline + +# cache the non_sim_dbs +result_dbs_cache = lal.Cache().from_urls( non_sim_dbs ) + +for result_db in result_dbs_cache: + + # get tag and veto_cat + print "Creating jobs for %s database..." % result_db.description + tag = result_db.description.replace('_CLUSTERED_CBC_RESULTS', '') + cat_num = get_veto_cat_from_tag( tag ) + veto_cat = '_'.join([ 'CAT', str(cat_num), 'VETO' ]) + + # get all possible instruments_on in this database + instruments = lsctables.instrument_set_from_ifos(result_db.observatory) + distinct_instrument_sets = [instruments] + distinct_instrument_sets.extend( set(sub_combo) + for nn in range(2, len(instruments)) + for sub_combo in iterutils.choices( list(instruments), nn ) ) + + # add the injection xmls to the FULL_DATA databases + if 'FULL_DATA' in tag: + + # create a sqlite node to add the injetion results + sim2fulldb_node = pipeline.LigolwSqliteNode( sql_fromcache_job ) + sim2fulldb_node.set_category('ligolw_sqlite') + sim2fulldb_node.set_input_cache( sim_caches[veto_cat] ) + sim2fulldb_node.set_database( result_db.path() ) + sim2fulldb_node.set_tmp_space( tmp_space ) + + sim2fulldb_node.add_parent( inspinjfind_nodes[veto_cat] ) + sim2fulldb_node.add_parent( cluster_nodes[tag] ) + dag.add_node( sim2fulldb_node ) + + # create a dbsimplify node to clean the database + dbsimplify2_node = inspiral.DBSimplifyNode( dbsimplify_job ) + dbsimplify2_node.set_category('dbsimplify') + dbsimplify2_node.set_tmp_space( tmp_space ) + dbsimplify2_node.set_database( result_db.path() ) + + dbsimplify2_node.add_parent( sim2fulldb_node ) + dag.add_node( dbsimplify2_node ) + + ############################################################################ + # Setup a LigolwSqliteNode for putting the veto-segments file into the + # database + + # write node to add the veto file + veto2sql_node = pipeline.LigolwSqliteNode( sql_frominput_job ) + veto2sql_node.set_category('ligolw_sqlite') + veto2sql_node.add_file_arg( veto_files[veto_cat] ) + veto2sql_node.set_tmp_space( tmp_space ) + veto2sql_node.set_database( result_db.path() ) + + # set parent node + veto2sql_node.add_parent( cluster_nodes[tag] ) + if 'FULL_DATA' in tag: + veto2sql_node.add_parent( dbsimplify2_node ) + + dag.add_node( veto2sql_node ) + + ############################################################################ + # Step 3b: Compute durations in the database + + print "\tsetting up compute_durations node..." + + # set node options + comp_durs_node = inspiral.ComputeDurationsNode( comp_durs_job) + comp_durs_node.set_category('compute_durations') + comp_durs_node.set_tmp_space( tmp_space ) + comp_durs_node.set_database( result_db.path() ) + + # set parent node + comp_durs_node.add_parent( veto2sql_node ) + + dag.add_node(comp_durs_node) ############################################################################ # Step 5a: Setup a CfarNode to compute the uncombined false alarm rates @@ -408,12 +620,13 @@ for tag in user_tags: # set node options: output database is same as input ucfar_node = inspiral.CFarNode( ucfar_job ) - ucfar_node.set_tmp_space( options.log_path ) - ucfar_node.set_input( result_db ) - ucfar_node.set_output( result_db ) + ucfar_node.set_category('cfar') + ucfar_node.set_tmp_space( tmp_space ) + ucfar_node.set_input( result_db.path() ) + ucfar_node.set_output( result_db.path() ) # set parent node - ucfar_node.add_parent( cluster_node ) + ucfar_node.add_parent( comp_durs_node ) dag.add_node( ucfar_node ) @@ -424,53 +637,134 @@ for tag in user_tags: # set node options: output database is same as input ccfar_node = inspiral.CFarNode( ccfar_job ) - ccfar_node.set_tmp_space( options.log_path ) - ccfar_node.set_input( result_db ) - ccfar_node.set_output( result_db ) + ccfar_node.set_category('cfar') + ccfar_node.set_tmp_space( tmp_space ) + ccfar_node.set_input( result_db.path() ) + ccfar_node.set_output( result_db.path() ) # set parent node ccfar_node.add_parent( ucfar_node ) dag.add_node( ccfar_node ) + ############################################################################ + # Summary: Setup PrintLC and MiniFollowup Nodes to generate a summary of + # loudest events + + print "\tsetting up printlc and minifollowup nodes..." + + # set datatypes to generate files for + if 'PLAYGROUND' in tag: + datatypes = ['playground', 'slide'] + else: + datatypes = ['all_data', 'playground', 'exclude_play', 'simulation', 'slide'] + + for datatype in datatypes: + print "\t\tfor %s..." % datatype + # set file naming type + if datatype == 'simulation' and veto_cat != 'CAT_1_VETO': + type_prefix = '_'.join(['ALLINJ', veto_cat]) + elif datatype == 'simulation' and veto_cat == 'CAT_1_VETO': + type_prefix = 'ALLINJ' + else: + type_prefix = tag + type = '_'.join([ type_prefix, 'LOUDEST', datatype.upper(), 'EVENTS_BY', cp.get('printlc', 'ranking-stat').upper()]) + # cycle over all ifos times, creating different tables for each + for on_instruments in distinct_instrument_sets: + on_instruments = lsctables.ifos_from_instrument_set(on_instruments) + # set output and extracted xml file names + summary_filename = '.'.join([ + '-'.join([ ''.join(on_instruments.split(',')), type + '_SUMMARY', experiment_start, experiment_duration ]), + 'xml' ]) + xml_filename = '.'.join([ + '-'.join([ ''.join(on_instruments.split(',')), type, experiment_start, experiment_duration ]), + 'xml' ]) + # set node options + printlc_node = inspiral.PrintLCNode( printlc_job ) + printlc_node.set_category('printlc') + printlc_node.set_tmp_space( tmp_space ) + printlc_node.set_input( result_db.path() ) + printlc_node.set_output( summary_filename ) + printlc_node.set_extract_to_xml( xml_filename ) + printlc_node.set_include_only_coincs( '[ALLin' + on_instruments + ']' ) + printlc_node.set_datatype( datatype ) + + # set parent node + printlc_node.add_parent( ccfar_node ) + + dag.add_node( printlc_node ) + + # create the minifollowups nodes + prefix = '-'.join([ ''.join(on_instruments.split(',')), tag ]) + suffix = re.sub(prefix + '_', '', summary_filename).rstrip('.xml') + + minifup_node = inspiral.MiniFollowupsNode( minifup_job ) + minifup_node.set_category('minifollowups') + minifup_node.set_cache_file( options.ihope_cache ) + minifup_node.set_cache_string( tag.split('_CAT_')[0] ) + minifup_node.set_prefix( prefix ) + minifup_node.set_suffix( suffix ) + minifup_node.set_input_xml( xml_filename ) + minifup_node.set_input_xml_summary( summary_filename ) + minifup_node.set_output_html_table( re.sub('.xml', '.html', summary_filename ) ) + + minifup_node.add_parent( printlc_node ) + dag.add_node( minifup_node ) + + ############################################################################ # Plotting: Generate all result plots print "\tsetting up plotting jobs..." - - if not simulation: - print "\t\tcreating plotslides node..." - # set plotslides_job options - if options.plot_playground_only or 'PLAYGROUND' in tag: - plotslides_job.set_plot_playground_only() - # Write plotslides node + + # Write plotslides node + print "\t\tcreating plotslides node..." + if not options.generate_all_data_plots or 'PLAYGROUND' in tag: + plotslides_node = inspiral.PlotSlidesNode( plotslides_play_job ) + else: plotslides_node = inspiral.PlotSlidesNode( plotslides_job ) - plotslides_node.set_tmp_space( options.log_path ) - plotslides_node.set_input( result_db ) - plotslides_node.set_user_tag( tag ) - + + plotslides_node.set_category('plotslides') + plotslides_node.set_tmp_space( tmp_space ) + plotslides_node.set_input( result_db.path() ) + plotslides_node.set_user_tag( tag ) + + plotslides_node.add_parent( ccfar_node ) + dag.add_node( plotslides_node ) + + # create plotcumhist node + print "\t\tcreating plotcumhist node..." + if not options.generate_all_data_plots or 'PLAYGROUND' in tag: + plotcumhist_node = inspiral.PlotCumhistNode( plotcumhist_play_job ) + else: + plotcumhist_node = inspiral.PlotCumhistNode( plotcumhist_job ) + + plotcumhist_node.set_tmp_space( tmp_space ) + plotcumhist_node.set_input( result_db.path() ) + plotcumhist_node.set_user_tag( tag ) + + plotcumhist_node.add_parent( ccfar_node ) + + dag.add_node( plotcumhist_node ) + + # Write plotifar nodes for different datatypes + print "\t\tcreating plotifar node for datatypes:" + for datatype in ['all_data', 'playground', 'exclude_play']: + # only create nodes for non-playground if options.plot-playground-only not set + if (not options.generate_all_data_plots or 'PLAYGROUND' in tag) and datatype != 'playground': + continue + print "\t\t\t%s..." % datatype + plotifar_node = inspiral.PlotIfarNode( plotifar_job ) + plotifar_node.set_category('plotifar') + plotifar_node.set_tmp_space( tmp_space ) + plotifar_node.set_input( result_db.path() ) + plotifar_node.set_datatype( datatype ) + plotifar_node.set_user_tag( tag ) + # set parent node - plotslides_node.add_parent( ccfar_node ) - - dag.add_node( plotslides_node ) - - # Write plotifar nodes for different datatypes - print "\t\tcreating plotifar node for datatypes:" - for datatype in ['all_data', 'playground', 'exclude_play']: - # only create nodes for non-playground if options.plot-playground-only not set - if (options.plot_playground_only or 'PLAYGROUND' in tag) and datatype != 'playground': - continue - print "\t\t\t%s..." % datatype - plotifar_node = inspiral.PlotIfarNode( plotifar_job ) - plotifar_node.set_tmp_space( options.log_path ) - plotifar_node.set_input( result_db ) - plotifar_node.set_datatype( datatype ) - plotifar_node.set_user_tag( tag ) - - # set parent node - plotifar_node.add_parent( ccfar_node ) - - dag.add_node( plotifar_node ) + plotifar_node.add_parent( ccfar_node ) + + dag.add_node( plotifar_node ) ############################################################################## @@ -479,6 +773,9 @@ for tag in user_tags: print "Writing DAG and sub files..." +# set max-jobs: currently, only minifollowups is set +dag.add_maxjobs_category('minifollowups', 15) + dag.write_sub_files() dag.write_dag() diff --git a/lalapps/src/inspiral/cbc_pipedown.ini b/lalapps/src/inspiral/cbc_pipedown.ini index 62ea1f02b70f8807fc04f9eabd2ca27b99f23d4e..7f77b5b94de0f100d05e2a08794015520f9c2346 100644 --- a/lalapps/src/inspiral/cbc_pipedown.ini +++ b/lalapps/src/inspiral/cbc_pipedown.ini @@ -3,8 +3,8 @@ ; $Id$ ; ; this is the configuration file for the inspiral DAG generation program -; lalapps_cbc_post_process that creates a condor DAG to run the cbc -; post-processing dag. +; lalapps_cbc_pipedown that creates a condor DAG to run the cbc +; pipedown dag. [condor] ; setup of condor universe and location of executables @@ -12,12 +12,22 @@ universe = vanilla thinca_to_coinc = ../executables/ligolw_thinca_to_coinc ligolw_sqlite = ../executables/ligolw_sqlite dbsimplify = ../executables/ligolw_cbc_dbsimplify +compute_durations = ../executables/ligolw_cbc_compute_durations dbaddinj = ../executables/ligolw_cbc_dbaddinj +inspinjfind = ../executables/ligolw_inspinjfind cluster_coincs = ../executables/ligolw_cbc_cluster_coincs cfar = ../executables/ligolw_cbc_cfar +printlc = ../executables/ligolw_cbc_printlc +minifollowups = ../executables/minifollowups plotslides = ../executables/ligolw_cbc_plotslides +plotcumhist = ../executables/ligolw_cbc_plotcumhist plotifar = ../executables/ligolw_cbc_plotifar +[pipeline] +; set node-tmp-dir to be a local directory that exists +; on all the slave nodes +node-tmp-dir = /usr1/cdcapano + [input] ; options common to all commands ihope-segments-directory = ../segments @@ -25,15 +35,12 @@ ihope-segments-directory = ../segments [plot_input] ; options common to plotting commands enable-output = -; FIXME: remove output-path option once plotting codes generate XSL output -output-path = /home/cdcapano/public_html/sqlite_development/ [thinca_to_coinc] ; set options for thinca_to_coinc jobs search = low_mass ;lars-id = ;effective-snr-factor = 250. -compute-durations = [ligolw_sqlite] ; set options for ligolw_sqlite jobs @@ -44,9 +51,18 @@ compute-durations = ; set options for dbsimplify jobs ;vacuum = +[compute_durations] +; set options for compute_durations jobs + [dbaddinj] ; set options for dbaddinj jobs +[inspinjfind] +; set options for inspinjfind jobs +match-algorithm = inspiral +;force = +;comment = None + [cluster_coincs] ; set static options for cluster_coinc jobs ; following are required options @@ -85,9 +101,28 @@ rank-by = MIN ; uncomment group-by-ifos ;group-by-ifos = +[printlc] +; set static options for printlc jobs +ranking-stat = combined_far +rank-by = MIN +convert-durations = days +limit = 10 + +[minifollowups] +; set static options for minifollowup jobs + [plotslides] ; set static options for plotslide jobs +[plotcumhist] +; set static options for plotcumhist jobs +num-bins = 20 +ranking-stat = snr +rank-by = MAX +square-stats = +;param-name = mchirp +;param-ranges = [0.87,3.48);[3.48,7.4);[7.4,15.24] + [plotifar] ; set static options for plotifar jobs param-name = mchirp @@ -96,7 +131,6 @@ plot-uncombined = ;group-by-ifos = plot-combined = plot-slides = -ifar-dist = show-min-bkg = show-max-bkg = show-two-sigma-error = diff --git a/lalapps/src/inspiral/coherent_inspiral.c b/lalapps/src/inspiral/coherent_inspiral.c index 04c52582b76f01b6e37ada27eb030bfd097de444..394e43a09ea9b704dd306ab1650263467d1b6d18 100644 --- a/lalapps/src/inspiral/coherent_inspiral.c +++ b/lalapps/src/inspiral/coherent_inspiral.c @@ -63,7 +63,6 @@ #include <lal/AVFactories.h> #include <lal/LALConstants.h> #include <lal/FrameStream.h> -#include <lal/DataBuffer.h> #include <lal/LIGOMetadataTables.h> #include <lal/LIGOMetadataUtils.h> #include <lal/LIGOLwXML.h> @@ -75,7 +74,6 @@ #include <lal/FindChirpBCV.h> #include <lal/FindChirpBCVSpin.h> #include <lal/FindChirpChisq.h> -#include <lal/StochasticCrossCorrelation.h> #include <lal/DetectorSite.h> #include <lal/Random.h> #include <lal/LALInspiral.h> @@ -106,17 +104,17 @@ else \ LALCalloc( 1, sizeof(SummValueTable) ); \ } \ snprintf( this_summ_value->program, LIGOMETA_PROGRAM_MAX, "%s", \ - PROGRAM_NAME ); \ + PROGRAM_NAME ); \ this_summ_value->version = 0; \ this_summ_value->start_time = searchsumm.searchSummaryTable->out_start_time; \ this_summ_value->end_time = searchsumm.searchSummaryTable->out_end_time; \ this_summ_value->value = (REAL4) val; \ this_summ_value->intvalue = (INT4) intval; \ snprintf( this_summ_value->name, LIGOMETA_SUMMVALUE_NAME_MAX, "%s", \ - sv_name ); \ + sv_name ); \ snprintf( this_summ_value->ifo, LIGOMETA_IFO_MAX, "%s", ifo ); \ snprintf( this_summ_value->comment, LIGOMETA_SUMMVALUE_COMM_MAX, \ - "%s", sv_comment ); \ + "%s", sv_comment ); \ #define rint(x) (floor((x)+0.5)) @@ -178,7 +176,6 @@ int gpsEndTimeTemp = 0; /* input data GPS start time ns */ INT8 outTimeNS = 0; /* search summ out time */ LALStatus status; -LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; CHAR *userTag = NULL; /* string the user can tag with */ CHAR *ifos = NULL; /* string to tag parent IFOs */ @@ -290,8 +287,7 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION, "$Revi" "sion$")) { @@ -327,7 +323,7 @@ int main( int argc, char *argv[] ) this_search_summvar = searchsummvars.searchSummvarsTable = (SearchSummvarsTable *) LALCalloc( 1, sizeof(SearchSummvarsTable) ); snprintf( this_search_summvar->name, LIGOMETA_NAME_MAX * sizeof(CHAR), - "data sample rate" ); + "data sample rate" ); this_search_summvar->value = (REAL8) sampleRate; @@ -336,8 +332,8 @@ int main( int argc, char *argv[] ) /* read in the cohbank trigger ligo lw xml file */ numTriggers = XLALReadInspiralTriggerFile( &cohbankEventList, - ¤tTrigger, &searchSummList, - &inputFiles, cohbankFileName ); + ¤tTrigger, &searchSummList, + &inputFiles, cohbankFileName ); fprintf(stdout,"Reading templates from %s\n",cohbankFileName); @@ -349,18 +345,18 @@ int main( int argc, char *argv[] ) else if ( numTriggers == 0 ) { if( vrbflg ) - { - fprintf( stdout, - "%s contains no triggers - the coherent bank will be empty\n", - cohbankFileName ); - } + { + fprintf( stdout, + "%s contains no triggers - the coherent bank will be empty\n", + cohbankFileName ); + } } else { if( vrbflg ) { - fprintf( stdout, - "Read in %d triggers from the file %s\n", numTriggers, - cohbankFileName ); + fprintf( stdout, + "Read in %d triggers from the file %s\n", numTriggers, + cohbankFileName ); } /* reconstruct the coincs */ @@ -371,21 +367,21 @@ int main( int argc, char *argv[] ) if( numCoincs < 0 ) { - fprintf(stderr, "Unable to reconstruct coincs from single ifo triggers"); - exit( 1 ); + fprintf(stderr, "Unable to reconstruct coincs from single ifo triggers"); + exit( 1 ); } else { - fprintf( stdout, - "Recreated %d coincs from the %d triggers\n", numCoincs, - numTriggers ); - if ( numCoincs % numCohTrigs == 0) { - - numCohFiles = floor( numCoincs / numCohTrigs ); - } - else { - numCohFiles = floor( numCoincs / numCohTrigs ) + 1; - } + fprintf( stdout, + "Recreated %d coincs from the %d triggers\n", numCoincs, + numTriggers ); + if ( numCoincs % numCohTrigs == 0) { + + numCohFiles = floor( numCoincs / numCohTrigs ); + } + else { + numCohFiles = floor( numCoincs / numCohTrigs ) + 1; + } } thisCoinc=coincHead; @@ -404,546 +400,546 @@ int main( int argc, char *argv[] ) struct FrameH *outFrameNullStatH1H2 = NULL; if( (cohFileID == (numCohFiles-1) && !((numCoincs % numCohTrigs) == 0)) ) - { - cohtriglimit = (numCoincs % numCohTrigs); - } + { + cohtriglimit = (numCoincs % numCohTrigs); + } else - { - cohtriglimit = numCohTrigs; - } + { + cohtriglimit = numCohTrigs; + } for ( cohtrigs = 0 ; cohtrigs < cohtriglimit ; cohtrigs++) { - - numDetectors = thisCoinc->numIfos; - - /* l is another detector index, which can have a max value of 4 */ - l=0; - - /* Note the participating ifos and the eventID - for this coincident trigger */ - for( k=0 ; k<LAL_NUM_IFO ; k++) - { - if( thisCoinc->snglInspiral[k] ) - { - kmax = k; /* final trigger's k value */ - caseID[k] = 1; - memcpy( caseIDChars[k], &thisCoinc->snglInspiral[k]->ifo, sizeof(caseIDChars[k] - 1) ); - snprintf( channelNameArray[k], LALNameLength*sizeof(CHAR), "%s", &thisCoinc->snglInspiral[k]->channel ); - eventID = thisCoinc->snglInspiral[k]->event_id->id; - if( vrbflg ) fprintf(stdout,"eventID = %Ld\n",eventID ); - - /* Parse eventID to get the slide number */ - triggerNumber = eventID % 100000; - slideNumber = ((eventID % 100000000) - triggerNumber)/100000; - slideSign = (eventID % 1000000000) - slideNumber*100000 - triggerNumber; - - /* Store CData frame name now for reading its frame-file - later, within thisCoinc-ident loop - */ - snprintf( nameArrayCData[k], LALNameLength*sizeof(CHAR), "%s:CBC-CData_%Ld", caseIDChars[k], eventID ); - } - }/* Closes loop for k; finished noting the participating ifos - and the eventID for this coincident trigger*/ - - /* Initialize tempTime to account for time-slides (wrt H1, hence j<5)*/ - for( j=0; j<(LAL_NUM_IFO - 1) ; j++) - { - /* slideSign=0 is the same as a positive time slide */ - if(slideSign != 0) - { - tempTime[j] = slideStep[j]*slideNumber; - } - else - { - tempTime[j] -= slideStep[j]*slideNumber; - } - } - - l=0; - if( G1file ) l++; - if( H1file ) l++; - if( H2file ) l++; - if( L1file ) l++; - if( T1file ) l++; - if( V1file ) l++; - - if( (INT4)numDetectors != l ) - { - fprintf( stderr, "You have events for %d detectors, but specified frame files for %d detectors\n",numDetectors,l); - if( (INT4)numDetectors > l ) - { - fprintf( stderr, "You must specify more frame files. Exiting...\n"); - exit(1); - } - else - { - if( vrbflg ) fprintf( stdout, "One or more of the frame files specified will not be used for this event since the number of detectors is less than the number of frame files you specified.\n"); - } - } - - l = 0; - - if( vrbflg ) fprintf(stdout,"numDetectors = %d\n", numDetectors); - if( vrbflg ) fprintf(stdout,"caseID = %d %d %d %d %d %d (G1,H1,H2,L1,T1,V1)\n", caseID[0], caseID[1], caseID[2], caseID[3], caseID[4], caseID[5]); - - - /* Initialize the necessary structures for thisCoinc-ident trigger*/ - - if( !(cohInspInitParams = (CoherentInspiralInitParams *) calloc(1,sizeof(CoherentInspiralInitParams)) )) - { - fprintf( stdout, "could not allocate memory for coherentInspiral init params\n" ); - exit(1); - } - - /* Initialize the coherent param structure for thisCoinc trigger */ - cohInspInitParams->numDetectors = numDetectors; - cohInspInitParams->numSegments = numSegments; - cohInspInitParams->numPoints = numPoints; - cohInspInitParams->numBeamPoints = numBeamPoints; - cohInspInitParams->cohSNROut = cohSNROut; - /* In addition to the network cohSNR, output the cohH1H2SNR if - the user wants it and the network has the ifos H1 and H2; since - in a 2D network this will make one of cohSNR and cohH1H2SNR - redundant, do not output the latter for < 3D networks */ - if( cohH1H2SNROut && caseID[1] && caseID[2] && (numDetectors > 2) ) { - cohInspInitParams->cohH1H2SNROut = 1; - } - else if( cohSNROut && caseID[1] && caseID[2] && (numDetectors == 2)){ - cohInspInitParams->cohH1H2SNROut = 1; - } - else { - if ( vrbflg && cohH1H2SNROut ) fprintf( stdout, "Not outputting cohH1H2SNR because either numDetectors < 3 or at least one of H1 and H2 is missing ...\n " ); - cohInspInitParams->cohH1H2SNROut = 0; - } - - /* Determine if the H1-H2 null-statistic should be computed */ - if( (nullStatH1H2Out && ( (caseID[1] && caseID[2]) - || (numDetectors > 2) ) ) ) { - cohInspInitParams->nullStatH1H2Out = 1; - } - else { - if ( vrbflg && nullStatH1H2Out ) fprintf( stdout, "Not outputting nullStatH1H2Out because either this is a two-detector network or at least one of H1 and H2 is missing ...\n " ); - cohInspInitParams->nullStatH1H2Out = 0; - } - - if( (nullStatOut && ( ( numDetectors >3 ) || - ( (numDetectors == 3) && !(caseID[1] && caseID[2]) ) ) ) ) { - cohInspInitParams->nullStatOut = 1; - } - else { - if ( vrbflg && nullStatOut ) fprintf( stdout, "Not outputting nullStatOut because either numDetectors < 3 or at least one of H1 and H2 is missing ...\n " ); - cohInspInitParams->nullStatOut = 0; - } - - /* create the data structures needed for coherentInspiral */ - - if ( vrbflg ) fprintf( stdout, "initializing coherentInspiral...\n " ); - - /* initialize coherentInspiral filter functions */ - LAL_CALL( LALCoherentInspiralFilterInputInit (&status, &cohInspFilterInput, - cohInspInitParams), &status ); - - cohInspCVec = cohInspFilterInput->multiCData; - - m1 = thisCoinc->snglInspiral[kmax]->mass1; - m2 = thisCoinc->snglInspiral[kmax]->mass2; - muMass = m1 * m2 / (m1 + m2); - - cohInspFilterInput->tmplt = (InspiralTemplate *) - LALCalloc(1,sizeof(InspiralTemplate) ); - cohInspFilterInput->tmplt->mass1 = m1; - cohInspFilterInput->tmplt->mass2 = m2; - cohInspFilterInput->tmplt->totalMass = m1 + m2; - cohInspFilterInput->tmplt->mu = m1 * m2 / (m1 + m2); - cohInspFilterInput->tmplt->eta = (m1 * m2) / ((m1 + m2) * (m1 + m2 )); - - if (vrbflg) fprintf( stdout, "m1:%f m2:%f totalmass:%f mu:%f eta:%f\n", cohInspFilterInput->tmplt->mass1, cohInspFilterInput->tmplt->mass2,cohInspFilterInput->tmplt->totalMass,cohInspFilterInput->tmplt->mu,cohInspFilterInput->tmplt->eta); - - LAL_CALL( LALCoherentInspiralFilterParamsInit (&status, &cohInspFilterParams, - cohInspInitParams),&status ); - - /* Initialize the filter param structure for thisCoinc trigger */ - - cohInspFilterParams->deltaT = 1.0/((REAL8) sampleRate); - cohInspFilterParams->cohSNRThresh = cohSNRThresh; - cohInspFilterParams->cohSNROut = cohInspInitParams->cohSNROut; - cohInspFilterParams->cohH1H2SNROut = cohInspInitParams->cohH1H2SNROut; - cohInspFilterParams->nullStatH1H2Out = cohInspInitParams->nullStatH1H2Out; - cohInspFilterParams->nullStatOut = cohInspInitParams->nullStatOut; - cohInspFilterParams->numTmplts = 1; - cohInspFilterParams->fLow = fLow; - cohInspFilterParams->maximizeOverChirp = maximizeOverChirp; - cohInspFilterParams->numDetectors = cohInspInitParams->numDetectors; - cohInspFilterParams->raStep = raStep; - cohInspFilterParams->decStep = decStep; - /* initParams not needed anymore */ - free( cohInspInitParams ); - cohInspInitParams = NULL; - - if (vrbflg) fprintf( stdout, "deltaT:%f cohSNRThresh:%f numTmplts:%d\n", cohInspFilterParams->deltaT,cohInspFilterParams->cohSNRThresh,cohInspFilterParams->numTmplts); - - for( j=0; j<LAL_NUM_IFO; j++ ) - { - cohInspFilterParams->detIDVec->data[j] = caseID[j]; - cohInspFilterParams->sigmasqVec->data[j] = 1.0; - } - - /* Read in the snippets associated with thisCoinc trigger */ - l = 0; /* A counter to step through the cohInspCVec-tors */ - for( j=0; j<LAL_NUM_IFO; j++ ) - { - if( caseID[j] ) { - FrFile *frfileIn[j]; - FrameH *ifoFrame = NULL; - FrProcData *proc = NULL; - LIGOTimeGPS tmpEpoch; - - if( vrbflg ) fprintf(stdout, "getting the COMPLEX8TimeSeries %s \n", nameArrayCData[j] ); - - if ( !(frfileIn[j]= XLALFrOpenURL( ifoframefile[j] )) ) { - XLALPrintError( "XLAL Error: could not open frame file %s - exiting...\n", ifoframefile[j] ); - exit(1); - } - while( ! proc && (ifoFrame = FrameRead( frfileIn[j] )) ) { - proc = ifoFrame->procData; + + numDetectors = thisCoinc->numIfos; + + /* l is another detector index, which can have a max value of 4 */ + l=0; + + /* Note the participating ifos and the eventID + for this coincident trigger */ + for( k=0 ; k<LAL_NUM_IFO ; k++) + { + if( thisCoinc->snglInspiral[k] ) + { + kmax = k; /* final trigger's k value */ + caseID[k] = 1; + memcpy( caseIDChars[k], &thisCoinc->snglInspiral[k]->ifo, sizeof(caseIDChars[k] - 1) ); + snprintf( channelNameArray[k], LALNameLength*sizeof(CHAR), "%s", &thisCoinc->snglInspiral[k]->channel ); + eventID = thisCoinc->snglInspiral[k]->event_id->id; + if( vrbflg ) fprintf(stdout,"eventID = %Ld\n",eventID ); + + /* Parse eventID to get the slide number */ + triggerNumber = eventID % 100000; + slideNumber = ((eventID % 100000000) - triggerNumber)/100000; + slideSign = (eventID % 1000000000) - slideNumber*100000 - triggerNumber; + + /* Store CData frame name now for reading its frame-file + later, within thisCoinc-ident loop + */ + snprintf( nameArrayCData[k], LALNameLength*sizeof(CHAR), "%s:CBC-CData_%Ld", caseIDChars[k], eventID ); + } + }/* Closes loop for k; finished noting the participating ifos + and the eventID for this coincident trigger*/ + + /* Initialize tempTime to account for time-slides (wrt H1, hence j<5)*/ + for( j=0; j<(LAL_NUM_IFO - 1) ; j++) + { + /* slideSign=0 is the same as a positive time slide */ + if(slideSign != 0) + { + tempTime[j] = slideStep[j]*slideNumber; + } + else + { + tempTime[j] -= slideStep[j]*slideNumber; + } + } + + l=0; + if( G1file ) l++; + if( H1file ) l++; + if( H2file ) l++; + if( L1file ) l++; + if( T1file ) l++; + if( V1file ) l++; + + if( (INT4)numDetectors != l ) + { + fprintf( stderr, "You have events for %d detectors, but specified frame files for %d detectors\n",numDetectors,l); + if( (INT4)numDetectors > l ) + { + fprintf( stderr, "You must specify more frame files. Exiting...\n"); + exit(1); + } + else + { + if( vrbflg ) fprintf( stdout, "One or more of the frame files specified will not be used for this event since the number of detectors is less than the number of frame files you specified.\n"); + } + } + + l = 0; + + if( vrbflg ) fprintf(stdout,"numDetectors = %d\n", numDetectors); + if( vrbflg ) fprintf(stdout,"caseID = %d %d %d %d %d %d (G1,H1,H2,L1,T1,V1)\n", caseID[0], caseID[1], caseID[2], caseID[3], caseID[4], caseID[5]); + + + /* Initialize the necessary structures for thisCoinc-ident trigger*/ + + if( !(cohInspInitParams = (CoherentInspiralInitParams *) calloc(1,sizeof(CoherentInspiralInitParams)) )) + { + fprintf( stdout, "could not allocate memory for coherentInspiral init params\n" ); + exit(1); + } + + /* Initialize the coherent param structure for thisCoinc trigger */ + cohInspInitParams->numDetectors = numDetectors; + cohInspInitParams->numSegments = numSegments; + cohInspInitParams->numPoints = numPoints; + cohInspInitParams->numBeamPoints = numBeamPoints; + cohInspInitParams->cohSNROut = cohSNROut; + /* In addition to the network cohSNR, output the cohH1H2SNR if + the user wants it and the network has the ifos H1 and H2; since + in a 2D network this will make one of cohSNR and cohH1H2SNR + redundant, do not output the latter for < 3D networks */ + if( cohH1H2SNROut && caseID[1] && caseID[2] && (numDetectors > 2) ) { + cohInspInitParams->cohH1H2SNROut = 1; + } + else if( cohSNROut && caseID[1] && caseID[2] && (numDetectors == 2)){ + cohInspInitParams->cohH1H2SNROut = 1; + } + else { + if ( vrbflg && cohH1H2SNROut ) fprintf( stdout, "Not outputting cohH1H2SNR because either numDetectors < 3 or at least one of H1 and H2 is missing ...\n " ); + cohInspInitParams->cohH1H2SNROut = 0; + } + + /* Determine if the H1-H2 null-statistic should be computed */ + if( (nullStatH1H2Out && ( (caseID[1] && caseID[2]) + || (numDetectors > 2) ) ) ) { + cohInspInitParams->nullStatH1H2Out = 1; + } + else { + if ( vrbflg && nullStatH1H2Out ) fprintf( stdout, "Not outputting nullStatH1H2Out because either this is a two-detector network or at least one of H1 and H2 is missing ...\n " ); + cohInspInitParams->nullStatH1H2Out = 0; + } + + if( (nullStatOut && ( ( numDetectors >3 ) || + ( (numDetectors == 3) && !(caseID[1] && caseID[2]) ) ) ) ) { + cohInspInitParams->nullStatOut = 1; + } + else { + if ( vrbflg && nullStatOut ) fprintf( stdout, "Not outputting nullStatOut because either numDetectors < 3 or at least one of H1 and H2 is missing ...\n " ); + cohInspInitParams->nullStatOut = 0; + } + + /* create the data structures needed for coherentInspiral */ + + if ( vrbflg ) fprintf( stdout, "initializing coherentInspiral...\n " ); + + /* initialize coherentInspiral filter functions */ + LAL_CALL( LALCoherentInspiralFilterInputInit (&status, &cohInspFilterInput, + cohInspInitParams), &status ); + + cohInspCVec = cohInspFilterInput->multiCData; + + m1 = thisCoinc->snglInspiral[kmax]->mass1; + m2 = thisCoinc->snglInspiral[kmax]->mass2; + muMass = m1 * m2 / (m1 + m2); + + cohInspFilterInput->tmplt = (InspiralTemplate *) + LALCalloc(1,sizeof(InspiralTemplate) ); + cohInspFilterInput->tmplt->mass1 = m1; + cohInspFilterInput->tmplt->mass2 = m2; + cohInspFilterInput->tmplt->totalMass = m1 + m2; + cohInspFilterInput->tmplt->mu = m1 * m2 / (m1 + m2); + cohInspFilterInput->tmplt->eta = (m1 * m2) / ((m1 + m2) * (m1 + m2 )); + + if (vrbflg) fprintf( stdout, "m1:%f m2:%f totalmass:%f mu:%f eta:%f\n", cohInspFilterInput->tmplt->mass1, cohInspFilterInput->tmplt->mass2,cohInspFilterInput->tmplt->totalMass,cohInspFilterInput->tmplt->mu,cohInspFilterInput->tmplt->eta); + + LAL_CALL( LALCoherentInspiralFilterParamsInit (&status, &cohInspFilterParams, + cohInspInitParams),&status ); + + /* Initialize the filter param structure for thisCoinc trigger */ + + cohInspFilterParams->deltaT = 1.0/((REAL8) sampleRate); + cohInspFilterParams->cohSNRThresh = cohSNRThresh; + cohInspFilterParams->cohSNROut = cohInspInitParams->cohSNROut; + cohInspFilterParams->cohH1H2SNROut = cohInspInitParams->cohH1H2SNROut; + cohInspFilterParams->nullStatH1H2Out = cohInspInitParams->nullStatH1H2Out; + cohInspFilterParams->nullStatOut = cohInspInitParams->nullStatOut; + cohInspFilterParams->numTmplts = 1; + cohInspFilterParams->fLow = fLow; + cohInspFilterParams->maximizeOverChirp = maximizeOverChirp; + cohInspFilterParams->numDetectors = cohInspInitParams->numDetectors; + cohInspFilterParams->raStep = raStep; + cohInspFilterParams->decStep = decStep; + /* initParams not needed anymore */ + free( cohInspInitParams ); + cohInspInitParams = NULL; + + if (vrbflg) fprintf( stdout, "deltaT:%f cohSNRThresh:%f numTmplts:%d\n", cohInspFilterParams->deltaT,cohInspFilterParams->cohSNRThresh,cohInspFilterParams->numTmplts); + + for( j=0; j<LAL_NUM_IFO; j++ ) + { + cohInspFilterParams->detIDVec->data[j] = caseID[j]; + cohInspFilterParams->sigmasqVec->data[j] = 1.0; + } + + /* Read in the snippets associated with thisCoinc trigger */ + l = 0; /* A counter to step through the cohInspCVec-tors */ + for( j=0; j<LAL_NUM_IFO; j++ ) + { + if( caseID[j] ) { + FrFile *frfileIn[j]; + FrameH *ifoFrame = NULL; + FrProcData *proc = NULL; + LIGOTimeGPS tmpEpoch; + + if( vrbflg ) fprintf(stdout, "getting the COMPLEX8TimeSeries %s \n", nameArrayCData[j] ); + + if ( !(frfileIn[j]= XLALFrOpenURL( ifoframefile[j] )) ) { + XLALPrintError( "XLAL Error: could not open frame file %s - exiting...\n", ifoframefile[j] ); + exit(1); + } + while( ! proc && (ifoFrame = FrameRead( frfileIn[j] )) ) { + proc = ifoFrame->procData; if( vrbflg ) fprintf(stdout, "Proc name is %s \n", proc->name ); - /*while ( proc && ( strcmp( nameArrayCData[j], proc->name) == 0 ) ) {*/ + /*while ( proc && ( strcmp( nameArrayCData[j], proc->name) == 0 ) ) {*/ while ( proc && strcmp( nameArrayCData[j], proc->name ) ) { - proc = proc->next; - } - if ( ! proc ) - FrameFree( ifoFrame ); - } - - if ( ! proc ) { - XLALPrintError( "XLAL Error: could not find channel %s in file %s - exiting...\n", nameArrayCData[j], ifoframefile[j] ); - FrFileIEnd( frfileIn[j] ); - exit(1); - } - - XLALGPSSet( &tmpEpoch, ifoFrame->GTimeS, ifoFrame->GTimeN ); - XLALGPSAdd( &tmpEpoch, proc->timeOffset ); - XLALGPSAdd( &tmpEpoch, proc->data->startX[0] ); - - /* Scale up fShift for all ifos */ - if ( proc->fShift ) { - cohInspCVec->cData[l] = XLALCreateCOMPLEX8TimeSeries( proc->data->name, &tmpEpoch, (REAL8) proc->fShift, proc->data->dx[0], &lalDimensionlessUnit, proc->data->nData ); - } - else { - cohInspCVec->cData[l] = XLALCreateCOMPLEX8TimeSeries( proc->data->name, &tmpEpoch, 0.0, proc->data->dx[0], &lalDimensionlessUnit, proc->data->nData ); - } - if ( ! cohInspCVec->cData[l] ) { - FrFileIEnd( frfileIn[j] ); - XLALPrintError( "XLAL Error: could not create cData from channel %s in file %s - exiting...\n", nameArrayCData[j], ifoframefile[j] ); - exit(1); - } - - memcpy( cohInspCVec->cData[l]->data->data, proc->data->data, cohInspCVec->cData[l]->data->length * sizeof( *(cohInspCVec->cData[l])->data->data ) ); - FrFileIEnd( frfileIn[j] ); - - /*CHECK: Note that inspiral.c has a temporary fix for using - the f0 member of the COMPLEX8TimeSeries structure for - communicating sigmasq. - */ - if ( !(cohInspCVec->cData[l]->f0 == 0.0) ) { - cohInspFilterParams->sigmasqVec->data[j] = cohInspCVec->cData[l]->f0; - } - else { - cohInspFilterParams->sigmasqVec->data[j] = 1.0; - } - - if (vrbflg) fprintf( stdout, "sigmasq:%f\n",cohInspFilterParams->sigmasqVec->data[j]); - - l++; - }/* Closes "if( caseID[j] )" */ - }/* Closes "for( j=0; j<LAL_NUM_IFO; j++ )" */ - - for ( l=0 ; l<(INT4)numDetectors ; l++) - { - tempTime[l] += cohInspCVec->cData[l]->epoch.gpsSeconds + cohInspCVec->cData[l]->epoch.gpsNanoSeconds * 1e-9; - } - - /* store the start and end time of the first ifo cdata in the search summary */ - /* FIXME: loss of precision; consider - searchsumm.searchSummaryTable->in_start_time = searchsumm.searchSummaryTable->in_end_time = cohInspCVec->cData[0]->epoch; - XLALGPSAdd(&searchsumm.searchSummaryTable->in_end_time, (REAL8) cohSegLength / sampleRate); - */ - searchsumm.searchSummaryTable->in_start_time = cohInspCVec->cData[0]->epoch; - cohSeriesLength = XLALGPSGetREAL8( &(cohInspCVec->cData[0]->epoch) ); - cohSeriesLength += (REAL8) cohSegLength / sampleRate ; - XLALGPSSetREAL8( &(searchsumm.searchSummaryTable->in_end_time), cohSeriesLength ); - - /* If we can estimate distance then compute templateNorm */ - /* At present, this is only good for frequency domain tmplts */ - /* Since each detector's data has been filtered with templates */ - /* that have the same mass pair, templateNorm is the same for */ - /* every detector and needs to be computed only once. */ - - totMass = (REAL4) cohInspFilterInput->tmplt->totalMass; - deltaT = (REAL4) cohInspFilterParams->deltaT; - distNorm = 2.0 * LAL_MRSUN_SI / (1.0 * 1e6 * LAL_PC_SI); - templateNorm = sqrt( (5.0*((REAL4)muMass)) / 96.0 ) * pow( totMass / (LAL_PI*LAL_PI) , 1.0/3.0 ) * pow( LAL_MTSUN_SI / deltaT, -1.0/6.0 ); - distNorm *= dynRange; - templateNorm *= templateNorm; - templateNorm *= distNorm * distNorm; - cohInspFilterParams->templateNorm = templateNorm; - cohInspFilterParams->segmentLength = numPointsSeg; - - /* calculate the length of the chirp for clustering over chirp-length*/ - c0 = 5.0*(cohInspFilterInput->tmplt->totalMass)*LAL_MTSUN_SI/(256.0*(cohInspFilterInput->tmplt->eta)); - c2 = 743.0/252.0 + (cohInspFilterInput->tmplt->eta)*11.0/3.0; - c3 = -32*LAL_PI/3; - c4 = 3058673.0/508032.0 + (cohInspFilterInput->tmplt->eta)*(5429.0/504.0 + (cohInspFilterInput->tmplt->eta)*617.0/72.0); - x1 = pow(LAL_PI*((REAL4)(cohInspFilterInput->tmplt->totalMass))*LAL_MTSUN_SI*cohInspFilterParams->fLow , 1.0/3.0); - x2 = x1*x1; - x3 = x1*x2; - x4 = x2*x2; - x8 = x4*x4; - - cohInspFilterParams->chirpTime = ((REAL4)c0)*(1 + ((REAL4)c2)*x2 + c3*x3 + ((REAL4)c4)*x4)/x8; - - if (vrbflg) fprintf(stdout,"filtering the data..\n"); - if ( maximizeOverChirp && vrbflg ) - { - fprintf(stdout,"clustering events\n"); - } - - /* Before the data gets filtered, I need to make the c-data snippets commensurate */ - for(j=0;j<(INT4)numDetectors - 1;j++) - { - timeptDiff[j] = rint((tempTime[0] - tempTime[j+1]) * sampleRate); - if( vrbflg ) fprintf(stdout,"timeptDiff = %d\n",timeptDiff[j]); - } - - /* Now allocate memory for a temporary storage vector */ - memset( &tempSnippet, 0, sizeof(COMPLEX8TimeSeries) ); - LAL_CALL( LALCCreateVector( &status, &(tempSnippet.data), numPoints ), &status ); - - /* If cohSNR is being output, then copy epoch */ - if( cohInspFilterParams->cohSNROut ) { - cohInspFilterParams->cohSNRVec->epoch = cohInspCVec->cData[0]->epoch; - cohInspFilterParams->cohSNRVec->deltaT = cohInspCVec->cData[0]->deltaT; - } - - if( cohInspFilterParams->cohH1H2SNROut ) { - cohInspFilterParams->cohH1H2SNRVec->epoch = cohInspCVec->cData[0]->epoch; - cohInspFilterParams->cohH1H2SNRVec->deltaT = cohInspCVec->cData[0]->deltaT; - } - - if( cohInspFilterParams->nullStatH1H2Out ) { - cohInspFilterParams->nullStatH1H2Vec->epoch = cohInspCVec->cData[0]->epoch; - cohInspFilterParams->nullStatH1H2Vec->deltaT = cohInspCVec->cData[0]->deltaT; - } - - if( cohInspFilterParams->nullStatOut ) { - cohInspFilterParams->nullStatVec->epoch = cohInspCVec->cData[0]->epoch; - cohInspFilterParams->nullStatVec->deltaT = cohInspCVec->cData[0]->deltaT; - } - - /* Now that the time series are commensurate, do the filtering... */ - LALCoherentInspiralFilterSegment (&status, &thisEvent, cohInspFilterInput, cohInspFilterParams); - - /* Save event id in multi_inspiral table */ - thisEventTemp =thisEvent; - while( thisEventTemp ) - { - thisEventTemp->event_id = (EventIDColumn *) - LALCalloc(1, sizeof(EventIDColumn) ); - thisEventTemp->event_id->id=eventID; - thisEventTemp = thisEventTemp->next; - } - - if ( cohInspFilterParams->cohSNROut ) - { - snprintf( cohdataStr, LALNameLength*sizeof(CHAR), - "SNR_%Ld", eventID ); - strcpy( cohInspFilterParams->cohSNRVec->name, "Coherent"); - outFrameCoh = fr_add_proc_REAL4TimeSeries( outFrameCoh, cohInspFilterParams->cohSNRVec, "none", cohdataStr ); - } - - /* save the coherent-snr of the H1-H2 pair */ - if ( cohInspFilterParams->cohH1H2SNROut ) - { - snprintf( cohdataStr, LALNameLength*sizeof(CHAR), - "H1H2SNR_%Ld", eventID ); - strcpy( cohInspFilterParams->cohH1H2SNRVec->name, "Coherent"); - outFrameCohH1H2SNR = fr_add_proc_REAL4TimeSeries( outFrameCohH1H2SNR, cohInspFilterParams->cohH1H2SNRVec, "none", cohdataStr ); - } - - /* save H1-H2 null-stream statistic in frames */ - if ( cohInspFilterParams->nullStatH1H2Out ) - { - snprintf( cohdataStr, LALNameLength*sizeof(CHAR), - "H1H2_NullStat_%Ld", eventID ); - strcpy( cohInspFilterParams->nullStatH1H2Vec->name, "Coherent"); - outFrameNullStatH1H2 = fr_add_proc_REAL4TimeSeries( outFrameNullStatH1H2, cohInspFilterParams->nullStatH1H2Vec, "none", cohdataStr ); - } - - /* save network null-stream statistic in frames */ - if ( cohInspFilterParams->nullStatOut ) - { - snprintf( cohdataStr, LALNameLength*sizeof(CHAR), - "NullStat_%Ld", eventID ); - strcpy( cohInspFilterParams->nullStatVec->name, "Coherent"); - outFrameNullStat = fr_add_proc_REAL4TimeSeries( outFrameNullStat, cohInspFilterParams->nullStatVec, "none", cohdataStr ); - } - - if ( !eventsOut ) - { - while( thisEvent ) - { - MultiInspiralTable *tempEvent = thisEvent; - thisEvent = thisEvent->next; - LALFree( tempEvent->event_id ); - LALFree( tempEvent ); - } - } - - if( thisEvent ) - { - if( vrbflg ) fprintf( stdout,"******> Dumping Events <******\n"); - if( !savedEvents.multiInspiralTable ) - { - MultiInspiralTable *tempEvent = thisEvent; - tempTable = (MultiInspiralTable *) LALCalloc( 1, sizeof(MultiInspiralTable) ); - memcpy(tempTable,thisEvent,sizeof(MultiInspiralTable) ); - savedEvents.multiInspiralTable = tempTable; - thisEvent = thisEvent->next; - LALFree( tempEvent ); - tempEvent = NULL; - if( thisEvent ) - { - while( thisEvent ) - { - MultiInspiralTable *tempEvent = thisEvent; - tempTable->next = (MultiInspiralTable *) LALCalloc( 1, sizeof(MultiInspiralTable) ); - tempTable = tempTable->next; - memcpy(tempTable, thisEvent, sizeof(MultiInspiralTable) ); - thisEvent = thisEvent->next; - - LALFree( tempEvent ); - tempEvent = NULL; - } - } - } - else - { - while( thisEvent ) - { - MultiInspiralTable *tempEvent = thisEvent; - tempTable->next = (MultiInspiralTable *) LALCalloc( 1, sizeof(MultiInspiralTable) ); - tempTable = tempTable->next; - memcpy(tempTable, thisEvent, sizeof(MultiInspiralTable) ); - thisEvent = thisEvent->next; - LALFree( tempEvent ); - tempEvent = NULL; - } - } - - while( thisEvent ) - { - MultiInspiralTable *tempEvent = thisEvent; - thisEvent = thisEvent->next; - LALFree( tempEvent ); - tempEvent = NULL; - } - - }/*end if( thisEvent ) */ - - /* Finalize */ - LAL_CALL( LALCDestroyVector( &status, &(tempSnippet.data) ), &status ); - LALFree( cohInspFilterInput->tmplt ); - cohInspFilterInput->tmplt = NULL; - - for ( l = 0 ; l<(INT4)numDetectors ; l++ ) { - XLALDestroyCOMPLEX8TimeSeries( cohInspCVec->cData[l] ); - } - - /* Destroy params structure for coherent filter code */ - LAL_CALL( LALCoherentInspiralFilterParamsFinalize (&status,&cohInspFilterParams), &status ); - cohInspFilterParams = NULL; - - /* Destroy input structure for coherent filter code */ - LAL_CALL( LALCoherentInspiralFilterInputFinalize (&status, &cohInspFilterInput), &status); - cohInspFilterInput = NULL; - cohInspBeamVec = NULL; - cohInspCVec = NULL; - - for(j=0;j<5;j++) - { - tempTime[j] = 0.0; - timeptDiff[j] = 0; - } - tempTime[5] = 0.0; - - thisCoinc=thisCoinc->next; - + proc = proc->next; + } + if ( ! proc ) + FrameFree( ifoFrame ); + } + + if ( ! proc ) { + XLALPrintError( "XLAL Error: could not find channel %s in file %s - exiting...\n", nameArrayCData[j], ifoframefile[j] ); + FrFileIEnd( frfileIn[j] ); + exit(1); + } + + XLALGPSSet( &tmpEpoch, ifoFrame->GTimeS, ifoFrame->GTimeN ); + XLALGPSAdd( &tmpEpoch, proc->timeOffset ); + XLALGPSAdd( &tmpEpoch, proc->data->startX[0] ); + + /* Scale up fShift for all ifos */ + if ( proc->fShift ) { + cohInspCVec->cData[l] = XLALCreateCOMPLEX8TimeSeries( proc->data->name, &tmpEpoch, (REAL8) proc->fShift, proc->data->dx[0], &lalDimensionlessUnit, proc->data->nData ); + } + else { + cohInspCVec->cData[l] = XLALCreateCOMPLEX8TimeSeries( proc->data->name, &tmpEpoch, 0.0, proc->data->dx[0], &lalDimensionlessUnit, proc->data->nData ); + } + if ( ! cohInspCVec->cData[l] ) { + FrFileIEnd( frfileIn[j] ); + XLALPrintError( "XLAL Error: could not create cData from channel %s in file %s - exiting...\n", nameArrayCData[j], ifoframefile[j] ); + exit(1); + } + + memcpy( cohInspCVec->cData[l]->data->data, proc->data->data, cohInspCVec->cData[l]->data->length * sizeof( *(cohInspCVec->cData[l])->data->data ) ); + FrFileIEnd( frfileIn[j] ); + + /*CHECK: Note that inspiral.c has a temporary fix for using + the f0 member of the COMPLEX8TimeSeries structure for + communicating sigmasq. + */ + if ( !(cohInspCVec->cData[l]->f0 == 0.0) ) { + cohInspFilterParams->sigmasqVec->data[j] = cohInspCVec->cData[l]->f0; + } + else { + cohInspFilterParams->sigmasqVec->data[j] = 1.0; + } + + if (vrbflg) fprintf( stdout, "sigmasq:%f\n",cohInspFilterParams->sigmasqVec->data[j]); + + l++; + }/* Closes "if( caseID[j] )" */ + }/* Closes "for( j=0; j<LAL_NUM_IFO; j++ )" */ + + for ( l=0 ; l<(INT4)numDetectors ; l++) + { + tempTime[l] += cohInspCVec->cData[l]->epoch.gpsSeconds + cohInspCVec->cData[l]->epoch.gpsNanoSeconds * 1e-9; + } + + /* store the start and end time of the first ifo cdata in the search summary */ + /* FIXME: loss of precision; consider + searchsumm.searchSummaryTable->in_start_time = searchsumm.searchSummaryTable->in_end_time = cohInspCVec->cData[0]->epoch; + XLALGPSAdd(&searchsumm.searchSummaryTable->in_end_time, (REAL8) cohSegLength / sampleRate); + */ + searchsumm.searchSummaryTable->in_start_time = cohInspCVec->cData[0]->epoch; + cohSeriesLength = XLALGPSGetREAL8( &(cohInspCVec->cData[0]->epoch) ); + cohSeriesLength += (REAL8) cohSegLength / sampleRate ; + XLALGPSSetREAL8( &(searchsumm.searchSummaryTable->in_end_time), cohSeriesLength ); + + /* If we can estimate distance then compute templateNorm */ + /* At present, this is only good for frequency domain tmplts */ + /* Since each detector's data has been filtered with templates */ + /* that have the same mass pair, templateNorm is the same for */ + /* every detector and needs to be computed only once. */ + + totMass = (REAL4) cohInspFilterInput->tmplt->totalMass; + deltaT = (REAL4) cohInspFilterParams->deltaT; + distNorm = 2.0 * LAL_MRSUN_SI / (1.0 * 1e6 * LAL_PC_SI); + templateNorm = sqrt( (5.0*((REAL4)muMass)) / 96.0 ) * pow( totMass / (LAL_PI*LAL_PI) , 1.0/3.0 ) * pow( LAL_MTSUN_SI / deltaT, -1.0/6.0 ); + distNorm *= dynRange; + templateNorm *= templateNorm; + templateNorm *= distNorm * distNorm; + cohInspFilterParams->templateNorm = templateNorm; + cohInspFilterParams->segmentLength = numPointsSeg; + + /* calculate the length of the chirp for clustering over chirp-length*/ + c0 = 5.0*(cohInspFilterInput->tmplt->totalMass)*LAL_MTSUN_SI/(256.0*(cohInspFilterInput->tmplt->eta)); + c2 = 743.0/252.0 + (cohInspFilterInput->tmplt->eta)*11.0/3.0; + c3 = -32*LAL_PI/3; + c4 = 3058673.0/508032.0 + (cohInspFilterInput->tmplt->eta)*(5429.0/504.0 + (cohInspFilterInput->tmplt->eta)*617.0/72.0); + x1 = pow(LAL_PI*((REAL4)(cohInspFilterInput->tmplt->totalMass))*LAL_MTSUN_SI*cohInspFilterParams->fLow , 1.0/3.0); + x2 = x1*x1; + x3 = x1*x2; + x4 = x2*x2; + x8 = x4*x4; + + cohInspFilterParams->chirpTime = ((REAL4)c0)*(1 + ((REAL4)c2)*x2 + c3*x3 + ((REAL4)c4)*x4)/x8; + + if (vrbflg) fprintf(stdout,"filtering the data..\n"); + if ( maximizeOverChirp && vrbflg ) + { + fprintf(stdout,"clustering events\n"); + } + + /* Before the data gets filtered, I need to make the c-data snippets commensurate */ + for(j=0;j<(INT4)numDetectors - 1;j++) + { + timeptDiff[j] = rint((tempTime[0] - tempTime[j+1]) * sampleRate); + if( vrbflg ) fprintf(stdout,"timeptDiff = %d\n",timeptDiff[j]); + } + + /* Now allocate memory for a temporary storage vector */ + memset( &tempSnippet, 0, sizeof(COMPLEX8TimeSeries) ); + LAL_CALL( LALCCreateVector( &status, &(tempSnippet.data), numPoints ), &status ); + + /* If cohSNR is being output, then copy epoch */ + if( cohInspFilterParams->cohSNROut ) { + cohInspFilterParams->cohSNRVec->epoch = cohInspCVec->cData[0]->epoch; + cohInspFilterParams->cohSNRVec->deltaT = cohInspCVec->cData[0]->deltaT; + } + + if( cohInspFilterParams->cohH1H2SNROut ) { + cohInspFilterParams->cohH1H2SNRVec->epoch = cohInspCVec->cData[0]->epoch; + cohInspFilterParams->cohH1H2SNRVec->deltaT = cohInspCVec->cData[0]->deltaT; + } + + if( cohInspFilterParams->nullStatH1H2Out ) { + cohInspFilterParams->nullStatH1H2Vec->epoch = cohInspCVec->cData[0]->epoch; + cohInspFilterParams->nullStatH1H2Vec->deltaT = cohInspCVec->cData[0]->deltaT; + } + + if( cohInspFilterParams->nullStatOut ) { + cohInspFilterParams->nullStatVec->epoch = cohInspCVec->cData[0]->epoch; + cohInspFilterParams->nullStatVec->deltaT = cohInspCVec->cData[0]->deltaT; + } + + /* Now that the time series are commensurate, do the filtering... */ + LALCoherentInspiralFilterSegment (&status, &thisEvent, cohInspFilterInput, cohInspFilterParams); + + /* Save event id in multi_inspiral table */ + thisEventTemp =thisEvent; + while( thisEventTemp ) + { + thisEventTemp->event_id = (EventIDColumn *) + LALCalloc(1, sizeof(EventIDColumn) ); + thisEventTemp->event_id->id=eventID; + thisEventTemp = thisEventTemp->next; + } + + if ( cohInspFilterParams->cohSNROut ) + { + snprintf( cohdataStr, LALNameLength*sizeof(CHAR), + "SNR_%Ld", eventID ); + strcpy( cohInspFilterParams->cohSNRVec->name, "Coherent"); + outFrameCoh = fr_add_proc_REAL4TimeSeries( outFrameCoh, cohInspFilterParams->cohSNRVec, "none", cohdataStr ); + } + + /* save the coherent-snr of the H1-H2 pair */ + if ( cohInspFilterParams->cohH1H2SNROut ) + { + snprintf( cohdataStr, LALNameLength*sizeof(CHAR), + "H1H2SNR_%Ld", eventID ); + strcpy( cohInspFilterParams->cohH1H2SNRVec->name, "Coherent"); + outFrameCohH1H2SNR = fr_add_proc_REAL4TimeSeries( outFrameCohH1H2SNR, cohInspFilterParams->cohH1H2SNRVec, "none", cohdataStr ); + } + + /* save H1-H2 null-stream statistic in frames */ + if ( cohInspFilterParams->nullStatH1H2Out ) + { + snprintf( cohdataStr, LALNameLength*sizeof(CHAR), + "H1H2_NullStat_%Ld", eventID ); + strcpy( cohInspFilterParams->nullStatH1H2Vec->name, "Coherent"); + outFrameNullStatH1H2 = fr_add_proc_REAL4TimeSeries( outFrameNullStatH1H2, cohInspFilterParams->nullStatH1H2Vec, "none", cohdataStr ); + } + + /* save network null-stream statistic in frames */ + if ( cohInspFilterParams->nullStatOut ) + { + snprintf( cohdataStr, LALNameLength*sizeof(CHAR), + "NullStat_%Ld", eventID ); + strcpy( cohInspFilterParams->nullStatVec->name, "Coherent"); + outFrameNullStat = fr_add_proc_REAL4TimeSeries( outFrameNullStat, cohInspFilterParams->nullStatVec, "none", cohdataStr ); + } + + if ( !eventsOut ) + { + while( thisEvent ) + { + MultiInspiralTable *tempEvent = thisEvent; + thisEvent = thisEvent->next; + LALFree( tempEvent->event_id ); + LALFree( tempEvent ); + } + } + + if( thisEvent ) + { + if( vrbflg ) fprintf( stdout,"******> Dumping Events <******\n"); + if( !savedEvents.multiInspiralTable ) + { + MultiInspiralTable *tempEvent = thisEvent; + tempTable = (MultiInspiralTable *) LALCalloc( 1, sizeof(MultiInspiralTable) ); + memcpy(tempTable,thisEvent,sizeof(MultiInspiralTable) ); + savedEvents.multiInspiralTable = tempTable; + thisEvent = thisEvent->next; + LALFree( tempEvent ); + tempEvent = NULL; + if( thisEvent ) + { + while( thisEvent ) + { + MultiInspiralTable *tempEvent = thisEvent; + tempTable->next = (MultiInspiralTable *) LALCalloc( 1, sizeof(MultiInspiralTable) ); + tempTable = tempTable->next; + memcpy(tempTable, thisEvent, sizeof(MultiInspiralTable) ); + thisEvent = thisEvent->next; + + LALFree( tempEvent ); + tempEvent = NULL; + } + } + } + else + { + while( thisEvent ) + { + MultiInspiralTable *tempEvent = thisEvent; + tempTable->next = (MultiInspiralTable *) LALCalloc( 1, sizeof(MultiInspiralTable) ); + tempTable = tempTable->next; + memcpy(tempTable, thisEvent, sizeof(MultiInspiralTable) ); + thisEvent = thisEvent->next; + LALFree( tempEvent ); + tempEvent = NULL; + } + } + + while( thisEvent ) + { + MultiInspiralTable *tempEvent = thisEvent; + thisEvent = thisEvent->next; + LALFree( tempEvent ); + tempEvent = NULL; + } + + }/*end if( thisEvent ) */ + + /* Finalize */ + LAL_CALL( LALCDestroyVector( &status, &(tempSnippet.data) ), &status ); + LALFree( cohInspFilterInput->tmplt ); + cohInspFilterInput->tmplt = NULL; + + for ( l = 0 ; l<(INT4)numDetectors ; l++ ) { + XLALDestroyCOMPLEX8TimeSeries( cohInspCVec->cData[l] ); + } + + /* Destroy params structure for coherent filter code */ + LAL_CALL( LALCoherentInspiralFilterParamsFinalize (&status,&cohInspFilterParams), &status ); + cohInspFilterParams = NULL; + + /* Destroy input structure for coherent filter code */ + LAL_CALL( LALCoherentInspiralFilterInputFinalize (&status, &cohInspFilterInput), &status); + cohInspFilterInput = NULL; + cohInspBeamVec = NULL; + cohInspCVec = NULL; + + for(j=0;j<5;j++) + { + tempTime[j] = 0.0; + timeptDiff[j] = 0; + } + tempTime[5] = 0.0; + + thisCoinc=thisCoinc->next; + }/* Close loop over cohtrigs*/ /* Write the summary information */ - if ( userTag ) { - snprintf( fileName, FILENAME_MAX, "H1H2-CHIA_COHSNR_%d_%s-%d-%d", cohFileID, - userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + if ( userTag ) { + snprintf( fileName, FILENAME_MAX, "H1H2-CHIA_COHSNR_%d_%s-%d-%d", cohFileID, + userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } - else { - snprintf( fileName, FILENAME_MAX, "H1H2-CHIA_COHSNR_%d-%d-%d", - cohFileID, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + else { + snprintf( fileName, FILENAME_MAX, "H1H2-CHIA_COHSNR_%d-%d-%d", + cohFileID, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } if( outFrameCohH1H2SNR ) - { - if ( outputPath[0] ) - { - snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s/%s.gwf", outputPath, fileName); - } - else - { - snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s.gwf", fileName ); - } - - if ( vrbflg ) fprintf( stdout, "writing H1-H2 coherent-snr frame data to %s....", framename ); - frOutFile = FrFileONew( framename, 0); - FrameWrite( outFrameCohH1H2SNR, frOutFile); - FrFileOEnd( frOutFile ); - if ( vrbflg ) fprintf(stdout, "done\n"); - - } + { + if ( outputPath[0] ) + { + snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s/%s.gwf", outputPath, fileName); + } + else + { + snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s.gwf", fileName ); + } + + if ( vrbflg ) fprintf( stdout, "writing H1-H2 coherent-snr frame data to %s....", framename ); + frOutFile = FrFileONew( framename, 0); + FrameWrite( outFrameCohH1H2SNR, frOutFile); + FrFileOEnd( frOutFile ); + if ( vrbflg ) fprintf(stdout, "done\n"); + + } - if ( userTag ) { - snprintf( fileName, FILENAME_MAX, "H1H2-CHIA_NULL_STAT_%d_%s-%d-%d", cohFileID, - userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + if ( userTag ) { + snprintf( fileName, FILENAME_MAX, "H1H2-CHIA_NULL_STAT_%d_%s-%d-%d", cohFileID, + userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } - else { - snprintf( fileName, FILENAME_MAX, "H1H2-CHIA_NULL_STAT_%d-%d-%d", - cohFileID, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + else { + snprintf( fileName, FILENAME_MAX, "H1H2-CHIA_NULL_STAT_%d-%d-%d", + cohFileID, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } if( outFrameNullStatH1H2 ) - { - if ( outputPath[0] ) - { - snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s/%s.gwf", outputPath, fileName); - } - else - { - snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s.gwf", fileName ); - } - - if ( vrbflg ) fprintf( stdout, "writing null statistic frame data to %s....", framename ); - frOutFile = FrFileONew( framename, 0); - FrameWrite( outFrameNullStatH1H2, frOutFile); - FrFileOEnd( frOutFile ); - if ( vrbflg ) fprintf(stdout, "done\n"); - - } + { + if ( outputPath[0] ) + { + snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s/%s.gwf", outputPath, fileName); + } + else + { + snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s.gwf", fileName ); + } + + if ( vrbflg ) fprintf( stdout, "writing null statistic frame data to %s....", framename ); + frOutFile = FrFileONew( framename, 0); + FrameWrite( outFrameNullStatH1H2, frOutFile); + FrFileOEnd( frOutFile ); + if ( vrbflg ) fprintf(stdout, "done\n"); + + } if ( userTag ) { - snprintf( fileName, FILENAME_MAX, "%s-CHIA_NULL_STAT_%d_%s-%d-%d", ifos, cohFileID, - userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + snprintf( fileName, FILENAME_MAX, "%s-CHIA_NULL_STAT_%d_%s-%d-%d", ifos, cohFileID, + userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } else { - snprintf( fileName, FILENAME_MAX, "%s-CHIA_NULL_STAT_%d-%d-%d", ifos, - cohFileID, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + snprintf( fileName, FILENAME_MAX, "%s-CHIA_NULL_STAT_%d-%d-%d", ifos, + cohFileID, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } if( outFrameNullStat ) @@ -956,151 +952,151 @@ int main( int argc, char *argv[] ) { snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s.gwf", fileName ); } - + if ( vrbflg ) fprintf( stdout, "writing null statistic frame data to %s....", framename ); frOutFile = FrFileONew( framename, 0); FrameWrite( outFrameNullStat, frOutFile); FrFileOEnd( frOutFile ); if ( vrbflg ) fprintf(stdout, "done\n"); - - } + + } - if ( userTag ) { - snprintf( fileName, FILENAME_MAX, "%s-CHIA_%d_%s-%d-%d", ifos, cohFileID, - userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + if ( userTag ) { + snprintf( fileName, FILENAME_MAX, "%s-CHIA_%d_%s-%d-%d", ifos, cohFileID, + userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } - else { - snprintf( fileName, FILENAME_MAX, "%s-CHIA_%d-%d-%d", ifos, - cohFileID, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + else { + snprintf( fileName, FILENAME_MAX, "%s-CHIA_%d-%d-%d", ifos, + cohFileID, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } if( outFrameCoh ) - { - if ( outputPath[0] ) - { - snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s/%s.gwf", outputPath, fileName); - } - else - { - snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s.gwf", fileName ); - } - - if ( vrbflg ) fprintf( stdout, "writing coherent frame data to %s....", framename ); - frOutFile = FrFileONew( framename, 0); - FrameWrite( outFrameCoh, frOutFile); - FrFileOEnd( frOutFile ); - if ( vrbflg ) fprintf(stdout, "done\n"); - - } + { + if ( outputPath[0] ) + { + snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s/%s.gwf", outputPath, fileName); + } + else + { + snprintf( framename, FILENAME_MAX * sizeof(CHAR), "%s.gwf", fileName ); + } + + if ( vrbflg ) fprintf( stdout, "writing coherent frame data to %s....", framename ); + frOutFile = FrFileONew( framename, 0); + FrameWrite( outFrameCoh, frOutFile); + FrFileOEnd( frOutFile ); + if ( vrbflg ) fprintf(stdout, "done\n"); + + } if (eventsOut ) - { - memset( &results, 0, sizeof(LIGOLwXMLStream) ); - if ( outputPath[0] ) - { - if ( outCompress ) - { - snprintf( xmlname, FILENAME_MAX * sizeof(CHAR), "%s/%s.xml.gz", outputPath, fileName); - } - else - { - snprintf( xmlname, FILENAME_MAX * sizeof(CHAR), "%s/%s.xml", outputPath, fileName); - } - } - else - { - if ( outCompress ) - { - snprintf( xmlname, FILENAME_MAX * sizeof(CHAR), "%s.xml.gz", fileName ); - } - else - { - snprintf( xmlname, FILENAME_MAX * sizeof(CHAR), "%s.xml", fileName ); - } - } - if ( vrbflg ) fprintf( stdout, "writing XML data to %s...\n", xmlname ); - LAL_CALL( LALOpenLIGOLwXMLFile( &status, &results, xmlname), &status ); - - /* write the process table */ - j=0; - while( !(caseID[j]) ) { - ifo = caseIDChars[j]; - j++; - } - - if ( vrbflg ) fprintf( stdout, " process table...\n" ); - /* snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "%s", caseID );*/ - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), &accuracy ), &status ); - LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_table ), &status ); - LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, proctable, process_table ), &status ); - LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); - - /* write the process params table */ - if ( vrbflg ) fprintf( stdout, " process_params table...\n" ); - LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_params_table ), &status ); - LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, procparams, process_params_table ), &status ); - LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); - - /* write the search summary table */ - if ( vrbflg ) fprintf( stdout, " search_summary table...\n" ); - searchsumm.searchSummaryTable->out_start_time.gpsSeconds = - gpsStartTime.gpsSeconds + (numPointsSeg / (4 * sampleRate)); - searchsumm.searchSummaryTable->out_end_time.gpsSeconds = - gpsEndTime.gpsSeconds - (numPoints / (4 * sampleRate)); - - /* the number of nodes for a standalone job is always 1 */ - searchsumm.searchSummaryTable->nnodes = 1; - LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, - search_summary_table ), &status ); - LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, searchsumm, - search_summary_table ), &status ); - LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); - - if ( numTriggers ) - { - if ( vrbflg ) fprintf( stdout, " search_summvars table...\n" ); - LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, - search_summvars_table ), &status ); - LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, searchsummvars, - search_summvars_table ), &status ); - LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); - } - - /* store calibration information */ - if ( cohFileID == 1) { - ADD_SUMM_VALUE( "calibration alpha", "analysis", alpha, 0 ); - ADD_SUMM_VALUE( "calibration alphabeta", "analysis", alphabeta, 0 ); - ADD_SUMM_VALUE( "calibration alpha", "injection", inj_alpha, 0 ); - ADD_SUMM_VALUE( "calibration alphabeta", "injection", inj_alphabeta, 0 ); - } - LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, summ_value_table ), - &status ); - LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, summvalue, - summ_value_table ), &status ); - LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); - - /* write multi_inspiral table */ - if ( savedEvents.multiInspiralTable ) { - if( vrbflg ) fprintf(stdout," event params table\n "); - - LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, multi_inspiral_table ), &status ); - LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, savedEvents, multi_inspiral_table ), &status ); - LAL_CALL( LALEndLIGOLwXMLTable( &status, &results), &status ); - } - - while( savedEvents.multiInspiralTable ) - { - MultiInspiralTable *tempEvent2 = savedEvents.multiInspiralTable; - savedEvents.multiInspiralTable = savedEvents.multiInspiralTable->next; - LALFree( tempEvent2->event_id ); - LALFree( tempEvent2 ); - } - - /* close the output xml file */ - LAL_CALL( LALCloseLIGOLwXMLFile ( &status, &results ), &status ); - if ( vrbflg ) fprintf( stdout, "done. XML file closed\n" ); - - }/*end "if ( eventsOut )" */ + { + memset( &results, 0, sizeof(LIGOLwXMLStream) ); + if ( outputPath[0] ) + { + if ( outCompress ) + { + snprintf( xmlname, FILENAME_MAX * sizeof(CHAR), "%s/%s.xml.gz", outputPath, fileName); + } + else + { + snprintf( xmlname, FILENAME_MAX * sizeof(CHAR), "%s/%s.xml", outputPath, fileName); + } + } + else + { + if ( outCompress ) + { + snprintf( xmlname, FILENAME_MAX * sizeof(CHAR), "%s.xml.gz", fileName ); + } + else + { + snprintf( xmlname, FILENAME_MAX * sizeof(CHAR), "%s.xml", fileName ); + } + } + if ( vrbflg ) fprintf( stdout, "writing XML data to %s...\n", xmlname ); + LAL_CALL( LALOpenLIGOLwXMLFile( &status, &results, xmlname), &status ); + + /* write the process table */ + j=0; + while( !(caseID[j]) ) { + ifo = caseIDChars[j]; + j++; + } + + if ( vrbflg ) fprintf( stdout, " process table...\n" ); + /* snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "%s", caseID );*/ + XLALGPSTimeNow(&(proctable.processTable->end_time)); + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_table ), &status ); + LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, proctable, process_table ), &status ); + LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); + + /* write the process params table */ + if ( vrbflg ) fprintf( stdout, " process_params table...\n" ); + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_params_table ), &status ); + LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, procparams, process_params_table ), &status ); + LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); + + /* write the search summary table */ + if ( vrbflg ) fprintf( stdout, " search_summary table...\n" ); + searchsumm.searchSummaryTable->out_start_time.gpsSeconds = + gpsStartTime.gpsSeconds + (numPointsSeg / (4 * sampleRate)); + searchsumm.searchSummaryTable->out_end_time.gpsSeconds = + gpsEndTime.gpsSeconds - (numPoints / (4 * sampleRate)); + + /* the number of nodes for a standalone job is always 1 */ + searchsumm.searchSummaryTable->nnodes = 1; + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, + search_summary_table ), &status ); + LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, searchsumm, + search_summary_table ), &status ); + LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); + + if ( numTriggers ) + { + if ( vrbflg ) fprintf( stdout, " search_summvars table...\n" ); + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, + search_summvars_table ), &status ); + LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, searchsummvars, + search_summvars_table ), &status ); + LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); + } + + /* store calibration information */ + if ( cohFileID == 1) { + ADD_SUMM_VALUE( "calibration alpha", "analysis", alpha, 0 ); + ADD_SUMM_VALUE( "calibration alphabeta", "analysis", alphabeta, 0 ); + ADD_SUMM_VALUE( "calibration alpha", "injection", inj_alpha, 0 ); + ADD_SUMM_VALUE( "calibration alphabeta", "injection", inj_alphabeta, 0 ); + } + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, summ_value_table ), + &status ); + LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, summvalue, + summ_value_table ), &status ); + LAL_CALL( LALEndLIGOLwXMLTable ( &status, &results ), &status ); + + /* write multi_inspiral table */ + if ( savedEvents.multiInspiralTable ) { + if( vrbflg ) fprintf(stdout," event params table\n "); + + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, multi_inspiral_table ), &status ); + LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, savedEvents, multi_inspiral_table ), &status ); + LAL_CALL( LALEndLIGOLwXMLTable( &status, &results), &status ); + } + + while( savedEvents.multiInspiralTable ) + { + MultiInspiralTable *tempEvent2 = savedEvents.multiInspiralTable; + savedEvents.multiInspiralTable = savedEvents.multiInspiralTable->next; + LALFree( tempEvent2->event_id ); + LALFree( tempEvent2 ); + } + + /* close the output xml file */ + LAL_CALL( LALCloseLIGOLwXMLFile ( &status, &results ), &status ); + if ( vrbflg ) fprintf( stdout, "done. XML file closed\n" ); + + }/*end "if ( eventsOut )" */ }/* close "for( cohFileID...)" */ @@ -1149,7 +1145,7 @@ int main( int argc, char *argv[] ) LALFree( thisSearchSumm ); } - while ( coincHead ) { + while ( coincHead ) { thisCoinc = coincHead; coincHead = coincHead->next; LALFree( thisCoinc ); @@ -1301,12 +1297,12 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) break; case 'A': - optarg_len = strlen( optarg ) + 1; - ifoframefile[1] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); - memcpy( ifoframefile[1], optarg, optarg_len ); + optarg_len = strlen( optarg ) + 1; + ifoframefile[1] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); + memcpy( ifoframefile[1], optarg, optarg_len ); H1file = 1; - ADD_PROCESS_PARAM( "string", "%s", optarg ); - break; + ADD_PROCESS_PARAM( "string", "%s", optarg ); + break; case 'D': /* set right-ascension step-size (in degrees) */ decStep = atof (optarg); @@ -1319,43 +1315,43 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) break; case 'G': - optarg_len = strlen( optarg ) + 1; - ifoframefile[0] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); - memcpy( ifoframefile[0], optarg, optarg_len ); + optarg_len = strlen( optarg ) + 1; + ifoframefile[0] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); + memcpy( ifoframefile[0], optarg, optarg_len ); G1file = 1; - ADD_PROCESS_PARAM( "string", "%s", optarg ); + ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'L': - optarg_len = strlen( optarg ) + 1; - ifoframefile[3] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); - memcpy( ifoframefile[3], optarg, optarg_len ); + optarg_len = strlen( optarg ) + 1; + ifoframefile[3] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); + memcpy( ifoframefile[3], optarg, optarg_len ); L1file = 1; - ADD_PROCESS_PARAM( "string", "%s", optarg ); + ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'T': - optarg_len = strlen( optarg ) + 1; - ifoframefile[4] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); - memcpy( ifoframefile[4], optarg, optarg_len ); + optarg_len = strlen( optarg ) + 1; + ifoframefile[4] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); + memcpy( ifoframefile[4], optarg, optarg_len ); T1file = 1; - ADD_PROCESS_PARAM( "string", "%s", optarg ); + ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'V': - optarg_len = strlen( optarg ) + 1; - ifoframefile[5] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); - memcpy( ifoframefile[5], optarg, optarg_len ); + optarg_len = strlen( optarg ) + 1; + ifoframefile[5] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); + memcpy( ifoframefile[5], optarg, optarg_len ); V1file = 1; - ADD_PROCESS_PARAM( "string", "%s", optarg ); + ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'Z': - optarg_len = strlen( optarg ) + 1; - ifoframefile[2] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); - memcpy( ifoframefile[2], optarg, optarg_len ); + optarg_len = strlen( optarg ) + 1; + ifoframefile[2] = (CHAR *) calloc( optarg_len, sizeof(CHAR)); + memcpy( ifoframefile[2], optarg, optarg_len ); H2file = 1; - ADD_PROCESS_PARAM( "string", "%s", optarg ); + ADD_PROCESS_PARAM( "string", "%s", optarg ); break; case 'B': @@ -1379,12 +1375,12 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) snprintf( outputPath, FILENAME_MAX * sizeof(CHAR),"%s", optarg ); ADD_PROCESS_PARAM( "string", "%s", outputPath ); break; - + case 'd': /* set debuglevel */ set_debug_level( optarg ); ADD_PROCESS_PARAM( "string", "%s", optarg ); break; - + case 'f': /* set fLow */ fLow = (REAL4) atof (optarg); ADD_PROCESS_PARAM( "float", "%e", fLow ); @@ -1422,17 +1418,17 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) /*optarg_len = strlen( optarg ) + 1; bankFileName = (CHAR *) calloc( optarg_len, sizeof(CHAR)); memcpy( bankFileName, optarg, optarg_len );*/ - strcpy(cohbankFileName, optarg); - char tempName[256]; - char *duration =NULL; - strcpy(tempName, cohbankFileName); - duration = strtok(tempName,"-"); - duration = strtok(NULL,"-"); - duration = strtok(NULL,"-"); - duration = strtok(NULL,"."); - bankDuration=atoi(duration); + strcpy(cohbankFileName, optarg); + char tempName[256]; + char *duration =NULL; + strcpy(tempName, cohbankFileName); + duration = strtok(tempName,"-"); + duration = strtok(NULL,"-"); + duration = strtok(NULL,"-"); + duration = strtok(NULL,"."); + bankDuration=atoi(duration); ADD_PROCESS_PARAM( "string", "%s", cohbankFileName ); - duration=NULL; + duration=NULL; break; /* Read in time-slide steps for all detectors */ @@ -1484,6 +1480,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) "Bose/Seader <sukanta@wsu.edu>\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -1509,7 +1506,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) exit( 1 ); } gpsStartTimeNS += (INT8) gstartt * 1000000000LL; - gpsStartTimeTemp=gstartt; + gpsStartTimeTemp=gstartt; ADD_PROCESS_PARAM( "int", "%ld", gstartt ); } break; @@ -1536,7 +1533,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) exit( 1 ); } gpsEndTimeNS += (INT8) gendt * 1000000000LL; - gpsEndTimeTemp=gendt; + gpsEndTimeTemp=gendt; ADD_PROCESS_PARAM( "int", "%ld", gendt ); } break; @@ -1567,23 +1564,23 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) if ( eventsOut == 1 ) { snprintf( procparams.processParamsTable->program, - LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); + LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( procparams.processParamsTable->param, - LIGOMETA_PARAM_MAX, "--write-events" ); + LIGOMETA_PARAM_MAX, "--write-events" ); snprintf( procparams.processParamsTable->type, - LIGOMETA_TYPE_MAX, "string" ); + LIGOMETA_TYPE_MAX, "string" ); snprintf( procparams.processParamsTable->value, - LIGOMETA_VALUE_MAX, " " ); + LIGOMETA_VALUE_MAX, " " ); } if ( cohSNROut == 1 ) { this_proc_param = this_proc_param->next = (ProcessParamsTable *) - calloc( 1, sizeof(ProcessParamsTable) ); + calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--write-cohsnr" ); + "--write-cohsnr" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -1591,11 +1588,11 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) if ( cohH1H2SNROut == 1 ) { this_proc_param = this_proc_param->next = (ProcessParamsTable *) - calloc( 1, sizeof(ProcessParamsTable) ); + calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--write-cohh1h2snr" ); + "--write-cohh1h2snr" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -1603,11 +1600,11 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) if ( nullStatOut == 1 ) { this_proc_param = this_proc_param->next = (ProcessParamsTable *) - calloc( 1, sizeof(ProcessParamsTable) ); + calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--write-cohnullstat" ); + "--write-cohnullstat" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } diff --git a/lalapps/src/inspiral/coherentbank.c b/lalapps/src/inspiral/coherentbank.c index c4bf473c1b6a516b90b68b4d2238a688a0fdc637..b52effe542b0160999ec6d0dc2d836bcd607852d 100644 --- a/lalapps/src/inspiral/coherentbank.c +++ b/lalapps/src/inspiral/coherentbank.c @@ -104,7 +104,6 @@ static void print_usage(char *program) int main( int argc, char *argv[] ) { static LALStatus status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; INT4 i; INT4 numTriggers = 0; @@ -192,20 +191,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = processParamsTable.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -434,7 +432,7 @@ int main( int argc, char *argv[] ) "Steve Fairhurst and Shawn Seader\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -599,70 +597,70 @@ int main( int argc, char *argv[] ) { if ( vrbflg ) fprintf( stdout, "sorting coinc inspiral trigger list..." ); coincHead = XLALSortCoincInspiral( coincHead, - *XLALCompareCoincInspiralByTime ); + *XLALCompareCoincInspiralByTime ); if ( vrbflg ) fprintf( stdout, "done\n" ); if ( vrbflg ) fprintf( stdout, "clustering remaining triggers... " ); if ( !numSlides ) { - numClusteredEvents = XLALClusterCoincInspiralTable( &coincHead, - cluster_dt, coincstat , &bittenLParams); + numClusteredEvents = XLALClusterCoincInspiralTable( &coincHead, + cluster_dt, coincstat , &bittenLParams); } else { - int slide = 0; - int numClusteredSlide = 0; - CoincInspiralTable *slideCoinc = NULL; - CoincInspiralTable *slideClust = NULL; - - if ( vrbflg ) fprintf( stdout, "splitting events by slide\n" ); - - for( slide = -numSlides; slide < (numSlides + 1); slide++) - { - if ( vrbflg ) fprintf( stdout, "slide number %d; ", slide ); - /* extract the slide */ - slideCoinc = XLALCoincInspiralSlideCut( &coincHead, slide ); - /* run clustering */ - numClusteredSlide = XLALClusterCoincInspiralTable( &slideCoinc, - cluster_dt, coincstat, &bittenLParams); - - if ( vrbflg ) fprintf( stdout, "%d clustered events \n", - numClusteredSlide ); - numClusteredEvents += numClusteredSlide; - - /* add clustered triggers */ - if( slideCoinc ) - { - if( slideClust ) - { - thisCoinc = thisCoinc->next = slideCoinc; - } - else - { - slideClust = thisCoinc = slideCoinc; - } - /* scroll to end of list */ - for( ; thisCoinc->next; thisCoinc = thisCoinc->next); - } - } - - /* free coincHead -- although we expect it to be empty */ - while ( coincHead ) - { - thisCoinc = coincHead; - coincHead = coincHead->next; - XLALFreeCoincInspiral( &thisCoinc ); - } - - /* move events to coincHead */ - coincHead = slideClust; - slideClust = NULL; + int slide = 0; + int numClusteredSlide = 0; + CoincInspiralTable *slideCoinc = NULL; + CoincInspiralTable *slideClust = NULL; + + if ( vrbflg ) fprintf( stdout, "splitting events by slide\n" ); + + for( slide = -numSlides; slide < (numSlides + 1); slide++) + { + if ( vrbflg ) fprintf( stdout, "slide number %d; ", slide ); + /* extract the slide */ + slideCoinc = XLALCoincInspiralSlideCut( &coincHead, slide ); + /* run clustering */ + numClusteredSlide = XLALClusterCoincInspiralTable( &slideCoinc, + cluster_dt, coincstat, &bittenLParams); + + if ( vrbflg ) fprintf( stdout, "%d clustered events \n", + numClusteredSlide ); + numClusteredEvents += numClusteredSlide; + + /* add clustered triggers */ + if( slideCoinc ) + { + if( slideClust ) + { + thisCoinc = thisCoinc->next = slideCoinc; + } + else + { + slideClust = thisCoinc = slideCoinc; + } + /* scroll to end of list */ + for( ; thisCoinc->next; thisCoinc = thisCoinc->next); + } + } + + /* free coincHead -- although we expect it to be empty */ + while ( coincHead ) + { + thisCoinc = coincHead; + coincHead = coincHead->next; + XLALFreeCoincInspiral( &thisCoinc ); + } + + /* move events to coincHead */ + coincHead = slideClust; + slideClust = NULL; } if ( vrbflg ) fprintf( stdout, "done\n" ); if ( vrbflg ) fprintf( stdout, "%d clustered events \n", - numClusteredEvents ); + numClusteredEvents ); } /* @@ -673,7 +671,7 @@ int main( int argc, char *argv[] ) if ( allIFO ) { - numTmplts = XLALGenerateCoherentBank( &newEventList, coincHead, ifos ); + numTmplts = XLALGenerateCoherentBank( &newEventList, coincHead, ifos ); } else { @@ -735,8 +733,7 @@ int main( int argc, char *argv[] ) &status ); /* write process table */ - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/cohire.c b/lalapps/src/inspiral/cohire.c index 804f4899e3e222fac0cbe6ca84f62f4629da2990..c1eda28b7c4207c31beb5f100bc485efdcaadaaf 100644 --- a/lalapps/src/inspiral/cohire.c +++ b/lalapps/src/inspiral/cohire.c @@ -132,7 +132,6 @@ int main( int argc, char *argv[] ) { /* lal initialization variables */ LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* program option variables */ extern int vrbflg; @@ -221,20 +220,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -358,6 +356,7 @@ int main( int argc, char *argv[] ) fprintf( stdout, "Single Inspiral Reader and Injection Analysis\n" "Patrick Brady, Duncan Brown and Steve Fairhurst\n" "CVS Version: " CVS_ID_STRING "\n" ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -759,9 +758,9 @@ int main( int argc, char *argv[] ) /* read in the input file names */ for ( j = 0; j < numInFiles; ++j ) { - inFileNameList[j] = (char *) LALCalloc( MAX_PATH, sizeof(char) ); - get_next_line( line, sizeof(line), fp ); - strncpy( inFileNameList[j], line, strlen(line) - 1); + inFileNameList[j] = (char *) LALCalloc( MAX_PATH, sizeof(char) ); + get_next_line( line, sizeof(line), fp ); + strncpy( inFileNameList[j], line, strlen(line) - 1); } fclose( fp ); @@ -780,7 +779,7 @@ int main( int argc, char *argv[] ) MultiInspiralTable *thisFileTrigger = NULL; numFileTriggers = XLALReadMultiInspiralTriggerFile( &inspiralFileList, - &thisFileTrigger, &searchSummList, &inputFiles, inFileNameList[j] ); + &thisFileTrigger, &searchSummList, &inputFiles, inFileNameList[j] ); numEvents += numFileTriggers; @@ -789,17 +788,17 @@ int main( int argc, char *argv[] ) if (numFileTriggers < 0) { - fprintf(stderr, "Error reading triggers from file %s\n", - inFileNameList[j]); - exit( 1 ); + fprintf(stderr, "Error reading triggers from file %s\n", + inFileNameList[j]); + exit( 1 ); } else { - if ( vrbflg ) - { - fprintf(stdout, "Read %d reading triggers from file %s\n", - numFileTriggers, inFileNameList[j]); - } + if ( vrbflg ) + { + fprintf(stdout, "Read %d reading triggers from file %s\n", + numFileTriggers, inFileNameList[j]); + } } /* read the summ value table as well. */ @@ -1015,8 +1014,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/coinext.c b/lalapps/src/inspiral/coinext.c index 20234f91f43f5b49a2d37528ac9d45beca68a27b..64b85dd76b61f71f2503f69411eb7e84f13266ae 100644 --- a/lalapps/src/inspiral/coinext.c +++ b/lalapps/src/inspiral/coinext.c @@ -84,7 +84,7 @@ typedef struct S_ExternalList { int checkCGNtrigger( void ); int readCGN( void ); -void writeCGN( void ); +void writeCGN( void ); void checkInspiralTrigger( void ); int coinInspiralCGN( void ); int createInspiralTable( int lifo, int dag ); @@ -109,8 +109,6 @@ int arg_parse_check( int argc, char *argv[]); variables *******************************/ -LALLeapSecAccuracy accuracy=LALLEAPSEC_LOOSE; - int flagTest=0; /* flag indicating a test of the program */ int flagRestart; /* flag indicating to restart the complete DAQ */ int flagRecalc=0; /* flag indicating to redo the inspiral analysis */ @@ -246,7 +244,7 @@ int main(int argc, char* argv[]) if (signal(SIGINT, sigint_handler) == SIG_ERR) { perror("signal"); exit(1); - } + } /* check if to restart all */ if (flagRestart) { @@ -337,14 +335,9 @@ int checkCGNtrigger( void ) char inputGPS[256]; char input1[256]; char input2[256]; - LIGOTimeGPS* gps; - LALDate* date; + struct tm date; FILE* fileTrigger; - /* initialize date */ - date=(LALDate*)LALCalloc(1, sizeof(LALDate)); - gps=(LIGOTimeGPS*)LALCalloc(1, sizeof(LIGOTimeGPS)); - /* check if to get some trigger file or not */ if (!flagTriggerFile) { @@ -355,7 +348,7 @@ int checkCGNtrigger( void ) /* downloading file */ } else { sprintf(command, "wget %s -O %s > download.log 2>&1", - webPage, nameInputList); + webPage, nameInputList); system(command); } } @@ -438,45 +431,43 @@ int checkCGNtrigger( void ) if (index==-1) { - /* store new trigger in external triggers structure */ - extList[numberStoredCGN].gps=thisExt->start_time; - extList[numberStoredCGN].gpsNano=thisExt->start_time_ns; - extList[numberStoredCGN].status[0]=0; - extList[numberStoredCGN].status[1]=0; - extList[numberStoredCGN].status[2]=0; - extList[numberStoredCGN].dagStatus[0]=0; - extList[numberStoredCGN].dagStatus[1]=0; - extList[numberStoredCGN].dagStatus[2]=0; - extList[numberStoredCGN].table=(ExtTriggerTable*)LALCalloc( 1, sizeof(ExtTriggerTable) ); - memcpy( extList[numberStoredCGN].table, thisExt, sizeof(ExtTriggerTable)); - - /* getting user friendly date and time */ - gps->gpsSeconds=thisExt->start_time; - gps->gpsNanoSeconds=thisExt->start_time_ns; - LALGPStoUTC(&status, date, gps, &accuracy); - - /* generate output saying that there is a new CGN trigger */ - sprintf(message,"New CGN trigger occured at %d-%02d-%02d %d:%02d:%02d (%d)", - date->unixDate.tm_year+1900, date->unixDate.tm_mon+1, - date->unixDate.tm_mday,date->unixDate.tm_hour, - date->unixDate.tm_min, date->unixDate.tm_sec, - gps->gpsSeconds); - printOut(3, message); - - /* start special analysis job if data should be recalculated */ - if (flagRecalc) { - for ( nifo=startIFO;nifo<=endIFO;nifo++) { - startAnalysisJob( &extList[numberStoredCGN], nifo ); - } - } - - /* increase number of stored triggers from the Global GRB Network */ + /* store new trigger in external triggers structure */ + extList[numberStoredCGN].gps=thisExt->start_time; + extList[numberStoredCGN].gpsNano=thisExt->start_time_ns; + extList[numberStoredCGN].status[0]=0; + extList[numberStoredCGN].status[1]=0; + extList[numberStoredCGN].status[2]=0; + extList[numberStoredCGN].dagStatus[0]=0; + extList[numberStoredCGN].dagStatus[1]=0; + extList[numberStoredCGN].dagStatus[2]=0; + extList[numberStoredCGN].table=(ExtTriggerTable*)LALCalloc( 1, sizeof(ExtTriggerTable) ); + memcpy( extList[numberStoredCGN].table, thisExt, sizeof(ExtTriggerTable)); + + /* getting user friendly date and time */ + XLALGPSToUTC(&date, thisExt->start_time); + + /* generate output saying that there is a new CGN trigger */ + sprintf(message,"New CGN trigger occured at %d-%02d-%02d %d:%02d:%02d (%d)", + date.tm_year+1900, date.tm_mon+1, + date.tm_mday,date.tm_hour, + date.tm_min, date.tm_sec, + thisExt->start_time); + printOut(3, message); + + /* start special analysis job if data should be recalculated */ + if (flagRecalc) { + for ( nifo=startIFO;nifo<=endIFO;nifo++) { + startAnalysisJob( &extList[numberStoredCGN], nifo ); + } + } + + /* increase number of stored triggers from the Global GRB Network */ numberStoredCGN++; } else { - /* old trigger found -> set pointer to correct table */ - extList[index].table=thisExt; + /* old trigger found -> set pointer to correct table */ + extList[index].table=thisExt; } } } @@ -486,10 +477,10 @@ int checkCGNtrigger( void ) for (nifo=startIFO;nifo<=endIFO;nifo++) { for (i=0;i<numberStoredCGN;i++) { if (extList[i].status[nifo]==0) { - - /* set flag and exit loop */ - newTrigger=1; - continue; + + /* set flag and exit loop */ + newTrigger=1; + continue; } } } @@ -531,7 +522,7 @@ int readCGN( void ) /* read next line and store data */ fscanf(file, "%ld,%ld,%d,%d,%d, %d, %d, %d", &gps, &gpsNano, &status0, &status1, &status2, - &dagStatus0, &dagStatus1, &dagStatus2); + &dagStatus0, &dagStatus1, &dagStatus2); extList[c].gps = gps; extList[c].gpsNano = gpsNano; extList[c].status[0]= status0; @@ -562,7 +553,7 @@ writeCGN: by the same data and eventually some more entries are added *********************************/ void writeCGN( void ) -{ +{ FILE* file; int i; @@ -570,9 +561,9 @@ void writeCGN( void ) file=fopen(nameSaveExternalList,"w"); for ( i=0; i<numberStoredCGN; i++ ) { fprintf( file, "%ld,%ld,%d,%d,%d, %d, %d, %d\n", - extList[i].gps, extList[i].gpsNano, - extList[i].status[0], extList[i].status[1], extList[i].status[2], - extList[i].dagStatus[0], extList[i].dagStatus[1], extList[i].dagStatus[2]); + extList[i].gps, extList[i].gpsNano, + extList[i].status[0], extList[i].status[1], extList[i].status[2], + extList[i].dagStatus[0], extList[i].dagStatus[1], extList[i].dagStatus[2]); } fclose(file); @@ -604,12 +595,12 @@ void checkInspiralTrigger( void ) /* create new file containing all present inspiral trigger lists */ if (flagRecalc) { - /* use directory for recalculated trigger */ - sprintf( command, "ls -1 ../Trigger/%s/%s/%s/*.xml > namesInspiral.cel", run, instrName[i], dagName[dag]); + /* use directory for recalculated trigger */ + sprintf( command, "ls -1 ../Trigger/%s/%s/%s/*.xml > namesInspiral.cel", run, instrName[i], dagName[dag]); } else{ - /* use directory for online created triggers */ - sprintf( command,"ls -1 %s%s/*.xml > namesInspiral.cel", dirInspiral, instrName[i] ); + /* use directory for online created triggers */ + sprintf( command,"ls -1 %s%s/*.xml > namesInspiral.cel", dirInspiral, instrName[i] ); } system( command ); @@ -617,29 +608,29 @@ void checkInspiralTrigger( void ) file=fopen( "namesInspiral.cel","r" ); do { - /* read next filename and remove directory path from it */ - fscanf(file, "%s", text); - filename = basename1( (char*)text ); - - /* extracting relevant parts of the filename - assuming the length are always the same! */ - strcpy(inspiralList[i][c].filename, filename); - strncpy(dummy, filename+8, 9);dummy[9]='\0'; - inspiralList[i][c].timeStart=atoi(dummy); - strncpy(dummy, filename+18, 4);dummy[4]='\0'; - inspiralList[i][c].timeLength=atoi(dummy); - inspiralList[i][c].coin=0; - inspiralList[i][c].dagNumber=dag; - - if (flagVerbose) { - sprintf( message,"Found inspiral-trigger, entry %d: %s| GPS: %ld | dag: %d", - c, filename, inspiralList[i][c].timeStart, dag ); - printOut( 7, message ); - } - - /* increasing counter */ - c++; - + /* read next filename and remove directory path from it */ + fscanf(file, "%s", text); + filename = basename1( (char*)text ); + + /* extracting relevant parts of the filename + assuming the length are always the same! */ + strcpy(inspiralList[i][c].filename, filename); + strncpy(dummy, filename+8, 9);dummy[9]='\0'; + inspiralList[i][c].timeStart=atoi(dummy); + strncpy(dummy, filename+18, 4);dummy[4]='\0'; + inspiralList[i][c].timeLength=atoi(dummy); + inspiralList[i][c].coin=0; + inspiralList[i][c].dagNumber=dag; + + if (flagVerbose) { + sprintf( message,"Found inspiral-trigger, entry %d: %s| GPS: %ld | dag: %d", + c, filename, inspiralList[i][c].timeStart, dag ); + printOut( 7, message ); + } + + /* increasing counter */ + c++; + } while ( !feof(file) ); fclose(file); } @@ -656,7 +647,7 @@ void checkInspiralTrigger( void ) out=fopen( savename, "w" ); for (j=0;j<numberInspiralList[i]; j++) { fprintf( out, "%s %ld %ld\n",inspiralList[i][j].filename, - inspiralList[i][j].timeStart,inspiralList[i][j].timeLength); + inspiralList[i][j].timeStart,inspiralList[i][j].timeLength); } fclose(out); @@ -689,89 +680,89 @@ int coinInspiralCGN( void ) /* check status of the current CGN triggers */ if (extList[cgn].status[lifo]<4) { - /* get pointer to corresponding E.T. structure */ - table=extList[cgn].table; - if ( !table ) { - sprintf(message,"WARNING in coinInspiralCGN: A ExtTriggerTable does not exist for cgn %d. " - "Check program!\n",cgn); - printOut( 1, message ); - continue; - } - - /* get time of CGN trigger */ - timeCGN=(double)table->start_time + (double)table->start_time_ns/1.0e+9; - - /* loop over the different DAG's */ - for ( dag=startDAG; dag<=endDAG; dag++ ){ - - /* loop over all available trigger-XML-files */ - numberFound=0; - for (insp=0; insp<numberInspiralList[lifo]; insp++ ) { - - inspiralList[lifo][insp].coin=0; - - /* get starting end ending time of the time period - the inspiral triggers are from this file */ - timeStart=inspiralList[lifo][insp].timeStart; - timeEnd=timeStart+inspiralList[lifo][insp].timeLength; - /* */ - if ( (timeStart>=timeCGN-timeWindow && timeStart<=timeCGN+timeWindow) || - (timeEnd>=timeCGN-timeWindow && timeEnd<=timeCGN+timeWindow)) { - printf("overlap, dag:%d dagNumber:%d\n",dag,inspiralList[lifo][insp].dagNumber ); - } - /* */ - - /* check if time overlaps */ - if ( ( (timeStart>=timeCGN-timeWindow && timeStart<=timeCGN+timeWindow) || - (timeEnd>=timeCGN-timeWindow && timeEnd<=timeCGN+timeWindow) ) && - (inspiralList[lifo][insp].dagNumber==dag) ) { - - /* mark corresponding inspiral file */ - numberFound++; - inspiralList[lifo][insp].coin=1; - } - } - - /* happy: coincidence trigger found!!! - Create xml file and copy data for end-analysis !! */ - if (numberFound) { - - /* output */ - sprintf(message, "ExtTrigger found in coincidence at time %f", timeCGN); - printOut(4, message); - - /* creating final xml file and copy it to somewhere */ - createInspiralTable( lifo, dag ); - copyStatus=writeXML( lifo, cgn, dag ); - - /* set new status */ - if (copyStatus==0) { - extList[cgn].dagStatus[lifo]+=pow(3, dag); - sprintf(message, "coinInspiralCGN: DAG status for ifo %d (CGN=%d) set to %d\n", - lifo, cgn, extList[cgn].dagStatus[lifo]); - if (flagVerbose) printOut(7, message); - } else { - sprintf(message, "Unable to transfer data to %s. Trying later again...", destCopyURL); - printOut(2,message); - } - - } - - } /* {dag} */ - - /* set new status */ - if (extList[cgn].dagStatus[lifo]>=pow(3, endDAG+1)-1) { - extList[cgn].status[lifo]=5; - sprintf(message, "Status for CGN %d set to 5 (all DAG's ready and processed)\n", cgn); - if (flagVerbose) printOut(7,message); - } - - /* delete old inspiral triggers */ - while ( list ) { - element = list; - list = list->next; - LALFree( element ); - } + /* get pointer to corresponding E.T. structure */ + table=extList[cgn].table; + if ( !table ) { + sprintf(message,"WARNING in coinInspiralCGN: A ExtTriggerTable does not exist for cgn %d. " + "Check program!\n",cgn); + printOut( 1, message ); + continue; + } + + /* get time of CGN trigger */ + timeCGN=(double)table->start_time + (double)table->start_time_ns/1.0e+9; + + /* loop over the different DAG's */ + for ( dag=startDAG; dag<=endDAG; dag++ ){ + + /* loop over all available trigger-XML-files */ + numberFound=0; + for (insp=0; insp<numberInspiralList[lifo]; insp++ ) { + + inspiralList[lifo][insp].coin=0; + + /* get starting end ending time of the time period + the inspiral triggers are from this file */ + timeStart=inspiralList[lifo][insp].timeStart; + timeEnd=timeStart+inspiralList[lifo][insp].timeLength; + /* */ + if ( (timeStart>=timeCGN-timeWindow && timeStart<=timeCGN+timeWindow) || + (timeEnd>=timeCGN-timeWindow && timeEnd<=timeCGN+timeWindow)) { + printf("overlap, dag:%d dagNumber:%d\n",dag,inspiralList[lifo][insp].dagNumber ); + } + /* */ + + /* check if time overlaps */ + if ( ( (timeStart>=timeCGN-timeWindow && timeStart<=timeCGN+timeWindow) || + (timeEnd>=timeCGN-timeWindow && timeEnd<=timeCGN+timeWindow) ) && + (inspiralList[lifo][insp].dagNumber==dag) ) { + + /* mark corresponding inspiral file */ + numberFound++; + inspiralList[lifo][insp].coin=1; + } + } + + /* happy: coincidence trigger found!!! + Create xml file and copy data for end-analysis !! */ + if (numberFound) { + + /* output */ + sprintf(message, "ExtTrigger found in coincidence at time %f", timeCGN); + printOut(4, message); + + /* creating final xml file and copy it to somewhere */ + createInspiralTable( lifo, dag ); + copyStatus=writeXML( lifo, cgn, dag ); + + /* set new status */ + if (copyStatus==0) { + extList[cgn].dagStatus[lifo]+=pow(3, dag); + sprintf(message, "coinInspiralCGN: DAG status for ifo %d (CGN=%d) set to %d\n", + lifo, cgn, extList[cgn].dagStatus[lifo]); + if (flagVerbose) printOut(7, message); + } else { + sprintf(message, "Unable to transfer data to %s. Trying later again...", destCopyURL); + printOut(2,message); + } + + } + + } /* {dag} */ + + /* set new status */ + if (extList[cgn].dagStatus[lifo]>=pow(3, endDAG+1)-1) { + extList[cgn].status[lifo]=5; + sprintf(message, "Status for CGN %d set to 5 (all DAG's ready and processed)\n", cgn); + if (flagVerbose) printOut(7,message); + } + + /* delete old inspiral triggers */ + while ( list ) { + element = list; + list = list->next; + LALFree( element ); + } } } @@ -808,28 +799,28 @@ int createInspiralTable( int lifo, int dag ) if (inspiralList[lifo][insp].coin) { /* read data from the XML file using LAL functions - into new allocated memory, pointed by 'head' */ + into new allocated memory, pointed by 'head' */ head=NULL; if (flagRecalc) { - /* use directory for recalculated trigger */ - sprintf( filename, "../Trigger/%s/%s/%s/%s", run, getIFOname(lifo), dagName[dag], - inspiralList[lifo][insp].filename); + /* use directory for recalculated trigger */ + sprintf( filename, "../Trigger/%s/%s/%s/%s", run, getIFOname(lifo), dagName[dag], + inspiralList[lifo][insp].filename); } else{ - /* use directory for online created triggers */ - sprintf( filename, " %s%s/%s", - dirInspiral, getIFOname(lifo), inspiralList[lifo][insp].filename); + /* use directory for online created triggers */ + sprintf( filename, " %s%s/%s", + dirInspiral, getIFOname(lifo), inspiralList[lifo][insp].filename); } if (flagVerbose) { - sprintf(comment, "Trying opening file %s, lifo: %d",filename, lifo); - printOut(7, comment); + sprintf(comment, "Trying opening file %s, lifo: %d",filename, lifo); + printOut(7, comment); } numTrig=LALSnglInspiralTableFromLIGOLw(&head, filename, 1,100000); /* read search summary table from same file - and store values into inspiral-list */ + and store values into inspiral-list */ summary=NULL; numSum=SummValueTableFromLIGOLw(&summary, filename); inspiralList[lifo][insp].startTime=summary->start_time; @@ -837,69 +828,69 @@ int createInspiralTable( int lifo, int dag ) /* apply SNR cut */ if (numTrig>0) { - - /* some basic pointer settings */ - numberDiscard=0; - mainPointer=head; - prevElement=NULL; - while ( mainPointer ) { - - /* check for SNR cut */ - if (mainPointer->snr < snrCut) { - /* discard one element */ - if (prevElement) { - prevElement->next=mainPointer->next; - } else { - head=head->next; /* the head element is changing */ - } - element=mainPointer; /* store in dummy struct*/ - mainPointer=mainPointer->next; /* go one up */ - LALFree( element ); /* free dummy here */ - numberDiscard++; - - } else { - /* do not discard */ - mainPointer=mainPointer->next; /* go one up */ - if (prevElement) { - prevElement=prevElement->next; /* go one up */ - } else { - prevElement=head; /* or specify */ - } - - } - } + + /* some basic pointer settings */ + numberDiscard=0; + mainPointer=head; + prevElement=NULL; + while ( mainPointer ) { + + /* check for SNR cut */ + if (mainPointer->snr < snrCut) { + /* discard one element */ + if (prevElement) { + prevElement->next=mainPointer->next; + } else { + head=head->next; /* the head element is changing */ + } + element=mainPointer; /* store in dummy struct*/ + mainPointer=mainPointer->next; /* go one up */ + LALFree( element ); /* free dummy here */ + numberDiscard++; + + } else { + /* do not discard */ + mainPointer=mainPointer->next; /* go one up */ + if (prevElement) { + prevElement=prevElement->next; /* go one up */ + } else { + prevElement=head; /* or specify */ + } + + } + } } /* store pointer to data only when there are some data */ if (head) { - if (tail) - tail->next=head; - else - list=head; + if (tail) + tail->next=head; + else + list=head; - /* store last element */ - tail=prevElement; + /* store last element */ + tail=prevElement; - if (!prevElement) { - printf("Hopefully this line will never be printed to screen...."); - exit(2); - } + if (!prevElement) { + printf("Hopefully this line will never be printed to screen...."); + exit(2); + } } /* store pointer to FIRST table only - in list */ if (!flag) { - flag=1; + flag=1; - /* set summ values in table */ - listSumm=summary; - tailSumm=listSumm; + /* set summ values in table */ + listSumm=summary; + tailSumm=listSumm; } else { - /* set summ values in table */ - tailSumm->next=summary; - tailSumm=tailSumm->next; + /* set summ values in table */ + tailSumm->next=summary; + tailSumm=tailSumm->next; } /* setting values in the summ-value table */ @@ -908,9 +899,9 @@ int createInspiralTable( int lifo, int dag ) snprintf( tailSumm->comment, LIGOMETA_SUMMVALUE_COMM_MAX, "%s",inspiralList[lifo][insp].filename ); if (flagVerbose) { - sprintf(comment, "+++ Adding %d-%d triggers from file %s ", - numTrig, numberDiscard,inspiralList[lifo][insp].filename); - printOut( 7, comment); + sprintf(comment, "+++ Adding %d-%d triggers from file %s ", + numTrig, numberDiscard,inspiralList[lifo][insp].filename); + printOut( 7, comment); } } } @@ -946,9 +937,9 @@ int writeXML( int nifo, int cgnIndex, int dag ) /* allocate memory for output stream and open file */ memset( &xmlStream, 0, sizeof(LIGOLwXMLStream) ); LALOpenLIGOLwXMLFile( &status, &xmlStream, filenameOut ); - + /* write process table */ - LALGPSTimeNow ( &status, &(proctable.processTable->end_time), &accuracy ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ); LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, process_table ); LALEndLIGOLwXMLTable ( &status, &xmlStream ); @@ -972,7 +963,7 @@ int writeXML( int nifo, int cgnIndex, int dag ) LALBeginLIGOLwXMLTable( &status, &xmlStream, ext_triggers_table ); LALWriteLIGOLwXMLTable( &status, &xmlStream, outputTable, ext_triggers_table ); - LALEndLIGOLwXMLTable( &status, &xmlStream ); + LALEndLIGOLwXMLTable( &status, &xmlStream ); /* writing inspiral table to xml file */ outputTable.snglInspiralTable = list; @@ -1043,14 +1034,13 @@ void startAnalysisJob(ExternalList* eList, int nifo) } /* check if enough time to create the frames (40 minutes) */ - LALGPSTimeNow( &status, &gpsnow, LALLEAPSEC_LOOSE ); + XLALGPSTimeNow(&gpsnow); - time ( &rawtime ); gpsnow.gpsSeconds=rawtime-315964787; if ( gpsnow.gpsSeconds - eList->gps < 2400 ) { sprintf(message,"GRB trigger occured only %ld seconds before, analysing event in next round...", - gpsnow.gpsSeconds - eList->gps); + gpsnow.gpsSeconds - eList->gps); printOut(3, message); return; } @@ -1063,11 +1053,11 @@ void startAnalysisJob(ExternalList* eList, int nifo) if (indexPeriod==1) { /* user EVERY available data */ sprintf(command, "LSCdataFind --server %s --observatory %s --gps-start-time %9ld --gps-end-time %9ld --type RDS_R_L3 2> .notfound.cel | xargs FrFileRanges 2> .notfound.cel | gawk '{s++; print s, $1, $2, $2-$1;}' > segment.txt 2> .notfound.cel ", - serverName, ifoName[nifo], eList->gps-timeWindow, eList->gps+timeWindow ); + serverName, ifoName[nifo], eList->gps-timeWindow, eList->gps+timeWindow ); } else { /* use only Science segments and comparable types */ sprintf(command, "LSCsegFind --server=%s --interferometer %s --type Science --output-format segwizard --gps-start-time %9ld --gps-end-time %9ld > segment.txt 2> .notfound.cel ", - serverName, instrName[nifo], eList->gps-timeWindow, eList->gps+timeWindow ); + serverName, instrName[nifo], eList->gps-timeWindow, eList->gps+timeWindow ); } /*sprintf(command, "LSCdataFind --server %s --observatory %s --gps-start-time %9ld --gps-end-time %9ld --type RDS_R_L3 | xargs FrFileRanges | gawk '{s++; print s, $1, $2, $2-$1;}' > segment.txt 2> .notfound.cel ", serverName, instrName[nifo], eList->gps-timeWindow, eList->gps+timeWindow );*/ @@ -1087,9 +1077,9 @@ void startAnalysisJob(ExternalList* eList, int nifo) /* get sum of times and maximum segment (has to be > 2048 seconds) */ if (!feof(fileSegment)) { if (d>minSegmentLength+2*pad_data) { - if (d>maxSegment) maxSegment=d; - if (minSegment<0 || d<minSegment) minSegment=d; - sumTime=sumTime+d; + if (d>maxSegment) maxSegment=d; + if (minSegment<0 || d<minSegment) minSegment=d; + sumTime=sumTime+d; } } @@ -1110,7 +1100,7 @@ void startAnalysisJob(ExternalList* eList, int nifo) if (numberOfSegments>15) numberOfSegments=15; sprintf(message, "Longest segment found is %.0f s, using %d number of segments in lalapps_inspiral.", - maxSegment, numberOfSegments); + maxSegment, numberOfSegments); printOut( 3, message); /* EXTRA FOR BEGINNING OF S5 */ @@ -1125,7 +1115,7 @@ void startAnalysisJob(ExternalList* eList, int nifo) /* create name of new directory for job execution */ sprintf(dirJob,"../OnlineAnalysis/Jobs/%s/%s%s-%9ld%s", dirJobs, instrName[nifo], - namePeriod[indexPeriod], eList->gps, dagName[dag]); + namePeriod[indexPeriod], eList->gps, dagName[dag]); /* create directory */ sprintf(command,"mkdir -p %s",dirJob); @@ -1160,14 +1150,14 @@ void startAnalysisJob(ExternalList* eList, int nifo) /* create ini file for job execution */ sprintf(command,"sed -f sed.file ../OnlineAnalysis/ProgInspiral/online%s.ini > %s/online.ini", - dagName[dag], dirJob); + dagName[dag], dirJob); if (flagVerbose) printOut(7, command); system(command); /* create the DAG */ sprintf(command,"cd %s; ./lalapps_inspiral_online_pipe --config-file online.ini --log-path /usr1/dietz", - dirJob ); + dirJob ); if (flagVerbose) printOut(7, command); system(command); @@ -1193,12 +1183,12 @@ void startAnalysisJob(ExternalList* eList, int nifo) /* output */ if (d==0) { sprintf(message, "No segments found for times %ld to %ld on %s", - eList->gps-timeWindow, eList->gps+timeWindow, instrName[nifo] ); + eList->gps-timeWindow, eList->gps+timeWindow, instrName[nifo] ); printOut(3, message); } else { sprintf(message, - "Max. segment for times %ld to %ld on %s is only %.0f seconds long. No data analyzed.", - eList->gps-timeWindow, eList->gps+timeWindow, instrName[nifo], maxSegment ); + "Max. segment for times %ld to %ld on %s is only %.0f seconds long. No data analyzed.", + eList->gps-timeWindow, eList->gps+timeWindow, instrName[nifo], maxSegment ); printOut(3, message); } } @@ -1312,9 +1302,9 @@ char* getCurrentTime( void ) timeinfo = localtime ( &rawtime ); sprintf(currentTime, "%d-%02d-%02d %d:%02d:%02d", timeinfo->tm_year+1900, timeinfo->tm_mon+1, timeinfo->tm_mday, - timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); + timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); - return currentTime; + return currentTime; } /******************************* @@ -1365,7 +1355,7 @@ int ce_startup( void ) /* create startup message */ sprintf(message, "-------------------------------------------------\n--- Starting coinext at %s", - getCurrentTime()); + getCurrentTime()); printOut(6, message); startPeriod=(long*)LALCalloc( numberPeriods, sizeof(long) ); @@ -1401,9 +1391,9 @@ int ce_shutdown( void ) /* creating shutdown message */ sprintf(message, "---" - "\n--- Stopping coinext at %s " - "\n-------------------------------------------------", - getCurrentTime() ); + "\n--- Stopping coinext at %s " + "\n-------------------------------------------------", + getCurrentTime() ); printOut(6, message); /* closing log file */ @@ -1525,25 +1515,25 @@ print_usage: static void print_usage(char *program) { fprintf(stderr, - "Usage: %s [options] \n" \ - "The following options are recognized. Options are required unless \n"\ - "surrounded in []\n", program); + "Usage: %s [options] \n" \ + "The following options are recognized. Options are required unless \n"\ + "surrounded in []\n", program); fprintf(stderr, - " [--help] display this message\n"\ - " [--version] print version information and exit\n"\ - " [--dirInspiral] specifies the directory where to find the inspiral XML\n"\ - " Either this option must be specified or --recalc\n"\ - " [--dirData] Specifies the directoet where to put the data\n"\ - " [--refresh] Specifies the refresh cycle in minutes. Default: 30 minutes\n"); + " [--help] display this message\n"\ + " [--version] print version information and exit\n"\ + " [--dirInspiral] specifies the directory where to find the inspiral XML\n"\ + " Either this option must be specified or --recalc\n"\ + " [--dirData] Specifies the directoet where to put the data\n"\ + " [--refresh] Specifies the refresh cycle in minutes. Default: 30 minutes\n"); fprintf(stderr, - " [--timeWindow] Specifies the time window to analyze around a external trigger\n"\ - " [--snrCut] Specifies a general SNR cut\n"\ - " [--restart] restarts the program, delets any intermediate data\n"\ - " [--recalc] starts a seperate DAG for each found external trigger\n"); + " [--timeWindow] Specifies the time window to analyze around a external trigger\n"\ + " [--snrCut] Specifies a general SNR cut\n"\ + " [--restart] restarts the program, delets any intermediate data\n"\ + " [--recalc] starts a seperate DAG for each found external trigger\n"); fprintf(stderr, " [--ifo] need to be specified if running on LHO. Choices: (LLO, LHO)\n"\ - " [--trigger] Besides downloading the latest trigger file, this option can be used\n"\ - " to choose a specific trigger file\n\n"); + " [--trigger] Besides downloading the latest trigger file, this option can be used\n"\ + " to choose a specific trigger file\n\n"); } @@ -1595,9 +1585,9 @@ int arg_parse_check( int argc, char *argv[]) size_t optarg_len; c = getopt_long_only( argc, argv, - "A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:S:T:U:V:W:X:Y:Z:" - "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z:", - long_options, &option_index ); + "A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:S:T:U:V:W:X:Y:Z:" + "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z:", + long_options, &option_index ); /* detect the end of the options */ if ( c == - 1 ) { @@ -1608,11 +1598,11 @@ int arg_parse_check( int argc, char *argv[]) case 0: /* if this option set a flag, do nothing else now */ if ( long_options[option_index].flag != 0 ) { - break; + break; } else { - fprintf( stderr, "error parsing option %s with argument %s\n", - long_options[option_index].name, optarg ); - exit( 1 ); + fprintf( stderr, "error parsing option %s with argument %s\n", + long_options[option_index].name, optarg ); + exit( 1 ); } break; @@ -1621,14 +1611,14 @@ int arg_parse_check( int argc, char *argv[]) /* get name for inspiral data path */ optarg_len = strlen( optarg ) + 1; memcpy( dirInspiral, optarg, optarg_len ); - ADD_PROCESS_PARAM( "string" , "%s", optarg); + ADD_PROCESS_PARAM( "string" , "%s", optarg); break; case 'A': { /* get name for directory to put the data in */ optarg_len = strlen( optarg ) + 1; - memcpy( dirData, optarg, optarg_len ); + memcpy( dirData, optarg, optarg_len ); ADD_PROCESS_PARAM( "string" , "%s", optarg); flagDirData=1; break; @@ -1637,10 +1627,10 @@ int arg_parse_check( int argc, char *argv[]) case 'b': { waitingTime = atol( optarg ); if ( waitingTime < 0 ) { - fprintf( stderr, "invalid argument to --%s:\n" - "waiting time can'y be negative\n", - long_options[option_index].name ); - exit( 1 ); + fprintf( stderr, "invalid argument to --%s:\n" + "waiting time can'y be negative\n", + long_options[option_index].name ); + exit( 1 ); } ADD_PROCESS_PARAM( "int" , "%ld", waitingTime); } @@ -1649,12 +1639,12 @@ int arg_parse_check( int argc, char *argv[]) case 'B': { timeWindow = atoi( optarg ); if ( timeWindow < 0 ) { - fprintf( stderr, "invalid argument to --%s:\n" - "window time must be positive number\n", - long_options[option_index].name ); - exit( 1 ); + fprintf( stderr, "invalid argument to --%s:\n" + "window time must be positive number\n", + long_options[option_index].name ); + exit( 1 ); } - ADD_PROCESS_PARAM( "float" , "%s", optarg); + ADD_PROCESS_PARAM( "float" , "%s", optarg); } break; @@ -1662,36 +1652,36 @@ int arg_parse_check( int argc, char *argv[]) case 'd': { snrCut = atof( optarg ); if ( snrCut < 0 ) { - fprintf( stderr, "invalid argument to --%s:\n" - "snrCut must be a positive number\n", - long_options[option_index].name ); - exit( 1 ); + fprintf( stderr, "invalid argument to --%s:\n" + "snrCut must be a positive number\n", + long_options[option_index].name ); + exit( 1 ); } - ADD_PROCESS_PARAM( "float" , "%s", snrCut); + ADD_PROCESS_PARAM( "float" , "%s", snrCut); } break; case 'i': { /* read IFO site */ optarg_len = strlen( optarg ) + 1; - memcpy( ifo, optarg, optarg_len ); - ADD_PROCESS_PARAM( "string" , "%s", optarg); + memcpy( ifo, optarg, optarg_len ); + ADD_PROCESS_PARAM( "string" , "%s", optarg); break; } case 't': { /* read triger file */ optarg_len = strlen( optarg ) + 1; - memcpy( nameInputList, optarg, optarg_len ); + memcpy( nameInputList, optarg, optarg_len ); ADD_PROCESS_PARAM( "string" , "%s", optarg); - flagTriggerFile=1; + flagTriggerFile=1; break; } case 'c': { /* read calibration vesrion to use */ optarg_len = strlen( optarg ) + 1; - memcpy( calibrationVersion, optarg, optarg_len ); + memcpy( calibrationVersion, optarg, optarg_len ); ADD_PROCESS_PARAM( "string" , "%s", optarg); break; } @@ -1699,7 +1689,7 @@ int arg_parse_check( int argc, char *argv[]) case 'r': { /* read run file */ optarg_len = strlen( optarg ) + 1; - memcpy( run, optarg, optarg_len ); + memcpy( run, optarg, optarg_len ); ADD_PROCESS_PARAM( "string" , "%s", optarg); flagRun=1; break; @@ -1715,9 +1705,9 @@ int arg_parse_check( int argc, char *argv[]) case 'V': { /* print version information and exit */ fprintf( stdout, "COINcidences with EXTernal triggers\n" - "Alexander Dietz\n" - "CVS Version: " CVS_ID_STRING "\n" - "CVS Tag: " CVS_NAME_STRING "\n" ); + "Alexander Dietz\n" + "CVS Version: " CVS_ID_STRING "\n" + "CVS Tag: " CVS_NAME_STRING "\n" ); fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -1747,9 +1737,9 @@ int arg_parse_check( int argc, char *argv[]) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--restart" ); + "--restart" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_TYPE_MAX, " " ); } @@ -1759,7 +1749,7 @@ int arg_parse_check( int argc, char *argv[]) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "--test" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_TYPE_MAX, " " ); @@ -1770,9 +1760,9 @@ int arg_parse_check( int argc, char *argv[]) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--recalc" ); + "--recalc" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_TYPE_MAX, " " ); } @@ -1782,9 +1772,9 @@ int arg_parse_check( int argc, char *argv[]) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--verbose" ); + "--verbose" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_TYPE_MAX, " " ); } diff --git a/lalapps/src/inspiral/coinj.c b/lalapps/src/inspiral/coinj.c index 2d5a8875e07c8dedbffc9981a3b4412be6a733cb..2af0d0cc96291f767566e78e50d7d39350a796ba 100644 --- a/lalapps/src/inspiral/coinj.c +++ b/lalapps/src/inspiral/coinj.c @@ -48,7 +48,7 @@ --input <injection.xml> Specify input SimInspiralTable xml file\n\ --response-type TYPE TYPE of injection, [ strain | etmx | etmy ]\n\ --frames Create h(t) frame files\n\n\ -[--maxSNR snrhigh --minSNR snrlow Adjust injections to have combined SNR between snrlow and snrhigh in the H1H2L1V1 network]\n\ +[--maxSNR snrhigh --minSNR snrlow Adjust injections to have combined SNR between snrlow and snrhigh in the H1H2L1V1 network]\n\ [--SNR snr adjust distance to get precisely this snr]\n\ [--GPSstart A --GPSend B Only generate waveforms for injection between GPS seconds A and B (int)]\n\ lalapps_coinj: create coherent injection files for LIGO and VIRGO\n" @@ -61,103 +61,103 @@ extern int lalDebugLevel; typedef enum { - noResponse, - unityResponse, - design, - actuationX, - actuationY + noResponse, + unityResponse, + design, + actuationX, + actuationY } ResponseType; typedef struct actuationparameters { - REAL4 ETMXcal; - REAL4 ETMYcal; - REAL4 pendFX; - REAL4 pendFY; - REAL4 pendQX; - REAL4 pendQY; - REAL4 length; + REAL4 ETMXcal; + REAL4 ETMYcal; + REAL4 pendFX; + REAL4 pendFY; + REAL4 pendQX; + REAL4 pendQY; + REAL4 length; } ActuationParametersType; typedef void (NoiseFunc)(LALStatus *status,REAL8 *psd,REAL8 f); int main(int argc, char *argv[]) { -LALStatus status=blank_status; -CHAR inputfile[FILENAME_MAX]; -CHAR adjustedfile[FILENAME_MAX+10]; -CHAR injtype[30]; -CHAR det_name[10]; -LIGOTimeGPS inj_epoch; -REAL8 deltaT= 1.0/16384.0; -REAL8 injLength=100.0; /* Ten seconds at end */ -REAL8 LeadupTime=95.0; -REAL8 dynRange=1.0/3.0e-23; - -UINT4 Nsamples,det_idx,i,inj_num=0; -ActuationParametersType actuationParams[LAL_NUM_IFO]; -ActuationParametersType actData; -ResponseType injectionResponse=noResponse; -FILE * outfile; -LIGOLwXMLStream *xmlfp=NULL; -CHAR outfilename[FILENAME_MAX]; - -const LALUnit strainPerCount={0,{0,0,0,0,0,1,-1},{0,0,0,0,0,0,0}}; -const LALUnit countPerStrain={0,{0,0,0,0,0,-1,1},{0,0,0,0,0,0,0}}; -NoiseFunc *PSD; -REAL8 PSDscale=1.0; -int c; -int repeatLoop=0; -int hitTarget=0; -SimInspiralTable *injTable=NULL; -SimInspiralTable this_injection; -SimInspiralTable *headTable=NULL; -MetadataTable MDT; -REAL4TimeSeries *TimeSeries; - -REAL4TimeSeries *actuationTimeSeries; -COMPLEX8FrequencySeries *resp; -COMPLEX8FrequencySeries *actuationResp; -COMPLEX8FrequencySeries *transfer; -COMPLEX8Vector *unity; - -FrOutPar VirgoOutPars; -CHAR VirgoParsSource[100]; -CHAR VirgoParsInfo[100]; -REAL8 NetworkSNR=0.0; -INT4 makeFrames=0; -INT4 outputRaw=0; -COMPLEX8FrequencySeries *fftData; -REAL8 mySNRsq,mySNR; -REAL4FFTPlan *fwd_plan; -REAL8 minSNR=0.0,maxSNR=0.0; - REAL8 maxRatio=1.0,minRatio=1.0; -REAL8 targetSNR=0.0; -INT4 GPSstart=0,GPSend=2147483647; -int SNROK=1; -int rewriteXML=0; - -/*vrbflg=6; -lalDebugLevel=6; */ - -struct option long_options[]= - { - {"help", no_argument, 0, 'h'}, - {"input",required_argument,0, 'i'}, - {"response-type",required_argument,0,'r'}, - {"frames",no_argument,&makeFrames,'F'}, - {"rawstrain",no_argument,&outputRaw,'s'}, - {"verbose",no_argument,&vrbflg,1}, - {"minSNR",required_argument,0,2}, - {"maxSNR",required_argument,0,3}, - {"SNR",required_argument,0,6}, - {"GPSstart",required_argument,0,4}, - {"GPSend",required_argument,0,5}, - {0,0,0,0} - }; + LALStatus status=blank_status; + CHAR inputfile[FILENAME_MAX]; + CHAR adjustedfile[FILENAME_MAX+10]; + CHAR injtype[30]; + CHAR det_name[10]; + LIGOTimeGPS inj_epoch; + REAL8 deltaT= 1.0/16384.0; + REAL8 injLength=100.0; /* Ten seconds at end */ + REAL8 LeadupTime=95.0; + REAL8 dynRange=1.0/3.0e-23; + + UINT4 Nsamples,det_idx,i,inj_num=0; + ActuationParametersType actuationParams[LAL_NUM_IFO]; + ActuationParametersType actData; + ResponseType injectionResponse=noResponse; + FILE * outfile; + LIGOLwXMLStream *xmlfp=NULL; + CHAR outfilename[FILENAME_MAX]; + + const LALUnit strainPerCount={0,{0,0,0,0,0,1,-1},{0,0,0,0,0,0,0}}; + const LALUnit countPerStrain={0,{0,0,0,0,0,-1,1},{0,0,0,0,0,0,0}}; + NoiseFunc *PSD; + REAL8 PSDscale=1.0; + int c; + int repeatLoop=0; + int hitTarget=0; + SimInspiralTable *injTable=NULL; + SimInspiralTable this_injection; + SimInspiralTable *headTable=NULL; + MetadataTable MDT; + REAL4TimeSeries *TimeSeries; + + REAL4TimeSeries *actuationTimeSeries; + COMPLEX8FrequencySeries *resp; + COMPLEX8FrequencySeries *actuationResp; + COMPLEX8FrequencySeries *transfer; + COMPLEX8Vector *unity; + + FrOutPar VirgoOutPars; + CHAR VirgoParsSource[100]; + CHAR VirgoParsInfo[100]; + REAL8 NetworkSNR=0.0; + INT4 makeFrames=0; + INT4 outputRaw=0; + COMPLEX8FrequencySeries *fftData; + REAL8 mySNRsq,mySNR; + REAL4FFTPlan *fwd_plan; + REAL8 minSNR=0.0,maxSNR=0.0; + REAL8 maxRatio=1.0,minRatio=1.0; + REAL8 targetSNR=0.0; + INT4 GPSstart=0,GPSend=2147483647; + int SNROK=1; + int rewriteXML=0; + + /*vrbflg=6; + lalDebugLevel=6; */ + + struct option long_options[]= + { + {"help", no_argument, 0, 'h'}, + {"input",required_argument,0, 'i'}, + {"response-type",required_argument,0,'r'}, + {"frames",no_argument,&makeFrames,'F'}, + {"rawstrain",no_argument,&outputRaw,'s'}, + {"verbose",no_argument,&vrbflg,1}, + {"minSNR",required_argument,0,2}, + {"maxSNR",required_argument,0,3}, + {"SNR",required_argument,0,6}, + {"GPSstart",required_argument,0,4}, + {"GPSend",required_argument,0,5}, + {0,0,0,0} + }; /*taken from Calibration CVS file: - * calibration/frequencydomain/runs/S5/H1/model/V3/H1DARMparams_849677446.m */ + * calibration/frequencydomain/runs/S5/H1/model/V3/H1DARMparams_849677446.m */ actuationParams[LAL_IFO_H1].ETMXcal = -0.795e-9; actuationParams[LAL_IFO_H1].pendFX = 0.767; actuationParams[LAL_IFO_H1].pendQX = 10.0; @@ -190,241 +190,266 @@ struct option long_options[]= /*******************************************************************************/ /* Process input arguments */ -while(1) -{ - int option_idx=0; - c=getopt_long_only(argc,argv,"hFi:",long_options,&option_idx); - if(c==-1) break; - switch(c) - { - case 'h': - fprintf(stderr,USAGE); - exit(0); - break; - case 'i': - strncpy(inputfile,optarg,FILENAME_MAX-1); - break; - case 'r': - if(!strcmp("strain",optarg)) injectionResponse = unityResponse; - else if(!strcmp("etmx",optarg)) injectionResponse = actuationX; - else if(!strcmp("etmy",optarg)) injectionResponse = actuationY; - else {fprintf(stderr,"Invalid argument to response-type: %s\nResponse type must be strain, etmy or etmx\n",\ - optarg); exit(1);} - break; - case 2: - minSNR=atof(optarg); - fprintf(stderr,"Using minimum SNR of %f\n",minSNR); - break; - case 3: - maxSNR=atof(optarg); - fprintf(stderr,"Using maximum SNR of %f\n",maxSNR); - break; - case 4: - GPSstart=atoi(optarg); - break; - case 5: - GPSend=atoi(optarg); - break; - case 6: - targetSNR=atof(optarg); - fprintf(stderr,"Target SNR = %lf\n",targetSNR); - break; - } -} - -if(minSNR!=0 && maxSNR!=0 && (maxSNR<minSNR)){ - fprintf(stderr,"Error: minSNR must be less than maxSNR\n"); - exit(1); - if(targetSNR!=0.0 && (targetSNR<minSNR || targetSNR>maxSNR)){ - fprintf(stderr,"Target SNR %lf is not in range %lf to %lf, ignoring min and max\n",targetSNR,minSNR,maxSNR); - } -} - -memset(&status,0,sizeof(status)); - -/* Read in the input XML */ -SimInspiralTableFromLIGOLw(&injTable,inputfile,0,0); -headTable=injTable; -Nsamples = (UINT4)injLength/deltaT; - -do{ -memcpy(&this_injection,injTable,sizeof(SimInspiralTable)); -this_injection.next=NULL; -NetworkSNR=0.0; -/* Set epoch */ -memcpy(&inj_epoch,&(this_injection.geocent_end_time),sizeof(LIGOTimeGPS)); -inj_epoch = this_injection.geocent_end_time; -XLALGPSAdd(&inj_epoch, -LeadupTime); -inj_epoch.gpsNanoSeconds=0; -SNROK=0; /* Reset this to 0 = OK */ -minRatio=2.0; -maxRatio=0.0; -repeatLoop=0; -/* Loop over detectors */ -for(det_idx=0;det_idx<LAL_NUM_IFO;det_idx++){ - /* Only generate within chosen bounds, if specified */ - if((this_injection.geocent_end_time.gpsSeconds-(int)LeadupTime )<GPSstart || (this_injection.geocent_end_time.gpsSeconds-(int)LeadupTime)>GPSend) continue; - - if(det_idx==LAL_IFO_T1||det_idx==LAL_IFO_G1||det_idx==LAL_IFO_H2) continue; /* Don't generate for GEO or TAMA */ - - switch(det_idx) - { - case LAL_IFO_H1: sprintf(det_name,"H1"); PSD=&LALLIGOIPsd; PSDscale=9E-46; break; - case LAL_IFO_H2: sprintf(det_name,"H2"); PSD=&LALLIGOIPsd; PSDscale=9E-46; break; - case LAL_IFO_L1: sprintf(det_name,"L1"); PSD=&LALLIGOIPsd; PSDscale=9E-46; break; - case LAL_IFO_V1: sprintf(det_name,"V1"); PSD=&LALVIRGOPsd; PSDscale=1.0; break; - case LAL_IFO_G1: sprintf(det_name,"G1"); PSD=&LALGEOPsd; PSDscale=1E-46; break; - case LAL_IFO_T1: sprintf(det_name,"T1"); PSD=&LALTAMAPsd; PSDscale=75E-46; break; - } - - TimeSeries=XLALCreateREAL4TimeSeries(det_name,&inj_epoch,0.0,deltaT,&lalADCCountUnit,(size_t)Nsamples); - for(i=0;i<Nsamples;i++) TimeSeries->data->data[i]=0.0; - resp = XLALCreateCOMPLEX8FrequencySeries("response",&inj_epoch,0.0,1.0/injLength,&strainPerCount,(size_t)Nsamples/2+1); - for(i=0;i<resp->data->length;i++) {resp->data->data[i].re=(REAL4)1.0/dynRange; resp->data->data[i].im=0.0;} - - /* Create h(t) time series for this detector */ - LAL_CALL( LALFindChirpInjectSignals(&status,TimeSeries,&this_injection,resp) , &status); - - XLALDestroyCOMPLEX8FrequencySeries(resp); - - if(det_idx==LAL_IFO_V1 && injectionResponse!=unityResponse){ - actuationTimeSeries=NULL; - goto calcSNRandwriteFrames; - } - - /* -=-=-=-=-=-=- Prepare actuations -=-=-=-=-=-=- */ - - if(injectionResponse==actuationX || injectionResponse==actuationY) actData=actuationParams[det_idx]; - actuationResp = XLALCreateCOMPLEX8FrequencySeries("actuationResponse",&inj_epoch,0.0,1.0/(2.0*injLength),&strainPerCount,(size_t)Nsamples/2+1); - /* Create actuation response */ - switch(injectionResponse){ - case unityResponse: - sprintf(injtype,"STRAIN"); - for(i=0;i<actuationResp->data->length;i++){actuationResp->data->data[i].re=1.0; actuationResp->data->data[i].im=0.0;} - break; - case actuationX: - sprintf(injtype,"ETMX"); - actuationResp=generateActuation(actuationResp,actData.ETMXcal/actData.length,actData.pendFX,actData.pendQX); - break; - case actuationY: - sprintf(injtype,"ETMY"); - actuationResp=generateActuation(actuationResp,actData.ETMYcal/actData.length,actData.pendFY,actData.pendQY); - break; - default: - fprintf(stderr,"Must specify response function: strain, etmy or etmx\n"); exit(1); - break; - } - - - if(injectionResponse!=unityResponse) { - actuationTimeSeries=XLALCreateREAL4TimeSeries(det_name,&inj_epoch,0.0,deltaT,&lalADCCountUnit,(size_t)Nsamples); - unity = XLALCreateCOMPLEX8Vector(actuationResp->data->length); - transfer = XLALCreateCOMPLEX8FrequencySeries("transfer",&inj_epoch,0.0,1.0/(2.0*injLength),&countPerStrain,(size_t)Nsamples/2+1); - for(i=0;i<unity->length;i++) {unity->data[i].re=1.0; unity->data[i].im=0.0;} - XLALCCVectorDivide(transfer->data,unity,actuationResp->data); - for(i=0;i<Nsamples;i++) actuationTimeSeries->data->data[i]=TimeSeries->data->data[i]; - actuationTimeSeries = XLALRespFilt(actuationTimeSeries,transfer); - XLALDestroyCOMPLEX8FrequencySeries(transfer); - XLALDestroyCOMPLEX8Vector(unity); - for(i=0;i<actuationTimeSeries->data->length;i++) actuationTimeSeries->data->data[i]/=dynRange; - } - else actuationTimeSeries=TimeSeries; - - XLALDestroyCOMPLEX8FrequencySeries(actuationResp); - - /* Output the actuation time series */ - sprintf(outfilename,"HWINJ_%i_%s_%i_%s.out",inj_num,injtype,inj_epoch.gpsSeconds,det_name); - outfile=fopen(outfilename,"w"); - fprintf(stdout,"Injected signal %i for %s into file %s\n",inj_num,det_name,outfilename); - for(i=0;i<actuationTimeSeries->data->length;i++) fprintf(outfile,"%10.10e\n",actuationTimeSeries->data->data[i]); - fclose(outfile); - -calcSNRandwriteFrames: - - /* Calculate SNR for this injection */ - fwd_plan = XLALCreateForwardREAL4FFTPlan( TimeSeries->data->length, 0 ); - fftData = XLALCreateCOMPLEX8FrequencySeries(TimeSeries->name,&(TimeSeries->epoch),0,1.0/TimeSeries->deltaT,&lalDimensionlessUnit,TimeSeries->data->length/2 +1); - XLALREAL4TimeFreqFFT(fftData,TimeSeries,fwd_plan); - XLALDestroyREAL4FFTPlan(fwd_plan); - - mySNRsq = 0.0; - mySNR=0.0; - for(i=1;i<fftData->data->length;i++){ - REAL8 freq; - REAL8 sim_psd_value=0; - freq = fftData->deltaF * i; - PSD( &status, &sim_psd_value, freq ); - mySNRsq += fftData->data->data[i].re * fftData->data->data[i].re / - (sim_psd_value*PSDscale); - mySNRsq += fftData->data->data[i].im * fftData->data->data[i].im / - (sim_psd_value*PSDscale); - } - mySNRsq *= 4.0*fftData->deltaF; - XLALDestroyCOMPLEX8FrequencySeries( fftData ); - if(det_idx==LAL_IFO_H2) mySNRsq/=4.0; - mySNR = sqrt(mySNRsq)/dynRange; - fprintf(stdout,"SNR in design %s of injection %i = %lf\n",det_name,inj_num,mySNR); - - for(i=0;i<TimeSeries->data->length;i++) { - TimeSeries->data->data[i]=TimeSeries->data->data[i]/dynRange +0.0; - } - NetworkSNR+=mySNR*mySNR; - - if(makeFrames){ /* Also output frames for Virgo */ - sprintf(VirgoParsSource,"%s-INSP%i",det_name,inj_num); - VirgoOutPars.source=VirgoParsSource; - sprintf(VirgoParsInfo,"HWINJ-STRAIN"); - VirgoOutPars.description=VirgoParsInfo; - VirgoOutPars.type=ProcDataChannel; - VirgoOutPars.nframes=(UINT4)injLength; - VirgoOutPars.frame=0; - VirgoOutPars.run=2; - fprintf(stdout,"Generating frame file for %s-%s-%i\n",VirgoParsSource,VirgoParsInfo,TimeSeries->epoch.gpsSeconds); - LALFrWriteREAL4TimeSeries(&status,TimeSeries,&VirgoOutPars); - } - - if(TimeSeries==actuationTimeSeries) XLALDestroyREAL4TimeSeries(TimeSeries); - else { - if(injectionResponse) XLALDestroyREAL4TimeSeries(actuationTimeSeries); - XLALDestroyREAL4TimeSeries(TimeSeries); - } + while(1) + { + int option_idx=0; + c=getopt_long_only(argc,argv,"hFi:",long_options,&option_idx); + if(c==-1) break; + switch(c) + { + case 'h': + fprintf(stderr,USAGE); + exit(0); + break; + case 'i': + strncpy(inputfile,optarg,FILENAME_MAX-1); + break; + case 'r': + if(!strcmp("strain",optarg)) injectionResponse = unityResponse; + else if(!strcmp("etmx",optarg)) injectionResponse = actuationX; + else if(!strcmp("etmy",optarg)) injectionResponse = actuationY; + else {fprintf(stderr,"Invalid argument to response-type: %s\nResponse type must be strain, etmy or etmx\n", \ + optarg); exit(1);} + break; + case 2: + minSNR=atof(optarg); + fprintf(stderr,"Using minimum SNR of %f\n",minSNR); + break; + case 3: + maxSNR=atof(optarg); + fprintf(stderr,"Using maximum SNR of %f\n",maxSNR); + break; + case 4: + GPSstart=atoi(optarg); + break; + case 5: + GPSend=atoi(optarg); + break; + case 6: + targetSNR=atof(optarg); + fprintf(stderr,"Target SNR = %lf\n",targetSNR); + break; + } + } + + if(minSNR!=0 && maxSNR!=0 && (maxSNR<minSNR)){ + fprintf(stderr,"Error: minSNR must be less than maxSNR\n"); + exit(1); + if(targetSNR!=0.0 && (targetSNR<minSNR || targetSNR>maxSNR)){ + fprintf(stderr,"Target SNR %lf is not in range %lf to %lf, ignoring min and max\n",targetSNR,minSNR,maxSNR); + } + } + + memset(&status,0,sizeof(status)); + + /* Read in the input XML */ + SimInspiralTableFromLIGOLw(&injTable,inputfile,0,0); + headTable=injTable; + Nsamples = (UINT4)injLength/deltaT; + + do{ + memcpy(&this_injection,injTable,sizeof(SimInspiralTable)); + this_injection.next=NULL; + NetworkSNR=0.0; + /* Set epoch */ + memcpy(&inj_epoch,&(this_injection.geocent_end_time),sizeof(LIGOTimeGPS)); + inj_epoch = this_injection.geocent_end_time; + XLALGPSAdd(&inj_epoch, -LeadupTime); + inj_epoch.gpsNanoSeconds=0; + SNROK=0; /* Reset this to 0 = OK */ + minRatio=2.0; + maxRatio=0.0; + repeatLoop=0; + /* Loop over detectors */ + for(det_idx=0;det_idx<LAL_NUM_IFO;det_idx++){ + /* Only generate within chosen bounds, if specified */ + if((this_injection.geocent_end_time.gpsSeconds-(int)LeadupTime )<GPSstart || (this_injection.geocent_end_time.gpsSeconds-(int)LeadupTime)>GPSend) continue; + + if(det_idx==LAL_IFO_T1||det_idx==LAL_IFO_G1||det_idx==LAL_IFO_H2) continue; /* Don't generate for GEO or TAMA */ + + switch(det_idx) + { + case LAL_IFO_H1: sprintf(det_name,"H1"); PSD=&LALLIGOIPsd; PSDscale=9E-46; break; + case LAL_IFO_H2: sprintf(det_name,"H2"); PSD=&LALLIGOIPsd; PSDscale=9E-46; break; + case LAL_IFO_L1: sprintf(det_name,"L1"); PSD=&LALLIGOIPsd; PSDscale=9E-46; break; + case LAL_IFO_V1: sprintf(det_name,"V1"); PSD=&LALVIRGOPsd; PSDscale=1.0; break; + case LAL_IFO_G1: sprintf(det_name,"G1"); PSD=&LALGEOPsd; PSDscale=1E-46; break; + case LAL_IFO_T1: sprintf(det_name,"T1"); PSD=&LALTAMAPsd; PSDscale=75E-46; break; + } + + TimeSeries=XLALCreateREAL4TimeSeries(det_name,&inj_epoch,0.0,deltaT,&lalADCCountUnit,(size_t)Nsamples); + for(i=0;i<Nsamples;i++) TimeSeries->data->data[i]=0.0; + resp = XLALCreateCOMPLEX8FrequencySeries("response",&inj_epoch,0.0,1.0/injLength,&strainPerCount,(size_t)Nsamples/2+1); + for(i=0;i<resp->data->length;i++) {resp->data->data[i].re=(REAL4)1.0/dynRange; resp->data->data[i].im=0.0;} + + /* Create h(t) time series for this detector */ + LAL_CALL( LALFindChirpInjectSignals(&status,TimeSeries,&this_injection,resp) , &status); + + XLALDestroyCOMPLEX8FrequencySeries(resp); + + if(det_idx==LAL_IFO_V1 && injectionResponse!=unityResponse){ + actuationTimeSeries=NULL; + goto calcSNRandwriteFrames; + } + + /* -=-=-=-=-=-=- Prepare actuations -=-=-=-=-=-=- */ + + if(injectionResponse==actuationX || injectionResponse==actuationY) actData=actuationParams[det_idx]; + actuationResp = XLALCreateCOMPLEX8FrequencySeries("actuationResponse",&inj_epoch,0.0,1.0/(2.0*injLength),&strainPerCount,(size_t)Nsamples/2+1); + /* Create actuation response */ + switch(injectionResponse){ + case unityResponse: + sprintf(injtype,"STRAIN"); + for(i=0;i<actuationResp->data->length;i++){actuationResp->data->data[i].re=1.0; actuationResp->data->data[i].im=0.0;} + break; + case actuationX: + sprintf(injtype,"ETMX"); + actuationResp=generateActuation(actuationResp,actData.ETMXcal/actData.length,actData.pendFX,actData.pendQX); + break; + case actuationY: + sprintf(injtype,"ETMY"); + actuationResp=generateActuation(actuationResp,actData.ETMYcal/actData.length,actData.pendFY,actData.pendQY); + break; + default: + fprintf(stderr,"Must specify response function: strain, etmy or etmx\n"); exit(1); + break; + } + + + if(injectionResponse!=unityResponse) { + actuationTimeSeries=XLALCreateREAL4TimeSeries(det_name,&inj_epoch,0.0,deltaT,&lalADCCountUnit,(size_t)Nsamples); + unity = XLALCreateCOMPLEX8Vector(actuationResp->data->length); + transfer = XLALCreateCOMPLEX8FrequencySeries("transfer",&inj_epoch,0.0,1.0/(2.0*injLength),&countPerStrain,(size_t)Nsamples/2+1); + for(i=0;i<unity->length;i++) {unity->data[i].re=1.0; unity->data[i].im=0.0;} + XLALCCVectorDivide(transfer->data,unity,actuationResp->data); + for(i=0;i<Nsamples;i++) actuationTimeSeries->data->data[i]=TimeSeries->data->data[i]; + actuationTimeSeries = XLALRespFilt(actuationTimeSeries,transfer); + XLALDestroyCOMPLEX8FrequencySeries(transfer); + XLALDestroyCOMPLEX8Vector(unity); + for(i=0;i<actuationTimeSeries->data->length;i++) actuationTimeSeries->data->data[i]/=dynRange; + } + else actuationTimeSeries=TimeSeries; + + XLALDestroyCOMPLEX8FrequencySeries(actuationResp); + + /* Output the actuation time series */ + sprintf(outfilename,"HWINJ_%i_%s_%i_%s.out",inj_num,injtype,inj_epoch.gpsSeconds,det_name); + outfile=fopen(outfilename,"w"); + fprintf(stdout,"Injected signal %i for %s into file %s\n",inj_num,det_name,outfilename); + for(i=0;i<actuationTimeSeries->data->length;i++) fprintf(outfile,"%10.10e\n",actuationTimeSeries->data->data[i]); + fclose(outfile); + + calcSNRandwriteFrames: + + /* Calculate SNR for this injection */ + fwd_plan = XLALCreateForwardREAL4FFTPlan( TimeSeries->data->length, 0 ); + fftData = XLALCreateCOMPLEX8FrequencySeries(TimeSeries->name,&(TimeSeries->epoch),0,1.0/TimeSeries->deltaT,&lalDimensionlessUnit,TimeSeries->data->length/2 +1); + XLALREAL4TimeFreqFFT(fftData,TimeSeries,fwd_plan); + XLALDestroyREAL4FFTPlan(fwd_plan); + + mySNRsq = 0.0; + mySNR=0.0; + for(i=1;i<fftData->data->length;i++){ + REAL8 freq; + REAL8 sim_psd_value=0; + freq = fftData->deltaF * i; + PSD( &status, &sim_psd_value, freq ); + mySNRsq += fftData->data->data[i].re * fftData->data->data[i].re / + (sim_psd_value*PSDscale); + mySNRsq += fftData->data->data[i].im * fftData->data->data[i].im / + (sim_psd_value*PSDscale); + } + mySNRsq *= 4.0*fftData->deltaF; + XLALDestroyCOMPLEX8FrequencySeries( fftData ); + if(det_idx==LAL_IFO_H2) mySNRsq/=4.0; + mySNR = sqrt(mySNRsq)/dynRange; + fprintf(stdout,"SNR in design %s of injection %i = %lf\n",det_name,inj_num,mySNR); + + for(i=0;i<TimeSeries->data->length;i++) { + TimeSeries->data->data[i]=TimeSeries->data->data[i]/dynRange +0.0; + } + NetworkSNR+=mySNR*mySNR; + + if(makeFrames){ /* Also output frames for Virgo */ + sprintf(VirgoParsSource,"%s-INSP%i",det_name,inj_num); + VirgoOutPars.source=VirgoParsSource; + sprintf(VirgoParsInfo,"HWINJ-STRAIN"); + VirgoOutPars.description=VirgoParsInfo; + VirgoOutPars.type=ProcDataChannel; + VirgoOutPars.nframes=(UINT4)injLength; + VirgoOutPars.frame=0; + VirgoOutPars.run=2; + fprintf(stdout,"Generating frame file for %s-%s-%i\n",VirgoParsSource,VirgoParsInfo,TimeSeries->epoch.gpsSeconds); + LALFrWriteREAL4TimeSeries(&status,TimeSeries,&VirgoOutPars); + } + + if(TimeSeries==actuationTimeSeries) XLALDestroyREAL4TimeSeries(TimeSeries); + else { + if(injectionResponse) XLALDestroyREAL4TimeSeries(actuationTimeSeries); + XLALDestroyREAL4TimeSeries(TimeSeries); + } } /* End loop over detectors */ -/*fprintf(stdout,"Finished injecting signal %i, network SNR %f\n",inj_num,sqrt(NetworkSNR));*/ - NetworkSNR=sqrt(NetworkSNR); - if(NetworkSNR!=0.0){ /* Check the SNR if we did this injection */ - if(targetSNR!=0.0 && repeatLoop==0 && hitTarget==0) { injTable->distance*=(REAL4)(NetworkSNR/targetSNR); rewriteXML=1; repeatLoop=1; hitTarget=1;} else {repeatLoop=0; hitTarget=0;} - if(targetSNR==0.0 && minSNR>NetworkSNR) {injTable->distance*=(REAL4)(0.99*NetworkSNR/minSNR); rewriteXML=1; repeatLoop=1;} - else { - if(targetSNR==0.0 && maxSNR!=0.0 && maxSNR<NetworkSNR) {injTable->distance*=(1.01*NetworkSNR/maxSNR); injTable->distance+=0.01; rewriteXML=1; repeatLoop=1; fprintf(stderr,"Multiplying by %lf to get from %lf to target\n",1.01*(NetworkSNR/maxSNR),NetworkSNR);} - } - } - if(repeatLoop==1) fprintf(stderr,"Reinjecting with new distance %f for desired SNR\n\n",injTable->distance); - - if(repeatLoop==0){ - fprintf(stderr,"\nNetwork SNR of %i = %lf\n",inj_num,NetworkSNR); - injTable=injTable->next; - inj_num++; - } + /*fprintf(stdout,"Finished injecting signal %i, network SNR %f\n",inj_num,sqrt(NetworkSNR));*/ + NetworkSNR=sqrt(NetworkSNR); + if(NetworkSNR!=0.0){ /* Check the SNR if we did this injection */ + if(targetSNR!=0.0 && repeatLoop==0 && hitTarget==0) { + injTable->distance*=(REAL4)(NetworkSNR/targetSNR); + injTable->eff_dist_h*=(REAL4)(NetworkSNR/targetSNR); + injTable->eff_dist_l*=(REAL4)(NetworkSNR/targetSNR); + injTable->eff_dist_v*=(REAL4)(NetworkSNR/targetSNR); + injTable->eff_dist_g*=(REAL4)(NetworkSNR/targetSNR); + injTable->eff_dist_t*=(REAL4)(NetworkSNR/targetSNR); + rewriteXML=1; repeatLoop=1; hitTarget=1;} + else {repeatLoop=0; hitTarget=0;} + if(targetSNR==0.0 && minSNR>NetworkSNR) { + injTable->distance*=(REAL4)(0.99*NetworkSNR/minSNR); + injTable->eff_dist_h*=(REAL4)(0.99*NetworkSNR/minSNR); + injTable->eff_dist_l*=(REAL4)(0.99*NetworkSNR/minSNR); + injTable->eff_dist_v*=(REAL4)(0.99*NetworkSNR/minSNR); + injTable->eff_dist_t*=(REAL4)(0.99*NetworkSNR/minSNR); + injTable->eff_dist_g*=(REAL4)(0.99*NetworkSNR/minSNR); + rewriteXML=1; repeatLoop=1;} + else { + if(targetSNR==0.0 && maxSNR!=0.0 && maxSNR<NetworkSNR) { + injTable->distance*=(1.01*NetworkSNR/maxSNR); + injTable->eff_dist_h*=(1.01*NetworkSNR/maxSNR); + injTable->eff_dist_l*=(1.01*NetworkSNR/maxSNR); + injTable->eff_dist_v*=(1.01*NetworkSNR/maxSNR); + injTable->eff_dist_t*=(1.01*NetworkSNR/maxSNR); + injTable->eff_dist_g*=(1.01*NetworkSNR/maxSNR); + /*injTable->distance+=0.01;*/ + rewriteXML=1; + repeatLoop=1; + fprintf(stderr,"Multiplying by %lf to get from %lf to target\n",1.01*(NetworkSNR/maxSNR),NetworkSNR);} + } + } + if(repeatLoop==1) fprintf(stderr,"Reinjecting with new distance %f for desired SNR\n\n",injTable->distance); + + if(repeatLoop==0){ + fprintf(stderr,"\nNetwork SNR of %i = %lf\n",inj_num,NetworkSNR); + injTable=injTable->next; + inj_num++; + } -}while(injTable!=NULL); - -/* If the distances were adjusted, re-write the SimInspiral table */ -if(rewriteXML){ - memset(&MDT,0,sizeof(MDT)); - MDT.simInspiralTable = headTable; - - fprintf(stderr,"Overwriting %s with adjusted distances\n",inputfile); - strncat(adjustedfile,inputfile,strlen(inputfile)-4); /* Cut off the .xml */ - sprintf(inputfile,"%s_adj.xml",adjustedfile); - xmlfp=XLALOpenLIGOLwXMLFile((const char *)inputfile); - if(xmlfp==NULL) fprintf(stderr,"Error! Cannot open %s for writing\n",inputfile); - LAL_CALL( LALBeginLIGOLwXMLTable( &status, xmlfp, sim_inspiral_table ), &status ); - LAL_CALL( LALWriteLIGOLwXMLTable( &status, xmlfp, MDT,sim_inspiral_table ), &status ); - LAL_CALL( LALEndLIGOLwXMLTable ( &status, xmlfp ), &status ); - LAL_CALL( LALCloseLIGOLwXMLFile ( &status, xmlfp ), &status ); -} - -return(0); + }while(injTable!=NULL); + + /* If the distances were adjusted, re-write the SimInspiral table */ + if(rewriteXML){ + memset(&MDT,0,sizeof(MDT)); + MDT.simInspiralTable = headTable; + + fprintf(stderr,"Overwriting %s with adjusted distances\n",inputfile); + strncat(adjustedfile,inputfile,strlen(inputfile)-4); /* Cut off the .xml */ + sprintf(inputfile,"%s_adj.xml",adjustedfile); + xmlfp=XLALOpenLIGOLwXMLFile((const char *)inputfile); + if(xmlfp==NULL) fprintf(stderr,"Error! Cannot open %s for writing\n",inputfile); + LAL_CALL( LALBeginLIGOLwXMLTable( &status, xmlfp, sim_inspiral_table ), &status ); + LAL_CALL( LALWriteLIGOLwXMLTable( &status, xmlfp, MDT,sim_inspiral_table ), &status ); + LAL_CALL( LALEndLIGOLwXMLTable ( &status, xmlfp ), &status ); + LAL_CALL( LALCloseLIGOLwXMLFile ( &status, xmlfp ), &status ); + } + + return(0); } diff --git a/lalapps/src/inspiral/coire.c b/lalapps/src/inspiral/coire.c index 14ee04691c0b37557ae241b3fbed253f3dab76cd..40f6dceb801a307d77c54da1574eb65c4281469a 100644 --- a/lalapps/src/inspiral/coire.c +++ b/lalapps/src/inspiral/coire.c @@ -158,7 +158,6 @@ LALPlaygroundDataMask dataType; int main( int argc, char *argv[] ) { /* lal initialization variables */ - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; LALStatus status = blank_status ; /* program option variables */ @@ -258,20 +257,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->start_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -446,7 +444,7 @@ int main( int argc, char *argv[] ) "Steve Fairhurst\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -1442,8 +1440,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->end_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, @@ -1524,8 +1521,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->end_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/corse.c b/lalapps/src/inspiral/corse.c index 6b94352f34423403e39467605e2e77cf1a6276b6..7b50ce8eb008a9b22de4951ac59f102bd8238e56 100644 --- a/lalapps/src/inspiral/corse.c +++ b/lalapps/src/inspiral/corse.c @@ -138,7 +138,6 @@ extern int vrbflg; int main( int argc, char *argv[] ) { /* lal initialization variables */ - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; LALStatus status = blank_status ; /* program option variables */ @@ -243,20 +242,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->start_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -433,7 +431,7 @@ int main( int argc, char *argv[] ) "Drew Keppel\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -1447,8 +1445,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->end_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, @@ -1529,8 +1526,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->end_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/followup_page.in b/lalapps/src/inspiral/followup_page.in index 13d94464b7920eac4c11a6c12ce501992c13dd2f..75b89c03985adf4abfec8e6c8be0007a9260f84e 100644 --- a/lalapps/src/inspiral/followup_page.in +++ b/lalapps/src/inspiral/followup_page.in @@ -133,7 +133,10 @@ def param_table(pdict, wiki, server): colors,colordict = get_colors() skypath = glob.glob('pylal_skyPlotJob/Images/*plot_inspiral_skymap_*' + pdict['All']['ID'] + '*_skylocation-unspecified-gpstime_thumb.png') - wiki.write('||<|'+str(nrows)+'>'+imageLink(server+'/'+skypath[0])) + if skypath: + wiki.write('||<|'+str(nrows)+'>'+imageLink(server+'/'+skypath[0])) + else: + wiki.write('||<|'+str(nrows)+'>') write_columns(['RANK','COINC TYPE','IFO TIME','EVENT ID','STAT','FAR'],wiki) write_columns([pdict['All']['Rank'],pdict['All']['Type'],pdict['All']['IfoTime'],pdict['All']['ID'],pdict['All']['Stat'],pdict['All']['FAR']], wiki,'white','normal') @@ -152,7 +155,7 @@ def setup(dest, server): # Make a destination directory if it doesn't exist if not os.path.isdir(dest): print "destination:" + dest + " does not exist, I'll make it for you..." - os.mkdir(dest) + os.makedirs(dest) # copy the data to the webspace - sort of painful probably could omit some for sec in sections: diff --git a/lalapps/src/inspiral/followup_pipe.in b/lalapps/src/inspiral/followup_pipe.in index f141e34b02aafeff9131e3e9ce4294d7555aa423..10c70cabf3721ed350917a5e72296d100513bef5 100644 --- a/lalapps/src/inspiral/followup_pipe.in +++ b/lalapps/src/inspiral/followup_pipe.in @@ -265,7 +265,7 @@ if not opts.write_to_iulgroup and not opts.generate_fu_cache and \ opts.coh_inspiral and not opts.sky_map and not opts.sky_map_plot and not \ opts.convert_eventid and not opts.odds and not opts.plot_chia \ and not opts.make_checklist and not opts.create_localcopy \ - and not opts.followup_triggers: + and not opts.followup_triggers and not opts.spin_mcmc: print >> sys.stderr, "No steps of the pipeline specified." print >> sys.stderr, "Please specify at least one of" @@ -280,7 +280,7 @@ if not opts.write_to_iulgroup and not opts.generate_fu_cache and \ print >> sys.stderr, "--sky-map, --sky-map-plot, --followup-triggers," print >> sys.stderr, "--convert-eventid, --create-localcopy," print >> sys.stderr, "--ifo-status-check, --single-qevent, --H1H2-qevent" - print >> sys.stderr, "--make-checklist or --write-to-iulgroup" + print >> sys.stderr, "--make-checklist or --spin-mcmc or --write-to-iulgroup" sys.exit(1) if opts.disable_followup: @@ -419,8 +419,7 @@ if opts.do_remote_ifo and not opts.activate_cm_messages: # first, get the path to the scripts scriptPath = Popen(["which", "analyseQscan.py"], stdout=PIPE).communicate()[0] - scriptPath = scriptPath.strip('\n') - scriptPath = scriptPath.replace('analyseQscan.py','followup_virgo_scripts') + scriptPath = scriptPath.strip('analyseQscan.py\n') os.system('cp '+scriptPath+'/qsub_wscan.sh '+depIfoDir+'/SCRIPTS/') os.system('cp '+scriptPath+'/qsub_wscanlite.sh '+depIfoDir+'/SCRIPTS/') os.system('cp '+scriptPath+'/wscan_in2p3.sh '+depIfoDir+'/SCRIPTS/') @@ -434,7 +433,7 @@ if opts.do_remote_ifo and not opts.activate_cm_messages: print(' The web address for Virgo qscans should start with \"http://virgo.in2p3.fr/followups/\"') print(' followed by the name of the submitter of the jobs') else: - depIfoWebForeground = depIfoWebForeground.replace('http://virgo.in2p3.fr/followups/','') + depIfoWebForeground = depIfoWebForeground.replace('http://virgo.in2p3.fr/followups/','') + "/qscan/" os.system('sed -e \'s|@foreground@|'+depIfoWebForeground+'|\' '+depIfoDir+'/virgo_qscan_in2p3.py > '+depIfoDir+'/virgo_qscan_in2p3.py.tmp') os.system('mv -f '+depIfoDir+'/virgo_qscan_in2p3.py.tmp '+depIfoDir+'/virgo_qscan_in2p3.py') os.system('chmod +x '+depIfoDir+'/virgo_qscan_in2p3.py') @@ -445,7 +444,7 @@ if opts.do_remote_ifo and not opts.activate_cm_messages: print(' The web address for Virgo qscans should start with \"http://virgo.in2p3.fr/followups/\"') print(' followed by the name of the submitter of the jobs') else: - depIfoWebForegroundSeismic = depIfoWebForegroundSeismic.replace('http://virgo.in2p3.fr/followups/','') + depIfoWebForegroundSeismic = depIfoWebForegroundSeismic.replace('http://virgo.in2p3.fr/followups/','') + "/seismic_qscan/" os.system('sed -e \'s|@foreground-seismic@|'+depIfoWebForegroundSeismic+'|\' '+depIfoDir+'/virgo_qscan_in2p3.py > '+depIfoDir+'/virgo_qscan_in2p3.py.tmp') os.system('mv -f '+depIfoDir+'/virgo_qscan_in2p3.py.tmp '+depIfoDir+'/virgo_qscan_in2p3.py') os.system('chmod +x '+depIfoDir+'/virgo_qscan_in2p3.py') @@ -455,7 +454,7 @@ if opts.do_remote_ifo and not opts.activate_cm_messages: # Prepare the qscan background if opts.background_qscan or opts.background_hoft_qscan or opts.background_seis_qscan: for ifo in ifos_list: - times, timeListFile = getQscanBackgroundTimes(cp,opts,ifo, dq_url_pattern,segFile) + times, timeListFile = getQscanBackgroundTimes(cp,opts,ifo,segFile) for time in times: # SETUP DATAFIND JOBS FOR BACKGROUND QSCANS (REGULAR DATA SET) dNode = followupDataFindNode(dataJob,'futrig','q-datafind',cp,time,ifo,opts,dag,'datafind') @@ -613,7 +612,7 @@ if not opts.disable_followup and not opts.read_times: chainNumber = string.strip(cp.get('followup-mcmc','chain_nb')) mcmcIdList = [] for k in range(int(chainNumber)): - randomseed = [str(trig.gpsTime[ifo] + k).split('.')[0][5:9],str(trig.gpsTime[ifo]).split('.')[1]] + randomseed = str(trig.gpsTime[ifo] + k).split('.')[0][5:9] MCMCNode = followupmcmcNode(MCMCJob,inspiral_process_params, trig, randomseed, cp, opts, dag, ifo) mcmcIdList.append(MCMCNode.id) @@ -689,7 +688,7 @@ if not opts.disable_followup and not opts.read_times: chainNumber = string.strip(cp.get('followup-mcmc','chain_nb')) mcmcIdList = [] for k in range(int(chainNumber)): - randomseed = [str(trig.gpsTime[trig.ifolist_in_coinc[0]] + k).split('.')[0][5:9],str(trig.gpsTime[trig.ifolist_in_coinc[0]]).split('.')[1]] + randomseed = str(trig.gpsTime[trig.ifolist_in_coinc[0]] + k).split('.')[0][5:9] MCMCNode = followupmcmcNode(MCMCJob,inspiral_process_params, trig, randomseed, cp, opts, dag) mcmcIdList.append(MCMCNode.id) diff --git a/lalapps/src/inspiral/followup_pipe.ini b/lalapps/src/inspiral/followup_pipe.ini index fb123cbaf92d394675a09ece966455287feb80fd..5e64243cdd7762ac69c76339d91dfcad58aa6cf7 100644 --- a/lalapps/src/inspiral/followup_pipe.ini +++ b/lalapps/src/inspiral/followup_pipe.ini @@ -1,6 +1,6 @@ [condor] universe = standard -datafind = /archive/home/romain/TRUNK_20081113/opt/lscsoft/glue/bin/LSCdataFind +datafind = /archive/home/romain/TRUNK_20081113/opt/lscsoft/glue/bin/ligo_data_find convertcache = /ligotools/bin/convertlalcache.pl ;if you run on the Caltech cluster, you can leave the qevent, qscan, qscanlite paths as they are qscan = /archive/home/romain/opt/omega-romain/bin/wpipeline @@ -50,6 +50,8 @@ hipe-cache-path = /archive/home/vallis/year2-allplot/859651570-862070770/datafin hipe-output-cache = /archive/home/vallis/year2-allplot/859651570-862070770/ihope.cache.full ;triggers-tag = COIRE_SUMMARY_SECOND_H1H2L1_FULL_DATA_CAT_3_VETO xml-glob = /archive/home/vallis/year2-allplot/859651570-862070770/ifar2/corse_all_data_files/all_data/H1H2L1_H1L1-CORSE_ALL_DATA_mchirp_17_35_CAT_3-859651570-2419200.xml.gz +;List of patterns to be rejected from the glob of input files +;exclude-tags = H2L1_H2L1-* ;If left blank, that means no injections ;Must specify the same HL file that the inspiral jobs were ran with injection-file = @@ -284,8 +286,12 @@ write-events = write-cohsnr = write-cohnullstat = write-cohh1h2snr = +;for lowmass searches ra-step = 6.0 dec-step = 6.0 +;for highmass searches +;ra-step = 3.0 +;dec-step = 3.0 numCohTrigs = 2000 [skymap] diff --git a/lalapps/src/inspiral/fr_ninja.c b/lalapps/src/inspiral/fr_ninja.c index 449f51bd55a0f28d9a03af2baefad3f5ba3cc454..e90bde36e821c2d267d0bc7594eafc374b12bfae 100644 --- a/lalapps/src/inspiral/fr_ninja.c +++ b/lalapps/src/inspiral/fr_ninja.c @@ -191,7 +191,7 @@ INT4 main(INT4 argc, CHAR **argv) fprintf(stdout, "Numerical Relativity Frame Generation\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n"); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit(0); break; diff --git a/lalapps/src/inspiral/gwf2xml.c b/lalapps/src/inspiral/gwf2xml.c index e61b9b962b6b807b548b7d7fb8c61886f1feb41b..3b8aacd749386b224a36d940e8e1c71c1b2b79a2 100644 --- a/lalapps/src/inspiral/gwf2xml.c +++ b/lalapps/src/inspiral/gwf2xml.c @@ -62,7 +62,7 @@ int frEvent2snglInspiral(SnglInspiralTable **snglInspiralEvent, SnglInspiralTable *snglEvt = NULL; int numEvt = 0; double timeAfter = 0; - + /* If we already have events in snglInspiralEvent, * wind on to the end of the list */ for( snglEvt = *snglInspiralEvent; snglEvt; snglEvt=snglEvt->next); @@ -86,8 +86,8 @@ int frEvent2snglInspiral(SnglInspiralTable **snglInspiralEvent, snglEvt->snr = frEvt->amplitude; snglEvt->end_time.gpsSeconds = frEvt->GTimeS; snglEvt->end_time.gpsNanoSeconds = frEvt->GTimeN; - timeAfter = frEvt->timeAfter; - XLALGPSAdd(&snglEvt->end_time,timeAfter); + timeAfter = frEvt->timeAfter; + XLALGPSAdd(&snglEvt->end_time,timeAfter); snglEvt->eff_distance = FrEventGetParam ( frEvt, "distance (Mpc)"); snglEvt->mass1 = FrEventGetParam ( frEvt, "mass1"); snglEvt->mass2 = FrEventGetParam ( frEvt, "mass2" ); @@ -95,7 +95,7 @@ int frEvent2snglInspiral(SnglInspiralTable **snglInspiralEvent, snglEvt->tau3 = FrEventGetParam ( frEvt, "tau1p5" ); snglEvt->coa_phase = FrEventGetParam ( frEvt, "phase" ); snglEvt->chisq = FrEventGetParam ( frEvt, "chi2" ); - + /* populate additional colums */ snglEvt->mtotal = snglEvt->mass1 + snglEvt->mass2; snglEvt->eta = (snglEvt->mass1 * snglEvt->mass2) / @@ -202,7 +202,7 @@ int main( int argc, char *argv[] ) {"input", required_argument, 0, 'i'}, {"output", required_argument, 0, 'o'}, {"snr-threshold", required_argument, 0, 's'}, - {"ifo", required_argument, 0, 'd'}, + {"ifo", required_argument, 0, 'd'}, {0, 0, 0, 0} }; int c; @@ -253,13 +253,13 @@ int main( int argc, char *argv[] ) memcpy( outputFileName, optarg, optarg_len ); break; - case 'd': + case 'd': /* create storage for the output file name */ optarg_len = strlen( optarg ) + 1; ifo = (CHAR *) calloc( optarg_len, sizeof(CHAR)); memcpy( ifo, optarg, optarg_len ); break; - + case 's': snrMin = (double) atof( optarg ); if ( snrMin < 0 ) @@ -341,36 +341,36 @@ int main( int argc, char *argv[] ) FrSimEventFree(frSimEvent); - /* - * - * write a search summary table - * - */ + /* + * + * write a search summary table + * + */ - /* create the search summary and zero out the summvars table */ + /* create the search summary and zero out the summvars table */ searchsumm.searchSummaryTable = (SearchSummaryTable *) calloc( 1, sizeof(SearchSummaryTable) ); - - /* create the search summary and zero out the summvars table */ + + /* create the search summary and zero out the summvars table */ searchsumm.searchSummaryTable = (SearchSummaryTable *) calloc( 1, sizeof(SearchSummaryTable) ); - searchsumm.searchSummaryTable->in_start_time.gpsSeconds = tStart; + searchsumm.searchSummaryTable->in_start_time.gpsSeconds = tStart; searchsumm.searchSummaryTable->in_end_time.gpsSeconds = tEnd; searchsumm.searchSummaryTable->out_start_time.gpsSeconds = tStart; - searchsumm.searchSummaryTable->out_end_time.gpsSeconds = tEnd; + searchsumm.searchSummaryTable->out_end_time.gpsSeconds = tEnd; searchsumm.searchSummaryTable->nnodes = 1; - if (numEvt) - { - searchsumm.searchSummaryTable->nevents = numEvt; - } - else if (numSim) - { - searchsumm.searchSummaryTable->nevents = numSim; - } - + if (numEvt) + { + searchsumm.searchSummaryTable->nevents = numEvt; + } + else if (numSim) + { + searchsumm.searchSummaryTable->nevents = numSim; + } + /* * @@ -382,14 +382,14 @@ int main( int argc, char *argv[] ) memset( &xmlStream, 0, sizeof(LIGOLwXMLStream) ); LALOpenLIGOLwXMLFile( &stat, &xmlStream, outputFileName ); - /* Write search_summary table */ + /* Write search_summary table */ LALBeginLIGOLwXMLTable( &stat, &xmlStream, search_summary_table ); LALWriteLIGOLwXMLTable( &stat, &xmlStream, searchsumm, search_summary_table ); LALEndLIGOLwXMLTable ( &stat, &xmlStream ); - + /* Write the results to the inspiral table */ if ( snglInspiralEvent ) { diff --git a/lalapps/src/inspiral/ihope.in b/lalapps/src/inspiral/ihope.in index 1fc1bfbe136c07b1099ace8084cd119bc49d3fa2..fea9df3619c3c558575ca0aa531eb2fd1b9dceb5 100644 --- a/lalapps/src/inspiral/ihope.in +++ b/lalapps/src/inspiral/ihope.in @@ -91,6 +91,11 @@ parser.add_option("-p", "--log-path",action="store",type="string",\ metavar=" PATH", \ help="directory to write condor log file, should be a local directory") +parser.add_option("-l", "--node-local-dir",action="store",type="string",\ + metavar=" NODEPATH", \ + help='''directory to write the temporary sql databases. This must be a +directory that is local to all nodes.''') + parser.add_option("-s", "--gps-start-time",action="store",type="int",\ metavar=" GPS_START", help="begin analysis at GPS_START") @@ -127,10 +132,6 @@ parser.add_option("-I", "--skip-injections",action="store_false",\ default=True, dest="run_injections", \ help="skip the inspiral analysis with software injections") -parser.add_option("-H", "--run-hardware-injections",action="store_true",\ - default=False, dest="run_hardware_injections", \ - help="skip the inspiral analysis with hardware injections") - parser.add_option("-A", "--skip-search",action="store_false",\ default=True, dest="run_search", help="skip the search of the data (i.e. don't run inspiral hipe)") @@ -145,15 +146,12 @@ parser.add_option("-Z", "--skip-plots",action="store_false",\ parser.add_option("-U", "--skip-followup",action="store_false",\ default=True, dest="run_followup", help="skip the inspiral followup") +parser.add_option("-H", "--skip-pipedown",action="store_false",\ + default=True, dest="run_pipedown", help="skip running pipedown") + parser.add_option("-x", "--dax",action="store_true",\ default=False, help="Make a dax workflow") -parser.add_option("-G","--generate-full-data-results-plots",\ - action="store_true",default=False,dest="generate_results_plots",\ - help="""Use this option to generate the zero lag full data results plots -This is independant of --skip-plots and --skip-full-data. DO NOT run with this -option unless the box has been opened.""") - command_line = sys.argv[1:] (opts,args) = parser.parse_args() @@ -169,6 +167,13 @@ if not opts.log_path: print >> sys.stderr, "Use --log-path PATH to specify a location." sys.exit(1) +if opts.run_pipedown: + if not opts.node_local_dir: + print >> sys.stderr, "No local dir specified. If running with pipedown" + print >> sys.stderr, "use --node-local-dir to specify a local directory" + print >> sys.stderr, "Use --help for more information" + sys.exit(1) + if not opts.gps_start_time: print >> sys.stderr, "No GPS start time specified for the analysis" print >> sys.stderr, "Use --gps-start-time GPS_START to specify a location." @@ -183,12 +188,7 @@ if opts.gps_end_time < opts.gps_start_time: print >> sys.stderr, "The GPS end time must be after the GPS start time" sys.exit(1) -#FIXME: run hardware injections option will no longer work with the switch -# to ligolw_segment_query. For now, will print error message and exit; once -# fixed, remove this. -if opts.run_hardware_injections: - print >> sys.stderr, "--run-hardware-injections currently does not work" - sys.exit(1) +opts.complete_cache = (opts.run_data_quality or opts.run_plots or opts.run_pipedown or opts.run_search) ############################################################################## # set up the analysis directory @@ -214,6 +214,10 @@ cp.set("input", "gps-end-time", str(opts.gps_end_time) ) opts.do_dag_categories = not cp.has_option( "hipe-arguments","disable-dag-categories") +# Add local dir to pipeline + +if opts.run_pipedown: + cp.set("pipeline","node-tmp-dir",opts.node_local_dir) ############################################################################## # create a directory called executables and copy them over @@ -248,9 +252,6 @@ fh.close() dag = pipeline.CondorDAG(logfile) dag.set_dag_file(basename) -# write the file to handle the rescue dags -inspiralutils.write_rescue() - ############################################################################## # Set up the IFOs and get the appropriate segments ifos = [] @@ -276,24 +277,19 @@ sys.stdout.flush() # first, copy the segment files and make sure that the ini file reflects the # new path, relative to the DAG directories. -if opts.run_hardware_injections: - hwcp = copy.deepcopy(cp) - inspiralutils.mkdir("hardware_inj_segments") - inspiralutils.mkdir("segments") os.chdir("..") for vetoes, infile in cp.items("segments"): inspiralutils.copyCategoryFiles(cp,vetoes,"segments",infile,\ analysisDirectory) -if opts.run_hardware_injections: - for vetoes, infile in hwcp.items("segments"): - inspiralutils.copyCategoryFiles(hwcp,vetoes,"hardware_inj_segments",infile,\ - analysisDirectory,hardwareInj=True) - os.chdir(analysisDirectory) os.chdir("segments") +# Determine which veto categories to filter +veto_categories = [int(cat) for cat in cp.get('segments','veto-categories').split(',')] +veto_categories.sort() + # Download the veto definer xml file vetoDefFile = inspiralutils.downloadVetoDefFile(cp, opts.generate_segments) @@ -301,13 +297,29 @@ vetoDefFile = inspiralutils.downloadVetoDefFile(cp, opts.generate_segments) inspiralutils.generate_veto_cat_files(cp, vetoDefFile, \ opts.generate_veto_segments) +# Generate a combined veto file for each ifo for use by pipedown +gps_start = int(opts.gps_start_time) +gps_end = int(opts.gps_end_time) +duration = gps_end - gps_start + +for category in [1] + veto_categories: + ifos_string = '' + veto_cat_files = [] + veto_cat_filename = str(gps_start) + '-' + str(duration) + '.xml' + for ifo in ifos: + veto_cat_files.append('-'.join([ifo, 'VETOTIME_CAT' + str(category), veto_cat_filename])) + ifos_string += ifo + concat_veto_call = ' '.join([ cp.get("condor", "ligolw_add"), + "--output", '-'.join([ifos_string, 'VETOTIME_CAT_' + str(category), veto_cat_filename])] + veto_cat_files ) + inspiralutils.make_external_call(concat_veto_call) segFile = {} dqVetoes = {} for ifo in ifos: - segFile[ifo], dqVetoes[ifo] = inspiralutils.findSegmentsToAnalyze(cp, ifo, - opts.generate_segments, opts.use_available_data, \ + segFile[ifo], dqVetoes[ifo] = inspiralutils.findSegmentsToAnalyze( + cp, ifo, veto_categories, + opts.generate_segments, opts.use_available_data, opts.generate_veto_segments) # set correct name as we're in the segments directory: segFile[ifo] = "../segments/" + segFile[ifo] @@ -315,38 +327,6 @@ for ifo in ifos: for key in dqVetoes[ifo].keys(): dqVetoes[ifo][key] = "../segments/" + dqVetoes[ifo][key] - -if opts.run_hardware_injections: - # FIXME: This will no longer work - dqHWSegFile = {} - # Download the dqHWSegFiles - for ifo in ifos: - os.chdir("../hardware_inj_segments") - dqHWSegFile[ifo] = inspiralutils.downloadDqHWSegFiles(hwcp,\ - ifo,opts.generate_segments,"../segments/" + dqSegFile[ifo]) - os.chdir("../segments") - - os.chdir("..") - os.chdir("hardware_inj_segments") - hwInjHtmlLoc = hwcp.get('hardware-inj','hw-inj-file-html-path') - hwFileTempName = 'HARDWARE_INJECTIONS.xml' - hwFileTempName,hwInfo = urllib.urlretrieve(hwInjHtmlLoc,hwFileTempName) - hwcp.set('input','hardware-inj-file',\ - '../hardware_inj_segments/' + hwFileTempName) - - HWsegFile = {} - HWdqVetoes = {} - - for ifo in ifos: - HWsegFile[ifo],HWdqVetoes[ifo]=inspiralutils.findSegmentsToAnalyze(hwcp,\ - ifo,dqHWSegFile[ifo],opts.generate_segments, opts.use_available_data, \ - opts.generate_veto_segments) - HWsegFile[ifo] = "../hardware_inj_segments/" + HWsegFile[ifo] - hwcp.set("input", ifo.lower() + "-segments", HWsegFile[ifo]) - for key in HWdqVetoes[ifo].keys(): - HWdqVetoes[ifo][key] = "../hardware_inj_segments/" + HWdqVetoes[ifo][key] - - os.chdir("..") ############################################################################## @@ -363,7 +343,7 @@ if opts.run_datafind or opts.run_tmpltbank: cachelist = [] cachefilename = basename + '.cache' -if opts.run_search: +if opts.complete_cache: # We need to get the names of the template bank files that are generated in # the datafind step, so we can link them into all the search directories datafind_cache_filename = "datafind/" + inspiralutils.hipe_cache(ifos, \ @@ -371,48 +351,86 @@ if opts.run_search: tmpltbank_cache = inspiralutils.tmpltbank_cache(datafind_cache_filename) if opts.run_playground: - print "Running inspiral hipe for playground run" - hipePlayNode = inspiralutils.hipe_setup("playground", cp, ifos, \ - opts.log_path, playOnly = True, dax=opts.dax, \ - site=cp.get("sites","playground"), tmpltbankCache = tmpltbank_cache) - for cacheFile in hipePlayNode.get_output_files(): - cachelist.append("playground/" + cacheFile) - dag.add_node(hipePlayNode) - if opts.run_datafind or opts.run_tmpltbank: - hipePlayNode.add_parent(hipeDfNode) + playDir = "playground" + if opts.run_search: + print "Running inspiral hipe for playground run" + hipePlayNode = inspiralutils.hipe_setup(playDir, cp, ifos, \ + opts.log_path, playOnly = True, dax=opts.dax, \ + tmpltbankCache = tmpltbank_cache) + for cacheFile in hipePlayNode.get_output_files(): + cachelist.append(playDir + "/" + cacheFile) + dag.add_node(hipePlayNode) + if opts.run_datafind or opts.run_tmpltbank: + hipePlayNode.add_parent(hipeDfNode) + else: + if cp.get("pipeline","user-tag"): + usertag = ecp.get("pipeline", "user-tag") + "_" + playDir.upper() + else: + usertag = playDir.upper() + cacheFile = inspiralutils.hipe_cache( ifos,usertag, \ + cp.getint("input", "gps-start-time"), \ + cp.getint("input", "gps-end-time")) + if os.path.isfile(playDir + "/" + cacheFile): + cachelist.append(playDir + "/" + cacheFile) + else: + print>>sys.stderr, "WARNING: Cache file " + playDir + "/" + cacheFile + print>>sys.stderr, "does not exist! This might cause later failures." - if opts.run_full_data: - print "Running inspiral hipe for analysis run" - hipeAnalysisNode = inspiralutils.hipe_setup("full_data", cp, ifos, \ - opts.log_path,dax=opts.dax,site=cp.get("sites","full_data"), \ - tmpltbankCache = tmpltbank_cache) - for cacheFile in hipeAnalysisNode.get_output_files(): - cachelist.append("full_data/" + cacheFile) - dag.add_node(hipeAnalysisNode) - if opts.run_datafind or opts.run_tmpltbank: - hipeAnalysisNode.add_parent(hipeDfNode) - if opts.run_hardware_injections: - hipeHWinjNode = inspiralutils.hipe_setup("hardware_injections", hwcp, ifos,\ - opts.log_path, hardwareInj = True) - for cacheFile in hipeHWinjNode.get_output_files(): - cachelist.append("hardware_injections/" + cacheFile) - dag.add_node(hipeHWinjNode) - if opts.run_datafind: - hipeHWinjNode.add_parent(hipeDfNode) + if opts.run_full_data: + fullDir = "full_data" + if opts.run_search: + print "Running inspiral hipe for analysis run" + hipeAnalysisNode = inspiralutils.hipe_setup(fullDir, cp, ifos, \ + opts.log_path,dax=opts.dax, \ + tmpltbankCache = tmpltbank_cache) + for cacheFile in hipeAnalysisNode.get_output_files(): + cachelist.append(fullDir + "/" + cacheFile) + dag.add_node(hipeAnalysisNode) + if opts.run_datafind or opts.run_tmpltbank: + hipeAnalysisNode.add_parent(hipeDfNode) + else: + if cp.get("pipeline","user-tag"): + usertag = cp.get("pipeline", "user-tag") + "_" + fullDir.upper() + else: + usertag = fullDir.upper() + cacheFile = inspiralutils.hipe_cache( ifos,usertag, \ + cp.getint("input", "gps-start-time"), \ + cp.getint("input", "gps-end-time")) + if os.path.isfile(fullDir + "/" + cacheFile): + cachelist.append(fullDir + "/" + cacheFile) + else: + print>>sys.stderr, "WARNING: Cache file " + fullDir + "/" + cacheFile + print>>sys.stderr, "does not exist! This might cause later failures." + if opts.run_injections: hipeInjNode = {} print "Running inspiral hipe for injection runs" for (injDir, injSeed) in cp.items("injections"): - hipeInjNode[injDir] = inspiralutils.hipe_setup(injDir, cp, ifos, \ - opts.log_path, injSeed, dax=opts.dax, \ - site=cp.get("sites",injDir), tmpltbankCache = tmpltbank_cache) - for cacheFile in hipeInjNode[injDir].get_output_files(): - cachelist.append(injDir + "/" + cacheFile) - dag.add_node(hipeInjNode[injDir]) - if opts.run_datafind or opts.run_tmpltbank: - hipeInjNode[injDir].add_parent(hipeDfNode) + if opts.run_search: + hipeInjNode[injDir] = inspiralutils.hipe_setup(injDir, cp, ifos, \ + opts.log_path, injSeed, dax=opts.dax, \ + tmpltbankCache = tmpltbank_cache) + for cacheFile in hipeInjNode[injDir].get_output_files(): + cachelist.append(injDir + "/" + cacheFile) + dag.add_node(hipeInjNode[injDir]) + if opts.run_datafind or opts.run_tmpltbank: + hipeInjNode[injDir].add_parent(hipeDfNode) + else: + if cp.get("pipeline","user-tag"): + usertag = cp.get("pipeline", "user-tag") + "_" + injDir.upper() + else: + usertag = injDir.upper() + cacheFile = inspiralutils.hipe_cache( ifos,usertag, \ + cp.getint("input", "gps-start-time"), \ + cp.getint("input", "gps-end-time")) + if os.path.isfile(injDir + "/" + cacheFile): + cachelist.append(injDir + "/" + cacheFile) + else: + print>>sys.stderr, "WARNING: Cache file " + injDir + "/" + cacheFile + print>>sys.stderr, "does not exist! This might cause later failures." + ################################################################################ # Setting up directories for reverse analysis @@ -424,7 +442,7 @@ if opts.reverse_analysis: print "Running inspiral hipe for reverse playground run" hipePlayNode = inspiralutils.hipe_setup("playground_reverse", cp, ifos, \ opts.log_path, playOnly = True, dax = opts.dax, \ - site = cp.get("sites","playground"), tmpltbankCache = tmpltbank_cache) + tmpltbankCache = tmpltbank_cache) for cacheFile in hipePlayNode.get_output_files(): cachelist.append("playground_reverse/" + cacheFile) dag.add_node(hipePlayNode) @@ -435,7 +453,7 @@ if opts.reverse_analysis: cp.set ("inspiral","reverse-chirp-bank","") print "Running inspiral hipe for reverse analysis run" hipeAnalysisNode = inspiralutils.hipe_setup("full_data_reverse", cp, ifos, \ - opts.log_path, dax=opts.dax, site = cp.get("sites","full_data"), \ + opts.log_path, dax=opts.dax, \ tmpltbankCache = tmpltbank_cache) for cacheFile in hipeAnalysisNode.get_output_files(): cachelist.append("full_data_reverse/" + cacheFile) @@ -450,7 +468,7 @@ if opts.reverse_analysis: for (injDir, injSeed) in cp.items("injections_reverse"): hipeInjNode[injDir] = inspiralutils.hipe_setup(injDir, cp, ifos, \ opts.log_path, injSeed, dax=opts.dax, \ - site= cp.get("sites",injDir), tmpltbankCache = tmpltbank_cache) + tmpltbankCache = tmpltbank_cache) for cacheFile in hipeInjNode[injDir].get_output_files(): cachelist.append(injDir + "/" + cacheFile) dag.add_node(hipeInjNode[injDir]) @@ -459,74 +477,110 @@ if opts.reverse_analysis: ############################################################################## # Run the data quality vetoes -if opts.run_data_quality: +if opts.complete_cache: hipePlayVetoNode = {} hipeAnalysisVetoNode = {} hipeInjVetoNode = {} - hipeHWinjVetoNode = {} - for category in [2,3,4]: + for category in veto_categories: hipeInjVetoNode[category] = {} - print "Setting up the category " + str(category) + " veto dags" + if opts.run_data_quality: + print "Setting up the category " + str(category) + " veto dags" if opts.run_playground: - print "Running inspiral hipe for play with vetoes" - hipePlayVetoNode[category] = inspiralutils.hipe_setup("playground", cp, \ - ifos, opts.log_path, playOnly = True, vetoCat = category, \ - vetoFiles = dqVetoes, dax=opts.dax, \ - site=cp.get("sites","playground")) - for cacheFile in hipePlayVetoNode[category].get_output_files(): - cachelist.append("playground/" + cacheFile) - dag.add_node(hipePlayVetoNode[category]) - if category==2 and opts.run_search: - hipePlayVetoNode[category].add_parent(hipePlayNode) - elif category>2: - hipePlayVetoNode[category].add_parent(hipePlayVetoNode[category-1]) + playDir = "playground" + if opts.run_data_quality: + print "Running inspiral hipe for play with vetoes" + hipePlayVetoNode[category] = inspiralutils.hipe_setup(playDir, cp, \ + ifos, opts.log_path, playOnly = True, vetoCat = category, \ + vetoFiles = dqVetoes, dax=opts.dax ) + for cacheFile in hipePlayVetoNode[category].get_output_files(): + cachelist.append(playDir + "/" + cacheFile) + dag.add_node(hipePlayVetoNode[category]) + if category==2 and opts.run_search: + hipePlayVetoNode[category].add_parent(hipePlayNode) + elif category>2: + hipePlayVetoNode[category].add_parent(hipePlayVetoNode[category-1]) + elif not opts.run_search: + if cp.get("pipeline","user-tag"): + usertag = cp.get("pipeline", "user-tag") + "_" + playDir.upper() + else: + usertag = playDir.upper() + usertag += "_CAT_" + str(category) + "_VETO" + cacheFile = inspiralutils.hipe_cache( ifos,usertag, \ + cp.getint("input", "gps-start-time"), \ + cp.getint("input", "gps-end-time")) + if os.path.isfile(playDir + "/" + cacheFile): + cachelist.append(playDir + "/" + cacheFile) + else: + print>>sys.stderr, "WARNING: Cache file " + playDir + "/" + cacheFile + print>>sys.stderr, "does not exist! This might cause later failures." + if opts.run_full_data: - print "Running inspiral hipe for full data with vetoes" - hipeAnalysisVetoNode[category] = inspiralutils.hipe_setup("full_data", \ - cp, ifos, opts.log_path, vetoCat = category, vetoFiles = dqVetoes, dax = opts.dax, site=cp.get("sites","full_data")) - for cacheFile in hipeAnalysisVetoNode[category].get_output_files(): - cachelist.append("full_data/" + cacheFile) - dag.add_node(hipeAnalysisVetoNode[category]) - if category==2 and opts.run_search: - hipeAnalysisVetoNode[category].add_parent(hipeAnalysisNode) - elif category>2: - hipeAnalysisVetoNode[category].add_parent( \ - hipeAnalysisVetoNode[category-1]) - - if opts.run_hardware_injections: - print "Running inspiral hipe for hardware injections with vetoes" - hipeHWinjVetoNode[category] = inspiralutils.hipe_setup( \ - "hardware_injections",hwcp, ifos, opts.log_path, \ - vetoCat = category, vetoFiles = HWdqVetoes,hardwareInj=True) - for cacheFile in hipeHWinjVetoNode[category].get_output_files(): - cachelist.append("hardware_injections" + "/" + cacheFile) - dag.add_node(hipeHWinjVetoNode[category]) - if category==2 and opts.run_search: - hipeHWinjVetoNode[category].add_parent(hipeHWinjNode) - elif category>2: - hipeHWinjVetoNode[category].add_parent( \ - hipeHWinjVetoNode[category-1]) + fullDir = "full_data" + if opts.run_data_quality: + print "Running inspiral hipe for full data with vetoes" + hipeAnalysisVetoNode[category] = inspiralutils.hipe_setup(fullDir, \ + cp, ifos, opts.log_path, vetoCat = category, vetoFiles = dqVetoes, dax = opts.dax) + for cacheFile in hipeAnalysisVetoNode[category].get_output_files(): + cachelist.append(fullDir + "/" + cacheFile) + dag.add_node(hipeAnalysisVetoNode[category]) + if category==2 and opts.run_search: + hipeAnalysisVetoNode[category].add_parent(hipeAnalysisNode) + elif category>2: + hipeAnalysisVetoNode[category].add_parent( \ + hipeAnalysisVetoNode[category-1]) + elif not opts.run_search: + if cp.get("pipeline","user-tag"): + usertag = cp.get("pipeline", "user-tag") + "_" + fullDir.upper() + else: + usertag = fullDir.upper() + usertag += "_CAT_" + str(category) + "_VETO" + cacheFile = inspiralutils.hipe_cache( ifos,usertag, \ + cp.getint("input", "gps-start-time"), \ + cp.getint("input", "gps-end-time")) + if os.path.isfile(fullDir + "/" + cacheFile): + cachelist.append(fullDir + "/" + cacheFile) + else: + print>>sys.stderr, "WARNING: Cache file " + fullDir + "/" + cacheFile + print>>sys.stderr, "does not exist! This might cause later failures." + if opts.run_injections: - print "Running inspiral hipe for injections with vetoes" + if opts.run_data_quality: + print "Running inspiral hipe for injections with vetoes" for (injDir, injSeed) in cp.items("injections"): - hipeInjVetoNode[category][injDir] = inspiralutils.hipe_setup(injDir, \ - cp, ifos, opts.log_path, \ - injSeed= injSeed, vetoCat = category, vetoFiles = dqVetoes, \ - dax=opts.dax, site=cp.get("sites",injDir)) - for cacheFile in hipeInjVetoNode[category][injDir].get_output_files(): - cachelist.append(injDir + "/" + cacheFile) - dag.add_node(hipeInjVetoNode[category][injDir]) - if category==2 and opts.run_search: - hipeInjVetoNode[category][injDir].add_parent(hipeInjNode[injDir]) - elif category>2: - hipeInjVetoNode[category][injDir].add_parent(\ - hipeInjVetoNode[category-1][injDir]) + if opts.run_data_quality: + hipeInjVetoNode[category][injDir] = inspiralutils.hipe_setup(injDir, \ + cp, ifos, opts.log_path, \ + injSeed= injSeed, vetoCat = category, vetoFiles = dqVetoes, \ + dax=opts.dax ) + for cacheFile in hipeInjVetoNode[category][injDir].get_output_files(): + cachelist.append(injDir + "/" + cacheFile) + dag.add_node(hipeInjVetoNode[category][injDir]) + if category==2 and opts.run_search: + hipeInjVetoNode[category][injDir].add_parent(hipeInjNode[injDir]) + elif category>2: + hipeInjVetoNode[category][injDir].add_parent(\ + hipeInjVetoNode[category-1][injDir]) + elif not opts.run_search: + if cp.get("pipeline","user-tag"): + usertag = cp.get("pipeline", "user-tag") + "_" + injDir.upper() + else: + usertag = injDir.upper() + usertag += "_CAT_" + str(category) + "_VETO" + cacheFile = inspiralutils.hipe_cache( ifos,usertag, \ + cp.getint("input", "gps-start-time"), \ + cp.getint("input", "gps-end-time")) + if os.path.isfile(injDir + "/" + cacheFile): + cachelist.append(injDir + "/" + cacheFile) + else: + print>>sys.stderr, "WARNING: Cache file " + injDir + "/" + cacheFile + print>>sys.stderr, "does not exist! This might cause later failures." + ############################################################################# # run the data quality vetoes for reverse chirp analysis @@ -537,7 +591,7 @@ if opts.reverse_analysis: hipeAnalysisVetoNode = {} hipeInjVetoNode = {} - for category in [2,3,4]: + for category in veto_categories: print "Setting up the category " + str(category) + " veto dags" + " for reverse chirp analysis" cp.set ("inspiral","reverse-chirp-bank","") if opts.run_play_analysis: @@ -584,6 +638,51 @@ if opts.reverse_analysis: hipeInjVetoNode[injDir][category].add_parent(\ hipeInjVetoNode[injDir][category-1]) +############################################################################## +# cat the cache files together + + +if len(cachelist): + command = "cat " + " ".join(cachelist) + " > " + cachefilename + os.popen(command) + +############################################################################## +# Run lalapps_pipedown + +if opts.run_pipedown: + # Set up parents correctly + parentNodes = [] + if opts.run_search: + if opts.run_full_data: + parentNodes.append(hipeAnalysisNode) + if opts.run_playground: + parentNodes.append(hipePlayNode) + + if opts.run_data_quality: + if opts.run_playground: + for category in veto_categories: + parentNodes.append(hipePlayVetoNode[category]) + if opts.run_full_data: + for category in veto_categories: + parentNodes.append(hipeAnalysisVetoNode[category]) + + if opts.run_injections: + for (injDir, injSeed) in cp.items("injections"): + if opts.run_search: + parentNodes.append(hipeInjNode[injDir]) + if opts.run_data_quality: + for category in veto_categories: + parentNodes.append(hipeInjVetoNode[category][injDir]) + + if len(parentNodes) == 0: + parentNodes = None + + playgroundOnly = False + + print "Running lalapps_pipedown" + dag = inspiralutils.pipedownSetup(dag,cp,opts.log_path,"pipedown",\ + "../" + cachefilename,parentNodes,playgroundOnly) + ############################################################################## # Set up the directories for plotting and run lalapps_plot if opts.run_plots: @@ -595,14 +694,15 @@ if opts.run_plots: else: parentNodes = None if opts.run_data_quality: - parentVetoNodes = [hipePlayVetoNode[3]] + parentVetoNodes = [hipePlayVetoNode] else: parentVetoNodes = None # make the playground slide/zerolag plots print "Making plots depending only on the playground" dag = inspiralutils.zeroSlidePlots(dag, "playground_summary_plots", cp, \ opts.log_path, "PLAYGROUND", "PLAYGROUND", "../" + cachefilename, \ - opts.do_dag_categories, parentNodes, parentVetoNodes, 3, ifos) + opts.do_dag_categories, parentNodes, parentVetoNodes, \ + veto_categories, ifos) if opts.run_playground and opts.run_full_data: @@ -612,51 +712,32 @@ if opts.run_plots: else: parentNodes = None if opts.run_data_quality and opts.run_playground: - parentVetoNodes = [hipePlayVetoNode[3], hipeAnalysisVetoNode[3]] + parentVetoNodes = [hipePlayVetoNode, hipeAnalysisVetoNode] else: parentVetoNodes = None # make the playground slide/zerolag plots print "Making plots with full data slides, playground zero lag" dag = inspiralutils.zeroSlidePlots(dag, "full_data_slide_summary_plots", \ cp, opts.log_path, "PLAYGROUND", "FULL_DATA", "../" + cachefilename, \ - opts.do_dag_categories, parentNodes, parentVetoNodes, 3, ifos) + opts.do_dag_categories, parentNodes, parentVetoNodes, \ + veto_categories, ifos) + + if opts.run_full_data: - # Setting up plots for hardware injection run. - - if opts.run_hardware_injections: - print "Making plots depending on the hardware injection" + # set up parents correctly + parentNodes = None + parentVetoNodes = None if opts.run_full_data: - slideSuffix = "FULL_DATA" - elif opts.run_playground: - slideSuffix = "PLAYGROUND" - else: - slideSuffix = "NONE_AVAILABLE" - if opts.run_playground: - zeroLagSuffix = "PLAYGROUND" - else: - zeroLagSuffix = "NONE_AVAILABLE" - # Set up parent Nodes - if opts.run_search: - parentNodes=[hipeHWinjNode] - if opts.run_full_data: - parentNodes.append(hipeAnalysisNode) - if opts.run_playground: - parentNodes.append(hipePlayNode) - else: parentNodes = None + if opts.run_search: + parentNodes = [hipeAnalysisNode] + if opts.run_data_quality: + parentVetoNodes = [hipeAnalysisVetoNode] - if opts.run_data_quality: - parentVetoNodes = [hipeHWinjVetoNode[4]] - if opts.run_full_data: - parentVetoNodes.append(hipeAnalysisVetoNode[3]) - if opts.run_playground: - parentVetoNodes.append(hipePlayVetoNode[3]) - else: parentVetoNodes = None - dag = inspiralutils.injZeroSlidePlots(dag,\ - "hardware_injections" + "_summary_plots", hwcp, opts.log_path,\ - "HARDWARE_INJECTIONS", zeroLagSuffix, slideSuffix, \ - "../" + cachefilename, opts.do_dag_categories, parentNodes, - parentVetoNodes, 3, ifos) - print "Making plots of hardware injection runs" + # make the full data slide/zerolag plots + print "Making full data zero lag plots." + dag = inspiralutils.zeroSlidePlots(dag, "full_data_summary_plots", cp, \ + opts.log_path, "FULL_DATA", "FULL_DATA", "../" + cachefilename, \ + opts.do_dag_categories, parentNodes, parentVetoNodes, veto_categories , ifos) # Setting up plots for software injection run. @@ -684,17 +765,17 @@ if opts.run_plots: else: parentNodes = None if opts.run_data_quality: - parentVetoNodes = [hipeInjVetoNode[4][injDir]] + parentVetoNodes = [hipeInjVetoNode[veto_categories[-1]][injDir]] if opts.run_full_data: - parentVetoNodes.append(hipeAnalysisVetoNode[3]) + parentVetoNodes.append(hipeAnalysisVetoNode[veto_categories[-1]]) if opts.run_playground: - parentVetoNodes.append(hipePlayVetoNode[3]) + parentVetoNodes.append(hipePlayVetoNode[veto_categories[-1]]) else: parentVetoNodes = None dag = inspiralutils.injZeroSlidePlots(dag, injDir + "_summary_plots", \ cp, opts.log_path, injDir.upper(), zeroLagSuffix, slideSuffix, \ "../" + cachefilename, opts.do_dag_categories, parentNodes, - parentVetoNodes, 3, ifos) + parentVetoNodes, veto_categories, ifos) print "Making plots of all injection runs together" @@ -708,37 +789,21 @@ if opts.run_plots: else: parentNodes = None if opts.run_data_quality: - parentVetoNodes = hipeInjVetoNode[4].values() + parentVetoNodes = hipeInjVetoNode[veto_categories[-1]].values() if opts.run_playground: - parentVetoNodes.append(hipePlayVetoNode[3]) + parentVetoNodes.append(hipePlayVetoNode[veto_categories[-1]]) if opts.run_full_data: - parentVetoNodes.append(hipeAnalysisVetoNode[3]) + parentVetoNodes.append(hipeAnalysisVetoNode[veto_categories[-1]]) else: parentVetoNodes = None dag = inspiralutils.injZeroSlidePlots(dag, "allinj_summary_plots", cp, \ opts.log_path, "*INJ", zeroLagSuffix, slideSuffix, \ "../" + cachefilename, opts.do_dag_categories, parentNodes, - parentVetoNodes, 3, ifos) + parentVetoNodes, veto_categories, ifos) if opts.do_dag_categories: dag.add_maxjobs_category('plotting',2) -if opts.generate_results_plots: - # set up parents correctly - parentNodes = None - parentVetoNodes = None - if opts.run_full_data: - if opts.run_search: - parentNodes = [hipeAnalysisNode] - if opts.run_data_quality: - parentVetoNodes = [hipeAnalysisVetoNode[3]] - - # make the full data slide/zerolag plots - print "Making full data zero lag plots." - dag = inspiralutils.zeroSlidePlots(dag, "full_data_summary_plots", cp, \ - opts.log_path, "FULL_DATA", "FULL_DATA", "../" + cachefilename, \ - opts.do_dag_categories, parentNodes, parentVetoNodes, 3, ifos) - ############################################################################## # Set up the directories for followup and run lalapps_followup_pipe if opts.run_followup: @@ -787,14 +852,6 @@ print """\n from a condor submit machine This will also give the expiry time of the proxy.""" -############################################################################## -# cat the cache files together - - -if len(cachelist): - command = "cat " + " ".join(cachelist) + " > " + cachefilename - os.popen(command) - ############################################################################## # write out a log file for this script log_fh = open(basename + '.pipeline.log', 'w') diff --git a/lalapps/src/inspiral/ihope.ini b/lalapps/src/inspiral/ihope.ini index 5c13b1a8dcdf2eff2a639b0bcf4e143814a781be..b25235381b0925a8fa95b40bad1da8da78be4f8e 100644 --- a/lalapps/src/inspiral/ihope.ini +++ b/lalapps/src/inspiral/ihope.ini @@ -122,6 +122,7 @@ hipe = lalapps_inspiral_hipe plot = lalapps_plot_hipe follow = lalapps_followup_pipe datafind = LSCdataFind +pipedown = lalapps_cbc_pipedown segfind = ligolw_segment_query segs_from_cats = ligolw_segments_from_cats ligolw_print = ligolw_print @@ -160,6 +161,19 @@ plotinspinj = plotinspinj plotsnrchi = plotsnrchi plotinspiralrange = plotinspiralrange ploteffdistcut = ploteffdistcut +thinca_to_coinc = ligolw_thinca_to_coinc +ligolw_sqlite = ligolw_sqlite +dbsimplify = ligolw_cbc_dbsimplify +compute_durations = ligolw_cbc_compute_durations +dbaddinj = ligolw_cbc_dbaddinj +inspinjfind = ligolw_inspinjfind +cluster_coincs = ligolw_cbc_cluster_coincs +cfar = ligolw_cbc_cfar +printlc = ligolw_cbc_printlc +minifollowups = minifollowups +plotslides = ligolw_cbc_plotslides +plotcumhist = ligolw_cbc_plotcumhist +plotifar = ligolw_cbc_plotifar ;convertcache= convertlalcache.pl ;qscan = qscan.sh ;plotsnrchisq= plotsnrchisq_pipe.py @@ -819,3 +833,115 @@ page = [seg] ; details of follow-up segments window = 1800 + +; PIPEDOWN SECTIONS +;;;;;;;;;;;;;;;;;;;;;;;;;;; + +[plot_input] +; options common to pipedown plotting commands +enable-output = + +[thinca_to_coinc] +; set options for thinca_to_coinc jobs +search = low_mass +;lars-id = +;effective-snr-factor = 250. + +[ligolw_sqlite] +; set options for ligolw_sqlite jobs +;preserve_ids = +;replace = + +[dbsimplify] +; set options for dbsimplify jobs +;vacuum = + +[compute_durations] +; set options for compute_durations jobs + +[dbaddinj] +; set options for dbaddinj jobs + +[inspinjfind] +; set options for inspinjfind jobs +match-algorithm = inspiral +;force = +;comment = None + +[cluster_coincs] +; set static options for cluster_coinc jobs +; following are required options +cluster-window = 10000 +ranking-stat = snr +rank-by = MAX +; following are optional +param-name = mchirp +param-ranges = [0.87,3.48);[3.48,7.4);[7.4,15.24] +;exclude-coincs = [all in h1,h2];[h1,h2 in all];[h2,l1 in h1,h2,l1] +vacuum = + +[cfar-uncombined] +; set static options for cfar jobs that +; compute uncombined false alarm rates +output-column = false_alarm_rate +ranking-stat = snr +rank-by = MAX +; the following 3 options define a 'category': +; the first 2, what parameter to bin by +; the last, whether or not to bin by coincident +; ifos +param-name = mchirp +param-ranges = [0.87,3.48);[3.48,7.4);[7.4,15.24] +group-by-ifos = +;exclude-coincs = [all in h1,h2];[h1,h2 in all];[h2,l1 in h1,h2,l1] + +[cfar-combined] +; set static options for cfar jobs that +; compute combined false alarm rates +output-column = combined_far +ranking-stat = false_alarm_rate +rank-by = MIN +; no categories are defined when combining; +; however, if only want to combine over param-bins, +; uncomment group-by-ifos +;group-by-ifos = + +[printlc] +; set static options for printlc jobs +output-format = xml +ranking-stat = combined_far +rank-by = MIN +convert-durations = days +limit = 10 + +[minifollowups] +; set static options for minifollowup jobs + +[plotslides] +; set static options for plotslide jobs + +[plotcumhist] +; set static options for plotcumhist jobs +num-bins = 20 +ranking-stat = snr +rank-by = MAX +square-stats = +;param-name = mchirp +;param-ranges = [0.87,3.48);[3.48,7.4);[7.4,15.24] + +[plotifar] +; set static options for plotifar jobs +param-name = mchirp +param-ranges = [0.87,3.48);[3.48,7.4);[7.4,15.24] +plot-uncombined = +;group-by-ifos = +plot-combined = +plot-slides = +show-min-bkg = +show-max-bkg = +show-two-sigma-error = +;x-min = +;x-max = +;y-min = +;y-max = + diff --git a/lalapps/src/inspiral/ihope_status.in b/lalapps/src/inspiral/ihope_status.in index 41794b6a2e51c9cb2da14aaaa158587fb634b7f1..3289fb03ccf1b6b9381ddee547437591cd8fbad2 100755 --- a/lalapps/src/inspiral/ihope_status.in +++ b/lalapps/src/inspiral/ihope_status.in @@ -4,41 +4,36 @@ ihope_status.in - give a brief dag status $Id $ -This script parse a dag file and retrieve the last status line found in the -file. It prints the number of failed/done jobs. +Reads in a dag file and looks for sub dags. The status of each sub dag is +reported as well as the total number of jobs, the number of submitted jobs +and the progress. -If a dag contains other dag, those dags are alos read. +This is specificly designed for use with lalapps_ihope. """ -__author__ = 'Thomas Cokelaer < Thomas.Cokelaer@astro.cf.ac.uk>' +__author__ = 'Thomas Cokelaer < Thomas.Cokelaer@astro.cf.ac.uk>, David Mckechan' __date__ = '$Date$' __version__ = '$Revision$' __name__ = 'ihope_status' import sys -import os -import optparse from optparse import OptionParser -import time +from time import sleep ############################################################################## usage = """\ %prog [options] ----------------- - brief status of the dag +---------------- + Specifically designed for use with lalapps_ihope uber-dags. - Purpose - parse one or several dagman.out file(s) to obtain a brief summary - of the dag status and their rescue files if they exist. + Purpose - parse several dags and their dagman.out file(s) to obtain a + concise summary of the dag status. - Example - You can parse a dag that contains several dag such as ihope.dag - + Example - >>> python %prog --dag-file ihope.dag - - - Or a simple dag: - >>> python %prog --dag-file hipe.dag') """ @@ -68,75 +63,65 @@ options, args = parse_command_line() ############################################################################## -def get_status(filename, depth, totals, debug=False): +def get_status(filename, totals, debug=False): """ parse a dag filem search for failed/done jobs @param filename: name of a dag file to parse - @param depth: used for the tabbing @param totals: cumulitive number of jobs in each category - @return output_message - @return error_message - @return number_of_failed_jobs + @return status_int """ - space = " " - tab ="" - for i in range(0,depth): - tab = tab + space + tab = " " + dag_status = 0 + num = 0 + output = 0 try: - thisdag = open(filename, 'r') + thisdag = open(filename + '.dagman.out', 'r') except: - if debug==True: - print "This file does not exists ("+filename+")" - return [], "fileError", -1 - print tab + '--> parsing '+ filename - - #line = thisdag.readline() - #if not line: - # return [], "emptyFile", -1 - - line = "dummy" - status = [] - error = [] - countline = 0 - while line: - line = thisdag.readline() - if line.find('Done')>=0: - output = tab + line - line = thisdag.readline() - output = output + tab + line - #read the numbers + dag_status = -1 + + if dag_status == 0: + line = "dummy" + while line: line = thisdag.readline() - numbers = line.split(" ") - num = line - number_of_failed_jobs = int(numbers[len(numbers)-1]) - - output = output + tab + line - # count the number of jobs - num=num.split() - num = num[2:] - s = 0 - for i in num: - s = s+ int(i) - njobs = s - # and failed or unready - s = 0 - for i in num[1:]: - s = s+ int(i) - number_of_failed_jobs = s - # adjust totals - for i in xrange( len( num ) ): - totals[i] += int(num[i]) - + if line.find('Done')>=0: + output = tab + line + line = thisdag.readline() + output = output + tab + line + #read the numbers + line = thisdag.readline() + #numbers = line.split(" ") + num = line + #number_of_undone_jobs = int(numbers[len(numbers)-1]) + output = output + tab + line + if line.find('EXITING WITH STATUS 0')>=0: + dag_status = 1 + + # count the number of jobs + if num != 0: + num=num.split() + num = num[2:] + for i in xrange( len( num ) ): + totals[i] += int(num[i]) + + elif dag_status == -1: + try: + thisdag = open(filename, 'r') + except: + dag_status = -2 + + if dag_status == -1: + line = "dummy" + while line: + line = thisdag.readline() + if line.find('.sub')>=0: + totals[7] += 1 - if len(output)>0: - print output - else: - print "No line matches \"Done or Failed\" as expected... " - print error + if output != 0: + print output[:-1] - return output, error, number_of_failed_jobs + return dag_status # @@ -155,15 +140,16 @@ def get_status(filename, depth, totals, debug=False): by itself, and in such case we search for the .dagman.out file. """ -print 'Parsing ' +options.dag_file + '...' -time.sleep(1) +print 'Parsing ' + options.dag_file + '...' +sleep(1.5) -# Need path path for dub dags +# Need path path for sub dags if '/' in options.dag_file: path = options.dag_file[:( options.dag_file.rindex( '/' ) + 1 )] else: path = '' +# Look for sub dags dagFile = open(options.dag_file, 'r') filenames = [] lines = dagFile.readlines() @@ -172,72 +158,80 @@ for line in lines: strs = line.split() if "DIR" in strs: fname = strs[-1] + "/" - else: - fname = "" for string in strs: if "dag" in string: fname += string.strip(".condor.sub") - filenames.append(fname) - print 'Found ' + fname + filenames.append(fname) dagFile.close() if len(filenames)==0: print 'No dag files found in ' + options.dag_file print 'Assuming that ' + options.dag_file + ' is the dag file you want to parse' - filenames.append(options.dag_file) - + filenames.append( options.dag_file[len(path):] ) + sub_dags = 0 +else: + sub_dags = len( filenames ) + print 'Found', str( sub_dags ), 'subdags' +done_dags = 0 + +for file in filenames: + print path + file print 'Parsing the dag files for status...\n' ### we found some dag files hopefully -time.sleep(1) +sleep(1.5) +totals = [0,0,0,0,0,0,0,0] #parse all the dags one by one -totals = [0,0,0,0,0,0,0] for i in xrange(0,len(filenames), 1): - tag = filenames[i] - filename = tag +'.dagman.out' - - # if sub dags add path - if path != '' and path not in filename: - filename = path + filename - + filename = path + filenames[i] - undone_jobs = 111 #dummy value - depth = 0 # used for tabulating rescue files print '-------------------------------------------------------------------------' - while undone_jobs is not 0: - # How many jobs are completed/failed ? - output, error, undone_jobs = get_status(filename, depth, totals) - tag = tag+'.rescue' - filename = tag + '.dagman.out' - depth = depth + 1 - # If no file found, we stop this dag parsing - if len(error)>0: -# print error - break + # How many jobs are completed/failed ? + print "Parsing " + filenames[i] + + status = get_status(filename, totals) - # This dag has been parsed. Where they any failures ? - if undone_jobs >0: - print " WARNING: still " +str(undone_jobs) + "jobs not done" - if error=="emptyFile": - print "empty file" - if undone_jobs==0: - print filenames[i]+" is COMPLETED" -# print '-------------------------------------------------------------------------\n' + if status==1: + done_dags += 1 + print "COMPLETE :)" + elif status==0: + print "incomplete :(" + elif status==-1: + print "dag not yet started!" + elif status==-2: + print "dag NOT FOUND!" -# Print totals -print " Done =", totals[0] -print " Pre =", totals[1] -print " Queued =", totals[2] -print " Post =", totals[3] -print " Ready =", totals[4] -print " Unready =", totals[5] -print " Failed =", totals[6] -print " --------------------------- " -print " Total jobs =", sum( totals ) -print " --------------------------- " - +# Print totals +print " --------------------------- " +print " Done =", totals[0] +#print " Pre =", totals[1] +print " Queued =", totals[2] +#print " Post =", totals[3] +print " Ready =", totals[4] +print " Unready =", totals[5] +print " Failed =", totals[6] +print " ----------------------------------- " +print " Completed Jobs = " + str( totals[0] ) +print " Submitted Jobs = " + str( sum( totals[:7] ) ) +print " Total Jobs = " + str( sum(totals[:]) ) +if sub_dags != 0: + print " Sub-dags =", str( done_dags ) + "/" + str( sub_dags ) +print " ----------------------------------- " + +# Confirm if completed +dagFile = open(options.dag_file + '.dagman.out', 'r') +uber = 0 +lines = dagFile.readlines() +for line in lines: + if "EXITING WITH STATUS 0" in line: + uber = 1 +if uber == 1: + print " ihope status... COMPLETED!" +else: + print " ihope status... incomplete." +print "" diff --git a/lalapps/src/inspiral/inca.c b/lalapps/src/inspiral/inca.c index 43ea1effeb1cfbc5c9a901a64a2d80f6f527dd12..58abec60aa79e3f945c1ca0a4638c60e20800816 100644 --- a/lalapps/src/inspiral/inca.c +++ b/lalapps/src/inspiral/inca.c @@ -131,7 +131,6 @@ RCSID("$Id$"); int main( int argc, char *argv[] ) { static LALStatus status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; extern int vrbflg; static INT4 writeUniqTrigs = 0; @@ -252,20 +251,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = processParamsTable.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -594,7 +592,7 @@ int main( int argc, char *argv[] ) "Patrick Brady, Duncan Brown and Steve Fairhurst\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -1663,8 +1661,7 @@ cleanexit: snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "%s%s", ifoName[0], ifoName[1] ); } - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/injcut.c b/lalapps/src/inspiral/injcut.c index e3ec1bdc1b51134ad9238882fcc248f65c3980a2..d8c2e647c191f78373b1dbfe3e319925f2d66c03 100644 --- a/lalapps/src/inspiral/injcut.c +++ b/lalapps/src/inspiral/injcut.c @@ -81,17 +81,17 @@ RCSID( "$Id$" ); /* all units are in kpc since this is what GalacticInspiralParamStruc expects */ static ProcessParamsTable *next_process_param( - const char *name, - const char *type, - const char *fmt, ... ); + const char *name, + const char *type, + const char *fmt, ... ); extern int vrbflg; ProcessParamsTable *next_process_param( - const char *name, - const char *type, - const char *fmt, ... ) + const char *name, + const char *type, + const char *fmt, ... ) { ProcessParamsTable *pp; va_list ap; @@ -119,7 +119,6 @@ ProcessParamsTable *next_process_param( int main( int argc, char *argv[] ) { LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* command line options */ CHAR *massCut = NULL; /* mass cut type */ REAL4 minMass = -1; /* minimum mass */ @@ -168,20 +167,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) @@ -333,7 +331,7 @@ int main( int argc, char *argv[] ) "Drew Keppel\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -477,8 +475,7 @@ int main( int argc, char *argv[] ) /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable, diff --git a/lalapps/src/inspiral/inspfrinj.c b/lalapps/src/inspiral/inspfrinj.c index f6281e7638361c3fc1b51a8f6e4d25f2851cef79..e781766269fec90639673737e246594988df4186 100644 --- a/lalapps/src/inspiral/inspfrinj.c +++ b/lalapps/src/inspiral/inspfrinj.c @@ -157,7 +157,6 @@ int main( int argc, char *argv[] ) { /* lal function variables */ LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* frame input data */ FrCache *frInCache = NULL; @@ -213,20 +212,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -750,8 +748,7 @@ int main( int argc, char *argv[] ) /* write the process table */ if ( vrbflg ) fprintf( stdout, " process table...\n" ); snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "%s", ifo ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, proctable, @@ -1353,7 +1350,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) "Steve Fairhurst <sfairhur@gravity.phys.uwm.edu>\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; diff --git a/lalapps/src/inspiral/inspinj.c b/lalapps/src/inspiral/inspinj.c index 4782b6f3eb1c58b681709274b0c37cde0a0ce529..ecb6e2b9f6dbe2cd6b2435f01057ab5f0a386c5f 100644 --- a/lalapps/src/inspiral/inspinj.c +++ b/lalapps/src/inspiral/inspinj.c @@ -44,6 +44,7 @@ #include <processtable.h> #include <lal/lalGitID.h> #include <lalappsGitID.h> +#include <lal/Ring.h> RCSID( "$Id$" ); @@ -70,6 +71,7 @@ snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, format, ppvalue ); * Definition of the prototypes * ********************************* */ +extern int vrbflg; ProcessParamsTable *next_process_param( const char *name, const char *type, const char *fmt, ... ); void read_mass_data( char *filename ); @@ -96,6 +98,7 @@ MassDistribution mDistr; InclDistribution iDistr; SimInspiralTable *simTable; +SimRingdownTable *simRingTable; char *massFileName = NULL; char *nrFileName = NULL; @@ -121,8 +124,8 @@ REAL4 massStdev2=-1.0; REAL4 minMassRatio=-1.0; REAL4 maxMassRatio=-1.0; REAL4 inclStd=-1.0; -REAL4 fixed_inc=0.0; -REAL4 psi=0.0; +REAL4 fixed_inc=-1.0; +REAL4 psi=-1.0; REAL4 longitude=181.0; REAL4 latitude=91.0; REAL4 epsAngle=1e-7; @@ -136,6 +139,7 @@ REAL4 maxKappa1=1.0; REAL4 minabsKappa1=0.0; REAL4 maxabsKappa1=1.0; INT4 bandPassInj = 0; +INT4 writeSimRing = 0; InspiralApplyTaper taperInj = INSPIRAL_TAPER_NONE; @@ -290,6 +294,8 @@ static void print_usage(char *program) " gaussian: gaussian mass distribution\n"\ " log: log distribution in comonent mass\n"\ " totalMassRatio: uniform distribution in total mass ratio\n"\ + " logTotalMassUniformMassRatio: log distribution in total mass\n"\ + " and uniform in total mass ratio\n"\ " [--mass-file] mFile read population mass parameters from mFile\n"\ " [--nr-file] nrFile read mass/spin parameters from xml nrFile\n"\ " [--min-mass1] m1min set the minimum component mass to m1min\n"\ @@ -326,6 +332,9 @@ static void print_usage(char *program) " [--taper-injection] OPT Taper the inspiral template using option OPT\n"\ " (start|end|startend) \n)"\ " [--band-pass-injection] sets the tapering method of the injected waveform\n"\ + "\n"\ + "Output:\n"\ + " [--write-sim-ring] Writes a sim_ringdown table\n"\ "\n"); } @@ -833,7 +842,6 @@ void drawFromSource( REAL8 *rightAscension, void drawLocationFromExttrig( SimInspiralTable* table ) { LIGOTimeGPS timeGRB; /* real time of the GRB */ - LALMSTUnitsAndAcc unitsAndAcc; REAL4 ra_rad, de_rad; REAL8 gmst1, gmst2; @@ -841,16 +849,12 @@ void drawLocationFromExttrig( SimInspiralTable* table ) ra_rad = exttrigHead->event_ra * LAL_PI_180; de_rad = exttrigHead->event_dec * LAL_PI_180; - /* set units and accuracy for GMST calculation*/ - unitsAndAcc.accuracy = LALLEAPSEC_STRICT; - unitsAndAcc.units = MST_RAD; - /* populate the time structures */ timeGRB.gpsSeconds = exttrigHead->start_time; timeGRB.gpsNanoSeconds = exttrigHead->start_time_ns; - LALGPStoGMST1( &status, &gmst1, &timeGRB, &unitsAndAcc ); - LALGPStoGMST1( &status, &gmst2, &table->geocent_end_time, &unitsAndAcc ); + gmst1 = XLALGreenwichMeanSiderealTime(&timeGRB); + gmst2 = XLALGreenwichMeanSiderealTime(&table->geocent_end_time); /* populate the table */ table->longitude = ra_rad- gmst1 + gmst2; @@ -886,10 +890,10 @@ int main( int argc, char *argv[] ) /* xml output data */ CHAR fname[256]; CHAR *userTag = NULL; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; MetadataTable proctable; MetadataTable procparams; MetadataTable injections; + MetadataTable ringparams; ProcessParamsTable *this_proc_param; LIGOLwXMLStream xmlfp; @@ -907,6 +911,7 @@ int main( int argc, char *argv[] ) struct option long_options[] = { {"help", no_argument, 0, 'h'}, + {"verbose", no_argument, &vrbflg, 1 }, {"source-file", required_argument, 0, 'f'}, {"mass-file", required_argument, 0, 'm'}, {"nr-file", required_argument, 0, 'c'}, @@ -963,6 +968,7 @@ int main( int argc, char *argv[] ) {"write-compress", no_argument, &outCompress, 1}, {"taper-injection", required_argument, 0, '*'}, {"band-pass-injection", no_argument, 0, '}'}, + {"write-sim-ring", no_argument, 0, '{'}, {0, 0, 0, 0} }; int c; @@ -974,20 +980,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) @@ -1245,11 +1250,14 @@ int main( int argc, char *argv[] ) { mDistr=uniformTotalMassRatio; } + else if (!strcmp(dummy, "logTotalMassUniformMassRatio")) + mDistr=logMassUniformTotalMassRatio; else { fprintf( stderr, "invalid argument to --%s:\n" "unknown mass distribution: %s must be one of\n" - "(source, nrwaves, totalMass, componentMass, gaussian, log, totalMassRatio)\n", + "(source, nrwaves, totalMass, componentMass, gaussian, log,\n" + "totalMassRatio, logTotalMassUniformMassRatio)\n", long_options[option_index].name, optarg ); exit( 1 ); } @@ -1336,7 +1344,7 @@ int main( int argc, char *argv[] ) maxMassRatio = atof( optarg ); this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, - "float", "%le", minMassRatio ); + "float", "%le", maxMassRatio ); break; case 'p': @@ -1485,7 +1493,7 @@ int main( int argc, char *argv[] ) if (latitude <= ( LAL_PI/2. + epsAngle ) && \ latitude >= ( -LAL_PI/2. - epsAngle )) { - this_proc_param = this_proc_param->next = + this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", latitude ); } @@ -1561,6 +1569,13 @@ int main( int argc, char *argv[] ) case 'S': /* set the polarization angle */ psi = (REAL4) atof( optarg )/180.*LAL_PI; + if ( (atof(optarg) < 0.) || (atof(optarg) >= 360.) ) { + fprintf( stderr, "invalid argument to --%s:\n" + "polarization angle must be between 0 and 360 degrees: " + "(%s specified)\n", + long_options[option_index].name, optarg ); + exit( 1 ); + } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", psi ); @@ -1637,7 +1652,7 @@ int main( int argc, char *argv[] ) "The CBC group \n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -1665,6 +1680,14 @@ int main( int argc, char *argv[] ) bandPassInj = 1; break; + case '{': + /* write out a sim_ringdown table */ + this_proc_param = this_proc_param->next = + next_process_param( long_options[option_index].name, "string", + "" ); + writeSimRing = 1; + break; + case '*': /* Set injection tapering */ if ( ! strcmp( "start", optarg ) ) @@ -1701,6 +1724,10 @@ int main( int argc, char *argv[] ) exit( 1 ); break; + case 'vv': + vrbflg = 1; + break; + default: fprintf( stderr, "unknown error while parsing options\n" ); print_usage(argv[0]); @@ -1868,13 +1895,20 @@ int main( int argc, char *argv[] ) } /* check inclination distribution */ - if ( iDistr==gaussianInclDist && inclStd<0.0 ) + if ( ( iDistr == gaussianInclDist ) && ( inclStd < 0.0 ) ) { fprintf( stderr, - "Must specify width for gaussian inclination distribution, "\ + "Must specify width for gaussian inclination distribution; "\ "use --inclStd.\n" ); exit( 1 ); } + if ( ( iDistr == fixedInclDist ) && ( fixed_inc < 0. ) ) + { + fprintf( stderr, + "Must specify an inclination if you want it fixed; "\ + "use --fixed-inc.\n" ); + exit( 1 ); + } /* require --f-lower be explicit */ if ( fLower <= 0.0 ) @@ -1896,7 +1930,7 @@ int main( int argc, char *argv[] ) /* check if the mass area is properly specified */ if ( mDistr!=gaussianMassDist && (minMass1 <=0.0 || minMass2 <=0.0 || - maxMass1 <=0.0 || maxMass2 <=0.0) ) + maxMass1 <=0.0 || maxMass2 <=0.0) ) { fprintf( stderr, "Must specify --min-mass1/2 and --max-mass1/2 if choosing" @@ -1927,11 +1961,12 @@ int main( int argc, char *argv[] ) } /* check if mass ratios are specified */ - if ( mDistr==uniformTotalMassRatio && (minMassRatio < 0.0 || maxMassRatio < 0.0) ) + if ( (mDistr==uniformTotalMassRatio || mDistr==logMassUniformTotalMassRatio) + && (minMassRatio < 0.0 || maxMassRatio < 0.0) ) { fprintf( stderr, "Must specify --min-mass-ratio and --max-mass-ratio if choosing" - " --m-distr=totalMassRatio\n"); + " --m-distr=totalMassRatio or --m-distr=logTotalMassUniformMassRatio\n"); exit( 1 ); } @@ -2019,7 +2054,7 @@ int main( int argc, char *argv[] ) if (meanTimeStep<=0) { fprintf( stderr, - "Minimum time step value must be larger than zero\n" ); + "Minimum time step value must be larger than zero\n" ); exit( 1 ); } @@ -2065,6 +2100,9 @@ int main( int argc, char *argv[] ) simTable = injections.simInspiralTable = (SimInspiralTable *) calloc( 1, sizeof(SimInspiralTable) ); + simRingTable = ringparams.simRingdownTable = (SimRingdownTable *) + calloc( 1, sizeof(SimRingdownTable) ); + /* loop over parameter generation until end time is reached */ ninj = 0; currentGpsTime = gpsStartTime; @@ -2103,8 +2141,14 @@ int main( int argc, char *argv[] ) else if ( mDistr==uniformTotalMassRatio ) { simTable=XLALRandomInspiralTotalMassRatio(simTable, randParams, - minMtotal, maxMtotal, minMassRatio, maxMassRatio ); + mDistr, minMtotal, maxMtotal, minMassRatio, maxMassRatio ); + } + else if ( mDistr==logMassUniformTotalMassRatio ) + { + simTable=XLALRandomInspiralTotalMassRatio(simTable, randParams, + mDistr, minMtotal, maxMtotal, minMassRatio, maxMassRatio ); } + else { simTable=XLALRandomInspiralMasses( simTable, randParams, mDistr, minMass1, maxMass1, @@ -2159,28 +2203,32 @@ int main( int argc, char *argv[] ) else { fprintf( stderr, - "Unknown location distribution specified. Possible choices: " - "source, exttrig, random or fixed\n" ); + "Unknown location distribution specified. Possible choices: " + "source, exttrig, random or fixed\n" ); exit( 1 ); } - /* populate orientations */ + /* populate polarization, inclination, and coa_phase */ + do + { + simTable=XLALRandomInspiralOrientation(simTable, randParams, + iDistr, inclStd); + } while ( ! strcmp(waveform, "SpinTaylorthreePointFivePN") && + ( iDistr != fixedInclDist ) && + ( simTable->inclination < eps || + simTable->inclination > LAL_PI-eps) ); + + /* override inclination */ if ( iDistr == fixedInclDist ) { simTable->inclination = fixed_inc; } - else - { - do { - simTable=XLALRandomInspiralOrientation(simTable, randParams, - iDistr, inclStd); - } while ( ! strcmp(waveform, "SpinTaylorthreePointFivePN") && - ( simTable->inclination < eps || - simTable->inclination > LAL_PI-eps) ); - } - /* set polarization angle */ - simTable->polarization = psi; + /* override polarization angle */ + if ( psi != -1.0 ) + { + simTable->polarization = psi; + } /* populate spins, if required */ if (spinInjections) @@ -2224,6 +2272,34 @@ int main( int argc, char *argv[] ) /* populate the bandpass options */ simTable->bandpass = bandPassInj; + + /* populate the sim_ringdown table */ + if ( writeSimRing ) + { + memcpy( simRingTable->waveform, waveform, + sizeof(CHAR) * LIGOMETA_WAVEFORM_MAX ); + simRingTable->geocent_start_time = simTable->geocent_end_time; + simRingTable->h_start_time = simTable->h_end_time; + simRingTable->l_start_time = simTable->l_end_time; + simRingTable->start_time_gmst = simTable->end_time_gmst; + simRingTable->longitude = simTable->longitude; + simRingTable->latitude = simTable->latitude; + simRingTable->distance = simTable->distance; + simRingTable->inclination = simTable->inclination; + simRingTable->polarization = simTable->polarization; + simRingTable->phase = 0; + simRingTable->mass = XLALNonSpinBinaryFinalBHMass(simTable->eta, simTable->mass1, simTable->mass2); + simRingTable->spin = XLALNonSpinBinaryFinalBHSpin(simTable->eta); + simRingTable->frequency = XLALBlackHoleRingFrequency( simRingTable->mass, simRingTable->spin); + simRingTable->quality = XLALBlackHoleRingQuality(simRingTable->spin); + simRingTable->epsilon = 0; + simRingTable->amplitude = 0; + simRingTable->eff_dist_h = simTable->eff_dist_h; + simRingTable->eff_dist_l = simTable->eff_dist_l; + simRingTable->hrss = 0; + simRingTable->hrss_h = 0; + simRingTable->hrss_l = 0; + } /* increment current time, avoiding roundoff error; check if end of loop is reached */ @@ -2231,10 +2307,13 @@ int main( int argc, char *argv[] ) XLALGPSAdd(¤tGpsTime, ninj * meanTimeStep); if ( XLALGPSCmp( ¤tGpsTime, &gpsEndTime ) >= 0 ) break; - - /* allocate and go to next SimInspiralTable */ + + /* allocate and go to next SimInspiralTable */ simTable = simTable->next = (SimInspiralTable *) calloc( 1, sizeof(SimInspiralTable) ); + simRingTable = simRingTable->next = (SimRingdownTable *) + calloc( 1, sizeof(SimRingdownTable) ); + } @@ -2261,8 +2340,7 @@ int main( int argc, char *argv[] ) LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlfp, fname ), &status ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable, @@ -2287,6 +2365,18 @@ int main( int argc, char *argv[] ) LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status ); } + if ( writeSimRing ) + { + if ( ringparams.simRingdownTable ) + { + LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, sim_ringdown_table ), + &status ); + LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, ringparams, + sim_ringdown_table ), &status ); + LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status ); + } + } + LAL_CALL( LALCloseLIGOLwXMLFile ( &status, &xmlfp ), &status ); if (source_data) diff --git a/lalapps/src/inspiral/inspiral.c b/lalapps/src/inspiral/inspiral.c index 570905150031668e2fc63db562d21610b2295650..fe9a9729026399dfb21c955c35b7d70fb23a80dd 100644 --- a/lalapps/src/inspiral/inspiral.c +++ b/lalapps/src/inspiral/inspiral.c @@ -201,6 +201,14 @@ enum specType_undefined } specType = specType_undefined; +/* set the spectrum for colored Gaussian noise */ +enum +{ + colorSpec_LIGO, + colorSpec_AdvLIGO, + colorSpec_undefined +} colorSpec = colorSpec_undefined; + INT4 badMeanPsd = 0; /* use a mean with no overlap */ INT4 invSpecTrunc = -1; /* length of inverse spec (s) */ REAL4 dynRangeExponent = -1; /* exponent of dynamic range */ @@ -248,8 +256,6 @@ INT4 randomSeed = 0; /* value of sim rand seed */ REAL4 gaussVar = 64.0; /* variance of Gaussian noise */ INT4 whiteGaussian = 0; /* make input data Gaussian */ INT4 unitResponse = 0; /* set the response to unity */ -INT4 colorSpec = 0; /* set the spectrum for colored */ - /* Gaussian noise */ INT4 coloredGaussian = 0; /* generate colored Gaussian */ /* noise */ /* template bank simulation params */ @@ -314,7 +320,6 @@ int main( int argc, char *argv[] ) { /* lal function variables */ LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* frame input data */ FrCache *frInCache = NULL; @@ -333,7 +338,7 @@ int main( int argc, char *argv[] ) FrameHNode *thisCoherentFrame = NULL; UINT4 nRhosqFr = 0; UINT4 nChisqFr = 0; - REAL4TimeSeries templateTimeSeries; + REAL4TimeSeries templateTimeSeries; REAL4Vector *templateTimeSeriesVector = NULL; /* raw input data storage */ REAL4TimeSeries chan; @@ -444,7 +449,7 @@ int main( int argc, char *argv[] ) UINT4 *analyseThisTmplt = NULL; INT4 thisTemplateIndex = 0; UINT4 analyseTag; - + /* * @@ -459,20 +464,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -502,7 +506,7 @@ int main( int argc, char *argv[] ) /* populate the filter table */ snprintf( filtertable.filterTable->program, LIGOMETA_PROGRAM_MAX, "%s", - PROGRAM_NAME ); + PROGRAM_NAME ); filtertable.filterTable->start_time = gpsStartTime.gpsSeconds; snprintf( filtertable.filterTable->filter_name, LIGOMETA_COMMENT_MAX, "%s%s", approximantName, orderName ); @@ -516,39 +520,39 @@ int main( int argc, char *argv[] ) else { snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, - "%s", comment ); + "%s", comment ); snprintf( filtertable.filterTable->comment, LIGOMETA_COMMENT_MAX, - "%s", comment ); + "%s", comment ); } /* put the name of the search in the search_summary comment */ snprintf( searchsumm.searchSummaryTable->comment, LIGOMETA_COMMENT_MAX, - "%s%s", approximantName, orderName ); + "%s%s", approximantName, orderName ); /* set the name of the output file */ if ( userTag && ifoTag ) { snprintf( fileName, FILENAME_MAX, "%s-INSPIRAL_%s_%s-%d-%d", ifo, - ifoTag, userTag, gpsStartTime.gpsSeconds, - gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + ifoTag, userTag, gpsStartTime.gpsSeconds, + gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } else if ( userTag && !ifoTag ) { snprintf( fileName, FILENAME_MAX, "%s-INSPIRAL_%s-%d-%d", ifo, - userTag, gpsStartTime.gpsSeconds, - gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + userTag, gpsStartTime.gpsSeconds, + gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } else if ( !userTag && ifoTag ) { snprintf( fileName, FILENAME_MAX, "%s-INSPIRAL_%s-%d-%d", ifo, - ifoTag, gpsStartTime.gpsSeconds, - gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + ifoTag, gpsStartTime.gpsSeconds, + gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } else { snprintf( fileName, FILENAME_MAX, "%s-INSPIRAL-%d-%d", ifo, - gpsStartTime.gpsSeconds, - gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); + gpsStartTime.gpsSeconds, + gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } /* the number of nodes for a standalone job is always 1 */ @@ -606,7 +610,7 @@ int main( int argc, char *argv[] ) if ( ! bankSim && ( trigStartTimeNS && (trigStartTimeNS > outTimeNS) ) ) { XLALINT8NSToGPS( &(searchsumm.searchSummaryTable->out_start_time), - trigStartTimeNS ); + trigStartTimeNS ); } searchsumm.searchSummaryTable->out_end_time.gpsSeconds = @@ -617,7 +621,7 @@ int main( int argc, char *argv[] ) if ( ! bankSim && ( trigEndTimeNS && (trigEndTimeNS < outTimeNS) ) ) { XLALINT8NSToGPS( &(searchsumm.searchSummaryTable->out_end_time), - trigEndTimeNS ); + trigEndTimeNS ); } } @@ -671,8 +675,8 @@ int main( int argc, char *argv[] ) /* sieve out the requested data type */ memset( &sieve, 0, sizeof(FrCacheSieve) ); snprintf( ifoRegExPattern, - sizeof(ifoRegExPattern) / sizeof(*ifoRegExPattern), ".*%c.*", - fqChanName[0] ); + sizeof(ifoRegExPattern) / sizeof(*ifoRegExPattern), ".*%c.*", + fqChanName[0] ); sieve.srcRegEx = ifoRegExPattern; sieve.dscRegEx = frInType; LAL_CALL( LALFrCacheSieve( &status, &frInCache, frGlobCache, &sieve ), @@ -718,7 +722,7 @@ int main( int argc, char *argv[] ) /* copy the data paramaters from the h(t) channel to input data channel */ snprintf( chan.name, LALNameLength * sizeof(CHAR), "%s", - strainChan.name ); + strainChan.name ); chan.epoch = strainChan.epoch; chan.deltaT = strainChan.deltaT; chan.f0 = strainChan.f0; @@ -815,7 +819,7 @@ int main( int argc, char *argv[] ) /* re-copy the data paramaters from the h(t) channel to input data channel*/ snprintf( chan.name, LALNameLength * sizeof(CHAR), "%s", - strainChan.name ); + strainChan.name ); chan.epoch = strainChan.epoch; chan.deltaT = strainChan.deltaT; chan.f0 = strainChan.f0; @@ -974,7 +978,7 @@ int main( int argc, char *argv[] ) &status ); LAL_CALL( LALDCreateVector( &status, &spectrum, length / 2 + 1 ), &status ); - if (colorSpec == 3 ) + if (colorSpec == colorSpec_LIGO ) { /* set the spectrum to the Initial LIGO design noise curve */ REAL8 psd_value; @@ -990,7 +994,7 @@ int main( int argc, char *argv[] ) spectrum->data[k] = 9.0e-46 * psd_value * dynRange * dynRange; } } - else if( colorSpec == 4) + else if( colorSpec == colorSpec_AdvLIGO ) { /* set the spectrum to the Advanced LIGO design noise curve */ REAL8 psd_value; @@ -1099,7 +1103,7 @@ int main( int argc, char *argv[] ) { calGlobPattern = (CHAR *) LALCalloc( calGlobLen, sizeof(CHAR) ); snprintf( calGlobPattern, calGlobLen * sizeof(CHAR), - "*CAL*%s*.gwf", ifo ); + "*CAL*%s*.gwf", ifo ); if ( vrbflg ) fprintf( stdout, "globbing for %s calibration frame files " "in current directory\n", calGlobPattern ); } @@ -1121,10 +1125,10 @@ int main( int argc, char *argv[] ) this_search_summvar = this_search_summvar->next = (SearchSummvarsTable *) LALCalloc( 1, sizeof(SearchSummvarsTable) ); snprintf( this_search_summvar->name, LIGOMETA_NAME_MAX * sizeof(CHAR), - "calibration frame %d", i ); + "calibration frame %d", i ); snprintf( this_search_summvar->string, - LIGOMETA_STRING_MAX * sizeof(CHAR), "%s", - calCache->frameFiles[i].url ); + LIGOMETA_STRING_MAX * sizeof(CHAR), "%s", + calCache->frameFiles[i].url ); } /* get the response from the frame data */ @@ -1300,7 +1304,7 @@ int main( int argc, char *argv[] ) { calGlobPattern = (CHAR *) LALCalloc( calGlobLen, sizeof(CHAR) ); snprintf( calGlobPattern, calGlobLen * sizeof(CHAR), - "*CAL*%s*.gwf", ifo ); + "*CAL*%s*.gwf", ifo ); if ( vrbflg ) fprintf( stdout, "globbing for %s calibration frame files " "in current directory\n", calGlobPattern ); @@ -1324,11 +1328,11 @@ int main( int argc, char *argv[] ) (SearchSummvarsTable *) LALCalloc( 1, sizeof(SearchSummvarsTable) ); snprintf( this_search_summvar->name, - LIGOMETA_NAME_MAX * sizeof(CHAR), - "injection calibration frame %d", i ); + LIGOMETA_NAME_MAX * sizeof(CHAR), + "injection calibration frame %d", i ); snprintf( this_search_summvar->string, - LIGOMETA_STRING_MAX * sizeof(CHAR), "%s", - calCache->frameFiles[i].url ); + LIGOMETA_STRING_MAX * sizeof(CHAR), "%s", + calCache->frameFiles[i].url ); } /* extract the calibration from frames */ @@ -1387,15 +1391,15 @@ int main( int argc, char *argv[] ) /* read the event waveform approximant to see if we've been asked to perform NumRel injections */ LAL_CALL( LALGetApproximantFromString( &status, injections->waveform, - &injApproximant ), &status); + &injApproximant ), &status); if (injApproximant == NumRel) { REAL4TimeVectorSeries *tempStrain=NULL; - /* loop over injections */ + /* loop over injections */ for ( thisInj = injections; thisInj; thisInj = thisInj->next ) - { + { LAL_CALL( AddNumRelStrainModes( &status, &tempStrain, thisInj), &status); @@ -1411,8 +1415,8 @@ int main( int argc, char *argv[] ) } else { - LAL_CALL( LALFindChirpInjectSignals( &status, &chan, injections, - injRespPtr ), &status ); + LAL_CALL( LALFindChirpInjectSignals( &status, &chan, injections, + injRespPtr ), &status ); } snprintf( chan.name, LALNameLength * sizeof(CHAR), "%s", tmpChName ); @@ -1481,7 +1485,7 @@ int main( int argc, char *argv[] ) if ( ckptPath[0] ) { snprintf( fname, FILENAME_MAX * sizeof(CHAR), "%s/%s.ckpt", - ckptPath, fileName ); + ckptPath, fileName ); } else { @@ -1585,7 +1589,7 @@ int main( int argc, char *argv[] ) { /* override with trigger end time */ XLALINT8NSToGPS( &(searchsumm.searchSummaryTable->out_end_time), - trigEndTimeNS ); + trigEndTimeNS ); } /* @@ -2449,7 +2453,7 @@ int main( int argc, char *argv[] ) { CHAR snrsqStr[LALNameLength]; snprintf( snrsqStr, LALNameLength*sizeof(CHAR), - "SNRSQ_%d", nRhosqFr++ ); + "SNRSQ_%d", nRhosqFr++ ); strcpy( fcFilterParams->rhosqVec->name, chan.name ); outFrame = fr_add_proc_REAL4TimeSeries( outFrame, fcFilterParams->rhosqVec, "none", snrsqStr ); @@ -2591,6 +2595,8 @@ int main( int argc, char *argv[] ) if ( trigTime >= lowerBound && trigTime <= upperBound ) { + REAL8 sigmasq = 0.0; + tempTmplt = (SnglInspiralTable *) LALCalloc(1, sizeof(SnglInspiralTable) ); tempTmplt->event_id = (EventIDColumn *) @@ -2600,22 +2606,53 @@ int main( int argc, char *argv[] ) bankCurrent->end_time.gpsSeconds; tempTmplt->end_time.gpsNanoSeconds = bankCurrent->end_time.gpsNanoSeconds; - tempTmplt->event_id->id = bankCurrent->event_id->id; + if (bankCurrent->event_id) + tempTmplt->event_id->id = bankCurrent->event_id->id; + else tempTmplt->event_id->id = 0; + + if ( ! eventList ) { + UINT4 kmax; + REAL8 deltaF=0.0; + + /* Compute sigmasq for coherent statistic */ + deltaF = 1.0 / ( (REAL4) fcFilterParams->deltaT * + (REAL4) fcFilterParams->qVec->length ); + + kmax = fcFilterInput->fcTmplt->tmplt.fFinal / deltaF < + fcFilterParams->qVec->length/2 ? + fcFilterInput->fcTmplt->tmplt.fFinal / deltaF : + fcFilterParams->qVec->length/2; + + sigmasq = fcFilterInput->segment->segNorm->data[kmax] * + fcFilterInput->segment->segNorm->data[kmax] * + fcFilterInput->fcTmplt->tmpltNorm * + fcFilterInput->fcTmplt->norm; + + /* If sigmasq is still zero */ + if ( (sigmasq == 0.0) ) + { + REAL4 totalMass = bankCurrent->mass1 + bankCurrent->mass2; + REAL4 mu = bankCurrent->mass1 * bankCurrent->mass2 / totalMass; - tempTmplt->sigmasq = eventList->sigmasq; + sigmasq = candle.sigmasq * pow( totalMass / + (REAL4) candle.tmplt.totalMass,2.0/3.0); + sigmasq *= mu / candle.tmplt.mu; + } + tempTmplt->sigmasq = sigmasq; + } + else { + tempTmplt->sigmasq = eventList->sigmasq; + } LAL_CALL( LALFindChirpCreateCoherentInput( &status, &coherentInputData, fcFilterParams->cVec, tempTmplt, 0.5, numPoints / 4 ), &status ); - LALFree( tempTmplt->event_id ); - LALFree( tempTmplt ); - if ( coherentInputData ) { cDataForFrame = 1; snprintf( cdataStr, LALNameLength*sizeof(CHAR), - "%Ld", bankCurrent->event_id->id ); + "%Ld", tempTmplt->event_id->id ); snprintf( coherentInputData->name, LALNameLength*sizeof(CHAR), "%s:CBC-CData", ifo ); @@ -2636,6 +2673,8 @@ int main( int argc, char *argv[] ) LALFree( coherentInputData ); coherentInputData = NULL; } + LALFree( tempTmplt->event_id ); + LALFree( tempTmplt ); } } @@ -2800,11 +2839,6 @@ int main( int argc, char *argv[] ) /* point the saved events to the linked list of loudest events */ savedEvents.snglInspiralTable = loudestEventHead; } - else - { - /* save the number of events in the search summary table */ - searchsumm.searchSummaryTable->nevents = numEvents; - } /* @@ -2919,7 +2953,7 @@ int main( int argc, char *argv[] ) if ( outputPath[0] ) { snprintf( fname, FILENAME_MAX * sizeof(CHAR), "%s/%s.gwf", - outputPath, fileName ); + outputPath, fileName ); } else { @@ -2944,6 +2978,116 @@ int main( int argc, char *argv[] ) if ( vrbflg ) fprintf( stdout, "done\n" ); } + /* cut triggers based on start/end times and do trig_scan clustering */ + if ( savedEvents.snglInspiralTable ) + { + SnglInspiralTable *tmpEventHead = NULL; + SnglInspiralTable *lastEvent = NULL; + + /* sort the inspiral events by time */ + if ( vrbflg ) fprintf( stdout, " sorting events by time... " ); + LAL_CALL( LALSortSnglInspiral( &status, &(savedEvents.snglInspiralTable), + LALCompareSnglInspiralByTime), &status ); + if ( vrbflg ) fprintf( stdout, "done\n" ); + + /* discard any triggers outside the trig start/end time window */ + event = savedEvents.snglInspiralTable; + if ( ! bankSim && ( trigStartTimeNS || trigEndTimeNS ) ) + { + if ( vrbflg ) fprintf( stdout, + " discarding triggers outside trig start/end time... " ); + + while ( event ) + { + INT8 trigTimeNS; + trigTimeNS = XLALGPSToINT8NS( &(event->end_time) ); + + if ( trigTimeNS && + ((trigStartTimeNS && (trigTimeNS < trigStartTimeNS)) || + (trigEndTimeNS && (trigTimeNS >= trigEndTimeNS))) ) + { + /* throw this trigger away */ + SnglInspiralTable *tmpEvent = event; + + if ( lastEvent ) + { + lastEvent->next = event->next; + } + + /* increment the linked list by one and free the event */ + event = event->next; + LALFree( tmpEvent ); + } + else + { + /* store the first event as the head of the new linked list */ + if ( ! tmpEventHead ) tmpEventHead = event; + + /* save the last event and increment the linked list by one */ + lastEvent = event; + event = event->next; + } + } + + savedEvents.snglInspiralTable = tmpEventHead; + + if ( vrbflg ) fprintf( stdout, "done\n" ); + } + + if (maximizationInterval) + { + XLALMaxSnglInspiralOverIntervals( &(savedEvents.snglInspiralTable), + maximizationInterval); + } + + /* trigScanClustering */ + if ( trigScanMethod ) + { + if ( savedEvents.snglInspiralTable) + { + + /* Call the clustering routine */ + if (XLALTrigScanClusterTriggers( &(savedEvents.snglInspiralTable), + trigScanMethod, + trigScanMetricScalingFac, + trigScanAppendStragglers ) == XLAL_FAILURE ) + { + fprintf( stderr, "New trig scan has failed!!\n" ); + exit(1); + } + + } + else + { + if ( vrbflg ) + fprintf (stderr, + "The event head appears to be null containing %d triggers \n", + XLALCountSnglInspiral ( (savedEvents.snglInspiralTable) )); + } + } + } + + /* After clustering, count the number of triggers left. */ + if ( ! bankSim) + { + if (savedEvents.snglInspiralTable) + { + numEvents = 1; + eventList = savedEvents.snglInspiralTable; + while ( eventList->next ) + { + eventList = eventList->next; + ++numEvents; + } + searchsumm.searchSummaryTable->nevents = numEvents; + } + else + { + searchsumm.searchSummaryTable->nevents = 0; + } + } + + /* open the output xml file */ memset( &results, 0, sizeof(LIGOLwXMLStream) ); if ( outputPath[0] ) @@ -2976,8 +3120,7 @@ int main( int argc, char *argv[] ) /* write the process table */ if ( vrbflg ) fprintf( stdout, " process table...\n" ); snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "%s", ifo ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, proctable, @@ -3074,94 +3217,6 @@ int main( int argc, char *argv[] ) /* free the search summary table after the summ_value table is written */ free( searchsumm.searchSummaryTable ); - /* cut triggers based on start/end times and do trig_scan clustering */ - if ( savedEvents.snglInspiralTable ) - { - SnglInspiralTable *tmpEventHead = NULL; - SnglInspiralTable *lastEvent = NULL; - - /* sort the inspiral events by time */ - if ( vrbflg ) fprintf( stdout, " sorting events by time... " ); - LAL_CALL( LALSortSnglInspiral( &status, &(savedEvents.snglInspiralTable), - LALCompareSnglInspiralByTime), &status ); - if ( vrbflg ) fprintf( stdout, "done\n" ); - - /* discard any triggers outside the trig start/end time window */ - event = savedEvents.snglInspiralTable; - if ( ! bankSim && ( trigStartTimeNS || trigEndTimeNS ) ) - { - if ( vrbflg ) fprintf( stdout, - " discarding triggers outside trig start/end time... " ); - - while ( event ) - { - INT8 trigTimeNS; - trigTimeNS = XLALGPSToINT8NS( &(event->end_time) ); - - if ( trigTimeNS && - ((trigStartTimeNS && (trigTimeNS < trigStartTimeNS)) || - (trigEndTimeNS && (trigTimeNS >= trigEndTimeNS))) ) - { - /* throw this trigger away */ - SnglInspiralTable *tmpEvent = event; - - if ( lastEvent ) - { - lastEvent->next = event->next; - } - - /* increment the linked list by one and free the event */ - event = event->next; - LALFree( tmpEvent ); - } - else - { - /* store the first event as the head of the new linked list */ - if ( ! tmpEventHead ) tmpEventHead = event; - - /* save the last event and increment the linked list by one */ - lastEvent = event; - event = event->next; - } - } - - savedEvents.snglInspiralTable = tmpEventHead; - - if ( vrbflg ) fprintf( stdout, "done\n" ); - } - - if (maximizationInterval) - { - XLALMaxSnglInspiralOverIntervals( &(savedEvents.snglInspiralTable), - maximizationInterval); - } - - /* trigScanClustering */ - if ( trigScanMethod ) - { - if ( savedEvents.snglInspiralTable) - { - - /* Call the clustering routine */ - if (XLALTrigScanClusterTriggers( &(savedEvents.snglInspiralTable), - trigScanMethod, - trigScanMetricScalingFac, - trigScanAppendStragglers ) == XLAL_FAILURE ) - { - fprintf( stderr, "New trig scan has failed!!\n" ); - exit(1); - } - - } - else - { - if ( vrbflg ) - fprintf (stderr, - "The event head appears to be null containing %d triggers \n", - XLALCountSnglInspiral ( (savedEvents.snglInspiralTable) )); - } - } - } /* write sngl_inspiral table */ if ( vrbflg ) fprintf( stdout, " sngl_inspiral table...\n" ); @@ -4412,17 +4467,16 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) break; case '.': - colorSpec = (INT4) atoi( optarg ); if ( ! strcmp( "LIGO", optarg ) ) { - colorSpec = 3; + colorSpec = colorSpec_LIGO; fprintf( stderr, "WARNING: replacing input data with colored Gaussian noise: " "psd = Initial LIGO\n"); } else if ( ! strcmp( "AdvLIGO", optarg ) ) { - colorSpec = 4; + colorSpec = colorSpec_AdvLIGO; fprintf( stderr, "WARNING: replacing input data with colored Gaussian noise: " "psd = Advanced LIGO\n"); @@ -4430,14 +4484,16 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) else { fprintf(stderr,"invalid power spectrum for colored Gaussian noise;" - "colorSpec must be either LIGO or advLIGO"); + "colorSpec must be either LIGO or advLIGO " + "(%f specified)", colorSpec); + exit( 1 ); } coloredGaussian = 1; break; case 'N': if ( snprintf( ckptPath, FILENAME_MAX * sizeof(CHAR), - "%s", optarg ) < 0 ) + "%s", optarg ) < 0 ) { fprintf( stderr, "invalid argument to --%s\n" "local path %s too long: string truncated\n", @@ -4448,7 +4504,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) case 'O': if ( snprintf( outputPath, FILENAME_MAX * sizeof(CHAR), - "%s", optarg ) < 0 ) + "%s", optarg ) < 0 ) { fprintf( stderr, "invalid argument to --%s\n" "output path %s too long: string truncated\n", @@ -4471,7 +4527,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", - PROGRAM_NAME ); + PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "-userTag" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, "%s", @@ -4492,7 +4548,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) "Duncan Brown <duncan@gravity.phys.uwm.edu>\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -4520,8 +4576,8 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) long_options[option_index].name, maxms ); exit( 1 ); } - /* internally we require maximizationInterval to be in nano seconds */ - /* This will be passed as an argument in the call to */ + /* internally we require maximizationInterval to be in nano seconds */ + /* This will be passed as an argument in the call to */ /* XLALMaxSnglInspiralOverIntervals (). Therefore multiply by */ /* 1000000 to convert msec to nano seconds */ maximizationInterval = (INT4) maxms * 1000000; @@ -4729,16 +4785,16 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) break; case '?': - bankSimParams.f_lower = (REAL4) atof( optarg ); - if (bankSimParams.f_lower <= 0 ) - { - fprintf( stderr, "invalid argument to --%s:\n" - "bank-sim-flower must be > 0.0 : " - "(%f specified)\n", - long_options[option_index].name, bankSimParams.f_lower ); - exit( 1 ); - } - ADD_PROCESS_PARAM( "float", "%e", bankSimParams.f_lower ); + bankSimParams.f_lower = (REAL4) atof( optarg ); + if (bankSimParams.f_lower <= 0 ) + { + fprintf( stderr, "invalid argument to --%s:\n" + "bank-sim-flower must be > 0.0 : " + "(%f specified)\n", + long_options[option_index].name, bankSimParams.f_lower ); + exit( 1 ); + } + ADD_PROCESS_PARAM( "float", "%e", bankSimParams.f_lower ); break; case '(': @@ -4860,29 +4916,29 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) if ( enableOutput == 1 ) { snprintf( procparams.processParamsTable->program, - LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); + LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( procparams.processParamsTable->param, - LIGOMETA_PARAM_MAX, "--enable-output" ); + LIGOMETA_PARAM_MAX, "--enable-output" ); snprintf( procparams.processParamsTable->type, - LIGOMETA_TYPE_MAX, "string" ); + LIGOMETA_TYPE_MAX, "string" ); snprintf( procparams.processParamsTable->value, - LIGOMETA_VALUE_MAX, " " ); + LIGOMETA_VALUE_MAX, " " ); } else if ( enableOutput == 0 ) { snprintf( procparams.processParamsTable->program, - LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); + LIGOMETA_PROGRAM_MAX, "%s", PROGRAM_NAME ); snprintf( procparams.processParamsTable->param, - LIGOMETA_PARAM_MAX, "--disable-output" ); + LIGOMETA_PARAM_MAX, "--disable-output" ); snprintf( procparams.processParamsTable->type, - LIGOMETA_TYPE_MAX, "string" ); + LIGOMETA_TYPE_MAX, "string" ); snprintf( procparams.processParamsTable->value, - LIGOMETA_VALUE_MAX, " " ); + LIGOMETA_VALUE_MAX, " " ); } else { fprintf( stderr, "--enable-output or --disable-output " - "argument must be specified\n" ); + "argument must be specified\n" ); exit( 1 ); } @@ -4892,9 +4948,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--inject-overhead" ); + "--inject-overhead" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -4917,9 +4973,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--write-compress" ); + "--write-compress" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -5010,9 +5066,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--disable-high-pass" ); + "--disable-high-pass" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -5075,8 +5131,8 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) if ( fLow < bankSimParams.f_lower ) { - fprintf( stderr, "--low-frequency-cutoff must be greater than bank sim injection starting frequency\n" ); - exit( 1 ); + fprintf( stderr, "--low-frequency-cutoff must be greater than bank sim injection starting frequency\n" ); + exit( 1 ); } /* check filter parameters have been specified */ @@ -5221,9 +5277,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--glob-frame-data" ); + "--glob-frame-data" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -5260,9 +5316,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--glob-calibration-data" ); + "--glob-calibration-data" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -5424,9 +5480,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--disable-rsq-veto" ); + "--disable-rsq-veto" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -5443,9 +5499,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--enable-rsq-veto" ); + "--enable-rsq-veto" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -5506,9 +5562,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--enable-filter-inj-only" ); + "--enable-filter-inj-only" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } @@ -5517,9 +5573,9 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) this_proc_param = this_proc_param->next = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, - "%s", PROGRAM_NAME ); + "%s", PROGRAM_NAME ); snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, - "--disable-filter-inj-only" ); + "--disable-filter-inj-only" ); snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, " " ); } diff --git a/lalapps/src/inspiral/inspiral.py b/lalapps/src/inspiral/inspiral.py index 787308dd64560109aef0b9b5c0e6f8ad2c1578d5..d4cfbc64c77e8367156a5c8baa388a045c0dc8f6 100644 --- a/lalapps/src/inspiral/inspiral.py +++ b/lalapps/src/inspiral/inspiral.py @@ -454,6 +454,25 @@ class ChiaJob(InspiralAnalysisJob): InspiralAnalysisJob.__init__(self,cp,sections,exec_name,extension,dax) +class InspInjFindJob(InspiralAnalysisJob): + """ + An inspinjfind job. The static options are read from the [inspinjfind] + section in the cp file. + """ + def __init__(self, cp, dax = False): + """ + @cp: a ConfigParser object from which the options are read. + """ + exec_name = 'inspinjfind' + sections = ['inspinjfind'] + extension = 'xml' + InspiralAnalysisJob.__init__(self, cp, sections, exec_name, extension, dax) + self.add_condor_cmd('getenv', 'True') + # overwrite standard log file names + self.set_stdout_file('logs/' + exec_name + '-$(cluster)-$(process).out') + self.set_stderr_file('logs/' + exec_name + '-$(cluster)-$(process).err') + + ############################################################################# @@ -1096,9 +1115,7 @@ class ThincaToCoincNode(InspiralAnalysisNode): raise ValueError, "no input-cache specified" # open the input cache file fp = open(self.__input_cache, 'r') - input_cache = lal.Cache().fromfile(fp) - # remove any slide files - input_cache = input_cache - input_cache.sieve( description = 'SLIDE' ) + input_cache = lal.Cache().fromfile(fp).sieve( description = 'THINCA_SECOND' ) output_files = [ \ '/'.join([ os.getcwd(), re.sub('THINCA', 'THINCA_TO_COINC', os.path.basename(entry.url)) ]) for entry in input_cache \ @@ -1126,7 +1143,7 @@ class ThincaToCoincNode(InspiralAnalysisNode): self.add_var_opt('veto-segments', veto_segments) self.__veto_segments = veto_segments - def get_veto_segmetns(self): + def get_veto_segments(self): """ Returns the name of the veto-segments file for this node. """ @@ -1415,7 +1432,7 @@ class CoireNode(InspiralAnalysisNode): self.add_var_opt('input',input_file) def set_output_tag(self): - fname = "COIRE" + fname = self.job().get_exec_name().upper() if self.get_slides(): fname += "_SLIDE" if self.get_inj_file(): fname += "_" + \ @@ -1601,6 +1618,24 @@ class ChiaNode(InspiralAnalysisNode): return filename +class InspInjFindNode( InspiralAnalysisNode ): + """ + An InspInjFindNode runs an instance of the InspInjJob in a + Condor DAG. + """ + def __init__(self, job): + """ + @job: A CondorDAGJob that can run an instance of ligolw_inspinjfind. + """ + InspiralAnalysisNode.__init__(self, job) + + def get_input_from_cache(self, cache): + """ + Retrieves + """ + self.add_var_arg(filename) + + ############################################################################## #Plotting Jobs and Nodes @@ -1938,6 +1973,7 @@ class PlotSnrchiNode(InspiralPlottingNode): job = A CondorDAGJob that can run an instance of plotsnrchi. """ InspiralPlottingNode.__init__(self,job) + ############################################################################# class PlotGRBtimeslideStatsJob(InspiralAnalysisJob): @@ -1967,6 +2003,131 @@ class PlotGRBtimeslideStatsNode(InspiralAnalysisNode): """ InspiralAnalysisNode.__init__(self,job) +############################################################################# + +class MiniFollowupsJob(InspiralPlottingJob): + """ + A minifollowups job. Static options are read from the + [minifollowups] section in the ini file. + """ + def __init__(self, cp, dax = False): + """ + @cp: ConfigParser object from which options are read. + """ + exec_name = 'minifollowups' + sections = ['minifollowups'] + extension = None + InspiralPlottingJob.__init__(self, cp, sections, exec_name, extension, dax) + + +class MiniFollowupsNode(InspiralPlottingNode): + """ + A mininfollowups node. + """ + def __init__(self, job): + """ + @job: a MiniFollowupsJob + """ + InspiralAnalysisNode.__init__(self, job) + self.__cache_file = None + self.__cache_string = None + self.__prefix = None + self.__suffix = None + self.__input_xml = None + self.__input_xml_summary = None + self.__output_html_table = None + + def set_cache_file(self, cache_file): + """ + Set the ihope cache file to use. + """ + self.add_file_opt( 'cache-file', cache_file ) + self.__cache_file = cache_file + + def get_cache_file(self): + """ + Returns the cache file that's set. + """ + return self.__cache_file + + def set_cache_string(self, cache_string): + """ + Set the ihope cache file to use. + """ + self.add_file_opt( 'cache-string', cache_string ) + self.__cache_string = cache_string + + def get_cache_string(self): + """ + Returns the cache file that's set. + """ + return self.__cache_string + + def set_prefix(self, prefix): + """ + Sets the prefix option, which is used for plot names. + """ + self.add_var_opt( 'prefix', prefix ) + self.__prefix = prefix + + def get_prefix(self): + """ + Return the prefix that's set. + """ + return self.__prefix + + def set_suffix(self, suffix): + """ + Sets the suffix option, which is used for plot names. + """ + self.add_var_opt( 'suffix', suffix ) + self.__suffix = suffix + + def get_suffix(self): + """ + Return the suffix that's set. + """ + return self.__suffix + + def set_input_xml(self, input_xml): + """ + Sets the input xml. + """ + self.add_var_opt( 'input-xml', input_xml) + self.__input_xml = input_xml + + def get_input_xml(self): + """ + Return the input_xml that's set. + """ + return self.__input_xml + + def set_input_xml_summary(self, input_xml_summary): + """ + Sets the input xml. + """ + self.add_var_opt( 'input-xml-summary', input_xml_summary) + self.__input_xml_summary = input_xml_summary + + def get_input_xml_summary(self): + """ + Return the input_xml_summary that's set. + """ + return self.__input_xml_summary + + def set_output_html_table(self, output_html_table): + """ + Sets the input xml. + """ + self.add_var_opt( 'output-html-table', output_html_table) + self.__output_html_table = output_html_table + + def get_output_html_table(self): + """ + Return the output_html_table that's set. + """ + return self.__output_html_table + ############################################################################# # following are types of pipeline.SqliteJobs and Nodes @@ -1996,6 +2157,31 @@ class DBSimplifyNode(pipeline.SqliteNode): pipeline.SqliteNode.__init__(self, job) +class ComputeDurationsJob(pipeline.SqliteJob): + """ + A ComputeDurations job. The static options are read from the section + [compute_durations] in the ini file. + """ + def __init__(self, cp, dax = False): + """ + @cp: ConfigParser object from which options are read. + """ + exec_name = 'compute_durations' + sections = ['compute_durations'] + pipeline.SqliteJob.__init__(self, cp, sections, exec_name, dax) + + +class ComputeDurationsNode(pipeline.SqliteNode): + """ + A ComputeDurations node. + """ + def __init__(self, job): + """ + @job: a ComputeDurationsJob + """ + pipeline.SqliteNode.__init__(self, job) + + class DBAddInjJob(pipeline.SqliteJob): """ A DBAddInj job. The static options are read from the section @@ -2086,11 +2272,92 @@ class CFarNode(pipeline.SqliteNode): pipeline.SqliteNode.__init__(self, job) +class PrintLCJob(pipeline.SqliteJob): + """ + A printlc job. The static options are read from the section [printlc] in + the ini file. + """ + def __init__(self, cp, dax = False): + """ + @cp: ConfigParser object from which options are read. + @sections: list of sections for cp to read from + """ + exec_name = 'printlc' + sections = ['printlc'] + pipeline.SqliteJob.__init__(self, cp, sections, exec_name, dax) + + +class PrintLCNode(pipeline.SqliteNode): + """ + A PrintLC node. + """ + def __init__(self, job): + """ + @job: a PrintLCJob + """ + pipeline.SqliteNode.__init__(self, job) + self.__datatype = None + self.__extract_to_xml = None + self.__exclude_coincs = None + self.__include_only_coincs = None + + def set_datatype(self, datatype): + """ + Sets datatype option. + """ + self.add_var_opt('datatype', datatype) + self.__datatype = datatype + + def get_datatype(self): + """ + Gets datatype. + """ + return self.__datatype + + def set_extract_to_xml(self, xml_filename): + """ + Sets the extract-to-xml option. + """ + self.add_var_opt('extract-to-xml', xml_filename) + self.__extract_to_xml = xml_filename + + def get_extract_to_xml(self): + """ + Gets xml-filename if extract-to-xml is set. + """ + return self.__extract_to_xml + + def set_exclude_coincs(self, exclude_coincs): + """ + Sets exclude-coincs option. + """ + self.add_var_opt('exclude-coincs', exclude_coincs) + self.__exclude_coincs = exclude_coincs + + def get_exclude_coincs(self): + """ + Gets exclude-coincs option. + """ + return self.__exclude_coincs + + def set_include_only_coincs(self, include_only_coincs): + """ + Sets include-only-coincs option. + """ + self.add_var_opt('include-only-coincs', include_only_coincs) + self.__include_only_coincs = include_only_coincs + + def get_include_only_coincs(self): + """ + Gets include-only-coincs option. + """ + return self.__include_only_coincs + + class PlotSlidesJob(pipeline.SqliteJob): """ A plotslides job. The static options are read from the sections [plot_input] - and [plotslides]. [plot_input] is used to determine if should plot playground - only. + and [plotslides]. """ def __init__(self, cp, dax = False): """ @@ -2104,7 +2371,7 @@ class PlotSlidesJob(pipeline.SqliteJob): """ Sets plot-playground-only option. This causes job to only plot playground. """ - self.add_arg('plot-playground-only') + self.add_var_opt('plot-playground-only') class PlotSlidesNode(pipeline.SqliteNode): @@ -2118,6 +2385,37 @@ class PlotSlidesNode(pipeline.SqliteNode): pipeline.SqliteNode.__init__(self, job) +class PlotCumhistJob(pipeline.SqliteJob): + """ + A plotcumhist job. The static options are read from the sections [plot_input] and + [plotcumhist]. + """ + def __init__(self, cp, dax = False): + """ + @cp: ConfigParser object from which options are read. + """ + exec_name = 'plotcumhist' + sections = ['plot_input', 'plotcumhist'] + pipeline.SqliteJob.__init__(self, cp, sections, exec_name, dax) + + def set_plot_playground_only(self): + """ + Sets plot-playground-only option. This causes job to only plot playground. + """ + self.add_var_opt('plot-playground-only') + + +class PlotCumhistNode(pipeline.SqliteNode): + """ + A PlotCumhist node. + """ + def __init__(self, job): + """ + @job: a PlotCumhist Job + """ + pipeline.SqliteNode.__init__(self, job) + + class PlotIfarJob(pipeline.SqliteJob): """ A plotifar job. The static options are read from the [plotifar] section. diff --git a/lalapps/src/inspiral/inspiral_hipe.in b/lalapps/src/inspiral/inspiral_hipe.in index 4e409aa363dddc83839a5d185f90ec38bfb71697..d24b4c54128ba6f5de2ee58ae5bfd295d1205e96 100644 --- a/lalapps/src/inspiral/inspiral_hipe.in +++ b/lalapps/src/inspiral/inspiral_hipe.in @@ -172,7 +172,7 @@ def analyze_ifo(ifo_name,ifo_data,ifo_to_do,tmplt_job,insp_job,df_job,\ data_opts = 'ligo-data' try: type = cp.get('input','ligo-type') - if (type == 'RDS_R_L4') or ('RDS_C' in type) or ('DMT_C' in type): + if (type == 'RDS_R_L4') or ('RDS_C' in type) or ('DMT_C' in type) or ('LDAS_C' in type): type = ifo_name + '_' + type except: type = None channel = cp.get('input','ligo-channel') @@ -1245,6 +1245,10 @@ parser.add_option("-x","--dax", action="store_true", default=False,\ parser.add_option("-w", "--write-script", action="store_true", default=False, help="write the workflow to a locally executable script") +parser.add_option("--summary-first-coinc-triggers", action='store_true', default=False,\ + help="coire (first coincidence) files containing triggers from the whole run. " + "Use with care, as files can become very large.") + command_line = sys.argv[1:] (opts,args) = parser.parse_args() @@ -1615,14 +1619,34 @@ sire_summary_job = inspiral.SireJob(cp) sire_summary_job.set_sub_file( basename + '.sire_summary' + subsuffix ) # coire: -coire_job = inspiral.CoireJob(cp) -coire_job.set_sub_file( basename + '.coire' + subsuffix ) -coire_slide_job = inspiral.CoireJob(cp) -coire_slide_job.set_sub_file( basename + '.coire_slide' + subsuffix ) -coire_summary_job = inspiral.CoireJob(cp) -coire_summary_job.set_sub_file( basename + '.coire_summary' + subsuffix ) -coire_slide_summary_job = inspiral.CoireJob(cp) -coire_slide_summary_job.set_sub_file( basename + '.coire_slide_summary' + \ +coire_job = inspiral.CoireJob(cp, opts.dax) +if opts.ringdown: + coire_job.set_exec_name('coincringread') + coire_job.set_sub_file( basename + '.coincringread' + subsuffix ) +else: + coire_job.set_sub_file( basename + '.coire' + subsuffix ) + +coire_slide_job = inspiral.CoireJob(cp, opts.dax) +if opts.ringdown: + coire_slide_job.set_exec_name('coincringread') + coire_slide_job.set_sub_file( basename + '.coincringread_slide' + subsuffix ) +else: + coire_slide_job.set_sub_file( basename + '.coire_slide' + subsuffix ) + +coire_summary_job = inspiral.CoireJob(cp, opts.dax) +if opts.ringdown: + coire_summary_job.set_exec_name('coincringread') + coire_summary_job.set_sub_file( basename + '.coincringread_summary' + subsuffix ) +else: + coire_summary_job.set_sub_file( basename + '.coire_summary' + subsuffix ) + +coire_slide_summary_job = inspiral.CoireJob(cp, opts.dax) +if opts.ringdown: + coire_slide_summary_job.set_exec_name('coincringread') + coire_slide_summary_job.set_sub_file( basename + '.coincringread_slide_summary' + \ + subsuffix ) +else: + coire_slide_summary_job.set_sub_file( basename + '.coire_slide_summary' + \ subsuffix ) # coire2: @@ -2069,6 +2093,12 @@ for ifos in ifo_coincs: opts.coire_coincidence, opts.coincidence, ifos, inj_file=inj_file, ifotag="FIRST", usertag=usertag, inspinjNode=inspinj) + if len(coinc_nodes[ifos]): + coire_segments(coinc_nodes[ifos], coire_summary_job, dag, + opts.summary_first_coinc_triggers, + opts.coire_coincidence, ifos, gps_start_time, gps_end_time, + inj_file=inj_file, ifotag="SUMMARY_FIRST_" + ifos, usertag=usertag, + write_input_file = True,inspinjNode=inspinj) # Step 6 slide: Time slides @@ -2088,10 +2118,16 @@ for ifos in ifo_coincs: do_coire=opts.coire_coincidence, ifotag=ifotag, slides=num_slides ) if not doExtTrig: - coire_segments_individually(coinc_slide_nodes[ifos], coire_slide_job, - dag, opts.coire_coincidence, opts.coincidence, ifos, + coinc_slide_nodes[ifos]=coire_segments_individually(coinc_slide_nodes[ifos], + coire_slide_job, dag, opts.coire_coincidence, opts.coincidence, ifos, inj_file = inj_file, num_slides = num_slides, ifotag="FIRST", usertag=usertag,inspinjNode=inspinj) + if len(coinc_slide_nodes[ifos]): + coire_segments(coinc_slide_nodes[ifos], coire_slide_summary_job, dag, + opts.summary_first_coinc_triggers, + opts.coire_coincidence, ifos, gps_start_time, gps_end_time, + inj_file=inj_file, num_slides = num_slides, ifotag="SUMMARY_FIRST_" + ifos, + usertag=usertag, write_input_file = True,inspinjNode=inspinj) # Concatenate the zerolag and slide nodes coinc_nodes[ifos] = coinc_nodes[ifos] + coinc_slide_nodes[ifos] @@ -2198,11 +2234,11 @@ for ifos in ifo_coincs: inspinjNode=inspinj) if len(coire2_nodes[ifos]): - coire_segments(coire2_nodes[ifos], coire2_summary_job, dag, - opts.summary_coinc_triggers, - opts.coire_second_coinc, ifos, gps_start_time, gps_end_time, - inj_file=inj_file, ifotag="SUMMARY_SECOND_" + ifos, usertag=usertag, - write_input_file = True,inspinjNode=inspinj) + coire_segments(coire2_nodes[ifos], coire2_summary_job, dag, + opts.summary_coinc_triggers, + opts.coire_second_coinc, ifos, gps_start_time, gps_end_time, + inj_file=inj_file, ifotag="SUMMARY_SECOND_" + ifos, usertag=usertag, + write_input_file = True,inspinjNode=inspinj) for ifo in ifo_list: if ifo in ifos: diff --git a/lalapps/src/inspiral/inspiralutils.c b/lalapps/src/inspiral/inspiralutils.c index 96d1a261c6e4add0b394741aef18bf4278e3e125..c99d5b9b1fe1cf414c6331aafa62022c02f70d63 100644 --- a/lalapps/src/inspiral/inspiralutils.c +++ b/lalapps/src/inspiral/inspiralutils.c @@ -145,8 +145,8 @@ SummValueTable **add_summvalue_table(SummValueTable **newTable, void AddNumRelStrainModes( LALStatus *status, - REAL4TimeVectorSeries **outStrain, /** [out] h+, hx data */ - SimInspiralTable *thisinj /** [in] injection data */) + REAL4TimeVectorSeries **outStrain, /** [out] h+, hx data */ + SimInspiralTable *thisinj /** [in] injection data */) { INT4 modeL, modeM, modeLlo, modeLhi; INT4 len, lenPlus, lenCross, k, lenIni; @@ -188,7 +188,7 @@ void AddNumRelStrainModes( LALStatus *status, /* loop over m values */ for ( modeM = -modeL; modeM <= modeL; modeM++ ) { - + /* read numrel waveform */ /* first the plus polarization */ channel_name_plus = XLALGetNinjaChannelName("plus", modeL, modeM); @@ -204,10 +204,10 @@ void AddNumRelStrainModes( LALStatus *status, /* skip on to next mode if mode doesn't exist */ if ( (lenPlus <= 0) || (lenCross <= 0) || (lenPlus != lenCross) ) { - XLALClearErrno(); - LALFree(channel_name_plus); - LALFree(channel_name_cross); - continue; + XLALClearErrno(); + LALFree(channel_name_plus); + LALFree(channel_name_cross); + continue; } /* note: lenPlus and lenCross must be equal if we got this far*/ @@ -230,7 +230,7 @@ void AddNumRelStrainModes( LALStatus *status, LALFree(channel_name_cross); /* allocate memory for tempStrain */ - tempStrain = LALCalloc(1, sizeof(*tempStrain)); + tempStrain = LALCalloc(1, sizeof(*tempStrain)); tempStrain->data = XLALCreateREAL4VectorSequence(2, len); tempStrain->deltaT = LAL_MTSUN_SI * (thisinj->mass1 + thisinj->mass2) * seriesPlus->deltaT ; tempStrain->f0 = seriesPlus->f0; @@ -240,8 +240,8 @@ void AddNumRelStrainModes( LALStatus *status, /* now copy the data and scale amplitude corresponding to distance of 1Mpc*/ for (k = 0; k < len; k++) { - tempStrain->data->data[k] = massMpc * seriesPlus->data->data[k]; - tempStrain->data->data[len + k] = massMpc * seriesCross->data->data[k]; + tempStrain->data->data[k] = massMpc * seriesPlus->data->data[k]; + tempStrain->data->data[len + k] = massMpc * seriesCross->data->data[k]; } /* we are done with seriesPlus and Cross for this iteration */ @@ -249,32 +249,32 @@ void AddNumRelStrainModes( LALStatus *status, XLALDestroyREAL4TimeSeries (seriesCross); seriesPlus = NULL; seriesCross = NULL; - + /* compute the h+ and hx for given inclination and coalescence phase*/ XLALOrientNRWave( tempStrain, modeL, modeM, thisinj->inclination, thisinj->coa_phase ); if (sumStrain == NULL) { - - sumStrain = LALCalloc(1, sizeof(*sumStrain)); - sumStrain->data = XLALCreateREAL4VectorSequence(2, tempStrain->data->vectorLength); - sumStrain->deltaT = tempStrain->deltaT; - sumStrain->f0 = tempStrain->f0; - sumStrain->sampleUnits = tempStrain->sampleUnits; - - memset(sumStrain->data->data,0.0,2*tempStrain->data->vectorLength*sizeof(REAL4)); - - sumStrain = XLALSumStrain( sumStrain, tempStrain ); + + sumStrain = LALCalloc(1, sizeof(*sumStrain)); + sumStrain->data = XLALCreateREAL4VectorSequence(2, tempStrain->data->vectorLength); + sumStrain->deltaT = tempStrain->deltaT; + sumStrain->f0 = tempStrain->f0; + sumStrain->sampleUnits = tempStrain->sampleUnits; + + memset(sumStrain->data->data,0.0,2*tempStrain->data->vectorLength*sizeof(REAL4)); + + sumStrain = XLALSumStrain( sumStrain, tempStrain ); } else { - sumStrain = XLALSumStrain( sumStrain, tempStrain ); + sumStrain = XLALSumStrain( sumStrain, tempStrain ); } /* clear memory for strain */ if (tempStrain->data != NULL) { - XLALDestroyREAL4VectorSequence ( tempStrain->data ); - LALFree( tempStrain ); - tempStrain = NULL; + XLALDestroyREAL4VectorSequence ( tempStrain->data ); + LALFree( tempStrain ); + tempStrain = NULL; } } /* end loop over modeM values */ @@ -297,14 +297,14 @@ void AddNumRelStrainModes( LALStatus *status, timeseries for a specified ifo and a dynamic range factor. */ void InjectNumRelWaveforms (LALStatus *status, - REAL4TimeSeries *chan, /**< [out] the output time series */ - SimInspiralTable *injections, /**< [in] list of injections */ - CHAR ifo[3], /**< [in] 2 char code for interferometer */ - REAL8 dynRange, /**< [in] dynamic range factor for scaling time series */ - REAL8 freqLowCutoff, /**< [in] Lower cutoff frequency */ - REAL8 snrLow, /**< [in] lower cutoff value of snr */ - REAL8 snrHigh, - CHAR *fname) /**< [in] higher cutoff value of snr */ + REAL4TimeSeries *chan, /**< [out] the output time series */ + SimInspiralTable *injections, /**< [in] list of injections */ + CHAR ifo[3], /**< [in] 2 char code for interferometer */ + REAL8 dynRange, /**< [in] dynamic range factor for scaling time series */ + REAL8 freqLowCutoff, /**< [in] Lower cutoff frequency */ + REAL8 snrLow, /**< [in] lower cutoff value of snr */ + REAL8 snrHigh, + CHAR *fname) /**< [in] higher cutoff value of snr */ { REAL4TimeVectorSeries *tempStrain=NULL; @@ -331,44 +331,44 @@ void InjectNumRelWaveforms (LALStatus *status, startFreqHz = startFreq / ( LAL_TWOPI * massTotal); if (startFreqHz < freqLowCutoff) - { - TRY( AddNumRelStrainModes( status->statusPtr, &tempStrain, thisInj), - status); - - thisSNR = calculate_ligo_snr_from_strain( tempStrain, thisInj, ifo); - - fprintf(stdout, "injection %s has a snr of %f\n", thisInj->numrel_data, thisSNR); - - /* set channel name */ - snprintf( chan->name, LIGOMETA_CHANNEL_MAX * sizeof( CHAR ), - "%s:STRAIN", ifo ); - - if ((thisSNR < snrHigh) && (thisSNR > snrLow)) - { - - /* simTableOut will be null only the first time */ - if ( simTableOut == NULL) { - simTableOut = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); - memcpy(simTableOut, thisInj, sizeof(*thisInj)); - simTableOut->next = NULL; - thisInjOut = simTableOut; - } - else { - thisInjOut->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); - memcpy(thisInjOut->next, thisInj, sizeof(*thisInj)); - thisInjOut->next->next = NULL; - thisInjOut = thisInjOut->next; - } - - TRY( LALInjectStrainGW( status->statusPtr, chan, tempStrain, thisInj, - ifo, dynRange), status); - } - - XLALDestroyREAL4VectorSequence ( tempStrain->data); - tempStrain->data = NULL; - LALFree(tempStrain); - tempStrain = NULL; - } + { + TRY( AddNumRelStrainModes( status->statusPtr, &tempStrain, thisInj), + status); + + thisSNR = calculate_ligo_snr_from_strain( tempStrain, thisInj, ifo); + + fprintf(stdout, "injection %s has a snr of %f\n", thisInj->numrel_data, thisSNR); + + /* set channel name */ + snprintf( chan->name, LIGOMETA_CHANNEL_MAX * sizeof( CHAR ), + "%s:STRAIN", ifo ); + + if ((thisSNR < snrHigh) && (thisSNR > snrLow)) + { + + /* simTableOut will be null only the first time */ + if ( simTableOut == NULL) { + simTableOut = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); + memcpy(simTableOut, thisInj, sizeof(*thisInj)); + simTableOut->next = NULL; + thisInjOut = simTableOut; + } + else { + thisInjOut->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); + memcpy(thisInjOut->next, thisInj, sizeof(*thisInj)); + thisInjOut->next->next = NULL; + thisInjOut = thisInjOut->next; + } + + TRY( LALInjectStrainGW( status->statusPtr, chan, tempStrain, thisInj, + ifo, dynRange), status); + } + + XLALDestroyREAL4VectorSequence ( tempStrain->data); + tempStrain->data = NULL; + LALFree(tempStrain); + tempStrain = NULL; + } } /* loop over injectionsj */ @@ -386,10 +386,10 @@ void InjectNumRelWaveforms (LALStatus *status, TRY( LALOpenLIGOLwXMLFile( status->statusPtr, &xmlfp, fname ), status ); TRY( LALBeginLIGOLwXMLTable( status->statusPtr, &xmlfp, sim_inspiral_table ), - status ); + status ); TRY( LALWriteLIGOLwXMLTable( status->statusPtr, &xmlfp, dummyTable, - sim_inspiral_table ), status ); + sim_inspiral_table ), status ); TRY( LALEndLIGOLwXMLTable ( status->statusPtr, &xmlfp ), status ); @@ -451,8 +451,8 @@ REAL8 start_freq_from_frame_url(CHAR *url) REAL8 calculate_ligo_snr_from_strain( REAL4TimeVectorSeries *strain, - SimInspiralTable *thisInj, - CHAR ifo[3]) + SimInspiralTable *thisInj, + CHAR ifo[3]) { REAL8 ret = -1, snrSq, freq, psdValue; @@ -469,8 +469,8 @@ REAL8 calculate_ligo_snr_from_strain( REAL4TimeVectorSeries *strain, deltaF = chan->deltaT * strain->data->vectorLength; fftData = XLALCreateCOMPLEX8FrequencySeries( chan->name, &(chan->epoch), - 0, deltaF, &lalDimensionlessUnit, - chan->data->length/2 + 1 ); + 0, deltaF, &lalDimensionlessUnit, + chan->data->length/2 + 1 ); /* perform the fft */ pfwd = XLALCreateForwardREAL4FFTPlan( chan->data->length, 0 ); diff --git a/lalapps/src/inspiral/inspiralutils.py b/lalapps/src/inspiral/inspiralutils.py index 5a57d9c9cefb1620eea6250bc6cec186c78bef2a..412ca913e11e6e1206e64d4004524fbd05f7220e 100644 --- a/lalapps/src/inspiral/inspiralutils.py +++ b/lalapps/src/inspiral/inspiralutils.py @@ -176,7 +176,7 @@ def generate_veto_cat_files(config, vetoDefFile, generateVetoes): end = config.get("input", "gps-end-time") genVetoCall = executable - genVetoCall = ' '.join([ genVetoCall, "--separate-categories", + genVetoCall = ' '.join([ genVetoCall, "--cumulative-categories", "--segment-url", config.get("segfind", "segment-url"), "--veto-file", vetoDefFile, "--gps-start-time", start, @@ -250,11 +250,11 @@ def veto_segments(ifo, config, categories, generateVetoes): vetoFiles = {} for category in categories: - veto_cat_file = ifo + "-VETOTIME_CAT" + str(category) + "*.xml" + veto_cat_file = ifo + "-VETOTIME_CAT" + str(category) + "-" + \ + str(start) + "-" + str(end - start) + ".xml" vetoFile = ifo + "-CATEGORY_" + str(category) + "_VETO_SEGS-" + \ - str(start) + "-" + \ - str(end - start) + ".txt" + str(start) + "-" + str(end - start) + ".txt" if generateVetoes: return_val = convert_veto_cat_xml_to_txt(config, veto_cat_file, vetoFile) @@ -306,7 +306,7 @@ def datafind_segments(ifo, config): dataFindFile = ifo_type + "-" + str(start) + "-" + \ str(end - start) + ".txt" - print "Running LSCdataFind to determine available data from " + type + \ + print "Running ligo_data_find to determine available data from " + type + \ " frames for " + ifo dataFindCall = executable for opt,arg in config.items("datafind"): @@ -323,13 +323,10 @@ def datafind_segments(ifo, config): ############################################################################## # Function to copy the segments files -# If the hardwareInj flag is used we add the hardware injection not made -# flag to Cat1 and remove the Injection flag from cat 2. def copyCategoryFiles(config,vetoes,directory,\ - infile,analysisDirectory,hardwareInj=False): + infile,analysisDirectory): """ Copy the category files to the directory specified - Modify the cat files accordingly if hardware injections specified """ outfile = analysisDirectory + "/" + directory + "/" \ + os.path.basename(infile) @@ -340,44 +337,9 @@ def copyCategoryFiles(config,vetoes,directory,\ "without DQ vetoes" outfile += vetoes + "_BLANK.txt" rel_outfile += vetoes + "_BLANK.txt" - if hardwareInj: - injNotMadeCat='cat-'+config.get('hardware-inj','inj-not-made-veto-cat') - injNotMadeFlag= config.get('hardware-inj','inj-not-made-veto-flag') - if injNotMadeCat in vetoes: - open(outfile, "w").write(vetoes[0:2].upper()+ ':' + injNotMadeFlag +\ - '\t\t0\t0\n') - else: - open(outfile, "w").write("") # touch - else: - open(outfile, "w").write("") # touch + open(outfile, "w").write("") # touch else: - if hardwareInj: - injVetoFlag = config.get('hardware-inj','inj-veto-flag') - injVetoFlagList = injVetoFlag.split(',') - injVetoCat = config.get('hardware-inj','inj-veto-cat') - injNotMadeCat= config.get('hardware-inj','inj-not-made-veto-cat') - injNotMadeFlag= config.get('hardware-inj','inj-not-made-veto-flag') - dqFile = open(infile,'r') - dqFileConts = dqFile.read() - dqFile.close() - if 'cat-' + injNotMadeCat in vetoes: - dqFileConts = vetoes[0:2].upper()+':' + injNotMadeFlag + \ - '\t\t0\t0\n' + dqFileConts - if 'cat-' + injVetoCat in vetoes: - dqFileContsList = dqFileConts.split('\n') - dqFileConts = '' - for line in dqFileContsList: - remLine = False - for flag in injVetoFlagList: - if flag in line: - remLine = True - if not remLine: - dqFileConts += line + '\n' - dqHWFile = open(outfile, 'w') - dqHWFile.write(dqFileConts) - dqHWFile.close() - else: - shutil.copy(infile, outfile) + shutil.copy(infile, outfile) config.set("segments", vetoes, rel_outfile) ############################################################################## @@ -428,47 +390,11 @@ def downloadDqSegFiles(config,ifo,generate_segments): print "done" return dqSegFile -############################################################################## -# Function to download hwInj not made lists and append to dq seg lists -def downloadDqHWSegFiles(config,ifo,generate_segments,dqSegFile): - """ - Download the dqSegFiles from a html location - @param config : the configParser object with analysis details - @param ifo : name of the ifo - @param generate_segments : If False do not download, just return filename - @param dqSegFile : The dqSegFiles locations (to be appended to the Hw files - """ - start = config.getint("input","gps-start-time") - end = config.getint("input","gps-end-time") - dqHWSegFile = ifo + "-DQ_HW_SEGMENTS-" + str(start) + "-" + \ - str(end - start) + ".txt" - if generate_segments: - dq_url = config.get("segments","dq-server-url") - dq_hw_segdb_file = config.get("segments", ifo.lower() + '-hw-dq-file') - if dq_hw_segdb_file == "": - print >>sys.stderr, "warning: no file provided to %s-hw-dq-file; " \ - "assuming there are no HW_INJ_NOT_MADE times" % ifo.lower() - openHWDQFile = open(dqHWSegFile,'w') - else: - print "Downloading HW_INJ_NOT_MADE list" + dq_hw_segdb_file - sys.stdout.flush() - dqHWSegFile, info = urllib.urlretrieve(dq_url + '/' + dq_hw_segdb_file, - dqHWSegFile) - print "Done,appending this to dqSegFile for hardware-inj" - openHWDQFile = open(dqHWSegFile,'a') - openDQFile=open(dqSegFile, 'r') - dqFileConts = openDQFile.read() - openDQFile.close() - openHWDQFile.write(dqFileConts) - openHWDQFile.close() - print "done" - return dqHWSegFile - ############################################################################## # Function to determine the segments to analyze #(science segments, data quality, missing segments) -def findSegmentsToAnalyze(config, ifo, generate_segments=True,\ +def findSegmentsToAnalyze(config, ifo, veto_categories, generate_segments=True,\ use_available_data=False, data_quality_vetoes=False): """ generate segments for the given ifo @@ -526,9 +452,9 @@ def findSegmentsToAnalyze(config, ifo, generate_segments=True,\ print "done" if data_quality_vetoes: - print "Generating cat 2, 3, and 4 veto segments for " + ifo + "..." + print "Generating cat " + str(veto_categories) + " veto segments for " + ifo + "..." sys.stdout.flush() - dqVetoes = veto_segments(ifo, config, [2,3,4], data_quality_vetoes ) + dqVetoes = veto_segments(ifo, config, veto_categories, data_quality_vetoes ) if data_quality_vetoes: print "done" return tuple([segFile, dqVetoes]) @@ -567,7 +493,7 @@ def slide_sanity(config, playOnly = False): # Function to set up lalapps_inspiral_hipe def hipe_setup(hipeDir, config, ifos, logPath, injSeed=None, dataFind = False, \ tmpltBank = False, playOnly = False, vetoCat = None, vetoFiles = None, \ - hardwareInj = False, site = "local", dax=None, tmpltbankCache = None): + site = "local", dax=None, tmpltbankCache = None): """ run lalapps_inspiral_hipe and add job to dag hipeDir = directory in which to run inspiral hipe @@ -667,18 +593,22 @@ def hipe_setup(hipeDir, config, ifos, logPath, injSeed=None, dataFind = False, \ # copy over the arguments from the relevant injection section for (name,value) in config.items(hipeDir): hipecp.set("inspinj",name,value) + if config.has_option("hipe-arguments","ringdown"): + injType = config.get(hipeDir,"injection-type") + hipecp.set("inspiral","injection-type",injType) + hipecp.remove_option("inspinj","injection-type") + if injType == "ringdown": + executable = "../executables/lalapps_rinj" + hipecp.set("condor","inspinj",executable) hipecp.remove_section(hipeDir) hipecp.set("input","injection-seed",injSeed) hipecp.set("input", "num-slides", "") # set any extra inspiral arguments for the injection - for item in config.items('-'.join([hipeDir,"inspiral"])): - hipecp.set("inspiral",item[0],item[1]) - - elif hardwareInj and not dataFind and not tmpltBank: - hipecp.set("input","hardware-injection","") - hipecp.set("inspiral","hardware-injection","") - hipecp.set("input", "num-slides", "") - + try: + for item in config.items('-'.join([hipeDir,"inspiral"])): + hipecp.set("inspiral",item[0],item[1]) + except ConfigParser.NoSectionError: + pass else: # add the time slide to the ini file numSlides = slide_sanity(config, playOnly) @@ -695,7 +625,6 @@ def hipe_setup(hipeDir, config, ifos, logPath, injSeed=None, dataFind = False, \ print "Running hipe in directory " + hipeDir if dataFind or tmpltBank: print "Running datafind / template bank generation" - elif hardwareInj: print "Running hardware injection analysis" elif injSeed: print "Injection seed: " + injSeed else: print "No injections, " + str(hipecp.get("input","num-slides")) + \ " time slides" @@ -725,7 +654,8 @@ def hipe_setup(hipeDir, config, ifos, logPath, injSeed=None, dataFind = False, \ hipeCommand = test_and_add_hipe_arg(hipeCommand,hipe_arg) elif vetoCat: if config.has_option("hipe-arguments","ringdown"): - hipe_args = ["coincidence", "ringdown"] + hipe_args = ["coincidence", "ringdown","coire-coincidence", + "summary-first-coinc-triggers","write-script"] else: hipe_args = ["second-coinc", "coire-second-coinc", "summary-coinc-triggers", "sire-second-coinc", @@ -733,10 +663,7 @@ def hipe_setup(hipeDir, config, ifos, logPath, injSeed=None, dataFind = False, \ for hipe_arg in hipe_args: hipeCommand = test_and_add_hipe_arg(hipeCommand,hipe_arg) else: - if hardwareInj: - omit = ["disable-dag-categories", "disable-dag-priorities"] - else: - omit = ["datafind", "template-bank", "disable-dag-categories", "disable-dag-priorities"] + omit = ["datafind", "template-bank", "disable-dag-categories", "disable-dag-priorities"] for (opt, arg) in config.items("hipe-arguments"): if opt not in omit: hipeCommand += "--" + opt + " " + arg @@ -748,7 +675,7 @@ def hipe_setup(hipeDir, config, ifos, logPath, injSeed=None, dataFind = False, \ make_external_call(hipeCommand) # link datafind - if not dataFind and not tmpltBank and not vetoCat and not hardwareInj: + if not dataFind and not tmpltBank and not vetoCat: try: os.rmdir("cache") os.symlink("../datafind/cache", "cache") @@ -798,8 +725,6 @@ def hipe_setup(hipeDir, config, ifos, logPath, injSeed=None, dataFind = False, \ hipeNode.add_output_file( hipe_cache(ifos, usertag, \ hipecp.getint("input", "gps-start-time"), \ hipecp.getint("input", "gps-end-time")) ) - # add postscript to deal with rescue dag - fix_rescue(hipeNode) # return to the original directory os.chdir("..") @@ -891,12 +816,14 @@ def plot_setup(plotDir, config, logPath, stage, injectionSuffix, analysisstart = plotcp.get("common","gps-start-time") analysisend = plotcp.get("common","gps-end-time") analysisduration = int(analysisend) - int(analysisstart) - if "HARDWARE_INJECTION" in injectionSuffix: - inspmissedVetoDir = "../hardware_inj_segments" - else: - inspmissedVetoDir = "../segments" + inspmissedVetoDir = "../segments" for ifo in ifos: - plotcp.set("plotinspmissed","followup-vetofile-" + ifo.lower(), + if cat == 2: + plotcp.set("plotinspmissed","followup-vetofile-" + ifo.lower(), + inspmissedVetoDir + "/" + ifo + "-CATEGORY_" + str(cat) + + "_VETO_SEGS-" + analysisstart + "-" + str(analysisduration) + ".txt") + else: + plotcp.set("plotinspmissed","followup-vetofile-" + ifo.lower(), inspmissedVetoDir + "/" + ifo + "-COMBINED_CAT_" + str(cat) + "_VETO_SEGS-" + analysisstart + "-" + str(analysisduration) + ".txt") @@ -970,20 +897,89 @@ def plot_setup(plotDir, config, logPath, stage, injectionSuffix, plotJob = pipeline.CondorDAGManJob(plotDag, plotDir) plotNode = pipeline.CondorDAGNode(plotJob) - # add postscript to deal with rescue dag - fix_rescue(plotNode) - # return to the original directory os.chdir("..") return plotNode +############################################################################## +# Function to set up and run pipedown + +def pipedownSetup(dag,config,logPath,pipedownDir,\ + cacheFile,parentNodes,playgroundOnly): + """ + Set up and run pipedown + dag = the dag + config = the config object + logPath = Location where log files will be written + pipedownDir = Directory to run pipedown in + cacheFile = The input ihope cache file + parentNodes = Name of parent dags to add + playgroundOnly = Are we opening the box? + """ + # Get necessary information from the config object + gpsStart = config.get("input","gps-start-time") + gpsEnd = config.get("input","gps-end-time") + + # Make directory + + mkdir(pipedownDir) + os.chdir(pipedownDir) + + # Create the necessary ini file + + pipeCp = copy.deepcopy(config) + pipeCp.set("condor","universe","vanilla") + + # Create input section + + pipeCp.remove_section("input") + pipeCp.add_section("input") + pipeCp.set("input","ihope-segments-directory","../segments") + + # Write ini file to folder + + iniFile = pipedownDir + iniFile += ".ini" + + pipeCp.write(file(iniFile,"w")) + + # Set up the command to run pipedown + + pipeCommand = config.get("condor","pipedown") + pipeCommand += " --log-path " + logPath + pipeCommand += " --config-file " + iniFile + pipeCommand += " --gps-start-time " + gpsStart + pipeCommand += " --gps-end-time " + gpsEnd + pipeCommand += " --ihope-cache " + cacheFile + if not playgroundOnly: + pipeCommand += " --generate-all-data-plots" + # Need to add playground command + + # run lalapps_pipedown + make_external_call(pipeCommand) + + # make pipedown job/node + pipeDag = iniFile.rstrip("ini") + "dag" + pipeJob = pipeline.CondorDAGManJob(pipeDag, pipedownDir) + pipeNode = pipeline.CondorDAGNode(pipeJob) + dag.add_node(pipeNode) + if parentNodes: + for thisDag in parentNodes: + pipeNode.add_parent(thisDag) + + # return to the original directory + os.chdir("..") + + return dag + + ############################################################################## # Function to set up zero/slide plots: def zeroSlidePlots(dag, plotDir, config, logPath, zerolagSuffix, slideSuffix, cacheFile, doDagCategories, parentDags = None, vetoParentDags = None, - vetoCat = 3, ifos = []): + vetoCat = [2,3,4], ifos = []): """ set up plots for zero lag and time slides dag = the dag @@ -1020,29 +1016,30 @@ def zeroSlidePlots(dag, plotDir, config, logPath, zerolagSuffix, slideSuffix, plotNode.add_parent(thisDag) # second stage (require DQ) - vetoString = "_CAT_" + str(vetoCat) + "_VETO" - plotcp = copy.deepcopy(config) - plotcp.add_section("plot-arguments") - plotcp.set("plot-arguments","plotinspiral","") - plotcp.set("plot-arguments","plotthinca","") - plotcp.set("plot-arguments","write-script","") - if zerolagSuffix == "PLAYGROUND" and slideSuffix == "FULL_DATA": - plotcp.set("plotthinca","zero-lag-playground","") - plotVetoNode = plot_setup(plotDir, plotcp, logPath, "second", \ - "", zerolagSuffix + vetoString, slideSuffix + vetoString, \ - slideSuffix + vetoString, cacheFile, "", \ - tag=vetoString[1:], ifos=ifos, cat=vetoCat) - if doDagCategories: - plotVetoNode.set_category('plotting') - dag.add_node(plotVetoNode) - if parentDags: - for thisDag in parentDags: - plotVetoNode.add_parent(thisDag) - if vetoParentDags: - for thisDag in vetoParentDags: - plotVetoNode.add_parent(thisDag) - if not doDagCategories: - plotVetoNode.add_parent(plotNode) + for cat in vetoCat: + vetoString = "_CAT_" + str(cat) + "_VETO" + plotcp = copy.deepcopy(config) + plotcp.add_section("plot-arguments") + plotcp.set("plot-arguments","plotinspiral","") + plotcp.set("plot-arguments","plotthinca","") + plotcp.set("plot-arguments","write-script","") + if zerolagSuffix == "PLAYGROUND" and slideSuffix == "FULL_DATA": + plotcp.set("plotthinca","zero-lag-playground","") + plotVetoNode = plot_setup(plotDir, plotcp, logPath, "second", \ + "", zerolagSuffix + vetoString, slideSuffix + vetoString, \ + slideSuffix + vetoString, cacheFile, "", \ + tag=vetoString[1:], ifos=ifos, cat=cat) + if doDagCategories: + plotVetoNode.set_category('plotting') + dag.add_node(plotVetoNode) + if parentDags: + for thisDag in parentDags: + plotVetoNode.add_parent(thisDag) + if vetoParentDags: + for thisDag in vetoParentDags: + plotVetoNode.add_parent(thisDag[cat]) + if not doDagCategories: + plotVetoNode.add_parent(plotNode) return dag @@ -1050,7 +1047,7 @@ def zeroSlidePlots(dag, plotDir, config, logPath, zerolagSuffix, slideSuffix, # Function to set up inj/zero/slide plots: def injZeroSlidePlots(dag, plotDir, config, logPath, injectionSuffix, zerolagSuffix, slideSuffix, cacheFile, doDagCategories, parentDags = None, - vetoParentDags = None, vetoCat = 3, ifos = []): + vetoParentDags = None, vetoCat = [2,3,4], ifos = []): """ set up plots for injections, zero lag and time slides dag = the dag @@ -1086,36 +1083,37 @@ def injZeroSlidePlots(dag, plotDir, config, logPath, injectionSuffix, injPlotNode.add_parent(thisDag) # second stage - vetoString = "_CAT_" + str(vetoCat) + "_VETO" - plotcp = copy.deepcopy(config) - plotcp.add_section("plot-arguments") - plotcp.set("plot-arguments","plotinspinj","") - plotcp.set("plot-arguments","plotsnrchi","") - plotcp.set("plot-arguments","plotethinca","") - plotcp.set("plot-arguments","plotinjnum","") - plotcp.set("plot-arguments","plotinspmissed","") - plotcp.set("plot-arguments","plotinspfound","") - plotcp.set("plot-arguments","plotcoincmissed","") - plotcp.set("plot-arguments","ploteffdistcut","") - plotcp.set("plot-arguments","write-script","") - injPlotVetoNode = plot_setup( plotDir, \ - plotcp, logPath, "second", injectionSuffix + vetoString, \ - zerolagSuffix + vetoString, slideSuffix + vetoString, \ - injectionSuffix + vetoString, cacheFile, injectionSuffix, \ - tag=vetoString[1:], ifos=ifos, cat=vetoCat) - if doDagCategories: - injPlotVetoNode.set_category('plotting') - dag.add_node(injPlotVetoNode) - - if parentDags: - for thisDag in parentDags: - injPlotVetoNode.add_parent(thisDag) - if vetoParentDags: - for thisDag in vetoParentDags: - injPlotVetoNode.add_parent(thisDag) + for cat in vetoCat: + vetoString = "_CAT_" + str(cat) + "_VETO" + plotcp = copy.deepcopy(config) + plotcp.add_section("plot-arguments") + plotcp.set("plot-arguments","plotinspinj","") + plotcp.set("plot-arguments","plotsnrchi","") + plotcp.set("plot-arguments","plotethinca","") + plotcp.set("plot-arguments","plotinjnum","") + plotcp.set("plot-arguments","plotinspmissed","") + plotcp.set("plot-arguments","plotinspfound","") + plotcp.set("plot-arguments","plotcoincmissed","") + plotcp.set("plot-arguments","ploteffdistcut","") + plotcp.set("plot-arguments","write-script","") + injPlotVetoNode = plot_setup( plotDir, \ + plotcp, logPath, "second", injectionSuffix + vetoString, \ + zerolagSuffix + vetoString, slideSuffix + vetoString, \ + injectionSuffix + vetoString, cacheFile, injectionSuffix, \ + tag=vetoString[1:], ifos=ifos, cat=cat) + if doDagCategories: + injPlotVetoNode.set_category('plotting') + dag.add_node(injPlotVetoNode) + + if parentDags: + for thisDag in parentDags: + injPlotVetoNode.add_parent(thisDag) + if vetoParentDags: + for thisDag in vetoParentDags: + injPlotVetoNode.add_parent(thisDag) - if not doDagCategories: - injPlotVetoNode.add_parent(injPlotNode) + if not doDagCategories: + injPlotVetoNode.add_parent(injPlotNode) return dag @@ -1206,53 +1204,11 @@ def followup_setup(followupDir, config, opts, hipeDir): os.chmod(followupDag + ".pre", 0744) followupNode.set_pre_script(followupDir + "/" + followupDag + ".pre") - # add postscript to deal with rescue dag - fix_rescue(followupNode) - # return to the original directory os.chdir("..") return followupNode -############################################################################## -# Function to fix the rescue of inner dags -def fix_rescue(dagNode): - """ - add a postscript to deal with the rescue dag correctly - - dagNode = the node for the subdag - """ - if not os.path.isfile("rescue.sh"): - os.symlink("../rescue.sh", "rescue.sh") - dagNode.set_post_script( "rescue.sh") - dagNode.add_post_script_arg( "$RETURN" ) - dagNode.add_post_script_arg( - dagNode.job().get_sub_file().rstrip(".condor.sub") ) - -def write_rescue(): - # Write the rescue post-script - # XXX FIXME: This is a hack, required until condor is fixed XXX - f = open("rescue.sh", "w") - f.write("""#! /bin/bash - if [ ! -n "${2}" ] - then - echo "Usage: `basename $0` DAGreturn DAGfile" - exit - fi - - if (( ${1}>0 )) - then - file=${2} - if [ -f ${file}.rescue ] - then - mv ${file} ${file}.orig - mv ${file}.rescue ${file} - fi - exit ${1} - fi""") - f.close() - os.chmod("rescue.sh", 0744) - ############################################################################## # plot_hipe helpers diff --git a/lalapps/src/inspiral/inspxmlinj.c b/lalapps/src/inspiral/inspxmlinj.c index c2a85c51d8cf0cca74564383594ac9bd3d8281d4..51933a887907f96fdb9ced503bb8a62840133fdc 100644 --- a/lalapps/src/inspiral/inspxmlinj.c +++ b/lalapps/src/inspiral/inspxmlinj.c @@ -105,7 +105,6 @@ int main ( int argc, char *argv[] ) CHAR fname[256]; CHAR *userTag = NULL; LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; MetadataTable proctable; MetadataTable procparams; MetadataTable injections; @@ -144,20 +143,19 @@ int main ( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) @@ -184,7 +182,7 @@ int main ( int argc, char *argv[] ) size_t optarg_len; c = getopt_long_only( argc, argv, - "Ha:b:c:d:e:f:g:h:i:j:k:l:Z:", long_options, &option_index ); + "Ha:b:c:d:e:f:g:h:i:j:k:l:Z:", long_options, &option_index ); /* detect the end of the options */ if ( c == - 1 ) @@ -195,18 +193,18 @@ int main ( int argc, char *argv[] ) switch ( c ) { case 0: - /* if this option set a flag, do nothing else now */ - if ( long_options[option_index].flag != 0 ) - { - break; - } - else - { - fprintf( stderr, "error parsing option %s with argument %s\n", - long_options[option_index].name, optarg ); - exit( 1 ); - } - break; + /* if this option set a flag, do nothing else now */ + if ( long_options[option_index].flag != 0 ) + { + break; + } + else + { + fprintf( stderr, "error parsing option %s with argument %s\n", + long_options[option_index].name, optarg ); + exit( 1 ); + } + break; case 'a': { @@ -262,25 +260,25 @@ int main ( int argc, char *argv[] ) break; case 'c': - injParams.mass1 = (REAL4) atof( optarg ); - this_proc_param = this_proc_param->next = - next_process_param( long_options[option_index].name, "real_4", - "%d", rand_seed ); - break; + injParams.mass1 = (REAL4) atof( optarg ); + this_proc_param = this_proc_param->next = + next_process_param( long_options[option_index].name, "real_4", + "%d", rand_seed ); + break; case 'd': - injParams.mass2 = (REAL4) atof( optarg ); - this_proc_param = this_proc_param->next = - next_process_param( long_options[option_index].name, "real_4", - "%d", rand_seed ); - break; + injParams.mass2 = (REAL4) atof( optarg ); + this_proc_param = this_proc_param->next = + next_process_param( long_options[option_index].name, "real_4", + "%d", rand_seed ); + break; case 'e': - injParams.distance = (REAL4) atof( optarg ); - this_proc_param = this_proc_param->next = - next_process_param( long_options[option_index].name, "real_4", - "%d", rand_seed ); - break; + injParams.distance = (REAL4) atof( optarg ); + this_proc_param = this_proc_param->next = + next_process_param( long_options[option_index].name, "real_4", + "%d", rand_seed ); + break; case 'f': abort(); @@ -295,64 +293,64 @@ int main ( int argc, char *argv[] ) break; case 'i': - injParams.inclination = (REAL4) atof( optarg ); - this_proc_param = this_proc_param->next = - next_process_param( long_options[option_index].name, "real_4", - "%d", rand_seed ); - break; + injParams.inclination = (REAL4) atof( optarg ); + this_proc_param = this_proc_param->next = + next_process_param( long_options[option_index].name, "real_4", + "%d", rand_seed ); + break; case 'j': - injParams.coa_phase= (REAL4) atof( optarg ); - this_proc_param = this_proc_param->next = - next_process_param( long_options[option_index].name, "real_4", - "%d", rand_seed ); - break; + injParams.coa_phase= (REAL4) atof( optarg ); + this_proc_param = this_proc_param->next = + next_process_param( long_options[option_index].name, "real_4", + "%d", rand_seed ); + break; case 'k': - injParams.polarization = (REAL4) atof( optarg ); - this_proc_param = this_proc_param->next = - next_process_param( long_options[option_index].name, "real_4", - "%d", rand_seed ); - break; + injParams.polarization = (REAL4) atof( optarg ); + this_proc_param = this_proc_param->next = + next_process_param( long_options[option_index].name, "real_4", + "%d", rand_seed ); + break; case 'l': - snprintf( &(injParams.waveform), - LIGOMETA_WAVEFORM_MAX * sizeof(CHAR), "%s", optarg ); - this_proc_param = this_proc_param->next = - next_process_param( long_options[option_index].name, "string", - "%s", optarg ); + snprintf( &(injParams.waveform), + LIGOMETA_WAVEFORM_MAX * sizeof(CHAR), "%s", optarg ); + this_proc_param = this_proc_param->next = + next_process_param( long_options[option_index].name, "string", + "%s", optarg ); break; case 'Z': - /* create storage for the usertag */ - optarg_len = strlen( optarg ) + 1; - userTag = (CHAR *) calloc( optarg_len, sizeof(CHAR) ); - memcpy( userTag, optarg, optarg_len ); - - this_proc_param = this_proc_param->next = (ProcessParamsTable *) - calloc( 1, sizeof(ProcessParamsTable) ); - snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", - PROGRAM_NAME ); - snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "-userTag" ); - snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); - snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, "%s", - optarg ); - break; + /* create storage for the usertag */ + optarg_len = strlen( optarg ) + 1; + userTag = (CHAR *) calloc( optarg_len, sizeof(CHAR) ); + memcpy( userTag, optarg, optarg_len ); + + this_proc_param = this_proc_param->next = (ProcessParamsTable *) + calloc( 1, sizeof(ProcessParamsTable) ); + snprintf( this_proc_param->program, LIGOMETA_PROGRAM_MAX, "%s", + PROGRAM_NAME ); + snprintf( this_proc_param->param, LIGOMETA_PARAM_MAX, "-userTag" ); + snprintf( this_proc_param->type, LIGOMETA_TYPE_MAX, "string" ); + snprintf( this_proc_param->value, LIGOMETA_VALUE_MAX, "%s", + optarg ); + break; case 'h': - fprintf( stderr, USAGE ); - exit( 0 ); - break; + fprintf( stderr, USAGE ); + exit( 0 ); + break; case '?': - fprintf( stderr, USAGE ); - exit( 1 ); - break; + fprintf( stderr, USAGE ); + exit( 1 ); + break; default: - fprintf( stderr, "unknown error while parsing options\n" ); - fprintf( stderr, USAGE ); - exit( 1 ); + fprintf( stderr, "unknown error while parsing options\n" ); + fprintf( stderr, USAGE ); + exit( 1 ); } } @@ -360,7 +358,7 @@ int main ( int argc, char *argv[] ) { /* default to Tev's GeneratePPNInspiral as used in */ snprintf( waveform, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR), - "GeneratePPNtwoPN" ); + "GeneratePPNtwoPN" ); } diff --git a/lalapps/src/inspiral/minj.c b/lalapps/src/inspiral/minj.c index d197a0d943fa729b8573f6b70dcc766ffd3d44d9..0277a5afae3256606a3b8279f8126651e3f438d2 100644 --- a/lalapps/src/inspiral/minj.c +++ b/lalapps/src/inspiral/minj.c @@ -139,7 +139,6 @@ double halo_pdf( int main( int argc, char *argv[] ) { LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; const INT4 S2StartTime = 729273613; /* Feb 14 2003 16:00:00 UTC */ const INT4 S2StopTime = 734367613; /* Apr 14 2003 15:00:00 UTC */ @@ -196,7 +195,7 @@ int main( int argc, char *argv[] ) {"gps-start-time", required_argument, 0, 'a'}, {"gps-end-time", required_argument, 0, 'b'}, {"time-step", required_argument, 0, 't'}, - {"time-interval", required_argument, 0, 'i'}, + {"time-interval", required_argument, 0, 'i'}, {"seed", required_argument, 0, 's'}, {"minimum-mass", required_argument, 0, 'A'}, {"maximum-mass", required_argument, 0, 'B'}, @@ -217,20 +216,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) @@ -657,8 +655,7 @@ int main( int argc, char *argv[] ) /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable, diff --git a/lalapps/src/inspiral/ninja.c b/lalapps/src/inspiral/ninja.c index 1eb225aa7aab8a548e7df22a5c0f568d77ab19ff..71b31eda9e2b97032f0deb2362ce5facaed810fa 100644 --- a/lalapps/src/inspiral/ninja.c +++ b/lalapps/src/inspiral/ninja.c @@ -162,7 +162,6 @@ int main( INT4 argc, CHAR *argv[] ) MetadataTable proctable; MetadataTable procparams; ProcessParamsTable *this_proc_param = NULL; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* nrwave stuff */ NinjaMetaData metaData; @@ -257,12 +256,12 @@ int main( INT4 argc, CHAR *argv[] ) /* create a frame cache by globbing *.gwf in specified dir */ LAL_CALL( LALFrCacheGenerate( &status, &frGlobCache, uvar_nrDir, uvar_pattern ), - &status ); + &status ); memset( &sieve, 0, sizeof(FrCacheSieve) ); /* sieve doesn't actually do anything yet */ LAL_CALL( LALFrCacheSieve( &status, &frInCache, frGlobCache, &sieve ), - &status ); + &status ); LAL_CALL( LALDestroyFrCache( &status, &frGlobCache ), &status ); @@ -295,10 +294,10 @@ int main( INT4 argc, CHAR *argv[] ) /* alloc next element of inspiral table linked list*/ if ( injections.simInspiralTable ) { - this_inj = this_inj->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); + this_inj = this_inj->next = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); } else { - injections.simInspiralTable = this_inj = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); + injections.simInspiralTable = this_inj = (SimInspiralTable *)LALCalloc( 1, sizeof(SimInspiralTable) ); } get_minmax_modes( &minMode,&maxMode,frame); @@ -333,29 +332,27 @@ int main( INT4 argc, CHAR *argv[] ) /* first the process table */ proctable.processTable = (ProcessTable *)LALCalloc( 1, sizeof(ProcessTable) ); - - /*LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), &accuracy ), &status );*/ XLALGPSTimeNow ( &(proctable.processTable->start_time) ); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); memset( &xmlfp, 0, sizeof(LIGOLwXMLStream) ); LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlfp, uvar_outFile ), &status ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable, process_table ), &status ); @@ -369,9 +366,9 @@ int main( INT4 argc, CHAR *argv[] ) if ( procparams.processParamsTable ) { LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_params_table ), - &status ); + &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, procparams, - process_params_table ), &status ); + process_params_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status ); } @@ -380,9 +377,9 @@ int main( INT4 argc, CHAR *argv[] ) if ( injections.simInspiralTable ) { LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, sim_inspiral_table ), - &status ); + &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, injections, - sim_inspiral_table ), &status ); + sim_inspiral_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status ); } LogPrintfVerbatim (LOG_NORMAL, "done\n"); @@ -433,7 +430,7 @@ int main( INT4 argc, CHAR *argv[] ) /* metadata is stored in the history field comment -- this function parses the comment to fill the metadata struct */ int get_nr_metadata_from_framehistory(NinjaMetaData *data, - FrHistory *history) + FrHistory *history) { UINT4 stringlen=128; @@ -456,7 +453,7 @@ int get_nr_metadata_from_framehistory(NinjaMetaData *data, int get_metadata_from_string(NinjaMetaData *data, - CHAR *comment) + CHAR *comment) { CHAR *token; @@ -578,8 +575,8 @@ int metadata_in_range(NinjaMetaData *data, NrParRange *range) int get_minmax_modes(INT4 *min, - INT4 *max, - FrameH *frame) + INT4 *max, + FrameH *frame) { int ret=1; INT4 mode_l, mode_m, locmin, locmax; @@ -591,9 +588,9 @@ int get_minmax_modes(INT4 *min, while (sim) { if (!get_mode_index_from_channel_name( &mode_l, &mode_m, sim->name)) { if (locmin > mode_l) - locmin = mode_l; + locmin = mode_l; if (locmax < mode_l) - locmax = mode_l; + locmax = mode_l; } sim = sim->next; @@ -607,8 +604,8 @@ int get_minmax_modes(INT4 *min, /* very hackish -- need to make this better */ int get_mode_index_from_channel_name(INT4 *mode_l, - INT4 *mode_m, - CHAR *name) + INT4 *mode_m, + CHAR *name) { int ret=1; CHAR *tmp; @@ -662,7 +659,7 @@ int get_mode_index_from_channel_name(INT4 *mode_l, /** take a list of numrel group names separated by ";" and parse it to get a vector of NumRelGroup */ int parse_group_list ( NrParRange *range, - CHAR *list) + CHAR *list) { UINT4 numGroups=0; @@ -685,10 +682,10 @@ int parse_group_list ( NrParRange *range, /* if the parsing was successful, add to list */ if (thisGroup != NINJA_GROUP_LAST) { - - numGroups++; - grouplist = LALRealloc(grouplist, numGroups*sizeof(*grouplist)); - grouplist[numGroups-1] = thisGroup; + + numGroups++; + grouplist = LALRealloc(grouplist, numGroups*sizeof(*grouplist)); + grouplist[numGroups-1] = thisGroup; } token = strtok(NULL,";"); } diff --git a/lalapps/src/inspiral/nullstream.c b/lalapps/src/inspiral/nullstream.c index 629971bf23662f63138832ed1af9509bd17a3c0c..9d44eae04f355abc9ea103263930237af4728233 100644 --- a/lalapps/src/inspiral/nullstream.c +++ b/lalapps/src/inspiral/nullstream.c @@ -60,7 +60,6 @@ #include <lal/AVFactories.h> #include <lal/LALConstants.h> #include <lal/FrameStream.h> -#include <lal/DataBuffer.h> #include <lal/LIGOMetadataTables.h> #include <lal/LIGOMetadataUtils.h> #include <lal/LIGOLwXML.h> @@ -138,7 +137,6 @@ int gpsStartTimeTemp = 0; /* input data GPS start time ns */ int gpsEndTimeTemp = 0; /* input data GPS start time ns */ LALStatus status; -LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; CHAR *userTag = NULL; /* string the user can tag with */ CHAR *ifoTag = NULL; /* string to tag IFOs */ @@ -229,20 +227,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) LALCalloc(1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) LALCalloc( 1, sizeof(ProcessParamsTable) ); @@ -691,8 +688,7 @@ int main( int argc, char *argv[] ) /* process table */ if ( vrbflg ) fprintf( stdout, "Writing the process table..." ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, proctable, @@ -977,7 +973,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) "Messaritaki <emess@caltech.ed>\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; diff --git a/lalapps/src/inspiral/plot_hipe.in b/lalapps/src/inspiral/plot_hipe.in index fd1b00c02d206bc846f6cacc3f7bb7bbabfd3933..99333cf06486b996888258a81fd44d68e7ee59fa 100644 --- a/lalapps/src/inspiral/plot_hipe.in +++ b/lalapps/src/inspiral/plot_hipe.in @@ -624,7 +624,9 @@ if opts.plotcoincmissed: "SIRE_INJECTIONS_*_" + short_suffix + \ "_FOUND_SUMMARY_FIRST_" + short_suffix ) plotcoincmissed_jobs['plotcoincmissed']. add_opt( "missed-pattern", - short_suffix + "_MISSED_SUMMARY_SECOND_*_" + this_suffix ) + short_suffix + "_MISSED_SUMMARY_SECOND_*_" + short_suffix ) + plotcoincmissed_jobs['plotcoincmissed']. add_opt( "inj-string", + short_suffix ) plotcoincmissed_jobs['plotcoincmissed'].set_sub_file( basename + '.plotcoincmissed' + subsuffix ) diff --git a/lalapps/src/inspiral/posterior/LALInspiralMCMC.c b/lalapps/src/inspiral/posterior/LALInspiralMCMC.c index 0e63967722f1adc23bd026b4bb5360343b4f9861..e403130839b2e34f3eec370ed0712b96bad9dc4e 100644 --- a/lalapps/src/inspiral/posterior/LALInspiralMCMC.c +++ b/lalapps/src/inspiral/posterior/LALInspiralMCMC.c @@ -105,7 +105,6 @@ This section briefly explains how to set-up the \texttt{MCMCInput} and the \text The first step is to initialize the \texttt{MCMCInput} structure with the output from data reading and conditioning, as well with user inputs to define settings for the MCMC. Also, the user is required to set the pointer to three functions which will initialize the parameter structure ({\tt funcInit}), that calculates the logarithm of the likelihood for a given set of parameters ({\tt funcLikelihood}) and that calculates the logarithm of the prior given a set of parameters ({\tt funcPrior}). Below is an example: \begin{verbatim} - /* populate the input structure*/ LALMCMCInput inputMCMC; inputMCMC.fcFilterInput = fcFilterInput; inputMCMC.fcFilterParams = fcFilterParams; @@ -115,32 +114,26 @@ The first step is to initialize the \texttt{MCMCInput} structure with the output inputMCMC.approximant = approximant; inputMCMC.inspiralTable = inputCurrent; - /* just a 'dummy' parameter */ inputMCMC.tmpltPtr = (InspiralTemplate*)LALCalloc(sizeof(InspiralTemplate),1); - /* reset some counters etc */ inputMCMC.counter=0; - /* set parameters for annealing */ inputMCMC.useAnnealing = 0; inputMCMC.numberAnneal=iterAnneal; inputMCMC.annealingTempBegin=4.0; inputMCMC.annealingTemp=1.0; inputMCMC.annealingSteps=0; - /* set parameters for scaling */ inputMCMC.useScaling = 1; inputMCMC.scalePeak=50.0; inputMCMC.scaleNormal=1.0; inputMCMC.scaleQ=0.84; inputMCMC.scalePA=1e-3; - /* set parameters for AcceptRatio */ inputMCMC.flagAcceptRatio=1; inputMCMC.acceptRatioCounter=0; - /* set parameters for matrix updating */ inputMCMC.useUpdate=1; inputMCMC.updateNumber=iterCovupdate; inputMCMC.updateOffset=100; @@ -149,13 +142,11 @@ The first step is to initialize the \texttt{MCMCInput} structure with the output inputMCMC.xdiff=NULL; inputMCMC.ndiff=NULL; - /* set parameters for burnin */ inputMCMC.flagBurnin = 1; inputMCMC.burninNumber = 100; - inputMCMC.burninStep = 100;/*must be smaller or equal to burninNumber*/ + inputMCMC.burninStep = 100; inputMCMC.burninTime = 0; - /* set the drawing number */ inputMCMC.numberDraw=iterDraw; inputMCMC.verbose=1; @@ -675,7 +666,7 @@ XLALMCMCSample( LALMCMCParameter *help=NULL; /* help parameter set */ LALMCMCParam* paraHead = NULL; - REAL4 alpha, random, s; + REAL4 alpha, my_random, s; REAL4 logPrior, logLikelihood, logPosterior; UINT4 move, accept, c; INT4 testPrior; @@ -724,10 +715,10 @@ XLALMCMCSample( /* calculate the alpha-value and draw a random number */ s=inputMCMC->scaling; alpha=exp( s*(logPosterior - *oldLogPosterior) ); - LALUniformDeviate( &status, &random, inputMCMC->randParams ); + LALUniformDeviate( &status, &my_random, inputMCMC->randParams ); /* now check accept/reject criterion */ - if ( random<=alpha ) + if ( my_random<=alpha ) { /* accept the proposal set */ move = 1; @@ -750,7 +741,7 @@ XLALMCMCSample( printf("MCMCSAMPLE: --JumpNotAccepted "); printf("current logPost: %6.3f proposal logPost: %6.3f alpha: %6.3f " "u: %6.3f\n", - *oldLogPosterior, logPosterior, alpha, random); + *oldLogPosterior, logPosterior, alpha, my_random); } } @@ -809,11 +800,11 @@ return; void normalise(REAL8 vec[3]); void normalise(REAL8 vec[3]){ -REAL8 abs=0.0; -abs=sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]); -vec[0]/=abs; -vec[1]/=abs; -vec[2]/=abs; +REAL8 my_abs=0.0; +my_abs=sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]); +vec[0]/=my_abs; +vec[1]/=my_abs; +vec[2]/=my_abs; return; } @@ -862,7 +853,7 @@ INT4 XLALMCMCReflectDetPlane( { /* Function to reflect a point on the sky about the plane of 3 detectors */ /* Returns -1 if not possible */ static LALStatus status; -int i,j,k; +UINT4 i,j; int DetCollision=0; REAL4 randnum; REAL8 longi,lat,newlong,newlat; @@ -973,7 +964,7 @@ void XLALMCMCRotateSky( REAL8 vec[3]; REAL8 cur[3]; REAL8 longi,lat; - REAL8 vec_abs=0.0,theta,c,s,r; + REAL8 vec_abs=0.0,theta,c,s; INT4 i,j; if(inputMCMC->numberDataStreams<2) return; @@ -1101,7 +1092,7 @@ XLALMCMCJump( LALMCMCParam *paraHead=NULL; REAL4Vector *step=NULL; gsl_matrix *work=NULL; - REAL8 aii, aij, ajj, delta; + REAL8 aii, aij, ajj; INT4 i, j, dim; /* set some values */ @@ -1150,7 +1141,8 @@ XLALMCMCJump( /* if (inputMCMC->verbose) printf("MCMCJUMP: %10s: value: %8.3f step: %8.3f newVal: %8.3f\n", paraHead->core->name, paraHead->value, step->data[i] , paraHead->value + step->data[i]);*/ - paraHead->value += step->data[i]; + + if(paraHead->core->wrapping!=-1) paraHead->value += step->data[i]; } XLALMCMCCyclicReflectiveBound(parameter); @@ -1171,7 +1163,7 @@ XLALMCMCJumpIntrinsic( LALMCMCParam *paraHead=NULL; REAL4Vector *step=NULL; gsl_matrix *work=NULL; - REAL8 aii, aij, ajj, delta; + REAL8 aii, aij, ajj; INT4 i, j, dim; /* set some values */ @@ -1215,7 +1207,7 @@ XLALMCMCJumpIntrinsic( /* loop over all parameters */ for (paraHead=parameter->param,i=0; paraHead; paraHead=paraHead->next,i++) { - if(!strcmp(paraHead->core->name,"long") || !strcmp(paraHead->core->name,"lat")||!strcmp(paraHead->core->name,"time")) + if(!strcmp(paraHead->core->name,"long") || !strcmp(paraHead->core->name,"lat")||!strcmp(paraHead->core->name,"time")||paraHead->core->wrapping==-1) {;} /* if (inputMCMC->verbose) printf("MCMCJUMP: %10s: value: %8.3f step: %8.3f newVal: %8.3f\n", @@ -1238,7 +1230,7 @@ function to keep its proposals inside the parameter space */ REAL8 delta; for (paraHead=parameter->param;paraHead;paraHead=paraHead->next) { - if(paraHead->core->wrapping) /* For cyclic boundaries */ + if(paraHead->core->wrapping==1) /* For cyclic boundaries */ { delta = paraHead->core->maxVal - paraHead->core->minVal; while ( paraHead->value > paraHead->core->maxVal) @@ -1246,7 +1238,7 @@ function to keep its proposals inside the parameter space */ while ( paraHead->value < paraHead->core->minVal) paraHead->value += delta; } - else /* Use reflective boundaries */ + else if(paraHead->core->wrapping==0) /* Use reflective boundaries */ { if(paraHead->core->maxVal < paraHead->value) paraHead->value-=2.0*(paraHead->value - paraHead->core->maxVal); if(paraHead->core->minVal > paraHead->value) paraHead->value+=2.0*(paraHead->core->minVal - paraHead->value); @@ -1266,6 +1258,13 @@ INT4 XLALMCMCCheckParameter( } +INT4 XLALMCMCCheckWrapping(LALMCMCParameter *parameter, + const char *name) +{ + LALMCMCParam *param=NULL; + param=XLALMCMCGetParam(parameter,name); + return param->core->wrapping; +} /* ***************************** XLALMCMCAddParam @@ -1282,8 +1281,6 @@ XLALMCMCAddParam( ) { /* </lalVerbatim> */ - static LALStatus status; - LALMCMCParam* paraPointer; if ( !parameter ) @@ -1404,7 +1401,7 @@ XLALMCMCSetParameter( LALMCMCParam* param; param=XLALMCMCGetParam( parameter, name); - if (param) + if (param && param->core->wrapping!=-1) { param->value=value; } @@ -1488,7 +1485,6 @@ XLALMCMCFreePara( { /* </lalVerbatim> */ LALMCMCParam* param=NULL; - LALMCMCParam* paramNext=NULL; LALMCMCParam* thisParam=NULL; diff --git a/lalapps/src/inspiral/posterior/LALInspiralMCMC.h b/lalapps/src/inspiral/posterior/LALInspiralMCMC.h index 5b1b20b36c9a68e952d04f9b1fbc6b0c3f58242e..31e5c854ae4f52765eca1a1b8e6ec09c26876dad 100644 --- a/lalapps/src/inspiral/posterior/LALInspiralMCMC.h +++ b/lalapps/src/inspiral/posterior/LALInspiralMCMC.h @@ -35,6 +35,7 @@ Header file for the MCMC tools code. # include <lal/LIGOMetadataTables.h> # include <lal/LALDatatypes.h> # include <lal/FindChirp.h> +#include <lal/Window.h> #include <lal/LALDetectors.h> #include <gsl/gsl_linalg.h> #include <gsl/gsl_errno.h> @@ -209,7 +210,7 @@ tagLALMCMCSubParam char name[30]; REAL8 minVal; REAL8 maxVal; - INT4 wrapping; + INT4 wrapping; /* 0=no, 1=yes, -1=fixed */ REAL4Vector *chain; } LALMCMCSubParam; @@ -535,7 +536,10 @@ XLALCheckPositiveDefinite( gsl_matrix *matrix, UINT4 dim); - +INT4 XLALMCMCCheckWrapping(LALMCMCParameter *parameter, + const char *name); + + #ifdef __cplusplus } #endif diff --git a/lalapps/src/inspiral/posterior/LALInspiralMCMCUser.c b/lalapps/src/inspiral/posterior/LALInspiralMCMCUser.c index 18ff9d9b2ae35c25671aa53237c602ff4f7229cc..dc3a7c6dc8adebfcfc56cbc5a8a32d6ab70e2c70 100644 --- a/lalapps/src/inspiral/posterior/LALInspiralMCMCUser.c +++ b/lalapps/src/inspiral/posterior/LALInspiralMCMCUser.c @@ -179,7 +179,7 @@ INT4 MCMCPriorTest( int ParamInRange(LALMCMCParameter *parameter) { -int i; +UINT4 i; int inrange=1; LALMCMCParam *p=parameter->param; for(i=0;i<parameter->dimension;i++){ @@ -190,56 +190,13 @@ if(!inrange) parameter->logPrior = -DBL_MAX; return inrange; } -void NestInitInj(LALMCMCParameter *parameter, void *iT){ -REAL8 time; -SimInspiralTable *injTable = (SimInspiralTable *)iT; -REAL4 mtot,eta,mwindow,localetawin; - REAL8 mc,mcmin,mcmax,lmmin,lmmax; -parameter->param = NULL; -parameter->dimension = 0; -time = (REAL8) injTable->geocent_end_time.gpsSeconds + (REAL8)injTable->geocent_end_time.gpsNanoSeconds *1.0e-9; -mtot = injTable->mass1 + injTable->mass2; -eta = injTable->eta; -mwindow = 0.2; -double etamin; -/*etamin = etamin<0.01?0.01:etamin;*/ -etamin=0.01; -double etamax = 0.25; -mc=m2mc(injTable->mass1,injTable->mass2); -mcmin=m2mc(1.0,1.0); -mcmax=m2mc(17.5,17.5); - - lmmin=log(mcmin); - lmmax=log(mcmax); -localetawin=etamax-etamin; - - XLALMCMCAddParam(parameter,"logM",lmmin+(lmmax-lmmin)*gsl_rng_uniform(RNG),lmmin,lmmax,0); - /*XLALMCMCAddParam(parameter,"mchirp",mcmin+(mcmax-mcmin)*gsl_rng_uniform(RNG),mcmin,mcmax,0);*/ - - -XLALMCMCAddParam(parameter, "eta", gsl_rng_uniform(RNG)*localetawin+etamin , etamin, etamax, 0); -XLALMCMCAddParam(parameter, "time", (gsl_rng_uniform(RNG)-0.5)*timewindow + time ,time-0.5*timewindow,time+0.5*timewindow,0); -XLALMCMCAddParam(parameter, "phi", LAL_TWOPI*gsl_rng_uniform(RNG),0.0,LAL_TWOPI,1); -XLALMCMCAddParam(parameter, "distMpc", 99.0*gsl_rng_uniform(RNG)+1.0, 1.0, 100.0, 0); - -XLALMCMCAddParam(parameter,"long",LAL_TWOPI*gsl_rng_uniform(RNG),0,LAL_TWOPI,1); -XLALMCMCAddParam(parameter,"lat",LAL_PI*(gsl_rng_uniform(RNG)-0.5),-LAL_PI/2.0,LAL_PI/2.0,0); - - -XLALMCMCAddParam(parameter,"psi",0.5*LAL_PI*gsl_rng_uniform(RNG),0,LAL_PI/2.0,0); -XLALMCMCAddParam(parameter,"iota",LAL_PI*gsl_rng_uniform(RNG),0,LAL_PI,0); - - -return; -} - void NestInitInjNINJA(LALMCMCParameter *parameter, void *iT){ -REAL8 time,mcmin,mcmax; +REAL8 trg_time,mcmin,mcmax; SimInspiralTable *injTable = (SimInspiralTable *)iT; REAL4 mtot,eta,mwindow,localetawin; parameter->param = NULL; parameter->dimension = 0; -time = (REAL8) injTable->geocent_end_time.gpsSeconds + (REAL8)injTable->geocent_end_time.gpsNanoSeconds *1.0e-9; +trg_time = (REAL8) injTable->geocent_end_time.gpsSeconds + (REAL8)injTable->geocent_end_time.gpsNanoSeconds *1.0e-9; REAL8 mchirp,total; /*eta = injTable->eta;*/ @@ -266,7 +223,7 @@ XLALMCMCAddParam(parameter,"mchirp",mchirp,mcmin,mcmax,0); /*XLALMCMCAddParam(parameter,"mtotal",gsl_rng_uniform(RNG)*100.0+50.0,50.0,150.0,0);*/ /*XLALMCMCAddParam(parameter,"mtotal",3.0+27.0*gsl_rng_uniform(RNG),3.0,30.0,0);*/ XLALMCMCAddParam(parameter, "eta", eta , etamin, etamax, 0); -XLALMCMCAddParam(parameter, "time", (gsl_rng_uniform(RNG)-0.5)*timewindow + time ,time-0.5*timewindow,time+0.5*timewindow,0); +XLALMCMCAddParam(parameter, "time", (gsl_rng_uniform(RNG)-0.5)*timewindow + trg_time ,trg_time-0.5*timewindow,trg_time+0.5*timewindow,0); XLALMCMCAddParam(parameter, "phi", LAL_TWOPI*gsl_rng_uniform(RNG),0.0,LAL_TWOPI,1); XLALMCMCAddParam(parameter, "distMpc", 499.0*gsl_rng_uniform(RNG)+1.0, 1.0, 500.0, 0); XLALMCMCAddParam(parameter,"long",LAL_TWOPI*gsl_rng_uniform(RNG),0,LAL_TWOPI,1); @@ -279,12 +236,12 @@ return; } void NestInitInjNINJAHighMass(LALMCMCParameter *parameter, void *iT){ -REAL8 time,mcmin,mcmax; +REAL8 trg_time,mcmin,mcmax; SimInspiralTable *injTable = (SimInspiralTable *)iT; REAL4 mtot,eta,mwindow,localetawin; parameter->param = NULL; parameter->dimension = 0; -time = (REAL8) injTable->geocent_end_time.gpsSeconds + (REAL8)injTable->geocent_end_time.gpsNanoSeconds *1.0e-9; +trg_time = (REAL8) injTable->geocent_end_time.gpsSeconds + (REAL8)injTable->geocent_end_time.gpsNanoSeconds *1.0e-9; REAL8 mchirp,total; /*eta = injTable->eta;*/ @@ -311,7 +268,7 @@ XLALMCMCAddParam(parameter,"mchirp",mchirp,mcmin,mcmax,0); /*XLALMCMCAddParam(parameter,"mtotal",gsl_rng_uniform(RNG)*100.0+50.0,50.0,150.0,0);*/ /*XLALMCMCAddParam(parameter,"mtotal",3.0+27.0*gsl_rng_uniform(RNG),3.0,30.0,0);*/ XLALMCMCAddParam(parameter, "eta", eta , etamin, etamax, 0); -XLALMCMCAddParam(parameter, "time", (gsl_rng_uniform(RNG)-0.5)*timewindow + time ,time-0.5*timewindow,time+0.5*timewindow,0); +XLALMCMCAddParam(parameter, "time", (gsl_rng_uniform(RNG)-0.5)*timewindow + trg_time ,trg_time-0.5*timewindow,trg_time+0.5*timewindow,0); XLALMCMCAddParam(parameter, "phi", LAL_TWOPI*gsl_rng_uniform(RNG),0.0,LAL_TWOPI,1); XLALMCMCAddParam(parameter, "distMpc", 499.0*gsl_rng_uniform(RNG)+1.0, 1.0, 500.0, 0); XLALMCMCAddParam(parameter,"long",LAL_TWOPI*gsl_rng_uniform(RNG),0,LAL_TWOPI,1); @@ -325,19 +282,23 @@ return; REAL8 GRBPrior(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) { - REAL8 mNS,mComp; + REAL8 mNS,mComp,logmc; REAL8 mc,eta; /* Priors for the GRB component masses */ #define m1min 1.0 #define m1max 3.0 #define m2min 1.0 #define m2max 35.0 + parameter->logPrior=0.0; if(XLALMCMCCheckParameter(parameter,"logM")) mc=exp(XLALMCMCGetParameter(parameter,"logM")); else mc=XLALMCMCGetParameter(parameter,"mchirp"); + logmc=log(mc); + parameter->logPrior+=-(5.0/6.0)*logmc; + eta=XLALMCMCGetParameter(parameter,"eta"); parameter->logPrior+=log(fabs(cos(XLALMCMCGetParameter(parameter,"lat")))); parameter->logPrior+=log(fabs(sin(XLALMCMCGetParameter(parameter,"iota")))); - parameter->logPrior+=logJacobianMcEta(mc,eta); + /*parameter->logPrior+=logJacobianMcEta(mc,eta);*/ parameter->logPrior-=2.0*log(XLALMCMCGetParameter(parameter,"distMpc")); ParamInRange(parameter); /*check GRB component masses */ @@ -350,7 +311,7 @@ REAL8 GRBPrior(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) REAL8 NestPriorHighMass(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) { - REAL8 m1,m2,logdl,ampli,a=50,b=21; + REAL8 m1,m2; parameter->logPrior=0.0; REAL8 mc,eta; REAL8 minCompMass = 1.0; @@ -376,11 +337,12 @@ REAL8 NestPriorHighMass(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) REAL8 NestPrior(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) { - REAL8 m1,m2,logdl,ampli,a=50,b=21; + REAL8 m1,m2; parameter->logPrior=0.0; REAL8 mc,eta; REAL8 minCompMass = 1.0; - REAL8 maxCompMass = 35.0; + REAL8 maxCompMass = 34.0; +#define MAX_MTOT 35.0 /* copied from alex's function */ /* logdl=2.0*XLALMCMCGetParameter(parameter,"distMpc"); parameter->logPrior+=2.0*logdl; @@ -392,10 +354,12 @@ REAL8 NestPrior(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) /* Check in range */ if(XLALMCMCCheckParameter(parameter,"logM")) mc=exp(XLALMCMCGetParameter(parameter,"logM")); else mc=XLALMCMCGetParameter(parameter,"mchirp"); - + double logmc=log(mc); eta=XLALMCMCGetParameter(parameter,"eta"); m1 = mc2mass1(mc,eta); m2 = mc2mass2(mc,eta); + /* This term is the sqrt of m-m term in F.I.M, ignoring dependency on f and eta */ + parameter->logPrior+=-(5.0/6.0)*logmc; parameter->logPrior+=log(fabs(cos(XLALMCMCGetParameter(parameter,"lat")))); parameter->logPrior+=log(fabs(sin(XLALMCMCGetParameter(parameter,"iota")))); @@ -404,109 +368,10 @@ REAL8 NestPrior(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) if(inputMCMC->approximant==IMRPhenomA && mc2mt(mc,eta)>475.0) parameter->logPrior=-DBL_MAX; if(m1<minCompMass || m2<minCompMass) parameter->logPrior=-DBL_MAX; if(m1>maxCompMass || m2>maxCompMass) parameter->logPrior=-DBL_MAX; + if(m1+m2>MAX_MTOT) parameter->logPrior=-DBL_MAX; return parameter->logPrior; } -REAL8 MCMCLikelihood1IFO(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter,int idx) -{ -/* Function to generate a inspiral wave using LALInspiralWave, then calculate the log - likelihood for a single interferometer */ - -/* WARNING! THIS ASSUMES THAT THE DATA IN inputMCMC->stilde IS NOT MULTIPLIED BY THE - PSD, i.e. IT IS JUST THE WINDOWED FFT OF THE TIME SERIES. We probably want to create a new field - in the inputMCMC structure to hold this data to avoid confusion */ - - static LALStatus status; - InspiralTemplate template; - UINT4 Nmodel; /* Length of the model */ - INT4 i; - int Fdomain; -/* memset(&status,0,sizeof(LALStatus)); */ - REAL8 chisq=0.0; - REAL8 real,imag,f,t; - REAL8 Mchirp; - REAL8 eta; - Fdomain = 1; - memset(&template,0,sizeof(InspiralTemplate)); -/* Populate the template */ - if(XLALMCMCCheckParameter(parameter,"logM")) Mchirp=exp(XLALMCMCGetParameter(parameter,"logM")); - else Mchirp = XLALMCMCGetParameter(parameter,"mchirp"); - eta = XLALMCMCGetParameter(parameter,"eta"); - template.totalMass = mc2mt(Mchirp,eta); - template.eta = eta; - template.massChoice = totalMassAndEta; - template.fLower = inputMCMC->fLow; - template.distance = XLALMCMCGetParameter(parameter,"distMpc"); - template.order=LAL_PNORDER_TWO; - template.approximant=inputMCMC->approximant; - template.tSampling = 1.0/inputMCMC->deltaT; - template.fCutoff = 0.5/inputMCMC->deltaT -1.0; - template.nStartPad = 0; - template.nEndPad =0; - template.startPhase = XLALMCMCGetParameter(parameter,"phi"); - template.startTime = XLALMCMCGetParameter(parameter,"time"); - template.startTime -= inputMCMC->stilde[idx]->epoch.gpsSeconds + 1e-9*inputMCMC->stilde[idx]->epoch.gpsNanoSeconds; - template.ieta = 1; - template.next = NULL; - template.fine = NULL; - -/*fprintf(stderr,"XLALErrNoGlobal=%i\n",*XLALGetErrnoPtr()); -XLALClearErrno();*/ - -/* Is this the correct way to set the end time? */ -/* XLALGPSSetREAL8((&template.end_time),XLALMCMCGetParameter(parameter,"time"));*/ -/* Fill the rest of the mass/tc parameters in */ - LALInspiralParameterCalc(&status,&template); - - template.startTime-=template.tC; - - LALInspiralRestrictedAmplitude(&status,&template); - -/* Find the number of points needed to store the template - disabled */ - /*LALInspiralWaveLength(&status,&Nmodel,template);*/ -/* Set the number of points in the template from the lengh of the data */ - - if(Fdomain) Nmodel=inputMCMC->stilde[idx]->data->length*2; /* *2 for real/imag packing format */ - else Nmodel = inputMCMC->segment[idx]->data->length; - - if(model==NULL) LALCreateVector(&status,&model,Nmodel); - - LALInspiralWave(&status,model,&template); /* Create the model */ - - if(inputMCMC->verbose) fprintf(stderr,"duration: %fs\tfinal freq: %f Hz \n",template.tC,template.fFinal); -/* FILE *fp=fopen("waveform.txt","w"); - for(i=0;i<model->length;i++) fprintf(fp,"%e %e\n",i/(Nmodel/template.tSampling),model->data[i]); - fclose(fp); - fp=fopen("data.txt","w"); - for(i=0;i<inputMCMC->stilde[idx]->data->length;i++) fprintf(fp,"%e %e %e\n",i*inputMCMC->stilde[idx]->deltaF,inputMCMC->stilde[idx]->data->data[i].re,inputMCMC->stilde[idx]->data->data[i].im); - fclose(fp); -*/ - if(Fdomain){ - /* model is a f-domain vector with complex representation = model[j] + i*model[Nmodel-j] */ - int lowBin = (int)(inputMCMC->fLow / inputMCMC->stilde[idx]->deltaF); - /* Compute the -logL */ - for(i=lowBin;i<Nmodel/2;i++){ - real=inputMCMC->stilde[idx]->data->data[i].re - (REAL8) model->data[i]; - imag=inputMCMC->stilde[idx]->data->data[i].im - (REAL8) model->data[Nmodel-i]; - chisq+=(real*real + imag*imag)*inputMCMC->invspec[idx]->data->data[i]; -/* printf("%e\t%e\t%e\t%e\n",inputMCMC->invspec[idx]->data->data[i],real,imag,chisq); */ - } - chisq*=2.0; /* for 2 sigma^2 on denominator */ -/* LALDestroyVector(&status,&model); */ /* Free the model vector */ - /* add the normalisation constant */ - for(i=lowBin;i<inputMCMC->invspec[idx]->data->length-1;i++) chisq+=0.5*log(inputMCMC->invspec[idx]->data->data[i]); - chisq+=(REAL8)( 0.5 * (inputMCMC->invspec[idx]->data->length-lowBin) * log(2.0*LAL_PI)); - } /* end F domain part */ - else { - /* T domain part yet to be written */ - - - } - - - return(-chisq); -} - REAL8 MCMCLikelihoodMultiCoherentF(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) /* Calculate the likelihood of the signal using multiple interferometer data sets, in the frequency domain */ @@ -654,10 +519,11 @@ in the frequency domain */ det_resp.cross*=ci; /* Compute the response to the wave in the detector */ REAL8 deltaF = inputMCMC->stilde[det_i]->deltaF; - int lowBin = (int)(inputMCMC->fLow / inputMCMC->stilde[det_i]->deltaF); - int highBin = (int)(template.fFinal / inputMCMC->stilde[det_i]->deltaF); - - for(idx=lowBin;idx<Nmodel/2;idx++){ + UINT4 lowBin = (UINT4)(inputMCMC->fLow / inputMCMC->stilde[det_i]->deltaF); + UINT4 highBin = (UINT4)(template.fFinal / inputMCMC->stilde[det_i]->deltaF); + if(highBin==0 || highBin>inputMCMC->stilde[det_i]->data->length-1) highBin=inputMCMC->stilde[det_i]->data->length-1; + + for(idx=lowBin;idx<=highBin;idx++){ time_sin = sin(LAL_TWOPI*(TimeFromGC+TimeShiftToGC)*((double) idx)*deltaF); time_cos = cos(LAL_TWOPI*(TimeFromGC+TimeShiftToGC)*((double) idx)*deltaF); @@ -685,7 +551,8 @@ that LAL uses. Please check this whenever any change is made */ #if DEBUGMODEL !=0 fclose(modelout); #endif - /* chisq+=topdown_sum[det_i]->data[highBin+1];*/ + if(highBin<inputMCMC->stilde[det_i]->data->length-2 && highBin>lowBin) chisq+=topdown_sum[det_i]->data[highBin+1]; + else if(highBin<=lowBin) chisq+=topdown_sum[det_i]->data[highBin+1]; chisq*=2.0*deltaF; /* for 2 sigma^2 on denominator, also in student-t version */ /* add the normalisation constant */ @@ -706,14 +573,14 @@ REAL8 MCMCSTLikelihoodMultiCoherentF(LALMCMCInput *inputMCMC,LALMCMCParameter *p in the frequency domain */ { REAL8 logL=0.0; - int det_i; + UINT4 det_i; CHAR name[10] = "inspiral"; REAL8 TimeFromGC; /* Time delay from geocentre */ static LALStatus status; REAL8 resp_r,resp_i,ci; InspiralTemplate template; UINT4 Nmodel; /* Length of the model */ - INT4 i,NtimeModel; + UINT4 i,NtimeModel; LALDetAMResponse det_resp; REAL4FFTPlan *likelihoodPlan=NULL; int Fdomain; @@ -893,149 +760,3 @@ that LAL uses. Please check this whenever any change is made */ return(logL); } - - -REAL8 MCMCLikelihoodMultiCoherent(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) -{ - REAL8 logL=0.0; - int det_i,i; - static LALStatus status; - PPNParamStruc PPNparams; - CoherentGW co_wave; /* output structure */ - DetectorResponse det_resp; - REAL4TimeSeries *template; - REAL8TimeSeries *cur_seg; - COMPLEX8FrequencySeries *Ftemplate; - REAL4FFTPlan *FFTplan; - REAL8 mchirp=0; - REAL8 eta=0; - if(XLALMCMCCheckParameter(parameter,"logM")) mchirp=exp(XLALMCMCGetParameter(parameter,"logM")); - else mchirp=XLALMCMCGetParameter(parameter,"mchirp"); - eta = XLALMCMCGetParameter(parameter,"eta"); - - - /* Populate input struct */ - PPNparams.mTot=(REAL4)mc2mt(mchirp,eta); - PPNparams.eta=(REAL4)eta; - PPNparams.d=(REAL4)XLALMCMCGetParameter(parameter,"distMpc")*MpcInMeters; - PPNparams.phi=(REAL4)XLALMCMCGetParameter(parameter,"phi"); - PPNparams.position.system=COORDINATESYSTEM_EQUATORIAL; - PPNparams.position.longitude=XLALMCMCGetParameter(parameter,"long"); - PPNparams.position.latitude=XLALMCMCGetParameter(parameter,"lat"); - PPNparams.psi=(REAL4)XLALMCMCGetParameter(parameter,"psi"); - PPNparams.inc=(REAL4)XLALMCMCGetParameter(parameter,"iota"); - PPNparams.deltaT=(REAL8)inputMCMC->deltaT; - PPNparams.fStartIn=(REAL4)inputMCMC->fLow; - PPNparams.fStopIn=(REAL4)0.5/inputMCMC->deltaT - 1.0; - PPNparams.lengthIn=0; /* Let the waveform be as long as necessary */ - PPNparams.ppn=NULL; - - memcpy(&(PPNparams.epoch),&(inputMCMC->epoch),sizeof(LIGOTimeGPS)); - - memset(&co_wave,0,sizeof(CoherentGW)); /* Blank the output fields */ - memset(&det_resp,0,sizeof(DetectorResponse)); /* Only need the detector field in this struct, the rest are left blank */ - - /* Create coherent waveform */ - LALGeneratePPNInspiral(&status,&co_wave,&PPNparams); - - - /* Adjust time */ - REAL8 tC=XLALMCMCGetParameter(parameter,"time"); - tC-=PPNparams.tc; /* tC is now the time the wave reaches the low frequency */ - XLALGPSSetREAL8(&(co_wave.a->epoch),tC); /* which is the starting epoch of the co_wave */ - memcpy(&(co_wave.f->epoch),&(co_wave.a->epoch),sizeof(LIGOTimeGPS)); - memcpy(&(co_wave.phi->epoch),&(co_wave.a->epoch),sizeof(LIGOTimeGPS)); - - FFTplan=XLALCreateForwardREAL4FFTPlan(inputMCMC->segment[0]->data->length,0); - /* Loop over detectors */ - for(det_i=0;det_i<inputMCMC->numberDataStreams;det_i++) - { - cur_seg=inputMCMC->segment[det_i]; - /* Allocate template */ - template=(REAL4TimeSeries *)XLALCreateREAL4TimeSeries("template",&(cur_seg->epoch),cur_seg->f0,cur_seg->deltaT,&(cur_seg->sampleUnits),(size_t)cur_seg->data->length); - /* compute waveform in detector det_i */ - det_resp.site=inputMCMC->detector[det_i]; - LALSimulateCoherentGW(&status,template,&co_wave,&det_resp); - - /* Calculate likelihood in that detector */ -/* char filename[100]; - sprintf(filename,"wave_%s.dat",inputMCMC->ifoID[det_i]); - FILE *fpout=fopen(filename,"w"); - for(i=0;i<template->data->length;i++) fprintf(fpout,"%e\t%10.10e\n",i*template->deltaT,template->data->data[i]); - fclose(fpout); -*/ - for(i=0;i<template->data->length;i++) template->data->data[i]*=(REAL4)inputMCMC->window->data->data[i]; - Ftemplate=(COMPLEX8FrequencySeries *)XLALCreateCOMPLEX8FrequencySeries("Ftemplate", - &(cur_seg->epoch), - cur_seg->f0, - 1.0/cur_seg->deltaT, - &(inputMCMC->stilde[det_i]->sampleUnits), - (size_t)inputMCMC->stilde[det_i]->data->length); - - XLALREAL4TimeFreqFFT(Ftemplate,template,FFTplan); -/* - sprintf(filename,"waveF_%sdat",inputMCMC->ifoID[det_i]); - fpout=fopen(filename,"w"); - int N=inputMCMC->stilde[det_i]->data->length; - for(i=0;i<Ftemplate->data->length;i++) fprintf(fpout,"%e\t%10.10e\t%10.10e\t%10.10e\t%10.10e\n",i*Ftemplate->deltaF,Ftemplate->data->data[i].re,Ftemplate->data->data[i].im,inputMCMC->stilde[det_i]->data->data[i].re,inputMCMC->stilde[det_i]->data->data[i].im); - fclose(fpout); -*/ - int lowBin = (int)(inputMCMC->fLow / inputMCMC->stilde[det_i]->deltaF); - /* Compute the -logL */ - REAL8 chisq=0.0; - for(i=lowBin;i<Ftemplate->data->length;i++){ - REAL8 real=inputMCMC->stilde[det_i]->data->data[i].re - (REAL8) Ftemplate->data->data[i].re; - REAL8 imag=inputMCMC->stilde[det_i]->data->data[i].im - (REAL8) Ftemplate->data->data[i].im; - chisq+=(real*real + imag*imag)*inputMCMC->invspec[det_i]->data->data[i]; - } - chisq*=0.5; /* for 2 sigma^2 on denominator */ - /* add the normalisation constant */ - for(i=lowBin;i<inputMCMC->invspec[det_i]->data->length-1;i++) chisq+=0.5*log(inputMCMC->invspec[det_i]->data->data[i]); - chisq+=(REAL8)( 0.5 * (inputMCMC->invspec[det_i]->data->length-lowBin) * log(2.0*LAL_PI)); - - /* Free template */ - XLALDestroyREAL4TimeSeries(template); - XLALDestroyCOMPLEX8FrequencySeries(Ftemplate); - logL-=chisq; - } - /* Free co_wave structures */ - - XLALDestroyVectorSequence((co_wave.a->data)); - LALFree(co_wave.a); - XLALDestroyREAL8TimeSeries(co_wave.phi); - XLALDestroyREAL4TimeSeries(co_wave.f); - LALDestroyREAL4FFTPlan(&status,&FFTplan); - parameter->logLikelihood=logL; - return(logL); -} - - -REAL8 MCMCLikelihoodMultiIFO(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter) -{ - REAL8 logL=0.0; - int i; - /* Loop over detectors/datasets */ - for(i=0;i<inputMCMC->numberDataStreams;i++) logL+= MCMCLikelihood1IFO(inputMCMC,parameter,i); - parameter->logLikelihood=logL; - return logL; -} - -void MCMCInit1IFO(LALMCMCParameter *parameter, SnglInspiralTable *inspiralTable) -{ -REAL4 mass1,mass2; -REAL8 time,length; - -mass1=inspiralTable->mass1; -mass2=inspiralTable->mass2; -time = (REAL8)inspiralTable->end_time.gpsSeconds + (REAL8)inspiralTable->end_time.gpsNanoSeconds * 1.0e-9; -length=(REAL8)inspiralTable->template_duration; -time=-length; - parameter->param=NULL; - parameter->dimension=0; - XLALMCMCAddParam(parameter,"mass1", mass1, 0.98*mass1, 1.02*mass1,0); - XLALMCMCAddParam(parameter,"mass2", mass2, 0.98*mass2, 1.02*mass2,0); - XLALMCMCAddParam(parameter,"time",time,time-0.01,time+0.01,0); - XLALMCMCAddParam(parameter,"phi",0.0,0.0,LAL_TWOPI,1); - XLALMCMCAddParam(parameter,"logdistance",10.0,1.0,90.0,0); - -} diff --git a/lalapps/src/inspiral/posterior/LALInspiralMCMCUser.h b/lalapps/src/inspiral/posterior/LALInspiralMCMCUser.h index d37031a172dced95dce85c85eda00b1528819315..d139b496fcb0eb7fb8ec6fb32a2770eab790efcb 100644 --- a/lalapps/src/inspiral/posterior/LALInspiralMCMCUser.h +++ b/lalapps/src/inspiral/posterior/LALInspiralMCMCUser.h @@ -119,8 +119,6 @@ REAL8 NestPriorHighMass(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter); REAL8 GRBPrior(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter); -void NestInitInj(LALMCMCParameter *parameter, void *iT); - void NestInitInjNINJA(LALMCMCParameter *parameter, void *iT); void NestInitInjNINJAHighMass(LALMCMCParameter *parameter, void *iT); @@ -128,20 +126,12 @@ void NestInitInjNINJAHighMass(LALMCMCParameter *parameter, void *iT); int ParamInRange(LALMCMCParameter *parameter); -REAL8 MCMCLikelihoodMultiIFO(LALMCMCInput *inputMCMC, LALMCMCParameter *parameter); - -REAL8 MCMCLikelihood1IFO(LALMCMCInput *inputMCMC, LALMCMCParameter *parameter, int idx); - -void MCMCInit1IFO(LALMCMCParameter *parameter, SnglInspiralTable *inspiralTable); - extern REAL4Vector *model; extern REAL4Vector *Tmodel; -extern REAL8Sequence **topdown_sum; +extern REAL8Vector **topdown_sum; extern REAL8 *normalisations; -REAL8 MCMCLikelihoodMultiCoherent(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter); - REAL8 MCMCSTLikelihoodMultiCoherentF(LALMCMCInput *inputMCMC,LALMCMCParameter *parameter); REAL8 MCMCLikelihoodMultiCoherentF(LALMCMCInput *inputMCMC, LALMCMCParameter *parameter); diff --git a/lalapps/src/inspiral/posterior/nest_calc.c b/lalapps/src/inspiral/posterior/nest_calc.c index c100de89c8290a06580a3fa1355ee60c241cee2a..af5894e2413dd4a7c76979ad29f6651be85ecb80 100644 --- a/lalapps/src/inspiral/posterior/nest_calc.c +++ b/lalapps/src/inspiral/posterior/nest_calc.c @@ -8,7 +8,8 @@ #include "LALInspiralMCMCUser.h" #include <lal/LALError.h> #include <lal/TimeDelay.h> - +#include <stdio.h> +#include <stdlib.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <gsl/gsl_linalg.h> @@ -19,70 +20,70 @@ gsl_matrix *cov_mat; -CHAR outfile[512]; +CHAR outfile[FILENAME_MAX]; double etawindow; INT4 seed; double logadd(double a,double b){ -if(a>b) return(a+log(1.0+exp(b-a))); -else return(b+log(1.0+exp(a-b))); + if(a>b) return(a+log(1.0+exp(b-a))); + else return(b+log(1.0+exp(a-b))); } void NestInit2PN(LALMCMCParameter *parameter, void *iT){ -REAL8 time; -SnglInspiralTable *inspiralTable = (SnglInspiralTable *)iT; -REAL4 mtot,eta,mwindow,etawindow,timewindow; -time = (REAL8)inspiralTable->end_time.gpsSeconds + (REAL8)inspiralTable->end_time.gpsNanoSeconds *1.0e-9; -parameter->param=NULL; -parameter->dimension=0; -mwindow=0.5; -REAL8 m1=inspiralTable->mass1; -REAL8 m2=inspiralTable->mass2; -mtot=inspiralTable->mass1 + inspiralTable->mass2; -eta=inspiralTable->eta; -if (eta==0.0) eta=m1*m2/((m1+m2)*(m1+m2)); -double etamin = eta-0.5*etawindow; -etamin = etamin<0.01?0.01:etamin; -double etamax = eta+0.5*etawindow; -etamax = etamax>0.25?0.25:etamax; -etamin=0.05; etamax=0.25; -REAL4 localetawin=etamax-etamin; -fprintf(stderr,"clipped eta prior %lf\n",localetawin); - -XLALMCMCAddParam(parameter,"mtotal",2.0+33.0*gsl_rng_uniform(RNG),2.0,35.0,0); /* Low mass */ -/*XLALMCMCAddParam(parameter, "mtotal", mtot*(1.0 + mwindow*(gsl_rng_uniform(RNG)-0.5)),mtot*(1.0-0.5*mwindow),mtot*(1.0+0.5*mwindow),0);*/ -/*XLALMCMCAddParam(parameter, "eta", gsl_rng_uniform(RNG)*0.25 , 0, 0.25, 0);*/ -XLALMCMCAddParam(parameter, "eta", gsl_rng_uniform(RNG)*localetawin+etamin , etamin, etamax, 0); -/*XLALMCMCAddParam(parameter, "eta", eta*(1.0 + etawindow*(gsl_rng_uniform(RNG)-0.5)),eta*(1.0-0.5*etawindow),eta*(1.0+0.5*etawindow),0);*/ -XLALMCMCAddParam(parameter, "time", (gsl_rng_uniform(RNG)-0.5)*timewindow + time ,time-0.5*timewindow,time+0.5*timewindow,0); -XLALMCMCAddParam(parameter, "phi", LAL_TWOPI*gsl_rng_uniform(RNG),0.0,LAL_TWOPI,1); -XLALMCMCAddParam(parameter, "distMpc", 99.0*gsl_rng_uniform(RNG)+1.0, 1.0, 100.0, 0); -XLALMCMCAddParam(parameter,"long",LAL_TWOPI*gsl_rng_uniform(RNG),0,LAL_TWOPI,1); -XLALMCMCAddParam(parameter,"lat",LAL_PI*(gsl_rng_uniform(RNG)-0.5),-LAL_PI*0.5,LAL_PI*0.5,0); -XLALMCMCAddParam(parameter,"psi",0.5*LAL_PI*gsl_rng_uniform(RNG),0,LAL_PI*0.5,0); -XLALMCMCAddParam(parameter,"iota",LAL_PI*gsl_rng_uniform(RNG),0,LAL_PI,0); - -return; + REAL8 trg_time; + SnglInspiralTable *inspiralTable = (SnglInspiralTable *)iT; + REAL4 mtot,eta,mwindow; + trg_time = (REAL8)inspiralTable->end_time.gpsSeconds + (REAL8)inspiralTable->end_time.gpsNanoSeconds *1.0e-9; + parameter->param=NULL; + parameter->dimension=0; + mwindow=0.5; + REAL8 m1=inspiralTable->mass1; + REAL8 m2=inspiralTable->mass2; + mtot=inspiralTable->mass1 + inspiralTable->mass2; + eta=inspiralTable->eta; + if (eta==0.0) eta=m1*m2/((m1+m2)*(m1+m2)); + double etamin = eta-0.5*etawindow; + etamin = etamin<0.01?0.01:etamin; + double etamax = eta+0.5*etawindow; + etamax = etamax>0.25?0.25:etamax; + etamin=0.05; etamax=0.25; + REAL4 localetawin=etamax-etamin; + fprintf(stderr,"clipped eta prior %lf\n",localetawin); + + XLALMCMCAddParam(parameter,"mtotal",2.0+33.0*gsl_rng_uniform(RNG),2.0,35.0,0); /* Low mass */ + /*XLALMCMCAddParam(parameter, "mtotal", mtot*(1.0 + mwindow*(gsl_rng_uniform(RNG)-0.5)),mtot*(1.0-0.5*mwindow),mtot*(1.0+0.5*mwindow),0);*/ + /*XLALMCMCAddParam(parameter, "eta", gsl_rng_uniform(RNG)*0.25 , 0, 0.25, 0);*/ + XLALMCMCAddParam(parameter, "eta", gsl_rng_uniform(RNG)*localetawin+etamin , etamin, etamax, 0); + /*XLALMCMCAddParam(parameter, "eta", eta*(1.0 + etawindow*(gsl_rng_uniform(RNG)-0.5)),eta*(1.0-0.5*etawindow),eta*(1.0+0.5*etawindow),0);*/ + XLALMCMCAddParam(parameter, "time", (gsl_rng_uniform(RNG)-0.5)*timewindow + trg_time ,trg_time-0.5*timewindow,trg_time+0.5*timewindow,0); + XLALMCMCAddParam(parameter, "phi", LAL_TWOPI*gsl_rng_uniform(RNG),0.0,LAL_TWOPI,1); + XLALMCMCAddParam(parameter, "distMpc", 99.0*gsl_rng_uniform(RNG)+1.0, 1.0, 100.0, 0); + XLALMCMCAddParam(parameter,"long",LAL_TWOPI*gsl_rng_uniform(RNG),0,LAL_TWOPI,1); + XLALMCMCAddParam(parameter,"lat",LAL_PI*(gsl_rng_uniform(RNG)-0.5),-LAL_PI*0.5,LAL_PI*0.5,0); + XLALMCMCAddParam(parameter,"psi",0.5*LAL_PI*gsl_rng_uniform(RNG),0,LAL_PI*0.5,0); + XLALMCMCAddParam(parameter,"iota",LAL_PI*gsl_rng_uniform(RNG),0,LAL_PI,0); + + return; } void Inject2PN(LALMCMCParameter *parameter, LALMCMCInput *inputMCMC, double SNR){ -static LALStatus status; -InspiralTemplate template; -REAL8 real,imag,chisq; -UINT4 Nmodel; -INT4 i; -double SNR1,mul_factor=1.0; - -memset(&template,0,sizeof(InspiralTemplate)); -template.totalMass = XLALMCMCGetParameter(parameter,"mtotal"); -template.eta = XLALMCMCGetParameter(parameter,"eta"); -template.massChoice = totalMassAndEta; -template.fLower = inputMCMC->fLow; -template.distance = XLALMCMCGetParameter(parameter,"distMpc"); -template.order = LAL_PNORDER_TWO; -template.approximant=inputMCMC->approximant; -template.tSampling = 1.0/inputMCMC->deltaT; + static LALStatus status; + InspiralTemplate template; + REAL8 real,imag,chisq; + UINT4 Nmodel; + UINT4 i; + double SNR1,mul_factor=1.0; + + memset(&template,0,sizeof(InspiralTemplate)); + template.totalMass = XLALMCMCGetParameter(parameter,"mtotal"); + template.eta = XLALMCMCGetParameter(parameter,"eta"); + template.massChoice = totalMassAndEta; + template.fLower = inputMCMC->fLow; + template.distance = XLALMCMCGetParameter(parameter,"distMpc"); + template.order = LAL_PNORDER_TWO; + template.approximant=inputMCMC->approximant; + template.tSampling = 1.0/inputMCMC->deltaT; template.fCutoff = 0.5/inputMCMC->deltaT -1.0; template.nStartPad = 0; template.nEndPad =0; @@ -92,18 +93,18 @@ template.tSampling = 1.0/inputMCMC->deltaT; template.ieta = 1; template.next = NULL; template.fine = NULL; - + LALInspiralParameterCalc(&status,&template); - + template.startTime-=template.tC; - + LALInspiralRestrictedAmplitude(&status,&template); Nmodel=inputMCMC->stilde[0]->data->length*2; /* *2 for real/imag packing format */ - + LALCreateVector(&status,&model,Nmodel); - + LALInspiralWave(&status,model,&template); /* Create the model */ - + int lowBin = (int)(inputMCMC->fLow / inputMCMC->stilde[0]->deltaF); /* Find the SNR of this wave */ for(chisq=0.0,i=lowBin;i<Nmodel/2;i++){ @@ -121,13 +122,13 @@ template.tSampling = 1.0/inputMCMC->deltaT; } fprintf(stderr,"Injected wave, SNR = %e\n",sqrt(chisq)); model=NULL; -/* free(model); */ + /* free(model); */ } -REAL8 nestZ(INT4 Nruns, INT4 Nlive, LALMCMCParameter **Live, LALMCMCInput *MCMCinput) +REAL8 nestZ(UINT4 Nruns, UINT4 Nlive, LALMCMCParameter **Live, LALMCMCInput *MCMCinput) { - int i=0; - int j,minpos; + UINT4 i=0; + UINT4 j,minpos; static LALStatus status; REAL4 accept; REAL8 *logZarray,*logwarray,*Harray,*oldZarray,*Wtarray; @@ -135,64 +136,80 @@ REAL8 nestZ(INT4 Nruns, INT4 Nlive, LALMCMCParameter **Live, LALMCMCInput *MCMCi REAL8 MCMCfail=0; REAL8 logZnoise=0.0; REAL8 logLmax=-DBL_MAX; - REAL4 rngseed=0; FILE *fpout=NULL; - CHAR outEnd[1000]; + CHAR outEnd[FILENAME_MAX]; LALMCMCParameter *temp=(LALMCMCParameter *)malloc(sizeof(LALMCMCParameter)); - + if(!(MCMCinput->randParams)) LALCreateRandomParams(&status,&(MCMCinput->randParams),seed); - + MCMCinput->Live=Live; MCMCinput->Nlive=(UINT4)Nlive; /* Initialise the RNG */ gsl_rng_env_setup(); RNG=gsl_rng_alloc(gsl_rng_default); - gsl_rng_set(RNG,seed==0 ? (unsigned long int)time(NULL) : seed); - + gsl_rng_set(RNG,seed==0 ? (unsigned long int)time(NULL) : (unsigned int long) seed); + /* Initialise the optimised tables declared in LALInspiralMCMCUser.h*/ - + normalisations = calloc((size_t)MCMCinput->numberDataStreams,sizeof(REAL8)); - + for(i=0;i<MCMCinput->numberDataStreams;i++) { normalisations[i]=0.0; if(MCMCinput->invspec[i]!=NULL){ for(j=(int)(MCMCinput->fLow/MCMCinput->invspec[i]->deltaF);j<MCMCinput->invspec[i]->data->length-1;j++) normalisations[i]+=0.5*log(MCMCinput->invspec[i]->data->data[j]); } } - - + + topdown_sum=calloc((size_t)MCMCinput->numberDataStreams,sizeof(REAL8Vector *)); + for (i=0;i<MCMCinput->numberDataStreams;i++){ + topdown_sum[i]=XLALCreateREAL8Vector(MCMCinput->stilde[i]->data->length); + topdown_sum[i]->data[topdown_sum[i]->length-1]= + (pow(MCMCinput->stilde[i]->data->data[topdown_sum[i]->length-1].re,2.0)+pow(MCMCinput->stilde[i]->data->data[topdown_sum[i]->length-1].im,2.0))*MCMCinput->invspec[i]->data->data[topdown_sum[i]->length-1]; + for(j=topdown_sum[i]->length-2;j>0;j--) topdown_sum[i]->data[j]=topdown_sum[i]->data[j+1]+(pow(MCMCinput->stilde[i]->data->data[j].re,2.0)+pow(MCMCinput->stilde[i]->data->data[j].im,2.0))*MCMCinput->invspec[i]->data->data[j]; + } + if(MCMCinput->injectionTable!=NULL) MCMCinput->funcInit(temp,(void *)MCMCinput->injectionTable); else MCMCinput->funcInit(temp,(void *)MCMCinput->inspiralTable); - + + /* Likelihood of the noise model */ XLALMCMCSetParameter(temp,"distMpc",DBL_MAX); MCMCinput->funcPrior(MCMCinput,temp); MCMCinput->funcLikelihood(MCMCinput,temp); - logZnoise = temp->logLikelihood; +/* logZnoise = temp->logLikelihood; */ +/* Calculate this from the tables instead of calling logL with dist = DBL_MAX */ + logZnoise=0.0; + for (j=0;j<MCMCinput->numberDataStreams;j++){ + int lowBin=(int)MCMCinput->fLow/MCMCinput->deltaF; + logZnoise+=topdown_sum[j]->data[lowBin]; + } + logZnoise*=-2.0*MCMCinput->deltaF; + fprintf(stdout,"Noise evidence: %lf\n",logZnoise); fprintf(stderr,"Sprinkling initial points, may take a while"); /* Set up the parameters for the live points */ for(i=0;i<Nlive;i++) { - if(MCMCinput->injectionTable!=NULL) MCMCinput->funcInit(Live[i],(void *)MCMCinput->injectionTable); - else MCMCinput->funcInit(Live[i],(void *)MCMCinput->inspiralTable); - MCMCinput->dim=Live[i]->dimension; - MCMCinput->funcPrior(MCMCinput,Live[i]); + do{ + if(MCMCinput->injectionTable!=NULL) MCMCinput->funcInit(Live[i],(void *)MCMCinput->injectionTable); + else MCMCinput->funcInit(Live[i],(void *)MCMCinput->inspiralTable); + MCMCinput->dim=Live[i]->dimension; + MCMCinput->funcPrior(MCMCinput,Live[i]); + if(Live[i]->logPrior==-DBL_MAX) XLALMCMCFreePara(Live[i]); + } while(Live[i]->logPrior==-DBL_MAX); MCMCinput->funcLikelihood(MCMCinput,Live[i]); } /* Set up covariance matrix */ cov_mat = gsl_matrix_alloc(MCMCinput->dim,MCMCinput->dim); - - calcCVM(cov_mat,Live,Nlive); - + for(i=0;i<Nlive;i++) { - accept=MCMCSampleLimitedPrior(Live[i],temp,MCMCinput,-DBL_MAX,cov_mat,MCMCinput->numberDraw); - if(i%50==0)fprintf(stderr,"."); + accept=MCMCSampleLimitedPrior(Live[i],temp,MCMCinput,-DBL_MAX,cov_mat,MCMCinput->numberDraw); + if(i%50==0)fprintf(stderr,"."); } if(MCMCinput->verbose) fprintf(stderr,"Set up %i live points\n",Nlive); - + /* Find max likelihood currently */ for(i=1,logLmax=Live[0]->logLikelihood;i<Nlive;i++) logLmax=logLmax>Live[i]->logLikelihood ? logLmax : Live[i]->logLikelihood; - + /* Set up arrays for parallel runs */ logZarray = calloc(Nruns,sizeof(REAL8)); oldZarray = calloc(Nruns,sizeof(REAL8)); @@ -200,91 +217,94 @@ REAL8 nestZ(INT4 Nruns, INT4 Nlive, LALMCMCParameter **Live, LALMCMCInput *MCMCi logwarray = calloc(Nruns,sizeof(REAL8)); Wtarray = calloc(Nruns,sizeof(REAL8)); if(logZarray==NULL || Harray==NULL || oldZarray==NULL || logwarray==NULL) {fprintf(stderr,"Unable to allocate RAM\n"); exit(-1);} - + logw=log(1.0-exp(-1.0/Nlive)); for(i=0;i<Nruns;i++) {logwarray[i]=logw; logZarray[i]=-DBL_MAX; oldZarray[i]=-DBL_MAX; Harray[i]=0.0;} i=0; - + /* open outfile */ fpout=fopen(outfile,"w"); if(fpout==NULL) fprintf(stderr,"Unable to open output file %s\n",outfile); - + /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Nested sampling loop -=-=-=-=--=-=-=-=-==-=-=-=-=-=-= */ -/* while(((REAL8)i)<=((REAL8)Nlive)*infosafe*H || i<3*Nlive) */ + /* while(((REAL8)i)<=((REAL8)Nlive)*infosafe*H || i<3*Nlive) */ deltaZ=1.0; /* while((REAL8)i<=((REAL8)Nlive)*infosafe*H ? 1 : Nlive*fabs(deltaZ/logZ)>1e-6)*/ while(((REAL8)i)<=((REAL8)Nlive) || logLmax+logw > logZ-5) /* This termination condition: when remaining prior can't - account for more than exp(-5) of the evidence, even - if entire support is at Lmax */ + account for more than exp(-5) of the evidence, even + if entire support is at Lmax */ { - minpos=0; - /* Find minimum likelihood sample to replace */ - for(j=0;j<Nlive;j++) {if(Live[j]->logLikelihood <= Live[minpos]->logLikelihood) minpos=j;} - logLmin = Live[minpos]->logLikelihood; - logWt = logw + Live[minpos]->logLikelihood; - fprintSample(fpout,Live[minpos]); - /* update evidence array */ - for(j=0;j<Nruns;j++){ - logZarray[j]=logadd(logZarray[j],Live[minpos]->logLikelihood + logwarray[j]); - Wtarray[j]=logwarray[j]+Live[minpos]->logLikelihood; - Harray[j]= exp(Wtarray[j]-logZarray[j])*Live[minpos]->logLikelihood - + exp(oldZarray[j]-logZarray[j])*(Harray[j]+oldZarray[j])-logZarray[j]; + minpos=0; + /* Find minimum likelihood sample to replace */ + for(j=0;j<Nlive;j++) {if(Live[j]->logLikelihood <= Live[minpos]->logLikelihood) minpos=j;} + logLmin = Live[minpos]->logLikelihood; + logWt = logw + Live[minpos]->logLikelihood; + fprintSample(fpout,Live[minpos]); + /* update evidence array */ + for(j=0;j<Nruns;j++){ + logZarray[j]=logadd(logZarray[j],Live[minpos]->logLikelihood + logwarray[j]); + Wtarray[j]=logwarray[j]+Live[minpos]->logLikelihood; + Harray[j]= exp(Wtarray[j]-logZarray[j])*Live[minpos]->logLikelihood + + exp(oldZarray[j]-logZarray[j])*(Harray[j]+oldZarray[j])-logZarray[j]; } - logZnew=mean(logZarray,Nruns); - deltaZ=logZnew-logZ; - H=mean(Harray,Nruns); - logZ=logZnew; - for(j=0;j<Nruns;j++) oldZarray[j]=logZarray[j]; - MCMCfail=0.0; - /* Update covariance matrix every so often */ - if(!(i%(Nlive/4))) calcCVM(cov_mat,Live,Nlive); - /* generate new live point */ - do{ - while((j=gsl_rng_uniform_int(RNG,Nlive))==minpos){}; - XLALMCMCCopyPara(&(Live[minpos]),Live[j]); - accept = MCMCSampleLimitedPrior(Live[minpos],temp,MCMCinput,logLmin,cov_mat,MCMCinput->numberDraw); - MCMCinput->funcLikelihood(MCMCinput,Live[minpos]); - MCMCinput->funcPrior(MCMCinput,Live[minpos]); - MCMCfail+=1.0; + logZnew=mean(logZarray,Nruns); + deltaZ=logZnew-logZ; + H=mean(Harray,Nruns); + logZ=logZnew; + for(j=0;j<Nruns;j++) oldZarray[j]=logZarray[j]; + MCMCfail=0.0; + + /* Replace the previous sample by a new one */ + + /* Update covariance matrix every so often */ + if(!(i%(Nlive/4))) calcCVM(cov_mat,Live,Nlive); + /* generate new live point */ + do{ + while((j=gsl_rng_uniform_int(RNG,Nlive))==minpos){}; + XLALMCMCCopyPara(&(Live[minpos]),Live[j]); + accept = MCMCSampleLimitedPrior(Live[minpos],temp,MCMCinput,logLmin,cov_mat,MCMCinput->numberDraw); + MCMCinput->funcLikelihood(MCMCinput,Live[minpos]); + MCMCinput->funcPrior(MCMCinput,Live[minpos]); + MCMCfail+=1.0; }while((Live[minpos]->logLikelihood<=logLmin)||(accept==0.0)); - if(Live[minpos]->logLikelihood > logLmax) logLmax = Live[minpos]->logLikelihood; - for(j=0;j<Nruns;j++) logwarray[j]+=sample_logt(Nlive); - logw=mean(logwarray,Nruns); - if(MCMCinput->verbose) fprintf(stderr,"%i: (%2.1lf%%) accpt: %1.3f H: %3.3lf nats (%3.3lf b) logL:%lf ->%lf logZ: %lf Zratio: %lf db\n", - i,100.0*((REAL8)i)/(((REAL8) Nlive)*H*infosafe),accept/MCMCfail,H,H/log(2.0),logLmin,Live[minpos]->logLikelihood,logZ,10.0*log10(exp(1.0))*(logZ-logZnoise)); - if(fpout && !(i%50)) fflush(fpout); - i++; + if(Live[minpos]->logLikelihood > logLmax) logLmax = Live[minpos]->logLikelihood; + for(j=0;j<Nruns;j++) logwarray[j]+=sample_logt(Nlive); + logw=mean(logwarray,Nruns); + if(MCMCinput->verbose) fprintf(stderr,"%i: (%2.1lf%%) accpt: %1.3f H: %3.3lf nats (%3.3lf b) logL:%lf ->%lf logZ: %lf Zratio: %lf db\n", + i,100.0*((REAL8)i)/(((REAL8) Nlive)*H*infosafe),accept/MCMCfail,H,H/log(2.0),logLmin,Live[minpos]->logLikelihood,logZ,10.0*log10(exp(1.0))*(logZ-logZnoise)); + if(fpout && !(i%50)) fflush(fpout); + i++; } - + /* Sort the remaining points (not essential, just nice)*/ for(i=0;i<Nlive-1;i++){ minpos=i; logLmin=Live[i]->logLikelihood; for(j=i+1;j<Nlive;j++){ if(Live[j]->logLikelihood<logLmin) {minpos=j; logLmin=Live[j]->logLikelihood;} - } + } temp=Live[minpos]; /* Put the minimum remaining point in the current position */ Live[minpos]=Live[i]; Live[i]=temp; } - + /* final corrections */ for(i=0;i<Nlive;i++){ logZ=logadd(logZ,Live[i]->logLikelihood+logw); for(j=0;j<Nruns;j++){ logwarray[j]+=sample_logt(Nlive); logZarray[j]=logadd(logZarray[j],Live[i]->logLikelihood+logwarray[j]-log((double)Nlive)); - } - fprintSample(fpout,Live[i]); } + fprintSample(fpout,Live[i]); + } double Npoints = MCMCinput->numberDataStreams*MCMCinput->stilde[0]->data->length-(int)(MCMCinput->fLow/MCMCinput->deltaF); fprintf(stdout,"MaxL = %lf\nReduced chi squared = %lf\n",Live[Nlive-1]->logLikelihood,-Live[Nlive-1]->logLikelihood/Npoints); logZ=mean(logZarray,Nruns); fprintf(stdout,"deltaLmax = %lf\n",Live[Nlive-1]->logLikelihood-logZnoise); double zscore =( -2.0*Live[Nlive-1]->logLikelihood - Npoints) / sqrt(2.0*Npoints); fprintf(stdout,"Z-score = %lf\n",zscore); - - close(fpout); + + fclose(fpout); sprintf(outEnd,"%s_B.txt",outfile); fpout=fopen(outEnd,"w"); fprintf(fpout,"%lf %lf %lf %lf %lf\n",logZ-logZnoise,logZ,logZnoise,Live[Nlive-1]->logLikelihood-logZnoise,zscore); @@ -292,7 +312,7 @@ REAL8 nestZ(INT4 Nruns, INT4 Nlive, LALMCMCParameter **Live, LALMCMCInput *MCMCi free(Harray); free(logwarray); free(Wtarray); free(oldZarray); free(logZarray); fprintf(stdout,"lodds ratio %lf\n",logZ-logZnoise); return logZ; - + } REAL8 mean(REAL8 *array,int N){ @@ -304,153 +324,156 @@ REAL8 mean(REAL8 *array,int N){ REAL4 MCMCSampleLimitedPrior(LALMCMCParameter *sample, LALMCMCParameter *temp, LALMCMCInput *MCMCInput,REAL8 minL,gsl_matrix *covM,INT4 N) { -/* Sample from prior using MCMC to evolve the existing value of sample subject to the new likelihood being >minL*/ -/* Returns acceptance ratio */ + /* Sample from prior using MCMC to evolve the existing value of sample subject to the new likelihood being >minL*/ + /* Returns acceptance ratio */ #define ROTATEFRAC 0.1 #define REFLECTFRAC 0.1 -int i=0; -int a_cnt=0; -int accept=0; -int nreflect=0; -REAL8 logL,logPri,phi; -REAL8 jump_select=0; -REAL8 scale_temp; -REAL8 scalefactor_small=1E-4; -int ret=0; - -MCMCInput->funcPrior(MCMCInput,sample); - -XLALMCMCCopyPara(&temp,sample); - -i=0; -while (i<N || (nreflect==a_cnt && nreflect>0 && nreflect%2==0)){ - i++; - jump_select = gsl_rng_uniform(RNG); - if(jump_select<0.1 && MCMCInput->numberDataStreams>1){ - if(MCMCInput->numberDataStreams>1) jump_select = gsl_rng_uniform(RNG); - else jump_select=0; - if(jump_select>0.5) { - ret=0; - /* Custom proposal for symmetry of the sky sphere */ - if(MCMCInput->numberDataStreams>=3 && jump_select>0.9) ret=XLALMCMCReflectDetPlane(MCMCInput,temp); - if(ret==0) nreflect++; - if(ret==-1 || jump_select <=0.9 || MCMCInput->numberDataStreams==2) XLALMCMCRotateSky(MCMCInput,temp); - /* Custom proposal for mass/eta1 surface of constant 1PN term */ - /* if(gsl_rng_uniform(RNG)<0.1) XLALMCMC1PNMasseta(MCMCInput,temp); */ + int i=0; + int a_cnt=0; + int accept=0; + int nreflect=0; + REAL8 jump_select=0; + int ret=0; + + MCMCInput->funcPrior(MCMCInput,sample); + + XLALMCMCCopyPara(&temp,sample); + + i=0; + while (i<N || (nreflect==a_cnt && nreflect>0 && nreflect%2==0)){ + i++; + jump_select = gsl_rng_uniform(RNG); + if(jump_select<0.1 && MCMCInput->numberDataStreams>1 && XLALMCMCCheckWrapping(sample,"long")!=-1 && XLALMCMCCheckWrapping(sample,"lat")!=-1){ + if(MCMCInput->numberDataStreams>1) jump_select = gsl_rng_uniform(RNG); + else jump_select=0; + if(jump_select>0.5) { + ret=0; + /* Custom proposal for symmetry of the sky sphere */ + if(MCMCInput->numberDataStreams>=3 && jump_select>0.9) ret=XLALMCMCReflectDetPlane(MCMCInput,temp); + if(ret==0) nreflect++; + if(ret==-1 || jump_select <=0.9 || MCMCInput->numberDataStreams==2) XLALMCMCRotateSky(MCMCInput,temp); + /* Custom proposal for mass/eta1 surface of constant 1PN term */ + /* if(gsl_rng_uniform(RNG)<0.1) XLALMCMC1PNMasseta(MCMCInput,temp); */ + } + else XLALMCMCDifferentialEvolution(MCMCInput,temp); + /* Evaluate MH ratio */ + } + else if( (jump_select=gsl_rng_uniform(RNG))<0.2/*0.2*/) XLALMCMCDifferentialEvolution(MCMCInput,temp); + /*else if(jump_select<0.6) XLALMCMCJumpIntrinsic(MCMCInput,temp,covM);*/ + else XLALMCMCJump(MCMCInput,temp,covM); + + + MCMCInput->funcPrior(MCMCInput,temp); + if(temp->logPrior!=-DBL_MAX && ( (temp->logPrior - sample->logPrior) > log(gsl_rng_uniform(RNG)) )) { + /* this would be accepted based on the priors, we can now confirm that its likelihood is above the limit + with the more expensive calculation */ + MCMCInput->funcLikelihood(MCMCInput,temp); + if(temp->logLikelihood>minL) accept = 1; + } + if(accept==1) {XLALMCMCCopyPara(&sample,temp); a_cnt++; accept=0;} + else XLALMCMCCopyPara(&temp,sample); } - else XLALMCMCDifferentialEvolution(MCMCInput,temp); - /* Evaluate MH ratio */ - } - else if( (jump_select=gsl_rng_uniform(RNG))<0.1) XLALMCMCDifferentialEvolution(MCMCInput,temp); - /*else if(jump_select<0.6) XLALMCMCJumpIntrinsic(MCMCInput,temp,covM);*/ - else XLALMCMCJump(MCMCInput,temp,covM); - - - MCMCInput->funcPrior(MCMCInput,temp); - if(temp->logPrior!=-DBL_MAX && ( (temp->logPrior - sample->logPrior) > log(gsl_rng_uniform(RNG)) )) { - /* this would be accepted based on the priors, we can now confirm that its likelihood is above the limit - with the more expensive calculation */ - MCMCInput->funcLikelihood(MCMCInput,temp); - if(temp->logLikelihood>minL) accept = 1; - } - if(accept==1) {XLALMCMCCopyPara(&sample,temp); a_cnt++; accept=0;} - else XLALMCMCCopyPara(&temp,sample); + return(((REAL4) a_cnt)/((REAL4) i)); } -return(((REAL4) a_cnt)/((REAL4) i)); -} - -void calcCVM(gsl_matrix *cvm, LALMCMCParameter **samples,int N) -{ int i,j,k; -int ND=samples[0]->dimension; -REAL8 *means; -LALMCMCParam *p; -LALMCMCParam *jp; -LALMCMCParam *kp; -gsl_matrix *oldcvm; - -oldcvm = gsl_matrix_alloc(ND,ND); -gsl_matrix_memcpy (oldcvm, cvm); - -/* clear the matrix */ -for(i=0;i<cvm->size1;i++) for(j=0;j<cvm->size2;j++) gsl_matrix_set(cvm,i,j,0.0); -/* Find the means */ -if(NULL==(means = malloc((size_t)ND*sizeof(REAL8)))){fprintf(stderr,"Can't allocate RAM"); exit(-1);} -for(i=0;i<ND;i++) means[i]=0.0; -for(i=0;i<N;i++){ - p=samples[i]->param; - for(j=0;j<ND;j++) {if(p->core->wrapping==0) {means[j]+=p->value;} p=p->next;} +void calcCVM(gsl_matrix *cvm, LALMCMCParameter **samples,UINT4 N) +{ UINT4 i,j,k; + UINT4 ND=samples[0]->dimension; + REAL8 *means; + LALMCMCParam *p; + LALMCMCParam *jp; + LALMCMCParam *kp; + gsl_matrix *oldcvm; + + oldcvm = gsl_matrix_alloc(ND,ND); + gsl_matrix_memcpy (oldcvm, cvm); + + /* clear the matrix */ + for(i=0;i<cvm->size1;i++) for(j=0;j<cvm->size2;j++) gsl_matrix_set(cvm,i,j,0.0); + + /* Find the means */ + if(NULL==(means = malloc((size_t)ND*sizeof(REAL8)))){fprintf(stderr,"Can't allocate RAM"); exit(-1);} + for(i=0;i<ND;i++) means[i]=0.0; + for(i=0;i<N;i++){ + p=samples[i]->param; + for(j=0;j<ND;j++) {if(p->core->wrapping==0) {means[j]+=p->value;} p=p->next;} } -for(j=0;j<ND;j++) means[j]/=(REAL8)N; - -/* Find the (co)-variances */ -for(i=0;i<N;i++){ - kp=jp=p=samples[i]->param; - for(j=0;j<ND;j++){ - for(k=0,kp=p;k<=j;k++){ - gsl_matrix_set(cvm,j,k,gsl_matrix_get(cvm,j,k) + (kp->value - means[k])*(jp->value - means[j])); - kp=kp->next; + for(j=0;j<ND;j++) means[j]/=(REAL8)N; + + /* Find the (co)-variances */ + for(i=0;i<N;i++){ + kp=jp=p=samples[i]->param; + for(j=0;j<ND;j++){ + for(k=0,kp=p;k<=j;k++){ + gsl_matrix_set(cvm,j,k,gsl_matrix_get(cvm,j,k) + (kp->value - means[k])*(jp->value - means[j])); + kp=kp->next; } - jp=jp->next; + jp=jp->next; } } - -/* Normalise */ -for(i=0;i<ND;i++) for(j=0;j<ND;j++) gsl_matrix_set(cvm,i,j,gsl_matrix_get(cvm,i,j)/((REAL8) N)); -free(means); -/* Fill in variances for angle parameters */ -for(p=samples[0]->param,j=0;j<ND;j++,p=p->next) { - if(p->core->wrapping!=0) { - for(k=0;k<j;k++) gsl_matrix_set(cvm,j,k,0.0); - gsl_matrix_set(cvm,j,j,ang_var(samples,p->core->name,N)); - for(k=j+1;k<ND;k++) gsl_matrix_set(cvm,k,j,0.0); - } -} - -/* the other half */ -for(i=0;i<ND;i++) for(j=0;j<i;j++) gsl_matrix_set(cvm,j,i,gsl_matrix_get(cvm,i,j)); - -/*fprintf(stderr,"shrinkage: "); -for(i=0;i<ND;i++) fprintf(stderr,"%lf ",sqrt(gsl_matrix_get(oldcvm,i,i)/gsl_matrix_get(cvm,i,i))); -fprintf(stderr,"\n"); -*/ -/* Check the 2nd order first moment - indicates non-gaussian structure */ -/* double *twopt=calloc(ND,sizeof(double)); -double *max=calloc(ND,sizeof(double)); -double *min=calloc(ND,sizeof(double)); -for(k=0;k<ND;k++) {min[k]=DBL_MAX; max[k]=-DBL_MAX;} -for(i=0;i<N;i++){ - p=samples[i]->param; - for(k=0;k<ND;k++){ - min[k]=min[k]<p->value?min[k]:p->value; - max[k]=max[k]>p->value?max[k]:p->value; - p=p->next; - } -} -for(i=0;i<N;i++) for(j=i+1;j<N;j++) { - p=samples[i]->param; - jp=samples[j]->param; - for(k=0;k<ND;k++) { - twopt[k]+=fabs(p->value-jp->value); - p=p->next; jp=jp->next;} -} - - -for(k=0;k<ND;k++) twopt[k]/= (1.0/(2.0*sqrt(2.0)))*((double)(N*(N-1)/2))*(max[k]-min[k]); -fprintf(stderr,"structure indicator: "); -for(k=0;k<ND;k++) fprintf(stderr,"%lf ",twopt[k]); -fprintf(stderr,"\n"); -free(twopt); -free(max); free(min); -*/ -/* Debug output the matrix -for(i=0;i<ND;i++){ - for(j=0;j<ND;j++){ fprintf(stderr,"%e ",gsl_matrix_get(cvm,i,j));} - fprintf(stderr,"\n"); + + /* Normalise */ + for(i=0;i<ND;i++) for(j=0;j<ND;j++) gsl_matrix_set(cvm,i,j,gsl_matrix_get(cvm,i,j)/((REAL8) N)); + free(means); + /* Fill in variances for angle parameters */ + for(p=samples[0]->param,j=0;j<ND;j++,p=p->next) { + if(p->core->wrapping==1) { + for(k=0;k<j;k++) gsl_matrix_set(cvm,j,k,0.0); + gsl_matrix_set(cvm,j,j,ang_var(samples,p->core->name,N)); + for(k=j+1;k<ND;k++) gsl_matrix_set(cvm,k,j,0.0); + } + /* Set variance to default 1 for non-varying params */ + else if (p->core->wrapping==-1) { + for(k=0;k<j;k++) gsl_matrix_set(cvm,j,k,0.0); + gsl_matrix_set(cvm,j,j,1.0); + for(k=j+1;k<ND;k++) gsl_matrix_set(cvm,k,j,0.0); + } } -*/ - -return; + + /* the other half */ + for(i=0;i<ND;i++) for(j=0;j<i;j++) gsl_matrix_set(cvm,j,i,gsl_matrix_get(cvm,i,j)); + + /*fprintf(stderr,"shrinkage: "); + for(i=0;i<ND;i++) fprintf(stderr,"%lf ",sqrt(gsl_matrix_get(oldcvm,i,i)/gsl_matrix_get(cvm,i,i))); + fprintf(stderr,"\n"); + */ + /* Check the 2nd order first moment - indicates non-gaussian structure */ + /* double *twopt=calloc(ND,sizeof(double)); + double *max=calloc(ND,sizeof(double)); + double *min=calloc(ND,sizeof(double)); + for(k=0;k<ND;k++) {min[k]=DBL_MAX; max[k]=-DBL_MAX;} + for(i=0;i<N;i++){ + p=samples[i]->param; + for(k=0;k<ND;k++){ + min[k]=min[k]<p->value?min[k]:p->value; + max[k]=max[k]>p->value?max[k]:p->value; + p=p->next; + } + } + for(i=0;i<N;i++) for(j=i+1;j<N;j++) { + p=samples[i]->param; + jp=samples[j]->param; + for(k=0;k<ND;k++) { + twopt[k]+=fabs(p->value-jp->value); + p=p->next; jp=jp->next;} + } + + + for(k=0;k<ND;k++) twopt[k]/= (1.0/(2.0*sqrt(2.0)))*((double)(N*(N-1)/2))*(max[k]-min[k]); + fprintf(stderr,"structure indicator: "); + for(k=0;k<ND;k++) fprintf(stderr,"%lf ",twopt[k]); + fprintf(stderr,"\n"); + free(twopt); + free(max); free(min); + */ + /* Debug output the matrix + for(i=0;i<ND;i++){ + for(j=0;j<ND;j++){ fprintf(stderr,"%e ",gsl_matrix_get(cvm,i,j));} + fprintf(stderr,"\n"); + } + */ + + return; } /* Calculate shortest angular distance between a1 and a2 */ @@ -461,21 +484,21 @@ REAL8 ang_dist(REAL8 a1, REAL8 a2){ /* Calculate the variance of a modulo-2pi distribution */ REAL8 ang_var(LALMCMCParameter **list,const char *pname, int N){ -int i=0; -REAL8 mean=0.0; -REAL8 var=0.0; -REAL8 ms,mc; -/* Calc mean */ -for(i=0,ms=0.0,mc=0.0;i<N;i++) { - ms+=sin(XLALMCMCGetParameter(list[i],pname)); - mc+=cos(XLALMCMCGetParameter(list[i],pname)); -} -ms/=N; mc/=N; -mean=atan2(ms,mc); -mean = mean<0? 2.0*LAL_PI + mean : mean; -/* calc variance */ -for(i=0;i<N;i++) var+=ang_dist(XLALMCMCGetParameter(list[i],pname),mean)*ang_dist(XLALMCMCGetParameter(list[i],pname),mean); -return(var/(REAL8)N); + int i=0; + REAL8 ang_mean=0.0; + REAL8 var=0.0; + REAL8 ms,mc; + /* Calc mean */ + for(i=0,ms=0.0,mc=0.0;i<N;i++) { + ms+=sin(XLALMCMCGetParameter(list[i],pname)); + mc+=cos(XLALMCMCGetParameter(list[i],pname)); + } + ms/=N; mc/=N; + ang_mean=atan2(ms,mc); + ang_mean = ang_mean<0? 2.0*LAL_PI + ang_mean : ang_mean; + /* calc variance */ + for(i=0;i<N;i++) var+=ang_dist(XLALMCMCGetParameter(list[i],pname),ang_mean)*ang_dist(XLALMCMCGetParameter(list[i],pname),ang_mean); + return(var/(REAL8)N); } void fprintSample(FILE *fp,LALMCMCParameter *sample){ diff --git a/lalapps/src/inspiral/posterior/nest_calc.h b/lalapps/src/inspiral/posterior/nest_calc.h index 0b56de129fce1c7838e1900de801edd48e06f9cd..b76d71679d6f0b03d454a554c00af6faca8638ef 100644 --- a/lalapps/src/inspiral/posterior/nest_calc.h +++ b/lalapps/src/inspiral/posterior/nest_calc.h @@ -5,7 +5,7 @@ extern gsl_matrix *cov_mat; -extern CHAR outfile[512]; +extern CHAR outfile[FILENAME_MAX]; extern double etawindow; double logadd(double a,double b); @@ -16,11 +16,11 @@ void NestInit2PN(LALMCMCParameter *parameter, void *iT); REAL8 mean(REAL8 *array,int N); -REAL8 nestZ(INT4 Nruns, INT4 Nlive, LALMCMCParameter **Live,LALMCMCInput *MCMCinput); +REAL8 nestZ(UINT4 Nruns, UINT4 Nlive, LALMCMCParameter **Live,LALMCMCInput *MCMCinput); REAL4 MCMCSampleLimitedPrior(LALMCMCParameter *sample, LALMCMCParameter *temp, LALMCMCInput *MCMCInput,REAL8 minL,gsl_matrix *covM,INT4 N); -void calcCVM(gsl_matrix *cvm, LALMCMCParameter **samples,int N); +void calcCVM(gsl_matrix *cvm, LALMCMCParameter **samples,UINT4 N); REAL8 ang_dist(REAL8 a1, REAL8 a2); diff --git a/lalapps/src/inspiral/randombank.c b/lalapps/src/inspiral/randombank.c index 858be3fdf83bcb918af1768b2dbe58cf8829c362..8a3c3c6a83214336f9080fc2ac5f2018255e4f84 100644 --- a/lalapps/src/inspiral/randombank.c +++ b/lalapps/src/inspiral/randombank.c @@ -98,7 +98,6 @@ int main ( int argc, char *argv[] ) { /* lal function variables */ LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* templates */ RandomParams *randParams = NULL; @@ -133,20 +132,19 @@ int main ( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -319,8 +317,7 @@ int main ( int argc, char *argv[] ) /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFO_MAX, "P1" ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, proctable, diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/cluster.sql b/lalapps/src/inspiral/s5_highmass_upper_limit/cluster.sql index c11d75a6df7e22fb10c98d041daf053fe5bf331e..ffcbeedb85ea1ea9ec6d0faf99982cd9faf14ae3 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/cluster.sql +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/cluster.sql @@ -1,12 +1,14 @@ -PRAGMA temp_store_directory = '/tmp'; +-- PRAGMA temp_store_directory = '/tmp'; SELECT "Number of coincs before clustering: " || count(*) FROM coinc_event; --- construct "is playground" look-up table. See --- glue.segmentsUtils.S2playground() for definition of playground segments +-- +-- construct a look-up table of playground/non-playground state +-- + CREATE TEMPORARY TABLE is_playground AS SELECT coinc_inspiral.coinc_event_id AS coinc_event_id, @@ -18,123 +20,65 @@ CREATE TEMPORARY TABLE is_playground AS JOIN coinc_event ON ( coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id ); -CREATE INDEX ip_cei_index ON is_playground (coinc_event_id); +CREATE INDEX tmpindex1 ON is_playground (coinc_event_id); +-- +-- create a look-up table of info required for clustering +-- --- temporary table containing highest SNR in each GPS second in each time --- slide in each on-instruments category for both playground and non-playground -CREATE TEMPORARY TABLE maxsnrs AS +CREATE TEMPORARY TABLE _cluster_info_ AS SELECT - coinc_inspiral.end_time AS end_time, - coinc_event.time_slide_id AS time_slide_id, - coinc_event.instruments AS on_instruments, - is_playground.is_playground AS is_playground, - MAX(coinc_inspiral.snr) AS snr + coinc_event.coinc_event_id AS coinc_event_id, + (coinc_event.time_slide_id || ";" || coinc_event.instruments || ";" || is_playground.is_playground) AS category, + (coinc_inspiral.end_time - (SELECT MIN(end_time) FROM coinc_inspiral)) + 1e-9 * coinc_inspiral.end_time_ns AS end_time, + coinc_inspiral.snr AS snr FROM - coinc_inspiral - JOIN coinc_event ON ( - coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id - ) + coinc_event JOIN is_playground ON ( - is_playground.coinc_event_id == coinc_inspiral.coinc_event_id + is_playground.coinc_event_id == coinc_event.coinc_event_id ) - GROUP BY - coinc_inspiral.end_time, - coinc_event.time_slide_id, - coinc_event.instruments, - is_playground.is_playground; - --- remove coincs whose SNRs are less than the highest SNR in their GPS --- second and time slide and on-instrument category -CREATE INDEX ms_et_index ON maxsnrs (end_time, time_slide_id, on_instruments, is_playground); -DELETE FROM - coinc_inspiral -WHERE - coinc_event_id NOT IN ( - SELECT - coinc_inspiral.coinc_event_id - FROM - coinc_inspiral - JOIN coinc_event INDEXED BY sqlite_autoindex_coinc_event_1 ON ( - coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id - ) - JOIN is_playground INDEXED BY ip_cei_index ON ( - is_playground.coinc_event_id == coinc_inspiral.coinc_event_id - ) - JOIN maxsnrs INDEXED BY ms_et_index ON ( - maxsnrs.end_time == coinc_inspiral.end_time - AND maxsnrs.time_slide_id == coinc_event.time_slide_id - AND maxsnrs.on_instruments == coinc_event.instruments - AND maxsnrs.is_playground == is_playground.is_playground - ) - WHERE - coinc_inspiral.snr >= maxsnrs.snr - ); -DROP INDEX ms_et_index; -DROP TABLE maxsnrs; + JOIN coinc_inspiral ON ( + coinc_inspiral.coinc_event_id == coinc_event.coinc_event_id + ); +DROP INDEX tmpindex1; +DROP TABLE is_playground; +CREATE INDEX tmpindex1 ON _cluster_info_ (coinc_event_id); +CREATE INDEX tmpindex2 ON _cluster_info_ (category, end_time, snr); --- remove unused coinc_event rows -DELETE FROM - coinc_event -WHERE - coinc_event_id NOT IN ( - SELECT - coinc_event_id - FROM - coinc_inspiral - ); +-- +-- delete coincs that are within 10 s of coincs with higher SNR in the same +-- category +-- --- find coincs that are within 10 s of coincs of higher effective SNR that --- involved the same instruments and were found in the same time slide --- NOTE: this code involves some *very* careful use of indeces to make --- this go quick, including the application of the constraints in a special --- order -CREATE INDEX ci_et_index ON coinc_inspiral (end_time); DELETE FROM coinc_event WHERE - coinc_event_id IN ( - SELECT DISTINCT - coinc_inspiral_a.coinc_event_id + EXISTS ( + SELECT + * FROM - coinc_inspiral AS coinc_inspiral_a - JOIN coinc_inspiral AS coinc_inspiral_b INDEXED BY ci_et_index ON ( - -- apply coarse \Delta t cut - coinc_inspiral_b.end_time BETWEEN coinc_inspiral_a.end_time - 10 AND coinc_inspiral_a.end_time + 10 - -- don't cluster coincs with themselves - AND coinc_inspiral_b.coinc_event_id != coinc_inspiral_a.coinc_event_id - ) - JOIN coinc_event AS coinc_event_a INDEXED BY sqlite_autoindex_coinc_event_1 ON ( - coinc_event_a.coinc_event_id == coinc_inspiral_a.coinc_event_id - ) - JOIN is_playground AS is_playground_a INDEXED BY ip_cei_index ON ( - is_playground_a.coinc_event_id == coinc_inspiral_a.coinc_event_id - ) - JOIN coinc_event AS coinc_event_b INDEXED BY sqlite_autoindex_coinc_event_1 ON ( - coinc_event_b.coinc_event_id == coinc_inspiral_b.coinc_event_id - ) - JOIN is_playground AS is_playground_b INDEXED BY ip_cei_index ON ( - is_playground_b.coinc_event_id == coinc_inspiral_b.coinc_event_id + _cluster_info_ AS _cluster_info_a_ + JOIN _cluster_info_ AS _cluster_info_b_ ON ( + _cluster_info_b_.category == _cluster_info_a_.category + AND (_cluster_info_b_.end_time BETWEEN _cluster_info_a_.end_time - 10.0 AND _cluster_info_a_.end_time + 10.0) + AND _cluster_info_b_.snr > _cluster_info_a_.snr ) WHERE - coinc_event_b.time_slide_id == coinc_event_a.time_slide_id - AND coinc_inspiral_b.snr >= coinc_inspiral_a.snr - AND coinc_event_b.instruments == coinc_event_a.instruments - AND is_playground_b.is_playground == is_playground_a.is_playground - AND coinc_event_b.coinc_def_id == coinc_event_a.coinc_def_id - -- apply fine \Delta t cut - AND abs((coinc_inspiral_b.end_time - coinc_inspiral_a.end_time) + (coinc_inspiral_b.end_time_ns - coinc_inspiral_a.end_time_ns) * 1e-9) < 10.0 + _cluster_info_a_.coinc_event_id == coinc_event.coinc_event_id ); -DROP INDEX ci_et_index; -DROP INDEX ip_cei_index; -DROP TABLE is_playground; +DROP INDEX tmpindex1; +DROP INDEX tmpindex2; +DROP TABLE _cluster_info_; SELECT "Number of coincs after clustering: " || count(*) FROM coinc_event; +-- -- delete unused coinc_inspiral rows +-- + DELETE FROM coinc_inspiral WHERE @@ -145,7 +89,10 @@ WHERE coinc_event ); +-- -- delete unused coinc_event_map rows +-- + DELETE FROM coinc_event_map WHERE @@ -156,7 +103,10 @@ WHERE coinc_event ); +-- -- delete unused sngl_inspiral rows +-- + DELETE FROM sngl_inspiral WHERE @@ -169,5 +119,8 @@ WHERE table_name == 'sngl_inspiral' ); --- VACUUM, this reduces the file size by ~6 -VACUUM; +-- +-- shrink the file +-- + +-- VACUUM; diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/highmass_post_process.py b/lalapps/src/inspiral/s5_highmass_upper_limit/highmass_post_process.py index b6125bcfa7e2a381beddf65dc0c56d64a1733fd9..0212a998e37f9382aaf3a00bb5b4d0f8952b77d3 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/highmass_post_process.py +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/highmass_post_process.py @@ -23,6 +23,7 @@ import subprocess ############################################################################## # import the modules we need to build the pipeline +from glue import iterutils from glue import pipeline from glue import lal from glue.ligolw import lsctables @@ -39,6 +40,161 @@ class hm_post_DAG(pipeline.CondorDAG): pipeline.CondorDAG.__init__(self,logfile) self.set_dag_file(self.basename) self.jobsDict = {} + self.node_id = 0 + + def add_node(self, node): + self.node_id += 1 + node.add_macro("macroid", self.node_id) + pipeline.CondorDAG.add_node(self, node) + +############################################################################### +########## MUSIC STUFF ######################################################## +############################################################################### +class mvsc_get_doubles_job(pipeline.CondorDAGJob): + """ + A mvsc_get_doubles.py job: BLAH + """ + def __init__(self, cp, tag_base='MVSC_GET_DOUBLES'): + """ + """ + self.__prog__ = 'mvsc_get_doubles.py' + self.__executable = string.strip(cp.get('condor','mvsc_get_doubles.py')) + self.__universe = "vanilla" + pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) + self.add_condor_cmd('getenv','True') + self.tag_base = tag_base + self.add_condor_cmd('environment',"KMP_LIBRARY=serial;MKL_SERIAL=yes") + self.set_sub_file(tag_base+'.sub') + self.set_stdout_file('logs/'+tag_base+'-$(macroid)-$(process).out') + self.set_stderr_file('logs/'+tag_base+'-$(macroid)-$(process).err') + + +class mvsc_get_doubles_node(pipeline.CondorDAGNode): + """ + """ +# add default values + def __init__(self, job, dag, instruments, databases, number=10, trainingstr='training', testingstr='testing', zerolagstr='zerolag', p_node=[]): + pipeline.CondorDAGNode.__init__(self,job) + self.number = number + self.add_var_opt("instruments", instruments) + self.add_var_opt("trainingstr",trainingstr) + self.add_var_opt("testingstr",testingstr) + self.add_var_opt("zerolagstr",zerolagstr) + for database in databases: + self.add_file_arg(database) + ifos=instruments.strip().split(',') + ifos.sort() + self.out_file_group = {} + for i in range(number): + self.out_file_group[i] = ((''.join(ifos) + '_set' + str(i) + '_' + str(trainingstr) + '.pat'), (''.join(ifos) + '_set' + str(i) + '_' + str(testingstr) + '.pat'), self.add_output_file(''.join(ifos) + '_set' + str(i) + '_' + str(testingstr) + '_info.pat')) + self.zerolag_file = [''.join(ifos) + '_' + str(zerolagstr) + '.pat'] + + for p in p_node: + self.add_parent(p) + dag.add_node(self) + +class train_forest_job(pipeline.CondorDAGJob): + """ + """ + def __init__(self, cp, tag_base='TRAIN_FOREST'): + """ + """ + self.__prog__ = 'SprBaggerDecisionTreeApp' + self.__executable = string.strip(cp.get('condor','SprBaggerDecisionTreeApp')) + self.__universe = "vanilla" + pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) + self.add_condor_cmd('getenv','True') + self.tag_base = tag_base + self.add_condor_cmd('environment',"KMP_LIBRARY=serial;MKL_SERIAL=yes") + self.set_sub_file(tag_base+'.sub') + self.set_stdout_file('logs/'+tag_base+'-$(macroid)-$(process).out') + self.set_stderr_file('logs/'+tag_base+'-$(macroid)-$(process).err') + +class train_forest_node(pipeline.CondorDAGNode): + """ + """ + def __init__(self, job, dag, trainingfile, p_node=[]): + pipeline.CondorDAGNode.__init__(self,job) + self.add_input_file(trainingfile) + self.trainingfile = self.get_input_files()[0] + self.trainedforest = self.trainingfile.replace('_training.pat','.spr') + self.add_file_arg("-a 1 -n 100 -l 4 -s 4 - c 6 -g 1 -i -d 1 -f %s %s" % (self.trainedforest, self.trainingfile)) + self.add_output_file(self.trainedforest) + for p in p_node: + self.add_parent(p) + dag.add_node(self) + +class use_forest_job(pipeline.CondorDAGJob): + """ + """ + def __init__(self, cp, tag_base='USE_FOREST'): + """ + """ + self.__prog__ = 'SprOutputWriterApp' + self.__executable = string.strip(cp.get('condor','SprOutputWriterApp')) + self.__universe = "vanilla" + pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) + self.add_condor_cmd('getenv','True') + self.tag_base = tag_base + self.add_condor_cmd('environment',"KMP_LIBRARY=serial;MKL_SERIAL=yes") + self.set_sub_file(tag_base+'.sub') + self.set_stdout_file('logs/'+tag_base+'-$(macroid)-$(process).out') + self.set_stderr_file('logs/'+tag_base+'-$(macroid)-$(process).err') + +class use_forest_node(pipeline.CondorDAGNode): + """ + """ + def __init__(self, job, dag, trainedforest, file_to_rank, p_node=[]): + pipeline.CondorDAGNode.__init__(self,job) + self.add_input_file(trainedforest) + self.add_input_file(file_to_rank) + self.trainedforest = self.get_input_files()[0] + self.file_to_rank = self.get_input_files()[1] + self.ranked_file = self.file_to_rank.replace('.pat','.dat') + self.add_file_arg("-a 1 %s %s %s" % (self.trainedforest, self.file_to_rank, self.ranked_file)) + self.add_output_file(self.ranked_file) +# I need to figure out how to parse these options + for p in p_node: + self.add_parent(p) + dag.add_node(self) + +class mvsc_update_sql_job(pipeline.CondorDAGJob): + """ + A mvsc_update_sql.py job: BLAH + """ + def __init__(self, cp, tag_base='MVSC_UPDATE_SQL'): + """ + """ + self.__prog__ = 'mvsc_update_sql.py' + self.__executable = string.strip(cp.get('condor','mvsc_update_sql.py')) + self.__universe = "vanilla" + pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) + self.add_condor_cmd('getenv','True') + self.tag_base = tag_base + self.add_condor_cmd('environment',"KMP_LIBRARY=serial;MKL_SERIAL=yes") + self.set_sub_file(tag_base+'.sub') + self.set_stdout_file('logs/'+tag_base+'-$(macroid)-$(process).out') + self.set_stderr_file('logs/'+tag_base+'-$(macroid)-$(process).err') + +class mvsc_update_sql_node(pipeline.CondorDAGNode): + """ + """ + def __init__(self, job, dag, files='*.dat', infofiles='*_info.pat', databases='*.sqlite', p_node=[]): + pipeline.CondorDAGNode.__init__(self,job) + # uhh these are still globs! FIXME + self.add_var_opt("files", files) + self.add_var_opt("infofiles", infofiles) + self.add_var_opt("databases", databases) + # do I need to put the databases as output files? + for p in p_node: + self.add_parent(p) + dag.add_node(self) + + +############################################################################### +###### END MUSIC STUFF ######################################################## +############################################################################### + class sqlite_job(pipeline.CondorDAGJob): """ @@ -49,7 +205,7 @@ class sqlite_job(pipeline.CondorDAGJob): """ self.__prog__ = 'sqlite3' self.__executable = string.strip(cp.get('condor','sqlite3')) - self.__universe = "vanilla" + self.__universe = string.strip(cp.get('condor','sqlite3_universe')) pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) self.add_condor_cmd("input","$(macroinput)") self.add_condor_cmd('getenv','True') @@ -208,11 +364,47 @@ class far_plot_job(pipeline.CondorDAGJob): self.set_stdout_file('logs/'+tag_base+'-$(macroid)-$(process).out') self.set_stderr_file('logs/'+tag_base+'-$(macroid)-$(process).err') +class ul_plot_job(pipeline.CondorDAGJob): + """ + A ul_plot Job + """ + def __init__(self, cp, tag_base='UL_PLOT'): + """ + """ + self.__prog__ = 'ul_plot' + self.__executable = string.strip(cp.get('condor','ul_plot')) + self.__universe = "vanilla" + pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) + self.add_condor_cmd('getenv','True') + self.tag_base = tag_base + self.add_condor_cmd('environment',"KMP_LIBRARY=serial;MKL_SERIAL=yes") + self.set_sub_file(tag_base+'.sub') + self.set_stdout_file('logs/'+tag_base+'-$(macroid)-$(process).out') + self.set_stderr_file('logs/'+tag_base+'-$(macroid)-$(process).err') + +class summary_page_job(pipeline.CondorDAGJob): + """ + A summary page job + """ + def __init__(self, cp, tag_base='SUMMARY_PAGE'): + """ + """ + self.__prog__ = 'summary_page' + self.__executable = string.strip(cp.get('condor','summary_page')) + self.__universe = "vanilla" + pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) + self.add_condor_cmd('getenv','True') + self.tag_base = tag_base + self.add_condor_cmd('environment',"KMP_LIBRARY=serial;MKL_SERIAL=yes") + self.set_sub_file(tag_base+'.sub') + self.add_opt("webserver", string.strip(cp.get('output','web_page'))) + self.set_stdout_file('logs/'+tag_base+'-$(macroid)-$(process).out') + self.set_stderr_file('logs/'+tag_base+'-$(macroid)-$(process).err') class ligolw_sqlite_node(pipeline.CondorDAGNode): """ """ - def __init__(self, job, dag, database, xml_list, id, p_node=[], replace=True, extract=False,cache_pat=None): + def __init__(self, job, dag, database, xml_list, p_node=[], replace=True, extract=False,cache_pat=None): pipeline.CondorDAGNode.__init__(self,job) #FIXME add tmp file space @@ -221,13 +413,13 @@ class ligolw_sqlite_node(pipeline.CondorDAGNode): if extract: cline += " --extract " if cache_pat: cline += " --input-cache ligolw_sqlite_" + cache_pat + ".cache " for xml in xml_list: cline += xml + " " - fn = "bash_scripts/ligolw_sqlite"+str(id)+".sh" + #FIXME the node id will be incremented when it is added, so we do +1 by hand here + fn = "bash_scripts/ligolw_sqlite"+str(dag.node_id+1)+".sh" f = open(fn,"w") if cache_pat: f.write("find $PWD -name '*" + cache_pat + "*.xml.gz' -print | sed -e 's?^?- - - - file://localhost?' > ligolw_sqlite_" + cache_pat + ".cache\n") f.write(cline) f.close - self.add_macro("macroid", id) self.add_file_arg(fn) for p in p_node: @@ -237,7 +429,7 @@ class ligolw_sqlite_node(pipeline.CondorDAGNode): class ligolw_thinca_to_coinc_node(pipeline.CondorDAGNode): """ """ - def __init__(self, job, dag, cache, vetoes, veto_name, prefix, id, start_time, end_time, effsnrfac=50.0, p_node=[], instruments='H1,H2,L1'): + def __init__(self, job, dag, cache, vetoes, veto_name, prefix, start_time, end_time, effsnrfac=50.0, p_node=[], instruments='H1,H2,L1,V1'): pipeline.CondorDAGNode.__init__(self,job) self.add_var_opt("ihope-cache", cache) self.add_var_opt("veto-segments", vetoes) @@ -248,7 +440,6 @@ class ligolw_thinca_to_coinc_node(pipeline.CondorDAGNode): self.add_var_opt("experiment-start-time", start_time) self.add_var_opt("experiment-end-time", end_time) - self.add_macro("macroid", id) for p in p_node: self.add_parent(p) dag.add_node(self) @@ -256,10 +447,9 @@ class ligolw_thinca_to_coinc_node(pipeline.CondorDAGNode): class sqlite_node(pipeline.CondorDAGNode): """ """ - def __init__(self, job, dag, database, sqlfile, id, p_node=[]): + def __init__(self, job, dag, database, sqlfile, p_node=[]): pipeline.CondorDAGNode.__init__(self,job) - self.add_macro("macroid", id) self.add_file_arg(database) self.add_macro("macroinput", sqlfile) for p in p_node: @@ -269,11 +459,10 @@ class sqlite_node(pipeline.CondorDAGNode): class ligolw_inspinjfind_node(pipeline.CondorDAGNode): """ """ - def __init__(self, job, dag, xml, id, p_node=[]): + def __init__(self, job, dag, xml, p_node=[]): pipeline.CondorDAGNode.__init__(self,job) self.add_var_arg(xml) - self.add_macro("macroid", id) for p in p_node: self.add_parent(p) dag.add_node(self) @@ -281,13 +470,12 @@ class ligolw_inspinjfind_node(pipeline.CondorDAGNode): class ligolw_segments_node(pipeline.CondorDAGNode): """ """ - def __init__(self, job, dag, ifodict, name, output, id, p_node=[], coalesce=True): + def __init__(self, job, dag, ifodict, name, output, p_node=[], coalesce=True): pipeline.CondorDAGNode.__init__(self,job) # HA HA, we win! self.add_var_opt("insert-from-segwizard", " --insert-from-segwizard ".join(["%s=%s" % (instrument.upper(), filename) for instrument, filename in ifodict.items()])) self.add_var_opt("name",name) self.add_var_opt("output",output) - self.add_macro("macroid", id) if coalesce: self.add_var_opt("coalesce","") for p in p_node: self.add_parent(p) @@ -296,7 +484,7 @@ class ligolw_segments_node(pipeline.CondorDAGNode): class lalapps_newcorse_node(pipeline.CondorDAGNode): """ """ - def __init__(self, job, dag, veto_segments_name, database, id, p_node=[],instruments = "H1,H2,L1", mass_bins="0,50,85,inf", live_time_program="thinca", categories="mtotal-ifos-oninstruments", rank="snr"): + def __init__(self, job, dag, veto_segments_name, database, p_node=[], mass_bins="0,50,85,inf", live_time_program="thinca", categories="mtotal-ifos-oninstruments", rank="snr", ext_num=5): pipeline.CondorDAGNode.__init__(self,job) #FIXME make temp space? #self.add_var_opt("tmp-space","/tmp") @@ -305,8 +493,8 @@ class lalapps_newcorse_node(pipeline.CondorDAGNode): self.add_var_opt("live-time-program",live_time_program) self.add_var_opt("veto-segments-name",veto_segments_name) self.add_var_opt("rank-by", rank) + self.add_var_opt("extrapolation-num", ext_num) self.add_var_arg(database) - self.add_macro("macroid", id) for p in p_node: self.add_parent(p) dag.add_node(self) @@ -315,56 +503,154 @@ class hm_upperlimit_node(pipeline.CondorDAGNode): """ hm_upperlimit.py --instruments --output-name-tag --full-data-file --inj-data-glob --bootstrap-iterations --veto-segments-name """ - def __init__(self, job, dag, ifos, output_name_tag, full_data_file, inj_data_glob, bootstrap_iterations, veto_segments_name, id, p_node=[]): + def __init__(self, job, dag, output_name_tag, database, bootstrap_iterations=10000, veto_segments_name="vetoes", ifos=None, p_node=[]): pipeline.CondorDAGNode.__init__(self,job) #FIXME make temp space? #self.add_var_opt("tmp-space","/tmp") - self.add_var_opt("instruments",ifos) + if ifos: self.add_var_opt("instruments",ifos) self.add_var_opt("output-name-tag",output_name_tag) - self.add_var_opt("full-data-file",full_data_file) - self.add_var_opt("inj-data-glob",inj_data_glob) + self.output_name_tag = output_name_tag self.add_var_opt("bootstrap-iterations",bootstrap_iterations) self.add_var_opt("veto-segments-name",veto_segments_name) - self.add_macro("macroid", id) + self.add_var_arg(database) for p in p_node: self.add_parent(p) dag.add_node(self) + def output_by_combo(self,ifo_combinations): + upperlimit_fnames = [] + for ifo_combination in ifo_combinations: + #FIXME use a different function + ifo_combination = str(ifo_combination) + fname = '2Dsearchvolume-' + self.output_name_tag + '-' + ifo_combination.replace(',','') + '.xml' + upperlimit_fnames.append(fname) + fstr = " ".join(upperlimit_fnames) + return fstr + + class far_plot_node(pipeline.CondorDAGNode): """ """ - def __init__(self, job, dag, database, id, p_node): + def __init__(self, job, dag, database, p_node, base=None): pipeline.CondorDAGNode.__init__(self,job) - self.add_macro("macroid", id) + if base: self.add_var_opt("base", base) self.add_var_arg(database) for p in p_node: self.add_parent(p) dag.add_node(self) +class ul_plot_node(pipeline.CondorDAGNode): + """ + """ + def __init__(self, job, dag, xml_list, p_node): + pipeline.CondorDAGNode.__init__(self,job) + self.add_var_arg(xml_list) + for p in p_node: + self.add_parent(p) + dag.add_node(self) +class summary_page_node(pipeline.CondorDAGNode): + """ + """ + def __init__(self, job, dag, open_box=None, base_name=None, p_node=[]): + pipeline.CondorDAGNode.__init__(self,job) + if open_box: self.add_var_arg("--open-box") + if base_name: self.add_var_opt("output-name-tag", base_name) + for p in p_node: + self.add_parent(p) + dag.add_node(self) + +def ifo_combos(ifosegdict): + ifos = [] + combos = [] + for ifo in ifosegdict.keys(): + if ifosegdict[ifo]: ifos.append(ifo) + ifos.sort() + for i in range(2, len(ifos)+1): + combos.extend([j for j in iterutils.choices(ifos,i)]) + l = [i for i in combos] + combos = [] + for i in l: combos.append(",".join(i)) + #FIXME assumes we don't look at H1H2 + if 'H1,H2' in combos: combos.remove('H1,H2') + return combos def ifo_seg_dict(cp): out = {} - - out["H1"] = string.strip(cp.get('input','h1vetosegments')) - out["H2"] = string.strip(cp.get('input','h2vetosegments')) - out["L1"] = string.strip(cp.get('input','l1vetosegments')) - cat = "_".join(os.path.basename(out["H1"]).split("_")[1:3]) - return out, [cat] - - -def grep(string, inname, outname): + instruments = set() + cat_list = set() + ifos = ['H1','H2','L1','V1'] + cats = ['CAT_2', 'CAT_3'] + combos = {} + for c in cats: + out[c] = {} + for i in ifos: + name_str = i.lower() + '-' + c.lower() + '-vetosegments' + if string.strip(cp.get('input',name_str)): + out[c][i] = string.strip(cp.get('input',name_str)) + instruments.add(i) + cat_list.add(c) + combos[c] = ifo_combos(out[c]) + print>>sys.stderr, "\tfound these " + c + " combos:", combos[c] + + #FIXME use proper instruments utilities + instruments = list(instruments) + instruments.sort() + cat_list = list(cat_list) + cat_list.sort() + if len(out['CAT_2']) and len(out['CAT_2']) and ( len(out['CAT_2']) != len(out['CAT_3']) ): + print >>sys.stderr, "cat 2 instruments don't agree with cat3 instruments, aborting." + sys.exit(1) + return out, cat_list, combos, ",".join(instruments) + + +def grep(string, inname, outname, append_cache=None): o = open(outname, "w") - print "grepping " + inname + " for " + string + " and sending it to " + outname + #print >>sys.stderr, "grepping %s for %s and sending it to %s" % (inname, string, outname + ".cache") + #print >>sys.stderr, "grepping " + inname + " for " + string + " and sending it to " + outname + "\r", expr = re.compile(string) o.write(''.join(filter(expr.search,open(inname).readlines()))) + if append_cache: o.write(''.join(append_cache)) + o.close() + + +def grep_pieces_and_append(string, inname, outname, append_cache=None): + expr = re.compile(string) + new_list = filter(expr.search,open(inname).readlines()) + new_list.sort() + #print len(new_list) + outnames = [] + try: os.mkdir(outname) + except: pass + # To make sure that includes slides and zero lag + for i in range(len(new_list)): + if not i % 10: + outnames.append(outname+"/"+outname+"_"+str(i)) + o = open(outnames[-1]+".cache", "w") + if append_cache: o.write(''.join(append_cache)) + print >>sys.stderr, "\tbreaking up full data into pieces %f%%\r" % (float(i) / len(new_list) * 100.0,), + o.write(new_list[i]) + o.write(new_list[i].replace('THINCA_SECOND','THINCA_SLIDE_SECOND')) + return outnames + +def get_doubles(instruments): + all_ifos = instruments.strip().split(',') + ifo_combinations = list(iterutils.choices(all_ifos,2)) + for comb in ifo_combinations: + comb=','.join(comb) + return comb ############################################################################### # MAIN PROGRAM ############################################################################### +print >> sys.stderr, "\n...WELCOME FRIENDOS...\n" + cp = ConfigParser.ConfigParser() -cp.read("hm_post.ini") +try: cp.read("hm_post.ini") +except: + print "couldn't find hm_post.ini" + sys.exit(1) try: os.mkdir("logs") except: pass @@ -373,7 +659,7 @@ try: os.mkdir("bash_scripts") except: pass # get the segments for a given category veto -seg_dict, cats = ifo_seg_dict(cp) +seg_dict, cats, ifo_combinations, instruments = ifo_seg_dict(cp) types = ["FULL_DATA"] FULLDATACACHE = string.strip(cp.get('input','fulldatacache')) @@ -382,7 +668,12 @@ dag = hm_post_DAG("hm_post.ini", string.strip(cp.get('output','logpath'))) # to get injection file entries from the cache #break down the cache to save on parsing -grep('HL', INJCACHE, "inj.cache") +grep('HL-INJ', INJCACHE, "inj.cache") + +#get second stage inspiral jobs for meta data +expr = re.compile("INSPIRAL_SECOND") +inspiral_second_list = filter(expr.search,open(FULLDATACACHE).readlines()) + #Setup jobs sqliteJob = sqlite_job(cp) @@ -393,13 +684,15 @@ lalappsNewcorseJobCombined = lalapps_newcorse_combined_job(cp) ligolwSegmentsJob = ligolw_segments_job(cp) ligolwThincaToCoincJob = ligolw_thinca_to_coinc_job(cp) hmUpperlimitJob = hm_upperlimit_job(cp) +hmUpperlimitPlotJob = ul_plot_job(cp) farPlotJob = far_plot_job(cp) +summaryPageJob = summary_page_job(cp) n = 0 #Do the segments node segNode = {} for cat in cats: - segNode[cat] = ligolw_segments_node(ligolwSegmentsJob, dag, seg_dict, "vetoes", "vetoes_"+cat+".xml.gz", n); n+=1 + segNode[cat] = ligolw_segments_node(ligolwSegmentsJob, dag, seg_dict[cat], "vetoes", "vetoes_"+cat+".xml.gz"); #Some initialization ligolwThincaToCoincNode = {} @@ -410,12 +703,37 @@ ligolwSqliteNode = {} ligolwSqliteNodeInjDBtoXML = {} ligolwSqliteNodeInjXMLtoDB = {} ligolwInspinjfindNode = {} -lallappsNewcorseNode = {} -lallappsNewcorseNodeCombined = {} +lalappsNewcorseNode = {} +lalappsNewcorseNodeCombined = {} hmUpperlimitNode = {} +hmUpperlimitPlotNode = {} farPlotNode = {} +summaryPageNode = {} db = {} +############# MUSIC STUFF #################### + +#mvsc_get_doubles +get_job = mvsc_get_doubles_job(cp) +get_node = {} + +#SprBaggerDecisionTreeApp +train_job = train_forest_job(cp) +train_node = {} + +#SprOutputWriterApp +rank_job = use_forest_job(cp) +rank_node = {} +zl_rank_job = use_forest_job(cp) +zl_rank_node = {} + +#mvsc_update_sql +update_job = mvsc_update_sql_job(cp) +update_node = {} + +############################################# + + # to get injection file entries from the cache injcache = map(lal.CacheEntry, file("inj.cache")) inj = injcache[0] @@ -424,26 +742,43 @@ end_time = inj.segment[1] timestr = str(start_time) + "-" + str(end_time) -for type in types: - for cat in cats: +############################################### +# LOOP OVER CATS +############################################### +for cat in cats: + print >>sys.stderr, "\nAnalyzing " + cat + p_nodes = {} + p_nodes[cat] = [] + ############################################### + # FULL DATA THINCA TO COINC AND CLUSTERING ETC + ############################################### + for type in types: #break down the cache to save on parsing tag = type + "_" + cat - grep('THINCA_SECOND_.*'+type + ".*" + cat, FULLDATACACHE, tag + ".cache") - try: os.mkdir(tag) - except: pass - ligolwThincaToCoincNode[type+cat] = ligolw_thinca_to_coinc_node(ligolwThincaToCoincJob, dag, tag+".cache", "vetoes_"+cat+".xml.gz", "vetoes", tag+"/S5_HM_"+timestr, n, start_time, end_time, effsnrfac=50, p_node=[segNode[cat]]); n+=1 + out_tags = grep_pieces_and_append('THINCA_SECOND_.*'+type + ".*" + cat, FULLDATACACHE, tag, inspiral_second_list) + cnt = 0; + node_list = [] + for otag in out_tags: + ligolwThincaToCoincNode[type+cat+str(cnt)] = ligolw_thinca_to_coinc_node(ligolwThincaToCoincJob, dag, otag+".cache", "vetoes_"+cat+".xml.gz", "vetoes", otag+timestr, start_time, end_time, effsnrfac=string.strip(cp.get('input',"eff_snr_fac")), instruments=instruments, p_node=[segNode[cat]]); + node_list.append(ligolwThincaToCoincNode[type+cat+str(cnt)]) + cnt+=1 database = tag+"_"+timestr+".sqlite" try: db[cat].append(database) except: db[cat] = [database] - #xml_list = [tag+"/S5_HM_"+timestr+"*"+type+"*"+cat+"*.xml.gz", "vetoes_"+cat+".xml.gz"] xml_list = ["vetoes_"+cat+".xml.gz"] - ligolwSqliteNode[type+cat] = ligolw_sqlite_node(ligolwSqliteJob, dag, database, xml_list, n, p_node=[ligolwThincaToCoincNode[type+cat]], replace=True, cache_pat=tag); n+=1 - sqliteNodeSimplify[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"simplify")), n, p_node=[ligolwSqliteNode[type+cat]]); n+=1 - sqliteNodeRemoveH1H2[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"remove_h1h2")),n, p_node=[sqliteNodeSimplify[type+cat]]); n+=1 - sqliteNodeCluster[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"cluster")),n, p_node=[sqliteNodeRemoveH1H2[type+cat]]); n+=1 - -for inj in injcache: - for cat in cats: + ligolwSqliteNode[type+cat] = ligolw_sqlite_node(ligolwSqliteJob, dag, database, xml_list, p_node=node_list, replace=True, cache_pat=tag); + sqliteNodeSimplify[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"simplify")), p_node=[ligolwSqliteNode[type+cat]]); + sqliteNodeRemoveH1H2[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"remove_h1h2")), p_node=[sqliteNodeSimplify[type+cat]]); + sqliteNodeCluster[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"cluster")), p_node=[sqliteNodeRemoveH1H2[type+cat]]); + # keep track of parents + p_nodes[cat].append(sqliteNodeCluster[type+cat]) + + ############################################### + # INJECTION THINCA TO COINC AND CLUSTERING ETC + ############################################### + print >> sys.stderr, "\n" + for injnum, inj in enumerate(injcache): + print >> sys.stderr, "\tprocessing injection %f %%\r" % (float(injnum) / len(injcache) * 100.00,), type = "_".join(inj.description.split("_")[2:]) tag = type + "_" + cat url = inj.url @@ -451,52 +786,82 @@ for inj in injcache: try: os.mkdir(tag) except: pass #break down the cache - grep('THINCA_SECOND_.*'+type + '.*' + cat, INJCACHE, cachefile) - ligolwThincaToCoincNode[type+cat] = ligolw_thinca_to_coinc_node(ligolwThincaToCoincJob, dag, cachefile, "vetoes_"+cat+".xml.gz", "vetoes", tag+"/S5_HM_INJ_"+timestr, n, start_time, end_time, effsnrfac=50, p_node=[segNode[cat]]);n+=1 + grep('THINCA_SECOND_.*'+type + '.*' + cat, INJCACHE, cachefile, inspiral_second_list) + ligolwThincaToCoincNode[type+cat] = ligolw_thinca_to_coinc_node(ligolwThincaToCoincJob, dag, cachefile, "vetoes_"+cat+".xml.gz", "vetoes", tag+"/S5_HM_INJ_"+timestr, start_time, end_time, effsnrfac=50, instruments=instruments, p_node=[segNode[cat]]); database = tag+"_"+timestr+".sqlite" db_to_xml_name = tag +"_"+timestr+".xml.gz" try: db[cat].append(database) except: db[cat] = [database] - #xml_list = [type+cat+"/S5_HM_INJ_"+timestr+"*"+type+"*"+cat+"*.xml.gz", url, "vetoes_"+cat+".xml.gz"] xml_list = [url, "vetoes_"+cat+".xml.gz"] - ligolwSqliteNode[type+cat] = ligolw_sqlite_node(ligolwSqliteJob, dag, database, xml_list, n, p_node=[ligolwThincaToCoincNode[type+cat]], replace=True,cache_pat=tag);n+=1 - sqliteNodeSimplify[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"simplify")), n, p_node=[ligolwSqliteNode[type+cat]]);n+=1 - sqliteNodeRemoveH1H2[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"remove_h1h2")),n, p_node=[sqliteNodeSimplify[type+cat]]);n+=1 - sqliteNodeCluster[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"cluster")),n, p_node=[sqliteNodeRemoveH1H2[type+cat]]);n+=1 - ligolwSqliteNodeInjDBtoXML[type+cat] = ligolw_sqlite_node(ligolwSqliteJob, dag, database, [db_to_xml_name], n, p_node=[sqliteNodeCluster[type+cat]], replace=False, extract=True); n+=1 - ligolwInspinjfindNode[type+cat] = ligolw_inspinjfind_node(ligolwInspinjfindJob, dag, db_to_xml_name, n, p_node=[ligolwSqliteNodeInjDBtoXML[type+cat]]);n+=1 - ligolwSqliteNodeInjXMLtoDB[type+cat] = ligolw_sqlite_node(ligolwSqliteJob, dag, database, [db_to_xml_name], n, p_node=[ligolwInspinjfindNode[type+cat]], replace=True);n+=1 - -# New corse -# First work out the parent/child relationships -p_nodes = [] -for k in ligolwInspinjfindNode.keys(): - p_nodes.append(ligolwSqliteNodeInjXMLtoDB[k]) -for k in sqliteNodeCluster.keys(): - p_nodes.append(sqliteNodeCluster[k]) - -#New corse jobs -for cat in cats: + ligolwSqliteNode[type+cat] = ligolw_sqlite_node(ligolwSqliteJob, dag, database, xml_list, p_node=[ligolwThincaToCoincNode[type+cat]], replace=True,cache_pat=tag); + sqliteNodeSimplify[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"simplify")), p_node=[ligolwSqliteNode[type+cat]]); + sqliteNodeRemoveH1H2[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"remove_h1h2")), p_node=[sqliteNodeSimplify[type+cat]]); + sqliteNodeCluster[type+cat] = sqlite_node(sqliteJob, dag, database, string.strip(cp.get('input',"cluster")), p_node=[sqliteNodeRemoveH1H2[type+cat]]); + ligolwSqliteNodeInjDBtoXML[type+cat] = ligolw_sqlite_node(ligolwSqliteJob, dag, database, [db_to_xml_name], p_node=[sqliteNodeCluster[type+cat]], replace=False, extract=True); + ligolwInspinjfindNode[type+cat] = ligolw_inspinjfind_node(ligolwInspinjfindJob, dag, db_to_xml_name, p_node=[ligolwSqliteNodeInjDBtoXML[type+cat]]); + ligolwSqliteNodeInjXMLtoDB[type+cat] = ligolw_sqlite_node(ligolwSqliteJob, dag, database, [db_to_xml_name], p_node=[ligolwInspinjfindNode[type+cat]], replace=True); + # keep track of parent nodes + p_nodes[cat].append(ligolwSqliteNodeInjXMLtoDB[type+cat]) + + + ############################################### + # FAR PLOTS AND UPPER LIMITS OH MY + ############################################### + + base_name = cat + "_" + timestr + "_" + #to compute uncombined far - lallappsNewcorseNode[cat] = lalapps_newcorse_node(lalappsNewcorseJob, dag, "vetoes", " ".join(db[cat]), n, p_nodes, mass_bins="0,50,85,inf", categories="mtotal-ifos-oninstruments", rank="snr");n+=1 + lalappsNewcorseNode[cat] = lalapps_newcorse_node(lalappsNewcorseJob, dag, "vetoes", " ".join(db[cat]), p_nodes[cat], mass_bins="0,50,85,inf", categories="mtotal-ifos-oninstruments", rank="snr", ext_num=5); + #to compute combined far - lallappsNewcorseNodeCombined[cat] = lalapps_newcorse_node(lalappsNewcorseJobCombined, dag, "vetoes", " ".join(db[cat]), n, [lallappsNewcorseNode[cat]], mass_bins=None, categories="oninstruments", rank="uncombined-ifar");n+=1 + lalappsNewcorseNodeCombined[cat] = lalapps_newcorse_node(lalappsNewcorseJobCombined, dag, "vetoes", " ".join(db[cat]), [lalappsNewcorseNode[cat]], mass_bins=None, categories="oninstruments", rank="uncombined-ifar", ext_num=1); -#Upper limit jobs -for cat in ['CAT_3']: - hmUpperlimitNode[cat] = hm_upperlimit_node(hmUpperlimitJob, dag, "H1,H2,L1",timestr, "FULL_DATA_CAT_3_"+timestr+".sqlite", "*INJ_CAT_3_"+timestr+".sqlite", 10000, "vetoes", n, p_node=[lallappsNewcorseNode[cat]]);n+=1 - hmUpperlimitNode[cat] = hm_upperlimit_node(hmUpperlimitJob, dag, "H1,L1", timestr, "FULL_DATA_CAT_3_"+timestr+".sqlite", "*INJ_CAT_3_"+timestr+".sqlite", 10000, "vetoes", n, p_node=[lallappsNewcorseNode[cat]]);n+=1 - hmUpperlimitNode[cat] = hm_upperlimit_node(hmUpperlimitJob, dag, "H2,L1", timestr, "FULL_DATA_CAT_3_"+timestr+".sqlite", "*INJ_CAT_3_"+timestr+".sqlite", 10000, "vetoes", n, p_node=[lallappsNewcorseNode[cat]]);n+=1 + # lalapps_cbc_plotsummary plots + farPlotNode[cat] = far_plot_node(farPlotJob, dag, " ".join(db[cat]), [lalappsNewcorseNodeCombined[cat]], base=base_name); + + # upper limit + hmUpperlimitNode[cat] = hm_upperlimit_node(hmUpperlimitJob, dag, base_name, " ".join(db[cat]), p_node=[lalappsNewcorseNodeCombined[cat]]); + + # upper limit plots + hmUpperlimitPlotNode[cat] = ul_plot_node(hmUpperlimitPlotJob, dag, hmUpperlimitNode[cat].output_by_combo(ifo_combinations[cat]), [hmUpperlimitNode[cat]]); + + # Summary pages (open and closed box) + summaryPageNode[cat] = summary_page_node(summaryPageJob, dag, base_name=base_name, p_node=[hmUpperlimitPlotNode[cat]]); + summaryPageNode[cat+"open"] = summary_page_node(summaryPageJob, dag, open_box=True, base_name=base_name, p_node=[hmUpperlimitPlotNode[cat]]); -#IFAR plots -for cat in cats: - farPlotNode[cat] = far_plot_node(farPlotJob, dag, " ".join(db[cat]), n, [lallappsNewcorseNodeCombined[cat]]);n+=1 + + ############# MUSIC STUFF (A LOOP OVER DOUBLES) ############################# + + for comb in get_doubles(instruments): + comb = ','.join(comb) + get_node[cat+comb] = mvsc_get_doubles_node(get_job, dag, comb, db[cat], trainingstr=base_name+"training",testingstr=base_name+"testing",zerolagstr=base_name+"zerolag",p_node=[hmUpperlimitNode[cat]]) + + for i in range(get_node[cat+comb].number): + file_for_this_set = get_node[cat+comb].out_file_group[i] + train_node[i] = train_forest_node(train_job, dag, file_for_this_set[0], p_node=[get_node[cat+comb]]) + try: rank_node[cat+comb] + except: rank_node[cat+comb] = {} + rank_node[cat+comb][i] = use_forest_node(rank_job, dag, train_node[i].trainedforest, file_for_this_set[1], p_node=[train_node[i]]) + + zl_rank_node[cat+comb] = use_forest_node(zl_rank_job, dag, train_node[0].trainedforest, get_node[cat+comb].zerolag_file[0], p_node=[get_node[cat+comb],train_node[0]]) + + finished_rank_nodes=[] + + for key in rank_node: + finished_rank_nodes.extend(rank_node[key].values()) + + update_node[cat] = mvsc_update_sql_node(update_job, dag, files='*'+base_name+'*.dat',infofiles='*'+base_name+'*.info',databases='*'+base_name+'*.sqlite',p_node=finished_rank_nodes+zl_rank_node.values()) + + +############################################### +# ALL FINNISH and loving it +############################################### dag.write_sub_files() dag.write_dag() dag.write_script() -print "\nYour database output should be...\n" +print "\n\nYour database output should be...\n" for cat in cats: - print cat + ":\n", " ".join(db[cat]) + "\n" - + print "\t" + cat + ":\n", " ".join(db[cat]) + "\n" +print "\n\n\tnow run condor_submit_dag hm_post.dag\n\n\tGOOD LUCK!" diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/hm_post.ini b/lalapps/src/inspiral/s5_highmass_upper_limit/hm_post.ini index 98b3b351bbf8919ebb3d83aa6af301d220e317ed..f17525d0665ec1b6b4b0d6082e43a050af901383 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/hm_post.ini +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/hm_post.ini @@ -8,17 +8,31 @@ ligolw_thinca_to_coinc=/archive/home/channa/opt/bin/ligolw_thinca_to_coinc hm_upperlimit=./hm_upperlimit.py bash=/bin/bash far_plot=/archive/home/channa/opt/bin/lalapps_cbc_plotsummary +ul_plot=./hm_upperlimit_plot.py +summary_page=./make_summary_page.py +;Change if ATLAS is giving trouble +sqlite3_universe=vanilla +;Change on ATLAS to /scr and CIT prefers /usr1/username (e.g. /usr1/channa) +;Currently disabled +;tmp_space = /tmp [input] ;Necessary input files from ihope injcache=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/highmass_ihope_871147814-875232014.cache fulldatacache=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/highmass_ihope_871147814-875232014.cache -h1vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/H1-COMBINED_CAT_3_VETO_SEGS-871147814-4084200.txt -h2vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/H2-COMBINED_CAT_3_VETO_SEGS-871147814-4084200.txt -l1vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/L1-COMBINED_CAT_3_VETO_SEGS-871147814-4084200.txt +h1-cat_3-vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/H1-COMBINED_CAT_3_VETO_SEGS-871147814-4084200.txt +h2-cat_3-vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/H2-COMBINED_CAT_3_VETO_SEGS-871147814-4084200.txt +l1-cat_3-vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/L1-COMBINED_CAT_3_VETO_SEGS-871147814-4084200.txt +v1-cat_3-vetosegments= +h1-cat_2-vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/H1-CATEGORY_2_VETO_SEGS-871147814-4084200.txt +h2-cat_2-vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/H2-CATEGORY_2_VETO_SEGS-871147814-4084200.txt +l1-cat_2-vetosegments=/archive/home/channa/analysis/s5_highmass_20090517/871147814-875232014/871147814-875232014/segments/L1-CATEGORY_2_VETO_SEGS-871147814-4084200.txt +v1-cat_2-vetosegments= simplify=./simplify.sql remove_h1h2=./remove_h1h2.sql cluster=./cluster.sql +eff_snr_fac=50.0 [output] logpath=/usr1/channa/logs +web_page=https://ldas-jobs.ligo.caltech.edu/~channa/highmass_months_23-24_summary_page diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/hm_upperlimit.py b/lalapps/src/inspiral/s5_highmass_upper_limit/hm_upperlimit.py index 97099e455d323de24336e493f322cd9cf7d035b9..76db4cf9e87fe4ebfcb99d25f401c0c02fbf8889 100755 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/hm_upperlimit.py +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/hm_upperlimit.py @@ -18,105 +18,240 @@ from glue.ligolw import ligolw from glue.ligolw import lsctables from glue.ligolw import dbtables from glue.ligolw import utils +from glue.ligolw import table +from glue import segmentsUtils + from pylal import db_thinca_rings from pylal import llwapp from pylal import rate from pylal import SimInspiralUtils -from pylal.xlal.date import LIGOTimeGPS +from pylal.xlal.datatypes.ligotimegps import LIGOTimeGPS lsctables.LIGOTimeGPS = LIGOTimeGPS - -def get_far_threshold_and_segments(zerofname, live_time_program, verbose = False): - """ - return the false alarm rate of the most rare zero-lag coinc, and a - dictionary of the thinca segments indexed by instrument. - """ - # open database - working_filename = dbtables.get_connection_filename(zerofname, verbose = verbose) - connection = sqlite3.connect(working_filename) - dbtables.DBTable_set_connection(connection) - - # extract false alarm rate threshold - query = 'SELECT MIN(coinc_inspiral.combined_far) FROM coinc_inspiral JOIN coinc_event ON (coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id) WHERE NOT EXISTS(SELECT * FROM time_slide WHERE time_slide.time_slide_id == coinc_event.time_slide_id AND time_slide.offset != 0);' - far, = connection.cursor().execute(query).fetchone() - - # extract segments. - seglists = db_thinca_rings.get_thinca_zero_lag_segments(connection, program_name = live_time_program) - - # done - connection.close() - dbtables.discard_connection_filename(zerofname, working_filename, verbose = verbose) - dbtables.DBTable_set_connection(None) - return far, seglists - -def get_volume_derivative(injfnames, twoDMassBins, dBin, FAR, zero_lag_segments, gw): - livetime = float(abs(zero_lag_segments)) - FARh = FAR*100000 - FARl = FAR*0.001 - nbins = 5 - FARS = rate.LogarithmicBins(FARl, FARh, nbins) - vA = [] - vA2 = [] - for far in FARS.centres(): - m, f = get_injections(injfnames, far, zero_lag_segments) - print >>sys.stderr, "computing volume at FAR " + str(far) - vAt, vA2t = twoD_SearchVolume(f, m, twoDMassBins, dBin, gw, livetime, 1) - # we need to compute derivitive of log according to ul paper - vAt.array = scipy.log10(vAt.array + 0.001) - vA.append(vAt) - # the derivitive is calcuated with respect to FAR * t - FARS = rate.LogarithmicBins(FARl * livetime, FARh * livetime, nbins) - return derivitave_fit(FARS, FAR * livetime, vA, twoDMassBins) +class upper_limit(object): + + def __init__(self, flist, opts): + self.far = {} + self.segments = segments.segmentlistdict() + self.non_inj_fnames = [] + self.inj_fnames = [] + #self.der_fit = None + self.twoDMassBins = None + #self.dBin = {} + self.gw = None + self.found = {} + self.missed = {} + self.wnfunc = None + self.opts = opts + if opts.bootstrap_iterations: self.bootnum = int(opts.bootstrap_iterations) + else: self.bootnum = 100 + self.veto_segments = segments.segmentlistdict() + self.zero_lag_segments = {} + self.instruments = [] + self.livetime = {} + self.minmass = None + self.maxmass = None + self.mintotal = None + self.maxtotal = None + + for f in flist: + if opts.verbose: print >> sys.stderr, "Gathering stats from: %s...." % (f,) + working_filename = dbtables.get_connection_filename(f, verbose = opts.verbose) + connection = sqlite3.connect(working_filename) + dbtables.DBTable_set_connection(connection) + xmldoc = dbtables.get_xml(connection) + + # look for a sim table + try: + sim_inspiral_table = table.get_table(xmldoc, dbtables.lsctables.SimInspiralTable.tableName) + self.inj_fnames.append(f) + sim = True + except ValueError: + self.non_inj_fnames.append(f) + sim = False + + if not sim: + if opts.veto_segments_name is not None: self.veto_segments = db_thinca_rings.get_veto_segments(connection, opts.veto_segments_name) + self.get_instruments(connection) + self.segments += db_thinca_rings.get_thinca_zero_lag_segments(connection, program_name = opts.live_time_program) + self.get_far_thresholds(connection) + else: + self.get_mass_ranges(connection) + + + #connection.close() + dbtables.discard_connection_filename(f, working_filename, verbose = opts.verbose) + dbtables.DBTable_set_connection(None) + + # FIXME Do these have to be done by instruments? + self.segments -= self.veto_segments + + # compute far, segments and livetime by instruments + for i in self.instruments: + self.far[i] = min(self.far[i]) + # FIXME this bombs if any of the FARS are zero. maybe it should continue + # and just remove that instrument combo from the calculation + if self.far[i] == 0: + print >> sys.stderr, "Encountered 0 FAR in %s, ABORTING" % (i,) + sys.exit(1) + self.zero_lag_segments[i] = self.segments.intersection(i) - self.segments.union(set(self.segments.keys()) - i) + # Livetime must have playground removed + self.livetime[i] = float(abs(self.zero_lag_segments[i] - segmentsUtils.S2playground(self.segments.extent_all()))) + if opts.verbose: print >> sys.stderr, "%s FAR %e, livetime %f" % (",".join(sorted(list(i))), self.far[i], self.livetime[i]) + + # get a 2D mass binning + self.twoDMassBins = self.get_2d_mass_bins(self.minmass, self.maxmass, opts.mass_bins) + + def get_distance_bins(self, instruments, found=None, missed=None): + if not found and not missed: found, missed = self.get_injections(instruments) + if not found: + print >>sys.stderr,"Found no injections cannot compute distance bins ABORTING" + sys.exit(1) + #Give the bins some padding based on the errors + maxdist = max([s.distance for s in found]) + mindist = min([s.distance for s in found]) + if (maxdist < 0) or (mindist < 0) or (mindist > maxdist): + print >>sys.stderr, "minimum and maximum distances are screwy, maybe the distance errors given in the options don't make sense? ABORTING" + sys.exit(1) + self.dBin[instruments] = rate.LogarithmicBins(mindist,maxdist,self.opts.dist_bins) + + + def set_instruments_to_calculate(self): + if not opts.instruments: return self.instruments + if opts.instruments in self.instruments: + return frozenset(lsctables.instrument_set_from_ifos(i[0])) + else: + print >> sys.stderr, "Instruments %s do not exist in DB, nothing will be calculated" % (str(frozenset(lsctables.instrument_set_from_ifos(i[0]))),) + return [] + + def get_mass_ranges(self, connection): + query = 'SELECT MIN(mass1), MIN(mass2), MAX(mass1), MAX(mass2), MIN(mass1+mass2), MAX(mass1+mass2) FROM sim_inspiral;' + for v in connection.cursor().execute(query): + if self.minmass: self.minmass = min([v[0], v[1], self.minmass]) + else: self.minmass = min(v[0], v[1]) + if self.maxmass: self.maxmass = max([v[2], v[3], self.maxmass]) + else: self.maxmass = max(v[2], v[3]) + if self.mintotal: self.mintotal = min([v[4], self.mintotal]) + else: self.mintotal = v[4] + if self.maxtotal: self.maxtotal = max([v[5], self.maxtotal]) + else: self.maxtotal = v[5] + + def get_instruments(self, connection): + for i in connection.cursor().execute('SELECT DISTINCT(instruments) FROM coinc_event'): + self.instruments.append(frozenset(lsctables.instrument_set_from_ifos(i[0]))) + return self.instruments + + def get_far_thresholds(self,connection): + """ + return the false alarm rate of the most rare zero-lag coinc, and a + dictionary of the thinca segments indexed by instrument. + """ + live_time_program = opts.live_time_program + verbose = opts.verbose + if self.opts.verbose: print >>sys.stderr, "getting FAR thresholds..." + # extract false alarm rate threshold + query = 'CREATE TEMPORARY TABLE distinct_instruments AS SELECT DISTINCT(instruments) as instruments FROM coinc_event;' + connection.cursor().execute(query) + + def create_is_playground_func( connection, playground_segs = segmentsUtils.S2playground(self.segments.extent_all()) ): + """ + Construct the is_playground() SQL function. + """ + connection.create_function("is_playground", 2, lambda seconds, nanoseconds: lsctables.LIGOTimeGPS(seconds, nanoseconds) in playground_segs) + + create_is_playground_func(connection) + + query = 'SELECT distinct_instruments.instruments, (SELECT MIN(coinc_inspiral.combined_far) AS combined_far FROM coinc_inspiral JOIN coinc_event ON (coinc_inspiral.coinc_event_id == coinc_event.coinc_event_id) WHERE coinc_event.instruments == distinct_instruments.instruments AND NOT EXISTS(SELECT * FROM time_slide WHERE time_slide.time_slide_id == coinc_event.time_slide_id AND time_slide.offset != 0) AND NOT is_playground(coinc_inspiral.end_time, coinc_inspiral.end_time_ns) ) FROM distinct_instruments;' + + for inst, far in connection.cursor().execute(query): + inst = frozenset(lsctables.instrument_set_from_ifos(inst)) + self.far.setdefault(inst,[]) + self.far[inst].append(far) + query = 'DROP TABLE distinct_instruments' + connection.cursor().execute(query) + + def get_volume_derivative(self,instruments): + injfnames = self.inj_fnames + FAR = self.far[instruments] + zero_lag_segments = self.zero_lag_segments[instruments] + gw = self.gw + twoDMassBins = self.twoDMassBins + + #determine binning up front for infinite FAR + found, missed = self.get_injections(instruments, FAR=float("inf")) + dbin = rate.LogarithmicBins(min([l.distance for l in found]),max([l.distance for l in found]), int(self.opts.dist_bins)) + + livetime = float(abs(zero_lag_segments)) + FARh = FAR*100000 + FARl = FAR*0.001 + nbins = 5 + FARS = rate.LogarithmicBins(FARl, FARh, nbins) + vA = [] + vA2 = [] + for far in FARS.centres(): + print >>sys.stderr, "computing volume at FAR " + str(far) + vAt, vA2t = self.twoD_SearchVolume(instruments, dbin=dbin, FAR = far, bootnum=1) + # we need to compute derivitive of log according to ul paper + vAt.array = scipy.log10(vAt.array + 0.001) + vA.append(vAt) + # the derivitive is calcuated with respect to FAR * t + FARTS = rate.LogarithmicBins(FARl * livetime, FARh * livetime, nbins) + return self._derivitave_fit(FARTS, FAR * livetime, vA, twoDMassBins) -def derivitave_fit(farts, FARt, vAs, twodbin): - ''' - Relies on scipy spline fits for each mass bin - to find the derivitave of the volume at a given - FAR. See how this works for a simple case where - I am clearly giving it a parabola. To high precision it calculates - the proper derivitave. - A = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] - B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - C = interpolate.splrep(B,A,s=0, k=4) - interpolate.splev(5,C,der=1) - 10.000 - ''' - dA = rate.BinnedArray(twodbin) - for m1 in range(dA.array.shape[0]): - for m2 in range(dA.array.shape[1]): - da = [] - for f in farts.centres(): - da.append(vAs[farts[f]].array[m1][m2]) - fit = interpolate.splrep(farts.centres(),da,k=4) - val = 0.0 - interpolate.splev(FARt,fit,der=1) - # FIXME this prevents negative derivitives arising from bad fits - if val < 0: val = 0 - dA.array[m1][m2] = val # minus the derivitave - return dA - -def get_injections(injfnames, FAR, zero_lag_segments, verbose = False): - """ - """ - def injection_was_made(geocent_end_time, geocent_end_time_ns, zero_lag_segments = zero_lag_segments): + def _derivitave_fit(self, farts, FARt, vAs, twodbin): + ''' + Relies on scipy spline fits for each mass bin + to find the derivitave of the volume at a given + FAR. See how this works for a simple case where + I am clearly giving it a parabola. To high precision it calculates + the proper derivitave. + A = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] + B = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + C = interpolate.splrep(B,A,s=0, k=4) + interpolate.splev(5,C,der=1) + 10.000 + ''' + dA = rate.BinnedArray(twodbin) + for m1 in range(dA.array.shape[0]): + for m2 in range(dA.array.shape[1]): + da = [] + for f in farts.centres(): + da.append(vAs[farts[f]].array[m1][m2]) + fit = interpolate.splrep(farts.centres(),da,k=4) + val = interpolate.splev(FARt,fit,der=1) + #print val + # FIXME this prevents negative derivitives arising from bad fits + if val < 0: val = 0 + dA.array[m1][m2] = val # minus the derivitave + return dA + + def get_injections(self, instruments, FAR=None): + injfnames = self.inj_fnames + if not FAR: FAR = self.far[instruments] + zero_lag_segments = self.zero_lag_segments[instruments] + verbose = self.opts.verbose """ - return True if injection was made in the given segmentlist """ - return lsctables.LIGOTimeGPS(geocent_end_time, geocent_end_time_ns) in zero_lag_segments - - found = [] - missed = [] - print >>sys.stderr, "" - for cnt, f in enumerate(injfnames): - print >>sys.stderr, "getting injections below FAR: " + str(FAR) + ":\t%.1f%%\r" % (100.0 * cnt / len(injfnames),), - working_filename = dbtables.get_connection_filename(f, tmp_path = None, verbose = verbose) - connection = sqlite3.connect(working_filename) - connection.create_function("injection_was_made", 2, injection_was_made) - - make_sim_inspiral = lsctables.table.get_table(dbtables.get_xml(connection), lsctables.SimInspiralTable.tableName)._row_from_cols - - for values in connection.cursor().execute(""" + def injection_was_made(geocent_end_time, geocent_end_time_ns, zero_lag_segments = zero_lag_segments): + """ + return True if injection was made in the given segmentlist + """ + return lsctables.LIGOTimeGPS(geocent_end_time, geocent_end_time_ns) in zero_lag_segments + + found = [] + missed = [] + print >>sys.stderr, "" + for cnt, f in enumerate(injfnames): + print >>sys.stderr, "getting injections below FAR: " + str(FAR) + ":\t%.1f%%\r" % (100.0 * cnt / len(injfnames),), + working_filename = dbtables.get_connection_filename(f, tmp_path = None, verbose = verbose) + connection = sqlite3.connect(working_filename) + connection.create_function("injection_was_made", 2, injection_was_made) + + make_sim_inspiral = lsctables.table.get_table(dbtables.get_xml(connection), lsctables.SimInspiralTable.tableName)._row_from_cols + + for values in connection.cursor().execute(""" SELECT sim_inspiral.*, -- true if injection matched a coinc below the false alarm rate threshold @@ -142,144 +277,209 @@ FROM WHERE -- only interested in injections that were injected injection_was_made(sim_inspiral.geocent_end_time, sim_inspiral.geocent_end_time_ns) - """, (FAR,)): - sim = make_sim_inspiral(values) - if values[-1]: - found.append(sim) - else: - missed.append(sim) - - # done - connection.close() - dbtables.discard_connection_filename(f, working_filename, verbose = verbose) - dbtables.DBTable_set_connection(None) - - print >>sys.stderr, "\nFound = %d Missed = %d" % (len(found), len(missed)) - return found, missed - - -def trim_mass_space(eff, twodbin, minthresh=0.0, minM=25.0, maxM=100.0): - """ - restricts array to only have data within the mass space and sets everything - outside the mass space to some canonical value, minthresh - """ - x = eff.array.shape[0] - y = eff.array.shape[1] - c1 = twodbin.centres()[0] - c2 = twodbin.centres()[1] - numbins = 0 - for i in range(x): - for j in range(y): - if c1[i] > c2[j] or (c1[i] + c2[j]) > maxM or (c1[i]+c2[j]) < minM: eff.array[i][j] = minthresh - else: numbins+=1 - print "found " + str(numbins) + " bins within total mass" - -def fix_masses(sims): - """ - Function to duplicate the mass pairs to remove edge effects - on the equal mass line, takes a list of sim rows - """ - sims2 = [] - for l in sims: - l2 = copy.deepcopy(l) - l2.mass1 = l.mass2 - l2.mass2 = l.mass1 - sims2.append(l2) - sims.extend(sims2) - -def get_2d_mass_bins(low, high, bins): - """ - Given the component mass range low, high of the search it will - return 2D bins with size bins in each direction - """ - mass1Bin = rate.LinearBins(low,high,bins) - mass2Bin = rate.LinearBins(low,high,bins) - twoDMB=rate.NDBins( (mass1Bin,mass2Bin) ) - return twoDMB + """, (FAR,)): + sim = make_sim_inspiral(values) + if values[-1]: + found.append(sim) + else: + missed.append(sim) + + # done + connection.close() + dbtables.discard_connection_filename(f, working_filename, verbose = verbose) + dbtables.DBTable_set_connection(None) + + print >>sys.stderr, "\nFound = %d Missed = %d" % (len(found), len(missed)) + return found, missed + + + def trim_mass_space(self, eff, instruments, minthresh=0.0, minM=25.0, maxM=100.0): + """ + restricts array to only have data within the mass space and sets everything + outside the mass space to some canonical value, minthresh + """ + twodbin = self.twoDMassBins + x = eff.array.shape[0] + y = eff.array.shape[1] + c1 = twodbin.centres()[0] + c2 = twodbin.centres()[1] + numbins = 0 + for i in range(x): + for j in range(y): + if c1[i] > c2[j] or (c1[i] + c2[j]) > maxM or (c1[i]+c2[j]) < minM: eff.array[i][j] = minthresh + else: numbins+=1 + print "found " + str(numbins) + " bins within total mass" + + def fix_masses(self, sims): + """ + Function to duplicate the mass pairs to remove edge effects + on the equal mass line, takes a list of sim rows + """ + sims2 = [] + for l in sims: + l2 = copy.deepcopy(l) + l2.mass1 = l.mass2 + l2.mass2 = l.mass1 + sims2.append(l2) + sims.extend(sims2) + + def get_2d_mass_bins(self, low, high, bins): + """ + Given the component mass range low, high of the search it will + return 2D bins with size bins in each direction + """ + mass1Bin = rate.LinearBins(low,high,bins) + mass2Bin = rate.LinearBins(low,high,bins) + twoDMB=rate.NDBins( (mass1Bin,mass2Bin) ) + return twoDMB -def scramble_pop(m, f): - """ - A function to draw a new injection sample in the "boot strap" method - http://en.wikipedia.org/wiki/Bootstrapping_(statistics) - and included refereneces. - This was used in the stack-a-flare search to get MC errors etc. - """ - inj = m+f - ix = scipy.random.randint(0,len(inj), (len(inj),)) - return [inj[i] for i in ix if i < len(m) ], [inj[i] for i in ix if i >=len(m) ] - -def scramble_dist(dist,relerr): - """ - function to handle random calibration error. Individually srambles the distances - of injection by an error. - """ - return dist * float( scipy.exp( relerr * scipy.random.standard_normal(1) ) ) - #return dist * (1-relerr) - -def twoD_SearchVolume(found, missed, twodbin, dbin, wnfunc, livetime, bootnum=1, derr=0.15): - """ - Compute the search volume in the mass/mass plane, bootstrap - and measure the first and second moment (assumes the underlying - distribution can be characterized by those two parameters) - This is gonna be brutally slow - """ - if wnfunc: wnfunc /= wnfunc[(wnfunc.shape[0]-1) / 2, (wnfunc.shape[1]-1) / 2] - x = twodbin.shape[0] - y = twodbin.shape[1] - z = dbin.n - rArrays = [] - volArray=rate.BinnedArray(twodbin) - volArray2=rate.BinnedArray(twodbin) - #set up ratio arrays for each distance bin - for k in range(z): - rArrays.append(rate.BinnedRatios(twodbin)) - - # Bootstrap to account for errors - for n in range(bootnum): - #initialize by setting these to zero + def _scramble_pop(self, m, f): + """ + A function to draw a new injection sample in the "boot strap" method + http://en.wikipedia.org/wiki/Bootstrapping_(statistics) + and included refereneces. + This was used in the stack-a-flare search to get MC errors etc. + """ + inj = m+f + ix = scipy.random.randint(0,len(inj), (len(inj),)) + #return new missed, found + missed = [inj[i] for i in ix if i < len(m) ] + found = [inj[i] for i in ix if i >=len(m) ] + return missed, found + + def _scramble_dist(self, inj, relerr, syserr): + """ + function to handle random calibration error. Individually srambles the distances + of injection by an error. + """ + dist_array = numpy.zeros(len(inj)) + for i,sim in enumerate(inj): + dist_array[i] = sim.distance * (1.0-syserr) * float(scipy.exp( relerr * scipy.random.standard_normal(1))) + return dist_array + + def live_time_array(self, instruments): + """ + return an array of live times, note every bin will be the same :) it is just a + convenience. + """ + live_time = rate.BinnedArray(self.twoDMassBins) + live_time.array += 1.0 + live_time.array *= self.livetime[instruments] + return live_time + + + def twoD_SearchVolume(self, instruments, dbin=None, FAR=None, bootnum=None, derr=0.197, dsys=0.074): + """ + Compute the search volume in the mass/mass plane, bootstrap + and measure the first and second moment (assumes the underlying + distribution can be characterized by those two parameters) + This is gonna be brutally slow + derr = (0.134**2+.103**2+.102**2)**.5 = 0.197 which is the 3 detector + calibration uncertainty in quadrature. This is conservative since some injections + will be H1L1 and have a lower error of .17 + the dsys is the DC offset which is the max offset of .074. + """ + + if not FAR: FAR = self.far[instruments] + found, missed = self.get_injections(instruments, FAR) + twodbin = self.twoDMassBins + wnfunc = self.gw + livetime = self.livetime[instruments] + if not bootnum: bootnum = self.bootnum + + if wnfunc: wnfunc /= wnfunc[(wnfunc.shape[0]-1) / 2, (wnfunc.shape[1]-1) / 2] + + x = twodbin.shape[0] + y = twodbin.shape[1] + z = int(self.opts.dist_bins) + + rArrays = [] + volArray=rate.BinnedArray(twodbin) + volArray2=rate.BinnedArray(twodbin) + #set up ratio arrays for each distance bin for k in range(z): - rArrays[k].numerator.array = numpy.zeros(rArrays[k].numerator.bins.shape) - rArrays[k].denominator.array = numpy.zeros(rArrays[k].numerator.bins.shape) - #Scramble the inj population - if bootnum > 1: sm, sf = scramble_pop(missed, found) - else: sm, sf = missed, found - for l in sf:#found: - tbin = rArrays[dbin[scramble_dist(l.distance,derr)]] - tbin.incnumerator( (l.mass1, l.mass2) ) - for l in sm:#missed: - tbin = rArrays[dbin[scramble_dist(l.distance,derr)]] - tbin.incdenominator( (l.mass1, l.mass2) ) + rArrays.append(rate.BinnedRatios(twodbin)) + + # Bootstrap to account for errors + for n in range(bootnum): + #initialize by setting these to zero + for k in range(z): + rArrays[k].numerator.array = numpy.zeros(rArrays[k].numerator.bins.shape) + rArrays[k].denominator.array = numpy.zeros(rArrays[k].numerator.bins.shape) + #Scramble the inj population and distances + if bootnum > 1: + sm, sf = self._scramble_pop(missed, found) + # I make a separate array of distances to speed up this calculation + f_dist = self._scramble_dist(sf, derr, dsys) + else: + sm, sf = missed, found + f_dist = numpy.array([l.distance for l in found]) + + # compute the distance bins + if not dbin: + dbin = rate.LogarithmicBins(min(f_dist),max(f_dist), z) + #else: print dbin.centres() + + + # get rid of all missed injections outside the distance bins + # to prevent binning errors + sm, m_dist = self.cut_distance(sm, dbin) + sf, f_dist = self.cut_distance(sf, dbin) + + + for i, l in enumerate(sf):#found: + tbin = rArrays[dbin[f_dist[i]]] + tbin.incnumerator( (l.mass1, l.mass2) ) + for i, l in enumerate(sm):#missed: + tbin = rArrays[dbin[m_dist[i]]] + tbin.incdenominator( (l.mass1, l.mass2) ) - tmpArray2=rate.BinnedArray(twodbin) #start with a zero array to compute the mean square - for k in range(z): - tbins = rArrays[k] - tbins.denominator.array += tbins.numerator.array - if wnfunc: rate.filter_array(tbins.denominator.array,wnfunc) - if wnfunc: rate.filter_array(tbins.numerator.array,wnfunc) - tbins.regularize() - # logarithmic(d) - integrand = 4.0 * pi * tbins.ratio() * dbin.centres()[k]**3 * dbin.delta - volArray.array += integrand - tmpArray2.array += integrand #4.0 * pi * tbins.ratio() * dbin.centres()[k]**3 * dbin.delta - print >>sys.stderr, "bootstrapping:\t%.1f%% and Calculating smoothed volume:\t%.1f%%\r" % ((100.0 * n / bootnum), (100.0 * k / z)), - tmpArray2.array *= tmpArray2.array - volArray2.array += tmpArray2.array + tmpArray2=rate.BinnedArray(twodbin) #start with a zero array to compute the mean square + for k in range(z): + tbins = rArrays[k] + tbins.denominator.array += tbins.numerator.array + if wnfunc: rate.filter_array(tbins.denominator.array,wnfunc) + if wnfunc: rate.filter_array(tbins.numerator.array,wnfunc) + tbins.regularize() + # logarithmic(d) + integrand = 4.0 * pi * tbins.ratio() * dbin.centres()[k]**3 * dbin.delta + volArray.array += integrand + tmpArray2.array += integrand #4.0 * pi * tbins.ratio() * dbin.centres()[k]**3 * dbin.delta + print >>sys.stderr, "bootstrapping:\t%.1f%% and Calculating smoothed volume:\t%.1f%%\r" % ((100.0 * n / bootnum), (100.0 * k / z)), + tmpArray2.array *= tmpArray2.array + volArray2.array += tmpArray2.array - print >>sys.stderr, "" - #Mean and variance - volArray.array /= bootnum - volArray2.array /= bootnum - volArray2.array -= volArray.array**2 # Variance - volArray.array *= livetime - volArray2.array *= livetime*livetime # this gets two powers of live time - return volArray, volArray2 + print >>sys.stderr, "" + #Mean and variance + volArray.array /= bootnum + volArray2.array /= bootnum + volArray2.array -= volArray.array**2 # Variance + volArray.array *= livetime + volArray2.array *= livetime*livetime # this gets two powers of live time + return volArray, volArray2 -def cut_distance(sims, mnd, mxd): - """ - Exclude sims outside some distance range to avoid errors when binning - """ - return [sim for sim in sims if mnd <= sim.distance <= mxd] + def cut_distance(self, sims, dbin): + """ + Exclude sims outside some distance range to avoid errors when binning + """ + mnd = min(dbin.lower()) + mxd = max(dbin.upper()) + #print len(sims), len(m_dist) + #m_dist_low = m_dist[m_dist >= mnd] + #m_dist_low = m_dist_low[m_dist_low <= mxd] + out = [sim for sim in sims if mnd <= sim.distance <= mxd] + return out, numpy.array([l.distance for l in out]) + +#### STUFF FOR PLAYGROUND #### + +#playground_segs = segmentsUtils.S2playground(self.seglists.extent_all()) + +#def create_is_playground_func(connection, playground_segs): +# """ +# Construct the is_playground() SQL function. +# """ +# connection.create_function("is_playground", 2, lambda seconds, nanoseconds: lsctables.LIGOTimeGPS(seconds, nanoseconds) in playground_segs) ######################## ACTUAL PROGRAM ####################################### @@ -289,98 +489,72 @@ def cut_distance(sims, mnd, mxd): def parse_command_line(): parser = OptionParser(version = "%prog CVS $Id$", usage = "%prog [options] [file ...]", description = "%prog computes mass/mass upperlimit") - parser.add_option("-i", "--instruments", metavar = "name[,name,...]", help = "Set the list of instruments. Required. Example \"H1,H2,L1\"") + parser.add_option("--instruments", metavar = "name[,name,...]", help = "Set the list of instruments. Required. Example \"H1,H2,L1\"") parser.add_option("--live-time-program", default = "thinca", metavar = "name", help = "Set the name of the program whose rings will be extracted from the search_summary table. Default = \"thinca\".") - parser.add_option("-t", "--output-name-tag", default = "", metavar = "name", help = "Set the file output name tag, real name is 2Dsearchvolume-<tag>-<ifos>.xml") - parser.add_option("-f", "--full-data-file", default = "FULL_DATACAT_3.sqlite", metavar = "pattern", help = "File in which to find the full data, example FULL_DATACAT_3.sqlite") - parser.add_option("-s", "--inj-data-glob", default = "*INJCAT_3.sqlite", metavar = "pattern", help = "Glob for files to find the inj data, example *INJCAT_3.sqlite") - parser.add_option("-b", "--bootstrap-iterations", default = 1, metavar = "integer", type = "int", help = "Number of iterations to compute mean and variance of volume MUST BE GREATER THAN 1 TO GET USABLE NUMBERS, a good number is 10000") - parser.add_option("--veto-segments-name", help = "Set the name of the veto segments to use from the XML document.") + parser.add_option("--output-name-tag", default = "", metavar = "name", help = "Set the file output name tag, real name is 2Dsearchvolume-<tag>-<ifos>.xml") + parser.add_option("--bootstrap-iterations", default = 1000, metavar = "integer", type = "int", help = "Number of iterations to compute mean and variance of volume MUST BE GREATER THAN 1 TO GET USABLE NUMBERS, a good number is 10000") + parser.add_option("--dist-bins", default = 50, metavar = "integer", type = "int", help = "Number of mass bins") + parser.add_option("--d-err", default = 0.197, metavar = "float", type = "int", help = "random calibration error on distance") + parser.add_option("--d-sys-err", default = 0.074, metavar = "float", type = "int", help = "systematic calibration error on distance (should use worst)") + parser.add_option("--mass-bins", default = 11, metavar = "integer", type = "int", help = "Number of mass bins along 1 dimension (Note the total number of mass bins will generally be less than --mass-bins * --mass-bins once the actual parameter space is carved out)") + parser.add_option("--veto-segments-name", default = "vetoes", help = "Set the name of the veto segments to use from the XML document.") parser.add_option("--verbose", action = "store_true", help = "Be verbose.") opts, filenames = parser.parse_args() - if opts.instruments is None: - raise ValueError, "missing required argument --instruments" - opts.instruments = lsctables.instrument_set_from_ifos(opts.instruments) - - opts.injfnames = glob.glob(opts.inj_data_glob) - + if opts.instruments: opts.instruments = lsctables.instrument_set_from_ifos(opts.instruments) + if not filenames: + print >>sys.stderr, "must specify at least one database file" + sys.exit(1) return opts, filenames # FIXME These values should probably be command line arguments or derived from the database secs_in_year = 31556926.0 -max_dist = 2000 -min_mass = 1 -max_mass = 99 -min_mtotal = 25 -max_mtotal = 100 -mass_bins = 11 -dist_bins = 50 - opts, filenames = parse_command_line() -if opts.veto_segments_name is not None: - working_filename = dbtables.get_connection_filename(opts.full_data_file, verbose = opts.verbose) - connection = sqlite3.connect(working_filename) - dbtables.DBTable_set_connection(connection) - veto_segments = db_thinca_rings.get_veto_segments(connection, opts.veto_segments_name) - connection.close() - dbtables.discard_connection_filename(opts.full_data_file, working_filename, verbose = opts.verbose) - dbtables.DBTable_set_connection(None) -else: - veto_segments = segments.segmentlistdict() - - -# FIXME: don't you need to request the min(FAR) for the given "on" -# instruments? -FAR, seglists = get_far_threshold_and_segments(opts.full_data_file, opts.live_time_program, verbose = opts.verbose) - - -# times when only exactly the required instruments are on -seglists -= veto_segments -zero_lag_segments = seglists.intersection(opts.instruments) - seglists.union(set(seglists.keys()) - opts.instruments) - -print FAR, float(abs(zero_lag_segments)) - - -Found, Missed = get_injections(opts.injfnames, FAR, zero_lag_segments, verbose = opts.verbose) +#initialize an upper limit class +UL = upper_limit(filenames, opts) +#loop over the requested instruments +for instruments in UL.set_instruments_to_calculate(): + if opts.verbose: print >>sys.stderr, "calculating upper limit for %s" % (",".join(sorted(list(instruments))),) -# restrict the sims to a distance range -Found = cut_distance(Found, 1, max_dist) -Missed = cut_distance(Missed, 1, max_dist) + #compute volume derivitive + dvA = UL.get_volume_derivative(instruments) -# get a 2D mass binning -twoDMassBins = get_2d_mass_bins(min_mass, max_mass, mass_bins) + #compute volume first and second moments + vA, vA2 = UL.twoD_SearchVolume(instruments) -# get log distance bins -dBin = rate.LogarithmicBins(0.1,max_dist*1.25,dist_bins) + # get an array of livetimes for convenience + ltA = UL.live_time_array(instruments) -# Someday we could try a Gaussian smoothing function -#gw = rate.gaussian_window2d(2,2,8) -gw = None + # FIXME convert to years (use some lal or pylal thing in the future) + vA.array /= secs_in_year + vA2.array /= secs_in_year * secs_in_year #two powers for this squared quantity -#Get derivative of volume with respect to FAR -dvA = get_volume_derivative(opts.injfnames, twoDMassBins, dBin, FAR, zero_lag_segments, gw) + #Trim the array to have sane values outside the total mass area of interest + try: minvol = scipy.unique(vA.array)[1]/10.0 + except: minvol = 0 + UL.trim_mass_space(dvA, instruments, minthresh=0.0, minM=UL.mintotal, maxM=UL.maxtotal) + UL.trim_mass_space(vA, instruments, minthresh=minvol, minM=UL.mintotal, maxM=UL.maxtotal) + UL.trim_mass_space(vA2, instruments, minthresh=0.0, minM=UL.mintotal, maxM=UL.maxtotal) -print >>sys.stderr, "computing volume at FAR " + str(FAR) -vA, vA2 = twoD_SearchVolume(Found, Missed, twoDMassBins, dBin, gw, float(abs(zero_lag_segments)), bootnum=int(opts.bootstrap_iterations)) + #output an XML file with the result + xmldoc = ligolw.Document() + xmldoc.appendChild(ligolw.LIGO_LW()) + xmldoc.childNodes[-1].appendChild(rate.binned_array_to_xml(vA, "2DsearchvolumeFirstMoment")) + xmldoc.childNodes[-1].appendChild(rate.binned_array_to_xml(vA2, "2DsearchvolumeSecondMoment")) + xmldoc.childNodes[-1].appendChild(rate.binned_array_to_xml(dvA, "2DsearchvolumeDerivative")) -# FIXME convert to years (use some lal or pylal thing in the future) -vA.array /= secs_in_year -vA2.array /= secs_in_year * secs_in_year #two powers for this squared quantity + # DONE with vA, so it is okay to mess it up... + # Compute range + vA.array = (vA.array * secs_in_year / UL.livetime[instruments] / (4.0/3.0 * pi)) **(1.0/3.0) + UL.trim_mass_space(vA, instruments, minthresh=0.0, minM=UL.mintotal, maxM=UL.maxtotal) + xmldoc.childNodes[-1].appendChild(rate.binned_array_to_xml(vA, "2DsearchvolumeDistance")) -#Trim the array to have sane values outside the total mass area of interest -trim_mass_space(dvA, twoDMassBins, minthresh=0.0, minM=min_mtotal, maxM=max_mtotal) -trim_mass_space(vA, twoDMassBins, scipy.unique(vA.array)[1]/10.0, minM=min_mtotal, maxM=max_mtotal) -trim_mass_space(vA2, twoDMassBins, minthresh=0.0, minM=min_mtotal, maxM=max_mtotal) + # make a live time + UL.trim_mass_space(ltA, instruments, minthresh=0.0, minM=UL.mintotal, maxM=UL.maxtotal) + xmldoc.childNodes[-1].appendChild(rate.binned_array_to_xml(ltA, "2DsearchvolumeLiveTime")) -#output an XML file with the result -xmldoc = ligolw.Document() -xmldoc.appendChild(ligolw.LIGO_LW()) -xmldoc.childNodes[-1].appendChild(rate.binned_array_to_xml(vA, "2DsearchvolumeFirstMoment")) -xmldoc.childNodes[-1].appendChild(rate.binned_array_to_xml(vA2, "2DsearchvolumeSecondMoment")) -xmldoc.childNodes[-1].appendChild(rate.binned_array_to_xml(dvA, "2DsearchvolumeDerivative")) -utils.write_filename(xmldoc, "2Dsearchvolume-%s-%s.xml" % (opts.output_name_tag, "".join(sorted(opts.instruments)))) + utils.write_filename(xmldoc, "2Dsearchvolume-%s-%s.xml" % (opts.output_name_tag, "".join(sorted(list(instruments))))) diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/hm_upperlimit_plot.py b/lalapps/src/inspiral/s5_highmass_upper_limit/hm_upperlimit_plot.py old mode 100644 new mode 100755 index 653e8666461c12ead1e0ed59d1198019feac9ec6..7c8d9eaeea158f92149f41b3fcc949c44e28fcfd --- a/lalapps/src/inspiral/s5_highmass_upper_limit/hm_upperlimit_plot.py +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/hm_upperlimit_plot.py @@ -4,6 +4,8 @@ from pylal import rate from pylal import SimInspiralUtils import scipy import numpy +import matplotlib +matplotlib.use('Agg') import pylab from math import * import sys @@ -11,6 +13,11 @@ import glob import copy from glue.ligolw.utils import ligolw_add from glue.ligolw import ligolw, utils +# FIXME: the plots should use LaTeX to generate the labels, but some don't +# work yet +matplotlib.rcParams.update({ + "text.usetex": False +}) # FIXME, I apparently don't know how to read XML as cleverly as I thought, how do I find the table # without specifying the childnode number? @@ -54,131 +61,242 @@ def posterior(VT, sigmasq, Lambda): post = numpy.ones(len(mu), dtype="float") for vt, k, lam in zip(VT, K, Lambda): + # FIXME maybe this should be smarter? + # a total lack of injections can screw this up. If vt = 0 move on. + if vt <= 0 or k <= 0: continue post *= vt / (1.0 + lam) * ( (1.0 + mu * vt / k)**(-k-1) + (mu * vt * lam * (1.0 + 1.0/k) /(1.0 + mu * vt / k)**(k+2)) ) return mu, post def integrate_posterior(mu, post, conf): cumpost = post.cumsum()/post.sum() - val = [idx for idx in range(len(cumpost)) if cumpost[idx] >= conf][0] + #if you can do it, maybe you can't cause the volume is zero + try: val = [idx for idx in range(len(cumpost)) if cumpost[idx] >= conf][0] + except: val = 0 return mu[val] -# test case +def get_mass_ranges(bins, mbA): + mass1 = [] + mass2 = [] + for i,m1 in enumerate(bins.lower()[0]): + for j,m2 in enumerate(bins.lower()[1]): + if not mbA[i][j]: + mass1.append(m1) + mass1.append(bins.upper()[0][i]) + mass2.append(m2) + mass2.append(bins.upper()[1][j]) + return [min(mass1), max(mass1)], [min(mass2), max(mass2)] + -VT = numpy.array([10.0**8]) -sigmasq = numpy.array([4.0*10**14]) -Lambda = numpy.array([1.0]) - -mu, post = posterior(VT, sigmasq, Lambda) - -#pylab.semilogy(mu, post.cumsum()/post.sum()) -#pylab.show() -print integrate_posterior(mu, post, 0.90) - -# bins is the same for each call and ulA is an empty binnedArray that has the right shape +# bins are the same for each call and ulA is an empty binnedArray that has the right shape # that can hold the upperlimit when we get around to computing it later, so it is okay # that bins, and ulA are overwritten in each call. vA, vA2 and dvA are the important ones bins, vA, ulA = get_combined_array("2DsearchvolumeFirstMoment", 0) +#FIXME Hack to give volume that is zero a value = 0.01 +vA[vA==0] = 0.01 + bins, vA2, ulA = get_combined_array("2DsearchvolumeSecondMoment", 1) bins, dvA, ulA = get_combined_array("2DsearchvolumeDerivative", 2) +bins, vAD, ulA = get_combined_array("2DsearchvolumeDistance", 3) +bins, ltA, tmp= get_combined_array("2DsearchvolumeLiveTime", 4) + +# track livetime bins that are 0, they are outside of the search space +# this is a useful array for computing only meaningful things +mbA = numpy.zeros(ltA[0].shape) +mbA[ltA[0] == 0] = 1 + + +m1range, m2range = get_mass_ranges(bins, mbA) - #bin edges Number of bins + 1 for pcolor X = numpy.array( list(bins.lower()[0]) + [bins.upper()[0][-1]] ) Y = numpy.array( list(bins.lower()[1]) + [bins.upper()[1][-1]] ) -#compute combined posterior over m1, m2 -for m1 in range(len(bins.lower()[0])): - for m2 in range(len(bins.lower()[1])): - mu, post = posterior(vA[...,m1,m2], vA2[...,m1,m2], dvA[...,m1,m2]) - ulA.array[m1][m2] = integrate_posterior(mu, post, 0.90) - -log_vol = pylab.log10(vA[0]) -log_ul = pylab.log10(ulA.array) - - -vol_error = vA2[0]**0.5 / (vA[0] + 0.0001) - -der = dvA[0] #pylab.log10(eA.array) - -pylab.figure(1) -masses = bins[15,15] -print masses -mu,post = posterior(vA[...,masses[0],masses[1]], vA2[...,masses[0],masses[1]], dvA[...,masses[0],masses[1]]) -pylab.loglog(mu,post/post.max()) -pylab.hold(1) -masses = bins[50,50] -print masses -mu,post = posterior(vA[...,masses[0],masses[1]], vA2[...,masses[0],masses[1]], dvA[...,masses[0],masses[1]]) -pylab.loglog(mu,post/post.max()) -masses = bins[1,99] -print masses -mu,post = posterior(vA[...,masses[0],masses[1]], vA2[...,masses[0],masses[1]], dvA[...,masses[0],masses[1]]) -pylab.loglog(mu,post/post.max()) -masses = bins[1,24] -print masses -mu,post = posterior(vA[...,masses[0],masses[1]], vA2[...,masses[0],masses[1]], dvA[...,masses[0],masses[1]]) -pylab.loglog(mu,post/post.max()) -pylab.hold(0) -pylab.title("Combined Posteriors for a few mass bins",fontsize=14) -pylab.legend(["15,15", "50,50", "1,99", "1,24"]) -pylab.ylabel("Prob (unnormalized)",fontsize=14) -pylab.xlabel("Rate",fontsize=14) -pylab.ylim([0.0001, 1]) -pylab.grid() +numfiles = len(sys.argv[1:]) +f = pylab.figure(1) +############################################################################### +# loop over all the filenames and masses and compute the posteriors separately +############################################################################### +for i, f in enumerate(sys.argv[1:]): + legend_str = [] + lines = [] + #FIXME we shouldn't get ifos from filenames, we should put it in the xml :( + ifos = sys.argv[1+i].replace('.xml','').replace("2Dsearchvolume-","") + #FIXME it is stupid to pull out names this way + combined_ifos = "_".join(ifos.split("_")[:-1]) + wiki = open(ifos+'_range_summary.txt',"w") + wiki.write("||'''Masses'''||'''Range(Mpc)'''||'''Time'''||'''UL @ 90%'''||'''Fractional error'''||\n") + # loop over mass bins + + ulA.array *= 0 -pylab.figure(2) -pylab.gray() -pylab.pcolor(X,Y, log_vol) -#pylab.hold(1) -#cn = pylab.contour(bins.centres()[0], bins.centres()[1], ul) -#pylab.clabel(cn) -#pylab.hold(0) -pylab.colorbar() -pylab.ylim([0, 51]) -pylab.xlim([11, 101]) -pylab.title("Log10[< Volume * Time>] in mergers/Mpc^3/yr",fontsize=14) -pylab.xlabel("Mass 2",fontsize=14) -pylab.ylabel("Mass 1",fontsize=14) -pylab.gca().set_aspect(1) -pylab.grid() -#pylab.show() + for j, m1 in enumerate(bins.centres()[0]): + for k, m2 in enumerate(bins.centres()[1]): + masses = bins[m1,m2] + if mbA[masses[0], masses[1]]: continue + legend_str.append("%.1f, %.1f" % (m1, m2)) + mu,post = posterior(vA[i:i+1,masses[0],masses[1]], vA2[i:i+1,masses[0],masses[1]], dvA[i:i+1,masses[0],masses[1]]) + lines.append(pylab.loglog(mu,post/post.max())) + ulA.array[j][k] = integrate_posterior(mu, post, 0.90) + wiki.write("||%.2f,%.2f||%.2f|| %.2f || %.2e || %.2f ||\n" % (m1, m2, vAD[i,masses[0],masses[1]], ltA[i, masses[0], masses[1]], ulA.array[j][k], vA2[i, masses[0], masses[1]]**0.5 / (vA[i, masses[0], masses[1]])) ) -pylab.figure(3) -pylab.pcolor(X,Y, vol_error) -pylab.colorbar() -pylab.ylim([0, 51]) -pylab.xlim([11, 101]) -pylab.title("Fractional Error on Volume * Time [std/mean]",fontsize=14) -pylab.xlabel("Mass 2",fontsize=14) -pylab.ylabel("Mass 1",fontsize=14) -pylab.gca().set_aspect(1) -pylab.grid() -pylab.figure(4) -pylab.pcolor(X,Y, der ) -pylab.colorbar() -pylab.ylim([0, 51]) -pylab.xlim([11, 101]) -pylab.title("Volume derivative, Lambda",fontsize=14) -pylab.xlabel("Mass 2",fontsize=14) -pylab.ylabel("Mass 1",fontsize=14) -pylab.gca().set_aspect(1) + + fudge = 0.01 * min (ulA.array[ulA.array !=0]) + log_vol = pylab.log10(vA[i]) + #HACKS FOR LOG PLOT :( + log_ul = pylab.log10(ulA.array + fudge) + vol_error = vA2[i]**0.5 / (vA[i] + 0.0001) + der = dvA[i] + log_der = pylab.log10(dvA[i] + 0.000000001) + # set points outside mass space to 1 (log(1) = 0) + log_ul[mbA == 1] = 0 + log_der[mbA == 1] = -3 + + ## + # Make posterior plots + ## + + #f = pylab.figure(i) + pylab.title("%s \nposteriors for a few mass bins" % (ifos,),fontsize=14) + leg = pylab.figlegend(lines, legend_str, 'lower right') + leg.prop.set_size(6) + leg.pad = 0 + pylab.ylabel("Prob (unnormalized)",fontsize=14) + pylab.xlabel("Rate",fontsize=14) + pylab.ylim([0.0001, 1]) + pylab.grid() + #FIXME hardcoded rate limits are bad for advanced ligo + pylab.xlim([1e-8, 1]) + pylab.savefig(ifos + '_posterior.png') + pylab.clf() + + ## + # Make log volume plot + ## + + #FIXME make it gray for pub? + #pylab.gray() + #FIXME setting these limits on the scale won't work in adv LIGO :) + pylab.pcolor(X,Y, log_vol, vmin=0, vmax=10) + pylab.colorbar() + pylab.ylim(m1range) + pylab.xlim(m2range) + pylab.title(ifos + " \nLog10[< Volume * Time>] in mergers/Mpc^3/yr",fontsize=14) + pylab.xlabel("Mass 2",fontsize=14) + pylab.ylabel("Mass 1",fontsize=14) + pylab.gca().set_aspect(1) + pylab.grid() + pylab.savefig(ifos+'_volume_time.png') + pylab.clf() + + ## + # Make vol error plot + ## + #FIXME we don't show errors greater than 100% + pylab.pcolor(X,Y, vol_error, vmin=0, vmax=1) + pylab.colorbar() + pylab.ylim(m1range) + pylab.xlim(m2range) + pylab.title(ifos + " \nFractional Error on Volume * Time [std/mean]",fontsize=14) + pylab.xlabel("Mass 2",fontsize=14) + pylab.ylabel("Mass 1",fontsize=14) + pylab.gca().set_aspect(1) + pylab.grid() + pylab.savefig(ifos+'_fractional_error.png') + pylab.clf() + + ## + # Make lambda plot + ## + + #FIXME hard limits + pylab.pcolor(X,Y, log_der, vmin=-3, vmax=3) + pylab.colorbar() + pylab.ylim(m1range) + pylab.xlim(m2range) + pylab.title(ifos + " \nLog10[fg/bg likelihood ratio(Lambda)]",fontsize=14) + pylab.xlabel("Mass 2",fontsize=14) + pylab.ylabel("Mass 1",fontsize=14) + pylab.gca().set_aspect(1) + pylab.grid() + pylab.savefig(ifos + '_lambda.png') + pylab.clf() + + ## + # Make UL plot + ## + #FIXME hard limits at log(rate) of -7, 0 + pylab.pcolor(X,Y, log_ul, vmin=-7, vmax=0) + pylab.colorbar() + pylab.ylim(m1range) + pylab.xlim(m2range) + pylab.title(ifos + " \nLog10[90% upper limit] in mergers/Mpc^3/yr",fontsize=14) + pylab.xlabel("Mass 2",fontsize=14) + pylab.ylabel("Mass 1",fontsize=14) + pylab.gca().set_aspect(1) + pylab.grid() + pylab.savefig(ifos + '_upper_limit.png') + pylab.clf() + + +############################################################################### +# now write out the special combined case +############################################################################### +lines = [] +legend_str = [] +ulA.array *= 0 + +for j, m1 in enumerate(bins.centres()[0]): + for k, m2 in enumerate(bins.centres()[1]): + masses = bins[m1,m2] + if mbA[masses[0], masses[1]]: continue + legend_str.append("%.1f, %.1f" % (m1, m2)) + mu,post = posterior(vA[...,masses[0],masses[1]], vA2[...,masses[0],masses[1]], dvA[...,masses[0],masses[1]]) + lines.append(pylab.loglog(mu,post/post.max())) + ulA.array[j][k] = integrate_posterior(mu, post, 0.90) + +#HACKS FOR LOG PLOT :( +# fudge is 1% effect +fudge = 0.01 * min (ulA.array[ulA.array !=0]) +log_ul = pylab.log10(ulA.array + fudge) + +# set points outside mass space to 1 (log(1) = 0) +log_ul[mbA == 1] = 0 + +# Make posterior plots +pylab.title("Combined posteriors for a few mass bins",fontsize=14) +leg = pylab.figlegend(lines, legend_str, 'lower right') +leg.prop.set_size(6) +leg.pad = 0 +leg.ncol = 2 +pylab.ylabel("Prob (unnormalized)",fontsize=14) +pylab.xlabel("Rate",fontsize=14) +pylab.ylim([0.0001, 1]) pylab.grid() +#FIXME hardcoded rate limits are bad for advanced ligo +pylab.xlim([1e-8, 1]) +pylab.savefig(combined_ifos + '_posterior.png') +pylab.clf() -pylab.figure(5) -pylab.gray() -pylab.pcolor(X,Y, log_ul) + +## +# Make UL plot +## +#FIXME hard limits at log(rate) of -7, 0 +pylab.pcolor(X,Y, log_ul, vmin=-7.0, vmax=0) pylab.colorbar() -pylab.ylim([0, 51]) -pylab.xlim([11, 101]) -pylab.title("Log10[90% upper limit] in mergers/Mpc^3/yr",fontsize=14) +pylab.ylim(m1range) +pylab.xlim(m2range) +pylab.title("Combined Log10[90% upper limit] in mergers/Mpc^3/yr",fontsize=14) pylab.xlabel("Mass 2",fontsize=14) pylab.ylabel("Mass 1",fontsize=14) pylab.gca().set_aspect(1) pylab.grid() - -pylab.show() +pylab.savefig(combined_ifos + '_upper_limit.png') +pylab.clf() +print >> sys.stderr, "ALL FINNISH!" +sys.exit(0) diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/lvstat.py b/lalapps/src/inspiral/s5_highmass_upper_limit/lvstat.py index 876e20d6fcca3a838b15557034ec6f07951e0c36..18b9555425cda41fc49104881754af24eaa3ef14 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/lvstat.py +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/lvstat.py @@ -22,7 +22,7 @@ from pylal import db_thinca_rings from pylal import llwapp from pylal import rate from pylal import SimInspiralUtils -from pylal.xlal.date import LIGOTimeGPS +from pylal.xlal.datatypes.ligotimegps import LIGOTimeGPS lsctables.LIGOTimeGPS = LIGOTimeGPS diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/make_summary_page.py b/lalapps/src/inspiral/s5_highmass_upper_limit/make_summary_page.py index 9a5cafabc1a0ffee127375e20497bb0d98dc9c7d..00a49fd50faa11b5be8ce3236608aedd535097b0 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/make_summary_page.py +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/make_summary_page.py @@ -6,15 +6,17 @@ import sys import glob import ConfigParser import subprocess +from optparse import OptionParser class wiki(object): - def __init__(self,fname="wiki.txt"): + def __init__(self,open_box=False,fname="wiki.txt"): + if open_box: fname = "open_box_" + fname self.fname = fname self.file = open(fname,"w") def image_link(self,path,webserver): thumb = "thumb_" + path - command = 'convert ' + path + ' -resize 300x300 ' + thumb + command = 'convert ' + path + ' -resize 300x300 -antialias ' + thumb print command popen = subprocess.Popen(command.split()) popen.communicate() @@ -24,81 +26,169 @@ class wiki(object): def image_table(self,image_list, webserver): if not image_list: return - self.file.write("||") - for i in image_list: + for j, i in enumerate(image_list): + if not (j) % 3: self.file.write("\n\n||") self.image_link(i, webserver) self.file.write("||") - self.file.write("\n") + self.file.write("\n\n") + + def image_glob(self, pat): + image_list = [] + for image in glob.glob(pat): + if 'thumb' in image: continue + else: image_list.append(image) + image_list.sort() + return image_list def section(self,title): s = "=== "+title.strip()+" ===\n" self.file.write(s) + def write(self,val): + self.file.write(val) + def finish(self): self.file.close() -try: webserver = sys.argv[1] -except: - print >>sys.stderr, "YOU MUST SPECIFY A WEBSERVER AS THE FIRST ARGUMENT (e.g. https://ldas-jobs.ligo.caltech.edu/~channa/highmass_months_23-24_summary_page)" - sys.exit(1) +def parse_command_line(): + parser = OptionParser(version = "%prog CVS $Id$", usage = "%prog [options] [file ...]", description = "%prog computes mass/mass upperlimit") + parser.add_option("--webserver", help = "Set the webserver path. Required. Example https://ldas-jobs.ligo.caltech.edu/~channa/highmass_months_23-24_summary_page") + parser.add_option("--open-box", action = "store_true", help = "Produce open box page") + parser.add_option("--output-name-tag", default = "", metavar = "name", help = "Set the basename for image search") + opts, filenames = parser.parse_args() + + if not opts.webserver: + print >>sys.stderr, "must specify a webserver" + sys.exit(1) + return opts, filenames + +########################################################### +# MAIN +########################################################### + +opts, filenames = parse_command_line() + +webserver = opts.webserver +open_box = opts.open_box +base_name = opts.output_name_tag -page = wiki() +if open_box: print >>sys.stderr, "WARNING: OPENING THE BOX" + +page = wiki(open_box, fname=base_name+"wiki.txt") + +page.section("Injection Parameters") + +image_list = page.image_glob(base_name+'6_sim_dist*.png') +page.image_table(image_list,webserver) page.section("Found / Missed") -image_list = ['cbc_plotsummary_0_deff_vs_mchirp_H1H2L1.png','cbc_plotsummary_0_deff_vs_mchirp_H1L1.png','cbc_plotsummary_0_deff_vs_mchirp_H2L1.png'] +image_list = page.image_glob(base_name+'1_deff_vs_mchirp_*.png') page.image_table(image_list,webserver) -image_list = ['cbc_plotsummary_0_deff_vs_t_H1H2L1.png','cbc_plotsummary_0_deff_vs_t_H1L1.png','cbc_plotsummary_0_deff_vs_t_H2L1.png'] +image_list = page.image_glob(base_name+'1_deff_vs_t_*.png') page.image_table(image_list,webserver) page.section("Parameter Accuracy") -image_list = ['cbc_plotsummary_1_mchirp_acc_frac_IMRPhenomAtwoPN_H1.png','cbc_plotsummary_1_mchirp_acc_frac_IMRPhenomAtwoPN_H2.png','cbc_plotsummary_1_mchirp_acc_frac_IMRPhenomAtwoPN_L1.png'] +image_list = page.image_glob(base_name+'2_mchirp_acc_frac_*.png') page.image_table(image_list,webserver) -image_list = ['cbc_plotsummary_1_eta_acc_frac_IMRPhenomAtwoPN_H1.png','cbc_plotsummary_1_eta_acc_frac_IMRPhenomAtwoPN_H2.png','cbc_plotsummary_1_eta_acc_frac_IMRPhenomAtwoPN_L1.png'] +image_list = page.image_glob(base_name+'2_eta_acc_frac_*.png') page.image_table(image_list,webserver) -image_list = ['cbc_plotsummary_1_t_acc_IMRPhenomAtwoPN_H1.png','cbc_plotsummary_1_t_acc_IMRPhenomAtwoPN_H2.png','cbc_plotsummary_1_t_acc_IMRPhenomAtwoPN_L1.png'] -page.image_table(image_list,webserver) -image_list = ['cbc_plotsummary_1_mchirp_acc_frac_EOBNRpseudoFourPN_H1.png','cbc_plotsummary_1_mchirp_acc_frac_EOBNRpseudoFourPN_H2.png','cbc_plotsummary_1_mchirp_acc_frac_EOBNRpseudoFourPN_L1.png'] -page.image_table(image_list,webserver) -image_list = ['cbc_plotsummary_1_eta_acc_frac_EOBNRpseudoFourPN_H1.png','cbc_plotsummary_1_eta_acc_frac_EOBNRpseudoFourPN_H2.png','cbc_plotsummary_1_eta_acc_frac_EOBNRpseudoFourPN_L1.png'] -page.image_table(image_list,webserver) -image_list = ['cbc_plotsummary_1_t_acc_EOBNRpseudoFourPN_H1.png','cbc_plotsummary_1_t_acc_EOBNRpseudoFourPN_H2.png','cbc_plotsummary_1_t_acc_EOBNRpseudoFourPN_L1.png'] +image_list = page.image_glob(base_name+'2_t_acc_*.png') page.image_table(image_list,webserver) page.section("Playground Chi-squared") -image_list = ['cbc_plotsummary_2_playground_chi2_vs_rho_H1.png', 'cbc_plotsummary_2_playground_chi2_vs_rho_H2.png', 'cbc_plotsummary_2_playground_chi2_vs_rho_L1.png'] +image_list = page.image_glob(base_name+'3_playground_chi2_vs_rho_*.png') page.image_table(image_list,webserver) page.section("Playground Effective SNR scatter") -image_list = ['cbc_plotsummary_3_playground_rho_H1_vs_L1.png', 'cbc_plotsummary_3_playground_rho_H1_vs_H2.png', 'cbc_plotsummary_3_playground_rho_H2_vs_L1.png'] +image_list = page.image_glob(base_name+'4_playground_rho_*.png') page.image_table(image_list,webserver) -page.section("Playground Ifar") -image_list = ['cbc_plotsummary_4_playground_count_vs_ifar_H1H2L1.png','cbc_plotsummary_4_playground_count_vs_ifar_H1L1.png','cbc_plotsummary_4_playground_count_vs_ifar_H2L1.png'] +page.section("Time slide plots") +image_list = page.image_glob(base_name + '7_playground_plot_slides_*.png') page.image_table(image_list,webserver) page.section("Playground SNR") -image_list = ['cbc_plotsummary_4_playground_count_vs_snr_H1H2L1.png','cbc_plotsummary_4_playground_count_vs_snr_H1L1.png','cbc_plotsummary_4_playground_count_vs_snr_H2L1.png'] +image_list = page.image_glob(base_name+'5_playground_count_vs_snr_*.png') page.image_table(image_list,webserver) -try: # see if you want to open the box - if sys.argv[2] == "open": +page.section("Playground Ifar") +image_list = page.image_glob(base_name+'5_playground_count_vs_ifar*.png') +page.image_table(image_list,webserver) + +try: + for l in open(base_name+"playground_summary_table.txt").readlines(): page.write(l) +except: print >>sys.stderr, "WARNING: couldn't find playground summary, continuing" + +if open_box: print >>sys.stderr, "WARNING: OPENING THE BOX" page.section("Full Data Chi-squared") - image_list = ['cbc_plotsummary_2_chi2_vs_rho_H1.png', 'cbc_plotsummary_2_chi2_vs_rho_H2.png', 'cbc_plotsummary_2_chi2_vs_rho_L1.png'] + image_list = page.image_glob(base_name+'3_chi2_vs_rho_*.png') page.image_table(image_list,webserver) page.section("Full Data Effective SNR scatter") - image_list = ['cbc_plotsummary_3_rho_H1_vs_L1.png', 'cbc_plotsummary_3_rho_H1_vs_H2.png', 'cbc_plotsummary_3_rho_H2_vs_L1.png'] + image_list = page.image_glob(base_name+'4_rho_*.png') page.image_table(image_list,webserver) - page.section("Full Data Ifar") - image_list = ['cbc_plotsummary_4_count_vs_ifar_H1H2L1.png','cbc_plotsummary_4_count_vs_ifar_H1L1.png','cbc_plotsummary_4_count_vs_ifar_H2L1.png'] + page.section("Time slide plots") + image_list = page.image_glob(base_name + '7_plot_slides_*.png') page.image_table(image_list,webserver) page.section("Full Data SNR") - image_list = ['cbc_plotsummary_4_count_vs_snr_H1H2L1.png','cbc_plotsummary_4_count_vs_snr_H1L1.png','cbc_plotsummary_4_count_vs_snr_H2L1.png'] + image_list = page.image_glob(base_name+'5_count_vs_snr_*.png') page.image_table(image_list,webserver) -except: pass + + page.section("Full Data Ifar") + image_list = page.image_glob(base_name+'5_count_vs_ifar_*.png') + page.image_table(image_list,webserver) + + try: + for l in open(base_name+"summary_table.txt").readlines(): page.write(l) + except: print >>sys.stderr, "WARNING: couldn't find summary, continuing" + + # UPPER LIMIT PLOTS + #ifos_list = [f.replace('volume_time.png','') for f in page.image_glob('*volume_time.png')] + #ifos_string = ",".join(ifos_list) + page.section("Volume x time ") + try: + filenames = page.image_glob(base_name+'-*_range_summary.txt') + print filenames + files = [open(f).readlines() for f in filenames] + for f in filenames: + page.write("|| '''!%s''' || || || || ||" % (f.replace('range_summary.txt','').replace(base_name, "").replace('_','').replace('-',''),) ) + page.write("\n") + for i in range(len(files[0])): + for f in files: + page.write(f[i].strip()) + page.write("\n") + except: print >>sys.stderr, "WARNING: couldn't find Range summary , continuing" + + page.write("\n") + image_list = page.image_glob(base_name+'-*_volume_time.png') + page.image_table(image_list,webserver) + + page.section("error on Volume x time ") + image_list = page.image_glob(base_name+'-*_fractional_error.png') + page.image_table(image_list,webserver) + + page.section("lambda ") + image_list = page.image_glob(base_name+'-*_lambda.png') + page.image_table(image_list,webserver) + + page.section("Selected posteriors ") + image_list = page.image_glob(base_name+'-*_posterior.png') + page.image_table(image_list,webserver) + + page.section("upper limit ") + image_list = page.image_glob(base_name+'-*_upper_limit.png') + page.image_table(image_list,webserver) + + page.section("Combined upper limit") + image_list = [base_name+'upper_limit.png', base_name+'posterior.png'] + page.image_table(image_list,webserver) + +try: + for l in open(base_name+"plotsummary.txt").readlines(): page.write(l) +except: print >>sys.stderr, "WARNING couldn't find plotsummary.txt" page.finish() diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/missed_found.py b/lalapps/src/inspiral/s5_highmass_upper_limit/missed_found.py index 974ab9f30e49357ee66703872568d3a05c55e74a..381d2963f96efca9a99fbcc12de880c255913541 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/missed_found.py +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/missed_found.py @@ -24,7 +24,7 @@ from pylal import db_thinca_rings from pylal import llwapp from pylal import rate from pylal import SimInspiralUtils -from pylal.xlal.date import LIGOTimeGPS +from pylal.xlal.datatypes.ligotimegps import LIGOTimeGPS lsctables.LIGOTimeGPS = LIGOTimeGPS diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/remove_h1h2.sql b/lalapps/src/inspiral/s5_highmass_upper_limit/remove_h1h2.sql index 51e931c6da9bf8815f6121ca78e77f6a8c8f0975..dc894498ba7dd89524ffbd946f592e8097620dca 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/remove_h1h2.sql +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/remove_h1h2.sql @@ -1,29 +1,30 @@ -- remove coincs when H1+H2 are the only instruments on DELETE FROM - coinc_inspiral + coinc_event WHERE - ifos == "H1,H2"; + instruments == "H1,H2"; --- remove H2+L1 coincs when H1+H2+L1 are on +-- remove coincs when H1+H2 are the only participants or when H2+L1 are the +-- only participants when H1+H2+L1 are on DELETE FROM coinc_inspiral WHERE - coinc_event_id IN ( - SELECT - coinc_inspiral.coinc_event_id - FROM - coinc_inspiral - JOIN coinc_event ON ( - coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id - ) - WHERE - coinc_inspiral.ifos == "H2,L1" - AND coinc_event.instruments == "H1,H2,L1" + ifos == "H1,H2" + OR ( + ifos == "H2,L1" + AND coinc_event_id IN ( + SELECT + coinc_event_id + FROM + coinc_event + WHERE + instruments == "H1,H2,L1" + ) ); --- remove unused rows from the coinc_event table +-- remove unused rows from the coinc_event and coinc_inspiral tables DELETE FROM coinc_event @@ -35,6 +36,16 @@ WHERE coinc_inspiral ); +DELETE FROM + coinc_inspiral +WHERE + coinc_event_id NOT IN ( + SELECT + coinc_event_id + FROM + coinc_event + ); + -- remove unused rows from the coinc_event_map table DELETE FROM diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/simplify.sql b/lalapps/src/inspiral/s5_highmass_upper_limit/simplify.sql index b0d786dfb7b078fa292d829fcc6090e41715951a..db7e889d89204bb2eb20109d87c000f8405bbf33 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/simplify.sql +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/simplify.sql @@ -2,8 +2,7 @@ -- coinc_definer clean up -- - -CREATE TABLE _idmap_ AS +CREATE TEMPORARY TABLE _idmap_ AS SELECT old_definer.coinc_def_id AS old, MIN(new_definer.coinc_def_id) AS new @@ -15,56 +14,37 @@ CREATE TABLE _idmap_ AS ) GROUP BY old_definer.coinc_def_id; +CREATE INDEX tmpindex ON _idmap_ (old); -CREATE INDEX idm_o_index ON _idmap_ (old); UPDATE coinc_event SET coinc_def_id = (SELECT new FROM _idmap_ WHERE old == coinc_def_id); -DROP INDEX idm_o_index; - DELETE FROM coinc_definer WHERE coinc_def_id IN (SELECT old FROM _idmap_ WHERE old != new); +DROP INDEX tmpindex; DROP TABLE _idmap_; - -- -- time_slide clean up -- - -CREATE TEMPORARY TABLE time_slide_ids AS SELECT DISTINCT time_slide_id AS time_slide_id FROM time_slide; -CREATE INDEX ts_io_index ON time_slide (instrument, offset); -CREATE INDEX tsi_index ON time_slide_ids (time_slide_id); -CREATE TABLE _idmap_ AS +CREATE TEMPORARY TABLE _idmap_ AS SELECT - old_ids.time_slide_id AS old, - ( - SELECT - MIN(new_ids.time_slide_id) - FROM - time_slide_ids AS new_ids - WHERE - NOT EXISTS ( - SELECT - * - FROM - time_slide AS alink - JOIN time_slide AS blink - WHERE - alink.time_slide_id == old_ids.time_slide_id - AND blink.time_slide_id == new_ids.time_slide_id - AND blink.instrument == alink.instrument - AND blink.offset != alink.offset - ) - ) AS new + time_slide_id AS old, + (SELECT group_concat(instrument || "=" || offset) FROM time_slide AS time_slide_a WHERE time_slide_a.time_slide_id == time_slide.time_slide_id ORDER BY instrument) AS repr, + NULL AS new FROM - time_slide_ids AS old_ids; -DROP INDEX tsi_index; -DROP INDEX ts_io_index; -DROP TABLE time_slide_ids; + time_slide + GROUP BY + time_slide_id; +CREATE INDEX tmpindex ON _idmap_ (repr, old); -CREATE INDEX idm_o_index ON _idmap_ (old); -UPDATE coinc_event SET time_slide_id = (SELECT new FROM _idmap_ WHERE old == time_slide_id); -DROP INDEX idm_o_index; +UPDATE _idmap_ SET new = (SELECT MIN(old) FROM _idmap_ AS a WHERE a.repr == _idmap_.repr); +DROP INDEX tmpindex; +CREATE INDEX tmpindex ON _idmap_ (old); +UPDATE coinc_event SET time_slide_id = (SELECT _idmap_.new FROM _idmap_ WHERE _idmap_.old == time_slide_id); DELETE FROM time_slide WHERE time_slide_id IN (SELECT old FROM _idmap_ WHERE old != new); +DROP INDEX tmpindex; DROP TABLE _idmap_; + +-- VACUUM; diff --git a/lalapps/src/inspiral/s5_highmass_upper_limit/upper_limit_wiki.py b/lalapps/src/inspiral/s5_highmass_upper_limit/upper_limit_wiki.py index dcf449f27178141c2c05fd2b60074c991a55fdb8..37870fbbe1f8b3b3ec1388818f8b539ffa834f45 100644 --- a/lalapps/src/inspiral/s5_highmass_upper_limit/upper_limit_wiki.py +++ b/lalapps/src/inspiral/s5_highmass_upper_limit/upper_limit_wiki.py @@ -46,20 +46,26 @@ page = wiki() page.section("Volume x time H1H2L1, H1L1, H2L1") image_list = ['H1H2L1volume_time.png', 'H1L1volume_time.png','H2L1volume_time.png'] page.image_table(image_list,webserver) + page.section("error on Volume x time H1H2L1, H1L1, H2L1") image_list = ['H1H2L1fractional_error.png', 'H1L1fractional_error.png','H2L1fractional_error.png'] page.image_table(image_list,webserver) + page.section("lambda H1H2L1, H1L1, H2L1") image_list = ['H1H2L1lambda.png', 'H1L1lambda.png','H2L1lambda.png'] page.image_table(image_list,webserver) + page.section("Selected posteriors H1H2L1, H1L1, H2L1") image_list = ['H1H2L1posterior.png', 'H1L1posterior.png','H2L1posterior.png'] page.image_table(image_list,webserver) + page.section("upper limit H1H2L1, H1L1, H2L1") image_list = ['H1H2L1upper_limit.png', 'H1L1upper_limit.png','H2L1upper_limit.png'] +page.image_table(image_list,webserver) + page.section("Combined upper limit") image_list = ['combinedupper_limit.png', 'combinedposterior.png'] - page.image_table(image_list,webserver) + page.finish() diff --git a/lalapps/src/inspiral/sire.c b/lalapps/src/inspiral/sire.c index 5585dcb66347851b2bc06fad94688fa03fd9336f..2a63a6817ec4817a91938c97bae6413460a1458d 100644 --- a/lalapps/src/inspiral/sire.c +++ b/lalapps/src/inspiral/sire.c @@ -158,7 +158,6 @@ int main( int argc, char *argv[] ) { /* lal initialization variables */ LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* program option variables */ extern int vrbflg; @@ -248,20 +247,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -387,7 +385,7 @@ int main( int argc, char *argv[] ) "Patrick Brady, Duncan Brown and Steve Fairhurst\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -895,7 +893,7 @@ int main( int argc, char *argv[] ) } /* read the summ value table as well. */ - XLALReadSummValueFile(&summValueList, inFileNameList[j]); + XLALReadSummValueFile(&summValueList, inFileNameList[j]); /* * @@ -1156,8 +1154,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/siva.c b/lalapps/src/inspiral/siva.c index badf16f112ede1c98c4111ea113ffe2219db2c19..0a92b6f83c9ac3df9f3969cdf9e2d66235593644 100644 --- a/lalapps/src/inspiral/siva.c +++ b/lalapps/src/inspiral/siva.c @@ -100,7 +100,7 @@ int main( int argc, char *argv[] ) numEvents = LALSnglInspiralTableFromLIGOLw( &events, inFile, 0, -1 ); if ( numEvents < 0 ) { fprintf( stderr, "error: unable to read sngl_inspiral table from %s\n", - inFile ); + inFile ); exit( 1 ); } diff --git a/lalapps/src/inspiral/skymap.c b/lalapps/src/inspiral/skymap.c index 8f4df1121bacefff26798638213b5927e32c4104..69140e532b2168e959d48d814ef6a19d722fb779 100644 --- a/lalapps/src/inspiral/skymap.c +++ b/lalapps/src/inspiral/skymap.c @@ -22,623 +22,714 @@ #include <lal/LIGOMetadataTables.h> #define max(A,B) (((A) > (B)) ? (A) : (B)) +#define NSIGMA 3 -/* declare C99 function */ -int (isnan)(double); +typedef double XLALSkymapSphericalPolarType[2]; + +typedef struct +{ + XLALSkymapSphericalPolarType *directions; + double* logPosteriors; + double total_logPosterior; + int count; +} SkyMapProperties; + +/* + * Use detector names from lal/packages/tools/include/LALDetectors.h : + * + * LAL_TAMA_300_DETECTOR = 0, + * LAL_VIRGO_DETECTOR = 1, + * LAL_GEO_600_DETECTOR = 2, + * LAL_LHO_2K_DETECTOR = 3, + * LAL_LHO_4K_DETECTOR = 4, + * LAL_LLO_4K_DETECTOR = 5, + * + *------------------------------------------------------- + * + * Array of pointers to the matched-filtered data z[t] + * + * x[0] = real(z_H) + * x[1] = real(z_L) + * x[2] = real(z_V) + * ... etc ... + * x[ MAXOBS + 0 ] = imag(z_H) + * x[ MAXOBS + 1 ] = imag(z_L) + * x[ MAXOBS + 2 ] = imag(z_V) + * ... etc ... + */ +typedef struct +{ + int N; + int* detectors; + double* wSw; + double** x; +} NetworkProperties; /* * File names for input and output */ -const char* h1_frame_file = 0; -const char* l1_frame_file = 0; -const char* v1_frame_file = 0; -const char* h2_frame_file = 0; - -char* xml_file[4] = { 0, 0, 0, 0}; - +char* frame_file[6] = { 0, 0, 0, 0, 0, 0}; +char* xml_file[6] = { 0, 0, 0, 0, 0, 0 }; +char* channel_name[6] = { 0, 0, 0, 0, 0, 0 }; +//typedef const char* cp; +//cp channel_name[6] = { "T1" , "V1" , "G1" , "H2" , "H1" , "L1" }; const char* output_file = "skymap.txt"; -char* event_id = 0; -/* - * Time of the trigger to be analyzed - */ -double w[3] = { 1, 1, 1 }; -/* - * Resolution of output sky map - */ -int ra_res = 512; -int dec_res = 256; - /* - * Sampling frequency of analysis, which determines sky tiling + * Global Variables... */ -int frequency = 0; +char* event_id = 0; // Event ID +int ra_res = 512; // resolution of output skyMap +int dec_res = 256; // "" +int frequency = 0; // sampling freq. of analysis (det's sky tilting) +int samples = 512; // Number of samples to analyze +double greenwich = 0; // Orientation of Earth at event time /* - * Number of samples to analyze + * Functions */ -int samples = 512; +void load_metadata( NetworkProperties* network, + int slot); +void load_data( NetworkProperties* network, + int slot ); +void writeSkymapOut( SkyMapProperties* skyMap ); +void analyze( NetworkProperties* network, + SkyMapProperties* skyMap ); /* - * Array of pointers to the matched-filtered data z[t] - * - * x[0] = real(z_H) - * x[1] = real(z_L) - * x[2] = real(z_V) - * x[3] = imag(z_H) - * x[4] = imag(z_L) - * x[5] = imag(z_V) - */ -double* x[6] = { 0, 0, 0, 0, 0, 0 }; -/* - * Orientation of the earth at the event time - */ -double greenwich = 0; -/* - * Functions + * MAIN */ -void load_metadata(char* file, int detector); -void load_data(int detector, const char* file, const char* initial); -void dump_data_to_file(FILE*); -void analyze(void); - int main(int argc, char** argv) { - int c; - - while (1) + fprintf( stderr , "#INSIDE MAIN!!!\n");//<<-----------------FIXME + int c,numObs = 0; + + while (1) { - static struct option long_options[] = - { - {"h1-frame-file", required_argument, 0, 'h'}, - {"l1-frame-file", required_argument, 0, 'l'}, - {"v1-frame-file", required_argument, 0, 'v'}, - {"h2-frame-file", required_argument, 0, 'i'}, - {"output-file", required_argument, 0, 'o'}, - {"ra-res", required_argument, 0, 'a'}, - {"dec-res", required_argument, 0, 'd'}, - {"h1-xml-file", required_argument, 0, 't'}, - {"l1-xml-file", required_argument, 0, 's'}, - {"v1-xml-file", required_argument, 0, 'r'}, - {"h2-xml-file", required_argument, 0, 'q'}, - {"event-id", required_argument, 0, 'e'}, - {"sample-rate", required_argument, 0, 'f'}, - {0, 0, 0, 0} - }; - int option_index = 0; - c = getopt_long_only(argc, argv, "h:l:v:i:o:a:d:t:s:r:q:e:f:", long_options, &option_index); - if (c == -1) - break; - - switch (c) + static struct option long_options[] = + { + {"h1-frame-file", required_argument, 0, 'h'}, + {"l1-frame-file", required_argument, 0, 'l'}, + {"v1-frame-file", required_argument, 0, 'v'}, + {"h2-frame-file", required_argument, 0, 'i'}, + {"h1-channel-name", required_argument, 0, 'j'}, + {"l1-channel-name", required_argument, 0, 'k'}, + {"v1-channel-name", required_argument, 0, 'm'}, + {"h2-channel-name", required_argument, 0, 'n'}, + {"output-file", required_argument, 0, 'o'}, + {"ra-res", required_argument, 0, 'a'}, + {"dec-res", required_argument, 0, 'd'}, + {"h1-xml-file", required_argument, 0, 't'}, + {"l1-xml-file", required_argument, 0, 's'}, + {"v1-xml-file", required_argument, 0, 'r'}, + {"h2-xml-file", required_argument, 0, 'q'}, + {"event-id", required_argument, 0, 'e'}, + {"sample-rate", required_argument, 0, 'f'}, + {0, 0, 0, 0} + }; + int option_index = 0; + c = getopt_long_only(argc, argv, "h:l:v:i:o:a:d:t:s:r:q:e:f:j:k:m:n:", long_options, &option_index); + if (c == -1) + break; + + switch (c) { - case 'h': - h1_frame_file = optarg; - break; - case 'l': - l1_frame_file = optarg; - break; - case 'v': - v1_frame_file = optarg; - break; - case 'i': - h2_frame_file = optarg; - break; - case 'o': - output_file = optarg; - break; - case 'a': - ra_res = atoi(optarg); - break; - case 'd': - dec_res = atoi(optarg); - break; - case 't': - xml_file[0] = optarg; - break; - case 's': - xml_file[1] = optarg; - break; - case 'r': - xml_file[2] = optarg; - break; - case 'q': - xml_file[3] = optarg; - break; - case 'e': - event_id = optarg; - break; - case 'f': - frequency = atoi(optarg); - break; - default: - fprintf(stderr, "unknown error while parsing options\n"); - exit(1); - } - } - - if (optind < argc) + case 'h': + frame_file[LAL_LHO_4K_DETECTOR] = optarg; + break; + case 'l': + frame_file[LAL_LLO_4K_DETECTOR] = optarg; + break; + case 'v': + frame_file[LAL_VIRGO_DETECTOR] = optarg; + break; + case 'i': + frame_file[LAL_LHO_2K_DETECTOR] = optarg; + break; + case 'o': + output_file = optarg; + break; + case 'a': + ra_res = atoi(optarg); + break; + case 'd': + dec_res = atoi(optarg); + break; + case 't': + xml_file[LAL_LHO_4K_DETECTOR] = optarg; + break; + case 's': + xml_file[LAL_LLO_4K_DETECTOR] = optarg; + break; + case 'r': + xml_file[LAL_VIRGO_DETECTOR] = optarg; + break; + case 'q': + xml_file[LAL_LHO_2K_DETECTOR] = optarg; + break; + case 'j': + channel_name[LAL_LHO_4K_DETECTOR] = optarg; + break; + case 'k': + channel_name[LAL_LLO_4K_DETECTOR] = optarg; + break; + case 'm': + channel_name[LAL_VIRGO_DETECTOR] = optarg; + break; + case 'n': + channel_name[LAL_LHO_2K_DETECTOR] = optarg; + break; + case 'e': + event_id = optarg; + break; + case 'f': + frequency = atoi(optarg); + break; + default: + fprintf(stderr, "unknown error while parsing options\n"); + exit(1); + }// end switch + }// end while + + if (optind < argc) { - fprintf(stderr, "error: extraneous command line argument "); - while (optind < argc) + fprintf(stderr, "error: extraneous command line argument "); + while (optind < argc) { - fprintf(stderr, "%s\n", argv[optind++]); + fprintf(stderr, "%s\n", argv[optind++]); } - exit(1); - } - - /* support "none" arguments */ - if (h1_frame_file && !strcmp("none", h1_frame_file)) { h1_frame_file = 0; } - if (l1_frame_file && !strcmp("none", l1_frame_file)) { l1_frame_file = 0; } - if (v1_frame_file && !strcmp("none", v1_frame_file)) { v1_frame_file = 0; } - if (h2_frame_file && !strcmp("none", h2_frame_file)) { h2_frame_file = 0; } - if (xml_file[0] && !strcmp("none", xml_file[0])) { xml_file[0] = 0; } - if (xml_file[1] && !strcmp("none", xml_file[1])) { xml_file[1] = 0; } - if (xml_file[2] && !strcmp("none", xml_file[2])) { xml_file[2] = 0; } - if (xml_file[3] && !strcmp("none", xml_file[3])) { xml_file[3] = 0; } - - /* check sanity */ - if (!(h1_frame_file || l1_frame_file || v1_frame_file || h2_frame_file)) - { - fprintf(stderr, "error: Supply at least one of --h1-frame-file, --l1-frame-file or --v1-frame-file\n"); - exit(1); - } - if (h1_frame_file && !xml_file[0]) - { - fprintf(stderr, "error: Supply --h1-xml-file to match --h1-frame-file\n"); - exit(1); - } - if (l1_frame_file && !xml_file[1]) - { - fprintf(stderr, "error: Supply --l1-xml-file to match --l1-frame-file\n"); - exit(1); - } - if (v1_frame_file && !xml_file[2]) - { - fprintf(stderr, "error: Supply --v1-xml-file to match --v1-frame-file\n"); - exit(1); - } - if (h2_frame_file && !xml_file[3]) - { - fprintf(stderr, "error: Supply --h2-xml-file to match --h2-frame-file\n"); - exit(1); - } - if (!h1_frame_file && xml_file[0]) - { - fprintf(stderr, "error: Supply --h1-frame-file to match --h1-xml-file\n"); - exit(1); - } - if (!l1_frame_file && xml_file[1]) - { - fprintf(stderr, "error: Supply --l1-frame-file to match --l1-xml-file\n"); - exit(1); - } - if (!v1_frame_file && xml_file[2]) + exit(1); + }// end if + + /* support "none" arguments */ + { + int i; + int arg_test; + for( i = 0 ; i < 6 ; ++i ) { - fprintf(stderr, "error: Supply --v1-frame-file to match --v1-xml-file\n"); - exit(1); - } - if (!h2_frame_file && xml_file[3]) + arg_test = 0; + if( frame_file[i] && !strcmp("none", frame_file[i] ) ) { frame_file[i] = 0; arg_test+=1;} + if( xml_file[i] && !strcmp("none" , xml_file[i] ) ) { xml_file[i] = 0; arg_test+=1;} + if( channel_name[i] && !strcmp("none" , channel_name[i] ) ) { channel_name[i] = 0; arg_test+=1;} + fprintf(stderr, "argtest %d\n",arg_test); + if( arg_test!=0 && arg_test!=3 ) + { + fprintf( stderr , "error: Supply matching pairs of frame, channel-name & XML files %d\n", arg_test); + exit(1); + }//end if + if( arg_test==0 && frame_file[i] ) + { + ++numObs; + printf("NUM OBS: %d\n" , numObs ); + }// end if + }// end i for + }// end code block + + if (frequency <= 0) { - fprintf(stderr, "error: Supply --h2-frame-file to match --h2-xml-file\n"); - exit(1); + fprintf(stderr, "error: Supply positive integer Hertz --sample-rate\n"); + exit(1); } + + /* examine one second of data around the injection */ + samples = frequency; + + + fprintf( stderr , "#Cleared Sanity Check!!!\n");//<<-----------------FIXME + + /* + * We create numObs + 1 networks... one for the whole system, and one network + * for each single detector: + */ + NetworkProperties* network; + NetworkProperties* singleObs = 0; // Suppress warning + + { + int i,k=0; - if (frequency <= 0) - { - fprintf(stderr, "error: Supply positive integer Hertz --sample-rate\n"); - exit(1); - } + network = malloc(sizeof(*network)); + network->N = numObs; - /* handle h2 */ - if (h2_frame_file) + network->wSw = malloc( sizeof(double) * numObs ); + network->detectors = malloc( sizeof(int) * numObs ); + + for( i = 0 ; i < 6 ; ++i ) + if( frame_file[i] ) + network->detectors[k++] = i; + + network->x = malloc( sizeof( double* ) * numObs * 2 ); + }// end code block + + + + /* + * Load metadata from XML files + */ + { + int i; + for( i = 0 ; i < numObs ; ++i ) + { + load_metadata(network , i); + load_data(network , i); + }// end i for + } + + { + int j; + double maxwSw = 0; + for( j = 0 ; j < network->N ; ++j ) + if( network->wSw[j] > maxwSw ) + maxwSw = network->wSw[j]; + for( j = 0 ; j < network->N ; ++j ) + network->wSw[j] /= maxwSw; + }// end code block + + if( numObs > 1 ) { - if (h1_frame_file) + singleObs = malloc( sizeof(*network) * numObs ); + + int i; + for( i = 0 ; i != numObs ; ++i ) { - fprintf(stderr, "warning: H1 and H2 both supplied; H2 will be ignored\n"); - } - else + singleObs[i].N = 1; + singleObs[i].wSw = malloc(sizeof(double)); + singleObs[i].wSw[0] = network->wSw[i]; + + singleObs[i].detectors = malloc(sizeof(int)); + singleObs[i].detectors[0] = network->detectors[i]; + + singleObs[i].x = malloc(sizeof(double*) * 2 ); + singleObs[i].x[0] = network->x[i]; + singleObs[i].x[1] = network->x[i + numObs]; + }//end for + }//end if + + fprintf( stderr , "#Entering Analsis...\n");//<<-----------------FIXME + + /* + * Analyze the data and save the skymap for the N-Detector Case + */ + SkyMapProperties* skyMap; + skyMap = malloc(sizeof(*skyMap)); + skyMap->count = ra_res * dec_res; + skyMap->directions = malloc(sizeof(*(skyMap->directions))*skyMap->count); + skyMap->logPosteriors = malloc(sizeof(*(skyMap->logPosteriors)) * skyMap->count ); + + /* + * Analyze the data for the N single-detector cases, and store the net + * log posteriors... + */ + double* total_logPosteriors = 0; // suppress warning + if( numObs > 1 ) + { + total_logPosteriors = malloc(sizeof(double) * numObs ); + int i; + for( i = 0 ; i != numObs ; ++i ) { - /* rebadge H2 as H1 */ - h1_frame_file = h2_frame_file; - xml_file[0] = xml_file[3]; - } - } - - /* examine one second of data around the injection */ - samples = frequency; - /* - * Load metadata from XML files - */ - load_metadata(xml_file[0], 0); - load_metadata(xml_file[1], 1); - load_metadata(xml_file[2], 2); - /* - * Load z[t] data from frame files - */ - load_data(0, h1_frame_file, "H"); - load_data(1, l1_frame_file, "L"); - load_data(2, v1_frame_file, "V"); - - /* - * Analyze the data and save the skymap - */ - - analyze(); - - return 0; -} - -void load_metadata(char* file, int detector) + analyze( singleObs + i , skyMap ); + total_logPosteriors[i] = skyMap->total_logPosterior; + fprintf(stderr,"total_logPosterior[%d] = %e\n", i , total_logPosteriors[i]); + }// end i for + }//end if + + /* + * Analyze the full network, write out the skymap, and + * then print the final summary... + */ + + analyze( network , skyMap ); + writeSkymapOut( skyMap ); + + { + int i,iMode = 0; + for( i = 0 ; i < skyMap->count ; ++i ) + { + if(skyMap->logPosteriors[i] > skyMap->logPosteriors[iMode]) + iMode = i; + } + + double raMax = fmod( skyMap->directions[iMode][0] + greenwich , LAL_TWOPI ); + double longMax = fmod( skyMap->directions[iMode][0] , LAL_TWOPI ); + double decMax = skyMap->directions[iMode][1]; + + printf("#FOUND RA \t FOUND DEC \t"); + printf(" TOTAL PROB \t LONG \t LAT\t"); + if( numObs > 1 ) + for( i = 0 ; i != numObs ; ++i ) + printf(" Detector_%d \t " , i ); + printf("\n"); + printf(" %f \t %f \t %e \t %f \t %f\t" , + raMax , decMax , skyMap->total_logPosterior , + longMax , decMax ); + if( numObs > 1 ) + for( i = 0 ; i != numObs ; ++i ) + printf(" %e \t",total_logPosteriors[i]); + printf("\n"); + }// end summary block + + + /* + * Raw data free'd + */ + { + int i; + for (i = 0; i != 2*numObs; ++i) + free(network->x[i]); + } + + + /* + * posterior data free'd + */ + free( skyMap->logPosteriors ); + free( skyMap->directions ); + free( singleObs ); + + return 0; +}// end main + +void load_metadata(NetworkProperties* network , int slot) { - if (file) + char* file = xml_file[ network->detectors[slot] ]; + + if (file) { - SnglInspiralTable* a = 0; - LALSnglInspiralTableFromLIGOLw(&a, file, 0, 1); - if (!a) + SnglInspiralTable* a = 0; + LALSnglInspiralTableFromLIGOLw(&a, file, 0, 1); + if (!a) { - fprintf(stderr, "error: failed to read single inspiral table from file %s\n", file); - exit(1); + fprintf(stderr, "error: failed to read single inspiral table from file %s\n", file); + exit(1); } - w[detector] = 1.0 / sqrt(a->sigmasq); - greenwich = fmod(XLALGreenwichMeanSiderealTime(&(a->end_time)), LAL_TWOPI); - /* - fprintf(stderr, "GPS %d -> GMS %e -> RAD %e \n", a->end_time.gpsSeconds, XLALGreenwichMeanSiderealTime(&(a->end_time)), greenwich); - */ - } -} + network->wSw[slot] = a->sigmasq; + greenwich = fmod(XLALGreenwichMeanSiderealTime(&(a->end_time)), LAL_TWOPI); + }//end file if +}// end load_metadata -void load_data(int detector, const char* file, const char* initial) +void load_data(NetworkProperties* network , int slot ) { - if (file) + const char* file = frame_file[ network->detectors[slot] ]; + const char* selected_channel_name = channel_name[ network->detectors[slot] ]; + + if (file) { - /* - * Read the frame file here - */ - - FrStream *stream = NULL; - COMPLEX8TimeSeries H1series; - int i; - - sprintf(H1series.name,"%s1:CBC-CData_%s", initial, event_id); - stream = XLALFrOpen("./", file); - if (!stream) + /* + * Read the frame file here + */ + + FrStream *stream = NULL; + COMPLEX8TimeSeries H1series; + int i; + + sprintf(H1series.name,"%s", selected_channel_name); + stream = XLALFrOpen("./", file); + if (!stream) { - fprintf(stderr, "error: failed to open FrStream from file %s\n", H1series.name); - exit(1); + fprintf(stderr, "error: failed to open FrStream from file %s\n", H1series.name); + exit(1); } - - H1series.data = XLALCreateCOMPLEX8Vector(samples); - if (!H1series.data) + + H1series.data = XLALCreateCOMPLEX8Vector(samples); + if (!H1series.data) { - fprintf(stderr, "error: failed to create COMPLEX8 vector\n"); - exit(1); + fprintf(stderr, "error: failed to create COMPLEX8 vector\n"); + exit(1); } - XLALFrGetCOMPLEX8TimeSeries(&H1series,stream); - XLALFrClose(stream); - - /* - * Allocate memory to repack the data in - */ - - /* real, or waveform one */ - x[detector] = (double*) malloc(samples * sizeof(double)); - /* complex, or waveform two */ - x[detector + 3] = (double*) malloc(samples * sizeof(double)); - - for (i = 0; i != samples; ++i) + XLALFrGetCOMPLEX8TimeSeries(&H1series,stream); + XLALFrClose(stream); + + /* + * real/complex or waveform one/two + */ + network->x[slot ] = (double*) malloc(samples * sizeof(double)); + network->x[slot + network->N ] = (double*) malloc(samples * sizeof(double)); + + for (i = 0; i != samples; ++i) { - x[detector ][i] = H1series.data->data[i].re; - x[detector + 3][i] = H1series.data->data[i].im; - } - } -} + network->x[slot ][i] = H1series.data->data[i].re; + network->x[slot + network->N ][i] = H1series.data->data[i].im; + }// end i for + }// end file if +}// end load_data -#define NSIGMA 3 - -void analyze(void) +void writeSkymapOut( SkyMapProperties* skyMap ) { + int i; + /* + * Write a gzipped ascii file describing the sky map + */ + gzFile* h = NULL; + h = gzopen(output_file, "wb"); + if (h == NULL) + { + fprintf(stderr,"cannot gzopen() %s\n",output_file); + exit(1); + } + + for ( i = 0; i != skyMap->count ; ++i ) + { + double phi,ra,dec,longitude; + phi = skyMap->directions[i][1]; + ra = fmod(phi + greenwich, LAL_TWOPI); + longitude = fmod( phi , LAL_TWOPI); + while (ra < 0) + ra += LAL_TWOPI; + while ( longitude < 0 ) + longitude += LAL_TWOPI; + while (ra >= LAL_TWOPI) + ra -= LAL_TWOPI; + while ( longitude >= LAL_TWOPI ) + longitude -= LAL_TWOPI; + dec = LAL_PI_2 - skyMap->directions[i][0]; + gzprintf( h, "%.10e %.10e %.10e %.10e %.10e\n", + ra, dec, (skyMap->logPosteriors[i]) , longitude , dec ); + }// end i for + gzclose(h); +}// end writeSkyMapOut - XLALSkymapPlanType* plan; - double s[NSIGMA]; - int i, j; - double* raw; - double* accumulator; - int begin[3], end[3]; - - double min_w = w[0]; - - for (i = 0; i != 3; ++i) - { - if (w[i] < min_w) min_w = w[i]; - } - - for (i = 0; i != 3; ++i) w[i] /= min_w; - - begin[0] = 0; - begin[1] = begin[0]; - begin[2] = begin[0]; - - end[0] = samples; - end[1] = end[0]; - end[2] = end[0]; - /* - * The characteristic size of the signal - */ - /*fprintf(stderr, "w: %e %e %e\n", w[0], w[1], w[2]);*/ - +/* + * ANALYZE + */ +void analyze( NetworkProperties* network , SkyMapProperties* skyMap ) +{ + int i,j; + + XLALSkymapPlanType* plan; + XLALSkymapDirectionPropertiesType *properties; + XLALSkymapKernelType *kernels; + + double** xSw = malloc( sizeof( double* ) * network->N ); + double** xSw2 = malloc( sizeof( double* ) * network->N ); + + /* + * The characteristic size of the signal + */ + + /* Validate the input */ + for (i = 0; i != network->N; ++i) { - /* Validate the input */ - - for (i = 0; i != 3; ++i) + if (network->x[i]) { - if (x[i]) + for (j = 0; j != samples; ++j) { - if (!((w[i] > 0) && (w[i] < -log(0)))) - { - fprintf(stderr, "error: w[%d] is %e\n", i, w[i]); - exit(1); - } - for (j = 0; j != samples; ++j) - { - if (!((x[i][j] > log(0)) && (x[i][j] < -log(0)))) - { - fprintf(stderr, "error: x[%d][%d] = %e\n", i, j, x[i][j]); - exit(1); - } - if (!((x[i + 3][j] > log(0)) && (x[i + 3][j] < -log(0)))) - { - fprintf(stderr, "error: x[%d][%d] = %e\n", i + 3, j, x[i + 3][j]); - exit(1); - } - } - } - } - - } + if (!( ( network->x[i][j] > log(0) ) && + ( network->x[i][j] < -log(0) ) )) + { + fprintf(stderr, "error: x[%d][%d] = %e\n", i, j, network->x[i][j]); + exit(1); + }// end if + if (!( (network->x[i + network->N][j] > log(0)) && + (network->x[i + network->N][j] < -log(0)) )) + { + fprintf( stderr , "error: x[%d][%d] = %e\n", + i + network->N, j, network->x[i + network->N][j]); + exit(1); + }//end if + }//end j for + }// end if + else + { + fprintf(stderr , "Data not supplied for detector %d\n" , i ); + exit(1); + }// end else + }//end i for + + fprintf( stderr , "#Input Validated...\n");//<<-----------------FIXME - { - /* - * Compute the glitch hypotheses - */ - double pglitches[3]; - double pglitch; - - for (i = 0; i != 3; ++i) - { - pglitches[i] = 0; - if (x[i]) - { - for (j = 0; j != samples; ++j) - { - int k; - for (k = 0; k != NSIGMA; ++k) - { - /* - * FIXME: exp may overflow - */ - double p = pow(s[k], -2) * exp(0.5 * (1.0 - pow(s[k], -2)) * (pow(x[i][j], 2) + pow(x[i + 3][j], 2))); - pglitches[i] += (p / (NSIGMA * samples)); - } - } - } - } - - pglitch = 1.0; - for (i = 0; i != 3; ++i) - { - if (x[i]) - { - pglitch *= pglitches[i]; - } - } - - /* - * FIXME: output pglitch somewhere - */ - - /* - * FIXME: implications of glitch model - */ - } + /* + * Compute the glitch hypotheses //<----------- TEMP REMOVED FIXME + * + { + double log_pglitches[network->N]; - { - /* - * Use the most sensitive detector to set the bottom of the - * logarithmic distribution of amplitude scales - */ - double min_w; - - min_w = -log(0); - - for (i = 0; i != 3; ++i) - { - if (x[i]) - { - if (w[i] < min_w) - { - min_w = w[i]; - } - } - } - - s[0] = sqrt(10.0) / min_w; - s[1] = sqrt(100.0) / min_w; - s[2] = sqrt(1000.0) / min_w; - } + for (i = 0; i != network->N; ++i) + { + log_pglitches[i] = log(0.0); + if (network->x[i]) + { + for (j = 0; j != samples; ++j) + { + double log_p = -1.0 * log( 1 + pow( 1 , 2 )) + + .5 * pow(1 + pow(1,-2),-1) * (pow(x[i][j],2) + pow(x[i+network->N][j],2)); + log_pglitches[i] = XLALSkymapLogSumExp( log_pglitches[i] , log_p ); + }// end j for + log_pglitches[i] -= log( samples ); + }// end x if + }// end i for + skyMap->log_pGlitch = 0.0; + for (i = 0; i != network->N ; ++i) + { + if (x[i]) + { + skyMap->log_pGlitch += log_pglitches[i]; + }//end if + }//end i for + }// end code block + + ----------- FIXME END TEMP REMOVED FIXME + + */ + + /* + * the sky tiles implied by the frequency) + */ + plan = malloc(sizeof(*plan)); + XLALSkymapPlanConstruct( frequency , network->N , network->detectors , plan ); + + /* + * Directions assigned for each pixel, using sine proj. + */ + { + for ( i = 0 ; i != dec_res ; ++i ) + { + for ( j = 0 ; j != ra_res ; ++j ) + { + skyMap->directions[i*ra_res + j][0] = acos((i - dec_res/2.0 + 0.5)/dec_res*2); + skyMap->directions[i*ra_res + j][1] = (j + .5)/ra_res*2*LAL_PI; + }//end j for + }// end i for + }// end code block + + fprintf( stderr , "#Pixel Direction Assigned...\n");//<<-----------------FIXME + + /* + * Properties Constructed + */ + properties = malloc(sizeof(*properties) * skyMap->count ); + for (i = 0 ; i != skyMap->count ; ++i) { - /* Convert the individually normalized matched filters to a common normalization */ - for (i = 0; i != 3; ++i) - { - if (x[i]) - { - for (j = 0; j != samples; ++j) - { - x[i][j] *= w[i]; - x[i + 3][j] *= w[i]; - } - } - } - } - - /* - * the sky tiles implied by the frequency) - */ - if (!(plan = XLALSkymapConstructPlanMN(frequency, dec_res, ra_res))) - { - fprintf(stderr, "XLALSkymapConstructPlanMN failed"); - exit(1); - } - /* - * Allocate a chunk of memory tto hold the sky map in the internal - * timing format - */ - raw = (double*) calloc(plan->pixelCount, sizeof(double)); - accumulator = (double*) calloc(plan->pixelCount, sizeof(double)); - /* - * Generate the skymap - */ - if (XLALSkymapEllipticalHypothesis(plan, accumulator, s[0], w, begin, end, x, 0)) - { - fprintf(stderr, "XLALSkymapEllipticalHypothesis failed"); - exit(1); - } - for (i = 1; i != NSIGMA; ++i) + XLALSkymapDirectionPropertiesConstruct( + plan, + &((*(skyMap->directions + i))[0]), + properties + i + ); + }// end i for + + fprintf(stderr,"#Properties Constructed, N = %d \n" , network->N); + + /* + * Posterior probabilities found for 4 different signal amplitudes, + * at each pixel in the sky, over all arrival times... + */ + { + for (i = 0; i != network->N; ++i) { - if (XLALSkymapEllipticalHypothesis(plan, raw, s[i], w, begin, end, x, 0)) + xSw[i] = malloc(sizeof(double) * samples); + xSw2[i] = malloc(sizeof(double) * samples); + for (j = 0; j != samples; ++j) { - fprintf(stderr, "XLALSkymapEllipticalHypothesis failed"); - exit(1); - } - XLALSkymapSum(plan, accumulator, accumulator, raw); - } + xSw[i][j] = network->x[i][j] * sqrt( network->wSw[i] ); + xSw2[i][j] = network->x[i + network->N ][j] * sqrt( network->wSw[i] ); + }// end j for + }// end i for - free(raw); - raw = accumulator; - - { - /* validate the output */ - for (i = 0; i != plan->pixelCount; ++i) - { - if ((plan->pixel[i].area != 0) && isnan(raw[i])) - { - fprintf(stderr, "plan->pixel[%d].area = %e && raw[%d] = %e\n", i, plan->pixel[i].area, i, raw[i]); - exit(1); - } - } - } + fprintf( stderr , "#Commencing kernel calculations...\n");//<<-----------------FIXME - { /* - * Get the mode - */ - double thetaphi[2]; - XLALSkymapModeThetaPhi(plan, raw, thetaphi); - while (thetaphi[1] < 0) - thetaphi[1] += LAL_TWOPI; - printf("%e %e\n", thetaphi[0], thetaphi[1]); - } + kernels = malloc( sizeof(*kernels) * skyMap->count ); + for( j = 0 ; j != skyMap->count ; ++j ) + skyMap->logPosteriors[j] = log(0); + double* buffer = malloc(sizeof(double) * samples); - { /* - * Render the timing-format sky map to a more friendly coordinate - * system - */ - double* render; - int m = dec_res; - int n = ra_res; - double maximum; - render = (double*) malloc(m * n * sizeof(double)); - if (XLALSkymapRender(render, plan, raw)) - { - fprintf(stderr, "XLALSkymapRender failed\n"); - exit(1); - } - - for (j = 0; j != m * n; ++j) - { - if (isnan(render[j])) - { - fprintf(stderr, "WARNING: The rendered skymap contains a NaN at pixel %d\n", j); - } - } - - maximum = log(0); - for (j = 0; j != m * n; ++j) - { - if (isnan(maximum)) - { - fprintf(stderr, "ERROR: The rendered skymap's progressive maximum became NaN before pixel %d\n", j); - exit(1); - } - if (render[j] > maximum) - { - maximum = render[j]; - } - } - if (!(maximum < -log(0))) - { - fprintf(stderr, "ERROR: The skymap maximum was not finite, and normalization cannot be performed\n"); - exit(0); - } - for (j = 0; j != m * n; ++j) + fprintf( stderr , "#Memory Allocated... btw's numObs == %d\n" , network->N );//<<--- FIXME + + { + int k; + double* wSw; + wSw = malloc( sizeof(double) * network->N ); + for( i = 0 ; i < network->N ; ++i ) { - render[j] -= maximum; - } - - + wSw[i] = network->wSw[i]; + }// end i for + for( k = 0 ; k < 4 ; ++k ) /* over 4 waveForm amplitudes */ { - /* - * Write a gzipped ascii file describing the sky map - */ - gzFile* h = NULL; - h = gzopen(output_file, "wb"); - if (h == NULL) - { - fprintf(stderr,"cannot gzopen() %s\n",output_file); - exit(1); - } - for (j = 0; j != n; ++j) - { - double phi, ra; - phi = (LAL_TWOPI * (j + 0.5)) / n; - ra = fmod(phi + greenwich, LAL_TWOPI); - while (ra < 0) - ra += LAL_TWOPI; - while (ra >= LAL_TWOPI) - ra -= LAL_TWOPI; - for (i = 0; i != m; ++i) - { - double dec; - dec = LAL_PI_2 - acos(1. - (i + 0.5) * (2. / m)); - gzprintf(h, "%.10e %.10e %.10e\n", ra, dec, (render[i + m * j])); - } - } - gzclose(h); - } - - free(render); - - } - - free(raw); - - /* - * The plan has allocated memory, so we have to destroy it - */ - XLALSkymapDestroyPlan(plan); + for (i = 0; i != skyMap->count; ++i) /* over all pixels */ + XLALSkymapKernelConstruct( plan , properties + i, wSw, kernels + i ); + fprintf( stderr , "#samples = %d\n#count= %d\n" , samples , skyMap->count); //<< FIXME + + for (i = 0; i != skyMap->count; ++i) /* over all pixels */ + { + int t; + //fprintf(stderr, "%d: i = %d\n", __LINE__, i); + for( t = samples/4 ; t < 3 * samples / 4 ; ++t ) /* over all sample times */ + { + double real , imag; + //fprintf(stderr, "%d: i = %d, t = %d\n", __LINE__, i, t); + XLALSkymapApply( plan , + properties + i , + kernels + i , + xSw , + ((double) t) / ((double) plan->sampleFrequency), + &real ); + //fprintf(stderr, "%d: i = %d, t = %d\n", __LINE__, i, t); + XLALSkymapApply( plan , + properties + i , + kernels + i , + xSw2 , + ((double) t) / ((double) plan->sampleFrequency), + &imag ); + buffer[t] = real + imag; + }// end t for + //if( isnan(skyMap->logPosteriors[i] ) ) + // { + // fprintf( stderr , "NAN @ i = %d\n" , i ); + // exit(1); + // }//end if + skyMap->logPosteriors[i] = XLALSkymapLogSumExp( skyMap->logPosteriors[i] , + XLALSkymapLogTotalExp( buffer + samples / 4 , + buffer + 3*samples/4) - log(4) - log(samples/2) ); + }//end i for + fprintf( stderr , "#N = %d\n" , k ); + /* + * For the next loop, look for a signal sqrt(10) larger... + */ + for( i = 0 ; i < network->N ; ++i ) + { + wSw[i] *= 10.0; + for( j = 0 ; j != samples; ++j ) + { + xSw[i][j] *= sqrt( 10.0 ); + xSw2[i][j] *= sqrt( 10.0 ); + }// end j for + }//end i for + }// end n for - /* - * Free the data - */ + }// end code block + + free(buffer); + }// end posterior computing code block + + fprintf( stderr , "#Posterior Found, writing...\n");//<<--------FIXME + + /* validate the output */ + for (i = 0; i != skyMap->count ; ++i) { - for (i = 0; i != 6; ++i) - { - free(x[i]); - } - } - -} + if( isnan(skyMap->logPosteriors[i]) ) + { + fprintf(stderr, "BAD DIRECTION :( THETA: %f PHI: %f i:%d\n", + skyMap->directions[i][0],skyMap->directions[i][1],i); + exit(1); + }//end if + }// end i for + { + double log_totalProb = XLALSkymapLogTotalExp( skyMap->logPosteriors , + skyMap->logPosteriors + skyMap->count ); + skyMap->total_logPosterior = log_totalProb - log( skyMap->count ); + fprintf( stderr , "#TOTAL PROB: %e\n" , skyMap->total_logPosterior ); + } + /* + * Free the data + */ + free(plan); + for(i = 0; i != network->N; ++i) + { + free(xSw2[i]); + free(xSw[i]); + }// end i for + free(kernels); + free(properties); +}// end analyze(void) diff --git a/lalapps/src/inspiral/sned.c b/lalapps/src/inspiral/sned.c index cbf8e3efb4f232db9a1a1971c6c800ecfc95fb8e..c93a10f49db6cf0ea1641bd5ee6e8ec48c7c213f 100644 --- a/lalapps/src/inspiral/sned.c +++ b/lalapps/src/inspiral/sned.c @@ -242,7 +242,6 @@ int main( int argc, char *argv[] ) /* output data */ LIGOLwXMLStream xmlStream; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; MetadataTable proctable; MetadataTable outputTable; MetadataTable procparams; @@ -253,35 +252,34 @@ int main( int argc, char *argv[] ) CHAR chanfilename[FILENAME_MAX]; /* vars needed for toy Monte Carlo */ - REAL8 SNRsq_threshold = 0; - REAL8 Store_ifoSNRsq[6]; - SimInspiralTable *thisMissedSim = NULL; - SimInspiralTable *thisFoundSim = NULL; - SimInspiralTable *headMissedSim = NULL; - SimInspiralTable *headFoundSim = NULL; - SnglInspiralTable *H1FoundSngl = NULL; - SnglInspiralTable *headFoundSngl = NULL; - SnglInspiralTable *L1FoundSngl = NULL; + REAL8 SNRsq_threshold = 0; + REAL8 Store_ifoSNRsq[6]; + SimInspiralTable *thisMissedSim = NULL; + SimInspiralTable *thisFoundSim = NULL; + SimInspiralTable *headMissedSim = NULL; + SimInspiralTable *headFoundSim = NULL; + SnglInspiralTable *H1FoundSngl = NULL; + SnglInspiralTable *headFoundSngl = NULL; + SnglInspiralTable *L1FoundSngl = NULL; /* set initial debug level */ set_debug_level("1"); /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->start_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -395,7 +393,7 @@ int main( int argc, char *argv[] ) "Drew Keppel and Gareth Jones\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -1244,8 +1242,7 @@ int main( int argc, char *argv[] ) LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlStream, fname ), &status ); /* write out the process and process params tables */ - LAL_CALL( LALGPSTimeNow( &status, &(proctable.processTable->end_time ), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, @@ -1288,8 +1285,7 @@ int main( int argc, char *argv[] ) LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlStream, fname ), &status ); /* write out the process and process params tables */ - LAL_CALL( LALGPSTimeNow( &status, &(proctable.processTable->end_time ), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, @@ -1325,8 +1321,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL( LALGPSTimeNow( &status, &(proctable.processTable->end_time ), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/spininj.c b/lalapps/src/inspiral/spininj.c index a4b1041a4a1263455457eaa0b4260c166bf7b121..74ab7a371a6e14973525705e87951b7daa2a906d 100644 --- a/lalapps/src/inspiral/spininj.c +++ b/lalapps/src/inspiral/spininj.c @@ -52,6 +52,7 @@ #include <lal/DetResponse.h> #include <lal/TimeDelay.h> #include <lal/lalGitID.h> +#include <lal/LALErrno.h> #include <lalappsGitID.h> @@ -82,9 +83,9 @@ RCSID( "$Id$" ); " twoPointFivePN, threePN) (default: EOBtwoPN)\n"\ " --fLower set the lower cutoff frequency of the isnpiral waveform (40)\n\n"\ " --dist-distr DDISTR set method of simulated source distance distr to DDISTR \n"\ -" SPININJ_distance : uniform distr of sources in distance \n"\ -" SPININJ_logDistance : uniform distr of sources in log(distance) \n"\ -" SPININJ_volume : uniform distr of sources in volume \n"\ +" SPININJ_distance : uniform distr of sources in distance \n"\ +" SPININJ_logDistance : uniform distr of sources in log(distance) \n"\ +" SPININJ_volume : uniform distr of sources in volume \n"\ " Default is SPININJ_logDistance \n"\ " --distance-min set minimal value of simulated sources distance in kpc \n"\ " --distance-max set maximal value of simulated sources distance in kpc \n\n"\ @@ -101,8 +102,8 @@ RCSID( "$Id$" ); " --spin2-max set maximal value of the initial spin (<=1)\n"\ " --spin2-range set range of the initial spin (0 - 1)\n\n"\ " --mass-distr MDISTR set method of simulated source mass distr to MDISTR \n"\ -" SPININJ_m1Andm2 : uniform distr of sources component mass \n"\ -" SPININJ_totalMass : uniform distr of sources total mass \n"\ +" SPININJ_m1Andm2 : uniform distr of sources component mass \n"\ +" SPININJ_totalMass : uniform distr of sources total mass \n"\ " Default is SPININJ_totalMass \n"\ " --mass1-range set range of the first mass (3 - 20 )\n"\ " --mass2-range set range of the second mass (3 - 20)\n\n"\ @@ -151,48 +152,48 @@ typedef struct { void LALSimInspiralTablePopulate(LALStatus *status, - MetadataTable injections, - SimInspiralTable *this_inj); + MetadataTable injections, + SimInspiralTable *this_inj); void LALSetIndividualMasses(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj); + InspiralInjectionParameters params, + SimInspiralTable *this_inj); void LALSetDistance(LALStatus *status, - InspiralInjectionParameters, - SimInspiralTable *this_inj); + InspiralInjectionParameters, + SimInspiralTable *this_inj); void LALSetSpin(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj ); + InspiralInjectionParameters params, + SimInspiralTable *this_inj ); void LALSetSpatialDistribution(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj); + InspiralInjectionParameters params, + SimInspiralTable *this_inj); void LALSetSiteParameters(LALStatus *status, - SimInspiralTable *this_inj); + SimInspiralTable *this_inj); -void LALSetGeoCentricEndTime(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj); +void LALSetGeoCentricEndTime(LALStatus *status, + InspiralInjectionParameters params, + SimInspiralTable *this_inj); void LALParserInspiralInjection(LALStatus *status, - int, - char**, - InspiralInjectionParameters *); + int, + char**, + InspiralInjectionParameters *); void LALCheckInspiralInjectionParameters(LALStatus *status, - InspiralInjectionParameters params); + InspiralInjectionParameters params); @@ -231,20 +232,20 @@ int main( int argc, char *argv[] ) /* command line options */ - InspiralInjectionParameters paramsIn; - MetadataTable injections; - SimInspiralTable *this_inj = NULL; - LALGPSCompareResult compareGPS; + InspiralInjectionParameters paramsIn; + MetadataTable injections; + SimInspiralTable *this_inj = NULL; + LALGPSCompareResult compareGPS; /* set up inital debugging values */ lal_errhandler = LAL_ERR_EXIT; set_debug_level( "1" ); LAL_CALL( LALParserInspiralInjection(&status, argc, argv, ¶msIn), - &status); + &status); LAL_CALL( LALCreateRandomParams( &status, &randParams, paramsIn.randSeed ), - &status ); + &status ); /* null out the head of the linked list */ injections.simInspiralTable = NULL; @@ -275,23 +276,23 @@ int main( int argc, char *argv[] ) } LAL_CALL(LALSetGeoCentricEndTime(&status, paramsIn, this_inj), - &status); + &status); LAL_CALL( LALSetIndividualMasses(&status, paramsIn, this_inj), - &status); + &status); LAL_CALL( LALSetSpin(&status, paramsIn, this_inj), - &status); + &status); LAL_CALL( LALSetDistance(&status, paramsIn, this_inj), - &status); + &status); LAL_CALL( LALSetSpatialDistribution(&status, paramsIn, this_inj), - &status); + &status); LAL_CALL( LALSetSiteParameters(&status, this_inj), - &status); + &status); /* increment the injection time */ XLALGPSAdd( &(paramsIn.gpsStartTime), paramsIn.meanTimeStep ); LAL_CALL( LALCompareGPS( &status, &compareGPS, &(paramsIn.gpsStartTime), - &(paramsIn.gpsEndTime) ), &status ); + &(paramsIn.gpsEndTime) ), &status ); this_inj->f_lower = paramsIn.fLower; @@ -309,8 +310,8 @@ int main( int argc, char *argv[] ) /* write the sim_inspiral table */ if ( injections.simInspiralTable ){ LAL_CALL(LALSimInspiralTablePopulate(&status, - injections, - this_inj), &status); + injections, + this_inj), &status); } /* close the injection file */ LAL_CALL( LALCloseLIGOLwXMLFile ( &status, &xmlfp ), &status ); @@ -324,14 +325,14 @@ int main( int argc, char *argv[] ) /*################################################*/ void LALSimInspiralTablePopulate(LALStatus *status, - MetadataTable injections, - SimInspiralTable *this_inj) + MetadataTable injections, + SimInspiralTable *this_inj) { LAL_CALL( LALBeginLIGOLwXMLTable( status, &xmlfp, sim_inspiral_table ), - status ); + status ); LAL_CALL( LALWriteLIGOLwXMLTable( status, &xmlfp, injections, - sim_inspiral_table ), status ); + sim_inspiral_table ), status ); LAL_CALL( LALEndLIGOLwXMLTable ( status, &xmlfp ), status ); while ( injections.simInspiralTable ) @@ -348,8 +349,8 @@ void LALSimInspiralTablePopulate(LALStatus *status, /* TODO check uniformity of totalmass and (2) set mchirp*/ void LALSetIndividualMasses(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj ) + InspiralInjectionParameters params, + SimInspiralTable *this_inj ) { REAL4 deltaM1 = params.m1.max - params.m1.min; @@ -376,7 +377,7 @@ void LALSetIndividualMasses(LALStatus *status, this_inj->mass1 = params.m1.min + u * deltaM1; this_inj->mass2 = mtotal - this_inj->mass1; while (this_inj->mass2 >= params.m2.max - || this_inj->mass2 <= params.m2.min ) + || this_inj->mass2 <= params.m2.min ) { LAL_CALL( LALUniformDeviate( status, &u, randParams ), status ); this_inj->mass1 = params.m1.min + u * deltaM1; @@ -393,8 +394,8 @@ void LALSetIndividualMasses(LALStatus *status, void LALSetSpin(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj ) + InspiralInjectionParameters params, + SimInspiralTable *this_inj ) { REAL4 u; REAL4 spin1Mag; @@ -425,17 +426,17 @@ void LALSetSpin(LALStatus *status, /* spin2Mag */ LAL_CALL( LALUniformDeviate( status, &u, randParams ), status ); spin2Mag = params.spin2.min + u * (params.spin2.max - params.spin2.min); - + /* spin2z */ LAL_CALL( LALUniformDeviate( status, &u, randParams ), status ); this_inj->spin2z = (u - 0.5) * 2 * (spin2Mag); - + r2 = pow( ((spin2Mag * spin2Mag) - (this_inj->spin2z * this_inj->spin2z)) , 0.5); - + /* phi2 */ LAL_CALL( LALUniformDeviate( status, &u, randParams ), status ); phi2 = u * LAL_TWOPI; - + /* spin2x and spin2y */ this_inj->spin2x = r2 * cos(phi2); this_inj->spin2y = r2 * sin(phi2); @@ -444,8 +445,8 @@ void LALSetSpin(LALStatus *status, /* TODO to check */ void LALSetDistance(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj) + InspiralInjectionParameters params, + SimInspiralTable *this_inj) { REAL4 u, deltaL, lmin,lmax, d3min,d3max,deltad3,d3, exponent; @@ -483,9 +484,9 @@ void LALSetDistance(LALStatus *status, void LALSetSpatialDistribution(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj - ) + InspiralInjectionParameters params, + SimInspiralTable *this_inj + ) { REAL4 u; @@ -518,8 +519,8 @@ void LALSetSpatialDistribution(LALStatus *status, void LALSetSiteParameters(LALStatus *status, - SimInspiralTable *this_inj) - + SimInspiralTable *this_inj) + { SkyPosition skyPos; LALSource source; @@ -567,13 +568,13 @@ void LALSetSiteParameters(LALStatus *status, /* lho */ placeAndGPS.p_detector = &lho; LAL_CALL( LALTimeDelayFromEarthCenter( status, &time_diff_ns, - &detTimeAndSource ), status ); + &detTimeAndSource ), status ); XLALGPSAdd( &(this_inj->h_end_time), time_diff_ns ); /* llo */ placeAndGPS.p_detector = &llo; LAL_CALL( LALTimeDelayFromEarthCenter( status, &time_diff_ns, - &detTimeAndSource ), status); + &detTimeAndSource ), status); XLALGPSAdd( &(this_inj->l_end_time), time_diff_ns ); /* temporarily, populate the fields for the */ @@ -600,23 +601,23 @@ void LALSetSiteParameters(LALStatus *status, detAndSource.pDetector = &lho; LAL_CALL( LALComputeDetAMResponse( status, &resp, &detAndSource, - &gpsAndAcc ), status ); + &gpsAndAcc ), status ); /* compute the effective distance for LHO */ this_inj->eff_dist_h /= sqrt( splus*splus*resp.plus*resp.plus + - scross*scross*resp.cross*resp.cross ); + scross*scross*resp.cross*resp.cross ); /* compute the response of the LLO detector */ detAndSource.pDetector = &llo; LAL_CALL( LALComputeDetAMResponse( status, &resp, &detAndSource, - &gpsAndAcc ), status); + &gpsAndAcc ), status); /* compute the effective distance for LLO */ this_inj->eff_dist_l /= sqrt( splus*splus*resp.plus*resp.plus - + scross*scross*resp.cross*resp.cross ); + + scross*scross*resp.cross*resp.cross ); /* temporarily, populate the fields for the */ /* GEO, TAMA and VIRGO effective distances */ @@ -634,13 +635,10 @@ void LALSetSiteParameters(LALStatus *status, void LALSetGeoCentricEndTime(LALStatus *status, - InspiralInjectionParameters params, - SimInspiralTable *this_inj) + InspiralInjectionParameters params, + SimInspiralTable *this_inj) { - LALGPSandAcc gpsAndAcc; REAL4 u; - LALMSTUnitsAndAcc gmstUnits = { MST_HRS, LALLEAPSEC_STRICT }; - /* set the geocentric end time of the injection */ /* XXX CHECK XXX */ @@ -650,25 +648,23 @@ void LALSetGeoCentricEndTime(LALStatus *status, LAL_CALL( LALUniformDeviate( status, &u, randParams ), status ); XLALGPSAdd( &(this_inj->geocent_end_time), u * params.timeInterval ); } - - gpsAndAcc.gps = this_inj->geocent_end_time; /* set gmst */ - LAL_CALL( LALGPStoGMST1( status, &(this_inj->end_time_gmst), - &(this_inj->geocent_end_time), &gmstUnits ), status); + this_inj->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &this_inj->geocent_end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + ASSERT( !XLAL_IS_REAL8_FAIL_NAN(this_inj->end_time_gmst), status, LAL_FAIL_ERR, LAL_FAIL_MSG ); } void LALParserInspiralInjection(LALStatus *status, - int argc, - char **argv, - InspiralInjectionParameters *params) + int argc, + char **argv, + InspiralInjectionParameters *params) { MetadataTable proctable; MetadataTable procparams; ProcessParamsTable *this_proc_param; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; int i; @@ -676,20 +672,20 @@ void LALParserInspiralInjection(LALStatus *status, /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - - LAL_CALL( LALGPSTimeNow ( status, &(proctable.processTable->start_time), &accuracy ), status); + + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) @@ -727,10 +723,10 @@ void LALParserInspiralInjection(LALStatus *status, params->ddistr = SPININJ_logDistance; params->userTag = NULL; snprintf( params->waveform, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR), - "EOBtwoPN"); + "EOBtwoPN"); snprintf( fname, sizeof(fname), "HL-INJECTIONS_%d-%d-%d.xml", - params->randSeed, params->gpsStartTime.gpsSeconds, - params->gpsEndTime.gpsSeconds - params->gpsStartTime.gpsSeconds ); + params->randSeed, params->gpsStartTime.gpsSeconds, + params->gpsEndTime.gpsSeconds - params->gpsStartTime.gpsSeconds ); /* Actual parsing is here; we do not check validity of the input arguments for the time being*/ @@ -739,185 +735,185 @@ void LALParserInspiralInjection(LALStatus *status, while (i < argc) { if ( (strcmp(argv[i], "--help") == 0) || (strcmp(argv[i], "-h") == 0) ){ - fprintf( stderr, USAGE ); - exit(1); + fprintf( stderr, USAGE ); + exit(1); } else if ( strcmp(argv[i], "--user-tag") == 0){ /* create storage for the usertag */ params->userTag = (CHAR *) calloc( strlen( argv[i+1] ) + 1, sizeof(CHAR) ); memcpy( params->userTag, argv[i+1], strlen( argv[i+1] ) + 1 ); this_proc_param = this_proc_param->next = - next_process_param( "user-tag", "string", "%s", argv[i+1] ); - i++; + next_process_param( "user-tag", "string", "%s", argv[i+1] ); + i++; } - else if ( strcmp(argv[i], "--gps-start-time") == 0){ - params->gpsStartTime.gpsSeconds = atol(argv[++i]); - this_proc_param = this_proc_param->next = + else if ( strcmp(argv[i], "--gps-start-time") == 0){ + params->gpsStartTime.gpsSeconds = atol(argv[++i]); + this_proc_param = this_proc_param->next = next_process_param( "gps-start-time", "int", "%ld", params->gpsStartTime.gpsSeconds); } else if ( strcmp(argv[i], "--gps-end-time") == 0){ - params->gpsEndTime.gpsSeconds = atol(argv[++i]); - this_proc_param = this_proc_param->next = + params->gpsEndTime.gpsSeconds = atol(argv[++i]); + this_proc_param = this_proc_param->next = next_process_param( "gps-end-time", "int", "%ld", params->gpsEndTime.gpsSeconds ); } else if ( strcmp(argv[i], "--seed") == 0){ - params->randSeed = atoi( argv[++i]); + params->randSeed = atoi( argv[++i]); this_proc_param = this_proc_param->next = next_process_param( "seed", "int", "%d", params->randSeed ); } else if ( strcmp(argv[i] , "--time-interval") == 0 ){ - params->timeInterval = atof( argv[++i] ); + params->timeInterval = atof( argv[++i] ); this_proc_param = this_proc_param->next = next_process_param( "time-interval", "float", "%le", params->timeInterval ); } else if ( strcmp(argv[i] , "--time-step") == 0 ){ - params->meanTimeStep = atof( argv[++i] ); - this_proc_param = this_proc_param->next = + params->meanTimeStep = atof( argv[++i] ); + this_proc_param = this_proc_param->next = next_process_param( "time-step", "float", "%le", params->meanTimeStep ); } else if ( strcmp(argv[i] , "--coa-phase-min") == 0 ){ - params->coa_phase.min = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "coa-phase-min", "float", "%le", params->coa_phase.min ); + params->coa_phase.min = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "coa-phase-min", "float", "%le", params->coa_phase.min ); } else if ( strcmp(argv[i] , "--coa-phase-max") == 0 ){ - params->coa_phase.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "coa-phase-max", "float", "%le", params->coa_phase.max ); + params->coa_phase.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "coa-phase-max", "float", "%le", params->coa_phase.max ); } else if ( strcmp(argv[i] , "--coa-phase-range") == 0 ){ - params->coa_phase.min = atof( argv[++i] ); - params->coa_phase.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "coa-phase-min", "float", "%le", params->coa_phase.min ); - this_proc_param = this_proc_param->next = - next_process_param( "coa-phase-max", "float", "%le", params->coa_phase.max ); + params->coa_phase.min = atof( argv[++i] ); + params->coa_phase.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "coa-phase-min", "float", "%le", params->coa_phase.min ); + this_proc_param = this_proc_param->next = + next_process_param( "coa-phase-max", "float", "%le", params->coa_phase.max ); } else if ( strcmp(argv[i] , "--mass1-min") == 0 ){ - params->m1.min = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "mass1-min", "float", "%le", params->m1.min ); + params->m1.min = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "mass1-min", "float", "%le", params->m1.min ); } else if ( strcmp(argv[i] , "--mass1-max") == 0 ){ - params->m1.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "mass1-max", "float", "%le", params->m1.max ); + params->m1.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "mass1-max", "float", "%le", params->m1.max ); } else if ( strcmp(argv[i] , "--mass1-range") == 0 ){ - params->m1.min = atof( argv[++i] ); - params->m1.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "mass1-min", "float", "%le", params->m1.min ); - this_proc_param = this_proc_param->next = - next_process_param( "mass1-max", "float", "%le", params->m1.max ); + params->m1.min = atof( argv[++i] ); + params->m1.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "mass1-min", "float", "%le", params->m1.min ); + this_proc_param = this_proc_param->next = + next_process_param( "mass1-max", "float", "%le", params->m1.max ); } else if ( strcmp(argv[i] , "--fLower") == 0 ){ - params->fLower = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "fLower", "float", "%le", params->fLower ); + params->fLower = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "fLower", "float", "%le", params->fLower ); } else if ( strcmp(argv[i] , "--mass2-min") == 0 ){ - params->m2.min = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "mass2-min", "float", "%le", params->m2.min ); + params->m2.min = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "mass2-min", "float", "%le", params->m2.min ); } else if ( strcmp(argv[i] , "--mass2-max") == 0 ){ - params->m2.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "mass2-max", "float", "%le", params->m2.max ); + params->m2.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "mass2-max", "float", "%le", params->m2.max ); } else if ( strcmp(argv[i] , "--mass2-range") == 0 ){ - params->m2.min = atof( argv[++i] ); - params->m2.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "mass2-min", "float", "%le", params->m2.min ); - this_proc_param = this_proc_param->next = - next_process_param( "mass2-max", "float", "%le", params->m2.max ); + params->m2.min = atof( argv[++i] ); + params->m2.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "mass2-min", "float", "%le", params->m2.min ); + this_proc_param = this_proc_param->next = + next_process_param( "mass2-max", "float", "%le", params->m2.max ); } else if ( strcmp(argv[i] , "--distance-min") == 0 ){ - params->distance.min = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "distance-min", "float", "%le", params->distance.min ); + params->distance.min = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "distance-min", "float", "%le", params->distance.min ); } else if ( strcmp(argv[i] , "--distance-max") == 0 ){ - params->distance.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "distance-max", "float", "%le", params->distance.max ); + params->distance.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "distance-max", "float", "%le", params->distance.max ); } else if ( strcmp(argv[i] , "--distance-range") == 0 ){ - params->distance.min = atof( argv[++i] ); - params->distance.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "distance-min", "float", "%le", params->distance.min ); - this_proc_param = this_proc_param->next = - next_process_param( "distance-max", "float", "%le", params->distance.max ); + params->distance.min = atof( argv[++i] ); + params->distance.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "distance-min", "float", "%le", params->distance.min ); + this_proc_param = this_proc_param->next = + next_process_param( "distance-max", "float", "%le", params->distance.max ); } else if ( strcmp(argv[i] , "--spin1-min") == 0 ){ - params->spin1.min = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "spin1-min", "float", "%le", params->spin1.min ); + params->spin1.min = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "spin1-min", "float", "%le", params->spin1.min ); } else if ( strcmp(argv[i] , "--spin2-min") == 0 ){ - params->spin2.min = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "spin2-min", "float", "%le", params->spin2.min ); + params->spin2.min = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "spin2-min", "float", "%le", params->spin2.min ); } else if ( strcmp(argv[i] , "--spin1-max") == 0 ){ - params->spin1.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "spin1-max", "float", "%le", params->spin1.max ); + params->spin1.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "spin1-max", "float", "%le", params->spin1.max ); } else if ( strcmp(argv[i] , "--spin2-max") == 0 ){ - params->spin2.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "spin2-max", "float", "%le", params->spin2.max ); + params->spin2.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "spin2-max", "float", "%le", params->spin2.max ); } else if ( strcmp(argv[i] , "--spin1-range") == 0 ){ - params->spin1.min = atof( argv[++i] ); - params->spin1.max = atof( argv[++i] ); - - this_proc_param = this_proc_param->next = - next_process_param( "spin1-min", "float", "%le", params->spin1.min ); - this_proc_param = this_proc_param->next = - next_process_param( "spin1-max", "float", "%le", params->spin1.max ); + params->spin1.min = atof( argv[++i] ); + params->spin1.max = atof( argv[++i] ); + + this_proc_param = this_proc_param->next = + next_process_param( "spin1-min", "float", "%le", params->spin1.min ); + this_proc_param = this_proc_param->next = + next_process_param( "spin1-max", "float", "%le", params->spin1.max ); } else if ( strcmp(argv[i] , "--spin2-range") == 0 ){ - params->spin2.min = atof( argv[++i] ); - params->spin2.max = atof( argv[++i] ); + params->spin2.min = atof( argv[++i] ); + params->spin2.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "spin2-min", "float", "%le", params->spin2.min ); - this_proc_param = this_proc_param->next = - next_process_param( "spin2-max", "float", "%le", params->spin2.max ); + this_proc_param = this_proc_param->next = + next_process_param( "spin2-min", "float", "%le", params->spin2.min ); + this_proc_param = this_proc_param->next = + next_process_param( "spin2-max", "float", "%le", params->spin2.max ); } else if ( strcmp(argv[i] , "--inclination-min") == 0 ){ - params->inclination.min = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "inclination-min", "float", "%le", params->inclination.min ); + params->inclination.min = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "inclination-min", "float", "%le", params->inclination.min ); } else if ( strcmp(argv[i] , "--inclination-max") == 0 ){ - params->inclination.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "inclination-max", "float", "%le", params->inclination.max ); + params->inclination.max = atof( argv[++i] ); + this_proc_param = this_proc_param->next = + next_process_param( "inclination-max", "float", "%le", params->inclination.max ); } else if ( strcmp(argv[i] , "--inclination-range") == 0 ){ - params->inclination.min = atof( argv[++i] ); - params->inclination.max = atof( argv[++i] ); + params->inclination.min = atof( argv[++i] ); + params->inclination.max = atof( argv[++i] ); - this_proc_param = this_proc_param->next = - next_process_param( "inclination-min", "float", "%le", params->inclination.min ); - this_proc_param = this_proc_param->next = - next_process_param( "inclination-max", "float", "%le", params->inclination.max ); + this_proc_param = this_proc_param->next = + next_process_param( "inclination-min", "float", "%le", params->inclination.min ); + this_proc_param = this_proc_param->next = + next_process_param( "inclination-max", "float", "%le", params->inclination.max ); } else if ( strcmp(argv[i] , "--waveform") == 0 ){ - snprintf( params->waveform, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR), "%s", - argv[++i]); + snprintf( params->waveform, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR), "%s", + argv[++i]); this_proc_param = this_proc_param->next = next_process_param( "waveform", "string", - "%s",argv[i] ); + "%s",argv[i] ); } else if ( strcmp(argv[i] , "--mass-distr") == 0 ){ - if ( ! strcmp( "SPININJ_m1Andm2", argv[++i] ) ) + if ( ! strcmp( "SPININJ_m1Andm2", argv[++i] ) ) { params->mdistr = SPININJ_m1Andm2; } @@ -932,7 +928,7 @@ void LALParserInspiralInjection(LALStatus *status, } this_proc_param = this_proc_param->next = next_process_param( "mass-distr", "string", - "%s",argv[i] ); + "%s",argv[i] ); } else if ( strcmp(argv[i] , "--dist-distr") == 0 ){ if ( ! strcmp( "SPININJ_distance", argv[++i] ) ) @@ -957,18 +953,18 @@ void LALParserInspiralInjection(LALStatus *status, "%s",argv[i] ); } else { - fprintf(stderr, "option %s unknown !!! abort\n", argv[i]); - exit(1); + fprintf(stderr, "option %s unknown !!! abort\n", argv[i]); + exit(1); } - + i++; } if (params->userTag){ snprintf( fname, sizeof(fname), "HL-INJECTIONS_%d_%s-%d-%d.xml", - params->randSeed, params->userTag, params->gpsStartTime.gpsSeconds, - params->gpsEndTime.gpsSeconds - params->gpsStartTime.gpsSeconds ); + params->randSeed, params->userTag, params->gpsStartTime.gpsSeconds, + params->gpsEndTime.gpsSeconds - params->gpsStartTime.gpsSeconds ); } /* Let us check now the validity of the arguments */ @@ -983,13 +979,13 @@ void LALParserInspiralInjection(LALStatus *status, /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" ); - LAL_CALL( LALGPSTimeNow ( status, &(proctable.processTable->end_time), &accuracy ), status); - + XLALGPSTimeNow(&(proctable.processTable->end_time)); + LAL_CALL( LALBeginLIGOLwXMLTable( status, &xmlfp, process_table ),status), LAL_CALL( LALWriteLIGOLwXMLTable( status, &xmlfp, proctable, - process_table ), status ); + process_table ), status ); LAL_CALL( LALEndLIGOLwXMLTable ( status, &xmlfp ), status ); @@ -1025,150 +1021,150 @@ void LALParserInspiralInjection(LALStatus *status, void LALCheckInspiralInjectionParameters(LALStatus *status, - InspiralInjectionParameters params) + InspiralInjectionParameters params) { LALGPSCompareResult compareGPS; - if ( params.fLower <= 5 || params.fLower >=1000) + if ( params.fLower <= 5 || params.fLower >=1000) { fprintf( stderr, "invalid argument to --%s:\n" - "fLower should not be less than 5Hz or greater than 1000Hz " - "(%f specified)\n", - "fLower", params.fLower ); + "fLower should not be less than 5Hz or greater than 1000Hz " + "(%f specified)\n", + "fLower", params.fLower ); exit( 1 ); } if ( params.gpsStartTime.gpsSeconds < 441417609 ) { fprintf( stderr, "invalid argument to --%s:\n" - "GPS start time is prior to " - "Jan 01, 1994 00:00:00 UTC:\n" - "(%d specified)\n", - "gps-start-time", params.gpsStartTime.gpsSeconds ); + "GPS start time is prior to " + "Jan 01, 1994 00:00:00 UTC:\n" + "(%d specified)\n", + "gps-start-time", params.gpsStartTime.gpsSeconds ); exit( 1 ); } if ( params.gpsStartTime.gpsSeconds > 999999999 ) { fprintf( stderr, "invalid argument to --%s:\n" - "GPS start time is after " - "Sep 14, 2011 01:46:26 UTC:\n" - "(%d specified)\n", - "gps-start-time", params.gpsStartTime.gpsSeconds); + "GPS start time is after " + "Sep 14, 2011 01:46:26 UTC:\n" + "(%d specified)\n", + "gps-start-time", params.gpsStartTime.gpsSeconds); exit( 1 ); } /* check that the start time is before the end time */ LAL_CALL( LALCompareGPS( status, &compareGPS, &(params.gpsStartTime), &(params.gpsEndTime)) , - status ); + status ); if ( params.gpsEndTime.gpsSeconds > 999999999 ) { fprintf( stderr, "invalid argument to --%s:\n" - "GPS End time is after " - "Sep 14, 2011 01:46:26 UTC:\n" - "(%d specified)\n", - "gps-end-time", params.gpsEndTime.gpsSeconds ); + "GPS End time is after " + "Sep 14, 2011 01:46:26 UTC:\n" + "(%d specified)\n", + "gps-end-time", params.gpsEndTime.gpsSeconds ); exit( 1 ); } if ( params.meanTimeStep <= 0 ) { fprintf( stderr, "invalid argument to --%s:\n" - "time step must be > 0: (%e seconds specified)\n", - "mean-time", params.meanTimeStep ); + "time step must be > 0: (%e seconds specified)\n", + "mean-time", params.meanTimeStep ); exit( 1 ); } if ( params.timeInterval < 0 ) { fprintf( stderr, "invalid argument to --%s:\n" - "time interval must be >= 0: (%e seconds specified)\n", - "time-interval", params.timeInterval ); + "time interval must be >= 0: (%e seconds specified)\n", + "time-interval", params.timeInterval ); exit( 1 ); } if ( params.m1.min < 0 || params.m2.max < 0 ) { fprintf( stderr, "invalid argument to --%s:\n" - "miniumum component mass must be > 0: \n", - "mass-range" ); + "miniumum component mass must be > 0: \n", + "mass-range" ); exit( 1 ); } if ( params.m1.min > params.m1.max ) { fprintf( stderr, "invalid argument to --%s:\n" - "minimum component (%f) mass must be < maximum component (%f) : \n", - "mass-range", params.m1.min, params.m1.max); + "minimum component (%f) mass must be < maximum component (%f) : \n", + "mass-range", params.m1.min, params.m1.max); exit( 1 ); } if ( params.m2.min > params.m2.max ) { fprintf( stderr, "invalid argument to --%s:\n" - "minimum component (%f) mass must be < maximum component (%f) : \n", - "mass-range", params.m2.min, params.m2.max); + "minimum component (%f) mass must be < maximum component (%f) : \n", + "mass-range", params.m2.min, params.m2.max); exit( 1 ); } if ( params.distance.min <= 0) { fprintf( stderr, "invalid argument to --%s:\n" - "minimum distance must be > 0: " - "(%f kpc specified)\n", "distance-range",params.distance.min); + "minimum distance must be > 0: " + "(%f kpc specified)\n", "distance-range",params.distance.min); exit( 1 ); } if ( params.distance.max < params.distance.min) { fprintf( stderr, "invalid argument to --%s:\n" - "maximum distance max (%f) must be > distance min (%f)", - "distance-range",params.distance.max, params.distance.min); + "maximum distance max (%f) must be > distance min (%f)", + "distance-range",params.distance.max, params.distance.min); exit( 1 ); } if ( params.coa_phase.max < params.coa_phase.min) { fprintf( stderr, "invalid argument to --%s:\n" - "maximum coa_phase max (%f) must be > coa_phase min (%f)", - "coa-phase-range",params.coa_phase.max, params.coa_phase.min); + "maximum coa_phase max (%f) must be > coa_phase min (%f)", + "coa-phase-range",params.coa_phase.max, params.coa_phase.min); exit( 1 ); } - if ( params.spin1.min < 0 || params.spin1.max < 0) + if ( params.spin1.min < 0 || params.spin1.max < 0) { fprintf( stderr, "invalid argument to --%s:\n" "spin1-min (%f) and spin1-max (%f) must be > 0 \n", "spin1-min or spin1-max",params.spin1.min, params.spin1.max); - + exit( 1 ); } - if ( params.spin1.max < params.spin1.min) + if ( params.spin1.max < params.spin1.min) { fprintf( stderr, "invalid argument to --%s:\n" "spin1-min (%f) must be < spin1-max (%f) \n", "spin1-min or spin1-max",params.spin1.min, params.spin1.max); - + exit( 1 ); } - if ( params.spin2.min < 0 || params.spin2.max < 0) + if ( params.spin2.min < 0 || params.spin2.max < 0) { fprintf( stderr, "invalid argument to --%s:\n" "spin2-min (%f) and spin2-max (%f) must be > 0 \n", "spin2-min or spin2-max",params.spin2.min, params.spin2.max); - + exit( 1 ); } - - if ( params.spin2.max < params.spin2.min) + + if ( params.spin2.max < params.spin2.min) { fprintf( stderr, "invalid argument to --%s:\n" "spin2-min (%f) must be < spin2-max (%f) \n", "spin2-min or spin2-max",params.spin2.min, params.spin2.max); - + exit( 1 ); } - if ( params.inclination.max > LAL_PI) + if ( params.inclination.max > LAL_PI) { fprintf( stderr, "invalid argument to --%s:\n" "inclination-max (%f) must be < pi \n", @@ -1177,7 +1173,7 @@ void LALCheckInspiralInjectionParameters(LALStatus *status, exit( 1 ); } - if ( params.inclination.min < 0.01) + if ( params.inclination.min < 0.01) { fprintf( stderr, "invalid argument to --%s:\n" "inclination-min (%f) must be > 0.01 \n", @@ -1186,7 +1182,7 @@ void LALCheckInspiralInjectionParameters(LALStatus *status, exit( 1 ); } - if ( params.inclination.max < params.inclination.min) + if ( params.inclination.max < params.inclination.min) { fprintf( stderr, "invalid argument to --%s:\n" "inclination-min (%f) must be < inclination-max (%f) \n", diff --git a/lalapps/src/inspiral/splitbank.c b/lalapps/src/inspiral/splitbank.c index fc25a304f1b39f1aa55795e9ca801ca8b1876061..3eb2d241f50205306880f6c15230a874e9951e28 100644 --- a/lalapps/src/inspiral/splitbank.c +++ b/lalapps/src/inspiral/splitbank.c @@ -82,7 +82,6 @@ int main ( int argc, char *argv[] ) { /* lal function variables */ LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* template bank generation parameters */ CHAR *bankFileName = NULL; @@ -142,20 +141,19 @@ int main ( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -310,7 +308,7 @@ int main ( int argc, char *argv[] ) fprintf( stdout, "Inspiral Template Bank Splitter\n" "Duncan Brown <duncan@gravity.phys.uwm.edu>\n" "CVS Version: " CVS_ID_STRING "\n" ); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -434,8 +432,7 @@ int main ( int argc, char *argv[] ) fprintf( stdout, "writing templates to %s... ", outBankFileName ); /* write process table */ - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/thinca.c b/lalapps/src/inspiral/thinca.c index 64dd1d245df7d243cd08e60a76afff64b51ce03b..ee20e8467575cfe8f3963434c7d7085f9c758a65 100644 --- a/lalapps/src/inspiral/thinca.c +++ b/lalapps/src/inspiral/thinca.c @@ -245,7 +245,6 @@ fprintf( a, "[LIGOLW XML input files] list of the input trigger files.\n");\ int main( int argc, char *argv[] ) { static LALStatus status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; extern int vrbflg; @@ -469,8 +468,7 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION, "$Revi" "sion$")) { XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, @@ -1002,6 +1000,7 @@ int main( int argc, char *argv[] ) "Steve Fairhurst\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -1196,7 +1195,7 @@ int main( int argc, char *argv[] ) sourceFile = (CHAR *) calloc( optarg_len, sizeof(CHAR) ); memcpy( sourceFile, optarg, optarg_len ); ADD_PROCESS_PARAM( "string", "%s", optarg ); - accuracyParams.exttrig=1; + accuracyParams.exttrig=1; break; default: @@ -2271,8 +2270,7 @@ cleanexit: snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, ifos ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/tmpltbank.c b/lalapps/src/inspiral/tmpltbank.c index a098da8ae396952abaac703787e067f702be3b2a..a4632177239eb026ba0d1f32d64669bae8386fd2 100644 --- a/lalapps/src/inspiral/tmpltbank.c +++ b/lalapps/src/inspiral/tmpltbank.c @@ -151,8 +151,8 @@ REAL4 psi0Max = 0; /* maximum value of psi0 */ REAL4 psi3Min = 0; /* minimum value of psi3 */ REAL4 psi3Max = 0; /* maximum value of psi3 */ REAL4 alpha = 0; /* BCV amplitude correction */ -REAL4 betaMin = 0; /* minimum BCV spin parameter */ -REAL4 betaMax = 0; /* maximum BCV spin parameter */ +REAL4 betaMin = 0; /* minimum BCV spin parameter */ +REAL4 betaMax = 0; /* maximum BCV spin parameter */ INT4 maxFcutTmplts = -1; /* num tmplts in fcut direction */ REAL4 minMatch = -1; /* minimum requested match */ REAL4 fUpper = -1; /* upper frequency cutoff */ @@ -160,8 +160,8 @@ REAL4 chiMin = 0.0; /* minimum value of chi for PTF */ REAL4 chiMax = 1.0; /* maximum value of chi for PTF */ REAL4 kappaMin = -1.0; /* minimum value of kappa for PTF */ REAL4 kappaMax = 1.0; /* maximum value of kappa for PTF */ -INT4 nPointsChi = 3; /* PTF template bank density */ -INT4 nPointsKappa = 5; /* PTF templated bank density */ +INT4 nPointsChi = 3; /* PTF template bank density */ +INT4 nPointsKappa = 5; /* PTF templated bank density */ LALPNOrder order; /* post-Newtonian order */ Approximant approximant; /* approximation method */ CoordinateSpace space; /* coordinate space used */ @@ -179,9 +179,9 @@ INT4 unitResponse = 0; /* set the response to unity */ /* standard candle parameters */ INT4 computeCandle = 0; /* should we compute a candle? */ -REAL4 candleSnr = -1; /* candle signal to noise ratio */ -REAL4 candleMass1 = -1; /* standard candle mass (solar) */ -REAL4 candleMass2 = -1; /* standard candle mass (solar) */ +REAL4 candleSnr = -1; /* candle signal to noise ratio */ +REAL4 candleMass1 = -1; /* standard candle mass (solar) */ +REAL4 candleMass2 = -1; /* standard candle mass (solar) */ /* TD follow up filenames */ CHAR **tdFileNames = NULL; @@ -194,7 +194,7 @@ int writeRawData = 0; /* write the raw data to a file */ int writeResponse = 0; /* write response function used */ int writeSpectrum = 0; /* write computed psd to file */ int writeStrainSpec = 0; /* write computed stain spec */ -INT4 outCompress = 0; +INT4 outCompress = 0; /* other command line args */ CHAR comment[LIGOMETA_COMMENT_MAX]; /* process param comment */ @@ -203,7 +203,6 @@ int main ( int argc, char *argv[] ) { /* lal function variables */ LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* frame input data */ FrCache *frInCache = NULL; @@ -282,20 +281,19 @@ int main ( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -1186,8 +1184,7 @@ cleanExit: /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFO_MAX, "%s", ifo ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &results, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &results, proctable, @@ -1362,8 +1359,8 @@ fprintf(a, " --maximum-psi3 PSI3 set maximum range of BCV parameter ps fprintf(a, " --maximum-fcut-tmplts N maximum number of tmplts in fcut direction is N\n");\ fprintf(a, " --disable-polygon-fit disable the polygon fitting for BCV bank\n");\ fprintf(a, " --alpha ALPHA set alpha for the BCV bank generation\n");\ -fprintf(a, " --minimum-beta BETA set minimum BCV spin parameter beta to BETA\n");\ -fprintf(a, " --maximum-beta BETA set maximum BCV spin parameter beta to BETA\n");\ +fprintf(a, " --minimum-beta BETA set minimum BCV spin parameter beta to BETA\n");\ +fprintf(a, " --maximum-beta BETA set maximum BCV spin parameter beta to BETA\n");\ fprintf(a, "\n");\ fprintf(a, " --minimum-spin1 SPIN1_MIN set minimum value of chi for PTF to SPIN1_MIN (0.0)\n");\ fprintf(a, " --maximum-spin1 SPIN1_MAX set maximum value of chi for PTF to SPIN1_MAX (1.0)\n");\ @@ -1445,8 +1442,8 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) {"minimum-psi3", required_argument, 0, 'R'}, {"maximum-psi3", required_argument, 0, 'S'}, {"maximum-fcut-tmplts", required_argument, 0, 'U'}, - {"minimum-beta", required_argument, 0, 'o'}, - {"maximum-beta", required_argument, 0, 'O'}, + {"minimum-beta", required_argument, 0, 'o'}, + {"maximum-beta", required_argument, 0, 'O'}, {"alpha", required_argument, 0, 'T'}, {"minimum-spin1", required_argument, 0, '4'}, {"maximum-spin1", required_argument, 0, '5'}, @@ -1466,8 +1463,8 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) {"max-total-mass", required_argument, 0, 'y'}, {"min-total-mass", required_argument, 0, 'W'}, {"chirp-mass-cutoff", required_argument, 0, 'q'}, - {"disable-polygon-fit", no_argument, &polygonFit, 0 }, - {"disable-compute-moments", no_argument, &computeMoments, 0 }, + {"disable-polygon-fit", no_argument, &polygonFit, 0 }, + {"disable-compute-moments", no_argument, &computeMoments, 0 }, /* standard candle parameters */ {"candle-snr", required_argument, 0, 'k'}, {"candle-mass1", required_argument, 0, 'l'}, @@ -2310,7 +2307,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) optind++; } - break; + break; case 'Y': /* create storaged for the ifo-tag */ @@ -2326,6 +2323,7 @@ int arg_parse_check( int argc, char *argv[], MetadataTable procparams ) "Duncan Brown <duncan@gravity.phys.uwm.edu>\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; diff --git a/lalapps/src/inspiral/trigbank.c b/lalapps/src/inspiral/trigbank.c index 9ebc5e5bbd66d0e6db9cf6baa08d9dfeee7862c4..823f5088117f4724d0cedcc4e377d8e25f5c4a90 100644 --- a/lalapps/src/inspiral/trigbank.c +++ b/lalapps/src/inspiral/trigbank.c @@ -113,7 +113,6 @@ static void print_usage(char *program) int main( int argc, char *argv[] ) { static LALStatus status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; extern int vrbflg; LALPlaygroundDataMask dataType = unspecified_data_type; @@ -188,20 +187,19 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, CVS_REVISION, - CVS_SOURCE, CVS_DATE ), &status ); + PROGRAM_NAME, CVS_REVISION, + CVS_SOURCE, CVS_DATE ), &status ); } else { LAL_CALL( populate_process_table( &status, proctable.processTable, - PROGRAM_NAME, lalappsGitCommitID, - lalappsGitGitStatus, - lalappsGitCommitDate ), &status ); + PROGRAM_NAME, lalappsGitCommitID, + lalappsGitGitStatus, + lalappsGitCommitDate ), &status ); } this_proc_param = processParamsTable.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); @@ -424,7 +422,7 @@ int main( int argc, char *argv[] ) "Patrick Brady, Duncan Brown and Steve Fairhurst\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n"); - fprintf( stdout, lalappsGitID ); + fprintf( stdout, lalappsGitID ); exit( 0 ); break; @@ -671,8 +669,7 @@ cleanexit: /* write process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "%s", inputIFO ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/inspiral/trigger_hipe.in b/lalapps/src/inspiral/trigger_hipe.in index 032ec5ae1e51b97f5d664eb49893a49568085914..a145cd877de8cc5a669f694bc2969b50bb29ef29 100755 --- a/lalapps/src/inspiral/trigger_hipe.in +++ b/lalapps/src/inspiral/trigger_hipe.in @@ -530,6 +530,8 @@ parser.add_option("-g","--injection-config",action="store",type="string",\ default=None, metavar=" FILE", help="use configuration file FILE" ) parser.add_option("-p", "--log-path",action="store",type="string",\ metavar=" PATH",help="directory to write condor log file") +parser.add_option("-u","--user-tag",action="store",type="string",\ + default=None, help="user defined tag for naming the DAG file" ) # Add some extra capabilities parser.add_option("", "--skip-datafind", action="store_false", default=True, @@ -537,6 +539,10 @@ parser.add_option("", "--skip-datafind", action="store_false", default=True, "the file caches in ./GRBxxxxxx/datafind/cache).") parser.add_option("", "--skip-dataquality", action="store_false", default=True, dest="do_dataquality", help="skip a query for data quality") +parser.add_option("", "--skip-onsource", action="store_false", default=True, + dest="do_onsource", help="skip the onsource DAG") +parser.add_option("", "--skip-offsource", action="store_false", default=True, + dest="do_offsource", help="skip the offsource DAG") ( opts , args ) = parser.parse_args() @@ -659,6 +665,8 @@ if opts.do_dataquality: # set up the über dag for all intervals and all injections tag = opts.config_file.rstrip(".ini") +if opts.user_tag: + tag += '_'+opts.user_tag uberdag = pipeline.CondorDAG("%s/%s_uberdag.log" % (opts.log_path, tag)) uberdag.set_dag_file("%s_uberdag" % tag) ligolwdag = pipeline.CondorDAG("%s/%s_ligolwdag.log" % (opts.log_path, tag)) @@ -776,39 +784,41 @@ for grb in ext_trigs: # the other nodes will try to use datafind_node as a parent; set to None. datafind_node = None - if opts.verbose: print "Creating DAG for offsource analysis" - offsource_analysis = hipe_run(idirectory + "/offsource", cp, grb_ifolist, + if opts.do_offsource: + if opts.verbose: print "Creating DAG for offsource analysis" + offsource_analysis = hipe_run(idirectory + "/offsource", cp, grb_ifolist, opts.log_path, source_file, "offsource", offSourceSegment, exttrig_seg = '../../'+buffer_segfile, usertag=idirectory + "_OFFSOURCE_CATEGORY_1", exttrig_analyze="off_source", verbose=opts.verbose, dont_run=["datafind"]) - offsource_node = offsource_analysis.finalize(uberdag=uberdag, - parent=datafind_node) - hipe_caches.append(offsource_analysis.get_cache_name()) - if opts.do_dataquality: - for cat, subdict in veto_filename_dict.iteritems(): - dq_analysis = make_dq_run(offsource_analysis, subdict, cat) - dq_analysis_node = dq_analysis.finalize(uberdag=uberdag, - parent=offsource_node) - hipe_caches.append(dq_analysis.get_cache_name()) + offsource_node = offsource_analysis.finalize(uberdag=uberdag, + parent=datafind_node) + hipe_caches.append(offsource_analysis.get_cache_name()) + if opts.do_dataquality: + for cat, subdict in veto_filename_dict.iteritems(): + dq_analysis = make_dq_run(offsource_analysis, subdict, cat) + dq_analysis_node = dq_analysis.finalize(uberdag=uberdag, + parent=offsource_node) + hipe_caches.append(dq_analysis.get_cache_name()) - if opts.verbose: print "Creating DAG for onsource analysis" - onsource_analysis = hipe_run(idirectory + "/onsource", cp, grb_ifolist, + if opts.do_onsource: + if opts.verbose: print "Creating DAG for onsource analysis" + onsource_analysis = hipe_run(idirectory + "/onsource", cp, grb_ifolist, opts.log_path, source_file, "onsource", onSourceSegment, exttrig_analyze="on_source", exttrig_seg = '../../'+onsource_segfile, usertag=idirectory + "_ONSOURCE_CATEGORY_1", verbose=opts.verbose, dont_run=["datafind"]) - onsource_node = onsource_analysis.finalize(uberdag=uberdag, - parent=datafind_node) - hipe_caches.append(onsource_analysis.get_cache_name()) - if opts.do_dataquality: - for cat, subdict in veto_filename_dict.iteritems(): - dq_analysis = make_dq_run(onsource_analysis, subdict, cat) - dq_analysis_node = dq_analysis.finalize(uberdag=uberdag, + onsource_node = onsource_analysis.finalize(uberdag=uberdag, + parent=datafind_node) + hipe_caches.append(onsource_analysis.get_cache_name()) + if opts.do_dataquality: + for cat, subdict in veto_filename_dict.iteritems(): + dq_analysis = make_dq_run(onsource_analysis, subdict, cat) + dq_analysis_node = dq_analysis.finalize(uberdag=uberdag, parent=onsource_node) - hipe_caches.append(dq_analysis.get_cache_name()) + hipe_caches.append(dq_analysis.get_cache_name()) ############################################################################ # create the config parser object and read in the ini file @@ -886,7 +896,10 @@ for grb in ext_trigs: # add these two files to the regular main cache hipe_caches.append(ligolw_added_cache_filename) - grb_cache_name = idirectory + "/" + idirectory + ".cache" + if opts.user_tag: + grb_cache_name = idirectory + "/" + idirectory +"_"+ opts.cache_tag+".cache" + else: + grb_cache_name = idirectory + "/" + idirectory + ".cache" concatenate_files(hipe_caches, grb_cache_name) grb_caches.append(grb_cache_name) diff --git a/lalapps/src/inspiral/write_ihope_page.in b/lalapps/src/inspiral/write_ihope_page.in index 0064b5707c543c5e5b8acd200adf230c8ba1009f..0458bf08d937ea04819826d5d15a48194b60ac28 100755 --- a/lalapps/src/inspiral/write_ihope_page.in +++ b/lalapps/src/inspiral/write_ihope_page.in @@ -97,7 +97,7 @@ def functionId(nFramesUp): if msg.startswith("?") is False: print "-->ERROR in function: " + msg except: - msg=[] + msg="?" return msg @@ -131,7 +131,7 @@ def logText(logfile, text, tag="done"): logfile.write("</"+tag+">\n") msg=[] i=i+1 - print >>sys.stderr, msg + print >>sys.stderr, text else : msg = "<"+tag+">"+text+"</"+tag+">\n" logfile.write( msg ) @@ -277,21 +277,29 @@ def write_results(page, opts, section,injection=None): elif section=='datainfo': page = write_datainfo(page, opts) elif section=='playsummary': - page = write_summary(page,opts,thisSearch='playground',injection='allinj') + page = write_summary(page,opts,thisSearch='playground',injection='allinj', + pipedown='pipedown') elif section=='fullsummary': - page = write_summary(page,opts,thisSearch='full_data',injection='allinj') + page = write_summary(page,opts,thisSearch='full_data',injection='allinj', + pipedown='pipedown') + elif section=='play_full_slide_summary': + page = write_summary(page,opts,thisSearch='full_data_slide', + injection='allinj',pipedown='pipedown') elif section=='playground': - page = write_analysis(page, opts,thisSearch='playground') + page = write_analysis(page, opts,thisSearch='playground', + pipedown='pipedown') elif section=='full_data_slide': - page = write_analysis(page, opts,thisSearch='full_data_slide') + page = write_analysis(page, opts,thisSearch='full_data_slide', + pipedown='pipedown') elif section in hipecp.options("injections"): - page = write_injection(page, opts,section) + page = write_injection(page, opts,section,pipedown='pipedown') elif section=='allinj': - page = write_injection(page, opts,section) + page = write_injection(page, opts,section,pipedown='pipedown') elif section=='hardware_injections': page = write_injection(page, opts,section) elif section=='full_data': - page=write_analysis(page,opts,thisSearch='full_data') + page=write_analysis(page,opts,thisSearch='full_data', + pipedown='pipedown') elif section=='upperlimit': page = write_upperlimit(page, opts) elif section=='summary_files': @@ -462,7 +470,8 @@ def write_table(page, segs, keys,printKeys = True): return page # *************************************************************************** -def write_summary(page,opts,thisSearch='playground',injection = 'allinj'): +def write_summary(page,opts,thisSearch='playground',injection = 'allinj', + pipedown = 'pipedown'): """ Creates the summary section. @@ -481,14 +490,18 @@ def write_summary(page,opts,thisSearch='playground',injection = 'allinj'): page.add(msg) if thisSearch=='playground': ZLdir='playground_summary_plots/' + ifartag=['PLAYGROUND','PLAYGROUND','CLOSED_BOX'] elif thisSearch=='full_data_slide': ZLdir='full_data_slide_summary_plots/' + ifartag=['FULL_DATA','PLAYGROUND','CLOSED_BOX'] elif thisSearch=='full_data': ZLdir='full_data_summary_plots/' + ifartag=['FULL_DATA','ALL_DATA','OPEN_BOX'] else: print 'Error in write_analysis function: thisSearch is not valid' sys.exit(1) IJdir = injection + '_summary_plots' + PDdir = pipedown + '/' if opts.symlink_plots: symlink_plot_directory(opts.datadir + ZLdir,\ opts.physdir + ZLdir) @@ -501,90 +514,93 @@ def write_summary(page,opts,thisSearch='playground',injection = 'allinj'): else: copy_plot_directory(opts.datadir + IJdir,\ opts.physdir + IJdir) + copy_plot_directory(opts.datadir + PDdir,\ + opts.physdir + PDdir,open_box = opts.full_data) - - + # A keyword to identify the section # title will be the name of the section. # tags is a tag to search for the relevant cache file (will use the first one found) # imagetags. if not none, will only pu a subset of images corresponding to the list provided. # captions is the text to be written in the caption + # Comments: If not none a comment will be appended to the web page # configs : is not none, the part of the ini file corresponding to this config name will be written in the web page - - titles = [\ - "Inspiral range plots",\ - "Variation in template bank and triggered template size",\ - 'Second thinca step (all ifo combination and category 3 COIRE_SECOND*_ files)',\ - "Accuracies (Second stage)",\ - "Found and Missed plots (Second stage)",\ - "Chi squared plots",\ - ] - - tags = [\ - '*inspiralrange*',\ - '*plotnumtemplates*',\ - '*plotthinca_SECOND_*CAT_3*',\ - '*plotinspinj_SECOND*',\ - '*plotinspmissed_SECOND*',\ - '*plotsnrchi*' - ] + # images_dirs : What directory to look in. + + sections = [] + htmlOnly = [] + htmlAndPlot = [] + titles = {} + tags = {} + htmltags = {} + imagetags = {} + captions = {} + comments = {} + configs = {} + images_dirs = {} + + section = 'inspiralrange' + sections.append(section) + titles[section] = "Inspiral range plots" + tags[section] = '*inspiralrange*' + imagetags[section] = ['range_plot'] + captions[section] = """Inspiral Horizon distance for a \ + (1.4,1.4) solar mass system with SNR=8 (first sub-figure).""" + comments[section] = None + configs[section] = None + images_dirs[section] = ZLdir + + section = 'ifar3' + sections.append(section) + htmlAndPlot.append(section) + titles[section] = "IFAR and loudest event tables at CAT_3 (these include the hardware injections)." + tags[section] = '*plotifar*'+ifartag[0]+'*CAT_3*'+ifartag[1] + '*' + htmltags[section] = '*'+ifartag[0]+'*CAT_3_VETO_LOUDEST*'+ifartag[1]+'*_EVENTS_BY_COMBINED_FAR*' + imagetags[section] = ['cumhist_combined_ifar'] + captions[section] = "Combined and uncombined IFAR vs cumulative number of triggers (above). Loudest event tables as a function of combined FAR (below)." + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir + + section = 'ifar4' + sections.append(section) + htmlAndPlot.append(section) + titles[section] = "IFAR and loudest event tables at CAT_4 (hardware injections removed)." + tags[section] = '*plotifar*'+ifartag[0]+'*CAT_4*'+ifartag[1] + '*' + htmltags[section] = '*'+ifartag[0]+'*CAT_4_VETO_LOUDEST*'+ifartag[1]+'*_EVENTS_BY_COMBINED_FAR*' + imagetags[section] = ['cumhist_combined_ifar'] + captions[section] = "Combined and uncombined IFAR vs cumulative number of triggers (above). Loudest event tables as a function of combined FAR (below)." + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir + + section = 'inspmissed' + sections.append(section) + titles[section] = "Found and Missed plots (Second stage)" + tags[section] = '*plotinspmissed_SECOND*CAT_4*' + imagetags[section] = ['map-8','map-9'] + captions[section] = 'Found and Missed injections. Effective distance versus total mass' + comments[section] = None + configs[section] = None + images_dirs[section] = IJdir - imagetags=[\ - None,\ - None,\ - ['plot_slide_trigs', 'cum_hist_effective_snr'],\ - ['mchirp_vs_snr_accuracy_scatter_mtotal'],\ - ['map-8'],\ - ['chisq_inj_const_lines'] - ] - - captions = [\ - """ "Inspiral Horizon distance for a \ - (1.4,1.4) solar mass system with SNR=8 (first sub-figure), and \ - histograms(second sub-figure). The last sub-figure shows the \ - expected horizon distance for any total mass, using an SNR=8.""" ,\ - "Variation in template bank and triggered template bank size",\ - 'Trigger rate at second coincidence stage',\ - 'Accuracy plots (second stage)',\ - 'Found and Missed injections. Effective distance versus total mass',\ - "chi-square versus SNR (injections in red, slides in black) " - ] - - comments = [\ - None,\ - None,\ - "This section shows the plotthinca results for the category 3 only. ",\ - None, - None, - None - ] - - configs = [ \ - None,\ - None,\ - None,\ - None,\ - None,\ - None - ] - - images_dirs = [ \ - ZLdir,\ - ZLdir,\ - ZLdir,\ - IJdir,\ - IJdir,\ - IJdir - ] - - for title, tag, caption,config,image_tag,comment,images_dir in \ - zip(titles, tags, captions, configs, imagetags,comments,images_dirs): - page = heading(page, title) - if comment is not None: - page.p(comment) - page = add_config_section(page, config) - page = fom(page, opts, cachefile_tag=tag, caption=caption,\ - image_tag=image_tag, directory=images_dir) + for section in sections: + page = heading(page, titles[section]) + if comments[section] is not None: + page.p(comments[section]) + page = add_config_section(page, configs[section]) + if section in htmlOnly: + page = html_insert(page,opts, html_tag=htmltags[section],\ + caption=captions[section],directory=images_dirs[section]) + elif section in htmlAndPlot: + page = html_and_plot(page, opts, cachefile_tag=tags[section],\ + caption=captions[section],image_tag=imagetags[section],\ + directory=images_dirs[section],html_tag=htmltags[section]) + else: + page = fom(page, opts, cachefile_tag=tags[section],\ + caption=captions[section],image_tag=imagetags[section],\ + directory=images_dirs[section]) page.div.close() # for each heading + return page @@ -617,11 +633,7 @@ def write_datainfo(page,opts): page = heading(page, "Selected segments", "Switch details on/off") try: - page.add("<p>The segments files provided in the general section were ") - page.add("created with no data quality flags set. The times analyzed ") - page.add("according to ihope/hipe are provided here below</p>") - page.add("Note that duration of the selected segments added to duration") - page.add("of categories 1 equals duration of science segment") + page.add("<p>The SELECTED_SEGS are the times analyzed by ihope. They correspond to the science segments retrieved using the parameters above minus the times flagged by category 1 DQ flags.</p>") page.p(e.br()) segs = get_segments_tag("SELECTED_SEGS") @@ -647,15 +659,15 @@ def write_datainfo(page,opts): keys = [] formFlags = {} keys.append(str(key)) - formFlags[str(key)] = ['Ifo','Flag','Version','Start padding (s)', 'End padding (s)'] + formFlags[str(key)] = ['IFO','Flag','Version','Start padding (s)', 'End padding (s)','Start time','End time'] key += 1 for ifo in ifos: command = 'ligolw_print -t veto_definer -c ifo -c name -c version ' - command += '-c start_pad -c end_pad -c category ' + command += '-c start_pad -c end_pad -c category -c start_time -c end_time ' command += datadir +'/segments/' + hipecp.get("segments", "veto-def-file") command += """ -d " " | awk '{ if ($6 == '""" + str(i) + """' && """ command += '''$1 == "''' + ifo + '''")''' - command += """ printf("%s %s %s %s %s\\n",$1,$2,$3,$4,$5) }'""" + command += """ printf("%s %s %s %s %s %s %s\\n",$1,$2,$3,$4,$5,$7,$8) }'""" flags, status = \ make_external_call(command, opts.debug, opts.debug, True) flags = flags.split('\n') @@ -667,7 +679,7 @@ def write_datainfo(page,opts): page = write_table(page, formFlags,keys,printKeys = False) - msg="The veto times (category "+str(i)+") according to hipe ( "+cat+")" + msg="Cumulative time vetoed at category "+str(i)+" according to "+cat page.add(msg) segs = get_segments_tag(cat) @@ -679,14 +691,10 @@ def write_datainfo(page,opts): logText(logfile, msg,"warning") page.div.close() - for tag in ["SCIENCE_SEGMENTS", "RDS_C03_L2", "MISSED_SEGS"] : + for tag in ["SCIENCE_SEGMENTS"] : page = heading(page, tag +" summary ") if tag == "SCIENCE_SEGMENTS": - msg = "The times requested for analysis are:" - elif tag == "RDS_C03_L2": - msg = "The times for which " + tag + " data is available are: " - elif tag == "MISSED_SEGS": - msg = "The times for which data is requested but not available are:" + msg = "The amount of science mode time returned by the segment database (without CAT1 flags applied) is:" page.add(msg +" <br/>") try: @@ -724,7 +732,7 @@ def write_upperlimit(page, opts): #*************************************************************************** -def write_analysis(page, opts, thisSearch='playground'): +def write_analysis(page, opts, thisSearch='playground',pipedown='pipedown'): """ Creates the playground or full_data section. It uses the same function because except the name and time analysed, the figures of merits are the same. @@ -743,19 +751,26 @@ def write_analysis(page, opts, thisSearch='playground'): page.add(msg) if thisSearch=='playground': images_dir='playground_summary_plots/' + ifartag=['PLAYGROUND','PLAYGROUND','CLOSED_BOX'] elif thisSearch=='full_data_slide': images_dir='full_data_slide_summary_plots/' + ifartag=['FULL_DATA','PLAYGROUND','CLOSED_BOX'] elif thisSearch=='full_data': images_dir='full_data_summary_plots/' + ifartag=['FULL_DATA','ALL_DATA','OPEN_BOX'] else: print 'Error in write_analysis function: thisSearch is not valid' sys.exit(1) + PDdir = pipedown + '/' if opts.symlink_plots: symlink_plot_directory(opts.datadir + images_dir,\ opts.physdir + images_dir) else: copy_plot_directory(opts.datadir + images_dir,\ opts.physdir + images_dir) + copy_plot_directory(opts.datadir + PDdir,\ + opts.physdir + PDdir,open_box = opts.full_data) + #table and venn diagram page = heading(page, "General information", "see details here") @@ -795,9 +810,9 @@ def write_analysis(page, opts, thisSearch='playground'): try: # page.add("<td>") #create figure for the venn diagram - data = "" - for coinc in ("H1","H1H2","H2","H2L1","L1","H1L1","H1H2L1"): - data = data +coincs.get(coinc) + " " +# data = "" +# for coinc in ("H1","H1H2","H2","H2L1","L1","H1L1","H1H2L1"): +# data = data +coincs.get(coinc) + " " # The Venn diagram is currently non-functional, please fix! # success = create_venn(data, thisSearch) @@ -831,80 +846,173 @@ def write_analysis(page, opts, thisSearch='playground'): logText(logfile, "Error in generating Venn diagram.", "error") pass - - + # A keyword to identify the section # title will be the name of the section. # tags is a tag to search for the relevant cache file (will use the first one found) # imagetags. if not none, will only pu a subset of images corresponding to the list provided. # captions is the text to be written in the caption + # Comments: If not none a comment will be appended to the web page # configs : is not none, the part of the ini file corresponding to this config name will be written in the web page - titles = [\ - "Inspiral range plots",\ - "Variation in template bank and triggered template size",\ - "First inspiral stage (using SIRE_FIRST*_ files)",\ - "First coincidence stage (using COIRE_FIRST*_ and COIRE_SLIDE_FIRST*_ files)",\ - 'Second inspiral stage (using SIRE_SECOND files)',\ - 'Second thinca step (all ifo combination and category 3 COIRE_SECOND*_ files)'\ - ] - - tags = [\ - '*inspiralrange*',\ - '*plotnumtemplates*',\ - '*plotinspiral_FIRST_*',\ - '*plotthinca_FIRST_*',\ - '*plotinspiral_SECOND_*',\ - '*plotthinca_SECOND_*CAT_3*'\ - ] - - imagetags=[\ - None,\ - None,\ - ['snr_vs_time','snr_cum_hist','snr_histogram'],\ - ['dummy_on_purpose_so_that_no_images_is_passed_to_the_web_page'],\ - ['snr_vs_time','snr_vs_chisq_log','snr_histogram'],\ - ['plot_slide_trigs', 'cum_hist_effective_snr']\ - ] - - captions = [\ - """ "Inspiral Horizon distance for a \ - (1.4,1.4) solar mass system with SNR=8 (first sub-figure), and \ - histograms(second sub-figure). The last sub-figure shows the \ - expected horizon distance for any total mass, using an SNR=8.""" ,\ - "Variation in template bank and triggered template bank size",\ - "Trigger rate at first inspiral stage",\ - "Trigger rate at first coincidence stage",\ - "Trigger rate at second inspiral stage",\ - 'Trigger rate at second coincidence stage'\ - ] - - comments = [\ - None,\ - None,\ - None,\ - "<span style=\"color:red\">This section has no images (on purpose)</span>. \ - To obtain the first thinca stage images, clik on the links in the caption here below",\ - None,\ - "This section shows the plotthinca results for the category 3 only. "\ - ] - - configs = [ \ - None,\ - 'tmpltbank',\ - 'inspiral',\ - 'thinca',\ - 'veto-inspiral',\ - 'thinca-2'\ - ] - - for title, tag, caption,config,image_tag,comment in \ - zip(titles, tags, captions, configs, imagetags,comments): - page = heading(page, title) - if comment is not None: - page.p(comment) - page = add_config_section(page, config) - page = fom(page, opts, cachefile_tag=tag, caption=caption,\ - image_tag=image_tag, directory=images_dir) + # images_dirs : What directory to look in. + + sections = [] + htmlOnly = [] + titles = {} + tags = {} + imagetags = {} + captions = {} + comments = {} + configs = {} + images_dirs = {} + + section = 'inspiralrange' + sections.append(section) + titles[section] = "Inspiral range plots" + tags[section] = '*inspiralrange*' + imagetags[section] = ['range_plot','range_hist','range_mass'] + captions[section] = """ Inspiral Horizon distance for a \ + (1.4,1.4) solar mass system with SNR=8 (first plot), and \ + histograms(second plot). The last plot shows the \ + expected horizon distance for any total mass, using an SNR=8.""" + comments[section] = None + configs[section] = None + images_dirs[section] = images_dir + + section = 'numtemplates' + sections.append(section) + titles[section] = "Variation in template bank and triggered template size" + tags[section] = '*plotnumtemplates*' + imagetags[section] = None + captions[section] = "Variation in template bank and triggered template bank size" + comments[section] = None + configs[section] = 'tmpltbank' + images_dirs[section] = images_dir + + section = 'inspiral1' + sections.append(section) + titles[section] = "First inspiral stage (using SIRE_FIRST*_ files)" + tags[section] = '*plotinspiral_FIRST_*' + imagetags[section] = ['snr_vs_time','snr_cum_hist','snr_histogram'] + captions[section] = "Trigger rate at first inspiral stage" + comments[section] = None + configs[section] = 'inspiral' + images_dirs[section] = images_dir + + section = 'thinca1' + sections.append(section) + titles[section] = "First coincidence stage (using COIRE_FIRST*_ and COIRE_SLIDE_FIRST*_ files)" + tags[section] = '*plotthinca_FIRST_*' + imagetags[section] = ['dummy_on_purpose_so_that_no_images_is_passed_to_the_web_page'] + captions[section] = "Trigger rate at first coincidence stage" + comments[section] = "<span style=\"color:red\">This section has no images (on purpose)</span>. \ + To obtain the first thinca stage images, clik on the links in the caption here below" + configs[section] = 'thinca' + images_dirs[section] = images_dir + + section = 'inspiral2' + sections.append(section) + titles[section] = 'Second inspiral stage (using INSPIRAL_SECOND files)' + tags[section] = '*plotinspiral_SECOND_*CAT_4*' + imagetags[section] = ['snr_vs_time','snr_vs_chisq_log','snr_histogram'] + captions[section] = "Trigger rate at second inspiral stage" + comments[section] = None + configs[section] = 'veto-inspiral' + images_dirs[section] = images_dir + + section = 'ifar3' + sections.append(section) + titles[section] = "IFAR at CAT_3 (including hardware injections)." + tags[section] = '*plotifar*'+ifartag[0]+'*CAT_3*'+ifartag[1]+'*' + imagetags[section] = ['cumhist_uncombined_ifar','cumhist_combined_ifar'] + captions[section] = "Combined and uncombined IFAR vs cumulative number of triggers" + comments[section] = None + configs[section] = 'plotifar' + images_dirs[section] = PDdir + + section = 'ifar4' + sections.append(section) + titles[section] = "IFAR at CAT_4 (hardware injections removed)." + tags[section] = '*plotifar*'+ifartag[0]+'*CAT_4*'+ifartag[1]+'*' + imagetags[section] = ['cumhist_uncombined_ifar','cumhist_combined_ifar'] + captions[section] = "Combined and uncombined IFAR vs cumulative number of triggers" + comments[section] = None + configs[section] = 'plotifar' + images_dirs[section] = PDdir + + section = 'plotcumhist3' + sections.append(section) + titles[section] = "Effective SNR at CAT_3 (including hardware injections)" + tags[section] = '*plotcumhist*'+ifartag[0]+'*CAT_3*'+ifartag[2]+'*' + imagetags[section] = ['cumhist'] + captions[section] = 'Effective SNR vs number of triggers' + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir + + section = 'plotcumhist4' + sections.append(section) + titles[section] = "Effective SNR at CAT_4 (hardware injections removed)" + tags[section] = '*plotcumhist*'+ifartag[0]+'*CAT_4*'+ifartag[2]+'*' + imagetags[section] = ['cumhist'] + captions[section] = 'Effective SNR vs number of triggers' + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir + + section = 'plotslides' + sections.append(section) + titles[section] = "Trigger rates at second coincidence stage" + tags[section] = '*plotslides*'+ifartag[0]+'*CAT_4*'+ifartag[2]+'*' + imagetags[section] = ['rates','durations_per_slide'] + captions[section] = 'Trigger rate at second coincidence stage' + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir + + section = 'printlc3zl' + sections.append(section) + htmlOnly.append(section) + titles[section] = "Loudest zero lag events after CAT_3 (including hardware injections)." + tags[section] = '*'+ifartag[0]+'*CAT_3_VETO_LOUDEST*'+ifartag[1]+'*_EVENTS_BY_COMBINED_FAR*' + captions[section] = 'Loudest events after Category 3 vetoes (including hardware injections).' + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir + + section = 'printlc4zl' + sections.append(section) + htmlOnly.append(section) + titles[section] = "Loudest zero lag events after CAT_4 (hardware injections removed)." + tags[section] = '*'+ifartag[0]+'*CAT_4_VETO_LOUDEST*'+ifartag[1]+'*_EVENTS_BY_COMBINED_FAR*' + captions[section] = 'Loudest events after Category 4 vetoes (hardware injections removed).' + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir + + section = 'printlcsl' + sections.append(section) + htmlOnly.append(section) + titles[section] = "Loudest time slide events after CAT_4." + tags[section] = '*'+ifartag[0]+'*CAT_4_VETO_LOUDEST_SLIDE_EVENTS_BY_COMBINED_FAR*' + captions[section] = 'Loudest time slide events after Category 4 vetoes.' + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir + + for section in sections: + page = heading(page, titles[section]) + if comments[section] is not None: + page.p(comments[section]) + page = add_config_section(page, configs[section]) + if section in htmlOnly: + page = html_insert(page,opts, html_tag=tags[section],\ + caption=captions[section],directory=images_dirs[section]) + else: + page = fom(page, opts, cachefile_tag=tags[section],\ + caption=captions[section],image_tag=imagetags[section],\ + directory=images_dirs[section]) page.div.close() # for each heading + return page @@ -1079,7 +1187,7 @@ def write_summaryFiles(page, opts): # *************************************************************************** -def write_injection(page, opts,injection): +def write_injection(page, opts,injection,pipedown='pipedown'): """ Creates the injection section @@ -1100,6 +1208,11 @@ def write_injection(page, opts,injection): copy_plot_directory(opts.datadir + images_dir,\ opts.physdir + images_dir) + PDdir = pipedown + '/' + copy_plot_directory(opts.datadir + PDdir,\ + opts.physdir + PDdir,open_box = opts.full_data) + + page.add("This section summarizes the analysis of the injection runs.<br/>") @@ -1110,97 +1223,127 @@ def write_injection(page, opts,injection): # imagetags. if not none, will only pu a subset of images corresponding to the list provided. # captions is the text to be written in the caption # configs : is not none, the part of the ini file corresponding to this config name will be written in the web page - - titles = [\ - "Efficiency, Found and Missed plots (first stage)",\ - "Closeby missed injections (Second coincidence stage and CAT3)",\ - "Efficiencies (Second stage)",\ - "Accuracies (First stage)",\ - "Accuracies (Second stage)",\ - "Found injections with SNR loss through pipeline.", \ - "Coincident found injections at SIRE but missed by COIRE",\ - "Ethinca",\ - "chisq",\ - "rsq",\ - "distance cut"\ - ] - tags = [\ - '*plotinspmissed_FIRST*',\ - '*plotinspmissed_SECOND*',\ - '*plotinspmissed_SECOND*',\ - '*plotinspinj_FIRST*',\ - '*plotinspinj_SECOND*',\ - '*plotinspfound*',\ - '*plotcoincmissed*',\ - '*plotethinca_SECOND*CAT_3*',\ - '*plotsnrchi*',\ - '*plotsnrchi*',\ - '*ploteffdistcut*' - ] - #['map-8'],\ # this is not robust but works for GPS <900,000,000 - imagetags=[\ - ['dummy_on_purpose_so_that_no_images_is_passed_to_the_web_page'],\ - ['map-8'],\ - ['efficiency-eff_dist'],\ - ['mchirp_vs_snr_accuracy_scatter_mtotal'],\ - ['mchirp_vs_snr_accuracy_scatter_mtotal'],\ - ['no image'],\ - ['no image'],\ - ['ethinca_vs_combined'],\ - ['chisq_inj_const_lines'],\ - ['rsq'],\ - ['eff_dist_cut']\ - ] - captions = [\ - "Found and Missed injections links (first stage)",\ - 'Found and Missed injections. Effective distance versus total mass',\ - 'Efficiencies (Second stage)',\ - 'Accuracy plots (first stage)',\ - 'Accuracy plots (second stage)',\ - 'Found injections with SNR loss through pipeline',\ - 'Coincident found injections at SIRE but missed by COIRE',\ - "Ethinca versus combined SNR in the different ifo combinations",\ - "chi-square versus SNR (injections in red, slides in black) ",\ - "R-square versus SNR (injections in red, slides in blue) ",\ - "Fractional differences in effective distance (H1 and H2 detectors). \ - Blue crosses are slided triggers. Red crosses are injection triggers."\ - ] - - comments = [\ - "<span style=\"color:red\">This section has no images \ + + sections = [] + htmlOnly = [] + titles = {} + tags = {} + imagetags = {} + captions = {} + comments = {} + configs = {} + images_dirs = {} + + section = 'foundmissed1' + sections.append(section) + titles[section] = "Efficiency, Found and Missed plots (first stage)" + tags[section] = '*plotinspmissed_FIRST*' + imagetags[section] = ['dummy_on_purpose_so_that_no_images_is_passed_to_the_web_page'] + captions[section] = "Found and Missed injections links (first stage)" + comments[section] = "<span style=\"color:red\">This section has no images \ (on purpose)</span>. To obtain the efficiency and found/missed plots \ - at the first stage, click on the links in the caption here below",\ - None, \ - None, \ - None, \ - None, \ - "<span style=\"color:red\">plotinspfound does not produce \ + at the first stage, click on the links in the caption here below" + configs[section] = 'plotinspmissed' + images_dirs[section] = images_dir + + section = 'foundmissed2' + sections.append(section) + titles[section] = "Closeby missed injections (Second coincidence stage and CAT3)" + tags[section] = '*plotinspmissed_SECOND*CAT_4*' + imagetags[section] = ['map-8','map-9'] + captions[section] = 'Found and Missed injections. Effective distance versus total mass' + comments[section] = None + configs[section] = 'plotinspmissed' + images_dirs[section] = images_dir + + section = 'efficiency2' + sections.append(section) + titles[section] = "Efficiencies (Second stage)" + tags[section] = '*plotinspmissed_SECOND*CAT_4*' + imagetags[section] = ['efficiency-eff_dist'] + captions[section] = 'Efficiencies (Second stage)' + comments[section] = None + configs[section] = 'plotinspmissed' + images_dirs[section] = images_dir + + section = 'inspinj1' + sections.append(section) + titles[section] = "Accuracies (First stage)" + tags[section] = '*plotinspinj_FIRST*' + imagetags[section] = ['mchirp_vs_snr_accuracy_scatter_mtotal'] + captions[section] = 'Accuracy of recovered chirp mass vs SNR (first stage)' + comments[section] = '<span style=\"color:red\">The colours in these plots \ + represent the chirp mass of the injection. </span>' + configs[section] = 'plotinspinj' + images_dirs[section] = images_dir + + section = 'inspinj2' + sections.append(section) + titles[section] = "Accuracies (Second stage)" + tags[section] = '*plotinspinj_SECOND*CAT_4*' + imagetags[section] = ['mchirp_vs_snr_accuracy_scatter_mtotal'] + captions[section] = 'Accuracy of recovered chirp mass vs SNR (second stage)' + comments[section] = '<span style=\"color:red\">The colours in these plots \ + represent the chirp mass of the injection. </span>' + configs[section] = 'plotinspinj' + images_dirs[section] = images_dir + + section = 'inspfound' + sections.append(section) + titles[section] = "Found injections with SNR loss through pipeline." + tags[section] = '*plotinspfound*CAT_3*' + imagetags[section] = ['no image'] + captions[section] = 'Found injections with SNR loss through pipeline' + comments[section] = "<span style=\"color:red\">plotinspfound does not produce\ plots!</span>. \ To see the followup of found injections, click on the link in the \ - caption below",\ - "<span style=\"color:red\">plotcoincmissed does not produce \ - plots!</span>. \ + caption below" + configs[section] = 'plotinspfound' + images_dirs[section] = images_dir + + section = 'coincmissed' + sections.append(section) + titles[section] = "Coincident found injections at SIRE but missed by COIRE" + tags[section] = '*plotcoincmissed*CAT_4*' + imagetags[section] = ['no image'] + captions[section] = 'Coincident found injections at SIRE but missed by COIRE' + comments[section] = "<span style=\"color:red\">plotcoincmissed does not \ + produce plots!</span>. \ To see the followup of injections found in more than one ifo at SIRE \ - but missed by COIRE, click on the link in the caption below",\ - None, - None, - None, - None - ] - - configs = [\ - 'plotinspmissed',\ - 'plotinspmissed',\ - 'plotinspmissed',\ - 'plotinspinj',\ - 'plotinspinj',\ - 'plotinspfound',\ - 'plotcoincmissed',\ - 'plotethinca',\ - 'plotsnrchi',\ - 'plotsnrchi',\ - 'ploteffdistcut'\ - ] + but missed by COIRE, click on the link in the caption below" + configs[section] = 'plotcoincmissed' + images_dirs[section] = images_dir + + section = 'ethinca' + sections.append(section) + titles[section] = "The Ethinca Parameter" + tags[section] = '*plotethinca_SECOND*CAT_4*' + imagetags[section] = ['ethinca_vs_combined'] + captions[section] = "Ethinca versus combined SNR in the different ifo combinations" + comments[section] = None + configs[section] = 'plotethinca' + images_dirs[section] = images_dir + + section = 'chisq' + sections.append(section) + titles[section] = "The chisq parameter" + tags[section] = '*plotsnrchi*CAT_4*' + imagetags[section] = ['chisq_inj_const_lines','rsq'] + captions[section] = "chi-square versus SNR and rsq versus SNR" + comments[section] = "Chi-squared vs SNR with contours of constant effSNR, \ + the second plot includes contours of slide density." + configs[section] = 'plotsnrchi' + images_dirs[section] = images_dir + + section = 'printlc' + sections.append(section) + htmlOnly.append(section) + titles[section] = "Loudest software injection triggers after CAT_4.." + tags[section] = '*'+injection.upper()+'*CAT_4_VETO_LOUDEST_SIMULATION_EVENTS_BY_COMBINED_FAR*' + captions[section] = 'Loudest events after Category 4 vetoes (hardware injections removed).' + comments[section] = None + configs[section] = None + images_dirs[section] = PDdir try: make_cache(images_dir, "plotinspfound") @@ -1209,22 +1352,19 @@ def write_injection(page, opts,injection): logText(logfile, "Problem while copying files", "error") pass - - page.add("<h1>Summary of the "+images_dir+" directory</h1>") - for title, tag, caption,config,image_tag,comment in\ - zip(titles, tags, captions, configs,imagetags,comments): - page = heading(page, title) - try: - if comment is not None: - page.p(comment) - page = add_config_section(page, config) - page = fom(page, opts, cachefile_tag=tag, caption=caption,\ - image_tag=image_tag, directory=images_dir) - page.div.close() # for each heading - except: - page.div.close() # for each heading - pass - + for section in sections: + page = heading(page, titles[section]) + if comments[section] is not None: + page.p(comments[section]) + page = add_config_section(page, configs[section]) + if section in htmlOnly: + page = html_insert(page,opts, html_tag=tags[section],\ + caption=captions[section],directory=images_dirs[section]) + else: + page = fom(page, opts, cachefile_tag=tags[section],\ + caption=captions[section],image_tag=imagetags[section],\ + directory=images_dirs[section]) + page.div.close() # for each heading return page @@ -1353,7 +1493,7 @@ def add_caption(page, caption): # *************************************************************************** def add_figure(page,webDir,fnames="test", caption="add a caption", size=None, \ - alt="no figure found",source="not specified"): + alt="no figure found",source="not specified",html=None,html_file = None): """ Add a figure to the HTML document, taking care of the numbering. @@ -1381,6 +1521,15 @@ def add_figure(page,webDir,fnames="test", caption="add a caption", size=None, \ size="half" else : size="third" + # Determine the ifo + ifo = None + if html: + for combo in ['H1','L1','V1','H1L1','H1V1','L1V1','H1L1V1']: + if html.startswith(combo): + ifo = combo + if ifo: + page.h5(ifo + ' were operating') + # Source is the thumnail, target is the full-resolution image. for fnam in fnames: @@ -1388,6 +1537,8 @@ def add_figure(page,webDir,fnames="test", caption="add a caption", size=None, \ title = ' title="%s" ' % alt[this_count].strip() title = title.replace("_thumb","") target = source.replace("_thumb","") + if size == 'full': + source = source.replace("_thumb","") page.add("\t<a href=\"" + target+"\"" + title + " rel=\"external\">\n" ) try: thisalt = alt[this_count] @@ -1411,6 +1562,13 @@ def add_figure(page,webDir,fnames="test", caption="add a caption", size=None, \ page.add(fnam.replace("\n","")) page.add("</pre>") + if html_file: + this = open(html_file, "r") + for line in this: + page.add(line) + page.add("<pre>Source: "+ html_file + "\n </pre>" ) + this.close() + page.div.close() #check that the file exsits. If not, returns an error message @@ -1507,49 +1665,32 @@ def get_segments_tag(tag): # the name of the files (except for the ifo) this_tag = '-' + tag + opts.txt_suffix - if tag=="RDS_C03_L2": - this_tag = '_' + tag + opts.txt_suffix - + file = datadir +'/segments/' + ifos[1] + this_tag - if not os.path.isfile(file): + scifile = datadir +'/segments/' + ifos[1] + '-SCIENCE_SEGMENTS' + opts.txt_suffix + if not os.path.isfile(file) or not os.path.isfile(scifile): return thisdata #reading the segments files and extract the duration - command = 'awk \'{print NF}\' ' + file + command = 'segexpr \'intersection(%s,%s)\' -include index,duration | awk \'{print NF}\'' % (file,scifile) try: ncols, status = make_external_call(command, False, opts.debug, True) ncols = ncols[len(ncols)-2] # some files may be empty, so the first line (the comment # which has 5 cols) will be read, which explain the >= and not strict ==. - if float(ncols)>=4: + if float(ncols)>=4 or float(ncols)==2: for ifo in ifos: - thisfile = ifo + this_tag - command = 'awk \'{sum=sum+$4} END {print sum/3600/24}\' ' \ - + directory + thisfile - output_days, status = \ - make_external_call(command, False, opts.debug, True) - - command = 'awk \'{sum=sum+$4} END {print sum}\' ' \ - + directory + thisfile - output_seconds, status = \ - make_external_call(command, False, opts.debug, True) + file = datadir +'/segments/' + ifo + this_tag + scifile = datadir +'/segments/' + ifo + '-SCIENCE_SEGMENTS' + opts.txt_suffix - thisdata[ifo] = [thisfile, output_days, output_seconds] - # unfortunately, right now, there is no standard, so some files have only 2 columns - elif float(ncols)==2: - for ifo in ifos: - thisfile = ifo + this_tag - command = 'awk \'{sum=sum+$2-$1} END {print sum/3600/24}\' ' \ - + directory + thisfile - output_days, status = \ - make_external_call(command,False,opts.debug, True) - - command = 'awk \'{sum=sum+$2-$1} END {print sum}\' ' \ - + directory + thisfile + command = 'segexpr \'intersection(%s,%s)\' -include index,duration | awk \'{sum=sum+$4} END {print sum}\'' % (file,scifile) output_seconds, status = \ make_external_call(command, False, opts.debug, True) + try: + thisdata[ifo] = [os.path.basename(file), str(float(output_seconds)/86400.0), output_seconds] + except: + thisdata[ifo] = [os.path.basename(file), "0", "0"] - thisdata[ifo] = [thisfile, output_days, output_seconds] except: logText(logfile, 'Error while parsing the segment duration files', "error") @@ -1694,15 +1835,48 @@ def copy_segments(): else: logText(logfile, stdout) -def copy_plot_directory(dataDir,webDir): +def copy_files(dataDir,webDir,name): + ''' + A function to use find and xargs to copy a list of files + ''' + command = 'find ' + dataDir + ' -name "' + name + '" | xargs cp -r --target-directory ' + webDir + make_external_call(command, opts.debug, opts.debug, True) + +def copy_plot_directory(dataDir,webDir,open_box = True): ''' A function to copy the XXX_summary_plots directory to the html directory ''' if not os.path.isdir(webDir): - command = 'cp -r ' + dataDir + ' ' + webDir - print >> sys.stdout, ' .../ copying all' + dataDir + ' files to ' + webDir - make_external_call(command, opts.debug, opts.debug, True) - print >> sys.stdout, '... Done' + mkdir(webDir) + if open_box: + print >> sys.stdout, ' .../ copying all' + dataDir + ' files to ' + webDir + copy_files(dataDir,webDir,'*html') + copy_files(dataDir,webDir,'*cache') + command = 'cp -r ' + dataDir + '/Images ' + command += webDir + make_external_call(command, opts.debug, opts.debug, True) + print >> sys.stdout, '... Done' + else: + print >> sys.stdout, ' .../ copying all CLOSED BOX ' + dataDir + ' files to ' + webDir + copy_files(dataDir,webDir,'*PLAYGROUND*PLAYGROUND*html') + copy_files(dataDir,webDir,'*FULL_DATA*PLAYGROUND*html') + copy_files(dataDir,webDir,'*PLAYGROUND*ALL_DATA*html') + copy_files(dataDir,webDir,'*LOUDEST_SLIDE_EVENTS*html') + copy_files(dataDir,webDir,'*CLOSED_BOX*html') + copy_files(dataDir,webDir,'*SIMULATION*html') + copy_files(dataDir,webDir,'*PLAYGROUND*PLAYGROUND*cache') + copy_files(dataDir,webDir,'*FULL_DATA*PLAYGROUND*cache') + copy_files(dataDir,webDir,'*CLOSED_BOX*cache') + copy_files(dataDir,webDir,'*SIMULATION*cache') + mkdir(webDir + '/Images') + copy_files(dataDir+'/Images',webDir+'/Images','*PLAYGROUND*PLAYGROUND*') + copy_files(dataDir+'/Images',webDir+'/Images','*FULL_DATA*PLAYGROUND*') + copy_files(dataDir+'/Images',webDir+'/Images','*PLAYGROUND*ALL_DATA*') + copy_files(dataDir+'/Images',webDir+'/Images','*CLOSED_BOX*') + copy_files(dataDir+'/Images',webDir+'/Images','*SIMULATION*') + print >> sys.stdout, '... Done' + + def symlink_plot_directory(dataDir,webDir): ''' @@ -1762,9 +1936,6 @@ def fom(page, opts, cachefile_tag=None, caption="fix me",\ dataDir = opts.datadir+directory+'/' webDir = opts.physdir + directory + '/' - # create the div that will contain the figure -# page.div(class_="figure") - # create a list of cachefiles, each of which containing # the cachefile_tag argument in its name thisglob = webDir + cachefile_tag +'cache' @@ -1780,21 +1951,27 @@ def fom(page, opts, cachefile_tag=None, caption="fix me",\ # read this cachefile this = open(eachcache, "r") fnameList = [] + # Lots of lists but it ensures that the order is always the same + fileNameList = [] href = None #for each file contained in the cachefile if opts.debug is True : print >>sys.stdout, " --> Copying files from " +eachcache - + for filename in this: filename = filename.replace("\n","") filename = filename.replace(" ","") + fileNameList.append(filename) + + fileNameList.sort() + + for filename in fileNameList: # if the file is an image, we copy it in ./Images # if the file is an image, we copy the file. Then, if the pattern # (in image_tag) matches the filename, then we create am html section. if filename[-4:]=='.png': # we check if the pattern match the file if image_tag is not None: - image_tag.sort() for eachPattern in image_tag: if patternFoundInFilename(filename, eachPattern) is True: fnameList.append(filename.replace(".png", "_thumb.png")) @@ -1803,6 +1980,7 @@ def fom(page, opts, cachefile_tag=None, caption="fix me",\ elif filename[-5:] == '.html' and ('followup' not in filename): href = filename.replace("/pictures", "") href = href.replace("\n", "") + htmlFile = href href = directory + '/' + href if href: @@ -1813,9 +1991,9 @@ def fom(page, opts, cachefile_tag=None, caption="fix me",\ source = eachcache.split('/') source = source[len(source)-1] - fnameList.sort() page = add_figure(page, directory, fnames=fnameList, \ - caption=(caption+' '+msg), source=source,size=None, alt=fnameList) + caption=(caption+' '+msg), source=source,size=None, alt=fnameList,\ + html = htmlFile) # close the cachefile this.close() @@ -1823,6 +2001,165 @@ def fom(page, opts, cachefile_tag=None, caption="fix me",\ return page # *************************************************************************** + +def html_and_plot(page, opts, cachefile_tag=None,\ + caption='fix_me',image_tag=None,\ + directory=None,html_tag=None): + """ + This function does fom and html_insert together! + """ + dataDir = opts.datadir+directory+'/' + webDir = opts.physdir + directory + '/' + # create a list of cachefiles, each of which containing + # the cachefile_tag argument in its name + thisglob = webDir + cachefile_tag +'cache' + cachefileList = glob.glob(thisglob) + # And do the same for the html_tag glob. + thisglob = webDir + html_tag + 'html' + htmlfileList = glob.glob(thisglob) + + # Now we need to match them up + fileListDict = [] + cacheFiles = {} + htmlFiles = {} + cachefileList.sort() + for file in cachefileList: + ifo = None + for combo in ['H1','L1','V1','H1L1','H1V1','L1V1','H1L1V1']: + if os.path.basename(file).startswith(combo): + ifo = combo + if ifo: + cacheFiles[ifo] = file + fileListDict.append(ifo) + else: + print >> sys.stderr,"WARNING: file doesn't seem to match an ifo combo!" + + for file in htmlfileList: + ifo = None + for combo in ['H1','L1','V1','H1L1','H1V1','L1V1','H1L1V1']: + if os.path.basename(file).startswith(combo): + ifo = combo + if ifo: + htmlFiles[ifo] = file + else: + print >> sys.stderr,"WARNING: file doesn't seem to match an ifo combo!" + if ifo not in cacheFiles: + print >> sys.stderr,"WARNING: file doesn't seem to correspond to cache file list" + + if opts.verbose is True: + print " Searching for files with this(ese) tag(s): " +str(image_tag) + + for ifo in fileListDict: + # read the image cachefile + this = open(cacheFiles[ifo], "r") + fnameList = [] + # Lots of lists but it ensures that the order is always the same + fileNameList = [] + href = None + #for each file contained in the cachefile + + if opts.debug is True: + print >>sys.stdout, " --> Copying files from " +cacheFiles[ifo] + + for filename in this: + filename = filename.replace("\n","") + filename = filename.replace(" ","") + fileNameList.append(filename) + + fileNameList.sort() + + for filename in fileNameList: + # if the file is an image, we copy it in ./Images + # if the file is an image, we copy the file. Then, if the pattern + # (in image_tag) matches the filename, then we create am html section. + if filename[-4:]=='.png': + # we check if the pattern match the file + if image_tag is not None: + for eachPattern in image_tag: + if patternFoundInFilename(filename, eachPattern) is True: + fnameList.append(filename.replace(".png", "_thumb.png")) + else: + fnameList.append(filename.replace(".png", "_thumb.png")) + elif filename[-5:] == '.html' and ('followup' not in filename): + href = filename.replace("/pictures", "") + href = href.replace("\n", "") + htmlFile = href + href = directory + '/' + href + + if href: + msg =" <a href=\"" + href + "\"" + msg+=" rel=\"external\" >" + msg += """ <br/> --- <b>Click here (to open link in a new tab/window)</b> to get all pictures (full resolution) + as well as the pylal arguments used to generate the plots</a> """ + + source = cacheFiles[ifo].split('/') + source = source[len(source)-1] + page = add_figure(page, directory, fnames=fnameList, \ + caption=(caption+' '+msg), source=source,size=None, alt=fnameList,\ + html = htmlFile,html_file = htmlFiles[ifo]) + # close the cachefile + this.close() + + return page + +############################################################################### + +def html_insert(page,opts, html_tag=None,\ + caption='fix_me',directory='playground_summary_plots'): + """ + This function copies a set of html files verbatim into the page. + + + @param page: the HTML document page. + @type page: markup.py document + @param opts: the main options variable + @type opts: write_ihope_page options + @param html_tag: the pattern of the html files to look at + @type html_tag: string + @param caption: a list of caption + @type caption: list of string + @param directory: the directory to look at + @type directory: string + """ + + dataDir = opts.datadir+directory+'/' + webDir = opts.physdir + directory + '/' + + # create a list of html files to be used + thisglob = webDir + html_tag +'html' + htmlfileList = glob.glob(thisglob) + + if opts.verbose is True: + print " Copying this html file : " +str(html_tag) + + # for each cachefile we create a div figure section with all + # figures whose name is part of the image_tag list + htmlfileList.sort() + for htmlfile in htmlfileList: + # read this file + this = open(htmlfile, "r") + global fig_num + page.add("<!-- insert a figure -->\n<div class=\"figure\">") + this_count = 0 + # Determine the ifo + ifo = None + for combo in ['H1','L1','V1','H1L1','H1V1','L1V1','H1L1V1']: + if os.path.basename(htmlfile).startswith(combo): + ifo = combo + if ifo: + page.h5('When ' + ifo + ' interferometers operating') + # Add the html file into the page + for line in this: + page.add(line) + # add a yellow box (depends on yourcss style though) that contains the + # html filename. + page.add("<pre>Source: "+ htmlfile + "\n </pre>" ) + page.div.close() + # close the file + this.close() + + return page + # *************************************************************************** def set_style(): """ @@ -1998,7 +2335,7 @@ opts.style = set_style() # now we can parse the ihope.ini file itself msg = "Parsing the ihope ini file (" + opts.config_file+")" logText(logfile, msg) -hipe = opts.ihope_directory+'/'+opts.config_file +hipe = opts.datadir+'/'+opts.config_file hipecp = ConfigParser.ConfigParser() hipecp.read(hipe) make_external_call( 'cp '+opts.config_file + ' ' + opts.physdir, False, opts.debug, True) @@ -2013,8 +2350,8 @@ copy_segments() html_sections={} # the string "full_data" is hardcoded somewhere else, so it must remain as it is -html_order = ['general', 'datainfo', 'fullsummary', 'playsummary',\ - 'playground', 'full_data', \ +html_order = ['general', 'datainfo', 'fullsummary','play_full_slide_summary',\ + 'playsummary','playground', 'full_data', \ 'full_data_slide', 'injection', 'hardware_injections', \ 'followup', 'upperlimit', \ 'summary_files', 'logfile', 'about'] @@ -2025,6 +2362,10 @@ defaultPage = 'datainfo' if opts.summary is True and opts.playground is True: html_sections['playsummary'] = "Summary of playground" defaultPage = 'playsummary' +if opts.summary is True and opts.full_data_slide is True: + html_sections['play_full_slide_summary'] = \ + "Summary of playground with full data slides" + defaultPafe='play_full_slide_summary' if opts.summary is True and opts.full_data is True: html_sections['fullsummary'] = "Summary of full data" defaultPage = 'fullsummary' @@ -2032,10 +2373,15 @@ if opts.playground is True: html_sections['playground'] = "Playground" if opts.full_data_slide is True: html_sections['full_data_slide'] = "Full Data Slide And Playground Zero lag" if opts.injection is True: - html_sections['injection'] = "Injection" - for inj in hipecp.options("injections"): - html_sections[inj] = inj.upper() - html_sections['allinj'] = 'All Injections Combined' + if hipecp.has_section("injections"): + html_sections['injection'] = "Injection" + for inj in hipecp.options("injections"): + html_sections[inj] = inj.upper() + html_sections['allinj'] = 'All Injections Combined' + else: + opts.injection = False + print >> sys.stderr, "No injections section found in ini file." + print >> sys.stderr, "Now running with --skip-injections" if opts.hardware_injection is True: html_sections['hardware_injections'] = "Hardware Injection" if opts.full_data is True: html_sections['full_data'] = "Full Data" @@ -2080,15 +2426,21 @@ mainpage.div.close() mainpage.div.close() mainpage.div(id_="ihope") mainpage.add('<h2> i h o p e </h2>') -mainpage.add('<img src="https://www.lsc-group.phys.uwm.edu/ligovirgo/cbc/public/segments/S5/thomasLegacy.jpg">') +if opts.full_data: + mainpage.add('<img src="https://www.lsc-group.phys.uwm.edu/ligovirgo/cbc/public/segments/S5/OpenBox.jpg">') +else: + mainpage.add('<img src="https://www.lsc-group.phys.uwm.edu/ligovirgo/cbc/public/segments/S5/thomasLegacy.jpg">') mainpage.div.close() mainpage.div(id_='header') mainpage.add('<h1>' + title +' </h1>') -leads = 'Month Lead: ' + monthLead + ',   Second: '+ monthSecond +leads = 'Week Lead: ' + monthLead + ',   Second: '+ monthSecond mainpage.add('<h3> ' + leads + ' </h3>') mainpage.div.close() mainpage.div(id_='iframecontent') mainpage.add('<p id="placeholder">Please select a report section on the left.</p>') +mainpage.add('<script type="text/javascript">') +mainpage.add("""loadFrame('""" + defaultPage + """.html')""") +mainpage.add('</script>') mainpage.div.close() mainpage.div.close() @@ -2101,6 +2453,10 @@ output,status = make_external_call(cmd, True, True, False) if status==0: cmd = 'mv /tmp/tmp.html '+opts.output make_external_call(cmd, True, True, True) +if opts.full_data: + cmd = 'sed -i \'s/<body>/<body\ class=\"openbox\">/g\' ' + opts.output + '>/tmp/tmp.html' + make_external_call(cmd, True, True, True) + # that's it for the html creation. let us copy it to the requested directory print '---------------------FINISHED ---------------------' diff --git a/lalapps/src/inspiral/write_ihope_page.ini b/lalapps/src/inspiral/write_ihope_page.ini index 69b42f5622a373cf266bccbff909fd1fb3d2b298..d99c1b9f9d9cd5d277b6696d5a01f9058dc3c739 100644 --- a/lalapps/src/inspiral/write_ihope_page.ini +++ b/lalapps/src/inspiral/write_ihope_page.ini @@ -21,23 +21,24 @@ month-second = "Stephen Fairhurst" ; a title for the HTML page, title = "Low mass CBC analysis" -; the ini file used by ihope, +; the ini file used by ihope. This should just be the filename +; DO NOT give the full path. ihope-ini-file = ihope.ini ; the main directory where ihope was run ; (the parent directory of the "GPS times" directory) -ihope-directory = ~/YOURANALYSISDIR +ihope-directory = /home/YOURUSERNAME/YOURANALYSISDIR ; the physical directory where write_ihope_page will store the html and ; image files that it produces; this will usually be in your ~/public_html ; The output will be created in html-directory/GPSTIMES -html-directory = ~/public_html +html-directory = /home/YOURUSERNAME/public_html ; last, a standard CSS style for the summary page can be found ; in the lalapps installation dir, under share/lalapps, ; alongside write_ihope_page.ini; you may also link to your own style file -style = YOURLALAPPSINSTALLDIR/share/lalapps/write_ihope_style.css +style = write_ihope_style.css ; don't change anything below output = index.html diff --git a/lalapps/src/inspiral/write_ihope_style.css b/lalapps/src/inspiral/write_ihope_style.css index 529e6057e16210f40d669b6619b1891b38ab3e1d..25397d6e6884640a60a6813b85a5d1fecbcb0467 100644 --- a/lalapps/src/inspiral/write_ihope_style.css +++ b/lalapps/src/inspiral/write_ihope_style.css @@ -9,6 +9,10 @@ font-family: Helvetica, Verdana, sans-serif; font-size: 0.8em; } +body.openbox { +background-color: #ff0000; +} + #wrapper { position: relative; margin: 10px auto 10px auto; @@ -143,6 +147,13 @@ div.contenu h4 { color: #9bf; } +div.contenu h5 { + margin-left: 0px; + line-height: 30px; + font-size: 1.2em; + color: #aa0517; +} + div.contenu p { margin-left: 0px; text-align: justify; diff --git a/lalapps/src/lalapps/Makefile.am b/lalapps/src/lalapps/Makefile.am index 196f9971c92e7db04b2990af335125918ceb5f43..14da09cadc6aa29618ea18e97f0ce234897b01d8 100644 --- a/lalapps/src/lalapps/Makefile.am +++ b/lalapps/src/lalapps/Makefile.am @@ -15,7 +15,7 @@ lalapps_cache_SOURCES = cache.c LDADD = liblalapps.la @LAL_LIBS@ INCLUDES = -I$(top_srcdir)/src if HAVE_PYTHON -pkgpython_DATA = __init__.py +pkgpython_DATA = __init__.py defaults.py endif EXTRA_DIST = series.c series.h getdate.y __init__.py TESTS = lalapps_version diff --git a/lalapps/src/lalapps/__init__.py b/lalapps/src/lalapps/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..314d9acccdbc3b2460773a4be1385657c1c6cc5f 100644 --- a/lalapps/src/lalapps/__init__.py +++ b/lalapps/src/lalapps/__init__.py @@ -0,0 +1,27 @@ +# Copyright (C) 2009 LIGO Scientific Collaboration +# +# 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 this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +# +# ============================================================================= +# +# Preamble +# +# ============================================================================= +# + + +__all__ = ["defaults"] diff --git a/lalapps/src/lalapps/tconvert.c b/lalapps/src/lalapps/tconvert.c index 94fdf27d18170f3b3e5d0e005e6c910299e2da49..cf130f564687568ab524bdfa904b2de4a8667b1c 100644 --- a/lalapps/src/lalapps/tconvert.c +++ b/lalapps/src/lalapps/tconvert.c @@ -41,7 +41,7 @@ #define LHO_LONGITUDE_RAD_E (LAL_PI*(-119.0+(24.0+27.5657/60.0)/60.0)/180.0) #define LLO_LONGITUDE_RAD_E (LAL_PI*(-90.0+(46.0+27.2654/60.0)/60.0)/180.0) -const char * skip_space( const char *s ) +static const char * skip_space( const char *s ) { while ( s && *s && isspace( *s ) ) ++s; @@ -184,7 +184,7 @@ int main( int argc, char *argv[] ) } -void output_secs( int gps_sec ) +static void output_secs( int gps_sec ) { time_t unix_sec; int leap; @@ -216,7 +216,7 @@ void output_secs( int gps_sec ) return; } -void output_date( int gps_sec ) +static void output_date( int gps_sec ) { char date_string[256]; struct tm *tp; @@ -239,7 +239,7 @@ void output_date( int gps_sec ) return; } -void output_date_utc( int gps_sec ) +static void output_date_utc( int gps_sec ) { int utc_flag_save = utc_flag; utc_flag = 1; @@ -250,7 +250,7 @@ void output_date_utc( int gps_sec ) return; } -void output_date_local( int gps_sec ) +static void output_date_local( int gps_sec ) { int utc_flag_save = utc_flag; utc_flag = 0; @@ -261,7 +261,7 @@ void output_date_local( int gps_sec ) return; } -void output_lho_date( int gps_sec ) +static void output_lho_date( int gps_sec ) { set_zone_lho(); if ( verbose ) @@ -270,7 +270,7 @@ void output_lho_date( int gps_sec ) set_zone( tz ); } -void output_llo_date( int gps_sec ) +static void output_llo_date( int gps_sec ) { set_zone_llo(); if ( verbose ) @@ -279,7 +279,7 @@ void output_llo_date( int gps_sec ) set_zone( tz ); } -void output_date_site( int gps_sec ) +static void output_date_site( int gps_sec ) { switch ( site ) { @@ -299,7 +299,7 @@ void output_date_site( int gps_sec ) return; } -void output_jd( int gps_sec ) +static void output_jd( int gps_sec ) { struct tm utc; double jd; @@ -311,7 +311,7 @@ void output_jd( int gps_sec ) return; } -void output_mjd( int gps_sec ) +static void output_mjd( int gps_sec ) { struct tm utc; double jd; @@ -325,7 +325,7 @@ void output_mjd( int gps_sec ) return; } -void output_leaps( int gps_sec ) +static void output_leaps( int gps_sec ) { int leaps; leaps = XLALLeapSeconds( gps_sec ); @@ -335,7 +335,7 @@ void output_leaps( int gps_sec ) return; } -void output_sidereal_time( double sidereal_time_rad ) +static void output_sidereal_time( double sidereal_time_rad ) { double sidereal_time_hrs; double sidereal_time_min; @@ -367,7 +367,7 @@ void output_sidereal_time( double sidereal_time_rad ) return; } -void output_gmst( int gps_sec ) +static void output_gmst( int gps_sec ) { LIGOTimeGPS ligo_time; double gmst_rad; @@ -380,7 +380,7 @@ void output_gmst( int gps_sec ) return; } -void output_local_sidereal_time_lho( int gps_sec ) +static void output_local_sidereal_time_lho( int gps_sec ) { LIGOTimeGPS ligo_time; double sidereal_time_rad; @@ -393,7 +393,7 @@ void output_local_sidereal_time_lho( int gps_sec ) output_sidereal_time( sidereal_time_rad ); } -void output_local_sidereal_time_llo( int gps_sec ) +static void output_local_sidereal_time_llo( int gps_sec ) { LIGOTimeGPS ligo_time; double sidereal_time_rad; @@ -406,7 +406,7 @@ void output_local_sidereal_time_llo( int gps_sec ) output_sidereal_time( sidereal_time_rad ); } -void output_sidereal_time_site( int gps_sec ) +static void output_sidereal_time_site( int gps_sec ) { switch ( site ) { diff --git a/lalapps/src/online/online_datafind.c b/lalapps/src/online/online_datafind.c index 1a4bb74a0f18cae873d2c4d59c284710082d2692..c5d06e88d1e6928e8f973f37f900a6f603e3fa0d 100644 --- a/lalapps/src/online/online_datafind.c +++ b/lalapps/src/online/online_datafind.c @@ -40,8 +40,6 @@ #include <lalapps.h> -extern double round ( double ); - /* flags for getopt_long */ extern int vrbflg; @@ -117,17 +115,17 @@ static void parse_options(INT4 argc, CHAR *argv[]) case 'a': /* help */ - fprintf(stdout, "Usage: lalapps_online_datafind [options]\n"); - fprintf(stdout, " --help print this message\n"); - fprintf(stdout, " --verbose run in verbose mode\n"); - fprintf(stdout, " --debug-level N set lalDebugLevel\n"); - fprintf(stdout, " --ifo IFO set IFO\n"); - fprintf(stdout, " --gps-start-time GPS start of GPS time range\n"); - fprintf(stdout, " --gps-end-time GPS end of GPS time range\n"); - fprintf(stdout, " --timeout TIME set timeout\n"); - fprintf(stdout, " --output FILE output to FILE\n"); - fprintf(stdout, " --observatory SITE set SITE\n"); - fprintf(stdout, " --type FRAME_TYPE set FRAME_TYPE\n"); + fprintf(stderr, "Usage: lalapps_online_datafind [options]\n"); + fprintf(stderr, " --help print this message\n"); + fprintf(stderr, " --verbose run in verbose mode\n"); + fprintf(stderr, " --debug-level N set lalDebugLevel\n"); + fprintf(stderr, " --ifo IFO set IFO\n"); + fprintf(stderr, " --gps-start-time GPS start of GPS time range\n"); + fprintf(stderr, " --gps-end-time GPS end of GPS time range\n"); + fprintf(stderr, " --timeout TIME set timeout\n"); + fprintf(stderr, " --output FILE output to FILE\n"); + fprintf(stderr, " --observatory SITE set SITE\n"); + fprintf(stderr, " --type FRAME_TYPE set FRAME_TYPE\n"); exit(0); break; @@ -233,14 +231,14 @@ static void parse_options(INT4 argc, CHAR *argv[]) if (((observatory != NULL) && (frame_type == NULL)) || \ ((observatory == NULL) && (frame_type != NULL))) { - fprintf(stdout, "both --observatory and --type must be specified\n"); + fprintf(stderr, "both --observatory and --type must be specified\n"); exit(1); } /* are ifo and observatory both specified */ if ((ifo != NULL) && (observatory != NULL)) { - fprintf(stdout, "--ifo and --observatory are both specified\n"); + fprintf(stderr, "--ifo and --observatory are both specified\n"); exit(1); } @@ -281,6 +279,7 @@ INT4 main(INT4 argc, CHAR *argv[]) INT4 wait_time; CHAR *ptimeout; INT4 total_wait = 0; + INT4 found = 0; /* get maximum wait time from ONLINEHOFT_TIMEOUT */ ptimeout = getenv("ONLINEHOFT_TIMEOUT"); @@ -324,11 +323,11 @@ INT4 main(INT4 argc, CHAR *argv[]) /* report time info */ if (vrbflg) { - fprintf(stdout, "current time: %d\n", time_now.gpsSeconds); - fprintf(stdout, "latest data available: %d\n", latest_time->gpsSeconds); - fprintf(stdout, "requested start: %d\n", gps_start.gpsSeconds); - fprintf(stdout, "requested end: %d\n", gps_end.gpsSeconds); - fprintf(stdout, "requested duration: %9d\n", duration); + fprintf(stderr, "current time: %d\n", time_now.gpsSeconds); + fprintf(stderr, "latest data available: %d\n", latest_time->gpsSeconds); + fprintf(stderr, "requested start: %d\n", gps_start.gpsSeconds); + fprintf(stderr, "requested end: %d\n", gps_end.gpsSeconds); + fprintf(stderr, "requested duration: %9d\n", duration); } /* is requested data in the future? */ @@ -338,7 +337,7 @@ INT4 main(INT4 argc, CHAR *argv[]) wait_time = (INT4)round(XLALGPSDiff(&gps_end, &time_now)); /* wait for data to be available */ - fprintf(stdout, "requested data is in the future, waiting: %ds\n", wait_time); + fprintf(stderr, "requested data is in the future, waiting: %ds\n", wait_time); sleep(wait_time); } @@ -356,7 +355,7 @@ INT4 main(INT4 argc, CHAR *argv[]) } /* wait for data to be available */ - fprintf(stdout, "data unavailable, waiting %ds\n", wait_time); + fprintf(stderr, "data unavailable, waiting %ds\n", wait_time); sleep(wait_time); total_wait += wait_time; @@ -387,23 +386,49 @@ INT4 main(INT4 argc, CHAR *argv[]) } /* wait for data to be available */ - fprintf(stdout, "data unavailable, waiting %ds\n", wait_time); + fprintf(stderr, "data unavailable, waiting %ds\n", wait_time); sleep(wait_time); total_wait += wait_time; } else { - /* data is available, break do-while loop */ - break; + /* check that all files have been transferred, stat frames */ + if (XLALAggregationStatFiles(ifo, &gps_start, duration) == 0) + { + /* data is available, break do-while loop */ + found = 1; + break; + } } } while(total_wait < timeout); } + /* check that timeout has not been exceeded, exit if appropriate */ + if ((found == 0) && (total_wait > timeout)) + { + fprintf(stderr, "error: timeout exceeded\n"); + if (ifo) + free(ifo); + if (observatory) + free(observatory); + if (frame_type) + free(frame_type); + exit(1); + } + /* get frame cache */ cache = XLALAggregationFrameCache(ifo, &gps_start, duration); if (cache == NULL) { fprintf(stderr, "error: failed to get frame cache\n"); + + /* free memory and exit */ + if (ifo) + free(ifo); + if (observatory) + free(observatory); + if (frame_type) + free(frame_type); exit(xlalErrno); } @@ -412,9 +437,18 @@ INT4 main(INT4 argc, CHAR *argv[]) if (type == NULL) { fprintf(stderr, "error: failed to get frame type\n"); + + /* free memory and exit */ + if (ifo) + free(ifo); + if (observatory) + free(observatory); + if (frame_type) + free(frame_type); exit(xlalErrno); } + /* create a standard file name if none specified */ if (output_filename == NULL) { /* allocate memory for filename */ @@ -423,7 +457,7 @@ INT4 main(INT4 argc, CHAR *argv[]) /* create name for cache file */ snprintf(output_filename, FILENAME_MAX, "%c-%s-%d-%d.cache", \ ifo[0], type, gps_start.gpsSeconds, gps_end.gpsSeconds); - fprintf(stdout, "output filename not specified, using: %s\n", \ + fprintf(stderr, "output filename not specified, using: %s\n", \ output_filename); } diff --git a/lalapps/src/power/binj.c b/lalapps/src/power/binj.c index 914845b1a15886afa423fc20a048076382bab922..11a85265b308123ba8cf9d60c2efd90455ab78c2 100644 --- a/lalapps/src/power/binj.c +++ b/lalapps/src/power/binj.c @@ -82,6 +82,7 @@ RCSID("$Id$"); enum population { POPULATION_TARGETED, POPULATION_ALL_SKY_SINEGAUSSIAN, + POPULATION_ALL_SKY_BTLWNB, POPULATION_STRING_CUSP }; @@ -115,8 +116,8 @@ static struct options options_defaults(void) { struct options defaults; - defaults.gps_start_time = 0; - defaults.gps_end_time = 0; + defaults.gps_start_time = -1; + defaults.gps_end_time = -1; defaults.population = -1; defaults.ra = XLAL_REAL8_FAIL_NAN; defaults.dec = XLAL_REAL8_FAIL_NAN; @@ -196,7 +197,8 @@ static void print_usage(void) ); fprintf(stderr, "--population name\n" \ " Select the injection population to synthesize. Allowed values are\n" \ -" \"targeted\", \"string_cusp\", and \"all_sky_sinegaussian\".\n" \ +" \"targeted\", \"string_cusp\", and \"all_sky_sinegaussian\",\n" \ +" \"all_sky_btlwnb\".\n" \ "\n" \ "--q value\n" \ " Set the Q for sine-Gaussian injections.\n" \ @@ -355,6 +357,8 @@ static struct options parse_command_line(int *argc, char **argv[], const Process options.population = POPULATION_STRING_CUSP; else if(!strcmp(optarg, "all_sky_sinegaussian")) options.population = POPULATION_ALL_SKY_SINEGAUSSIAN; + else if(!strcmp(optarg, "all_sky_btlwnb")) + options.population = POPULATION_ALL_SKY_BTLWNB; else { fprintf(stderr, "error: unrecognized population \"%s\"", optarg); exit(1); @@ -454,7 +458,7 @@ static struct options parse_command_line(int *argc, char **argv[], const Process exit(1); } - if(!options.gps_start_time || !options.gps_end_time) { + if(options.gps_start_time == -1 || options.gps_end_time == -1) { fprintf(stderr, "--gps-start-time and --gps-end-time are both required\n"); exit(1); } @@ -463,6 +467,18 @@ static struct options parse_command_line(int *argc, char **argv[], const Process exit(1); } + switch(options.population) { + case POPULATION_TARGETED: + case POPULATION_ALL_SKY_SINEGAUSSIAN: + case POPULATION_ALL_SKY_BTLWNB: + case POPULATION_STRING_CUSP: + break; + + default: + fprintf(stderr, "error: --population is required\n"); + exit(1); + } + return options; } @@ -664,7 +680,7 @@ static SimBurst *random_string_cusp(double flow, double fhigh, double Alow, doub /* * ============================================================================ * - * Directed Simulations + * BTLWNB Injections * * ============================================================================ */ @@ -675,7 +691,7 @@ static SimBurst *random_string_cusp(double flow, double fhigh, double Alow, doub */ -static SimBurst *random_directed_btlwnb(double ra, double dec, double minf, double maxf, double minband, double maxband, double mindur, double maxdur, double minEoverr2, double maxEoverr2, gsl_rng *rng) +static SimBurst *random_directed_btlwnb(double ra, double dec, double psi, double minf, double maxf, double minband, double maxband, double mindur, double maxdur, double minEoverr2, double maxEoverr2, gsl_rng *rng) { REAL8TimeSeries *hplus, *hcross; SimBurst *sim_burst = XLALCreateSimBurst(); @@ -689,7 +705,7 @@ static SimBurst *random_directed_btlwnb(double ra, double dec, double minf, doub sim_burst->ra = ra; sim_burst->dec = dec; - sim_burst->psi = gsl_ran_flat(rng, 0, LAL_TWOPI); + sim_burst->psi = psi; /* pick a waveform */ @@ -739,6 +755,17 @@ static SimBurst *random_directed_btlwnb(double ra, double dec, double minf, doub } +static SimBurst *random_all_sky_btlwnb(double minf, double maxf, double minband, double maxband, double mindur, double maxdur, double minEoverr2, double maxEoverr2, gsl_rng *rng) +{ + double ra, dec, psi; + SimBurst *sim_burst; + + random_location_and_polarization(&ra, &dec, &psi, rng); + + return random_directed_btlwnb(ra, dec, psi, minf, maxf, minband, maxband, mindur, maxdur, minEoverr2, maxEoverr2, rng); +} + + /* * ============================================================================ * @@ -954,20 +981,30 @@ int main(int argc, char *argv[]) switch(options.population) { case POPULATION_TARGETED: - *sim_burst = random_directed_btlwnb(options.ra, options.dec, options.minf, options.maxf, options.minbandwidth, options.maxbandwidth, options.minduration, options.maxduration, options.minEoverr2, options.maxEoverr2, rng); + *sim_burst = random_directed_btlwnb(options.ra, options.dec, gsl_ran_flat(rng, 0, LAL_TWOPI), options.minf, options.maxf, options.minbandwidth, options.maxbandwidth, options.minduration, options.maxduration, options.minEoverr2, options.maxEoverr2, rng); break; case POPULATION_ALL_SKY_SINEGAUSSIAN: *sim_burst = random_all_sky_sineGaussian(options.minf, options.maxf, options.q, options.minhrss, options.maxhrss, rng); break; + case POPULATION_ALL_SKY_BTLWNB: + *sim_burst = random_all_sky_btlwnb(options.minf, options.maxf, options.minbandwidth, options.maxbandwidth, options.minduration, options.maxduration, options.minEoverr2, options.maxEoverr2, rng); + break; + case POPULATION_STRING_CUSP: *sim_burst = random_string_cusp(options.minf, options.maxf, options.minA, options.maxA, rng); break; + + default: + /* shouldn't get here, command line parsing code + * should prevent it */ + XLALPrintError("internal error\n"); + exit(1); } if(!*sim_burst) { - XLALPrintError("can't make injection"); + XLALPrintError("can't make injection\n"); exit(1); } @@ -990,6 +1027,10 @@ int main(int argc, char *argv[]) sim_burst = &(*sim_burst)->next; } + XLALPrintInfo("%s: ", argv[0]); + XLALPrintProgressBar(1.0); + XLALPrintInfo(" complete\n"); + /* output */ XLALGPSTimeNow(&process_table_head->end_time); diff --git a/lalapps/src/power/lalapps_power_pipe b/lalapps/src/power/lalapps_power_pipe index f5d70a15e512a45aff2d019896d99301a4cd07fd..66648540261b3a6fc87786f93aa2a825f1c66a3d 100644 --- a/lalapps/src/power/lalapps_power_pipe +++ b/lalapps/src/power/lalapps_power_pipe @@ -57,6 +57,18 @@ __date__ = "$Date$"[5:-2] __version__ = "$Revision$"[11:-2] +# +# ============================================================================= +# +# Speed Hacks +# +# ============================================================================= +# + + +ligolw_cafe.lsctables.LIGOTimeGPS = LIGOTimeGPS + + # # ============================================================================= # diff --git a/lalapps/src/pulsar/ComputeWeightedMultiAMCoeffs.c b/lalapps/src/pulsar/ComputeWeightedMultiAMCoeffs.c index 9cdacf9807eef820d670e6a5029043946bfd20dc..d219e289a893d98c600a629ca7a383d0257be5fb 100644 --- a/lalapps/src/pulsar/ComputeWeightedMultiAMCoeffs.c +++ b/lalapps/src/pulsar/ComputeWeightedMultiAMCoeffs.c @@ -164,14 +164,7 @@ int main(int argc, char *argv[]) { snprintf(ephemeris.ephiles.earthEphemeris, buf, "earth%s.dat", ephem_year); snprintf(ephemeris.ephiles.sunEphemeris, buf, "sun%s.dat", ephem_year); } - - /* Get the leap seconds */ - ephemeris.leap = (INT2)XLALGPSLeapSeconds(catalog->data[0].header.epoch.gpsSeconds); - if (xlalErrno != XLAL_SUCCESS) { - LALPrintError("XLALGPSLeapSeconds failed\n"); - return EXIT_FAILURE; - } - + /* Load ephemeris */ LogPrintf(LOG_DEBUG, "Loading ephemeris ... "); LAL_CALL(LALInitBarycenter(&status, &ephemeris), &status); diff --git a/lalapps/src/pulsar/FDS_binary/CalculateSensitivity_v1.c b/lalapps/src/pulsar/FDS_binary/CalculateSensitivity_v1.c index c91a3aee69b2db32e4d74b9905afa7ed5a8b27d2..998d65e7cc7f3ca1b7efaa63160c0c92f5e17ca1 100644 --- a/lalapps/src/pulsar/FDS_binary/CalculateSensitivity_v1.c +++ b/lalapps/src/pulsar/FDS_binary/CalculateSensitivity_v1.c @@ -741,8 +741,7 @@ int GetAB(EphemerisData *edat, char *detector, dataset *dataparams,binarysource AMCoeffsParams *amParams; LIGOTimeGPS FirstStamp; LIGOTimeGPS *midTS=NULL; /* Time stamps for amplitude modulation coefficients */ - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap,k; + INT4 k; AMCoeffs amc; REAL8 C; @@ -750,9 +749,6 @@ int GetAB(EphemerisData *edat, char *detector, dataset *dataparams,binarysource FirstStamp.gpsSeconds=dataparams->stamps[0].gpsSeconds; FirstStamp.gpsNanoSeconds=dataparams->stamps[0].gpsNanoSeconds; - LALLeapSecs(&status,&leap,&FirstStamp,&formatAndAcc); - (*edat).leap=leap; - if(strcmp(detector,"GEO")) Detector=lalCachedDetectors[LALDetectorIndexGEO600DIFF]; if(strcmp(detector,"LLO")) Detector=lalCachedDetectors[LALDetectorIndexLLODIFF]; if(strcmp(detector,"LHO")) Detector=lalCachedDetectors[LALDetectorIndexLHODIFF]; @@ -784,9 +780,7 @@ int GetAB(EphemerisData *edat, char *detector, dataset *dataparams,binarysource amParams->das->pSource->orientation = 0.0; amParams->das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!!!!!!!!*/ - amParams->leapAcc=formatAndAcc.accuracy; - /* Allocate space for AMCoeffs */ amc.a = NULL; amc.b = NULL; diff --git a/lalapps/src/pulsar/FDS_binary/ComputeFStatisticBinary_v2.c b/lalapps/src/pulsar/FDS_binary/ComputeFStatisticBinary_v2.c index 53eb958fc24f43c115983aca06bb4098e534892d..7e8cfc8c7562ba63a7281e69cd299b204b036371 100644 --- a/lalapps/src/pulsar/FDS_binary/ComputeFStatisticBinary_v2.c +++ b/lalapps/src/pulsar/FDS_binary/ComputeFStatisticBinary_v2.c @@ -1079,7 +1079,6 @@ void CreateDemodParams (LALStatus *status) amParams->das->pSource->orientation = 0.0; amParams->das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!!!!!!!!*/ - amParams->leapAcc = LALLEAPSEC_STRICT; /* Mid point of each SFT */ midTS = (LIGOTimeGPS *)LALCalloc(GV.SFTno, sizeof(LIGOTimeGPS)); @@ -1186,7 +1185,6 @@ void CreateBinaryDemodParams (LALStatus *status) amParams->das->pSource->orientation = 0.0; amParams->das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!!!!!!!!*/ - amParams->leapAcc = LALLEAPSEC_STRICT; /* Mid point of each SFT */ midTS = (LIGOTimeGPS *)LALCalloc(GV.SFTno, sizeof(LIGOTimeGPS)); @@ -1890,16 +1888,10 @@ SetGlobalVariables(LALStatus *status, ConfigVariables *cfg) * initialize Ephemeris-data */ { - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; - cfg->edat = LALCalloc(1, sizeof(EphemerisData)); cfg->edat->ephiles.earthEphemeris = cfg->EphemEarth; cfg->edat->ephiles.sunEphemeris = cfg->EphemSun; - TRY (LALLeapSecs (status->statusPtr, &leap, &starttime, &formatAndAcc), status); - cfg->edat->leap = leap; - TRY (LALInitBarycenter(status->statusPtr, cfg->edat), status); } /*------------------------------------------------------------*/ diff --git a/lalapps/src/pulsar/FDS_binary/FindCoincidence_v1.c b/lalapps/src/pulsar/FDS_binary/FindCoincidence_v1.c index b4e0e5ef70b7dce2b0930f1fcd0a01030d7930d8..4983922c2647d07863418b4dff62bce4d14748cb 100644 --- a/lalapps/src/pulsar/FDS_binary/FindCoincidence_v1.c +++ b/lalapps/src/pulsar/FDS_binary/FindCoincidence_v1.c @@ -51,8 +51,6 @@ EphemerisData *edat=NULL; /* Stores earth/sun ephemeris data for baryce LALDetector Detector; /* Our detector*/ EarthState earth; EmissionTime emit; -LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; -INT4 leap; /* clargs */ char presultsdir[256]; @@ -516,10 +514,6 @@ int SetupBaryInput(char *ephfile, char *year, char *detector, LIGOTimeGPS *tstar (*edat).ephiles.earthEphemeris = filenameE; (*edat).ephiles.sunEphemeris = filenameS; - /* set up leap second information */ - LALLeapSecs(&status,&leap,tstart,&formatAndAcc); - (*edat).leap=leap; - /* Read in ephemeris files */ LALInitBarycenter(&status,edat); diff --git a/lalapps/src/pulsar/FDS_binary/GenerateBinaryMesh_v1.c b/lalapps/src/pulsar/FDS_binary/GenerateBinaryMesh_v1.c index f8dc3b936cf9cf37a7ae2e7b280647fe6ff540f3..1e164c097b59379248a8bd3b9bb1a1ede941d507 100644 --- a/lalapps/src/pulsar/FDS_binary/GenerateBinaryMesh_v1.c +++ b/lalapps/src/pulsar/FDS_binary/GenerateBinaryMesh_v1.c @@ -515,9 +515,6 @@ int GenerateMesh(GlobVar GV,REAL4VectorSequence **XYmesh,XYparameterspace *XYspa int SetupBaryInput(GlobVar *GV,EphemerisData **edat,LALDetector *Detector) { - - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; CHAR filenameE[256],filenameS[256]; FILE *fp; @@ -552,10 +549,6 @@ int SetupBaryInput(GlobVar *GV,EphemerisData **edat,LALDetector *Detector) (*(*edat)).ephiles.earthEphemeris = filenameE; (*(*edat)).ephiles.sunEphemeris = filenameS; - /* set up leap second information */ - LALLeapSecs(&status,&leap,&GV->tstart,&formatAndAcc); - (*(*edat)).leap=leap; - /* Read in ephemeris files */ LALInitBarycenter(&status,(*edat)); @@ -1265,11 +1258,13 @@ int CheckInput(GlobVar GV) beginDate.tm_hour=0; beginDate.tm_mday=0; beginDate.tm_mon=0; + beginDate.tm_isdst=0; endDate.tm_sec=0; endDate.tm_min=0; endDate.tm_hour=0; endDate.tm_mday=0; endDate.tm_mon=0; + endDate.tm_isdst=0; /* set the start and end times for the given year */ if (strcmp(GV.yr,"98")==0) { @@ -1332,6 +1327,16 @@ int CheckInput(GlobVar GV) beginDate.tm_year=105; endDate.tm_year=110; } + + /* populate tm_wday, tm_yday. NOTE: this function does not understand + * leap seconds; if tm_sec is set to 60 it will "normalize" it by + * settting it to 0 and bumping the minutes, which is not the same time + * if the previous minute had 61 seconds in it. you can use these + * functions to populate the yday and wday fields, and then set the + * seconds, minutes, etc., *after* to avoid corrupting the time, but here + * we don't care because the times aren't leap seconds (see above). */ + mktime(&beginDate); + mktime(&endDate); /* convert the beginning and end of the relevant year(s) to a GPS time */ beginGPS = XLALUTCToGPS(&beginDate); diff --git a/lalapps/src/pulsar/FDS_binary/MakeSubMesh_v1.c b/lalapps/src/pulsar/FDS_binary/MakeSubMesh_v1.c index b332b728e3f025a745da9e376b9dcecbceda60c8..916cfa82d9a8f99612460d9512498ff9e265f586 100644 --- a/lalapps/src/pulsar/FDS_binary/MakeSubMesh_v1.c +++ b/lalapps/src/pulsar/FDS_binary/MakeSubMesh_v1.c @@ -54,8 +54,6 @@ EphemerisData *edat=NULL; /* Stores earth/sun ephemeris data for baryce LALDetector Detector; /* Our detector*/ EarthState earth; EmissionTime emit; -LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; -INT4 leap; BinaryMeshFileHeader BMFheader; INT4 exactflag; @@ -152,10 +150,6 @@ int SetupBaryInput(void) (*edat).ephiles.earthEphemeris = filenameE; (*edat).ephiles.sunEphemeris = filenameS; - /* set up leap second information */ - LALLeapSecs(&status,&leap,&TstartDET,&formatAndAcc); - (*edat).leap=leap; - /* Read in ephemeris files */ LALInitBarycenter(&status,edat); diff --git a/lalapps/src/pulsar/FDS_isolated/ComputeFStatAnalyticMonteCarloUpperLimit.c b/lalapps/src/pulsar/FDS_isolated/ComputeFStatAnalyticMonteCarloUpperLimit.c index 4c4b842e84e92b220c9e5360eff484d230111390..f694a3e5746558d2d93293c60d98ac9fe4a40c5f 100644 --- a/lalapps/src/pulsar/FDS_isolated/ComputeFStatAnalyticMonteCarloUpperLimit.c +++ b/lalapps/src/pulsar/FDS_isolated/ComputeFStatAnalyticMonteCarloUpperLimit.c @@ -277,14 +277,7 @@ int main(int argc, char *argv[]) { snprintf(ephemeris.ephiles.earthEphemeris, buf, "earth%s.dat", ephem_year); snprintf(ephemeris.ephiles.sunEphemeris, buf, "sun%s.dat", ephem_year); } - - /* Get the leap seconds */ - ephemeris.leap = (INT2)XLALGPSLeapSeconds(catalog->data[0].header.epoch.gpsSeconds); - if (xlalErrno != XLAL_SUCCESS) { - LALPrintError("XLALGPSLeapSeconds failed\n"); - return EXIT_FAILURE; - } - + /* Load ephemeris */ LogPrintf(LOG_DEBUG, "Loading ephemeris ... "); LAL_CALL(LALInitBarycenter(&status, &ephemeris), &status); diff --git a/lalapps/src/pulsar/FDS_isolated/ComputeFStatistic.c b/lalapps/src/pulsar/FDS_isolated/ComputeFStatistic.c index 3a8f719d0ffe810465beee429cb92495ae693845..52434cf1b9dfe76e5f40c59fa1029a934fb0e51f 100644 --- a/lalapps/src/pulsar/FDS_isolated/ComputeFStatistic.c +++ b/lalapps/src/pulsar/FDS_isolated/ComputeFStatistic.c @@ -1727,7 +1727,6 @@ void CreateDemodParams (LALStatus *status, PulsarDopplerParams searchpos) amParams->das->pSource->orientation = 0.0; amParams->das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!*/ - amParams->leapAcc = LALLEAPSEC_STRICT; /* Mid point of each SFT */ midTS = (LIGOTimeGPS *)LALCalloc(GV.SFTno, sizeof(LIGOTimeGPS)); @@ -2702,16 +2701,10 @@ InitFStat (LALStatus *status, ConfigVariables *cfg) * initialize Ephemeris-data */ { - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; - cfg->edat = (EphemerisData*)LALCalloc(1, sizeof(EphemerisData)); cfg->edat->ephiles.earthEphemeris = cfg->EphemEarth; cfg->edat->ephiles.sunEphemeris = cfg->EphemSun; - TRY (LALLeapSecs(status->statusPtr, &leap, &starttime, &formatAndAcc), status); - cfg->edat->leap = leap; - TRY (LALInitBarycenter(status->statusPtr, cfg->edat), status); } /* end: init ephemeris data */ diff --git a/lalapps/src/pulsar/FDS_isolated/ComputeFStatistic_v2.c b/lalapps/src/pulsar/FDS_isolated/ComputeFStatistic_v2.c index e200de80c0718b3e8e2820259e8cf90ec0e47d5e..e0b5ef9cdfa2d15bf481eda04aeb6fc27322c8d9 100644 --- a/lalapps/src/pulsar/FDS_isolated/ComputeFStatistic_v2.c +++ b/lalapps/src/pulsar/FDS_isolated/ComputeFStatistic_v2.c @@ -87,7 +87,7 @@ RCSID( "$Id$"); #define FALSE (1==0) /*----- SWITCHES -----*/ -#define NUM_SPINS 4 /* number of spin-values to consider: {f, fdot, f2dot, ... } */ +#define NUM_SPINS 4 /* number of spin-values to consider: {f, fdot, f2dot, ... } */ /*----- Error-codes -----*/ #define COMPUTEFSTATISTIC_ENULL 1 @@ -280,7 +280,6 @@ void WriteFStatLog ( LALStatus *status, const CHAR *log_fname, const CHAR *logst void getLogString ( LALStatus *status, CHAR **logstr, const ConfigVariables *cfg ); void OutputVersion ( void ); -const char *va(const char *format, ...); /* little var-arg string helper function */ CHAR *append_string ( CHAR *str1, const CHAR *append ); /* ---------- scanline window functions ---------- */ @@ -330,10 +329,10 @@ int main(int argc,char *argv[]) /* register all user-variable */ LAL_CALL (LALGetDebugLevel(&status, argc, argv, 'v'), &status); - LAL_CALL (initUserVars(&status, &uvar), &status); + LAL_CALL (initUserVars(&status, &uvar), &status); /* do ALL cmdline and cfgfile handling */ - LAL_CALL (LALUserVarReadAllInput(&status, argc, argv), &status); + LAL_CALL (LALUserVarReadAllInput(&status, argc, argv), &status); if (uvar.help) /* if help was requested, we're done here */ exit (0); @@ -420,13 +419,13 @@ int main(int argc,char *argv[]) /* count number of templates */ numTemplates = XLALNumDopplerTemplates ( GV.scanState ); if (uvar.countTemplates) - printf("%%%% Number of templates: %0.0f\n", numTemplates); + printf("%%%% Number of templates: %0.0f\n", numTemplates); /*---------------------------------------------------------------------- * main loop: demodulate data for each point in the sky-position grid * and for each value of the frequency-spindown */ - templateCounter = 0.0; + templateCounter = 0.0; tickCounter = 0; clock0 = time(NULL); @@ -434,9 +433,9 @@ int main(int argc,char *argv[]) while ( !uvar.countTemplates && (XLALNextDopplerPos( &dopplerpos, GV.scanState ) == 0) ) { dopplerpos.orbit = orbitalParams; /* temporary solution until binary-gridding exists */ - + /* main function call: compute F-statistic for this template */ - LAL_CALL( ComputeFStat(&status, &Fstat, &dopplerpos, GV.multiSFTs, GV.multiNoiseWeights, + LAL_CALL( ComputeFStat(&status, &Fstat, &dopplerpos, GV.multiSFTs, GV.multiNoiseWeights, GV.multiDetStates, &GV.CFparams, &cfBuffer ), &status ); /* Progress meter */ @@ -450,25 +449,25 @@ int main(int argc,char *argv[]) LogPrintf (LOG_DEBUG, "Progress: %g/%g = %.2f %% done, Estimated time left: %.0f s\n", templateCounter, numTemplates, templateCounter/numTemplates * 100.0, timeLeft); } - + /* sanity check on the result */ if ( !finite(Fstat.F) ) { - LogPrintf(LOG_CRITICAL, "non-finite F = %.16g, Fa=(%.16g,%.16g), Fb=(%.16g,%.16g)\n", + LogPrintf(LOG_CRITICAL, "non-finite F = %.16g, Fa=(%.16g,%.16g), Fb=(%.16g,%.16g)\n", Fstat.F, Fstat.Fa.re, Fstat.Fa.im, Fstat.Fb.re, Fstat.Fb.im ); LogPrintf (LOG_CRITICAL, "[Alpha,Delta] = [%.16g,%.16g],\nfkdot=[%.16g,%.16g,%.16g,%16.g]\n", - dopplerpos.Alpha, dopplerpos.Delta, + dopplerpos.Alpha, dopplerpos.Delta, dopplerpos.fkdot[0], dopplerpos.fkdot[1], dopplerpos.fkdot[2], dopplerpos.fkdot[3] ); - if (dopplerpos.orbit != NULL) + if (dopplerpos.orbit != NULL) { - LogPrintf (LOG_CRITICAL, "tp = {%d s, %d ns}, argp = %f, asini = %f, ecc = %f, period = %f\n", - dopplerpos.orbit->tp.gpsSeconds, dopplerpos.orbit->tp.gpsNanoSeconds, + LogPrintf (LOG_CRITICAL, "tp = {%d s, %d ns}, argp = %f, asini = %f, ecc = %f, period = %f\n", + dopplerpos.orbit->tp.gpsSeconds, dopplerpos.orbit->tp.gpsNanoSeconds, dopplerpos.orbit->argp, dopplerpos.orbit->asini, dopplerpos.orbit->ecc, dopplerpos.orbit->period); } return -1; } - + /* propagate fkdot from internalRefTime back to refTime for outputting results */ /* FIXE: only do this for candidates we're going to write out */ LAL_CALL ( LALExtrapolatePulsarSpins ( &status, dopplerpos.fkdot, GV.refTime, dopplerpos.fkdot, GV.searchRegion.refTime ), &status ); @@ -487,7 +486,7 @@ int main(int argc,char *argv[]) } /* correct normalization in --SignalOnly case: - * we didn't normalize data by 1/sqrt(Tsft * 0.5 * Sh) in terms of + * we didn't normalize data by 1/sqrt(Tsft * 0.5 * Sh) in terms of * the single-sided PSD Sh: the SignalOnly case is characterized by * setting Sh->1, so we need to divide Fa,Fb by sqrt(0.5*Tsft) and F by (0.5*Tsft) */ @@ -498,8 +497,8 @@ int main(int argc,char *argv[]) Fstat.Fb.re *= norm; Fstat.Fb.im *= norm; Fstat.F *= norm * norm; Fstat.F += 2; /* compute E[2F]:= 4 + SNR^2 */ - thisFCand.Mmunu.Sinv_Tsft = GV.Tsft; - } + thisFCand.Mmunu.Sinv_Tsft = GV.Tsft; + } thisFCand.Fstat = Fstat; /* push new value onto scan-line buffer */ @@ -529,7 +528,7 @@ int main(int argc,char *argv[]) } /* if outputFstat */ } /* if 2F > threshold */ - + /* separately keep track of loudest candidate (for --outputLoudest) */ if ( thisFCand.Fstat.F > loudestFCand.Fstat.F ) loudestFCand = thisFCand; @@ -546,15 +545,15 @@ int main(int argc,char *argv[]) LALPrintError("\nCouldn't (re)allocate 'Fstat_histogram'\n"); return COMPUTEFSTATISTIC_EMEM; } - + /* add to bin */ gsl_vector_int_set(Fstat_histogram, bin, gsl_vector_int_get(Fstat_histogram, bin) + 1); - + } - + } /* while more Doppler positions to scan */ - + /* ----- if using toplist: sort and write it out to file now ----- */ if ( fpFstat && GV.FstatToplist ) { @@ -576,10 +575,10 @@ int main(int argc,char *argv[]) { LogPrintf (LOG_CRITICAL, "Failed to write candidate to file.\n"); return -1; - } + } } /* for el < elems in toplist */ - } /* if fpFstat && toplist */ + } /* if fpFstat && toplist */ if ( fpFstat ) { @@ -595,7 +594,7 @@ int main(int argc,char *argv[]) PulsarCandidate pulsarParams = empty_PulsarCandidate; pulsarParams.Doppler = loudestFCand.doppler; - LAL_CALL(LALEstimatePulsarAmplitudeParams (&status, &pulsarParams, &loudestFCand.Fstat, &GV.searchRegion.refTime, &loudestFCand.Mmunu ), + LAL_CALL(LALEstimatePulsarAmplitudeParams (&status, &pulsarParams, &loudestFCand.Fstat, &GV.searchRegion.refTime, &loudestFCand.Mmunu ), &status ); if ( (fpLoudest = fopen (uvar.outputLoudest, "wb")) == NULL) @@ -619,30 +618,30 @@ int main(int argc,char *argv[]) gsl_matrix_free ( pulsarParams.AmpFisherMatrix ); } /* write loudest candidate to file */ - + LogPrintf (LOG_DEBUG, "Search finished.\n"); - + /* write out the Fstatistic histogram */ if (uvar.outputFstatHist) { size_t i = 0; FILE *fpFstatHist = fopen(uvar.outputFstatHist, "wb"); - + if (fpFstatHist == NULL) { LALPrintError ("\nError opening file '%s' for writing..\n\n", uvar.outputFstat); return (COMPUTEFSTATISTIC_ESYS); } fprintf(fpFstatHist, "%s", GV.logstring); - + for (i = 0; i < Fstat_histogram->size; ++i) fprintf(fpFstatHist, "%0.3g %0.3g %i\n", uvar.FstatHistBin * i, uvar.FstatHistBin * (i + 1), gsl_vector_int_get(Fstat_histogram, i)); - + fprintf(fpFstatHist, "%%DONE\n"); fclose(fpFstatHist); - + } /* Free memory */ @@ -662,16 +661,16 @@ int main(int argc,char *argv[]) fclose(fpLogPrintf); LogSetFile(fpLogPrintf = NULL); } - + /* did we forget anything ? */ LALCheckMemoryLeaks(); - + return 0; - + } /* main() */ -/** +/** * Register all our "user-variables" that can be specified from cmd-line and/or config-file. * Here we set defaults for some user-variables and register them with the UserInput module. */ @@ -764,7 +763,7 @@ initUserVars (LALStatus *status, UserInput_t *uvar) uvar->maxBraking = 0.0; /* ---------- register all user-variables ---------- */ - LALregBOOLUserStruct(status, help, 'h', UVAR_HELP, "Print this message"); + LALregBOOLUserStruct(status, help, 'h', UVAR_HELP, "Print this message"); LALregREALUserStruct(status, Alpha, 'a', UVAR_OPTIONAL, "Sky position alpha (equatorial coordinates) in radians"); LALregREALUserStruct(status, Delta, 'd', UVAR_OPTIONAL, "Sky position delta (equatorial coordinates) in radians"); @@ -796,9 +795,9 @@ initUserVars (LALStatus *status, UserInput_t *uvar) LALregREALUserStruct(status, orbitTpSSBMJD, 0, UVAR_OPTIONAL, "The true time of periapsis in the SSB frame (in MJD)"); LALregREALUserStruct(status, orbitArgp, 0, UVAR_OPTIONAL, "The orbital argument of periapse in radians"); LALregREALUserStruct(status, orbitEcc, 0, UVAR_OPTIONAL, "The orbital eccentricity"); - + LALregSTRINGUserStruct(status,skyRegion, 'R', UVAR_OPTIONAL, "ALTERNATIVE: Specify sky-region by polygon (or use 'allsky')"); - LALregSTRINGUserStruct(status,DataFiles, 'D', UVAR_REQUIRED, "File-pattern specifying (multi-IFO) input SFT-files"); + LALregSTRINGUserStruct(status,DataFiles, 'D', UVAR_REQUIRED, "File-pattern specifying (multi-IFO) input SFT-files"); LALregSTRINGUserStruct(status,IFO, 'I', UVAR_OPTIONAL, "Detector: 'G1', 'L1', 'H1', 'H2' ...(useful for single-IFO v1-SFTs only!)"); LALregSTRINGUserStruct(status,ephemDir, 'E', UVAR_OPTIONAL, "Directory where Ephemeris files are located"); LALregSTRINGUserStruct(status,ephemYear, 'y', UVAR_OPTIONAL, "Year (or range of years) of ephemeris files to be used"); @@ -813,7 +812,7 @@ initUserVars (LALStatus *status, UserInput_t *uvar) LALregSTRINGUserStruct(status,gridFile, 0, UVAR_OPTIONAL, "Load grid from this file: sky-grid or full-grid depending on --gridType."); LALregREALUserStruct(status, refTime, 0, UVAR_OPTIONAL, "SSB reference time for pulsar-parameters [Default: startTime]"); LALregREALUserStruct(status, refTimeMJD, 0, UVAR_OPTIONAL, "SSB reference time for pulsar-parameters in MJD [Default: startTime]"); - LALregREALUserStruct(status, dopplermax, 'q', UVAR_OPTIONAL, "Maximum doppler shift expected"); + LALregREALUserStruct(status, dopplermax, 'q', UVAR_OPTIONAL, "Maximum doppler shift expected"); LALregSTRINGUserStruct(status,outputFstat, 0, UVAR_OPTIONAL, "Output-file for F-statistic field over the parameter-space"); LALregSTRINGUserStruct(status,outputLoudest, 0, UVAR_OPTIONAL, "Loudest F-statistic candidate + estimated MLE amplitudes"); @@ -833,7 +832,7 @@ initUserVars (LALStatus *status, UserInput_t *uvar) /* ----- more experimental/expert options ----- */ LALregINTUserStruct (status, SSBprecision, 0, UVAR_DEVELOPER, "Precision to use for time-transformation to SSB: 0=Newtonian 1=relativistic"); - + LALregBOOLUserStruct(status, useRAA, 0, UVAR_DEVELOPER, "Use rigid adiabatic approximation (RAA) for detector response"); LALregBOOLUserStruct(status, bufferedRAA, 0, UVAR_DEVELOPER, "Approximate RAA by using only middle-frequency"); @@ -841,7 +840,7 @@ initUserVars (LALStatus *status, UserInput_t *uvar) LALregINTUserStruct(status, Dterms, 't', UVAR_DEVELOPER, "Number of terms to keep in Dirichlet kernel sum"); LALregSTRINGUserStruct(status,workingDir, 'w', UVAR_DEVELOPER, "Directory to use as work directory."); - LALregREALUserStruct(status, timerCount, 0, UVAR_DEVELOPER, "N: Output progress/timer info every N templates"); + LALregREALUserStruct(status, timerCount, 0, UVAR_DEVELOPER, "N: Output progress/timer info every N templates"); LALregREALUserStruct(status, internalRefTime, 0, UVAR_DEVELOPER, "internal reference time to use for Fstat-computation [Default: startTime]"); LALregINTUserStruct(status, upsampleSFTs, 0, UVAR_DEVELOPER, "(integer) Factor to up-sample SFTs by"); @@ -849,7 +848,7 @@ initUserVars (LALStatus *status, UserInput_t *uvar) LALregSTRINGUserStruct(status,outputLogPrintf, 0, UVAR_DEVELOPER, "Send all output from LogPrintf statements to this file"); - LALregBOOLUserStruct(status, countTemplates, 0, UVAR_DEVELOPER, "Count number of templates (if supported) instead of search"); + LALregBOOLUserStruct(status, countTemplates, 0, UVAR_DEVELOPER, "Count number of templates (if supported) instead of search"); LALregREALUserStruct(status, spindownAge, 0, UVAR_DEVELOPER, "Spindown age for --gridType=9"); LALregREALUserStruct(status, minBraking, 0, UVAR_DEVELOPER, "Minimum braking index for --gridType=9"); @@ -861,12 +860,12 @@ initUserVars (LALStatus *status, UserInput_t *uvar) /** Load Ephemeris from ephemeris data-files */ void -InitEphemeris (LALStatus * status, +InitEphemeris (LALStatus * status, EphemerisData *edat, /**< [out] the ephemeris-data */ const CHAR *ephemDir, /**< directory containing ephems */ const CHAR *ephemYear, /**< which years do we need? */ LIGOTimeGPS epoch, /**< epoch of observation */ - BOOLEAN isLISA /**< hack this function for LISA ephemeris */ + BOOLEAN isLISA /**< hack this function for LISA ephemeris */ ) { #define FNAME_LENGTH 1024 @@ -885,7 +884,7 @@ InitEphemeris (LALStatus * status, snprintf(EphemEarth, FNAME_LENGTH, "%s/ephemMLDC.dat", ephemDir); else snprintf(EphemEarth, FNAME_LENGTH, "%s/earth%s.dat", ephemDir, ephemYear); - + snprintf(EphemSun, FNAME_LENGTH, "%s/sun%s.dat", ephemDir, ephemYear); } else @@ -896,24 +895,16 @@ InitEphemeris (LALStatus * status, snprintf(EphemEarth, FNAME_LENGTH, "earth%s.dat", ephemYear); snprintf(EphemSun, FNAME_LENGTH, "sun%s.dat", ephemYear); } - + EphemEarth[FNAME_LENGTH-1]=0; EphemSun[FNAME_LENGTH-1]=0; - + /* NOTE: the 'ephiles' are ONLY ever used in LALInitBarycenter, which is * why we can use local variables (EphemEarth, EphemSun) to initialize them. */ edat->ephiles.earthEphemeris = EphemEarth; edat->ephiles.sunEphemeris = EphemSun; - edat->leap = XLALGPSLeapSeconds( epoch.gpsSeconds ); - { - INT4 err = xlalErrno; - if ( err != XLAL_SUCCESS ) { - ABORT ( status, err, "XLALLeapSeconds() failed!\n"); - } - } - TRY (LALInitBarycenter(status->statusPtr, edat), status); DETATCHSTATUSPTR ( status ); @@ -959,16 +950,16 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) maxEndTimeGPS.gpsSeconds = uvar->maxEndTime; constraints.startTime = &minStartTimeGPS; constraints.endTime = &maxEndTimeGPS; - + /* get full SFT-catalog of all matching (multi-IFO) SFTs */ LogPrintf (LOG_DEBUG, "Finding all SFTs to load ... "); - TRY ( LALSFTdataFind ( status->statusPtr, &catalog, uvar->DataFiles, &constraints ), status); + TRY ( LALSFTdataFind ( status->statusPtr, &catalog, uvar->DataFiles, &constraints ), status); LogPrintfVerbatim (LOG_DEBUG, "done. (found %d SFTs)\n", catalog->length); - if ( constraints.detector ) + if ( constraints.detector ) LALFree ( constraints.detector ); - if ( !catalog || catalog->length == 0 ) + if ( !catalog || catalog->length == 0 ) { LALPrintError ("\nSorry, didn't find any matching SFTs with pattern '%s'!\n\n", uvar->DataFiles ); ABORT ( status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); @@ -982,11 +973,11 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) XLALGPSAdd(&endTime, cfg->Tsft); /* add on Tsft to last SFT start-time */ /* ----- get reference-times (from user if given, use startTime otherwise): ----- */ - if ( LALUserVarWasSet(&uvar->refTime)) + if ( LALUserVarWasSet(&uvar->refTime)) { XLALGPSSetREAL8(&(cfg->refTime), uvar->refTime); - } - else if (LALUserVarWasSet(&uvar->refTimeMJD)) + } + else if (LALUserVarWasSet(&uvar->refTimeMJD)) { /* convert MJD peripase to GPS using Matt Pitkins code found at lal/packages/pulsar/src/BinaryPulsarTimeing.c */ REAL8 GPSfloat; @@ -1018,13 +1009,13 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) * f0/f1 are taken as the maximum/minimum value appropriate for getting the * maximum/minimum values of f1/f2 (note that f1 is strictly negative here). */ - - f1dotMin = -1.0 * fMin / ((uvar->minBraking - 1.0) * uvar->spindownAge); - f1dotMax = -1.0 * fMax / ((uvar->maxBraking - 1.0) * uvar->spindownAge); + + f1dotMin = -1.0 * fMax / ((uvar->minBraking - 1.0) * uvar->spindownAge); + f1dotMax = -1.0 * fMin / ((uvar->maxBraking - 1.0) * uvar->spindownAge); f2dotMin = uvar->minBraking * (f1dotMax * f1dotMax) / fMax; f2dotMax = uvar->maxBraking * (f1dotMin * f1dotMin) / fMin; - + } /* Used for all other --gridTypes */ @@ -1032,15 +1023,15 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) f1dotMin = MYMIN ( uvar->f1dot, uvar->f1dot + uvar->f1dotBand ); f1dotMax = MYMAX ( uvar->f1dot, uvar->f1dot + uvar->f1dotBand ); - + f2dotMin = MYMIN ( uvar->f2dot, uvar->f2dot + uvar->f2dotBand ); f2dotMax = MYMAX ( uvar->f2dot, uvar->f2dot + uvar->f2dotBand ); - + } f3dotMin = MYMIN ( uvar->f3dot, uvar->f3dot + uvar->f3dotBand ); f3dotMax = MYMAX ( uvar->f3dot, uvar->f3dot + uvar->f3dotBand ); - + spinRangeRef.refTime = cfg->refTime; spinRangeRef.fkdot[0] = fMin; spinRangeRef.fkdot[1] = f1dotMin; @@ -1054,7 +1045,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) } /* spin-range at refTime */ { /* ----- What frequency-band do we need to read from the SFTs? - * propagate spin-range from refTime to startTime and endTime of observation + * propagate spin-range from refTime to startTime and endTime of observation */ PulsarSpinRange spinRangeStart, spinRangeEnd; /* temporary only */ REAL8 fmaxStart, fmaxEnd, fminStart, fminEnd; @@ -1066,7 +1057,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) fminStart = spinRangeStart.fkdot[0]; /* ranges are in canonical format! */ - fmaxStart = fminStart + spinRangeStart.fkdotBand[0]; + fmaxStart = fminStart + spinRangeStart.fkdotBand[0]; fminEnd = spinRangeEnd.fkdot[0]; fmaxEnd = fminEnd + spinRangeEnd.fkdotBand[0]; @@ -1080,7 +1071,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) UINT4 wings = MYMAX(uvar->Dterms, uvar->RngMedWindow/2 +1); /* extra frequency-bins needed for rngmed, and Dterms */ REAL8 fMax = (1.0 + uvar->dopplermax) * fCoverMax + wings / cfg->Tsft; /* correct for doppler-shift and wings */ REAL8 fMin = (1.0 - uvar->dopplermax) * fCoverMin - wings / cfg->Tsft; - + LogPrintf (LOG_DEBUG, "Loading SFTs ... "); TRY ( LALLoadMultiSFTs ( status->statusPtr, &(cfg->multiSFTs), catalog, fMin, fMax ), status ); LogPrintfVerbatim (LOG_DEBUG, "done.\n"); @@ -1109,11 +1100,11 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) /* ----- normalize SFTs and calculate noise-weights ----- */ if ( uvar->SignalOnly ) cfg->multiNoiseWeights = NULL; /* noiseWeights == NULL is equivalent to unit noise-weights in ComputeFstat() */ - else + else { UINT4 X, alpha; MultiPSDVector *rngmed = NULL; - cfg->multiNoiseWeights = NULL; + cfg->multiNoiseWeights = NULL; TRY ( LALNormalizeMultiSFTVect (status->statusPtr, &rngmed, cfg->multiSFTs, uvar->RngMedWindow ), status ); TRY ( LALComputeMultiNoiseWeights (status->statusPtr, &(cfg->multiNoiseWeights), rngmed, uvar->RngMedWindow, 0 ), status ); TRY ( LALDestroyMultiPSDVector (status->statusPtr, &rngmed ), status ); @@ -1128,7 +1119,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) { UINT4 X, numDet = cfg->multiSFTs->length; LogPrintf (LOG_DEBUG, "Writing original SFTs for debugging ... "); - for (X=0; X < numDet ; X ++ ) + for (X=0; X < numDet ; X ++ ) { TRY ( LALWriteSFTVector2Dir ( status->statusPtr, cfg->multiSFTs->data[X], "./", "original", "orig"), status ); } @@ -1145,7 +1136,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) CHAR tag[60]; sprintf (tag, "upsampled%02d", uvar->upsampleSFTs ); LogPrintf (LOG_DEBUG, "Writing upsampled SFTs for debugging ... "); - for (X=0; X < numDet ; X ++ ) + for (X=0; X < numDet ; X ++ ) { TRY ( LALWriteSFTVector2Dir ( status->statusPtr, cfg->multiSFTs->data[X], "./", tag, tag), status ); } @@ -1153,13 +1144,13 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) } /* define sky position variables from user input */ - if (LALUserVarWasSet(&uvar->RA)) + if (LALUserVarWasSet(&uvar->RA)) { /* use Matt Pitkins conversion code found in lal/packages/pulsar/src/BinaryPulsarTiming.c */ cfg->Alpha = LALDegsToRads(uvar->RA, "alpha"); } else cfg->Alpha = uvar->Alpha; - if (LALUserVarWasSet(&uvar->Dec)) + if (LALUserVarWasSet(&uvar->Dec)) { /* use Matt Pitkins conversion code found in lal/packages/pulsar/src/BinaryPulsarTiming.c */ cfg->Delta = LALDegsToRads(uvar->Dec, "delta"); @@ -1170,7 +1161,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) LIGOTimeGPS internalRefTime = empty_LIGOTimeGPS; PulsarSpinRange spinRangeInt = empty_PulsarSpinRange; BOOLEAN haveAlphaDelta = (LALUserVarWasSet(&uvar->Alpha) && LALUserVarWasSet(&uvar->Delta)) || (LALUserVarWasSet(&uvar->RA) && LALUserVarWasSet(&uvar->Dec)); - + if (uvar->skyRegion) { cfg->searchRegion.skyRegionString = (CHAR*)LALCalloc(1, strlen(uvar->skyRegion)+1); @@ -1204,7 +1195,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) cfg->CFparams.SSBprec = uvar->SSBprecision; cfg->CFparams.useRAA = uvar->useRAA; cfg->CFparams.bufferedRAA = uvar->bufferedRAA; - cfg->CFparams.upsampling = 1.0 * uvar->upsampleSFTs; + cfg->CFparams.upsampling = 1.0 * uvar->upsampleSFTs; /* ----- set fixed grid step-sizes from user-input for GRID_FLAT ----- */ cfg->stepSizes.Alpha = uvar->dAlpha; @@ -1217,13 +1208,13 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) /* ----- set up scanline-window if requested for 1D local-maximum clustering on scanline ----- */ if ( (cfg->scanlineWindow = XLALCreateScanlineWindow ( uvar->clusterOnScanline )) == NULL ) { - ABORT (status, COMPUTEFSTATISTIC_EMEM, COMPUTEFSTATISTIC_MSGEMEM ); + ABORT (status, COMPUTEFSTATISTIC_EMEM, COMPUTEFSTATISTIC_MSGEMEM ); } /* initialize full multi-dimensional Doppler-scanner */ { DopplerFullScanInit scanInit; /* init-structure for DopperScanner */ - + scanInit.searchRegion = cfg->searchRegion; scanInit.gridType = uvar->gridType; scanInit.gridFile = uvar->gridFile; @@ -1244,7 +1235,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) } LogPrintf (LOG_DEBUG, "Setting up template grid ... "); - TRY ( InitDopplerFullScan ( status->statusPtr, &cfg->scanState, &scanInit), status); + TRY ( InitDopplerFullScan ( status->statusPtr, &cfg->scanState, &scanInit), status); LogPrintfVerbatim (LOG_DEBUG, "template grid ready.\n"); XLALNumDopplerTemplates ( cfg->scanState ); } @@ -1261,7 +1252,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg, const UserInput_t *uvar ) /* ----- set up toplist if requested ----- */ if ( toplist_length > 0 ) if ( create_toplist( &(cfg->FstatToplist), toplist_length, sizeof(FstatCandidate), compareFstatCandidates) != 0 ) { - ABORT (status, COMPUTEFSTATISTIC_EMEM, COMPUTEFSTATISTIC_MSGEMEM ); + ABORT (status, COMPUTEFSTATISTIC_EMEM, COMPUTEFSTATISTIC_MSGEMEM ); } DETATCHSTATUSPTR (status); @@ -1308,7 +1299,7 @@ getLogString ( LALStatus *status, CHAR **logstr, const ConfigVariables *cfg ) ret = append_string ( ret, "%% Loaded SFTs: [ " ); for ( i=0; i < numDet; i ++ ) { - sprintf (line, "%s:%d%s", cfg->multiSFTs->data[i]->data->name, + sprintf (line, "%s:%d%s", cfg->multiSFTs->data[i]->data->name, cfg->multiSFTs->data[i]->length, (i < numDet - 1)?", ":" ]\n"); ret = append_string ( ret, line ); @@ -1316,10 +1307,10 @@ getLogString ( LALStatus *status, CHAR **logstr, const ConfigVariables *cfg ) utc = *XLALGPSToUTC( &utc, (INT4)GPS2REAL8(cfg->multiDetStates->startTime) ); strcpy ( dateStr, asctime(&utc) ); dateStr[ strlen(dateStr) - 1 ] = 0; - sprintf (line, "%%%% Start GPS time tStart = %12.3f (%s GMT)\n", + sprintf (line, "%%%% Start GPS time tStart = %12.3f (%s GMT)\n", GPS2REAL8(cfg->multiDetStates->startTime), dateStr); ret = append_string ( ret, line ); - sprintf (line, "%%%% Total time spanned = %12.3f s (%.1f hours)\n", + sprintf (line, "%%%% Total time spanned = %12.3f s (%.1f hours)\n", cfg->multiDetStates->Tspan, cfg->multiDetStates->Tspan/3600 ); ret = append_string ( ret, line ); sprintf (line, "%%%% Pulsar-params refTime = %12.3f \n", GPS2REAL8(cfg->refTime) ); @@ -1330,11 +1321,11 @@ getLogString ( LALStatus *status, CHAR **logstr, const ConfigVariables *cfg ) ret = append_string ( ret, line ); ret = append_string (ret, "fkdot = [ " ); - for (i=0; i < numSpins; i ++ ) + for (i=0; i < numSpins; i ++ ) { - sprintf (line, "%.16g:%.16g%s", - cfg->searchRegion.fkdot[i], - cfg->searchRegion.fkdot[i] + cfg->searchRegion.fkdotBand[i], + sprintf (line, "%.16g:%.16g%s", + cfg->searchRegion.fkdot[i], + cfg->searchRegion.fkdot[i] + cfg->searchRegion.fkdotBand[i], (i < numSpins - 1)?", ":" ]\n"); ret = append_string ( ret, line ); } @@ -1385,7 +1376,7 @@ WriteFStatLog ( LALStatus *status, const CHAR *log_fname, const CHAR *log_string /** Free all globally allocated memory. */ void -Freemem(LALStatus *status, ConfigVariables *cfg) +Freemem(LALStatus *status, ConfigVariables *cfg) { INITSTATUS (status, "Freemem", rcsid); ATTATCHSTATUSPTR (status); @@ -1411,13 +1402,13 @@ Freemem(LALStatus *status, ConfigVariables *cfg) if ( cfg->searchRegion.skyRegionString ) LALFree ( cfg->searchRegion.skyRegionString ); - + /* Free ephemeris data */ LALFree(cfg->ephemeris->ephemE); LALFree(cfg->ephemeris->ephemS); LALFree(cfg->ephemeris); - if ( cfg->logstring ) + if ( cfg->logstring ) LALFree ( cfg->logstring ); DETATCHSTATUSPTR (status); @@ -1434,13 +1425,13 @@ void checkUserInputConsistency (LALStatus *status, const UserInput_t *uvar) { - INITSTATUS (status, "checkUserInputConsistency", rcsid); - + INITSTATUS (status, "checkUserInputConsistency", rcsid); + if (uvar->ephemYear == NULL) { LALPrintError ("\nNo ephemeris year specified (option 'ephemYear')\n\n"); ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); - } + } /* check that only alpha OR RA has been set */ if ( LALUserVarWasSet(&uvar->Alpha) && (LALUserVarWasSet(&uvar->RA)) ) @@ -1525,7 +1516,7 @@ checkUserInputConsistency (LALStatus *status, const UserInput_t *uvar) { BOOLEAN haveAlphaBand = LALUserVarWasSet( &uvar->AlphaBand ); BOOLEAN haveDeltaBand = LALUserVarWasSet( &uvar->DeltaBand ); - BOOLEAN haveSkyRegion, haveAlphaDelta, haveGridFile; + BOOLEAN haveSkyRegion, haveAlphaDelta, haveGridFile; BOOLEAN useSkyGridFile, useFullGridFile, haveMetric, useMetric; haveSkyRegion = (uvar->skyRegion != NULL); @@ -1543,17 +1534,17 @@ checkUserInputConsistency (LALStatus *status, const UserInput_t *uvar) if ( useSkyGridFile && !haveGridFile ) { LALPrintError ("\nERROR: gridType=SKY-FILE, but no --gridFile specified!\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } if ( useFullGridFile && !haveGridFile ) { LALPrintError ("\nERROR: gridType=GRID-FILE, but no --gridFile specified!\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } if ( (haveAlphaBand && !haveDeltaBand) || (haveDeltaBand && !haveAlphaBand) ) { - LALPrintError ("\nERROR: Need either BOTH (AlphaBand, DeltaBand) or NONE.\n\n"); + LALPrintError ("\nERROR: Need either BOTH (AlphaBand, DeltaBand) or NONE.\n\n"); ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } @@ -1562,14 +1553,14 @@ checkUserInputConsistency (LALStatus *status, const UserInput_t *uvar) LALPrintError ("\nOverdetermined sky-region: only use EITHER (Alpha,Delta) OR skyRegion!\n\n"); ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } - if ( !useMetric && haveMetric) + if ( !useMetric && haveMetric) { LALWarning (status, "\nWARNING: Metric was specified for non-metric grid... will be ignored!\n"); } - if ( useMetric && !haveMetric) + if ( useMetric && !haveMetric) { LALPrintError ("\nERROR: metric grid-type selected, but no metricType selected\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } /* Specific checks for --gridType=GRID_SPINDOWN_{SQUARE,AGEBRK} parameter spaces */ @@ -1578,13 +1569,13 @@ checkUserInputConsistency (LALStatus *status, const UserInput_t *uvar) /* Check that no third spindown range were given */ if (uvar->f3dot != 0.0 || uvar->f3dotBand != 0.0) { LALPrintError ("\nERROR: f3dot and f3dotBand cannot be used with gridType={8,9}\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } /* Check that no grid spacings were given */ if (uvar->df1dot != 0.0 || uvar->df2dot != 0.0 || uvar->df3dot != 0.0) { LALPrintError ("\nERROR: df{1,2,3}dot cannot be used with gridType={8,9}\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } } @@ -1595,29 +1586,29 @@ checkUserInputConsistency (LALStatus *status, const UserInput_t *uvar) /* Check age and braking indices */ if (uvar->spindownAge <= 0.0) { LALPrintError ("\nERROR: spindownAge must be strictly positive with gridType=9\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } if (uvar->minBraking <= 0.0) { LALPrintError ("\nERROR: minBraking must be strictly positive with gridType=9\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } if (uvar->maxBraking <= 0.0) { LALPrintError ("\nERROR: minBraking must be strictly positive with gridType=9\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } if (uvar->minBraking >= uvar->maxBraking) { LALPrintError ("\nERROR: minBraking must be strictly less than maxBraking with gridType=9\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } /* Check that no first and second spindown ranges were given */ if (uvar->f1dot != 0.0 || uvar->f1dotBand != 0.0) { LALPrintError ("\nERROR: f1dot and f1dotBand cannot be used with gridType=9\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } if (uvar->f2dot != 0.0 || uvar->f2dotBand != 0.0) { LALPrintError ("\nERROR: f2dot and f2dotBand cannot be used with gridType=9\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } } @@ -1627,11 +1618,11 @@ checkUserInputConsistency (LALStatus *status, const UserInput_t *uvar) /* check NumCandidatesToKeep and FracCandidatesToKeep */ if (LALUserVarWasSet(&uvar->NumCandidatesToKeep) && LALUserVarWasSet(&uvar->FracCandidatesToKeep)) { LALPrintError ("\nERROR: NumCandidatesToKeep and FracCandidatesToKeep are mutually exclusive\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } if (LALUserVarWasSet(&uvar->FracCandidatesToKeep) && (uvar->FracCandidatesToKeep <= 0.0 || 1.0 < uvar->FracCandidatesToKeep)) { LALPrintError ("\nERROR: FracCandidatesToKeep must be greater than 0.0 and less than or equal to 1.0\n\n"); - ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); + ABORT (status, COMPUTEFSTATISTIC_EINPUT, COMPUTEFSTATISTIC_MSGEINPUT); } RETURN (status); @@ -1648,7 +1639,7 @@ outputBeamTS( const CHAR *fname, const AMCoeffs *amcoe, const DetectorStateSerie if ( !fname || !amcoe || !amcoe->a || !amcoe->b || !detStates) return -1; - + len = amcoe->a->length; if ( (len != amcoe->b->length) || ( len != detStates->length ) ) return -1; @@ -1659,7 +1650,7 @@ outputBeamTS( const CHAR *fname, const AMCoeffs *amcoe, const DetectorStateSerie for (i=0; i < len; i ++ ) { INT4 ret; - ret = fprintf (fp, "%9d %f %f %f \n", + ret = fprintf (fp, "%9d %f %f %f \n", detStates->data[i].tGPS.gpsSeconds, detStates->data[i].LMST, amcoe->a->data[i], amcoe->b->data[i] ); if ( ret < 0 ) { @@ -1673,27 +1664,6 @@ outputBeamTS( const CHAR *fname, const AMCoeffs *amcoe, const DetectorStateSerie return 0; } /* outputBeamTS() */ -/* -============ -va ['stolen' from Quake2 (GPL'ed)] - -does a varargs printf into a temp buffer, so I don't need to have -varargs versions of all text functions. -FIXME: make this buffer size safe someday -============ -*/ -const char *va(const char *format, ...) -{ - va_list argptr; - static char string[1024]; - - va_start (argptr, format); - vsprintf (string, format,argptr); - va_end (argptr); - - return string; -} - /** write full 'PulsarCandidate' (i.e. Doppler params + Amplitude params + error-bars + Fa,Fb, F, + A,B,C,D * RETURN 0 = OK, -1 = ERROR */ @@ -1732,7 +1702,7 @@ write_PulsarCandidate_to_fp ( FILE *fp, const PulsarCandidate *pulsarParams, co fprintf (fp, "\n"); /* Binary parameters */ - if (pulsarParams->Doppler.orbit) + if (pulsarParams->Doppler.orbit) { fprintf (fp, "orbitPeriod = % .16g;\n", pulsarParams->Doppler.orbit->period ); fprintf (fp, "orbitasini = % .16g;\n", pulsarParams->Doppler.orbit->asini ); @@ -1763,13 +1733,17 @@ write_PulsarCandidate_to_fp ( FILE *fp, const PulsarCandidate *pulsarParams, co } /* write_PulsarCandidate_to_fp() */ /** comparison function for our candidates toplist */ -int +int compareFstatCandidates ( const void *candA, const void *candB ) { - if ( ((const FstatCandidate *)candA)->Fstat.F < ((const FstatCandidate *)candB)->Fstat.F ) + REAL8 F1 = ((const FstatCandidate *)candA)->Fstat.F; + REAL8 F2 = ((const FstatCandidate *)candB)->Fstat.F; + if ( F1 < F2 ) return 1; - else + else if ( F1 > F2 ) return -1; + else + return 0; } /* compareFstatCandidates() */ @@ -1784,12 +1758,12 @@ write_FstatCandidate_to_fp ( FILE *fp, const FstatCandidate *thisFCand ) return -1; fprintf (fp, "%.16g %.16g %.16g %.6g %.5g %.5g %.9g\n", - thisFCand->doppler.fkdot[0], thisFCand->doppler.Alpha, thisFCand->doppler.Delta, - thisFCand->doppler.fkdot[1], thisFCand->doppler.fkdot[2], thisFCand->doppler.fkdot[3], + thisFCand->doppler.fkdot[0], thisFCand->doppler.Alpha, thisFCand->doppler.Delta, + thisFCand->doppler.fkdot[1], thisFCand->doppler.fkdot[2], thisFCand->doppler.fkdot[3], 2.0 * thisFCand->Fstat.F ); - + return 0; - + } /* write_candidate_to_fp() */ /* -------------------------------------------------------------------------------- @@ -1837,10 +1811,10 @@ XLALDestroyScanlineWindow ( scanlineWindow_t *scanlineWindow ) LALFree ( scanlineWindow ); return; - + } /* XLALDestroyScanlineWindow() */ -/** Advance by pushing a new candidate into the scanline-window +/** Advance by pushing a new candidate into the scanline-window */ int XLALAdvanceScanlineWindow ( const FstatCandidate *nextCand, scanlineWindow_t *scanWindow ) @@ -1858,10 +1832,10 @@ XLALAdvanceScanlineWindow ( const FstatCandidate *nextCand, scanlineWindow_t *sc scanWindow->window[ scanWindow->length - 1 ] = *nextCand; /* struct-copy */ return XLAL_SUCCESS; - + } /* XLALAdvanceScanlineWindow() */ -/** check wether central candidate in Scanline-window is a local maximum +/** check wether central candidate in Scanline-window is a local maximum */ BOOLEAN XLALCenterIsLocalMax ( const scanlineWindow_t *scanWindow ) @@ -1879,7 +1853,7 @@ XLALCenterIsLocalMax ( const scanlineWindow_t *scanWindow ) return FALSE; return TRUE; - + } /* XLALCenterIsLocalMax() */ /** Simply output version information to stdout */ @@ -1921,4 +1895,3 @@ CHAR *append_string ( CHAR *str1, const CHAR *str2 ) return outstr; } /* append_string() */ - diff --git a/lalapps/src/pulsar/FDS_isolated/FrComputeFStatistic.c b/lalapps/src/pulsar/FDS_isolated/FrComputeFStatistic.c index 987e7ab8b2ef041c4c3dcce955957711cdf5b57d..dea1a75489b299d6d113687bfdd03b9a73ca5bbb 100644 --- a/lalapps/src/pulsar/FDS_isolated/FrComputeFStatistic.c +++ b/lalapps/src/pulsar/FDS_isolated/FrComputeFStatistic.c @@ -764,20 +764,15 @@ void CreateDemodParams (LALStatus *status) EmissionTime emit; AMCoeffsParams *amParams; LIGOTimeGPS *midTS=NULL; /* Time stamps for amplitude modulation coefficients */ - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; INT4 k; INITSTATUS (status, "CreateDemodParams", rcsid); ATTATCHSTATUSPTR (status); - + edat=(EphemerisData *)LALMalloc(sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = GV.EphemEarth; (*edat).ephiles.sunEphemeris = GV.EphemSun; - TRY (LALLeapSecs(status->statusPtr,&leap,×tamps[0],&formatAndAcc), status); - (*edat).leap=leap; - /* Reads in ephemeris files */ TRY (LALInitBarycenter(status->statusPtr, edat), status); @@ -806,7 +801,6 @@ void CreateDemodParams (LALStatus *status) amParams->das->pSource->orientation = 0.0; amParams->das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!!!!!!!!*/ - amParams->leapAcc=formatAndAcc.accuracy; /* Mid point of each SFT */ midTS = (LIGOTimeGPS *)LALCalloc(GV.SFTno,sizeof(LIGOTimeGPS)); diff --git a/lalapps/src/pulsar/FDS_isolated/Makefile.am b/lalapps/src/pulsar/FDS_isolated/Makefile.am index 9c999e7ef6f169810d1914f9aba31fdf3b0bd5eb..6a6831055c79ce6d88b22b16fa3c0c5351b2f933 100644 --- a/lalapps/src/pulsar/FDS_isolated/Makefile.am +++ b/lalapps/src/pulsar/FDS_isolated/Makefile.am @@ -17,7 +17,11 @@ bin_PROGRAMS = lalapps_ComputeFStatistic lalapps_FstatShapeTest lalapps_SemiAnal lalapps_makeInvetofile lalapps_extractSFTband lalapps_FindSh \ lalapps_monteint lalapps_zellepolka \ lalapps_ComputeFStatistic_v2 lalapps_PredictFStat \ - lalapps_ComputeFStatAnalyticMonteCarloUpperLimit + lalapps_ComputeFStatAnalyticMonteCarloUpperLimit \ + lalapps_synthesizeBstatMC + +EXTRA_PROGRAMS = lalapps_CFSv3 +check_PROGRAMS = testFstat_v3 lalapps_zellepolka_SOURCES = zellepolka.c lalapps_monteint_SOURCES = monteint.c @@ -55,7 +59,20 @@ lalapps_PredictFStat_SOURCES = PredictFStat.c lalapps_ComputeFStatAnalyticMonteCarloUpperLimit_SOURCES = ComputeFStatAnalyticMonteCarloUpperLimit.c +lalapps_synthesizeBstatMC_SOURCES = synthesizeBstatMC.c + +lalapps_CFSv3_SOURCES = CFSv3.c Fstat_v3.c Fstat_v3.h + +testFstat_v3_SOURCES = testFstat_v3.c Fstat_v3.c Fstat_v3.h + EXTRA_DIST = testFStat.sh testCFSv2.sh testGridv2.sh Fstats.ref1 Fstats.ref2 testPredictFStat.sh -TESTS = testFStat.sh testCFSv2.sh testGridv2.sh testPredictFStat.sh -CLEANFILES = + +TESTS = testFStat.sh testCFSv2.sh testGridv2.sh testPredictFStat.sh testFstat_v3 + +TESTS_ENVIRONMENT = \ +LAL_TOP_SRCDIR=$(LAL_TOP_SRCDIR) \ +LAL_PREFIX=$(LAL_PREFIX) \ +LAL_DATA_PATH=.:$${LAL_TOP_SRCDIR:+"$${LAL_TOP_SRCDIR}/packages/pulsar/test"}:$${LAL_PREFIX:+"$${LAL_PREFIX}/share/lal"} + +CLEANFILES = testFstat_v3-LFT.sft testFstat_v3-timeseries.dat diff --git a/lalapps/src/pulsar/FDS_isolated/PredictFStat.c b/lalapps/src/pulsar/FDS_isolated/PredictFStat.c index ccdd2eeaf1ee9d41d48656098f7807a2d9d4a902..0921b2516f9c9858b11a0458bd943cb0447b03fe 100644 --- a/lalapps/src/pulsar/FDS_isolated/PredictFStat.c +++ b/lalapps/src/pulsar/FDS_isolated/PredictFStat.c @@ -297,8 +297,8 @@ initUserVars (LALStatus *status, UserInput_t *uvar ) LALregREALUserStruct(status, h0, 's', UVAR_OPTIONAL, "Overall GW amplitude h0 [alternative to {aPlus, aCross}]"); LALregREALUserStruct(status, cosi, 'i', UVAR_OPTIONAL, "Inclination angle of rotation axis cos(iota) [alternative to {aPlus, aCross}]"); - LALregREALUserStruct(status, psi, 'Y', UVAR_REQUIRED, "Polarisation angle in radians"); - LALregREALUserStruct(status, phi0, 'Y', UVAR_OPTIONAL, "Initial GW phase phi0 in radians"); + LALregREALUserStruct(status, psi, 0, UVAR_REQUIRED, "Polarisation angle in radians"); + LALregREALUserStruct(status, phi0, 0, UVAR_OPTIONAL, "Initial GW phase phi0 in radians"); LALregREALUserStruct(status, Alpha, 'a', UVAR_REQUIRED, "Sky position alpha (equatorial coordinates) in radians"); LALregREALUserStruct(status, Delta, 'd', UVAR_REQUIRED, "Sky position delta (equatorial coordinates) in radians"); @@ -363,8 +363,6 @@ InitEphemeris (LALStatus * status, edat->ephiles.earthEphemeris = EphemEarth; edat->ephiles.sunEphemeris = EphemSun; - edat->leap = (INT2) XLALGPSLeapSeconds ( epoch.gpsSeconds ); - TRY (LALInitBarycenter(status->statusPtr, edat), status); DETATCHSTATUSPTR ( status ); diff --git a/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/ComputeFStatistic_resamp.c b/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/ComputeFStatistic_resamp.c index 80b6780f0d47521c45244993bb53c28dcdd958cb..84463734c5450c5c34e50ce20912ea43b39fcf43 100644 --- a/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/ComputeFStatistic_resamp.c +++ b/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/ComputeFStatistic_resamp.c @@ -49,6 +49,7 @@ int finite(double); #include <lal/SFTfileIO.h> #include <lal/ExtrapolatePulsarSpins.h> #include <lal/FrequencySeries.h> +#include <lal/GSLSupport.h> #include <lal/NormalizeSFTRngMed.h> #include <lal/ComputeFstat.h> @@ -82,8 +83,6 @@ NRCSID(TEMPORARY,"$Blah$"); #define TRUE (1==1) #define FALSE (1==0) -/*----- SWITCHES -----*/ -#define NUM_SPINS 4 /* number of spin-values to consider: {f, fdot, f2dot, ... } */ /*----- Error-codes -----*/ #define COMPUTEFSTATISTIC_ENULL 1 @@ -110,6 +109,7 @@ NRCSID(TEMPORARY,"$Blah$"); #define MYMIN(x,y) ( (x) < (y) ? (x) : (y) ) #define LAL_INT4_MAX 2147483647 +UINT4 FactorialLookup[7] = {1,1,2,6,24,120,720,5040}; /*---------- internal types ----------*/ @@ -135,6 +135,8 @@ typedef struct * These are 'pre-processed' settings, which have been derived from the user-input. */ typedef struct { + REAL8 Alpha; /**< sky position alpha in radians */ + REAL8 Delta; /**< sky position delta in radians */ REAL8 Tsft; /**< length of one SFT in seconds */ LIGOTimeGPS refTime; /**< reference-time for pulsar-parameters in SBB frame */ /* -------------------- Resampling -------------------- */ @@ -167,9 +169,11 @@ REAL8 uvar_Freq; REAL8 uvar_FreqBand; REAL8 uvar_dFreq; REAL8 uvar_Alpha; +CHAR* uvar_RA; REAL8 uvar_dAlpha; REAL8 uvar_AlphaBand; REAL8 uvar_Delta; +CHAR* uvar_Dec; REAL8 uvar_dDelta; REAL8 uvar_DeltaBand; /* 1st spindown */ @@ -199,10 +203,14 @@ CHAR *uvar_outputLogfile; CHAR *uvar_outputFstat; CHAR *uvar_outputLoudest; CHAR *uvar_outputTimeSeries; +BOOLEAN uvar_countTemplates; INT4 uvar_NumCandidatesToKeep; INT4 uvar_clusterOnScanline; +CHAR *uvar_outputFstatHist; /**< output discrete histogram of all Fstatistic values */ +REAL8 uvar_FstatHistBin; /**< width of an Fstatistic histogram bin */ + CHAR *uvar_gridFile; REAL8 uvar_dopplermax; INT4 uvar_RngMedWindow; @@ -215,6 +223,8 @@ INT4 uvar_maxEndTime; CHAR *uvar_workingDir; REAL8 uvar_timerCount; INT4 uvar_upsampleSFTs; +REAL8 uvar_WinFrac; +REAL8 uvar_BandFrac; REAL8 BaryRefTime; @@ -308,14 +318,13 @@ void XLALDestroyMultiCmplxAMCoeffs(MultiCmplxAMCoeffs *X); REAL8Sequence* XLALCreateREAL8Sequence(UINT4 length); MultiFFTWCOMPLEXSeries *XLALCreateMultiFFTWCOMPLEXSeries(UINT4 length); FFTWCOMPLEXSeries *XLALCreateFFTWCOMPLEXSeries(UINT4 length); -UINT4 factorial(UINT4 x); REAL8 magsquare(fftw_complex f); INT4 CombineSFTs(COMPLEX16Vector *L,SFTVector *sft_vect,REAL8 FMIN,INT4 number,INT4 startindex); void ApplyWindow(REAL8Window *Win, COMPLEX16Vector *X); void Reshuffle(COMPLEX16Vector *X); void PrintL(FFTWCOMPLEXSeries* L,REAL8 min,REAL8 step); void ApplyHetCorrection(REAL8Sequence *BaryTimes, REAL8Sequence *DetectorTimes, const REAL8Sequence *Real, const REAL8Sequence *Imag, REAL8Sequence *Times, MultiCOMPLEX8TimeSeries *TSeries, REAL8Sequence* Real_Corrected, REAL8Sequence* Imag_Corrected); -void ApplySpinDowns(const PulsarSpins *SpinDowns, REAL8 dt, const FFTWCOMPLEXSeries *FaIn, const FFTWCOMPLEXSeries *FbIn, REAL8 BaryStartTime,REAL8Sequence *CorrTimes, REAL8 RefTime, FFTWCOMPLEXSeries *FaInSpinCorrected, FFTWCOMPLEXSeries *FbInSpinCorrected); +void ApplySpinDowns(const PulsarSpins *SpinDowns, REAL8 dt, const FFTWCOMPLEXSeries *FaIn, const FFTWCOMPLEXSeries *FbIn, REAL8 BaryStartTime,REAL8Sequence *CorrTimes, REAL8 RefTime, FFTWCOMPLEXSeries *FaInSpinCorrected, FFTWCOMPLEXSeries *FbInSpinCorrected,UINT4 NUM_SPINS); void ApplyAandB(REAL8Sequence *FineBaryTimes,REAL8Sequence *BaryTimes,REAL8Sequence *a,REAL8Sequence *b,REAL8Sequence *Real,REAL8Sequence *Imag,FFTWCOMPLEXSeries *FaIn, FFTWCOMPLEXSeries *FbIn, REAL8 TSFT); double sinc(double t); void retband(REAL8 t0, REAL8 dt, REAL8* t,REAL8* x, REAL8* y,UINT4 n,UINT4 size, UINT4 terms); @@ -335,7 +344,7 @@ void Freemem(LALStatus *, ConfigVariables *cfg); void WriteFStatLog (LALStatus *, CHAR *argv[], const CHAR *log_fname); void checkUserInputConsistency (LALStatus *); int outputBeamTS( const CHAR *fname, const AMCoeffs *amcoe, const DetectorStateSeries *detStates ); -void InitEphemeris (LALStatus *, EphemerisData *edat, const CHAR *ephemDir, const CHAR *ephemYear, LIGOTimeGPS epoch, BOOLEAN isLISA); +void InitEphemeris (LALStatus *, EphemerisData *edat, const CHAR *ephemDir, const CHAR *ephemYear, BOOLEAN isLISA); void getUnitWeights ( LALStatus *, MultiNoiseWeights **multiWeights, const MultiSFTVector *multiSFTs ); int write_FstatCandidate_to_fp ( FILE *fp, const FstatCandidate *thisFCand ); @@ -344,8 +353,6 @@ int write_PulsarCandidate_to_fp ( FILE *fp, const PulsarCandidate *pulsarParams int compareFstatCandidates ( const void *candA, const void *candB ); void getLogString ( LALStatus *status, CHAR **logstr, const ConfigVariables *cfg ); -const char *va(const char *format, ...); /* little var-arg string helper function */ - /* ---------- scanline window functions ---------- */ scanlineWindow_t *XLALCreateScanlineWindow ( UINT4 windowWings ); void XLALDestroyScanlineWindow ( scanlineWindow_t *scanlineWindow ); @@ -384,6 +391,7 @@ int main(int argc,char *argv[]) ConfigVariables GV = empty_ConfigVariables; /**< global container for various derived configuration settings */ REAL8FrequencySeries *fstatVector = Buffer.fstatVector; Resamp_Variables Vars; + gsl_vector_int *Fstat_histogram = NULL; Buffer.fstatVector = NULL; lalDebugLevel = 0; @@ -430,6 +438,15 @@ int main(int argc,char *argv[]) fprintf (fpFstat, "%s", GV.logstring ); } /* if outputFstat */ + /* start Fstatistic histogram with a single empty bin */ + if (uvar_outputFstatHist) { + if ((Fstat_histogram = gsl_vector_int_alloc(1)) == NULL) { + LALPrintError("\nCouldn't allocate 'Fstat_histogram'\n"); + return COMPUTEFSTATISTIC_EMEM; + } + gsl_vector_int_set_zero(Fstat_histogram); + } + /* if a complete output of the Time Series was requested, * we open and prepare the output-file here */ if (uvar_outputTimeSeries) @@ -444,6 +461,11 @@ int main(int argc,char *argv[]) /* count number of templates */ numTemplates = XLALNumDopplerTemplates ( GV.scanState ); + if(uvar_countTemplates) + { + printf("%%%% Number of templates: %0.0f\n",numTemplates); + exit(0); + } /*Call the CalcTimeSeries Function Here*/ LogPrintf (LOG_DEBUG, "Calculating Time Series.\n"); @@ -460,8 +482,10 @@ int main(int argc,char *argv[]) LogPrintf (LOG_DEBUG, "Done Calculating Time Series.\n"); LogPrintf (LOG_DEBUG, "Starting Main Resampling Loop.\n"); - while ( XLALNextDopplerPos( &dopplerpos, GV.scanState ) == 0 ) + while ((XLALNextDopplerPos( &dopplerpos, GV.scanState ) == 0) ) { + REAL8 deltaF_refTime = 0; + /* main function call: compute F-statistic over frequency-band */ LAL_CALL( ComputeFStat_resamp ( &status, &dopplerpos, GV.multiSFTs, GV.multiNoiseWeights,GV.multiDetStates, &GV.CFparams, &Buffer, TSeries,&Vars), &status ); @@ -478,10 +502,17 @@ int main(int argc,char *argv[]) templateCounter, numTemplates, templateCounter/numTemplates * 100.0, timeLeft); } + { + REAL8 Freq_InternalRefTime = dopplerpos.fkdot[0]; + LAL_CALL ( LALExtrapolatePulsarSpins ( &status, dopplerpos.fkdot, GV.refTime, dopplerpos.fkdot, GV.searchRegion.refTime ), &status ); + deltaF_refTime = dopplerpos.fkdot[0] - Freq_InternalRefTime; + dopplerpos.refTime = GV.refTime; + } + for ( k=0; k < fstatVector->data->length; k++) { REAL8 thisF = fstatVector->data->data[k]; - REAL8 thisFreq = fstatVector->f0 + k * fstatVector->deltaF; + REAL8 thisFreq = fstatVector->f0 + k * fstatVector->deltaF + deltaF_refTime; /* sanity check on the result */ if ( !finite ( thisF ) ) { @@ -493,10 +524,7 @@ int main(int argc,char *argv[]) } /* propagate fkdot from internalRefTime back to refTime for outputting results */ - /* FIXE: only do this for candidates we're going to write out */ dopplerpos.fkdot[0] = thisFreq; - /*LAL_CALL ( LALExtrapolatePulsarSpins ( &status, dopplerpos.fkdot, GV.refTime, dopplerpos.fkdot, GV.searchRegion.refTime ), &status );*/ - dopplerpos.refTime = GV.refTime; /* correct normalization in --SignalOnly case: * we didn't normalize data by 1/sqrt(Tsft * 0.5 * Sh) in terms of @@ -544,6 +572,25 @@ int main(int argc,char *argv[]) if ( thisFCand.Fstat.F > loudestFCand.Fstat.F ) loudestFCand = thisFCand; + /* add Fstatistic to histogram if needed */ + if (uvar_outputFstatHist) + { + + /* compute bin */ + const size_t bin = 2.0 * thisFCand.Fstat.F / uvar_FstatHistBin; + + /* resize histogram vector if needed */ + if (!Fstat_histogram || bin >= Fstat_histogram->size) + if (NULL == (Fstat_histogram = XLALResizeGSLVectorInt(Fstat_histogram, bin + 1, 0))) { + LALPrintError("\nCouldn't (re)allocate 'Fstat_histogram'\n"); + return COMPUTEFSTATISTIC_EMEM; + } + + /* add to bin */ + gsl_vector_int_set(Fstat_histogram, bin, + gsl_vector_int_get(Fstat_histogram, bin) + 1); + + } } /* inner loop about frequency-bins from resampling frequ-band */ } /* while more Doppler positions to scan */ @@ -617,6 +664,31 @@ int main(int argc,char *argv[]) LogPrintf (LOG_DEBUG, "Search finished.\n"); + /* write out the Fstatistic histogram */ + if (uvar_outputFstatHist) + { + + size_t i = 0; + FILE *fpFstatHist = fopen(uvar_outputFstatHist, "wb"); + + if (fpFstatHist == NULL) { + LALPrintError ("\nError opening file '%s' for writing..\n\n", uvar_outputFstat); + return (COMPUTEFSTATISTIC_ESYS); + } + fprintf(fpFstatHist, "%s", GV.logstring); + + for (i = 0; i < Fstat_histogram->size; ++i) + fprintf(fpFstatHist, "%0.3g %0.3g %i\n", + uvar_FstatHistBin * i, + uvar_FstatHistBin * (i + 1), + gsl_vector_int_get(Fstat_histogram, i)); + + fprintf(fpFstatHist, "%%DONE\n"); + fclose(fpFstatHist); + + } + + /* Free memory */ LogPrintf (LOG_DEBUG, "Freeing Doppler grid ... "); LAL_CALL ( FreeDopplerFullScan(&status, &GV.scanState), &status); @@ -626,6 +698,9 @@ int main(int argc,char *argv[]) LAL_CALL ( Freemem(&status, &GV), &status); + if (Fstat_histogram) + gsl_vector_int_free(Fstat_histogram); + /* did we forget anything ? */ LALCheckMemoryLeaks(); @@ -653,6 +728,8 @@ initUserVars (LALStatus *status) uvar_AlphaBand = 0; uvar_DeltaBand = 0; uvar_skyRegion = NULL; + uvar_RA = NULL; + uvar_Dec = NULL; uvar_ephemYear = LALCalloc (1, strlen(EPHEM_YEARS)+1); strcpy (uvar_ephemYear, EPHEM_YEARS); @@ -675,6 +752,9 @@ initUserVars (LALStatus *status) uvar_df2dot = 0.0; uvar_df3dot = 0.0; + uvar_countTemplates = FALSE; + uvar_WinFrac = 0.01; + uvar_BandFrac = 2.0; uvar_TwoFthreshold = 10.0; uvar_NumCandidatesToKeep = 0; @@ -690,6 +770,10 @@ initUserVars (LALStatus *status) uvar_outputLogfile = NULL; uvar_outputFstat = NULL; + uvar_outputLoudest = NULL; + + uvar_outputFstatHist = NULL; + uvar_FstatHistBin = 0.1; uvar_gridFile = NULL; @@ -718,6 +802,8 @@ initUserVars (LALStatus *status) LALregREALUserVar(status, Alpha, 'a', UVAR_OPTIONAL, "Sky position alpha (equatorial coordinates) in radians"); LALregREALUserVar(status, Delta, 'd', UVAR_OPTIONAL, "Sky position delta (equatorial coordinates) in radians"); + LALregSTRINGUserVar(status,RA, 0 , UVAR_OPTIONAL, "Sky position alpha (equatorial coordinates) in format hh:mm:ss.sss"); + LALregSTRINGUserVar(status,Dec, 0 , UVAR_OPTIONAL, "Sky position delta (equatorial coordinates) in format dd:mm:ss.sss"); LALregREALUserVar(status, Freq, 'f', UVAR_REQUIRED, "Starting search frequency in Hz"); LALregREALUserVar(status, f1dot, 's', UVAR_OPTIONAL, "First spindown parameter dFreq/dt"); LALregREALUserVar(status, f2dot, 0 , UVAR_OPTIONAL, "Second spindown parameter d^2Freq/dt^2"); @@ -757,12 +843,17 @@ initUserVars (LALStatus *status) LALregSTRINGUserVar(status, outputFstat, 0, UVAR_OPTIONAL, "Output-file for F-statistic field over the parameter-space"); LALregSTRINGUserVar(status, outputLoudest, 0, UVAR_OPTIONAL, "Loudest F-statistic candidate + estimated MLE amplitudes"); + LALregSTRINGUserVar(status,outputFstatHist, 0, UVAR_OPTIONAL, "Output-file for a discrete histogram of all Fstatistic values"); + LALregREALUserVar(status, FstatHistBin, 0, UVAR_OPTIONAL, "Width of an Fstatistic histogram bin"); + LALregINTUserVar(status, NumCandidatesToKeep,0, UVAR_OPTIONAL, "Number of Fstat 'candidates' to keep. (0 = All)"); LALregINTUserVar(status, clusterOnScanline, 0, UVAR_OPTIONAL, "Neighbors on each side for finding 1D local maxima on scanline"); LALregINTUserVar ( status, minStartTime, 0, UVAR_OPTIONAL, "Earliest SFT-timestamp to include"); LALregINTUserVar ( status, maxEndTime, 0, UVAR_OPTIONAL, "Latest SFT-timestamps to include"); + LALregREALUserVar(status, WinFrac, 0, UVAR_OPTIONAL, "Fraction of Window to use as transition (0 -> Rectangular window , 1-> Hann Window) [Default: 0.01]"); + LALregREALUserVar(status, BandFrac, 0, UVAR_OPTIONAL, "Extra Fracion of Band to use, to minimize interpolation losses (1.0 -> Use Full Band , 2.0 -> Double the Band, 3.0 -> Triple the band) [Default: 1.0]"); /* ----- more experimental/expert options ----- */ LALregINTUserVar (status, SSBprecision, 0, UVAR_DEVELOPER, "Precision to use for time-transformation to SSB: 0=Newtonian 1=relativistic"); @@ -775,7 +866,7 @@ initUserVars (LALStatus *status) LALregINTUserVar(status, upsampleSFTs, 0, UVAR_DEVELOPER, "(integer) Factor to up-sample SFTs by"); LALregBOOLUserVar(status, projectMetric, 0, UVAR_DEVELOPER, "Use projected metric on Freq=const subspact"); - + LALregBOOLUserVar(status, countTemplates, 0, UVAR_DEVELOPER, "Count number of templates (if supported) instead of search"); DETATCHSTATUSPTR (status); RETURN (status); } /* initUserVars() */ @@ -786,15 +877,12 @@ InitEphemeris (LALStatus * status, EphemerisData *edat, /**< [out] the ephemeris-data */ const CHAR *ephemDir, /**< directory containing ephems */ const CHAR *ephemYear, /**< which years do we need? */ - LIGOTimeGPS epoch, /**< epoch of observation */ BOOLEAN isLISA /**< hack this function for LISA ephemeris */ ) { #define FNAME_LENGTH 1024 CHAR EphemEarth[FNAME_LENGTH]; /* filename of earth-ephemeris data */ CHAR EphemSun[FNAME_LENGTH]; /* filename of sun-ephemeris data */ - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_LOOSE}; - INT4 leap; INITSTATUS( status, "InitEphemeris", rcsid ); ATTATCHSTATUSPTR (status); @@ -829,9 +917,6 @@ InitEphemeris (LALStatus * status, edat->ephiles.earthEphemeris = EphemEarth; edat->ephiles.sunEphemeris = EphemSun; - TRY (LALLeapSecs (status->statusPtr, &leap, &epoch, &formatAndAcc), status); - edat->leap = (INT2) leap; - TRY (LALInitBarycenter(status->statusPtr, edat), status); DETATCHSTATUSPTR ( status ); @@ -906,8 +991,8 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg ) cfg->refTime = startTime; { /* ----- prepare spin-range at refTime (in *canonical format*, ie all Bands >= 0) ----- */ - REAL8 fMin = MYMIN ( uvar_Freq - uvar_FreqBand/2.0 , uvar_Freq + 3.0*uvar_FreqBand/2.0 ); - REAL8 fMax = MYMAX ( uvar_Freq - uvar_FreqBand/2.0 , uvar_Freq + 3.0*uvar_FreqBand/2.0 ); + REAL8 fMin = MYMIN ( uvar_Freq, uvar_Freq + uvar_FreqBand ); + REAL8 fMax = MYMAX ( uvar_Freq, uvar_Freq + uvar_FreqBand ); REAL8 f1dotMin = MYMIN ( uvar_f1dot, uvar_f1dot + uvar_f1dotBand ); REAL8 f1dotMax = MYMAX ( uvar_f1dot, uvar_f1dot + uvar_f1dotBand ); @@ -979,9 +1064,12 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg ) UINT4 wings = MYMAX(uvar_Dterms, uvar_RngMedWindow/2 +1); /* extra frequency-bins needed for rngmed, and Dterms */ REAL8 fMax = (1.0 + uvar_dopplermax) * fCoverMax + wings / cfg->Tsft; /* correct for doppler-shift and wings */ REAL8 fMin = (1.0 - uvar_dopplermax) * fCoverMin - wings / cfg->Tsft; + REAL8 LoadedBand = (fMax - fMin)*(uvar_BandFrac-1.0); + REAL8 fMax_Load = fMax + LoadedBand/2.0; + REAL8 fMin_Load = fMin - LoadedBand/2.0; LogPrintf (LOG_DEBUG, "Loading SFTs ... "); - TRY ( LALLoadMultiSFTs ( status->statusPtr, &(cfg->multiSFTs), catalog, fMin, fMax ), status ); + TRY ( LALLoadMultiSFTs ( status->statusPtr, &(cfg->multiSFTs), catalog, fMin_Load, fMax_Load ), status ); LogPrintfVerbatim (LOG_DEBUG, "done.\n"); TRY ( LALDestroySFTCatalog ( status->statusPtr, &catalog ), status ); } @@ -999,7 +1087,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg ) if ( cfg->multiSFTs->data[0]->data[0].name[0] == 'Z' ) isLISA = TRUE; - TRY( InitEphemeris (status->statusPtr, cfg->ephemeris, ephemDir, uvar_ephemYear, startTime, isLISA ), status); + TRY( InitEphemeris (status->statusPtr, cfg->ephemeris, ephemDir, uvar_ephemYear, isLISA ), status); } /* ----- obtain the (multi-IFO) 'detector-state series' for all SFTs ----- */ @@ -1051,12 +1139,26 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg ) } LogPrintfVerbatim ( LOG_DEBUG, "done.\n"); } - - + { /* ----- set up Doppler region (at internalRefTime) to scan ----- */ LIGOTimeGPS internalRefTime = empty_LIGOTimeGPS; PulsarSpinRange spinRangeInt = empty_PulsarSpinRange; - BOOLEAN haveAlphaDelta = LALUserVarWasSet(&uvar_Alpha) && LALUserVarWasSet(&uvar_Delta); + BOOLEAN haveAlphaDelta = (LALUserVarWasSet(&uvar_Alpha) && LALUserVarWasSet(&uvar_Delta)) || (LALUserVarWasSet(&uvar_RA) && LALUserVarWasSet(&uvar_Dec)); + + /* define sky position variables from user input */ + if (LALUserVarWasSet(&uvar_RA)) + { + /* use Matt Pitkins conversion code found in lal/packages/pulsar/src/BinaryPulsarTiming.c */ + cfg->Alpha = LALDegsToRads(uvar_RA, "alpha"); + } + else cfg->Alpha = uvar_Alpha; + if (LALUserVarWasSet(&uvar_Dec)) + { + /* use Matt Pitkins conversion code found in lal/packages/pulsar/src/BinaryPulsarTiming.c */ + cfg->Delta = LALDegsToRads(uvar_Dec, "delta"); + } + else cfg->Delta = uvar_Delta; + if (uvar_skyRegion) { @@ -1069,7 +1171,7 @@ InitFStat ( LALStatus *status, ConfigVariables *cfg ) else if (haveAlphaDelta) /* parse this into a sky-region */ { TRY ( SkySquare2String( status->statusPtr, &(cfg->searchRegion.skyRegionString), - uvar_Alpha, uvar_Delta, uvar_AlphaBand, uvar_DeltaBand), status); + cfg->Alpha, cfg->Delta, uvar_AlphaBand, uvar_DeltaBand), status); } if ( LALUserVarWasSet ( &uvar_internalRefTime ) ) { @@ -1439,27 +1541,6 @@ outputBeamTS( const CHAR *fname, const AMCoeffs *amcoe, const DetectorStateSerie return 0; } /* outputBeamTS() */ -/* -============ -va ['stolen' from Quake2 (GPL'ed)] - -does a varargs printf into a temp buffer, so I don't need to have -varargs versions of all text functions. -FIXME: make this buffer size safe someday -============ -*/ -const char *va(const char *format, ...) -{ - va_list argptr; - static char string[1024]; - - va_start (argptr, format); - vsprintf (string, format,argptr); - va_end (argptr); - - return string; -} - /** write full 'PulsarCandidate' (i.e. Doppler params + Amplitude params + error-bars + Fa,Fb, F, + A,B,C,D * RETURN 0 = OK, -1 = ERROR */ @@ -1771,17 +1852,6 @@ void XLALDestroyReSampBuffer ( ReSampBuffer *cfb) } /* XLALDestroyReSampBuffer() */ -/* Calculates the factorial of an integer */ -UINT4 factorial(UINT4 x) -{ - UINT4 prod = 1,i; - if(x==0 || x==1) - return(1); - for(i=2;i<=x;i++) - prod = prod*i; - return(prod); -} - /* Returns the magnitude square of a complex number */ REAL8 magsquare(fftw_complex f) @@ -2256,16 +2326,8 @@ MultiCOMPLEX8TimeSeries* CalcTimeSeries(MultiSFTVector *multiSFTs,FILE *Out,Resa /* Since the data in the Frequency and Time domain both have the same length, we can use one Tukey window for it all */ REAL8Window *Win; - /* The window will use the Dterms as a rise and a fall, So have to appropriately calculate the fraction */ - - /* Beta is a parameter used to create a Tukey window and signifies what fraction of the total length will constitute a rise and a fall */ - REAL8 Win_beta = (2.0*uvar_Dterms)/(REAL8)(N); - - if(Win_beta > 0.01) - Win_beta = 0.01; - /* Create the Window */ - Win = XLALCreateTukeyREAL8Window(N,Win_beta); + Win = XLALCreateTukeyREAL8Window(N,uvar_WinFrac); /* Assign some memory */ L = XLALCreateCOMPLEX16Vector(N); @@ -2363,7 +2425,7 @@ MultiCOMPLEX8TimeSeries* CalcTimeSeries(MultiSFTVector *multiSFTs,FILE *Out,Resa for(p=0;p<TSeries->Real[i]->length;p++) { REAL8 cosphis = cos(LAL_TWOPI*(UserFmin_Diff)*TSeries->Times[i]->data[p]); - REAL8 sinphis = -sin(LAL_TWOPI*(UserFmin_Diff)*TSeries->Times[i]->data[p]); + REAL8 sinphis = sin(LAL_TWOPI*(UserFmin_Diff)*TSeries->Times[i]->data[p]); REAL8 Realpart = TSeries->Real[i]->data[p]; REAL8 Imagpart = TSeries->Imag[i]->data[p]; TSeries->Real[i]->data[p] = Realpart*cosphis - Imagpart*sinphis; @@ -2521,8 +2583,8 @@ REAL8Sequence* ResampleSeries(REAL8Sequence *X_Real,REAL8Sequence *X_Imag,REAL8S return(CorrespondingDetTimes); } - -void ApplySpinDowns(const PulsarSpins *SpinDowns, REAL8 dt, const FFTWCOMPLEXSeries *FaIn, const FFTWCOMPLEXSeries *FbIn, REAL8 BaryStartTime,REAL8Sequence *CorrTimes, REAL8 RefTime, FFTWCOMPLEXSeries *FaInSpinCorrected, FFTWCOMPLEXSeries *FbInSpinCorrected) + +void ApplySpinDowns(const PulsarSpins *SpinDowns, REAL8 dt, const FFTWCOMPLEXSeries *FaIn, const FFTWCOMPLEXSeries *FbIn, REAL8 BaryStartTime,REAL8Sequence *CorrTimes, REAL8 RefTime, FFTWCOMPLEXSeries *FaInSpinCorrected, FFTWCOMPLEXSeries *FbInSpinCorrected,UINT4 NUM_SPINS) { UINT4 i; UINT4 j; @@ -2540,11 +2602,10 @@ void ApplySpinDowns(const PulsarSpins *SpinDowns, REAL8 dt, const FFTWCOMPLEXSer /* Phi is the sum of all terms */ Phi = 0; - for(j=1;j<PULSAR_MAX_SPINS;j++) + for(j=1;j<NUM_SPINS;j++) { - Phi += 2.0*LAL_PI* (*SpinDowns)[j] *pow(DT,j+1)/factorial(j+1) + 2.0*LAL_PI*Phi_M* (*SpinDowns)[j] * pow(DT,j)/factorial(j); - } - + Phi += 2.0*LAL_PI* (*SpinDowns)[j] *pow(DT,j+1)/FactorialLookup[j+1] + 2.0*LAL_PI*Phi_M* (*SpinDowns)[j] * pow(DT,j)/FactorialLookup[j]; + } sinphi = sin(Phi); cosphi = cos(Phi); @@ -2703,6 +2764,14 @@ void ComputeFStat_resamp(LALStatus *status, const PulsarDopplerParams *doppler, /* The output fstatVector */ REAL8FrequencySeries *fstatVector = NULL; + /* Calculate the number of non-zero spins and pass that to apply spin downs to save computation */ + UINT4 NUM_SPINS; + for(NUM_SPINS = PULSAR_MAX_SPINS;NUM_SPINS >= 1;NUM_SPINS--) + { + if(doppler->fkdot[NUM_SPINS-1]) + break; + } + /* Allocate Memory to some common variables */ Fa_Real = XLALCreateREAL8Sequence(new_length); Fb_Real = XLALCreateREAL8Sequence(new_length); @@ -2732,7 +2801,7 @@ void ComputeFStat_resamp(LALStatus *status, const PulsarDopplerParams *doppler, UINT4 numFreqBins = floor(uvar_FreqBand/dF_closest + 0.5); if(Buffer->fstatVector) XLALDestroyREAL8FrequencySeries(Buffer->fstatVector); - fstatVector = XLALCreateREAL8FrequencySeries ("Fstat vector", &doppler->refTime, uvar_Freq, dF_closest, &empty_Unit, numFreqBins ); + fstatVector = XLALCreateREAL8FrequencySeries ("Fstat vector", &doppler->refTime, doppler->fkdot[0], dF_closest, &empty_Unit, numFreqBins ); Buffer->fstatVector = fstatVector; } @@ -2837,8 +2906,8 @@ void ComputeFStat_resamp(LALStatus *status, const PulsarDopplerParams *doppler, LALPrintError("\nXLALWeighMultiAMCoeffs() failed with error = %d\n\n", xlalErrno ); ABORT ( status, COMPUTEFSTATC_EXLAL, COMPUTEFSTATC_MSGEXLAL ); } - - /* store these in buffer if available */ + + /* store these in buffer if available */ if ( Buffer ) { XLALDestroyMultiAMCoeffs ( Buffer->multiAMcoef ); @@ -3038,7 +3107,13 @@ void ComputeFStat_resamp(LALStatus *status, const PulsarDopplerParams *doppler, FaInSpinCorrected = XLALCreateFFTWCOMPLEXSeries(new_length); FbInSpinCorrected = XLALCreateFFTWCOMPLEXSeries(new_length); - ApplySpinDowns(&(doppler->fkdot),dt,FaIn,FbIn,Buffer->StartTimeinBaryCenter,MultiCorrDetTimes->data[i],uvar_refTime-StartTime,FaInSpinCorrected,FbInSpinCorrected); + for(p=0;p<new_length;p++) + { + FaInSpinCorrected->data[p][0] = 0; + FaInSpinCorrected->data[p][1] = 0; + FbInSpinCorrected->data[p][0] = 0; + FbInSpinCorrected->data[p][1] = 0; + } /* Allocate Memory for FaOut and FbOut*/ FaOut = XLALCreateFFTWCOMPLEXSeries(new_length); @@ -3046,8 +3121,10 @@ void ComputeFStat_resamp(LALStatus *status, const PulsarDopplerParams *doppler, /* Make Plans */ plan_a = fftw_plan_dft_1d(FaInSpinCorrected->length,FaInSpinCorrected->data,FaOut->data,FFTW_FORWARD,FFTW_ESTIMATE); - plan_b = fftw_plan_dft_1d(FbInSpinCorrected->length,FbInSpinCorrected->data,FbOut->data,FFTW_FORWARD,FFTW_ESTIMATE); - + plan_b = fftw_plan_dft_1d(FbInSpinCorrected->length,FbInSpinCorrected->data,FbOut->data,FFTW_FORWARD,FFTW_ESTIMATE); + + ApplySpinDowns(&(doppler->fkdot),dt,FaIn,FbIn,Buffer->StartTimeinBaryCenter,MultiCorrDetTimes->data[i],GPS2REAL8(doppler->refTime) - StartTime,FaInSpinCorrected,FbInSpinCorrected,NUM_SPINS); + /* FFT!! */ fftw_execute(plan_a); fftw_execute(plan_b); @@ -3065,6 +3142,8 @@ void ComputeFStat_resamp(LALStatus *status, const PulsarDopplerParams *doppler, XLALDestroyFFTWCOMPLEXSeries(FbOut); XLALDestroyFFTWCOMPLEXSeries(FaInSpinCorrected); XLALDestroyFFTWCOMPLEXSeries(FbInSpinCorrected); + fftw_destroy_plan(plan_a); + fftw_destroy_plan(plan_b); } diff --git a/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/fstat.c b/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/fstat.c index 3d8ae21273f6a5bf116bf61b5cd7630407980b20..5189767c0a743ea637d8ff71d83d8810b4582be6 100644 --- a/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/fstat.c +++ b/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/fstat.c @@ -635,7 +635,6 @@ int main(int argc, char **argv) detector = lalCachedDetectors[LALDetectorIndexLHODIFF]; edata.ephiles.earthEphemeris = EARTHDATA; edata.ephiles.sunEphemeris = SUNDATA; - edata.leap = 13; /****** Initializing earth data set edata ******/ LALInitBarycenter( &status, &edata); diff --git a/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/multiresamp_test.py b/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/multiresamp_test.py index 2b24d187485b47e99ff8b3fae05b60e399fc5de4..05dd8f5877f2533bd9391b407c699ac96eb0d341 100755 --- a/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/multiresamp_test.py +++ b/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/multiresamp_test.py @@ -1,11 +1,28 @@ #!/usr/bin/python # Resampling Test Code. This code is much more readable and reusable than its predecessor. Author - Pinkesh Patel -import sys,random,commands,math +import sys,random,commands,math,shutil,os,re,string def main(): # Import the Configuration File into config - config = __import__(sys.argv[1]); + # Import the Configuration File into config + if(len(sys.argv) < 2): + print >> sys.stderr, "Insufficient command line arguments " + print >> sys.stderr, " Usage is ",sys.argv[0]," <ConfigFile> {Job Number} " + print >> sys.stderr, " Exiting ........." + sys.exit(1) + + try: + config = __import__(sys.argv[1]); + except: + print >> sys.stderr, "Cannot import Config file '",sys.argv[1],"' exiting ...." + sys.exit(1) + + UniqueID = '' + + # Compute Unique ID Number + if(len(sys.argv) >= 3): + UniqueID += '_' + sys.argv[2] # Variables Structure/Dictionary Vars = {} @@ -14,14 +31,14 @@ def main(): try: Vars['TSFT'] = config.TSFT except: - print "TSFT cannot be read" + print >> sys.stderr, "TSFT cannot be read" sys.exit(1) # Strength of signal try: Vars['h0'] = config.h0 except: - print "h0 cannot be read" + print >> sys.stderr, "h0 cannot be read" sys.exit(1) # Cosine of iota @@ -31,10 +48,10 @@ def main(): try: Vars['cosi'] = random.uniform(config.cosi_min,config.cosi_max) except: - print "Cannot read in cosi variable" + print >> sys.stderr, "Cannot read in cosi variable" sys.exit(1) if(math.fabs(Vars['cosi']) > 1): - print "abs(cosi) > 1 !!!" + print >> sys.stderr, "abs(cosi) > 1 !!!" sys.exit(1) @@ -45,7 +62,7 @@ def main(): try: Vars['phi0'] = random.uniform(config.phi0_min,config.phi0_max) except: - print "Cannot read in phi0 variable" + print >> sys.stderr, "Cannot read in phi0 variable" sys.exit(1) # Polarization Angle @@ -55,14 +72,14 @@ def main(): try: Vars['psi'] = random.uniform(config.psi_min,config.psi_max) except: - print "Cannot read in psi variable" + print >> sys.stderr, "Cannot read in psi variable" sys.exit(1) # Number of Dirichlet terms used. try: Vars['Dterms'] = float(config.Dterms) except: - print "Dterms cannot be read" + print >> sys.stderr, "Dterms cannot be read" sys.exit(1) # Interferometer @@ -75,7 +92,7 @@ def main(): for i in range(NumofIFOs): Vars['IFO'].append(IFOs[i]) except: - print "IFO cannot be read" + print >> sys.stderr, "IFO cannot be read" sys.exit(1) # Start Time @@ -83,49 +100,49 @@ def main(): t0 = config.t0 t0 = t0.split(' ') if(len(t0) != NumofIFOs): - print "Number of starttimes != Number of IFOs" + print >> sys.stderr, "Number of starttimes != Number of IFOs" sys.exit(1) Vars['t0'] = [] for i in range(NumofIFOs): Vars['t0'].append(float(t0[i])) except: - print "t0 cannot be read" + print >> sys.stderr, "t0 cannot be read" sys.exit(1) # Reference Time in SSB try: Vars['refTime'] = float(config.refTime) + refString = ' --refTime ' + str(Vars['refTime']) except: - print "refTime cannot be read" - sys.exit(1) + refString = ' ' # Output Directory try: - Vars['Out'] = config.Out + Vars['Out'] = config.Out + UniqueID except: - print "Out cannot be read" + print >> sys.stderr, "Out cannot be read" sys.exit(1) # Ephemeris Directory try: Vars['Ephem'] = config.Ephem except: - print "Ephem cannot be read" + print >> sys.stderr, "Ephem cannot be read" sys.exit(1) # Ephemeris Year try: Vars['EphemYear'] = config.EphemYear except: - print "EphemYear cannot be read" + print >> sys.stderr, "EphemYear cannot be read" sys.exit(1) # Noise Sh try: Vars['Sh'] = float(config.Sh) except: - print "Sh cannot be read" + print >> sys.stderr, "Sh cannot be read" sys.exit(1) # Duration of Analysis @@ -133,14 +150,14 @@ def main(): TSpan = config.TSpan TSpan = TSpan.split(' ') if(len(TSpan) != NumofIFOs): - print "Number of TSpans != Number of IFOs" + print >> sys.stderr, "Number of TSpans != Number of IFOs" sys.exit(1) Vars['TSpan'] = [] for i in range(NumofIFOs): Vars['TSpan'].append(float(TSpan[i])) except: - print "TSpan cannot be read" + print >> sys.stderr, "TSpan cannot be read" sys.exit(1) # Number of SFTs to add @@ -148,14 +165,14 @@ def main(): NumSFTs = config.NumSFTs NumSFTs = NumSFTs.split(' ') if(len(NumSFTs) != NumofIFOs): - print "Number of starttimes != Number of IFOs" + print >> sys.stderr, "Number of starttimes != Number of IFOs" sys.exit(1) Vars['NumSFTs'] = [] for i in range(NumofIFOs): Vars['NumSFTs'].append(int(NumSFTs[i])) except: - print "NumSFTs cannot be read" + print >> sys.stderr, "NumSFTs cannot be read" sys.exit(1) # Number of Gaps to add @@ -163,14 +180,14 @@ def main(): NumGaps = config.NumGaps NumGaps = NumGaps.split(' ') if(len(NumGaps) != NumofIFOs): - print "Number of starttimes != Number of IFOs" + print >> sys.stderr, "Number of starttimes != Number of IFOs" sys.exit(1) Vars['NumGaps'] = [] for i in range(NumofIFOs): Vars['NumGaps'].append(int(NumGaps[i])) except: - print "NumGaps cannot be read" + print >> sys.stderr, "NumGaps cannot be read" sys.exit(1) # Alpha (Right Ascension) @@ -180,10 +197,10 @@ def main(): try: Vars['Alpha'] = random.uniform(config.Alpha_min,config.Alpha_max) except: - print "Cannot read in Alpha variable" + print >> sys.stderr, "Cannot read in Alpha variable" sys.exit(1) if(Vars['Alpha'] < 0 or Vars['Alpha'] > 2.0*math.pi): - print "Alpha out of bounds !!!" + print >> sys.stderr, "Alpha out of bounds !!!" sys.exit(1) # Delta (Declination) @@ -193,24 +210,24 @@ def main(): try: Vars['Delta'] = random.uniform(config.Delta_min,config.Delta_max) except: - print "Cannot read in Delta variable" + print >> sys.stderr, "Cannot read in Delta variable" sys.exit(1) if(math.fabs(Vars['Delta']) > math.pi/2.0): - print "abs(Delta) > pi/2 !!!" + print >> sys.stderr, "abs(Delta) > pi/2 !!!" sys.exit(1) # Minimum Frequency try: Vars['Fmin'] = config.Fmin except: - print "Fmin cannot be read" + print >> sys.stderr, "Fmin cannot be read" sys.exit(1) # Band of Analysis try: Vars['Band'] = config.Band except: - print "Band cannot be read" + print >> sys.stderr, "Band cannot be read" sys.exit(1) # Injection Frequency @@ -220,10 +237,10 @@ def main(): try: Vars['Finj'] = random.uniform(config.Finj_min,config.Finj_max) except: - print "Cannot read in Finj variable" + print >> sys.stderr, "Cannot read in Finj variable" sys.exit(1) if(Vars['Finj'] < 0): - print "Finj < 0 !!!" + print >> sys.stderr, "Finj < 0 !!!" sys.exit(1) # Spindown/ FDOT @@ -233,15 +250,15 @@ def main(): try: Vars['FDot'] = random.uniform(config.FDot_min,config.FDot_max) except: - print "Cannot read in FDot variable" + print >> sys.stderr, "Cannot read in FDot variable" sys.exit(1) # FDOTBand try: Vars['FDotBand'] = config.FDotBand except: - Vars['FdotBand'] = 0 - #print "Cannot read in FDot variable" + Vars['FDotBand'] = 0 + #print >> sys.stderr, "Cannot read in FDot variable" #sys.exit(1) # dFDot @@ -254,10 +271,10 @@ def main(): try: Vars['Res'] = config.Res if(Vars['Res'] > 1.0/Vars['TSpan'][0]): - print "Resolution too low, set to 1/T" + print >> sys.stderr, "Resolution too low, set to 1/T" Vars['Res'] = 1.0/Vars['TSpan'][0] if(Vars['Res'] < 0): - print "Resolution < 0" + print >> sys.stderr, "Resolution < 0" sys.exit(1) except: Vars['Res'] = 1.0/Vars['TSpan'][0] @@ -286,6 +303,14 @@ def main(): except: Vars['ResampOutput'] = "MyTS" + # Optional Use Your Own TimeStampsFile + try: + Vars['TimeStampsFile'] = config.TimeStampsFile + TimeStampsFile_Is_Set = True + except: + Vars['TimeStampsFile'] = 'TimeStampsFile' + UniqueID + TimeStampsFile_Is_Set = False + # Print out all the variables (if Debug is on) if(Vars['debug']): print "---------- Configuration Variables --------- " @@ -293,31 +318,48 @@ def main(): print "-------------------------------------------- \n \n" # Create the Time Stamp File - CreateTimeStampFile(Vars) + if(not(TimeStampsFile_Is_Set)): + if(Vars['debug']): + print "------------ Creating TimeStamps Files --------" + CreateTimeStampFile(Vars,UniqueID) # If running multiple time, delete all the old SFTs - RMOLD = 'rm ' + Vars['Out'] + '/*' - commands.getoutput(RMOLD) + if(os.path.exists("./"+Vars['Out'])): + try: + shutil.rmtree(Vars['Out']) + except: + print >> sys.stderr, "Could not delete old directory\n" + sys.exit(1) + + try: + os.mkdir(Vars['Out']) + except: + print >> sys.stderr, "Something went wrong creating new directory\n" + print >> sys.stderr, "Permission trouble maybe\n" + sys.exit(1) # Generate Fake data string for ifo in range(NumofIFOs): - FakeDataString = GenFakeDataString(1,Vars,ifo) + FakeDataString = GenFakeDataString(1,Vars,ifo,UniqueID,refString) if(Vars['debug']): print "----------- Makefakedata String ------------" print FakeDataString print "--------------------------------------------\n\n" # Generate the data - try: - G = commands.getoutput(FakeDataString) - except: - print "Tried to generate SFTs, failed" + (status,MOutput) = commands.getstatusoutput(FakeDataString) + os.remove("timestampsFile"+Vars['IFO'][ifo]+UniqueID) + if(status): + print >> sys.stderr, "Tried to generate SFTs, failed" + print >> sys.stderr, MOutput sys.exit(1) # Run v2() - OutputFile = "OutputV" - startstring = "lalapps_ComputeFStatistic_v2 --outputFstat " + OutputFile + " -F " + str(Vars['FThres']) + " " - endstring = " " + OutputFileVLoudest = "OutputVLoudest" + UniqueID + OutputFileVFstat = "OutputVFstat" + UniqueID + OutputFileVHist = "OutputVHist" + UniqueID + startstring = "lalapps_ComputeFStatistic_v2 --outputFstat " + OutputFileVFstat + " --outputLoudest " + OutputFileVLoudest + " -F " + str(Vars['FThres']) + " --outputFstatHist " + OutputFileVHist + " " + endstring = " " + refString V2DataString = GenDataString(startstring,endstring,Vars) if(Vars['debug']): print "----------- V2 String ------------" @@ -325,19 +367,28 @@ def main(): print "----------------------------------\n\n" print "----------- Running V2 -----------" - try: - G = commands.getoutput(V2DataString) - except: - print "V2 failed" - sys.exit(0) + + (status,Voutput) = commands.getstatusoutput(V2DataString) + if(status): + print >> sys.stderr, "V2 failed, Output was \n\n" + print >> sys.stderr, Voutput + print >> sys.stderr, "\nV2 Command was\n" + print >> sys.stderr, V2DataString + print >> sys.stderr, "\nMakeFakeData Command was\n" + print >> sys.stderr, FakeDataString + sys.exit(1) if(Vars['debug']): print "---------- V2 Done ---------------\n\n" # Run Resamp - OutputFile = "OutputR" - startstring = "./lalapps_ComputeFStatistic_resamp --outputFstat " + OutputFile + " -F " + str(Vars['FThres']) + " " - endstring = " --outputTimeSeries " + str(Vars['ResampOutput']) + " > plot1 " + #ResampLocation = "/home/ppatel/lalsuite/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/" + ResampLocation = "./" + OutputFileRLoudest = "OutputRLoudest" + UniqueID + OutputFileRFstat = "OutputRFstat" + UniqueID + OutputFileRHist = "OutputRHist" + UniqueID + startstring = ResampLocation + "lalapps_ComputeFStatistic_resamp --outputFstat " + OutputFileRFstat + " --outputLoudest " + OutputFileRLoudest+ " -F " + str(Vars['FThres']) + " --outputFstatHist " + OutputFileRHist + " " + endstring = " " + refString RDataString = GenDataString(startstring,endstring,Vars) if(Vars['debug']): print "-------- Resamp String -----------" @@ -345,30 +396,112 @@ def main(): print "----------------------------------\n\n" print "--------- Running Resamp ---------" - try: - G = commands.getoutput(RDataString) - except: - print "Resamp failed" + (status,Routput) = commands.getstatusoutput(RDataString) + if(status): + print >> sys.stderr, "Resamp failed, Output was\n\n" + print >> sys.stderr, Routput + print >> sys.stderr, "\nResamp Command was\n" + print >> sys.stderr, RDataString + print >> sys.stderr, "\nMakeFakeData Command was\n" + print >> sys.stderr, FakeDataString sys.exit(0) if(Vars['debug']): print "---------- Resamp Done -----------\n\n" - print "---------- Output was ------------\n\n" - print G,"\n" - + + if(Vars['debug']): + print "---------- Deleting SFT Folder ---------\n\n" + try: + shutil.rmtree(Vars['Out']) + except: + print >> sys.stderr, " Could not delete SFT folder \n\n" + sys.exit(1) + + FreqOutput = AnalyzeFreq(OutputFileRFstat,OutputFileVFstat,Vars['Finj'],Vars['Res']) + LoudestOutput = AnalyzeLoudest(OutputFileRLoudest,OutputFileVLoudest) + os.remove(OutputFileRLoudest) + os.remove(OutputFileVLoudest) + os.remove(OutputFileRFstat) + os.remove(OutputFileVFstat) + os.remove(OutputFileVHist) + os.remove(OutputFileRHist) + print FreqOutput,LoudestOutput return(0) +def AnalyzeFreq(Filename1,Filename2,Freq,dF): + File1 = open(Filename1,'r') + File2 = open(Filename2,'r') + File1lines = File1.readlines() + File2lines = File2.readlines() + Freq1 = 0 + dF1 = 0 + Freq2 = 0 + dF2 = 0 + + exp = re.compile(r'^\d') + + for line in File1lines: + if(exp.search(line)): + linesplit = string.split(line) + if(Freq1 and not(dF1)): + dF1 = abs(float(linesplit[0])) - Freq1 + Freq1 = float(linesplit[0]) + if(abs(Freq1-Freq) < dF1/2.0): + twoF1 = float(linesplit[6]) + Freq1store = Freq1 + storeline = line + + for line in File2lines: + if(exp.search(line)): + linesplit = string.split(line) + if(Freq2 and not(dF2)): + dF2 = abs(float(linesplit[0])) - Freq2 + Freq2 = float(linesplit[0]) + if(abs(Freq2-Freq) < dF2/2.0): + twoF2 = float(linesplit[6]) + Freq2store = Freq2 + + return(str(Freq) + " " + str(Freq1store) + " " + str(Freq2store) + " " + str(dF) + " " + str(dF1) + " " + str(dF2) + " " + str(twoF1) + " " + str(twoF2) + " ") + +def AnalyzeLoudest(Filename1,Filename2): + File1 = open(Filename1,'r') + File2 = open(Filename2,'r') + File1lines = File1.readlines() + File2lines = File2.readlines() + + expression = re.compile(r'(\D*)(\d*.\d*|\d*)') + + for line in File1lines: + if(expression.search(line)): + linesplit = expression.search(line).groups() + if(re.match('twoF',linesplit[0])): + twoF1 = float(linesplit[1]) + + if(re.match('Freq',linesplit[0])): + Freq1 = float(linesplit[1]) + + for line in File2lines: + if(expression.search(line)): + linesplit = expression.search(line).groups() + if(re.match('twoF',linesplit[0])): + twoF2 = float(linesplit[1]) + + if(re.match('Freq',linesplit[0])): + Freq2 = float(linesplit[1]) + + return(str(Freq1) + " " + str(twoF1) + " " + str(Freq2) + " " + str(twoF2) + " ") + def PrintValues(Dict): for key in Dict.keys(): print key," = ",Dict[key] -def CreateTimeStampFile(Vars): +def CreateTimeStampFile(Vars,UniqueID): for ifo in range(Vars['NumofIFOs']): - ifotimestampfile = "./timestampsFile" + str(Vars['IFO'][ifo]) + ifotimestampfile = "./timestampsFile" + str(Vars['IFO'][ifo])+UniqueID try: File = open(ifotimestampfile,'w') except: - print "Tried to open timestampsFile, failed" + print >> sys.stderr, "Tried to open timestampsFile, failed" sys.exit(0) if(Vars['debug']): @@ -419,7 +552,7 @@ def CreateTimeStampFile(Vars): File.write(" 0 \n") -def GenFakeDataString(addtonoise,Vars,ifo): +def GenFakeDataString(addtonoise,Vars,ifo,UniqueID,endstring): if(Vars['Band'] > 1e-2): CreationBand = Vars['Band']*4 CreationFmin = Vars['Fmin']-Vars['Band']*2 @@ -427,11 +560,13 @@ def GenFakeDataString(addtonoise,Vars,ifo): CreationBand = 1 CreationFmin = Vars['Fmin'] - 0.5 - S = 'lalapps_Makefakedata_v4 ' + ' --Tsft ' + str(Vars['TSFT']) + ' --fmin ' + str(CreationFmin) + ' --h0 ' + str(Vars['h0']) + ' --Band ' + str(CreationBand) + ' --cosi ' + str(Vars['cosi']) + ' --psi ' + str(Vars['psi']) + ' --phi0 ' + str(Vars['phi0']) + ' --Freq ' + str(Vars['Finj']) + ' --Alpha ' + str(Vars['Alpha']) + ' --Delta ' + str(Vars['Delta']) + ' --IFO ' + str(Vars['IFO'][ifo]) + ' --refTime ' + str(Vars['refTime']) + ' --outSFTbname ' + str(Vars['Out']) + ' --ephemDir ' + str(Vars['Ephem']) + ' --ephemYear ' + str(Vars['EphemYear']) + ' --f1dot ' + str(Vars['FDot']) + ' --noiseSqrtSh ' + str(Vars['Sh']**0.5) + ' --timestampsFile timestampsFile' + str(Vars['IFO'][ifo]) + CreationFmin -= 1 + CreationBand += 2 + S = 'lalapps_Makefakedata_v4 ' + ' --Tsft ' + str(Vars['TSFT']) + ' --fmin ' + str(CreationFmin) + ' --h0 ' + str(Vars['h0']) + ' --Band ' + str(CreationBand) + ' --cosi ' + str(Vars['cosi']) + ' --psi ' + str(Vars['psi']) + ' --phi0 ' + str(Vars['phi0']) + ' --Freq ' + str(Vars['Finj']) + ' --Alpha ' + str(Vars['Alpha']) + ' --Delta ' + str(Vars['Delta']) + ' --IFO ' + str(Vars['IFO'][ifo]) + ' --outSFTbname ' + str(Vars['Out']) + ' --ephemDir ' + str(Vars['Ephem']) + ' --ephemYear ' + str(Vars['EphemYear']) + ' --f1dot ' + str(Vars['FDot']) + ' --noiseSqrtSh ' + str(Vars['Sh']**0.5) + ' --timestampsFile timestampsFile' + str(Vars['IFO'][ifo]) + UniqueID + endstring return(S) def GenDataString(beginstring,endstring,Vars): - S = beginstring + ' --Freq ' + str(Vars['Fmin']) + ' --FreqBand ' + str(Vars['Band']) + ' --Alpha ' + str(Vars['Alpha']) + ' --Delta ' + str(Vars['Delta']) + ' --refTime ' + str(Vars['refTime']) + ' --ephemDir ' + str(Vars['Ephem']) + ' --ephemYear ' + str(Vars['EphemYear']) + ' --dFreq ' + str(Vars['Res']) + ' --DataFiles \"' + str(Vars['Out']) + '/*" ' + ' --f1dotBand ' + str(Vars['FDotBand']) + ' --df1dot ' + str(Vars['dFDot']) + endstring + S = beginstring + ' --Freq ' + str(Vars['Fmin']) + ' --FreqBand ' + str(Vars['Band']) + ' --Alpha ' + str(Vars['Alpha']) + ' --Delta ' + str(Vars['Delta']) + ' --ephemDir ' + str(Vars['Ephem']) + ' --ephemYear ' + str(Vars['EphemYear']) + ' --dFreq ' + str(Vars['Res']) + ' --DataFiles \"' + str(Vars['Out']) + '/*" ' + ' --f1dot ' + str(Vars['FDot']) + endstring return(S) #' --f1dot ' + str(Vars['FDot']) + diff --git a/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/resamp_test_MultiConfigFile.py b/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/resamp_test_MultiConfigFile.py index e3c71f14b84abe4589ffbda6ed5f8a4d6b785373..578abb91a13accca43915b4fc9586c1af01af702 100644 --- a/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/resamp_test_MultiConfigFile.py +++ b/lalapps/src/pulsar/FDS_isolated/ResamplingFstat/resamp_test_MultiConfigFile.py @@ -1,9 +1,9 @@ -# Configuration Script for auto_resamp.py script. Times are in seconds. + # Configuration Script for auto_resamp.py script. Times are in seconds. # For parameters with a _min and _max function, if parameter > 0, then it is # set as the value, else it is chosen uniformly from _min to _max # Strength of signal -h0 = 0.15*0 +h0 = 0.30*0 # Cosine of iota cosi = -0.3 @@ -26,6 +26,7 @@ Dterms = 128 # Interferometer IFOs = 'H2 H1' + # Start Time t0 = '820006091 820000000' @@ -47,16 +48,15 @@ Sh = 0.15 # Duration of Analysis TSpan = '36000 36000' + # SFT time baseline TSFT = 1800 # Number of SFTs to add -#NumSFTs = '20 20' NumSFTs = '10 11' # Number of Gaps to add -NumGaps = '5 5' -#NumGaps = '0 0' +NumGaps = '3 3' # Alpha (Right Ascension) #Alpha = 2.0 @@ -73,17 +73,17 @@ Delta_max = 1.57 Fmin = 103.0 # Band of Analysis -Band = 0.2 +Band = 0.1 # Injection Frequency -Finj = 103.05 -Finj_min = 55.0 -Finj_max = 55.1 +#Finj = 103.03 +Finj_min = 103.0 +Finj_max = 103.1 # Spindown -FDot = 1e-8 -FDot_min = 1e-7 -FDot_max = 1e-11 +#FDot = 1e-8*0 +FDot_min = -1e-7 +FDot_max = -1e-11 # Fdot band FDotBand = 2e-8*0 @@ -95,7 +95,7 @@ dFDot = 5e-9 debug = 1 # Resolution -Res = 1.0/144000/4/2 +Res = 1.0/20/1800/10/10 # OutputTimeSeries TimeSeriesOut = 'TSeries' diff --git a/lalapps/src/pulsar/FDS_isolated/SemiAnalyticF.c b/lalapps/src/pulsar/FDS_isolated/SemiAnalyticF.c index 0e4b3f04d2b4e6cb89508226821e091b367557a3..11a1c8965aab9bafc072229e5c8000b38fe9ad03 100644 --- a/lalapps/src/pulsar/FDS_isolated/SemiAnalyticF.c +++ b/lalapps/src/pulsar/FDS_isolated/SemiAnalyticF.c @@ -324,7 +324,6 @@ Initialize (LALStatus *status, struct CommandLineArgsTag *CLA) EarthState earth; AMCoeffsParams *amParams; LIGOTimeGPS *midTS=NULL; /* Time stamps for amplitude modulation coefficients */ - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; LALDetector *Detector; /* Our detector*/ INT4 k; @@ -378,8 +377,7 @@ Initialize (LALStatus *status, struct CommandLineArgsTag *CLA) #define MAXFILENAME 256 { CHAR filenameE[MAXFILENAME], filenameS[MAXFILENAME]; - INT4 leap; - + /* don't use absolute path if none was given, this * allows LAL to find the ephemeris in LAL_DATA_PATH */ if ( LALUserVarWasSet (&(CLA->efiles)) ) @@ -399,9 +397,6 @@ Initialize (LALStatus *status, struct CommandLineArgsTag *CLA) (*edat).ephiles.earthEphemeris = filenameE; (*edat).ephiles.sunEphemeris = filenameS; - TRY ( LALLeapSecs(status->statusPtr, &leap, &(timestamps->data[0]), &formatAndAcc), status); - (*edat).leap=leap; - /* Reads in ephemeris files */ TRY( LALInitBarycenter (status->statusPtr, edat), status ); @@ -436,7 +431,6 @@ Initialize (LALStatus *status, struct CommandLineArgsTag *CLA) amParams->das->pSource->orientation = 0.0; amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!!!!!!!!*/ - amParams->leapAcc = formatAndAcc.accuracy; /* Allocate space for AMCoeffs */ amc.a = NULL; diff --git a/lalapps/src/pulsar/FDS_isolated/monteint.c b/lalapps/src/pulsar/FDS_isolated/monteint.c index 9fa1a292c41827c4124f61786642596e0a446be6..04b3d473f1cf10dc18079472d67bc1a270952641 100644 --- a/lalapps/src/pulsar/FDS_isolated/monteint.c +++ b/lalapps/src/pulsar/FDS_isolated/monteint.c @@ -79,7 +79,6 @@ typedef struct { REAL8 Fstat; REAL8 tsft; /**< length of an SFT in seconds */ LALDetector Detector; /**< Our detector*/ - REAL8 leap; CHAR *timestampsfile; CHAR *EphemEarth; /**< filename of earth-ephemeris data */ CHAR *EphemSun; /**< filename of sun-ephemeris data */ @@ -1042,25 +1041,6 @@ InitConfigVariables(LALStatus *status, ConfigVariables *cfg) } - /* ----------------------------------------------------------------------*/ - /* - * initialize Ephemeris-data - */ - { - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; - - LALLeapSecs(status->statusPtr, &leap, &starttime, &formatAndAcc); - BEGINFAIL(status) { - LALFree(cfg->timestampsfile); - } ENDFAIL(status); - - cfg->leap = leap; - - } /* end: init ephemeris data */ - - - DETATCHSTATUSPTR (status); RETURN (status); } /* void InitConfigVariables(). */ @@ -1187,7 +1167,6 @@ InitAMParams(LALStatus *status, BayesFstatParams *bfparams, ConfigVariables *cfg } strcpy(bfparams->amParams->edat->ephiles.earthEphemeris, cfg->EphemEarth); strcpy(bfparams->amParams->edat->ephiles.sunEphemeris, cfg->EphemSun); - bfparams->amParams->edat->leap = cfg->leap; LALInitBarycenter(status->statusPtr, bfparams->amParams->edat); BEGINFAIL(status) { @@ -1203,7 +1182,6 @@ InitAMParams(LALStatus *status, BayesFstatParams *bfparams, ConfigVariables *cfg bfparams->amParams->das->pSource->orientation = 0.0; bfparams->amParams->das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; bfparams->amParams->polAngle = bfparams->amParams->das->pSource->orientation ; /* These two have to be the same!!!!!!!!!*/ - bfparams->amParams->leapAcc = LALLEAPSEC_STRICT; bfparams->amParams->das->pSource->equatorialCoords.latitude = Delta; bfparams->amParams->das->pSource->equatorialCoords.longitude = Alpha; bfparams->amParams->baryinput = &(bfparams->baryinput); diff --git a/lalapps/src/pulsar/GetSFTVelocities.c b/lalapps/src/pulsar/GetSFTVelocities.c index 2fae7536c2b2de7d282b4899d4479eae95385ac0..8259508bc393195b2a3fd015088b30204897e807 100644 --- a/lalapps/src/pulsar/GetSFTVelocities.c +++ b/lalapps/src/pulsar/GetSFTVelocities.c @@ -91,8 +91,6 @@ int main(int argc, char *argv[]){ /* ephemeris */ EphemerisData *edat=NULL; - INT4 tmpLeap; - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_LOOSE}; /* user input variables */ BOOLEAN uvar_help; @@ -134,8 +132,7 @@ int main(int argc, char *argv[]){ edat = (EphemerisData *)LALCalloc(1, sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = uvar_earthEphemeris; (*edat).ephiles.sunEphemeris = uvar_sunEphemeris; - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; + LAL_CALL( LALInitBarycenter( &status, edat), &status); /* read sft Files and set up weights and nstar vector */ diff --git a/lalapps/src/pulsar/Injections/Makefile.am b/lalapps/src/pulsar/Injections/Makefile.am index c253f11d7807d603e5d3b0665136b867f95a2718..38de2d01cf432d602d0b75cb9a2b4857d5204c6e 100644 --- a/lalapps/src/pulsar/Injections/Makefile.am +++ b/lalapps/src/pulsar/Injections/Makefile.am @@ -42,5 +42,10 @@ psinject_SOURCES = psinject.c EXTRA_DIST = testMakefakedata.sh testMFDv4.sh testMFDv4-HW.sh testT8_1800 TESTS = testMakefakedata.sh testMFDv4.sh testMFDv4-HW.sh +TESTS_ENVIRONMENT = \ +LAL_TOP_SRCDIR=$(LAL_TOP_SRCDIR) \ +LAL_PREFIX=$(LAL_PREFIX) \ +LAL_DATA_PATH=.:$${LAL_TOP_SRCDIR:+"$${LAL_TOP_SRCDIR}/packages/pulsar/test"}:$${LAL_PREFIX:+"$${LAL_PREFIX}/share/lal"} + CLEANFILES = diff --git a/lalapps/src/pulsar/Injections/makefakedata_test.c b/lalapps/src/pulsar/Injections/makefakedata_test.c index 6c28434e9039d07194354c0bf4c984a4fbbd5f06..21f9d2040818dbbac2fd162122616bc873959be7 100644 --- a/lalapps/src/pulsar/Injections/makefakedata_test.c +++ b/lalapps/src/pulsar/Injections/makefakedata_test.c @@ -903,7 +903,6 @@ int prepare_baryinput(LALStatus* status){ edat=(EphemerisData *)LALMalloc(sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = earthdata; (*edat).ephiles.sunEphemeris = sundata; - (*edat).leap=13; /* Read in ephemerides */ LALInitBarycenter(status, edat); @@ -1179,7 +1178,6 @@ int write_modulated_amplitudes_file(LALStatus* status){ gps.gpsSeconds=timestamps[i].gpsSeconds; gps.gpsNanoSeconds=timestamps[i].gpsNanoSeconds; gpsandacc.gps=gps; - gpsandacc.accuracy=LALLEAPSEC_STRICT; LALComputeDetAMResponse(status, &amresp, &detectorandsource, &gpsandacc); fprintf(fp,"%f %f\n",amresp.plus,amresp.cross); diff --git a/lalapps/src/pulsar/Injections/makefakedata_v2.c b/lalapps/src/pulsar/Injections/makefakedata_v2.c index dd86402a2886df9bf5e3ecf9afc6236a285070d6..aedbbbc92b6958fc7c9e6cca8ac2f6cf2a57609a 100644 --- a/lalapps/src/pulsar/Injections/makefakedata_v2.c +++ b/lalapps/src/pulsar/Injections/makefakedata_v2.c @@ -901,7 +901,6 @@ int prepare_baryinput(LALStatus* status){ edat=(EphemerisData *)LALMalloc(sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = earthdata; (*edat).ephiles.sunEphemeris = sundata; - (*edat).leap=13; /* Read in ephemerides */ LALInitBarycenter(status, edat); @@ -1182,7 +1181,6 @@ int write_modulated_amplitudes_file(LALStatus* status){ gps.gpsSeconds=timestamps[i].gpsSeconds; gps.gpsNanoSeconds=timestamps[i].gpsNanoSeconds; gpsandacc.gps=gps; - gpsandacc.accuracy=LALLEAPSEC_STRICT; LALComputeDetAMResponse(status, &amresp, &detectorandsource, &gpsandacc); fprintf(fp,"%f %f\n",amresp.plus,amresp.cross); diff --git a/lalapps/src/pulsar/Injections/makefakedata_v4.c b/lalapps/src/pulsar/Injections/makefakedata_v4.c index 7e42f30807f72e6645fcc7ad73862894316d3d59..c17d79cd28b94e6942b51379d352daeafb6cee50 100644 --- a/lalapps/src/pulsar/Injections/makefakedata_v4.c +++ b/lalapps/src/pulsar/Injections/makefakedata_v4.c @@ -526,9 +526,11 @@ main(int argc, char *argv[]) void InitMakefakedata (LALStatus *status, ConfigVars_t *cfg, int argc, char *argv[]) { + static const char *fn = "InitMakefakedata()"; + CHAR *channelName = NULL; - INITSTATUS( status, "InitMakefakedata", rcsid ); + INITSTATUS( status, fn, rcsid ); ATTATCHSTATUSPTR (status); /* register all user-variables */ @@ -847,19 +849,23 @@ InitMakefakedata (LALStatus *status, ConfigVars_t *cfg, int argc, char *argv[]) /* check if anything matched */ if ( catalog->length == 0 ) { - printf ("\nNo noise-SFTs matching the constraints (IFO, start+duration, timestamps) were found!\n\n"); + XLALPrintError ("%s: No noise-SFTs matching the constraints (IFO, start+duration, timestamps) were found!\n", fn); ABORT (status, MAKEFAKEDATAC_EBAD, MAKEFAKEDATAC_MSGEBAD); } - /* get timestamps from the matched SFTs */ - TRY ( LALSFTtimestampsFromCatalog ( status->statusPtr, &cfg->timestamps, catalog ), status ); - /* load effective frequency-band from noise-SFTs */ fMin = cfg->fmin_eff; fMax = fMin + cfg->fBand_eff; TRY ( LALLoadSFTs( status->statusPtr, &(cfg->noiseSFTs), catalog, fMin, fMax ), status ); TRY ( LALDestroySFTCatalog ( status->statusPtr, &catalog ), status ); + /* get timestamps from the loaded noise SFTs */ + if ( ( cfg->timestamps = XLALgetSFTtimestamps ( cfg->noiseSFTs )) == NULL ) { + XLALPrintError ("%s: XLALgetSFTtimestamps() failed to obtain timestamps from SFTvector.\n", fn ); + ABORT (status, MAKEFAKEDATAC_EBAD, MAKEFAKEDATAC_MSGEBAD); + } + + } /* if uvar_noiseSFTs */ /* have we got our timestamps yet?: If not, we must get them from (start, duration) user-input */ @@ -993,14 +999,6 @@ InitMakefakedata (LALStatus *status, ConfigVars_t *cfg, int argc, char *argv[]) edat.ephiles.earthEphemeris = earthdata; edat.ephiles.sunEphemeris = sundata; - edat.leap = XLALGPSLeapSeconds( cfg->startTimeGPS.gpsSeconds ); - { - INT4 err = xlalErrno; - if ( err != XLAL_SUCCESS ) { - ABORT ( status, err, "XLALLeapSeconds() failed!\n"); - } - } - /* Init ephemerides */ TRY( LALInitBarycenter(status->statusPtr, &edat), status); LALFree(earthdata); @@ -1085,7 +1083,12 @@ InitMakefakedata (LALStatus *status, ConfigVars_t *cfg, int argc, char *argv[]) /* set random-number generator seed: either taken from user or from /dev/urandom */ if ( LALUserVarWasSet ( &uvar_randSeed ) ) - cfg->randSeed = uvar_randSeed; + { + if ( uvar_randSeed == 0 ) { + XLALPrintError ("WARNING: setting randSeed==0 results in the system clock being used as a random seed!\n"); + } + cfg->randSeed = uvar_randSeed; + } else { FILE *devrandom; diff --git a/lalapps/src/pulsar/Injections/makefakedatabinary.c b/lalapps/src/pulsar/Injections/makefakedatabinary.c index ff9a34f0843742c89eea57f4c1d7f45a6a3f4e24..a537fd56e6967fdf03c56637a444aad1ccc780eb 100644 --- a/lalapps/src/pulsar/Injections/makefakedatabinary.c +++ b/lalapps/src/pulsar/Injections/makefakedatabinary.c @@ -736,7 +736,6 @@ int prepare_baryinput(LALStatus* status){ edat=(EphemerisData *)LALMalloc(sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = earthdata; (*edat).ephiles.sunEphemeris = sundata; - (*edat).leap=13; /* Read in ephemerides */ LALInitBarycenter(status, edat); diff --git a/lalapps/src/pulsar/Injections/psinject.c b/lalapps/src/pulsar/Injections/psinject.c index 84b8ada5cd611fa29426d35b056b2d14e1bfae83..8e532f2fdc000de3c541da5b1b6688a448732381 100644 --- a/lalapps/src/pulsar/Injections/psinject.c +++ b/lalapps/src/pulsar/Injections/psinject.c @@ -26,7 +26,11 @@ 2005/02 - Reinhard Prix removed the actuation scaling options - 28 May 2009: renamed this code from 's3inject' to 'psinject' in lalsuite-GIT + 28 May 2009 - renamed this code from 's3inject' to 'psinject' in lalsuite-GIT + + 19 March - 10 August: Bruce Allen, added ability to output FRAME format files + for VIRGO real-time hardware injections. Code version XXX reviewed + by YYY. */ #define _GNU_SOURCE @@ -680,30 +684,26 @@ int main(int argc, char *argv[]){ /* now output the total signal to frames */ if (write_frames) { - static FrFile *oFile = NULL; + static int counter = 0; + static FrFile *oFile; + FrameH *frame; FrSimData *sim; int m, level = 0; double sampleRate = SRATE; long ndata = BLOCKSIZE; - char framename[256]; - static int counter=0; struct stat statbuf; - /* Create next frame file. This leads to a names like: - CW_Injection-921517800-60.gwf - */ + /* This leads to a names like: CW_Injection-921517800-60.gwf */ sprintf(framename, "CW_Injection"); - - /* sprintf(framename, "CW_Injection_%d.gwf", counter + gpstime); */ frame = FrameHNew(framename); if (!frame) { syserror(1, "FrameNew failed (%s)", FrErrorGetHistory()); exit(1); } - + /* set up GPS time, sample interval, copy data */ frame->GTimeS = gpstime + counter; frame->GTimeN = 0; @@ -712,45 +712,56 @@ int main(int argc, char *argv[]){ for (m=0; m < ndata; m++) { sim->data->dataF[m] = total[m]; } - - /* open file, write file, close file */ - if (!(counter % secs_per_framefile)) { - if (oFile) { - FrFileOEnd(oFile); - oFile = NULL; - } - - /* Does the user want us to keep a limited set of frames on disk? */ - if (write_frames>1) { - char listname[256]; - int watchtime = gpstime + secs_per_framefile*(counter/secs_per_framefile - write_frames + 1); - sprintf(listname, "CW_Injection-%d-%d.gwf", watchtime, secs_per_framefile); - while (!stat(listname, &statbuf)) { - /* if enough files in place, sleep 0.1 seconds */ - struct timespec rqtp; - rqtp.tv_sec = 0; - rqtp.tv_nsec = 100000000; - nanosleep(&rqtp, NULL); - } - } + /* open framefile, to contain secs_per_framefile of data */ + if (!counter) { oFile = FrFileONewM(framename, level, argv[0], secs_per_framefile); + if (!oFile) { + syserror(1, "Cannot open output file %s\n", framename); + exit(1); + } + /* Turn off the 'framefile boundary alignment'. Without this one gets: + CW_Injection-921517807-3.gwf + CW_Injection-921517810-10.gwf + CW_Injection-921517820-10.gwf + ... + With this one gets + CW_Injection-921517807-10.gwf + CW_Injection-921517817-10.gwf + ... + */ + oFile->aligned = FR_NO; } - - if (!oFile) { - syserror(1, "Cannot open output file %s\n", framename); - exit(1); - } + + /* write data to framefile */ if (FR_OK != FrameWrite(frame, oFile)) { syserror(1, "Error during frame write\n" - " Last errors are:\n%s", FrErrorGetHistory()); + " Last errors are:\n%s", FrErrorGetHistory()); exit(1); - } - /* FrFileOEnd(oFile); */ + } + + /* free memory for frames and for simdata structures */ FrameFree(frame); + + /* Do we keep a limited set of frames on disk? */ + if (write_frames>1) { + char listname[256]; + int watchtime = gpstime + secs_per_framefile*(counter/secs_per_framefile - write_frames + 1); + sprintf(listname, "CW_Injection-%d-%d.gwf", watchtime, secs_per_framefile); + /* syserror(0, "Watching for file %s to disappear....\n", listname); */ + while (!stat(listname, &statbuf)) { + /* if enough files already in place, then sleep 0.1 seconds */ + struct timespec rqtp; + rqtp.tv_sec = 0; + rqtp.tv_nsec = 100000000; + nanosleep(&rqtp, NULL); + } + } + /* increment counter for the next second */ counter++; - } + + } /* if (write_frames) */ /* now output the total signal... */ else if (channel){ diff --git a/lalapps/src/pulsar/Injections/testMFDv4-HW.sh b/lalapps/src/pulsar/Injections/testMFDv4-HW.sh index 762ddd9a03e4c66adb9946ecc084ca8de1a81859..280ded457b453bb3e46e60090830f9321ad7eb25 100755 --- a/lalapps/src/pulsar/Injections/testMFDv4-HW.sh +++ b/lalapps/src/pulsar/Injections/testMFDv4-HW.sh @@ -28,7 +28,7 @@ tol=1e-4 ## error tolerance for v2-v4 strain comparison if [ -z "$LAL_DATA_PATH" ]; then if [ -n "$LAL_PREFIX" ]; then - export LAL_DATA_PATH=".:${LAL_PREFIX}/share/lal"; + LAL_DATA_PATH=".:${LAL_PREFIX}/share/lal"; else echo echo "Need environment-variable LAL_PREFIX, or LAL_DATA_PATH to be set" @@ -38,6 +38,7 @@ if [ -z "$LAL_DATA_PATH" ]; then exit 1 fi fi +export LAL_DATA_PATH #prepare test subdirectory if [ ! -d "$testDIR" ]; then @@ -47,7 +48,12 @@ else rm -f $testDIR/* || true fi -ephemdir=$LAL_PREFIX/share/lal +#ephemdir=$LAL_PREFIX/share/lal +# determine ephemdir from LAL_DATA_PATH +SAVEIFS="$IFS" +IFS=: +for ephemdir in $LAL_DATA_PATH; do test -r $ephemdir/earth00-04.dat && break; done +IFS="$SAVEIFS" # input parameters Tsft=20 diff --git a/lalapps/src/pulsar/Injections/testMakefakedata.sh b/lalapps/src/pulsar/Injections/testMakefakedata.sh index 043971386c959f2bd144bed9ca55d2d704e881f4..6133c2eaf3382f01dd38a27237f324abd03ec593 100755 --- a/lalapps/src/pulsar/Injections/testMakefakedata.sh +++ b/lalapps/src/pulsar/Injections/testMakefakedata.sh @@ -15,7 +15,7 @@ compCode="${builddir}lalapps_compareSFTs" if [ -z "$LAL_DATA_PATH" ]; then if [ -n "$LAL_PREFIX" ]; then - export LAL_DATA_PATH=".:${LAL_PREFIX}/share/lal"; + LAL_DATA_PATH=".:${LAL_PREFIX}/share/lal"; else echo echo "Need environment-variable LAL_PREFIX, or LAL_DATA_PATH to be set" @@ -25,6 +25,7 @@ if [ -z "$LAL_DATA_PATH" ]; then exit 1 fi fi +export LAL_DATA_PATH if [ -z "$1" ]; then newcode=${newcodeDEFAULT} @@ -45,7 +46,13 @@ fi tol="1e-4"; ## tolerance on relative difference between SFTs in comparison # input parameters ## FIXED -ephemdir=$LAL_PREFIX/share/lal +#ephemdir=$LAL_PREFIX/share/lal +# determine ephemdir from LAL_DATA_PATH +SAVEIFS="$IFS" +IFS=: +for ephemdir in $LAL_DATA_PATH; do test -r $ephemdir/earth00-04.dat && break; done +IFS="$SAVEIFS" + Tsft=1800 nTsft=20 timestamps="$srcdir/testT8_1800" diff --git a/lalapps/src/pulsar/MakeSFTs/scripts/MakeSFTDAG b/lalapps/src/pulsar/MakeSFTs/scripts/MakeSFTDAG index 578c34002e722a2dc9f1b6f1dce147204399da0f..a6b4ca64373ac6f0b2bd7860fc876e027e396e2f 100755 --- a/lalapps/src/pulsar/MakeSFTs/scripts/MakeSFTDAG +++ b/lalapps/src/pulsar/MakeSFTs/scripts/MakeSFTDAG @@ -505,13 +505,12 @@ nodeCount = 0L datafindFID = file('datafind.sub','w') datafindLogFile = subLogPath + '/' + 'datafind_' + dagFileName + '.log' datafindFID.write('universe = scheduler\n') -datafindFID.write('executable = $ENV(LSC_DATAFIND_PATH)/LSCdataFind\n') - +datafindFID.write('executable = $ENV(LSC_DATAFIND_PATH)/ligo_data_find\n') if not datafindMatch: dataFindMatchString = '' else: dataFindMatchString = '--match ' + datafindMatch -datafindFID.write('arguments = --observatory $(observatory) --url-type file --gps-start-time $(gpsstarttime) --gps-end-time $(gpsendtime) --lal-cache --type $(inputdatatype) %s\n' % dataFindMatchString) +datafindFID.write('arguments = -r $ENV(LIGO_DATAFIND_SERVER) --observatory $(observatory) --url-type file --gps-start-time $(gpsstarttime) --gps-end-time $(gpsendtime) --lal-cache --type $(inputdatatype) %s\n' % dataFindMatchString) datafindFID.write('getenv = True\n') datafindFID.write('log = %s\n' % datafindLogFile) datafindFID.write('error = %s/datafind_$(tagstring).err\n' % logPath) diff --git a/lalapps/src/pulsar/PowerFlux/Makefile b/lalapps/src/pulsar/PowerFlux/Makefile index 76a0291d0c96621360691212d961e0246253ba88..6924380527b12ef49afccc109d75304b1a84c66d 100644 --- a/lalapps/src/pulsar/PowerFlux/Makefile +++ b/lalapps/src/pulsar/PowerFlux/Makefile @@ -1,9 +1,9 @@ PACKAGE=\"powerflux\" -VERSION=1.4.32-64 +VERSION=1.4.35-64 LALROOT=./../../../../ LALROOT=/opt/lscsoft/lal/ LALINCLUDE=-I$(LALROOT)/include/ -LALLDFLAGS=-L$(LALROOT)/lib -L$(LALROOT)/support-lib -llalsupport -llal -lm +LALLDFLAGS=-L$(LALROOT)/lib -L$(LALROOT)/support-lib -L/opt/zlib/lib -L/opt/png/lib -llalsupport -llal -lm -lz LDFLAGS=$(LALLDFLAGS) -L. -lpng #OPTFLAGS=-O2 -funroll-loops OPTFLAGS=-O6 -mmmx -msse -mcpu=i686 @@ -12,8 +12,8 @@ OPTFLAGS=-O6 -msse2 -march=i686 -funroll-loops OPTFLAGS=-O6 -march=opteron -funroll-loops -fno-stack-protector OPTFLAGS=-O -march=opteron -fno-stack-protector OPTFLAGS=-O6 -msse2 -funroll-loops -fno-stack-protector -OPTFLAGS=-O6 -mtune=opteron -mfpmath=sse -funroll-loops -fno-stack-protector -U_FORTIFY_SOURCE -OPTFLAGS=-O6 -mtune=nocona -funroll-loops -fno-stack-protector -U_FORTIFY_SOURCE +#OPTFLAGS=-O6 -mtune=opteron -mfpmath=sse -funroll-loops -fno-stack-protector -U_FORTIFY_SOURCE +OPTFLAGS=-O6 -mtune=nocona -funroll-loops -fno-stack-protector -msse3 -U_FORTIFY_SOURCE CFLAGS=-Wall -g $(OPTFLAGS) -DPACKAGE=$(PACKAGE) -DVERSION=\"$(VERSION)\" \ $(LALINCLUDE) -fPIC CC=gcc $(CFLAGS) @@ -25,7 +25,7 @@ PYTHON_OBJS=$(COMMON_OBJS) candidates.o fine_grid.o OBJS=$(COMMON_OBJS) fine_grid.o candidates.o powerflux.o -OBJS2=$(COMMON_OBJS) power_cache.o power_sums.o outer_loop.o power_sum_stats.o skymarks.o powerflux2.o +OBJS2=$(COMMON_OBJS) power_cache.o power_sums.o outer_loop.o power_sum_stats.o skymarks.o powerflux2.o summing_context.o FILES=no_marks.txt sky_marks.txt all_sky_marks_*.txt @@ -397,10 +397,11 @@ upload: powerflux-condor powerflux-mt globus-scp -C powerflux-mt hydra.phys.uwm.edu:PowerFlux/powerflux-mt.$(VERSION) globus-scp -C $(FILES) hydra.phys.uwm.edu:PowerFlux/ -upload.a: powerflux-condor powerflux-mt powerflux-condor2 - globus-scp -C powerflux-condor h2.atlas.aei.uni-hannover.de:PowerFlux/powerflux-condor.$(VERSION) - globus-scp -C powerflux-mt h2.atlas.aei.uni-hannover.de:PowerFlux/powerflux-mt.$(VERSION) - globus-scp -C powerflux-condor2 h2.atlas.aei.uni-hannover.de:PowerFlux/powerflux-condor2.$(VERSION) +upload.a: powerflux-condor powerflux-mt powerflux-condor2 powerflux-mt2 + #globus-scp -C powerflux-condor h2.atlas.aei.uni-hannover.de:PowerFlux/powerflux-condor.$(VERSION) + #globus-scp -C powerflux-mt h2.atlas.aei.uni-hannover.de:PowerFlux/powerflux-mt.$(VERSION) + #globus-scp -C powerflux-condor2 h2.atlas.aei.uni-hannover.de:PowerFlux/powerflux-condor2.$(VERSION) + globus-scp -C powerflux-mt2 h2.atlas.aei.uni-hannover.de:PowerFlux/powerflux-mt2.$(VERSION) globus-scp -C $(FILES) h2.atlas.aei.uni-hannover.de:PowerFlux/ upload.g: powerflux-condor powerflux-mt @@ -416,9 +417,11 @@ upload.l: powerflux-condor powerflux-mt globus-scp -C powerflux-condor ldas-grid.ligo-la.caltech.edu:PowerFlux/powerflux-condor.$(VERSION) globus-scp -C $(FILES) ldas-grid.ligo-la.caltech.edu:PowerFlux/ -upload.c: powerflux-condor powerflux-mt +upload.c: powerflux-condor powerflux-mt powerflux-condor2 powerflux-mt2 globus-scp -C powerflux-condor ldas-grid.ligo.caltech.edu:PowerFlux/powerflux-condor.$(VERSION) globus-scp -C powerflux-mt ldas-grid.ligo.caltech.edu:PowerFlux/powerflux-mt.$(VERSION) + globus-scp -C powerflux-condor2 ldas-grid.ligo.caltech.edu:PowerFlux/powerflux-condor2.$(VERSION) + globus-scp -C powerflux-mt2 ldas-grid.ligo.caltech.edu:PowerFlux/powerflux-mt2.$(VERSION) globus-scp -C $(FILES) ldas-grid.ligo.caltech.edu:PowerFlux/ upload.m: powerflux-condor powerflux-mt diff --git a/lalapps/src/pulsar/PowerFlux/cmdline.c b/lalapps/src/pulsar/PowerFlux/cmdline.c index 49cf6fa64abff966443101a93d5191bbc4af64c0..8281475425c6de4bdaed72f13b85f052809c2b38 100644 --- a/lalapps/src/pulsar/PowerFlux/cmdline.c +++ b/lalapps/src/pulsar/PowerFlux/cmdline.c @@ -131,6 +131,7 @@ const char *gengetopt_args_info_help[] = { " --fine-grid-skymarks=INT use sky marks from the fine grid, this uses \n constant spindown (default=`0')", " --half-window=INT number of bins to exclude to the left and to \n the right of highest point when computing \n linear statistics (default=`20')", " --tail-veto=INT do not report outlier if its frequency is \n within that many bins from the tail - happens \n with steep spectrum (default=`10')", + " --cache-granularity=INT granularity of power cache frequency shift \n resolution, in fractions of a frequency bin \n (default=`-1')", 0 }; @@ -284,6 +285,7 @@ void clear_given (struct gengetopt_args_info *args_info) args_info->fine_grid_skymarks_given = 0 ; args_info->half_window_given = 0 ; args_info->tail_veto_given = 0 ; + args_info->cache_granularity_given = 0 ; args_info->injection_group_counter = 0 ; } @@ -475,6 +477,8 @@ void clear_args (struct gengetopt_args_info *args_info) args_info->half_window_orig = NULL; args_info->tail_veto_arg = 10; args_info->tail_veto_orig = NULL; + args_info->cache_granularity_arg = -1; + args_info->cache_granularity_orig = NULL; } @@ -587,6 +591,7 @@ void init_args_info(struct gengetopt_args_info *args_info) args_info->fine_grid_skymarks_help = gengetopt_args_info_help[100] ; args_info->half_window_help = gengetopt_args_info_help[101] ; args_info->tail_veto_help = gengetopt_args_info_help[102] ; + args_info->cache_granularity_help = gengetopt_args_info_help[103] ; } @@ -830,6 +835,7 @@ cmdline_parser_release (struct gengetopt_args_info *args_info) free_string_field (&(args_info->fine_grid_skymarks_orig)); free_string_field (&(args_info->half_window_orig)); free_string_field (&(args_info->tail_veto_orig)); + free_string_field (&(args_info->cache_granularity_orig)); @@ -1070,6 +1076,8 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) write_into_file(outfile, "half-window", args_info->half_window_orig, 0); if (args_info->tail_veto_given) write_into_file(outfile, "tail-veto", args_info->tail_veto_orig, 0); + if (args_info->cache_granularity_given) + write_into_file(outfile, "cache-granularity", args_info->cache_granularity_orig, 0); i = EXIT_SUCCESS; @@ -1732,6 +1740,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf { "fine-grid-skymarks", 1, NULL, 0 }, { "half-window", 1, NULL, 0 }, { "tail-veto", 1, NULL, 0 }, + { "cache-granularity", 1, NULL, 0 }, { NULL, 0, NULL, 0 } }; @@ -3141,6 +3150,20 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf additional_error)) goto failure; + } + /* granularity of power cache frequency shift resolution, in fractions of a frequency bin. */ + else if (strcmp (long_options[option_index].name, "cache-granularity") == 0) + { + + + if (update_arg( (void *)&(args_info->cache_granularity_arg), + &(args_info->cache_granularity_orig), &(args_info->cache_granularity_given), + &(local_args_info.cache_granularity_given), optarg, 0, "-1", ARG_INT, + check_ambiguity, override, 0, 0, + "cache-granularity", '-', + additional_error)) + goto failure; + } break; diff --git a/lalapps/src/pulsar/PowerFlux/cmdline.h b/lalapps/src/pulsar/PowerFlux/cmdline.h index d9f5d436496447fe32029fb971fcebac9a6fa5da..7ce3047f0549a35d8eb44bb9d906b1f3432c9a58 100644 --- a/lalapps/src/pulsar/PowerFlux/cmdline.h +++ b/lalapps/src/pulsar/PowerFlux/cmdline.h @@ -332,6 +332,9 @@ struct gengetopt_args_info int tail_veto_arg; /**< @brief do not report outlier if its frequency is within that many bins from the tail - happens with steep spectrum (default='10'). */ char * tail_veto_orig; /**< @brief do not report outlier if its frequency is within that many bins from the tail - happens with steep spectrum original value given at command line. */ const char *tail_veto_help; /**< @brief do not report outlier if its frequency is within that many bins from the tail - happens with steep spectrum help description. */ + int cache_granularity_arg; /**< @brief granularity of power cache frequency shift resolution, in fractions of a frequency bin (default='-1'). */ + char * cache_granularity_orig; /**< @brief granularity of power cache frequency shift resolution, in fractions of a frequency bin original value given at command line. */ + const char *cache_granularity_help; /**< @brief granularity of power cache frequency shift resolution, in fractions of a frequency bin help description. */ unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int version_given ; /**< @brief Whether version was given. */ @@ -435,6 +438,7 @@ struct gengetopt_args_info unsigned int fine_grid_skymarks_given ; /**< @brief Whether fine-grid-skymarks was given. */ unsigned int half_window_given ; /**< @brief Whether half-window was given. */ unsigned int tail_veto_given ; /**< @brief Whether tail-veto was given. */ + unsigned int cache_granularity_given ; /**< @brief Whether cache-granularity was given. */ int injection_group_counter; /**< @brief Counter for group injection */ } ; diff --git a/lalapps/src/pulsar/PowerFlux/hookup.c b/lalapps/src/pulsar/PowerFlux/hookup.c index 46374839d0e2e86e0665cb761aa86097238bb356..46a4dcc1e3a04a26b3f59b5ac2de93419be4a791 100644 --- a/lalapps/src/pulsar/PowerFlux/hookup.c +++ b/lalapps/src/pulsar/PowerFlux/hookup.c @@ -226,15 +226,11 @@ void get_AM_response(INT64 gps, float latitude, float longitude, float orientati float *plus, float *cross) { LALStatus status={level:0, statusPtr:NULL}; -INT4 tmp_leapsecs; -LALGPSandAcc gps_and_acc; -LALLeapSecFormatAndAcc leapsec_info={LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; LALSource source; LALDetAndSource det_and_source={NULL, NULL}; LALDetAMResponse response; memset(&gps_and_acc, 0, sizeof(gps_and_acc)); -gps_and_acc.accuracy=leapsec_info.accuracy; gps_and_acc.gps.gpsSeconds=gps; gps_and_acc.gps.gpsNanoSeconds=0; @@ -247,9 +243,6 @@ source.equatorialCoords.latitude=latitude; det_and_source.pDetector=&detector; det_and_source.pSource=&source; -/* TODO : find out why DetAMResponse does not care about leap seconds, but - DetectorVel does */ - LALComputeDetAMResponse(&status, &response, &det_and_source, &gps_and_acc); TESTSTATUS(&status); @@ -262,16 +255,11 @@ void get_detector_vel(INT64 gps, float *velocity) LALStatus status={level:0, statusPtr:NULL}; REAL8 det_velocity[3]; LALGPSandAcc gps_and_acc; -LALLeapSecFormatAndAcc leapsec_info={LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; -/* LIGOTimeGPS gps; */ int i; memset(&gps_and_acc, 0, sizeof(gps_and_acc)); -gps_and_acc.accuracy=leapsec_info.accuracy; -gps_and_acc.gps.gpsSeconds=gps; +gps_and_acc.gps.gpsSeconds=gps; gps_and_acc.gps.gpsNanoSeconds=0; - -ephemeris.leap = (INT2)XLALGPSLeapSeconds((INT4)gps); LALDetectorVel(&status, det_velocity, &(gps_and_acc.gps), detector, &ephemeris); TESTSTATUS(&status); @@ -284,8 +272,7 @@ fprintf(stderr,"powerflux: det_velocity=(%g,%g,%g)\n", ); fprintf(stderr,"gps=%d (nano=%d)\n",gps_and_acc.gps.gpsSeconds, gps_and_acc.gps.gpsNanoSeconds); fprintf(stderr,"detector=%s\n", detector.frDetector.name); -fprintf(stderr,"powerflux leap=%d nE=%d nS=%d dE=%g dS=%g\n", - ephemeris.leap, +fprintf(stderr,"powerflux nE=%d nS=%d dE=%g dS=%g\n", ephemeris.nentriesE, ephemeris.nentriesS, ephemeris.dtEtable, diff --git a/lalapps/src/pulsar/PowerFlux/outer_loop.c b/lalapps/src/pulsar/PowerFlux/outer_loop.c index 87a90c1f614a595cfe84aa7547731a474a7497f7..c2bb672d8d1086a1811e20d3f41aff6f52126691 100644 --- a/lalapps/src/pulsar/PowerFlux/outer_loop.c +++ b/lalapps/src/pulsar/PowerFlux/outer_loop.c @@ -16,6 +16,8 @@ #include "rastermagic.h" #include "hookup.h" #include "outer_loop.h" +#include "summing_context.h" +#include "jobs.h" extern struct gengetopt_args_info args_info; @@ -586,29 +588,10 @@ OUTPUT_SKYMAP(weight_loss_fraction_skymap, "weight_loss_fraction"); OUTPUT_SKYMAP(ks_skymap, "ks_value"); } -void outer_loop(void) +void create_segments(EXTREME_INFO ***out_ei, int *out_nei) { -int pi, i, k, m; -int nchunks; -int nei; -POWER_SUM **ps, **ps_tmp; +int i, k, m, nei; EXTREME_INFO **ei; -int ps_tmp_len; -int count; -double gps_start=min_gps(); -double gps_stop=max_gps()+1; -time_t start_time, end_time; -RGBPic *p; -PLOT *plot; - -assign_per_dataset_cutoff_veto(); -assign_cutoff_veto(); -assign_detector_veto(); - -nchunks=args_info.nchunks_arg*veto_free; -ps=do_alloc(nchunks, sizeof(*ps)); -ps_tmp=do_alloc(nchunks, sizeof(*ps)); - ei=do_alloc(args_info.nchunks_arg*(args_info.nchunks_arg-1)*(veto_free+1), sizeof(*ei)); fprintf(LOG, "nchunks: %d\n", args_info.nchunks_arg); @@ -632,60 +615,156 @@ for(i=0;i<args_info.nchunks_arg;i++) nei++; } -fprintf(LOG, "nei: %d\n", nei); +*out_nei=nei; +*out_ei=ei; +} -time(&start_time); +SUMMING_CONTEXT **summing_contexts=NULL; +struct { + POWER_SUM **ps; + POWER_SUM **ps_tmp; + + } *cruncher_contexts=NULL; +int n_contexts=0; -fprintf(stderr, "%d patches to process\n", patch_grid->npoints); -for(pi=0;pi<patch_grid->npoints;pi++) { - if(pi % 100 == 0) { - time(&end_time); - if(end_time<start_time)end_time=start_time; - fprintf(stderr, "%d (%f patches/sec)\n", pi, pi/(1.0*(end_time-start_time+1.0))); - print_cache_stats(); - //fprintf(stderr, "%d\n", pi); - } - generate_patch_templates(pi, &(ps[0]), &count); +int nei; +EXTREME_INFO **ei=NULL; +int nchunks; - if(count<1)continue; +double gps_start; +double gps_stop; - for(i=1;i<nchunks;i++) { - clone_templates(ps[0], count, &(ps[i])); - } - for(i=0;i<args_info.nchunks_arg;i++) { - for(k=0;k<veto_free;k++) { - accumulate_power_sums(ps[i*veto_free+k], count, gps_start+i*(gps_stop-gps_start)/args_info.nchunks_arg, gps_start+(i+1)*(gps_stop-gps_start)/args_info.nchunks_arg, veto_info[k].veto_mask); - } +MUTEX data_logging_mutex; + + +void outer_loop_cruncher(int thread_id, void *data) +{ +int pi=(long)data; +SUMMING_CONTEXT *ctx=summing_contexts[thread_id+1]; +int ps_tmp_len; +int i,k,m,count; +POWER_SUM **ps=cruncher_contexts[thread_id+1].ps; +POWER_SUM **ps_tmp=cruncher_contexts[thread_id+1].ps_tmp; + +//fprintf(stderr, "%d ", pi); + +generate_patch_templates(pi, &(ps[0]), &count); + +if(count<1) { + free(ps[0]); + ps[0]=NULL; + return; + } + +for(i=1;i<nchunks;i++) { + clone_templates(ps[0], count, &(ps[i])); + } +for(i=0;i<args_info.nchunks_arg;i++) { + for(k=0;k<veto_free;k++) { + accumulate_power_sums(ctx, ps[i*veto_free+k], count, gps_start+i*(gps_stop-gps_start)/args_info.nchunks_arg, gps_start+(i+1)*(gps_stop-gps_start)/args_info.nchunks_arg, veto_info[k].veto_mask); } + } - /* find largest strain and largest SNR candidates for this patch */ - for(i=0;i<nei;i++) { - ps_tmp_len=0; - for(k=ei[i]->first_chunk;k<=ei[i]->last_chunk;k++) { - if(ei[i]->veto_num<0) { - for(m=0;m<veto_free;m++) { - ps_tmp[ps_tmp_len]=ps[k*veto_free+m]; - ps_tmp_len++; - } - } else { - ps_tmp[ps_tmp_len]=ps[k*veto_free+ei[i]->veto_num]; +/* find largest strain and largest SNR candidates for this patch */ +for(i=0;i<nei;i++) { + ps_tmp_len=0; + for(k=ei[i]->first_chunk;k<=ei[i]->last_chunk;k++) { + if(ei[i]->veto_num<0) { + for(m=0;m<veto_free;m++) { + ps_tmp[ps_tmp_len]=ps[k*veto_free+m]; ps_tmp_len++; } + } else { + ps_tmp[ps_tmp_len]=ps[k*veto_free+ei[i]->veto_num]; + ps_tmp_len++; } - log_extremes(ei[i], pi, ps_tmp, ps_tmp_len, count); } - for(i=0;i<nchunks;i++) { - free_templates(ps[i], count); - ps[i]=NULL; - } + thread_mutex_lock(data_logging_mutex); + log_extremes(ei[i], pi, ps_tmp, ps_tmp_len, count); + thread_mutex_unlock(data_logging_mutex); + } + +for(i=0;i<nchunks;i++) { + free_templates(ps[i], count); + ps[i]=NULL; + } +} + +void outer_loop(void) +{ +int pi, i, k; +time_t start_time, end_time; +RGBPic *p; +PLOT *plot; + +thread_mutex_init(&data_logging_mutex); + +assign_per_dataset_cutoff_veto(); +assign_cutoff_veto(); +assign_detector_veto(); + +nchunks=args_info.nchunks_arg*veto_free; + +create_segments(&ei, &nei); + +n_contexts=get_max_threads(); +summing_contexts=do_alloc(n_contexts, sizeof(*summing_contexts)); +for(i=0;i<n_contexts;i++) + summing_contexts[i]=create_summing_context(); + +cruncher_contexts=do_alloc(n_contexts, sizeof(*cruncher_contexts)); +for(i=0;i<n_contexts;i++) { + cruncher_contexts[i].ps=do_alloc(nchunks, sizeof(*cruncher_contexts[i].ps)); + cruncher_contexts[i].ps_tmp=do_alloc(nchunks, sizeof(*cruncher_contexts[i].ps_tmp)); } + +fprintf(LOG, "nei: %d\n", nei); + +gps_start=min_gps(); +gps_stop=max_gps()+1; + +reset_jobs_done_ratio(); + +time(&start_time); + +fprintf(stderr, "%d patches to process\n", patch_grid->npoints); +for(pi=0;pi<patch_grid->npoints;pi++) { +/* if(pi % 100 == 0) { + time(&end_time); + if(end_time<start_time)end_time=start_time; + fprintf(stderr, "%d (%f patches/sec)\n", pi, pi/(1.0*(end_time-start_time+1.0))); + ctx->print_cache_stats(ctx); + //fprintf(stderr, "%d\n", pi); + }*/ + submit_job(outer_loop_cruncher, (void *)((long)pi)); + } +k=0; +while(do_single_job(-1)) { + if(k % 100 == 0)fprintf(stderr, "% 3.1f ", jobs_done_ratio()*100); + k++; + } +wait_for_all_done(); +fprintf(stderr, "\n"); + time(&end_time); if(end_time<start_time)end_time=start_time; fprintf(stderr, "Patch speed: %f\n", patch_grid->npoints/(1.0*(end_time-start_time+1.0))); fprintf(LOG, "Patch speed: %f\n", patch_grid->npoints/(1.0*(end_time-start_time+1.0))); -free(ps); -print_cache_stats(); + +for(i=0;i<n_contexts;i++) { + summing_contexts[i]->print_cache_stats(summing_contexts[i]); + free_summing_context(summing_contexts[i]); + summing_contexts[i]=NULL; + + free(cruncher_contexts[i].ps); + free(cruncher_contexts[i].ps_tmp); + } +free(summing_contexts); +summing_contexts=NULL; +free(cruncher_contexts); +cruncher_contexts=NULL; + fflush(DATA_LOG); fflush(LOG); diff --git a/lalapps/src/pulsar/PowerFlux/power_cache.c b/lalapps/src/pulsar/PowerFlux/power_cache.c index e5f38e5878b1fcbaa1ea63bacdfa1f0b5b37f13f..09fc7115da2cc7f43d1fa0022e7c8339c5d7f6fa 100644 --- a/lalapps/src/pulsar/PowerFlux/power_cache.c +++ b/lalapps/src/pulsar/PowerFlux/power_cache.c @@ -5,11 +5,15 @@ #define __USE_ISOC99 #include <math.h> #include <gsl/gsl_cblas.h> + +#include <pmmintrin.h> #include <xmmintrin.h> #include "polarization.h" #include "dataset.h" +#include "util.h" #include "power_cache.h" +#include "summing_context.h" #include "cmdline.h" extern DATASET *datasets; @@ -286,7 +290,7 @@ accum->c_weight_pccc+=partial->c_weight_pccc; accum->c_weight_cccc+=partial->c_weight_cccc; } -void get_uncached_single_bin_power_sum(SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps) +void get_uncached_single_bin_power_sum(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps) { int i,k,n,m; int bin_shift; @@ -472,7 +476,7 @@ pps->c_weight_cccc=weight_cccc; pps->collapsed_weight_arrays=0; } -void sse_get_uncached_single_bin_power_sum(SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps) +void sse_get_uncached_single_bin_power_sum(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps) { int i,k,n,m; int bin_shift; @@ -722,12 +726,462 @@ pps->c_weight_cccc=weight_cccc; pps->collapsed_weight_arrays=0; } -struct { +void get_uncached_matched_power_sum(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps) +{ +int i,k,n,m; +int bin_shift; +SEGMENT_INFO *si_local; +DATASET *d; +//POLARIZATION *pl; +float *im, *re, *pp, *pc, *cc, *fm; +float *power, *p; +float a; +float TM; +float weight; +float f_plus, f_cross, f_pp, f_pc, f_cc; +float filter[7]; +float x,y; + +int pps_bins=pps->nbins; + +float pmax; +float sum, sum_sq; +float pps_bins_inv=1.0/pps_bins; +//float pmax_factor=args_info.power_max_median_factor_arg; + +float weight_pppp=0; +float weight_pppc=0; +float weight_ppcc=0; +float weight_pccc=0; +float weight_cccc=0; + +/*pp=aligned_alloca(pps_bins*sizeof(*pp)); +pc=aligned_alloca(pps_bins*sizeof(*pc)); +cc=aligned_alloca(pps_bins*sizeof(*cc));*/ +power=aligned_alloca(pps_bins*sizeof(*power)); + +pp=pps->power_pp; +pc=pps->power_pc; +cc=pps->power_cc; +for(i=0;i<pps_bins;i++) { + (*pp)=0.0; + (*pc)=0.0; + (*cc)=0.0; + + pp++; + pc++; + cc++; + } + +pps->weight_arrays_non_zero=0; + +for(i=0;i<pps_bins;i++) { + pps->weight_pppp[i]=0.0; + pps->weight_pppc[i]=0.0; + pps->weight_ppcc[i]=0.0; + pps->weight_pccc[i]=0.0; + pps->weight_cccc[i]=0.0; + } + +//fprintf(stderr, "%d\n", count); + +for(k=0;k<count;k++) { + si_local=&(si[k]); + + bin_shift=rintf(si_local->bin_shift)-pps->offset; + if((bin_shift+side_cut<0) || (bin_shift>pps_bins+side_cut)) { + fprintf(stderr, "*** Attempt to sample outside loaded range bin_shift=%d bin_shift=%lg, aborting\n", + bin_shift, si_local->bin_shift); + exit(-1); + } + + d=&(datasets[si_local->dataset]); +// pl=&(d->polarizations[0]); + + //f_plus=F_plus_coeff(si_local->segment, si_local->e, pl->AM_coeffs); + //f_cross=F_plus_coeff(si_local->segment, si_local->e, pl->conjugate->AM_coeffs); + + f_plus=si_local->f_plus; + f_cross=si_local->f_cross; + + + re=&(d->re[si_local->segment*nbins+side_cut+bin_shift]); + im=&(d->im[si_local->segment*nbins+side_cut+bin_shift]); + fm=&(d->expFMedians_plain[side_cut+bin_shift]); + + if(args_info.subtract_background_arg) { + TM=d->expTMedians[si_local->segment]; + } else { + TM=0; + } + + tabulated_fill_hann_filter7(filter, (si_local->bin_shift-rintf(si_local->bin_shift))); + + pmax=0.0; + sum=0.0; + sum_sq=0.0; + p=power; + for(i=0;i<pps_bins;i++) { + x=re[-3]*filter[0]+re[-2]*filter[1]+re[-1]*filter[2]+re[0]*filter[3]+re[1]*filter[4]+re[2]*filter[5]+re[3]*filter[6]; + y=im[-3]*filter[0]+im[-2]*filter[1]+im[-1]*filter[2]+im[0]*filter[3]+im[1]*filter[4]+im[2]*filter[5]+im[3]*filter[6]; + + a=x*x+y*y; + + //a=((*re)*(*re)+(*im)*(*im)-TM*(*fm)); + //if(a>pmax)pmax=a; + (*p)=a; + sum+=a; + sum_sq+=a*a; + + im++; + re++; + fm++; + p++; + } + + if(args_info.tmedian_noise_level_arg) { + weight=d->expTMedians[si_local->segment]*d->weight; + } else { + sum*=pps_bins_inv; + sum_sq*=pps_bins_inv; + sum_sq-=sum*sum; + // + // pmax*=pmax_factor; /* scale factor to bring it down to power median */ + // a=pmax*pmax; + // //if(a>weight)weight=a; + // + weight=1.0/sum_sq; + } + + f_pp=f_plus*f_plus; + f_pc=f_plus*f_cross; + f_cc=f_cross*f_cross; + + + weight_pppp+=weight*f_pp*f_pp; + weight_pppc+=weight*f_pp*f_pc; + weight_ppcc+=weight*f_pp*f_cc; + weight_pccc+=weight*f_pc*f_cc; + weight_cccc+=weight*f_cc*f_cc; + + f_pp*=weight; + f_pc*=weight; + f_cc*=weight; + + p=power; + pp=pps->power_pp; + pc=pps->power_pc; + cc=pps->power_cc; + for(i=0;i<pps_bins;i++) { + a=(*p); + + (*pp)+=a*f_pp; + (*pc)+=a*f_pc; + (*cc)+=a*f_cc; + + p++; + pp++; + pc++; + cc++; + /**/ + } + + pp=pps->power_pp; + pc=pps->power_pc; + cc=pps->power_cc; + + /* + + for(n=0;(d->lines_report->lines_list[n]>=0)&&(n<d->lines_report->nlines);n++) { + m=d->lines_report->lines_list[n]; + i=m-side_cut-bin_shift; + if(i<0)continue; + if(i>=pps_bins)continue; + + a=power[i]*weight; + + pp[i]-=a*f_plus*f_plus; + pc[i]-=a*f_plus*f_cross; + cc[i]-=a*f_cross*f_cross; + + pps->weight_pppp[i]-=weight*f_plus*f_plus*f_plus*f_plus; + pps->weight_pppc[i]-=weight*f_plus*f_plus*f_plus*f_cross; + pps->weight_ppcc[i]-=weight*f_plus*f_plus*f_cross*f_cross; + pps->weight_pccc[i]-=weight*f_plus*f_cross*f_cross*f_cross; + pps->weight_cccc[i]-=weight*f_cross*f_cross*f_cross*f_cross; + + pps->weight_arrays_non_zero=1; + } + + */ + } + +pps->c_weight_pppp=weight_pppp; +pps->c_weight_pppc=weight_pppc; +pps->c_weight_ppcc=weight_ppcc; +pps->c_weight_pccc=weight_pccc; +pps->c_weight_cccc=weight_cccc; + +pps->collapsed_weight_arrays=0; +} + +void sse_get_uncached_matched_power_sum(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps) +{ +int i,k,n,m; +int bin_shift; +SEGMENT_INFO *si_local; +DATASET *d; +//POLARIZATION *pl; +float *im, *re, *pp, *pc, *cc, *fm; +float *power, *p; +float a; +float TM; +float weight; +float f_plus, f_cross, f_pp, f_pc, f_cc; + +int pps_bins=pps->nbins; + +float sum, sum_sq; +float pps_bins_inv=1.0/pps_bins; +//float pmax_factor=args_info.power_max_median_factor_arg; + +float filter[8]; + +float weight_pppp=0; +float weight_pppc=0; +float weight_ppcc=0; +float weight_pccc=0; +float weight_cccc=0; +__m128 v4power, v4power0, v4power1, v4tm, v4sum, v4sum_sq, v4pp, v4pc, v4cc, v4a, v4b, v4a1, v4b1, v4filt0, v4filt1; +float *tmp1, *tmp2; + +/*pp=aligned_alloca(pps_bins*sizeof(*pp)); +pc=aligned_alloca(pps_bins*sizeof(*pc)); +cc=aligned_alloca(pps_bins*sizeof(*cc));*/ +power=aligned_alloca(pps_bins*sizeof(*power)); + +tmp1=aligned_alloca(8*sizeof(*tmp1)); +tmp2=aligned_alloca(8*sizeof(*tmp2)); + +pp=pps->power_pp; +pc=pps->power_pc; +cc=pps->power_cc; +for(i=0;i<pps_bins;i++) { + (*pp)=0.0; + (*pc)=0.0; + (*cc)=0.0; + + pp++; + pc++; + cc++; + } + +pps->weight_arrays_non_zero=0; + +for(i=0;i<pps_bins;i++) { + pps->weight_pppp[i]=0.0; + pps->weight_pppc[i]=0.0; + pps->weight_ppcc[i]=0.0; + pps->weight_pccc[i]=0.0; + pps->weight_cccc[i]=0.0; + } + +//fprintf(stderr, "%d\n", count); + +for(k=0;k<count;k++) { + si_local=&(si[k]); + + bin_shift=rintf(si_local->bin_shift)-pps->offset; + if((bin_shift+side_cut<0) || (bin_shift>pps_bins+side_cut)) { + fprintf(stderr, "*** Attempt to sample outside loaded range bin_shift=%d bin_shift=%lg, aborting\n", + bin_shift, si_local->bin_shift); + exit(-1); + } + + d=&(datasets[si_local->dataset]); +// pl=&(d->polarizations[0]); + + //f_plus=F_plus_coeff(si_local->segment, si_local->e, pl->AM_coeffs); + //f_cross=F_plus_coeff(si_local->segment, si_local->e, pl->conjugate->AM_coeffs); + + f_plus=si_local->f_plus; + f_cross=si_local->f_cross; + + + re=&(d->re[si_local->segment*nbins+side_cut+bin_shift]); + im=&(d->im[si_local->segment*nbins+side_cut+bin_shift]); + fm=&(d->expFMedians_plain[side_cut+bin_shift]); + + if(args_info.subtract_background_arg) { + TM=-d->expTMedians[si_local->segment]; + } else { + TM=0; + } + + tabulated_fill_hann_filter7(filter, (si_local->bin_shift-rintf(si_local->bin_shift))); + filter[7]=0.0; + v4filt0=_mm_load_ps(filter); + v4filt1=_mm_load_ps(&(filter[4])); + + p=power; + + sum=0; + sum_sq=0; + tmp1[7]=0; + tmp2[7]=0; + for(i=0;i<pps_bins;i++) { + memcpy(tmp1, &(re[-3]), 8*sizeof(*tmp1)); + memcpy(tmp2, &(im[-3]), 8*sizeof(*tmp2)); + + v4a=_mm_load_ps(&(tmp1[0])); + v4a1=_mm_load_ps(&(tmp1[4])); + + v4a=_mm_mul_ps(v4filt0, v4a); + v4a1=_mm_mul_ps(v4filt1, v4a1); + + v4a=_mm_add_ps(v4a, v4a1); + + v4b=_mm_load_ps(&(tmp2[0])); + v4b1=_mm_load_ps(&(tmp2[4])); + + v4b=_mm_mul_ps(v4filt0, v4b); + v4b1=_mm_mul_ps(v4filt1, v4b1); + + v4b=_mm_add_ps(v4b, v4b1); + +// v4a=_mm_add_ps(_mm_mul_ps(v4filt0, _mm_loadu_ps(&(re[-3]))), _mm_mul_ps(v4filt1, _mm_load_ps(&(re[1])))); +// v4b=_mm_add_ps(_mm_mul_ps(v4filt0, _mm_loadu_ps(&(im[-3]))), _mm_mul_ps(v4filt1, _mm_load_ps(&(im[1])))); + + v4power0=_mm_hadd_ps(v4a, v4b); + v4power0=_mm_hadd_ps(v4power0, v4power0); + v4power1=_mm_mul_ps(v4power0, v4power0); + v4power1=_mm_hadd_ps(v4power1, v4power1); + + _mm_store_ss(&a, v4power1); + + *p=a; + + sum+=a; + sum_sq+=a*a; + + im++; + re++; + p++; + } + + if(args_info.tmedian_noise_level_arg) { + weight=d->expTMedians[si_local->segment]*d->weight; + } else { + sum*=pps_bins_inv; + sum_sq*=pps_bins_inv; + sum_sq-=sum*sum; + // + // pmax*=pmax_factor; /* scale factor to bring it down to power median */ + // a=pmax*pmax; + // //if(a>weight)weight=a; + // + weight=1.0/sum_sq; + } + + f_pp=f_plus*f_plus; + f_pc=f_plus*f_cross; + f_cc=f_cross*f_cross; + + + weight_pppp+=weight*f_pp*f_pp; + weight_pppc+=weight*f_pp*f_pc; + weight_ppcc+=weight*f_pp*f_cc; + weight_pccc+=weight*f_pc*f_cc; + weight_cccc+=weight*f_cc*f_cc; + + f_pp*=weight; + f_pc*=weight; + f_cc*=weight; + + p=power; + pp=pps->power_pp; + pc=pps->power_pc; + cc=pps->power_cc; + + v4pp=_mm_load1_ps(&f_pp); + v4pc=_mm_load1_ps(&f_pc); + v4cc=_mm_load1_ps(&f_cc); + + for(i=0;i<(pps_bins-3);i+=4) { + v4power=_mm_load_ps(p); + + _mm_store_ps(pp, _mm_add_ps(_mm_load_ps(pp), _mm_mul_ps(v4power, v4pp))); + _mm_store_ps(pc, _mm_add_ps(_mm_load_ps(pc), _mm_mul_ps(v4power, v4pc))); + _mm_store_ps(cc, _mm_add_ps(_mm_load_ps(cc), _mm_mul_ps(v4power, v4cc))); + + p+=4; + pp+=4; + pc+=4; + cc+=4; + /**/ + } + + for(;i<pps_bins;i++) { + a=(*p); + + (*pp)+=a*f_pp; + (*pc)+=a*f_pc; + (*cc)+=a*f_cc; + + p++; + pp++; + pc++; + cc++; + /**/ + } + + /* + pp=pps->power_pp; + pc=pps->power_pc; + cc=pps->power_cc; + for(n=0;(d->lines_report->lines_list[n]>=0)&&(n<d->lines_report->nlines);n++) { + m=d->lines_report->lines_list[n]; + i=m-side_cut-bin_shift; + if(i<0)continue; + if(i>=pps_bins)continue; + + a=power[i]*weight; + + pp[i]-=a*f_plus*f_plus; + pc[i]-=a*f_plus*f_cross; + cc[i]-=a*f_cross*f_cross; + + pps->weight_pppp[i]-=weight*f_plus*f_plus*f_plus*f_plus; + pps->weight_pppc[i]-=weight*f_plus*f_plus*f_plus*f_cross; + pps->weight_ppcc[i]-=weight*f_plus*f_plus*f_cross*f_cross; + pps->weight_pccc[i]-=weight*f_plus*f_cross*f_cross*f_cross; + pps->weight_cccc[i]-=weight*f_cross*f_cross*f_cross*f_cross; + + pps->weight_arrays_non_zero=1; + } + */ + } + +pps->c_weight_pppp=weight_pppp; +pps->c_weight_pppc=weight_pppc; +pps->c_weight_ppcc=weight_ppcc; +pps->c_weight_pccc=weight_pccc; +pps->c_weight_cccc=weight_cccc; + +pps->collapsed_weight_arrays=0; +} + +#define SIMPLE_CACHE_ID 1 + +typedef struct { + long id; + /* statistics */ long hits; long misses; long overwrites; long large_shifts; + int max_size; /* cache contents */ int segment_count; @@ -736,29 +1190,94 @@ struct { int *key; SEGMENT_INFO **si; PARTIAL_POWER_SUM_F **pps; - } SIMPLE_CACHE={0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL}; + } SIMPLE_CACHE; + +void free_simple_cache(SUMMING_CONTEXT *ctx) +{ +int i; +SIMPLE_CACHE *sc=(SIMPLE_CACHE *)ctx->cache; +if(sc==NULL)return; +if(sc->id!=SIMPLE_CACHE_ID) { + fprintf(stderr, "INTERNAL ERROR: simple cache id does not match in %s, aborting\n", __FUNCTION__); + exit(-1); + } +ctx->cache=NULL; +for(i=0;i<sc->free;i++) { + free_partial_power_sum_F(sc->pps[i]); + free(sc->si[i]); + } +free(sc->pps); +free(sc->si); +free(sc->key); +free(sc); +} + +void print_simple_cache_stats(SUMMING_CONTEXT *ctx) +{ +SIMPLE_CACHE *sc=(SIMPLE_CACHE *)ctx->cache; +if(sc==NULL) { + fprintf(stderr, "SIMPLE CACHE has not been initialized yet\n"); + fprintf(LOG, "SIMPLE CACHE has not been initialized yet\n"); + return; + } +if(sc->id!=SIMPLE_CACHE_ID) { + fprintf(stderr, "INTERNAL ERROR: simple cache id does not match in %s, aborting\n", __FUNCTION__); + exit(-1); + } +fprintf(stderr, "SIMPLE_CACHE stats: max_size=%d hits=%ld misses=%ld overwrites=%ld large_shifts=%ld miss ratio %f overwrite ratio %f\n", sc->max_size, sc->hits, sc->misses, sc->overwrites, sc->large_shifts, + sc->misses/(sc->hits+sc->misses+0.0), sc->overwrites/(sc->hits+sc->misses+0.0)); + +fprintf(LOG, "SIMPLE_CACHE stats: max_size=%d hits=%ld misses=%ld overwrites=%ld large_shifts=%ld miss ratio %f overwrite ratio %f\n", sc->max_size, sc->hits, sc->misses, sc->overwrites, sc->large_shifts, + sc->misses/(sc->hits+sc->misses+0.0), sc->overwrites/(sc->hits+sc->misses+0.0)); +} -void reset_simple_cache(int segment_count, int template_count) +void reset_simple_cache(SUMMING_CONTEXT *ctx, int segment_count, int template_count) { int i; -for(i=0;i<SIMPLE_CACHE.free;i++) { - free_partial_power_sum_F(SIMPLE_CACHE.pps[i]); - free(SIMPLE_CACHE.si[i]); - } -free(SIMPLE_CACHE.pps); -free(SIMPLE_CACHE.si); -free(SIMPLE_CACHE.key); - -SIMPLE_CACHE.segment_count=segment_count; -SIMPLE_CACHE.size=template_count; -SIMPLE_CACHE.free=0; -SIMPLE_CACHE.key=do_alloc(SIMPLE_CACHE.size, sizeof(*SIMPLE_CACHE.key)); -SIMPLE_CACHE.pps=do_alloc(SIMPLE_CACHE.size, sizeof(*SIMPLE_CACHE.pps)); -SIMPLE_CACHE.si=do_alloc(SIMPLE_CACHE.size, sizeof(*SIMPLE_CACHE.si)); +SIMPLE_CACHE *sc=(SIMPLE_CACHE *)ctx->cache; +if((sc==NULL) || (sc->id!=SIMPLE_CACHE_ID)) { + fprintf(stderr, "INTERNAL ERROR: simple cache id does not match in %s, aborting\n", __FUNCTION__); + exit(-1); + } +if(sc->free>sc->max_size)sc->max_size=sc->free; +for(i=0;i<sc->free;i++) { + free_partial_power_sum_F(sc->pps[i]); + free(sc->si[i]); + } +free(sc->pps); +free(sc->si); +free(sc->key); + +sc->segment_count=segment_count; +sc->size=template_count; +sc->free=0; +sc->key=do_alloc(sc->size, sizeof(*sc->key)); +sc->pps=do_alloc(sc->size, sizeof(*sc->pps)); +sc->si=do_alloc(sc->size, sizeof(*sc->si)); } +void allocate_simple_cache(SUMMING_CONTEXT *ctx) +{ +SIMPLE_CACHE *sc; +if(ctx->cache!=NULL)ctx->free_cache(ctx); +ctx->cache=NULL; +sc=do_alloc(1, sizeof(SIMPLE_CACHE)); + +memset(sc, 0, sizeof(*sc)); +sc->id=SIMPLE_CACHE_ID; + +ctx->free_cache=free_simple_cache; +ctx->print_cache_stats=print_simple_cache_stats; +ctx->reset_cache=reset_simple_cache; +ctx->cache=sc; +} + + +#define KEY_MULT 8388623 +#define KEY_DIV ((1<<31)-1) + /* Note: si is modified in place to have bin_shift rounded as appropriate to the power generating algorithm */ -void accumulate_single_bin_power_sum_cached1(SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps) +void accumulate_power_sum_cached1(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps) { int i, k; int match; @@ -767,97 +1286,104 @@ float a; int first_shift; int max_shift=args_info.max_first_shift_arg; SEGMENT_INFO *si_local, *sc_si_local; -if(count!=SIMPLE_CACHE.segment_count) { +int *sc_key; + +SIMPLE_CACHE *sc=(SIMPLE_CACHE *)ctx->cache; +if((sc==NULL) || (sc->id!=SIMPLE_CACHE_ID)) { + fprintf(stderr, "INTERNAL ERROR: simple cache id does not match in %s, aborting\n", __FUNCTION__); + exit(-1); + } + +if(count!=sc->segment_count) { fprintf(stderr, "Internal error: segment counts don't match.\n"); exit(-1); } +/* normalize frequency shifts by rounding off to nearest cache granularity value */ si_local=si; key=0.0; -k=rintf(si_local->bin_shift); +k=rintf(si_local->bin_shift)*ctx->cache_granularity; for(i=0;i<count;i++) { //fprintf(stderr, "%0.1f ", si_local->bin_shift); - a=rintf(si_local->bin_shift); - key+=((int)a-k)*2*i; - si_local->bin_shift=a; + a=rintf(si_local->bin_shift*ctx->cache_granularity); + + key=( (key+(int)a-k) * KEY_MULT) & KEY_DIV; + + si_local->bin_shift=a*ctx->inv_cache_granularity; si_local++; //fprintf(stderr, "%0.1f ", a); } -//fprintf(stderr, "%d ", key); +//fprintf(stderr, "k=%d key=%d %f\n", k, key, a); -for(k=0;k<SIMPLE_CACHE.free;k++) { - /* the reason we use exact equality for floating point numbers is because the number in cache have been placed there by the same function. */ - if(key==SIMPLE_CACHE.key[k]) { +sc_key=sc->key; +for(k=0;k<sc->free;k++) { + /* the reason we use exact equality for floating point numbers is because the numbers in cache have been placed there by the same function. */ + if(key==sc_key[k]) { /* we found the box holding our data, double check it is the right one */ si_local=si; - sc_si_local=SIMPLE_CACHE.si[k]; - first_shift=si_local->bin_shift-sc_si_local->bin_shift; + sc_si_local=sc->si[k]; + first_shift=rintf(si_local->bin_shift-sc_si_local->bin_shift); if( (first_shift>max_shift) || (first_shift< -max_shift)) { - SIMPLE_CACHE.large_shifts++; + sc->large_shifts++; break; } match=1; - for(i=1;i<count;i++) { - si_local++; - sc_si_local++; - - if(si_local->bin_shift!=sc_si_local->bin_shift+first_shift) { + for(i=0;i<count;i++) { + if(fabs(si_local->bin_shift-(sc_si_local->bin_shift+first_shift))> ctx->half_inv_cache_granularity) { match=0; + fprintf(stderr, "OVERWRITE: i=%d key=%d count=%d %f %f %d\n", i, key, count, si_local->bin_shift, sc_si_local->bin_shift, first_shift); break; } + + si_local++; + sc_si_local++; } if(match) { - SIMPLE_CACHE.hits++; + sc->hits++; /* align pps with stored data */ pps->offset-=first_shift; - sse_accumulate_partial_power_sum_F(pps, SIMPLE_CACHE.pps[k]); + sse_accumulate_partial_power_sum_F(pps, sc->pps[k]); pps->offset+=first_shift; //fprintf(stderr, "hit\n"); return; } - SIMPLE_CACHE.overwrites++; + sc->overwrites++; break; } } -SIMPLE_CACHE.misses++; +sc->misses++; //fprintf(stderr, "miss\n"); -if(k>=SIMPLE_CACHE.size) { +if(k>=sc->size) { fprintf(stderr, "*** INTERNAL ERROR: cache overflow\n"); exit(-1); } -if(k>=SIMPLE_CACHE.free) { - SIMPLE_CACHE.si[k]=do_alloc(SIMPLE_CACHE.segment_count, sizeof(*si)); - SIMPLE_CACHE.pps[k]=allocate_partial_power_sum_F(useful_bins+2*max_shift); - SIMPLE_CACHE.free++; +if(k>=sc->free) { + sc->si[k]=do_alloc(sc->segment_count, sizeof(*si)); + sc->pps[k]=allocate_partial_power_sum_F(useful_bins+2*max_shift); + sc->free++; } -SIMPLE_CACHE.key[k]=key; -memcpy(SIMPLE_CACHE.si[k], si, SIMPLE_CACHE.segment_count*sizeof(*si)); +sc->key[k]=key; +memcpy(sc->si[k], si, sc->segment_count*sizeof(*si)); -sse_get_uncached_single_bin_power_sum(SIMPLE_CACHE.si[k], SIMPLE_CACHE.segment_count, SIMPLE_CACHE.pps[k]); -sse_accumulate_partial_power_sum_F(pps, SIMPLE_CACHE.pps[k]); -} - -void print_cache_stats(void) -{ -fprintf(stderr, "SIMPLE_CACHE stats: hits=%ld misses=%ld overwrites=%ld large_shifts=%ld miss ratio %f overwrite ratio %f\n", SIMPLE_CACHE.hits, SIMPLE_CACHE.misses, SIMPLE_CACHE.overwrites, SIMPLE_CACHE.large_shifts, - SIMPLE_CACHE.misses/(SIMPLE_CACHE.hits+SIMPLE_CACHE.misses+0.0), SIMPLE_CACHE.overwrites/(SIMPLE_CACHE.hits+SIMPLE_CACHE.misses+0.0)); - -fprintf(LOG, "SIMPLE_CACHE stats: hits=%ld misses=%ld overwrites=%ld large_shifts=%ld miss ratio %f overwrite ratio %f\n", SIMPLE_CACHE.hits, SIMPLE_CACHE.misses, SIMPLE_CACHE.overwrites, SIMPLE_CACHE.large_shifts, - SIMPLE_CACHE.misses/(SIMPLE_CACHE.hits+SIMPLE_CACHE.misses+0.0), SIMPLE_CACHE.overwrites/(SIMPLE_CACHE.hits+SIMPLE_CACHE.misses+0.0)); +ctx->get_uncached_power_sum(ctx, sc->si[k], sc->segment_count, sc->pps[k]); +sse_accumulate_partial_power_sum_F(pps, sc->pps[k]); } void power_cache_selftest(void) { SEGMENT_INFO *si=NULL; PARTIAL_POWER_SUM_F *ps1=NULL, *ps2=NULL, *ps3=NULL, *ps4=NULL; +SUMMING_CONTEXT *ctx; int i; int count; int result=0; +ctx=create_summing_context(); + ps1=allocate_partial_power_sum_F(useful_bins+10); ps2=allocate_partial_power_sum_F(useful_bins+10); ps3=allocate_partial_power_sum_F(useful_bins+10); @@ -891,18 +1417,27 @@ for(i=0;i<count;i++) { si[i].f_cross= (i%17)/17.0; } /* reference implementation */ -get_uncached_single_bin_power_sum(si, count, ps3); +get_uncached_single_bin_power_sum(ctx, si, count, ps3); /* sse implementation */ -sse_get_uncached_single_bin_power_sum(si, count, ps4); +sse_get_uncached_single_bin_power_sum(ctx, si, count, ps4); result+=compare_partial_power_sums_F("sse_get_uncached_single_bin_power_sum:", ps3, ps4); +/* reference implementation */ +get_uncached_matched_power_sum(ctx, si, count, ps3); + +/* sse implementation */ +sse_get_uncached_matched_power_sum(ctx, si, count, ps4); +result+=compare_partial_power_sums_F("sse_get_uncached_matched_power_sum:", ps3, ps4); + free(si); free_partial_power_sum_F(ps1); free_partial_power_sum_F(ps2); free_partial_power_sum_F(ps3); free_partial_power_sum_F(ps4); +free_summing_context(ctx); + if(result<0) { fprintf(stderr, "*** POWER CACHE selftest failed, exiting\n"); exit(-1); @@ -910,4 +1445,4 @@ if(result<0) { fprintf(stderr, "Power cache selftest: passed\n"); fprintf(LOG, "Power cache selftest: passed\n"); -} \ No newline at end of file +} diff --git a/lalapps/src/pulsar/PowerFlux/power_cache.h b/lalapps/src/pulsar/PowerFlux/power_cache.h index 8458f32666f01c32b7fcf414c0ada39228d45397..56cd3429f7d655654e2673fbe3e74b636dd23860 100644 --- a/lalapps/src/pulsar/PowerFlux/power_cache.h +++ b/lalapps/src/pulsar/PowerFlux/power_cache.h @@ -38,17 +38,22 @@ typedef struct { #undef REAL #undef SUFFIX +#include "summing_context.h" + void accumulate_partial_power_sum_F1(PARTIAL_POWER_SUM_F *accum, PARTIAL_POWER_SUM *partial); void accumulate_partial_power_sum_F2(PARTIAL_POWER_SUM *accum, PARTIAL_POWER_SUM_F *partial); SEGMENT_INFO *find_segments(double gps_start, double gps_end, int veto_mask, int *count); -void reset_simple_cache(int segment_count, int template_count); +void allocate_simple_cache(SUMMING_CONTEXT *ctx); + +void get_uncached_single_bin_power_sum(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps); +void sse_get_uncached_single_bin_power_sum(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps); -void get_uncached_single_bin_power_sum(SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps); -void accumulate_single_bin_power_sum_cached1(SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps); +void get_uncached_matched_power_sum(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps); +void sse_get_uncached_matched_power_sum(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps); +void accumulate_power_sum_cached1(SUMMING_CONTEXT *ctx, SEGMENT_INFO *si, int count, PARTIAL_POWER_SUM_F *pps); -void print_cache_stats(void); void power_cache_selftest(void); #endif diff --git a/lalapps/src/pulsar/PowerFlux/power_sum_stats.c b/lalapps/src/pulsar/PowerFlux/power_sum_stats.c index 9726df90b010599dd7d52afb9ed6b09d94a36d98..5948001aebdc8d515843f6979de4c3ceaa236888 100644 --- a/lalapps/src/pulsar/PowerFlux/power_sum_stats.c +++ b/lalapps/src/pulsar/PowerFlux/power_sum_stats.c @@ -1680,8 +1680,33 @@ init_fc_ul(); init_fc_ll(); verify_limits(); + /* Account for power loss due to Hann windowing */ -upper_limit_comp=1.0/0.85; +if(!strcasecmp("Hann", args_info.upper_limit_comp_arg)){ + if(!strcasecmp(args_info.averaging_mode_arg, "matched")) { + /* Matched filter correctly reconstructs power in the bin */ + upper_limit_comp=1.0; + } else + if(!strcasecmp(args_info.averaging_mode_arg, "3") || !strcasecmp(args_info.averaging_mode_arg, "three")){ + /* 3 bins should contain the entire signal, regardless + of positioning */ + upper_limit_comp=sqrt(3.0); + } else + if(!strcasecmp(args_info.averaging_mode_arg, "1") || !strcasecmp(args_info.averaging_mode_arg, "one")){ + /* 0.85 is a ratio between amplitude of + half-bin centered signal and bin centered signal + *amplitude* + + */ + upper_limit_comp=1.0/0.85; + } else + { + fprintf(stderr, "ERROR: do not know how to compensate upper limits for averaging mode \"%s\", try specifying upper_limit_comp option directly\n", args_info.averaging_mode_arg); + } + } else { + upper_limit_comp=atof(args_info.upper_limit_comp_arg); + } +fprintf(LOG, "upper limit compensation factor: %8f\n", upper_limit_comp); // // /* /* Extra factor to convert to amplitude from RMS power */ diff --git a/lalapps/src/pulsar/PowerFlux/power_sums.c b/lalapps/src/pulsar/PowerFlux/power_sums.c index d9faeaf64f012239ac900738ef0d86dc9055b3dc..e703f1ecbae1264f318eddfd7d4607a531592e8b 100644 --- a/lalapps/src/pulsar/PowerFlux/power_sums.c +++ b/lalapps/src/pulsar/PowerFlux/power_sums.c @@ -11,6 +11,7 @@ #include "dataset.h" #include "grid.h" #include "skymarks.h" +#include "summing_context.h" #include "cmdline.h" extern struct gengetopt_args_info args_info; @@ -115,7 +116,7 @@ for(i=0;i<count;i++) { free(ps); } -void accumulate_power_sums(POWER_SUM *ps, int count, double gps_start, double gps_stop, int veto_mask) +void accumulate_power_sums(SUMMING_CONTEXT *ctx, POWER_SUM *ps, int count, double gps_start, double gps_stop, int veto_mask) { int segment_count; SEGMENT_INFO *si, *si_local; @@ -137,6 +138,8 @@ float avg_spindown=args_info.spindown_start_arg+0.5*args_info.spindown_step_arg* float *patch_e=ps[0].patch_e; /* set of coefficients for this patch, used for amplitude response and bin shift estimation */ +//fprintf(stderr, "%p %p %d %lf %lf 0x%08x\n", ctx, ps, count, gps_start, gps_stop, veto_mask); + for(gps_idx=gps_start; gps_idx<gps_stop; gps_idx+=gps_step) { si=find_segments(gps_idx, gps_idx+gps_step, veto_mask, &segment_count); @@ -217,7 +220,7 @@ for(gps_idx=gps_start; gps_idx<gps_stop; gps_idx+=gps_step) { for(k=0;k<group_count;k++) { //fprintf(stderr, "group %d has %d segments\n", k, group_segment_count[k]); if(group_segment_count[k]<1)continue; - reset_simple_cache(group_segment_count[k], count); + ctx->reset_cache(ctx, group_segment_count[k], count); /* loop over templates */ ps_local=ps; @@ -236,7 +239,8 @@ for(gps_idx=gps_start; gps_idx<gps_stop; gps_idx+=gps_step) { si_local++; } - accumulate_single_bin_power_sum_cached1(groups[k], group_segment_count[k], ps_local->pps); + //accumulate_single_bin_power_sum_cached1(groups[k], group_segment_count[k], ps_local->pps); + ctx->accumulate_power_sum_cached(ctx, groups[k], group_segment_count[k], ps_local->pps); ps_local++; } } diff --git a/lalapps/src/pulsar/PowerFlux/power_sums.h b/lalapps/src/pulsar/PowerFlux/power_sums.h index 32059ed3cbadd6e9e0541cd7619bf480107687ce..7453385662c25109afd2d1b86b5325a580e6e744 100644 --- a/lalapps/src/pulsar/PowerFlux/power_sums.h +++ b/lalapps/src/pulsar/PowerFlux/power_sums.h @@ -2,6 +2,7 @@ #define __POWER_SUMS_H__ #include "power_cache.h" +#include "summing_context.h" typedef struct { float freq_shift; /* additional shift e.g. for half-bin sampling */ @@ -26,6 +27,6 @@ void generate_patch_templates(int pi, POWER_SUM **ps, int *count); void clone_templates(POWER_SUM *ps, int count, POWER_SUM **ps_out); void free_templates(POWER_SUM *ps, int count); -void accumulate_power_sums(POWER_SUM *ps, int count, double gps_start, double gps_stop, int veto_mask); +void accumulate_power_sums(SUMMING_CONTEXT *ctx, POWER_SUM *ps, int count, double gps_start, double gps_stop, int veto_mask); #endif diff --git a/lalapps/src/pulsar/PowerFlux/powerflux.ggo b/lalapps/src/pulsar/PowerFlux/powerflux.ggo index c7f885b03c58652de21556639bca391c84441f31..8146fb1c78f43da491b4da855a2e0c5248b5fb92 100644 --- a/lalapps/src/pulsar/PowerFlux/powerflux.ggo +++ b/lalapps/src/pulsar/PowerFlux/powerflux.ggo @@ -127,4 +127,5 @@ option "compute-skymaps" - "allocate memory and compute skymaps with final resul option "fine-grid-skymarks" - "use sky marks from the fine grid, this uses constant spindown" int default="0" no option "half-window" - "number of bins to exclude to the left and to the right of highest point when computing linear statistics" int default="20" no option "tail-veto" - "do not report outlier if its frequency is within that many bins from the tail - happens with steep spectrum" int default="10" no +option "cache-granularity" - "granularity of power cache frequency shift resolution, in fractions of a frequency bin" int default="-1" no diff --git a/lalapps/src/pulsar/PowerFlux/powerflux2.c b/lalapps/src/pulsar/PowerFlux/powerflux2.c index 1a842426346674912394afe739c5debc41cd3e64..7bb0d99359a175ba39cb208a429b51491d673399 100644 --- a/lalapps/src/pulsar/PowerFlux/powerflux2.c +++ b/lalapps/src/pulsar/PowerFlux/powerflux2.c @@ -99,6 +99,13 @@ SKY_GRID *patch_grid=NULL; char *output_dir; +/* Give up and add this so compilation works on Ubuntu */ +void __stack_chk_fail(void) +{ +fprintf(stderr, "stack-protector: Stack is corrupted\n"); +exit(-1); +} + void *do_alloc(long a, long b) { @@ -554,14 +561,14 @@ if(args_info.dataset_given) { for(i=0;i<d_free;i++) { fprintf(LOG, "FMedians: \"%s\" \"%s\"", args_info.label_arg, datasets[i].name); for(j=0;j<datasets[i].nbins;j++)fprintf(LOG, " %g", datasets[i].TMedians[j]); + fprintf(LOG, "\n"); } -fprintf(LOG, "\n"); for(i=0;i<d_free;i++) { fprintf(LOG, "new_weighted_mean: \"%s\" \"%s\"", args_info.label_arg, datasets[i].name); for(j=0;j<datasets[i].nbins;j++)fprintf(LOG, " %g", datasets[i].new_weighted_mean[j]); + fprintf(LOG, "\n"); } -fprintf(LOG, "\n"); if(args_info.sky_marks_file_given) { FILE *f; diff --git a/lalapps/src/pulsar/PowerFlux/scripts/Makefile b/lalapps/src/pulsar/PowerFlux/scripts/Makefile index aeaf860848340a54cc35a59d3d508abf08c67e51..0bea66aded31f74a115102eded17875197ceb00e 100644 --- a/lalapps/src/pulsar/PowerFlux/scripts/Makefile +++ b/lalapps/src/pulsar/PowerFlux/scripts/Makefile @@ -4,7 +4,7 @@ UPLOAD_FILES=make_run.tcl split.tcl get_param.tcl make_1800_sfts.tcl \ generate_injection_batch.tcl make_sft_injection_run.tcl split_dataset.tcl \ split_sfti.tcl make_second_sft_injection_run.tcl normalize_sft_name.tcl \ make_native_sft_injection_run.tcl reshape_sfti.tcl archive.tcl keyed_split.tcl \ - make_split_run.tcl find_outlier_matches.tcl + make_split_run.tcl find_outlier_matches.tcl make_outlier_histogram.tcl all: diff --git a/lalapps/src/pulsar/PowerFlux/scripts/convert_lines_info.tcl b/lalapps/src/pulsar/PowerFlux/scripts/convert_lines_info.tcl index 742c9a539b3d2951213c3854f6e00ebae808acfb..fb7701d7db41f1a85dcf98743ce738c3178370e7 100755 --- a/lalapps/src/pulsar/PowerFlux/scripts/convert_lines_info.tcl +++ b/lalapps/src/pulsar/PowerFlux/scripts/convert_lines_info.tcl @@ -1,6 +1,6 @@ #!/usr/bin/env tclsh -puts "instance\tfirst_bin\tdataset\tbin\tz\tstrength\tflag" +puts "instance\tfirst_bin\tband\tdataset\tbin\tz\tstrength\tflag" while { ! [eof stdin] } { gets stdin line if { $line == "" } { continue } diff --git a/lalapps/src/pulsar/PowerFlux/scripts/load_bandinfo.R b/lalapps/src/pulsar/PowerFlux/scripts/load_bandinfo.R index c691f31d799d51495ce08b265e22cffedda5efb5..3619fdf3c7611a425b19076010b0866b5534eb2e 100644 --- a/lalapps/src/pulsar/PowerFlux/scripts/load_bandinfo.R +++ b/lalapps/src/pulsar/PowerFlux/scripts/load_bandinfo.R @@ -1,15 +1,14 @@ require("lattice") require("RMySQL") +p<-function(...) { + return(paste(..., sep="")) + } source("params.R") con<-dbConnect(dbDriver("MySQL"), user="volodya", password="", dbname="volodya") -p<-function(...) { - return(paste(..., sep="")) - } - fn<-p(prefix, "band_info", suffix) fnout<-p(fn) @@ -23,7 +22,7 @@ ofn<-function(name) { return(file(paste(output_dir, "/", name, sep=""), open="wt")) } -col_names<-read.table(pipe("grep tag: 0/90000-50.000000/powerflux.log | head --lines=1"), header=FALSE, sep=" ") +col_names<-read.table(pipe("grep tag: 0/*/powerflux.log | head --lines=1"), header=FALSE, sep=" ") cat("Loading data from ", fn, "\n", sep="") # Cheat - get a small sample first and use it to find out types and such. @@ -35,8 +34,8 @@ Types<-lapply(header, class) Types<-lapply(Types, function(x)gsub("logical", "numeric", x)) -CreateQuery<-p("CREATE TABLE ", TableName, "(Line INTEGER AUTO_INCREMENT") -LoadQuery<-p("LOAD DATA LOCAL INFILE '", fnout, "' INTO TABLE ", TableName, " FIELDS TERMINATED BY ' ' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n' (") +CreateQuery<-p("CREATE TABLE ", BandInfoTableName, "(Line INTEGER AUTO_INCREMENT") +LoadQuery<-p("LOAD DATA LOCAL INFILE '", fnout, "' INTO TABLE ", BandInfoTableName, " FIELDS TERMINATED BY ' ' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n' (") # " @@ -60,18 +59,18 @@ LoadQuery<-p(LoadQuery, ")") cat("Connecting to the database\n") con<-dbConnect(dbDriver("MySQL"), user="volodya", password="", dbname="volodya") -cat("Dropping table", TableName, "\n") -try(dbGetQuery(con, p("DROP TABLE ", TableName)), silent=TRUE) +cat("Dropping table", BandInfoTableName, "\n") +try(dbGetQuery(con, p("DROP TABLE ", BandInfoTableName)), silent=TRUE) -cat("Declaring table", TableName, "\n") +cat("Declaring table", BandInfoTableName, "\n") dbGetQuery(con, CreateQuery) -cat("Loading table", TableName, "\n") +cat("Loading table", BandInfoTableName, "\n") dbGetQuery(con, LoadQuery) -cat("Adding index to table", TableName, "\n") -dbGetQuery(con, p("ALTER TABLE `", TableName, "` ADD INDEX (first_bin)")) +cat("Adding index to table", BandInfoTableName, "\n") +dbGetQuery(con, p("ALTER TABLE `", BandInfoTableName, "` ADD INDEX (first_bin)")) cat("Warnings:\n") diff --git a/lalapps/src/pulsar/PowerFlux/scripts/normalize_sft_name.tcl b/lalapps/src/pulsar/PowerFlux/scripts/normalize_sft_name.tcl index 66514efcc53e0fff65d644e210198129d796a270..2834d353394944c72c89446fdf7fc69632610bbb 100755 --- a/lalapps/src/pulsar/PowerFlux/scripts/normalize_sft_name.tcl +++ b/lalapps/src/pulsar/PowerFlux/scripts/normalize_sft_name.tcl @@ -11,6 +11,11 @@ foreach {var value} { set $var $value } +foreach {var value} $argv { + global $var + set $var $value + } + proc get_header { name } { set FILE [open $name "r"] fconfigure $FILE -encoding binary -translation binary diff --git a/lalapps/src/pulsar/PowerFlux/simcoh/simcoh.c b/lalapps/src/pulsar/PowerFlux/simcoh/simcoh.c index 9d29d76dd92b2734cb24ee2e1a4cea11fbc890af..52569266727b7ed04aabcabf548dcab95b04e82c 100644 --- a/lalapps/src/pulsar/PowerFlux/simcoh/simcoh.c +++ b/lalapps/src/pulsar/PowerFlux/simcoh/simcoh.c @@ -126,7 +126,6 @@ int main(int argc, const char *argv[]) { LALDetector DetectorH,DetectorL; SkyPosition SourcePos; LALGPSandAcc gpsandacc; - gpsandacc.accuracy=LALLEAPSEC_STRICT; LALDetAndSource DetandSrc; LALSource sourceF; sourceF.orientation=1.0; @@ -146,7 +145,6 @@ int main(int argc, const char *argv[]) { (*edat).ephiles.earthEphemeris = earthdata; (*edat).ephiles.sunEphemeris = sundata; - (*edat).leap=13; LALInitBarycenter(&status, edat); double frequencies[3]={freq-fbin,freq,freq+fbin}, diff --git a/lalapps/src/pulsar/SideBand/GenerateSideBandTemplate.c b/lalapps/src/pulsar/SideBand/GenerateSideBandTemplate.c index ce8d72f86adda584922c07c3e77a7e5c6243efbd..0a7abaf431615663fdfebcfab549c9279d314ddf 100644 --- a/lalapps/src/pulsar/SideBand/GenerateSideBandTemplate.c +++ b/lalapps/src/pulsar/SideBand/GenerateSideBandTemplate.c @@ -126,8 +126,6 @@ int main(int argc,char *argv[]) BarycenterInput baryinput; /* Stores detector location and other barycentering data */ LALDetector Detector; /* Our detector*/ EarthState earth; - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; ABCcoParams abcparams; ABCcoefficients *ABCco = NULL; REAL8 df; @@ -183,10 +181,6 @@ int main(int argc,char *argv[]) if (lalDebugLevel) printf ("Finished initialising ephemeris.\n"); - /* sort out the leap seconds */ - LALLeapSecs(&status,&leap,&uvar_tstart,&formatAndAcc); - (*edat).leap=leap; - /* select the detector */ if(!strcmp(uvar_ifo,"G1")) { Detector=lalCachedDetectors[LALDetectorIndexGEO600DIFF]; diff --git a/lalapps/src/pulsar/SideBand/SideBandMCMC.c b/lalapps/src/pulsar/SideBand/SideBandMCMC.c index b7b58beccf47e8ebcfacf8bf940f4f2b794e746e..1cdeff904cbe5e326d8928be982003c05a4f2c96 100644 --- a/lalapps/src/pulsar/SideBand/SideBandMCMC.c +++ b/lalapps/src/pulsar/SideBand/SideBandMCMC.c @@ -116,8 +116,6 @@ int main(int argc,char *argv[]) BarycenterInput baryinput; /* Stores detector location and other barycentering data */ LALDetector Detector; /* Our detector */ EarthState earth; - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; ABCcoParams abcparams; ABCcoefficients *ABCco = NULL; SideBandMCMCVector **MCMCchain = NULL; /* a vector of MCMC parameter vectors where the Markov chain is stored */ @@ -273,10 +271,6 @@ int main(int argc,char *argv[]) /* here we set up the detector */ /************************************************************************/ - /* sort out the leap seconds */ - LALLeapSecs(&status,&leap,&(TParams->tstart),&formatAndAcc); - (*edat).leap=leap; - /* select the detector */ if(!strcmp(uvar_ifo,"G1")) { Detector=lalCachedDetectors[LALDetectorIndexGEO600DIFF]; diff --git a/lalapps/src/pulsar/SideBand/SideBandUtils.c b/lalapps/src/pulsar/SideBand/SideBandUtils.c index 4740c590038d23a18925838be445cd54a9eac0c5..147640cf144f642aec3a5e632ee9c6eeb775cf2e 100644 --- a/lalapps/src/pulsar/SideBand/SideBandUtils.c +++ b/lalapps/src/pulsar/SideBand/SideBandUtils.c @@ -405,8 +405,6 @@ void InitEphemeris (LALStatus * status, CHAR EphemEarth[FNAME_LENGTH]; /* filename of earth-ephemeris data */ CHAR EphemSun[FNAME_LENGTH]; /* filename of sun-ephemeris data */ - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; INITSTATUS( status, "InitEphemeris", rcsid ); ATTATCHSTATUSPTR (status); @@ -432,9 +430,6 @@ void InitEphemeris (LALStatus * status, */ edat->ephiles.earthEphemeris = EphemEarth; edat->ephiles.sunEphemeris = EphemSun; - - TRY (LALLeapSecs (status->statusPtr, &leap, &epoch, &formatAndAcc), status); - edat->leap = (INT2) leap; TRY ( LALInitBarycenter(status->statusPtr, edat), status); diff --git a/lalapps/src/pulsar/StackSlide/DriveStackSlide.c b/lalapps/src/pulsar/StackSlide/DriveStackSlide.c index ae3543b2881dfebed558362bdebbc5a7cca9fe33..c614cea6373d7b55599a4eb565eca91f2a11b67f 100644 --- a/lalapps/src/pulsar/StackSlide/DriveStackSlide.c +++ b/lalapps/src/pulsar/StackSlide/DriveStackSlide.c @@ -1357,8 +1357,7 @@ params->numFDeriv5 = 0; CHAR *xmlFile; MetadataTable proctable; MetadataTable procparams; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; - + params->xmlStream = (LIGOLwXMLStream *) LALMalloc(sizeof(LIGOLwXMLStream)); xmlFile = (CHAR *) LALMalloc( (strlen(params->outputFile) + 5) * sizeof(CHAR) ); strcpy(xmlFile,params->outputFile); @@ -1381,8 +1380,8 @@ params->numFDeriv5 = 0; proctable.processTable->is_online = 0; snprintf( proctable.processTable->node, LIGOMETA_NODE_MAX, "%s", BLANK ); snprintf( proctable.processTable->username, LIGOMETA_USERNAME_MAX, "%s", BLANK ); - LALGPSTimeNow ( status->statusPtr, &(proctable.processTable->start_time), &accuracy ); - LALGPSTimeNow ( status->statusPtr, &(proctable.processTable->end_time), &accuracy ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); + XLALGPSTimeNow(&(proctable.processTable->end_time)); proctable.processTable->jobid = 0; snprintf( proctable.processTable->domain, LIGOMETA_DOMAIN_MAX, "%s", BLANK ); proctable.processTable->unix_procid = 0; @@ -1458,8 +1457,6 @@ void StackSlideConditionData( /* UINT4 i = 0; */ /* all purpose index */ /* UINT4 k = 0; */ /* another all purpose index */ INT4 k = 0; /* another all purpose index */ - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; /* 03/01/04 gam; Call LALLeapSecs to get edat->leap */ - INT4 leap; /* 03/01/04 gam; 2nd arg to LALLeapSecFormatAndAcc is INT4 while edat->leap is INT2. */ /*********************************************************/ /* */ @@ -1724,17 +1721,7 @@ void StackSlideConditionData( params->edat->ephiles.sunEphemeris = params->sunEdatFile ; params->edat->ephiles.earthEphemeris = params->earthEdatFile; - - /* 02/24/04 gam; Set edat->leap = 13; Was NOT getting initialized. Note 13 is OK for 2000; Check for current date! */ - /* params->edat->leap = 13; */ - LALLeapSecs(status->statusPtr,&leap,&(params->timeStamps[0]),&formatAndAcc); /* 03/01/04 gam; Call LALLeapSecs to get edat->leap */ - INTERNAL_SHOWERRORFROMSUB (status); CHECKSTATUSPTR (status); - params->edat->leap = (INT2)leap; - #ifdef DEBUG_EPHEMERISDATA - fprintf(stdout, "\nparams->edat->leap = %i \n",params->edat->leap); - fflush(stdout); - #endif - + #ifdef INCLUDE_INTERNALLALINITBARYCENTER /* Use internal copy of LALInitBarycenter.c from the LAL support package. Author: Curt Cutler */ InternalLALInitBarycenter(status->statusPtr, params->edat); @@ -3756,8 +3743,7 @@ void GetDetResponseTStampMidPts(LALStatus *stat, REAL4Vector *detResponseTStampM das->pSource->orientation = orientationAngle; das->pSource->equatorialCoords.system = coordSystem; - timeAndAcc.accuracy=LALLEAPSEC_STRICT; - + /* loop that calls LALComputeDetAMResponse to find F_+ and F_x at the midpoint of each SFT for ZERO Psi */ for(i=0; i<numSTKs; i++) { /* Find mid point from timestamp, half way through SFT. */ diff --git a/lalapps/src/pulsar/StackSlide/StackSlideBinaryTest.c b/lalapps/src/pulsar/StackSlide/StackSlideBinaryTest.c index 1f6152a474e6448718592a7811f8bfda5a77878f..6348916adbd654f69bd2c585697a006a9908c547 100644 --- a/lalapps/src/pulsar/StackSlide/StackSlideBinaryTest.c +++ b/lalapps/src/pulsar/StackSlide/StackSlideBinaryTest.c @@ -561,8 +561,6 @@ ASSERT(params->SemiMajorAxis>=0, status, COMPUTESKYBINARYH_ENEGA, COMPUTESKYBINA /* Here we redefine the orbital variables for ease of use */ -/*printf("leap %d\n",(*edat).leap);*/ - a=params->SemiMajorAxis; /* This is the projected semi-major axis of the orbit normalised by the speed of light */ Period=params->OrbitalPeriod; /* This is the period of the orbit in seconds */ ecc=params->OrbitalEccentricity; /* This is the eccentricity of the orbit */ @@ -628,9 +626,6 @@ ASSERT(tGPS[n].gpsSeconds>=0, status, COMPUTESKYBINARYH_ENEGA, COMPUTESKYBINARYH /*fprintf(stdout,"half tgps in detector time %d\n",baryinput.tgps.gpsSeconds);*/ -/* fprintf(stdout,"leap %d\n",(*edat).leap);*/ - - /* Convert this mid point detector time into barycentric time (SSB) */ @@ -848,15 +843,8 @@ FILE *fpS; fscanf(fpS,"%d \t %le \t %d\n",&x, &y, &z); /*fprintf(stdout,"x y z are %d \t %12.12le \t %d\n", x,y,z);*/ - - /*set leap seconds for 00-04*/ - (*edat).leap = 13; - -#ifdef DEBUG_STACKSLIDE_FNC - printf("leap is %d\n",(*edat).leap); -#endif - /*Read in ephemeris files*/ + /*Read in ephemeris files*/ LALInitBarycenter(&status, edat); #ifdef DEBUG_STACKSLIDE_FNC diff --git a/lalapps/src/pulsar/TDS_isolated/CrabTNHeterodyne.c b/lalapps/src/pulsar/TDS_isolated/CrabTNHeterodyne.c index ea278bb0e0d86da3cf70828e7a03f25cd01619d9..3aea829135b7a48f1503db938a5be05e011e8cf6 100644 --- a/lalapps/src/pulsar/TDS_isolated/CrabTNHeterodyne.c +++ b/lalapps/src/pulsar/TDS_isolated/CrabTNHeterodyne.c @@ -191,13 +191,6 @@ TNInput.f1, TNInput.f2, TNInput.t0); /* set values for timing noise removal */ LALSetSpindownParams( &status, &hetParams, &crabOutput, dataEpoch ); - - if(time->data[j] <= 820108813) - (*edat).leap = 13; - else if(time->data[j] <= 914803214) - (*edat).leap = 14; - else - (*edat).leap = 15; baryinput.tgps.gpsSeconds = TNInput.epoch.gpsSeconds; baryinput.tgps.gpsNanoSeconds = TNInput.epoch.gpsNanoSeconds; diff --git a/lalapps/src/pulsar/TDS_isolated/TargetedBinaryPulsars.c b/lalapps/src/pulsar/TDS_isolated/TargetedBinaryPulsars.c index 5eef95bb9b2bf9bca4d6d0d0cec162d267db67bc..0fd45ad3863e9be0cce8e20efa918774db6c2f61 100644 --- a/lalapps/src/pulsar/TDS_isolated/TargetedBinaryPulsars.c +++ b/lalapps/src/pulsar/TDS_isolated/TargetedBinaryPulsars.c @@ -623,7 +623,6 @@ main( int argc, char *argv[]) /* set up LALBarycenter */ edat = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); - (*edat).leap = 13; sprintf(earthfile,"%s/earth03-06.dat",argv[2]); sprintf(sunfile,"%s/sun03-06.dat",argv[2]); (*edat).ephiles.earthEphemeris = earthfile; @@ -817,8 +816,6 @@ pname[i_pulsar],argv[4],starts[1]); /* set binary params */ params.binaryInput.tbflag = "GPS"; - params.binaryInput.leapSecs = 13; - params.binaryParams.T0 = T0[i_pulsar]; params.binaryParams.Tasc = Tasc[i_pulsar]; params.binaryParams.Pb = Pb[i_pulsar]; diff --git a/lalapps/src/pulsar/TDS_isolated/binary_test/BinaryPulsarTOATest.c b/lalapps/src/pulsar/TDS_isolated/binary_test/BinaryPulsarTOATest.c index 875779803fba1c3a11dab972d453b5f7489caafc..3873729124c031cced90eb9f6c4803cf6e17c046 100644 --- a/lalapps/src/pulsar/TDS_isolated/binary_test/BinaryPulsarTOATest.c +++ b/lalapps/src/pulsar/TDS_isolated/binary_test/BinaryPulsarTOATest.c @@ -114,7 +114,6 @@ x,y,z components are got from tempo */ /* initialise the solar system ephemerides */ edat = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); - (*edat).leap = 13; sprintf(earthFile, "/home/matthew/lscsoft/lal/packages/pulsar/test/earth00-04.dat"); sprintf(sunFile, @@ -124,8 +123,6 @@ x,y,z components are got from tempo */ LALInitBarycenter(&status, edat); /* convert TOAs from MJD into GPS */ - /* input.leapSecs = 13; /* number of leap seconds since the start of GPS time - -MJD 44244 */ fpout1 = fopen("deltaT.txt", "w"); diff --git a/lalapps/src/pulsar/TDS_isolated/crab_ephemeris.txt b/lalapps/src/pulsar/TDS_isolated/crab_ephemeris.txt index 731ee4b58eb5e3775735a98b25cd2cbed578c1c4..a3360f3fe10ea66897fbd36c8c9e43c83975448a 100644 --- a/lalapps/src/pulsar/TDS_isolated/crab_ephemeris.txt +++ b/lalapps/src/pulsar/TDS_isolated/crab_ephemeris.txt @@ -326,3 +326,11 @@ 54693.0 0.002627 29.7445817491 -371941.95 54724.0 0.013181 29.7435856030 -371896.87 54754.0 0.025508 29.7426216895 -371865.47 +54785 0.021232 29.7416257244 -371845.65 +54815 0.027366 29.7406619697 -371794.02 +54846 0.012614 29.7396661660 -371784.76 +54877 0.000804 29.7386704404 -371735.72 +54905 0.008639 29.7377711775 -371708.68 +54936 0.005942 29.7367756373 -371687.97 +54966 0.009801 29.7358122506 -371655.19 +54997 0.027323 29.7348168586 -371619.68 diff --git a/lalapps/src/pulsar/TDS_isolated/heterodyne_pulsar.c b/lalapps/src/pulsar/TDS_isolated/heterodyne_pulsar.c index 358447307e561351381955e09451cfa429428124..f1cfb75238b990f228eaf74f3b6b9a59b0b03263 100644 --- a/lalapps/src/pulsar/TDS_isolated/heterodyne_pulsar.c +++ b/lalapps/src/pulsar/TDS_isolated/heterodyne_pulsar.c @@ -966,17 +966,6 @@ void heterodyne_data(COMPLEX16TimeSeries *data, REAL8Vector *times, else t = times->data[i]; - /* set leap seconds noting that for all runs prior to S5 that the number - of leap seconds was 13, 1 leap seconds was added on 31st - Dec 2005 24:00:00 i.e. GPS 820108813, and another was added on 31st - Dec 2008 24:00:00 i.e. GPS 91480321 */ - if(t <= 820108813) - (*edat).leap = 13; - else if(t <= 914803214) - (*edat).leap = 14; - else - (*edat).leap = 15; - baryinput.tgps.gpsSeconds = (UINT8)floor(t); baryinput.tgps.gpsNanoSeconds = (UINT8)floor((fmod(t,1.0)*1.e9)); @@ -1030,14 +1019,6 @@ void heterodyne_data(COMPLEX16TimeSeries *data, REAL8Vector *times, t2 = times->data[i] + 1.; /* just add a second to get the gradient */ - /* set leap seconds */ - if(t <= 820108813) - (*edat).leap = 13; - else if(t <= 914803214) - (*edat).leap = 14; - else - (*edat).leap = 15; - baryinput2 = baryinput; baryinput.tgps.gpsSeconds = (UINT8)floor(t); diff --git a/lalapps/src/pulsar/TDS_isolated/lalapps_heterodyne_pulsar_pipe b/lalapps/src/pulsar/TDS_isolated/lalapps_heterodyne_pulsar_pipe index fa0cfdf7b4791410765ae25f8182405a20cdb1f5..47d6f79b7f6ace6bf000ae1d233966f984d49a1f 100755 --- a/lalapps/src/pulsar/TDS_isolated/lalapps_heterodyne_pulsar_pipe +++ b/lalapps/src/pulsar/TDS_isolated/lalapps_heterodyne_pulsar_pipe @@ -30,8 +30,6 @@ import exceptions from types import * try: - from glue import segments -# from glue import LSCsegFindClient from glue import gsiserverutils from glue.lal import LIGOTimeGPS except ImportError, e: @@ -55,11 +53,15 @@ Usage: lalapps_heterodyne_pulsar_pipe [options] -h, --help display this message -v, --version print version information and exit - -d, --datafind run LSCdataFind to create frame cache files + -d, --datafind run ligo_data_find to create frame cache files (required for coarse heterodyne) + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -s, --seglist run LSCsegFind to create a segment list (otherwise attempt to read the segment filename from the - configuation file) + configuation file) + THIS OPTION IS NO LONGER USABLE - CREATE YOUR OWN SEGMENT LIST (E.G. USING + ligolw_segment_query) INSTEAD AND ADD TO THE CONFIGURATION FILE + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -c, --coarse run lalapps_heterodyne_pulsar in coarse mode -f, --fine run lalapps_heterodyne_pulsar in fine mode -u, --update run lalapps_heterodyne_pulsar in update mode @@ -101,7 +103,6 @@ except getopt.GetoptError: # default options config_file = None do_datafind = None -do_seglist = None do_fine = None do_coarse = None do_update = None @@ -123,7 +124,8 @@ for o, a in opts: elif o in ("-d", "--datafind"): do_datafind = 1 elif o in ("-s", "--seglist"): - do_seglist = 1 + print "The -s (--segment) flag is no longer valid (see --help)" + sys.exit(0) elif o in ("-c", "--coarse"): do_coarse = 1 elif o in ("-f", "--fine"): @@ -159,8 +161,10 @@ if not log_path: sys.exit(1) # try and make a directory to store the cache files and job logs -try: os.mkdir('cache') -except: pass +if do_datafind: + try: os.mkdir('cache') + except: pass + try: os.mkdir('logs') except: pass @@ -250,9 +254,6 @@ except: pass if do_datafind: df = heterodyne_pulsar.LSCDataFindNode(df_job) - #server = cp.get('datafind','server') - #df.set_server(server) - # set observatory for LSCdataFind if (detector.find('H1') > -1) | (detector.find('H2') > -1): obs = 'H' @@ -274,104 +275,14 @@ H2, L1, V1, G1 or GEO.""" # add DAG dag.add_node(df) -# this bit is basically hacked from LSCsegFind -if do_seglist: - print >> sys.stderr, "I'm going to make a seglist" - # run LSCsegFind - don't bother with a job just run it and create this list - # set segment list and stuff - seg_list_file = basename + '.seglist' - - # defaults - hostPortString = None - port = 30015 - - clientMethodArgDict = { - 'interferometer': None, - 'type': None, - 'explain': None, - 'end': None, - 'start': None, - 'lfns': False, - 'strict' : True - } - - # default method - clientMethod = 'findStateSegments' - typeString = None - format = None - - hostPortString = cp.get('datafind','server') - - # environment variables override defaults but not - # command line options - try: - hostPortString = os.environ['LSC_SEGFIND_SERVER'] - except: - pass - - clientMethodArgDict['interferometer'] = detector - clientMethodArgDict['type'] = 'Science' - clientMethodArgDict['start'] = tstart - clientMethodArgDict['end'] = tend - - if hostPortString.find(':') < 0: - # no port specified - host = hostPortString - else: - # server and port specified - host, portString = hostPortString.split(':') - port = int(portString) - - # open connection to LSCsegFindServer - try: - myClient = LSCsegFindClient.LSCsegFind(host, port) - - except Exception, e: - print >> sys.stderr, \ - "Unable to connect to LSCsegFindServer %s:%d" % (host, port) - if gsiserverutils.checkCredentials(): - print >>sys.stderr, "Got the following error : " + str(e) - sys.exit(1) - - # get the segment list here - try: - seglist = eval("myClient.%s(%s)" % (clientMethod, clientMethodArgDict)) - - try: - f = open(seg_list_file, 'w') - - except Exception, e: - print >> sys.stderr, "Can't open file %s!" % (seg_list_file) - sys.exit(1) - - if type(seglist) is StringType: - print seglist - else: - if len( seglist ) == 0: - print >> sys.stderr, "No segments found!" - else: # output format will be segwizard style - i = 1 - for seg in seglist: - wizlist = str(i) + ' ' + str(seg[0]) + ' ' + str(seg[1]) + ' ' + str(seg.duration()) +\ -'\n' - f.write(wizlist) - i += 1 - - f.close() - - except Exception, e: - print >> sys.stderr, "Could not create segment list :(" - sys.exit(1) +# set seglist file from value in the config file +seg_list_file = cp.get('data','seg_list') -elif do_seglist == None: - # set seglist file from value in the config file - seg_list_file = cp.get('data','seg_list') - - # see if it exits - if it doesn't give an error - if os.path.isfile(seg_list_file)==False: - print >> sys.stderr, """No segment list file given in config file - add seg_list argument to +# see if it exits - if it doesn't give an error +if os.path.isfile(seg_list_file)==False: + print >> sys.stderr, """No segment list file given in config file - add seg_list argument to [data] section of .ini file""" - sys.exit(1) + sys.exit(1) if do_coarse: param_files = os.listdir(pulsar_param_dir) diff --git a/lalapps/src/pulsar/TDS_isolated/pulsar_parameter_estimation.c b/lalapps/src/pulsar/TDS_isolated/pulsar_parameter_estimation.c index bf7616e6382ae43916c77a5c011abd7f27cc12ff..66e0055d2fe2984941a43ad33780f8bc247428e1 100644 --- a/lalapps/src/pulsar/TDS_isolated/pulsar_parameter_estimation.c +++ b/lalapps/src/pulsar/TDS_isolated/pulsar_parameter_estimation.c @@ -2564,13 +2564,6 @@ REAL8Vector *get_phi( DataStructure data, BinaryPulsarParams params, DT = data.times->data[i] - T0; - if(data.times->data[i] <= 820108813) - (*edat).leap = 13; - else if(data.times->data[i] <= 914803214) - (*edat).leap = 14; - else - (*edat).leap = 15; - /* only do call the barycentring routines every 30 minutes, otherwise just linearly interpolate between them */ if( i==0 || DT > DTplus ){ diff --git a/lalapps/src/pulsar/TDS_isolated/pulsar_parameter_mismatch.c b/lalapps/src/pulsar/TDS_isolated/pulsar_parameter_mismatch.c index a7af64a9b51dc29734e9a0be15b0cfefca5a15b7..5a22fa77f2e5d9a1e6697f7e392c8eb7156df45a 100644 --- a/lalapps/src/pulsar/TDS_isolated/pulsar_parameter_mismatch.c +++ b/lalapps/src/pulsar/TDS_isolated/pulsar_parameter_mismatch.c @@ -478,13 +478,6 @@ REAL8Vector *get_phi( double start, double deltaT, int npoints, DT = time - T0; - if(time <= 820108813) - (*edat).leap = 13; - else if(time <= 914803214) - (*edat).leap = 14; - else - (*edat).leap = 15; - /* only call the barycentring routines every 30 minutes, otherwise just linearly interpolate between them */ if( i==0 || DT > DTplus ){ diff --git a/lalapps/src/pulsar/TimingTests/TEMPOcomparison.c b/lalapps/src/pulsar/TimingTests/TEMPOcomparison.c index 2479fe02faff337d6694954e102ade86712cb213..7d7ad058b68179cbfc0a4136e97474c2986c3a5e 100644 --- a/lalapps/src/pulsar/TimingTests/TEMPOcomparison.c +++ b/lalapps/src/pulsar/TimingTests/TEMPOcomparison.c @@ -259,7 +259,6 @@ main(int argc, char *argv[]){ REAL8 alpha, delta; EphemerisData *edat = NULL; CHAR EphemEarth[1024], EphemSun[1024]; - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_LOOSE}; INT4 leap0,leap; LIGOTimeGPS epoch; LIGOTimeGPS TstartSSB, TendSSB, TendGPS; @@ -275,7 +274,7 @@ main(int argc, char *argv[]){ MJDTime *TOA = NULL; CHAR tempstr[15]; CHAR *tempstr2; - CHAR TrefMJDstr[20],TstartMJDstr[20],TfinishMJDstr[20],TOAstr[20]; + CHAR TstartMJDstr[20],TfinishMJDstr[20],TOAstr[20]; PulsarSignalParams pulsarparams; CHAR parfile[256]; CHAR timfile[256]; @@ -376,10 +375,10 @@ main(int argc, char *argv[]){ snprintf(EphemSun, 1024, "%s/sun%s.dat", uvar.ephemdir, uvar.ephemyear); edat->ephiles.earthEphemeris = EphemEarth; edat->ephiles.sunEphemeris = EphemSun; - LALLeapSecs (&status, &leap0, &epoch, &formatAndAcc); - edat->leap = (INT2) leap0; + leap0 = XLALGPSLeapSeconds (epoch.gpsSeconds); + if (lalDebugLevel) fprintf(stdout,"STATUS : leap seconds = %d\n",leap0); - + /* initialise the barycenter routines */ LALInitBarycenter(&status, edat); if (lalDebugLevel) fprintf(stdout,"STATUS : Initiated Barycenter\n"); @@ -646,10 +645,10 @@ main(int argc, char *argv[]){ return(TEMPOCOMPARISONC_ESUB); } if (lalDebugLevel) fprintf(stdout,"STATUS : SSB -> detector conversion gives discrepancies of %e sec\n",diff); - + /* recompute leap seconds incase they've changed */ - LALLeapSecs (&status, &leap, &TDET, &formatAndAcc); - + leap = XLALGPSLeapSeconds (TDET.gpsSeconds); + /* must now convert to an MJD time for TEMPO */ /* Using UTC conversion as used by Matt in his successful comparison */ UTCGPStoMJD (&status,&tempTOA,&TDET,leap); @@ -813,7 +812,7 @@ initUserVars (LALStatus *status, int argc, char *argv[], UserVariables_t *uvar) LALregREALUserStruct ( status, DurationMJD, 'D', UVAR_OPTIONAL, "Full duration of TOAs (in days) [Default = 1800 ~ 5 years]"); LALregSTRINGUserStruct ( status, PSRJ, 'n', UVAR_OPTIONAL, "Name of pulsar [Default = TEST]"); LALregSTRINGUserStruct ( status, Observatory, 'O', UVAR_OPTIONAL, "TEMPO observatory name (GBT,ARECIBO,NARRABRI,NANSHAN,DSS_43,PARKES,JODRELL,VLA,NANCAY,COE,SSB) [Default = JODRELL]"); - LALregBOOLUserStruct ( status, randparams, 'r', UVAR_OPTIONAL, "Override sky position with random values [Default = FALSE]"); + LALregBOOLUserStruct ( status, randparams, 0, UVAR_OPTIONAL, "Override sky position with random values [Default = FALSE]"); LALregINTUserStruct ( status, seed, 'o', UVAR_OPTIONAL, "The random seed (integer) [Default = 0 = clock]"); /* read all command line variables */ diff --git a/lalapps/src/pulsar/crosscorr/pulsar_crosscorr.c b/lalapps/src/pulsar/crosscorr/pulsar_crosscorr.c index ef49ca724d2d19e802515869cbcdf945c0679e68..dde2a43f434f160ee160497289002e4738f09fe7 100644 --- a/lalapps/src/pulsar/crosscorr/pulsar_crosscorr.c +++ b/lalapps/src/pulsar/crosscorr/pulsar_crosscorr.c @@ -133,6 +133,12 @@ int main(int argc, char *argv[]){ REAL8FrequencySeries *psd1, *psd2; COMPLEX16Vector *yalpha = NULL, *ualpha = NULL; + /*estimator arrays */ + COMPLEX16Vector *gplus = NULL, *gcross = NULL; + static REAL8Vector *aplussq1, *aplussq2, *acrossq1, *acrossq2; + REAL8Vector *galphasq; + INT4 i; + CrossCorrAmps amplitudes; CrossCorrBeamFn *beamfns1, *beamfns2; CrossCorrBeamFnListElement *beamList, *beamHead = NULL, *beamTail = NULL; @@ -181,15 +187,16 @@ int main(int argc, char *argv[]){ static INT4VectorSequence *sftPairIndexList=NULL; REAL8Vector *sigmasq; PulsarDopplerParams thisPoint; - static REAL8Vector *rho, *stddev; + static REAL8Vector *rho, *variance; REAL8 tmpstat, freq1, phase1, freq2, phase2; - + REAL8 tmpstat2, tmpstat3, tmpstat4; REAL8 doppWings, fMin, fMax; /* output file */ FILE *fp = NULL; + FILE *estimator = NULL; CHAR filename[MAXFILENAMELENGTH]; /* sft constraint variables */ @@ -299,6 +306,18 @@ int main(int argc, char *argv[]){ exit(1); } + /* if debugging, and averaging over both psi & iota, OR using exact psi & iota + * values, print out estimator info */ + if (lalDebugLevel && ((!uvar_averagePsi && !uvar_averageIota) || + (uvar_averagePsi && uvar_averageIota))) { + strcpy (filename, uvar_dirnameOut); + strcat (filename, "estimator.dat"); + if ((estimator = fopen(filename, "w")) == NULL) { + fprintf(stderr, "error opening estimator output file\n"); + exit(1); + } + + } if (uvar_QCoeffs) { fprintf(fp, "##Alpha\tDelta\tFrequency\tQ1\tQ2\tBraking Index\tNormalised Power\n"); } @@ -428,8 +447,8 @@ int main(int argc, char *argv[]){ (*edat).ephiles.earthEphemeris = EphemEarth; (*edat).ephiles.sunEphemeris = EphemSun; - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; + /* LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); */ + /* (*edat).leap = (INT2)tmpLeap;*/ LAL_CALL( LALInitBarycenter( &status, edat), &status); @@ -480,11 +499,34 @@ int main(int argc, char *argv[]){ } rho = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); - stddev = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); rho->length = nParams; - stddev->length = nParams; rho->data = (REAL8 *)LALCalloc(nParams, sizeof(REAL8)); - stddev->data = (REAL8 *)LALCalloc(nParams, sizeof(REAL8)); + + variance = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); + variance->length = nParams; + variance->data = (REAL8 *)LALCalloc(nParams, sizeof(REAL8)); + + /*initialise debugging vectors */ + aplussq1 = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); + aplussq1->length = nParams; + aplussq1->data = (REAL8 *)LALCalloc(nParams, sizeof(REAL8)); + + aplussq2 = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); + aplussq2->length = nParams; + aplussq2->data = (REAL8 *)LALCalloc(nParams, sizeof(REAL8)); + + acrossq1 = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); + acrossq1->length = nParams; + acrossq1->data = (REAL8 *)LALCalloc(nParams, sizeof(REAL8)); + + acrossq2 = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); + acrossq2->length = nParams; + acrossq2->data = (REAL8 *)LALCalloc(nParams, sizeof(REAL8)); + + galphasq = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); + galphasq->length = nParams; + galphasq->data = (REAL8 *)LALCalloc(nParams, sizeof(REAL8)); + /*initialise detector choice*/ detChoice = uvar_detChoice; @@ -584,8 +626,20 @@ int main(int argc, char *argv[]){ yalpha = NULL; ualpha = NULL; sigmasq = NULL; + gplus = NULL; + gcross = NULL; + /* reset all search parameters */ + paramCounter = 0; counter = 0; + nCounter = 0; + q1Counter = 0; + q2Counter = 0; + freqCounter = 0; + fdotCounter = 0; + fddotCounter = 0; + skyCounter = 0; + /* throw away first sft from inputSFTs, and first psdvector, frequency, phase vectors, beamfns */ if (sftcounter > 0) { @@ -632,7 +686,6 @@ int main(int argc, char *argv[]){ } listLength = slidingcounter - sftcounter; - if (listLength > 1) { while (paramCounter < nParams) { @@ -700,10 +753,10 @@ int main(int argc, char *argv[]){ LAL_CALL( GetBeamInfo( &status, beamHead, sftHead, freqHead, phaseHead, skypos, edat, &thisPoint), &status); - /* loop over SFT mini-list to get pairs */ + /* loop over SFT mini-list to get pairs */ ualphacounter = 0; - /* correlate sft pairs */ + /* correlate sft pairs */ sftList = sftHead; psdList = psdHead; freqList = freqHead; @@ -721,6 +774,7 @@ int main(int argc, char *argv[]){ there is no need to check the lag as the sfts must satisfy this condition already to be in the mini-list*/ while (sftList->nextSFT) { + /*if we are autocorrelating, we want the head to be paired with itself first*/ if ((sftList == sftHead) && uvar_autoCorrelate) { sft2 = &(sftList->sft); @@ -729,100 +783,137 @@ int main(int argc, char *argv[]){ phase2 = phaseList->val; beamfns2 = &(beamList->beamfn); - sftList = (SFTListElement *)sftList->nextSFT; - psdList = (PSDListElement *)psdList->nextPSD; - freqList = (REAL8ListElement *)freqList->nextVal; - phaseList = (REAL8ListElement *)phaseList->nextVal; - beamList = (CrossCorrBeamFnListElement *)beamList->nextBeamfn; + sftList = (SFTListElement *)sftList->nextSFT; + psdList = (PSDListElement *)psdList->nextPSD; + freqList = (REAL8ListElement *)freqList->nextVal; + phaseList = (REAL8ListElement *)phaseList->nextVal; + beamList = (CrossCorrBeamFnListElement *)beamList->nextBeamfn; } else { /*otherwise just step to the next sft*/ - sftList = (SFTListElement *)sftList->nextSFT; - psdList = (PSDListElement *)psdList->nextPSD; - freqList = (REAL8ListElement *)freqList->nextVal; - phaseList = (REAL8ListElement *)phaseList->nextVal; - beamList = (CrossCorrBeamFnListElement *)beamList->nextBeamfn; - - sft2 = &(sftList->sft); - psd2 = &(psdList->psd); - freq2 = freqList->val; - phase2 = phaseList->val; - beamfns2 = &(beamList->beamfn); - } - /*strcmp returns 0 if strings are equal, >0 if strings are different*/ - sameDet = strcmp(sft1->name, sft2->name); - - /* if they are different, set sameDet to 1 so that it will match if - detChoice == DIFFERENT */ - if (sameDet != 0) { sameDet = 1; } + sftList = (SFTListElement *)sftList->nextSFT; + psdList = (PSDListElement *)psdList->nextPSD; + freqList = (REAL8ListElement *)freqList->nextVal; + phaseList = (REAL8ListElement *)phaseList->nextVal; + beamList = (CrossCorrBeamFnListElement *)beamList->nextBeamfn; + + sft2 = &(sftList->sft); + psd2 = &(psdList->psd); + freq2 = freqList->val; + phase2 = phaseList->val; + beamfns2 = &(beamList->beamfn); + } + /*strcmp returns 0 if strings are equal, >0 if strings are different*/ + sameDet = strcmp(sft1->name, sft2->name); + /* if they are different, set sameDet to 1 so that it will match if + detChoice == DIFFERENT */ + if (sameDet != 0) { sameDet = 1; } - /* however, if detChoice = ALL, then we want sameDet to match it */ - if (detChoice == ALL) { sameDet = detChoice; } + /* however, if detChoice = ALL, then we want sameDet to match it */ + if (detChoice == ALL) { sameDet = detChoice; } - /* decide whether to add this pair or not */ - if ((sameDet == (INT4)detChoice)) { + /* decide whether to add this pair or not */ + if ((sameDet == (INT4)detChoice)) { - /* increment the size of Y, u, sigmasq vectors by 1 */ - yalpha = XLALResizeCOMPLEX16Vector(yalpha, 1 + ualphacounter); - ualpha = XLALResizeCOMPLEX16Vector(ualpha, 1 + ualphacounter); - sigmasq = XLALResizeREAL8Vector(sigmasq, 1 + ualphacounter); + /* increment the size of Y, u, sigmasq vectors by 1 */ + yalpha = XLALResizeCOMPLEX16Vector(yalpha, 1 + ualphacounter); + ualpha = XLALResizeCOMPLEX16Vector(ualpha, 1 + ualphacounter); + sigmasq = XLALResizeREAL8Vector(sigmasq, 1 + ualphacounter); + gplus = XLALResizeCOMPLEX16Vector(gplus, 1 + ualphacounter); + gcross = XLALResizeCOMPLEX16Vector(gcross, 1 + ualphacounter); - LAL_CALL( LALCorrelateSingleSFTPair( &status, &(yalpha->data[ualphacounter]), + + + LAL_CALL( LALCorrelateSingleSFTPair( &status, &(yalpha->data[ualphacounter]), sft1, sft2, psd1, psd2, freq1, freq2), &status); - LAL_CALL( LALCalculateSigmaAlphaSq( &status, &sigmasq->data[ualphacounter], + LAL_CALL( LALCalculateSigmaAlphaSq( &status, &sigmasq->data[ualphacounter], freq1, freq2, psd1, psd2), &status); - /*if we are averaging over psi and cos(iota), call the simplified - Ualpha function*/ - if (uvar_averagePsi && uvar_averageIota) { + /*if we are averaging over psi and cos(iota), call the simplified + Ualpha function*/ + if (uvar_averagePsi && uvar_averageIota) { LAL_CALL( LALCalculateAveUalpha ( &status, &ualpha->data[ualphacounter], phase1, phase2, *beamfns1, *beamfns2, sigmasq->data[ualphacounter]), &status); - } else { + } else { LAL_CALL( LALCalculateUalpha ( &status, &ualpha->data[ualphacounter], amplitudes, phase1, phase2, *beamfns1, *beamfns2, - sigmasq->data[ualphacounter], psi), + sigmasq->data[ualphacounter], psi, &gplus->data[ualphacounter], &gcross->data[ualphacounter]), &status); - - } + } + ualphacounter++; + + } + } /*finish loop over sft pairs*/ + + /* calculate rho from Yalpha and Ualpha, if there were pairs */ + if (ualphacounter > 0) { + tmpstat = 0; + tmpstat2 = 0; + tmpstat3 =0; + tmpstat4 = 0; + LAL_CALL( LALCalculateCrossCorrPower( &status, &tmpstat, yalpha, ualpha), + &status); - ualphacounter++; - } - } /*finish loop over sft pairs*/ + rho->data[counter] += tmpstat; + /* calculate standard deviation of rho (Eq 4.6) */ + LAL_CALL( LALNormaliseCrossCorrPower( &status, &tmpstat, ualpha, sigmasq), + &status); + variance->data[counter] += tmpstat; - /* calculate rho from Yalpha and Ualpha, if there were pairs */ - if (ualphacounter > 0) { - tmpstat = 0; - LAL_CALL( LALCalculateCrossCorrPower( &status, &tmpstat, yalpha, ualpha), - &status); +/* +for (i=0; i < (INT4)ualpha->length; i++) { +printf("%f %f %f %f\n", ualpha->data[i].re, ualpha->data[i].im, yalpha->data[i].re, yalpha->data[i].im); +} +*/ - rho->data[counter] += tmpstat; - /* calculate standard deviation of rho (Eq 4.6) */ - LAL_CALL( LALNormaliseCrossCorrPower( &status, &tmpstat, ualpha, sigmasq), - &status); + if (lalDebugLevel && !uvar_averagePsi && !uvar_averageIota) { + LAL_CALL( LALCalculateEstimators( &status, &tmpstat, &tmpstat2, &tmpstat3, &tmpstat4, yalpha, gplus, gcross, sigmasq), &status); + + aplussq1->data[counter] += tmpstat; + aplussq2->data[counter] += tmpstat2; + acrossq1->data[counter] += tmpstat3; + acrossq2->data[counter] += tmpstat4; + + for (i=0; i < (INT4)ualpha->length; i++) { + + galphasq->data[counter] += SQUARE(sigmasq->data[i] * ualpha->data[i].re) + SQUARE(sigmasq->data[i] * ualpha->data[i].im); + } + + } + } /* endif (ualphacounter > 0) */ - stddev->data[counter] += tmpstat; - } + if (lalDebugLevel && uvar_averagePsi && uvar_averageIota) { + + for (i=0; i < (INT4)ualpha->length; i++) { - counter++; - paramCounter++; + galphasq->data[counter] += (SQUARE(sigmasq->data[i] * ualpha->data[i].re) + SQUARE(sigmasq->data[i] * ualpha->data[i].im)); + } + } + counter++; + paramCounter++; } /*endwhile*/ XLALDestroyCOMPLEX16Vector(yalpha); XLALDestroyCOMPLEX16Vector(ualpha); + XLALDestroyCOMPLEX16Vector(gplus); + XLALDestroyCOMPLEX16Vector(gcross); XLALDestroyREAL8Vector(sigmasq); + + } /*end if listLength > 1 */ } /* finish loop over all sfts */ + printf("finish loop over all sfts\n"); time(&t2); @@ -861,11 +952,20 @@ int main(int argc, char *argv[]){ thisPoint.Alpha = skyAlpha[skyCounter]; thisPoint.Delta = skyDelta[skyCounter]; - /*normalise rho*/ - rho->data[counter] = rho->data[counter]/sqrt(stddev->data[counter]); - fprintf(fp, "%1.5f\t %1.5f\t %1.5f\t %e\t %e\t %e\t %1.10f\n", thisPoint.Alpha, + /*normalise rho by stddev */ + rho->data[counter] = rho->data[counter]/sqrt(variance->data[counter]); + fprintf(fp, "%1.5f\t %1.5f\t %1.5f\t %e\t %e\t %e\t %1.10g\n", thisPoint.Alpha, thisPoint.Delta, f_current, q1_current, q2_current, n_current, rho->data[counter]); + + if (lalDebugLevel && !uvar_averagePsi && !uvar_averageIota) { + fprintf(estimator, "%1.5f %e %e %e \n", f_current, sqrt(fabs(aplussq2->data[counter]/aplussq1->data[counter])), sqrt(fabs(acrossq2->data[counter]/acrossq1->data[counter])), galphasq->data[counter]); + } + + if (lalDebugLevel && uvar_averagePsi && uvar_averageIota) { + fprintf(estimator, "%1.5f %g \n", f_current, galphasq->data[counter]); + } + counter++; } } /*end n loop*/ @@ -887,7 +987,7 @@ int main(int argc, char *argv[]){ thisPoint.Alpha = skyAlpha[skyCounter]; thisPoint.Delta = skyDelta[skyCounter]; /*normalise rho*/ - rho->data[counter] = rho->data[counter]/sqrt(stddev->data[counter]); + rho->data[counter] = rho->data[counter]/sqrt(variance->data[counter]); fprintf(fp, "%1.5f\t %1.5f\t %1.5f\t %e\t %e\t %1.10f\n", thisPoint.Alpha, thisPoint.Delta, f_current, fdot_current, fddot_current, rho->data[counter]); @@ -908,6 +1008,11 @@ int main(int argc, char *argv[]){ fclose (fp); + if (lalDebugLevel && !uvar_averagePsi && !uvar_averageIota) { + + fclose (estimator); + + } LAL_CALL( LALDestroySFTCatalog( &status, &catalog ), &status); LALFree(edat->ephemE); @@ -917,8 +1022,17 @@ int main(int argc, char *argv[]){ LALFree(skyDelta); LALFree(skySizeAlpha); LALFree(skySizeDelta); - XLALDestroyREAL8Vector(stddev); + XLALDestroyREAL8Vector(variance); XLALDestroyREAL8Vector(rho); + XLALDestroyREAL8Vector(aplussq1); + XLALDestroyREAL8Vector(aplussq2); + XLALDestroyREAL8Vector(acrossq1); + XLALDestroyREAL8Vector(acrossq2); + XLALDestroyREAL8Vector(galphasq); + + if (!uvar_averagePsi) { + LALFree(psi); + } if (uvar_QCoeffs) { XLALDestroyREAL8Vector(fdots); @@ -1718,7 +1832,7 @@ void initUserVars (LALStatus *status) "Output directory", &uvar_dirnameOut); LALRegisterSTRINGUserVar( status->statusPtr, "filenameOut", - 'o', UVAR_OPTIONAL, + 0, UVAR_OPTIONAL, "Output filename", &uvar_filenameOut); LALRegisterINTUserVar( status->statusPtr, "blocksRngMed", diff --git a/lalapps/src/pulsar/fscan/README b/lalapps/src/pulsar/fscan/README index 10f29b6be27ba59d3263370f3bd0bdd2f7d5a3ed..1bc8afb4d1cb26b39b8d2b4ccdbe575bf693c505 100644 --- a/lalapps/src/pulsar/fscan/README +++ b/lalapps/src/pulsar/fscan/README @@ -15,10 +15,27 @@ THIS CODE IS UNDER CONSTRUCTION: ../fscanDriver.py -s 842705233 -L 36000 -G exampleTest -d RDS_R_L1 -k 40 -T 1800 -p /archive/home/pulsar/searchcode/src/lalapps/src/pulsar/fscan/test/sfts -N H1:LSC-DARM_CTRL -F 100 -B 20 -b 5 -X fscanTest -o /usr1/pulsar -O . -C --run -5. How to compile plotSpecAvgOutput.m, e.g., on ldas-grid: +5. How to compile plotSpecAvgOutput.m, e.g., as user pulsar on ldas-grid: + +Make sure /archive/home/pulsar/.usematlab_r2008a exists, otherwise touch this file, and logout and login so that "which matlab" returns: +/ldcg/matlab_r2008a/bin/matlab + +Then run these commands: + +$ cd /archive/home/pulsar/searchcode/src/lalsuite/lalapps/src/pulsar/fscan +$ source MatlabSetup_R2008a_glnxa64.sh $ matlab -nodisplay -nodesktop -nojvm >> mbuild -setup >> mcc -mv plotSpecAvgOutput.m >> exit -# Need to run the code once by hand before it will work on the cluster: + +You many need to run the code once by hand before it will work on the cluster (it does not matter if this fails, this just makes Matlab set up the libraries under ~/.mcr_cache_v78): + ./plotSpecAvgOutput S4/spec_50.00_100.00_H1_793181266_795677345 /archive/home/pulsar/public_html/fscan/test/spec_50.00_100.00_H1_793181266_795677345.pdf H1:hoft 793181266 795677345 50 100 10 5 10 + +After this, logout, and login to unset the environment set by MatlabSetup_R2008a_glnxa64.sh. + +You do not want to source MatlabSetup_R2008a_glnxa64.sh when running plotSpecAvgOutput!!! + +Instead, the fscan code runs run_plotSpecAvgOutput.sh /ldcg/matlab_r2008a, which is a wrapper script the matlab mcc commands generated that runs plotSpecAvgOutput, and it will take care of setting up the environment. + diff --git a/lalapps/src/pulsar/fscan/fscanDriver.py b/lalapps/src/pulsar/fscan/fscanDriver.py index 8093639aa6ad59e5831b97b7fe34103989b82cd4..0969263c2816f18f8ab00342147294caac12357e 100755 --- a/lalapps/src/pulsar/fscan/fscanDriver.py +++ b/lalapps/src/pulsar/fscan/fscanDriver.py @@ -4,17 +4,23 @@ fscanDriver.py - Driver script for calling other code to generates SFTs and turns these into plots showing spectra. -$Id$ +$Id: fscanDriver.py,v 1.25 2009/03/13 01:51:46 collingill Exp $ """ -__author__ = 'Rejean Dupuis <rejean@caltech.edu> & Greg Mendell<gmendell@ligo-wa.caltech.edu>' -__date__ = '$Date$' -__version__ = '$Revision$'[11:-2] +__author__ = 'Rejean Dupuis <rejean@caltech.edu> & Greg Mendell<gmendell@ligo-wa.caltech.edu> & Colin Gill <c.gill@astro.gla.ac.uk>' +__date__ = '$Date: 2009/03/13 01:51:46 $' +__version__ = '$Revision: 1.25 $'[11:-2] # REVISIONS: # 03/02/2009 gam; implement -g --segment-file option; if not given run on Science,Injections times, if -g ALL given then use start and end times as segment. # 03/02/2009 gam; if createSFTs then splice in the SFT DAG. +# 06/29/2009 gam; Add option to include matlab path, and run_plotSpecAvgOutput.sh rather than plotSpecAvgOutput. +# 06/29/2009 gam; Include links to _2 plots, when making a comparisons with other fscans. +# 06/29/2009 gam; Fix options and printing of extra debugging info. +# 06/29/2009 gam; use ligolw_segment_query instead of LSCsegFind. +# 10/07/2009 gam; Add -I, --intersect-data option to run ligo_data_find with the --show-times option to find times data exist, and use LIGOtools segexpr to intersect this with the segments. +# 10/07/2009 gam; Add -t, --segment-type option to give segment type to use with ligolw_segment_query if segment file is not given (default is IFO:DMT-SCIENCE:1) # import standard modules and append the lalapps prefix to the python path import sys, os @@ -56,15 +62,18 @@ Usage: [options] -c, --freq-res the frequency resolution of the spectragrams produced. -v, --sft-version (optional) SFT version number (1 or 2; default is 1) -C --create-sfts (optional) create the SFTs !!! (/tmp will be appended to the sft-path and SFTs will be generated there!) - -g, --segment-file (optional) used only if creating sfts; gives alternative file with segments to use, otherwise LSCsegFind is used to find Science,Injection segments; if -g ALL is given then [start_time, start_time + duration) is used. + -g, --segment-file (optional) used only if creating sfts; gives alternative file with segments to use, otherwise ligolw_segment_query is used to find Science segments; if -g ALL is given then [start_time, start_time + duration) is used. + -t, --segment-type (optional) segment type to use with ligolw_segment_query if segment file is not given (default is IFO:DMT-SCIENCE:1). -o, --sub-log-path (optional) path to log files given in .sub files (default is $PWD/logs; this directory must exist and usually should be under a local file system.) -N, --channel-name name of input time-domain channel to read from frames - -i, --ifo (optional) ifo to use with LSCsegFind and MakeSFTDAG: e.g., H1, H2, L1, G1; PEM channels can start with H0, L0, or G0 (default: use start of channel name) + -i, --ifo (optional) ifo to use with ligolw_segment_query and MakeSFTDAG: e.g., H1, H2, L1, G1; PEM channels can start with H0, L0, or G0 (default: use start of channel name) + -I, --intersect-data (optional) Run ligo_data_find with the --show-times option to find times data exist, and use LIGOtools segexpr to intersect this with the segments. -u, --frame-struct-type (optional) string specifying the input frame structure and data type. Must begin with ADC_ or PROC_ followed by REAL4, REAL8, INT2, INT4, or INT8; default: ADC_REAL4; -H is the same as PROC_REAL8. -F, --start-freq (optional) start frequency of the SFTs (default is 48 Hz). -B, --band (optional) frequency band of the SFTs (default is 100 Hz). -b, --sub-band (optional) divide frequency band into sub bands of this size (default is 10 Hz). -O, --plot-output-path (optional) if given then Matlab jobs run and put output plots and data in this directory. + -m, --matlab-path (optional) Path to matlab installation, e.g., /ldcg/matlab_r2008a. (Required if --plot-output-path is given.) -W, --html-filename (optional) path and filename of output html file that displays output plots and data. -r --html-reference-path (optional) path to already existing reference output plots and data for display on html page. -e --html-ref-ifo-epoch (optional) string that give ifo and GPS start and end times of reference plots, e.g.,H1_840412814_845744945. @@ -72,6 +81,8 @@ Usage: [options] -y --coincidence-deltaf (optional) if a reference and threshold on snr is given, then use this as the coincidence window on frequency. -X --misc-desc (optional) misc. part of the SFT description field in the filename (also used if -D option is > 0). -H, --use-hot (optional) input data is from h(t) calibrated frames (h of t = hot!) (0 or 1). + -J --psrInput (optional) Input the name and path of tempo file used to overplot a source's freq onto specgrams + -j --psrEphemeris (optional) Input the name and path of ephemeris file used to overplot a source's freq onto specgrams """ print >> sys.stdout, msg @@ -83,7 +94,7 @@ Usage: [options] #################################### # PARSE COMMAND LINE OPTIONS # -shortop = "s:L:G:d:x:M:k:T:p:f:o:N:i:w:P:u:v:c:F:B:b:O:W:r:e:q:y:D:X:m:g:l:hSHZCR" #cg; shortop is a string. +shortop = "s:L:G:d:x:M:k:T:p:f:o:N:i:w:P:u:v:c:F:B:b:O:m:W:r:e:q:y:D:X:g:t:l:J:j:hSHZCRI" #cg; shortop is a string. longop = [ #cg; longopt is a list "help", "analysis-start-time=", @@ -102,6 +113,7 @@ longop = [ #cg; longopt is a list "sub-log-path=", "channel-name=", "ifo=", + "intersect-data", "frame-struct-type=", "window-type=", "overlap-fraction=", @@ -111,6 +123,7 @@ longop = [ #cg; longopt is a list "band=", "sub-band=", "plot-output-path=", + "matlab-path=", "html-filename=", "html-reference-path=", "html-ref-ifo-epoch=", @@ -120,11 +133,14 @@ longop = [ #cg; longopt is a list "misc-desc=", "max-num-per-node=", "segment-file=", + "segment-type=", "min-seg-length=", "use-single=", "use-hot", "make-tmp-file", "run", + "psrInput=", + "psrEphmeris=", ] try: @@ -152,6 +168,7 @@ logPath = "logs" subLogPath = "logs" channelName = None segIFO = None +intersectData = False makeSFTIFO = None frameStructType = None windowType = 1 @@ -162,6 +179,7 @@ startFreq = 48.0 freqBand = 50.0 freqSubBand = 10.0 plotOutputPath = None +matlabPath = None makeMatlabPlots = False htmlFilename = None htmlReferenceDir = None @@ -173,12 +191,15 @@ miscDesc = None maxNumPerNode = 1 maxLengthAllJobs = None segmentFile = None +segmentType = None minSegLength = 0L useSingle = False useHoT = False makeTmpFile = False runCondorSubmitDag = False -freqRes = 2.0 +freqRes = 0.2 +psrInput = None +psrEphemeris = None for o, a in opts: if o in ("-h", "--help"): @@ -212,6 +233,8 @@ for o, a in opts: channelName = a elif o in ("-i", "--ifo"): segIFO = a + elif o in ("-I", "--intersect-data"): + intersectData = True elif o in ("-u", "--frame-struct-type"): frameStructType = a elif o in ("-w", "--window-type"): @@ -220,8 +243,6 @@ for o, a in opts: overlapFraction = float(a) elif o in ("-v", "--sft-version"): sftVersion = int(a) - elif o in ("-c", "--comment-field"): - commentField = a elif o in ("-F", "--start-freq"): startFreq = long(a) elif o in ("-B", "--band"): @@ -230,6 +251,8 @@ for o, a in opts: freqSubBand = long(a) elif o in ("-O", "--plot-output-path"): plotOutputPath = a + elif o in ("-m", "--matlab-path"): + matlabPath = a elif o in ("-W", "--html-filename"): htmlFilename = a elif o in ("-r", "--html-reference-path"): @@ -250,6 +273,8 @@ for o, a in opts: maxLengthAllJobs = long(a) elif o in ("-g", "--segment-file"): segmentFile = a + elif o in ("-t", "--segment-type"): + segmentType = a elif o in ("-l", "--min-seg-length"): minSegLength = long(a) elif o in ("-S", "--use-single"): @@ -260,6 +285,10 @@ for o, a in opts: runCondorSubmitDag = True elif o in ("-Z", "--make-tmp-file"): makeTmpFile = True + elif o in ("-J", "--psrInput"): + psrInput = a + elif o in ("-j", "--psrEphmeris"): + psrEphemeris = a else: print >> sys.stderr, "Unknown option:", o usage() @@ -379,7 +408,11 @@ if (plotOutputPath == None): makeMatlabPlots = False else: makeMatlabPlots = True - + if (matlabPath == None): + print >> sys.stderr, "No matlab path specified." + print >> sys.stderr, "Use --help for usage details." + sys.exit(1) + # try and make a directory to store the cache files and job logs try: os.makedirs(logPath) except: pass @@ -410,22 +443,27 @@ if (createSFTs): except: pass ################################################### - # FIND SCIENCE MODE SEGMENTS; RUN LSCsegFind + # FIND SCIENCE MODE SEGMENTS; RUN ligolw_segment_query # # 03/02/2009 gam; in default case change Science to Science,Injection; add segment file options as elif and else options: + # 06/29/2009 gam; use ligolw_segment_query instead of LSCsegFind. if not segmentFile: segmentFile = 'tmpSegs%stmp.txt' % tagString - segCommand = 'LSCsegFind --type Science,Injection --interferometer %s --gps-start-time %d --gps-end-time %d > %s' % (segIFO,analysisStartTime, analysisEndTime,segmentFile) + if not segmentType: + # set default segment type + segmentType = "%s:DMT-SCIENCE:1" % segIFO + #segCommand = 'LSCsegFind --type Science,Injection --interferometer %s --gps-start-time %d --gps-end-time %d > %s' % (segIFO,analysisStartTime, analysisEndTime,segmentFile) + segCommand = "ligolw_segment_query --database --query-segments --include-segments %s --gps-start-time %d --gps-end-time %d | grep -v \"0, 0\" | ligolw_print -t segment:table -c start_time -c end_time -d \" \" > %s" % (segmentType,analysisStartTime,analysisEndTime,segmentFile) print >> sys.stdout,"Trying: ",segCommand,"\n" try: segFindExit = os.system(segCommand) if (segFindExit > 0): - print >> sys.stderr, 'LSCsegFind failed: %s \n' % segFindExit + print >> sys.stderr, 'ligolw_segment_query failed: %s \n' % segFindExit sys.exit(1) else: - print >> sys.stderr, 'LSCsegFind succeeded! \n' + print >> sys.stderr, 'ligolw_segment_query succeeded! \n' except: - print >> sys.stderr, 'LSCsegFind failed: %s \n' % segFindExit + print >> sys.stderr, 'ligolw_segment_query failed: %s \n' % segFindExit sys.exit(1) elif segmentFile == "ALL": segmentFile = 'tmpSegs%stmp.txt' % tagString @@ -445,7 +483,45 @@ if (createSFTs): # Just continue with the name given on the command line. print >> sys.stderr, 'Using segmentFile == %s \n' % segmentFile - + ################################################### + # Intersect with existing data if intersectData = True + # + + if intersectData: + # Get the segments the data exist from ligo_data_find + dataFindSegmentFile = 'tmpDataFindSegs%stmp.txt' % tagString + dataFindCommand = "ligo_data_find -s %d -e %d -o %s -t %s -u file --lal-cache --show-times > %s" % (analysisStartTime,analysisEndTime,site,inputDataType,dataFindSegmentFile) + print >> sys.stdout,"Trying: ",dataFindCommand,"\n" + try: + dataFindExit = os.system(dataFindCommand) + if (dataFindExit > 0): + print >> sys.stderr, 'ligo_data_find failed: %s \n' % dataFindExit + sys.exit(1) + else: + print >> sys.stderr, 'ligo_data_find succeeded! \n' + except: + print >> sys.stderr, 'ligo_data_find failed: %s \n' % dataFindExit + sys.exit(1) + + # Intersect the segments to run on with the segments data exist + intersectedSegmentFile = 'tmpIntersectedSegs%stmp.txt' % tagString + segexprCommand = "segexpr \"intersection(%s,%s)\" %s" % (segmentFile,dataFindSegmentFile,intersectedSegmentFile) + print >> sys.stdout,"Trying: ",segexprCommand,"\n" + try: + segexprExit = os.system(segexprCommand) + if (segexprExit > 0): + print >> sys.stderr, 'segexpr failed: %s \n' % segexprExit + sys.exit(1) + else: + print >> sys.stderr, 'segexpr succeeded! \n' + except: + print >> sys.stderr, 'segexpr failed: %s \n' % segexprExit + sys.exit(1) + + # set the segmentFile equal to the intersection of the segments to run on with the segments data exist + segmentFile = intersectedSegmentFile + # End if intersectData + ################################################### # CHECK THE SEGMENT FILE # @@ -562,9 +638,10 @@ spectrumAverageFID.close() if (makeMatlabPlots): runMatlabScriptFID = file('runMatlabPlotScript.sub','w') runMatlabScriptLogFile = subLogPath + '/' + 'runMatlabPlotScript_' + dagFileName + '.log' - runMatlabScriptFID.write('universe = vanilla\n') + runMatlabScriptFID.write('universe = local\n') # Run compiled version plotSpecAvgOutput.m: - runMatlabScriptFID.write('executable = $ENV(PLOTSPECAVGOUTPUT_PATH)/plotSpecAvgOutput\n') + # runMatlabScriptFID.write('executable = $ENV(PLOTSPECAVGOUTPUT_PATH)/plotSpecAvgOutput\n'); # 06/29/09 gam; changed to run_plotSpecAvgOutput.sh. + runMatlabScriptFID.write('executable = $ENV(PLOTSPECAVGOUTPUT_PATH)/run_plotSpecAvgOutput.sh\n') runMatlabScriptFID.write('getenv = True\n') runMatlabScriptFID.write('arguments = $(argList)\n') runMatlabScriptFID.write('log = %s\n' % runMatlabScriptLogFile) @@ -587,12 +664,12 @@ if (htmlFilename != None): htmlFID.write('<h1>FSCAN PLOTS</h1>\n') htmlFID.write('</div>\n') htmlFID.write('<br>\n') - if (htmlReferenceDir != None) and (thresholdSNR > 0): + if (htmlReferenceDir != None) and (thresholdSNR > 0):#If we want to compare to a reference, then lines below will create an extra page, and link to it... htmlLinesFilenameList = os.path.split(htmlFilename) htmlLinesFilenameShort = 'Lines_%s' % htmlLinesFilenameList[1] htmlLinesFilename = os.path.join(htmlLinesFilenameList[0],htmlLinesFilenameShort) - htmlLinesFID = file(htmlLinesFilename,'w') - htmlLinesFID.write('<html>\n') + htmlLinesFID = file(htmlLinesFilename,'w')#create a file whose name is stored in htmlLinesFilename, open it for writing. + htmlLinesFID.write('<html>\n')#write html into file, and go to next line. htmlLinesFID.write('<head>\n') htmlLinesFID.write('<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">\n') htmlLinesFID.write('<title>FSCANCOINCIDENTLINES</title>\n') @@ -637,21 +714,25 @@ while (thisEndFreq < endFreq): # Fix off-by-one bin end frequency error; for simplicity remove final 1 Hz #thisEndFreq = endFreq - 1 - print >> sys.stdout,"startfreq: ",startFreq,"\n" - print >> sys.stdout,"endfreq: ",endFreq,"\n" - print >> sys.stdout,"thisStartfreq: ",thisStartFreq,"\n" - print >> sys.stdout,"thisEndfreq: ",thisEndFreq,"\n" + #print >> sys.stdout,"startfreq: ",startFreq,"\n" + #print >> sys.stdout,"endfreq: ",endFreq,"\n" + #print >> sys.stdout,"thisStartfreq: ",thisStartFreq,"\n" + #print >> sys.stdout,"thisEndfreq: ",thisEndFreq,"\n" - freqrange = thisEndFreq - thisStartFreq + fRange = thisEndFreq - thisStartFreq #This section of code writes the arguments for spec_avg.c #------------------------------------------------------------ specAvgJobName = 'SpecAvg_%i' % nodeCount dagFID.write('JOB %s spectrumAverage.sub\n' % specAvgJobName) - dagFID.write('RETRY %s 10\n' % specAvgJobName) + dagFID.write('RETRY %s 0\n' % specAvgJobName) #the variable names in the arglist below are the names of the variables in spec_avg.c not in this code - if (sftVersion == 2): + if ((psrInput != None) and (sftVersion == 2)): + argList = '--startGPS %d --endGPS %d --IFO %s --fMin %d --fMax %d --freqRes %f --timeBaseline %d --SFTs %s/*.sft --psrInput %s --psrEphemeris %s' % (analysisStartTime,analysisEndTime,ifo,thisStartFreq,thisEndFreq,freqRes,timeBaseline,pathToSFTs,psrInput, psrEphemeris) + elif ((psrInput == None) and (sftVersion == 2)): argList = '--startGPS %d --endGPS %d --IFO %s --fMin %d --fMax %d --freqRes %f --timeBaseline %d --SFTs %s/*.sft' % (analysisStartTime,analysisEndTime,ifo,thisStartFreq,thisEndFreq,freqRes,timeBaseline,pathToSFTs) + elif ((psrInput != None) and (sftVersion != 2)): + argList = '--startGPS %d --endGPS %d --IFO %s --fMin %d --fMax %d --freqRes %f --timeBaseline %d --SFTs %s/SFT* --psrInput %s --psrEphemeris %s' % (analysisStartTime,analysisEndTime,ifo,thisStartFreq,thisEndFreq,freqRes,timeBaseline,pathToSFTs,psrInput, psrEphemeris) else: argList = '--startGPS %d --endGPS %d --IFO %s --fMin %d --fMax %d --freqRes %f --timeBaseline %d --SFTs %s/SFT*' % (analysisStartTime,analysisEndTime,ifo,thisStartFreq,thisEndFreq,freqRes,timeBaseline,pathToSFTs) tagStringOut = '%s_%i' % (tagString, nodeCount) @@ -660,69 +741,111 @@ while (thisEndFreq < endFreq): # 03/02/2009 gam; use SPLICE to insert SFT DAG #dagFID.write('PARENT %s CHILD %s\n'%(sftDAGSUBJobName,specAvgJobName)) dagFID.write('PARENT %s CHILD %s\n'%(spliceSFTDAGName,specAvgJobName)) + +#write arguments to be passed to matlab job if (makeMatlabPlots): - runMatlabPlotScriptJobName = 'runMatlabPlotScript_%i' % nodeCount - dagFID.write('JOB %s runMatlabPlotScript.sub\n' % runMatlabPlotScriptJobName) - dagFID.write('RETRY %s 3\n' % runMatlabPlotScriptJobName) - inputFileName = 'spec_%d.00_%d.00_%s_%d_%d' % (thisStartFreq,thisEndFreq,ifo,analysisStartTime,analysisEndTime) - # Matlab will append .pdf and .png to outputFileName to save plots: - outputFileName = '%s/%s' % (plotOutputPath, inputFileName) + runMatlabPlotScriptJobName = 'runMatlabPlotScript_%i' % nodeCount + dagFID.write('JOB %s runMatlabPlotScript.sub\n' % runMatlabPlotScriptJobName) + dagFID.write('RETRY %s 0\n' % runMatlabPlotScriptJobName) + inputFileName = 'spec_%d.00_%d.00_%s_%d_%d' % (thisStartFreq,thisEndFreq,ifo,analysisStartTime,analysisEndTime) + # Matlab will append .pdf and .png to outputFileName to save plots: + outputFileName = '%s/%s' % (plotOutputPath, inputFileName) - #check that the freq resolution does not exceed that of the raw sft freq resolution, if it does replace by max resolution. - if (freqRes < 1/timeBaseline): - freqRes = (1/timeBaseline) - effTBase = 1/freqRes - effTBaseFull = timeBaseline + #check that the freq resolution does not exceed that of the raw sft freq resolution, if it does replace by max resolution. + if (freqRes < 1/timeBaseline): + freqRes = (1/timeBaseline) + effTBase = 1/freqRes + effTBaseFull = timeBaseline - deltaFTicks=freqrange# divide deltaFticks by 10 in matlab script. - taveFlag = 1 + #work out the best frequency interval to place ticks at. + + if (fRange >= 200): + deltaFTicks = 20 + elif (fRange >= 100): + deltaFTicks = 10 + elif (fRange >= 50): + deltaFTicks = 5 + elif (fRange >= 5): + deltaFTicks = 1 + else: + deltaFTicks = 0.1 + + taveFlag = 1 + + #Test to see if we have pulsar input + if (psrInput != None): + pulsar = 1 + else: + pulsar = 0 - if (htmlReferenceDir != None): - referenceFileName = '%s/spec_%d.00_%d.00_%s' % (htmlReferenceDir,thisStartFreq,thisEndFreq,htmlRefIFOEpoch) - else: + if (htmlReferenceDir != None): + referenceFileName = '%s/spec_%d.00_%d.00_%s' % (htmlReferenceDir,thisStartFreq,thisEndFreq,htmlRefIFOEpoch) + else: referenceFileName = 'none' - argList = '%s %s %s %d %d %d %d %d %d %s' % (inputFileName,outputFileName,channelName,effTBase,deltaFTicks,taveFlag,effTBaseFull,thresholdSNR,coincidenceDeltaF,referenceFileName) - tagStringOut = '%s_%i' % (tagString, nodeCount) - dagFID.write('VARS %s argList="%s" tagstring="%s"\n'%(runMatlabPlotScriptJobName,argList,tagStringOut)) - dagFID.write('PARENT %s CHILD %s\n'%(specAvgJobName,runMatlabPlotScriptJobName)) + #argList = '%s %s %s %d %d %d %d %d %d %s' % (inputFileName,outputFileName,channelName,effTBase,deltaFTicks,taveFlag,effTBaseFull,thresholdSNR,coincidenceDeltaF,referenceFileName); # 06/29/09 gam; matlabPath has to be first argument. + #argList = '%s %s %s %s %d %d %d %d %d %d %s' % (matlabPath,inputFileName,outputFileName,channelName,effTBase,deltaFTicks,taveFlag,effTBaseFull,thresholdSNR,coincidenceDeltaF,referenceFileName) + argList = '%s %s %s %s %d %d %d %d %d %d %d %s' % (matlabPath,inputFileName,outputFileName,channelName,effTBase,deltaFTicks,taveFlag,effTBaseFull,thresholdSNR,coincidenceDeltaF,pulsar,referenceFileName) + tagStringOut = '%s_%i' % (tagString, nodeCount) + dagFID.write('VARS %s argList="%s" tagstring="%s"\n'%(runMatlabPlotScriptJobName,argList,tagStringOut)) + dagFID.write('PARENT %s CHILD %s\n'%(specAvgJobName,runMatlabPlotScriptJobName)) #add stuff to the html file to show the plots produced in matlab. #----------------------------------------------------------------- if (htmlFilename != None): - inputFileName = 'spec_%d.00_%d.00_%s_%d_%d' % (thisStartFreq,thisEndFreq,ifo,analysisStartTime,analysisEndTime) - # Matlab will append .pdf and .png to outputFileName to save plots. - htmlFID.write(' <tr>\n') - htmlFID.write(' <td style="vertical-align: top;">\n') - htmlFID.write(' <a href="%s.pdf"><img alt="" src="%s.png" style="border: 0px solid ; width: 576px; height: 432px;"></a><br>\n' % (inputFileName,inputFileName)) - htmlFID.write(' <a href="%s_2.pdf"><img alt="" src="%s_2.png" style="border: 0px solid ; width: 576px; height: 432px;"></a><br>\n' % (inputFileName,inputFileName)) - #cg, to add in the extra image write a line here, similar to above, but with some changes to the file name. - #HERE ****************************** HERE ******************* HERE ********************** - htmlFID.write(' </td>\n') - if (htmlReferenceDir != None): + inputFileName = 'spec_%d.00_%d.00_%s_%d_%d' % (thisStartFreq,thisEndFreq,ifo,analysisStartTime,analysisEndTime) + # Matlab will append .pdf and .png to outputFileName to save plots. + htmlFID.write(' <tr>\n')#tr adds a new table row. + htmlFID.write(' <td style="vertical-align: top;">\n') + htmlFID.write(' <a href="%s.pdf"><img alt="" src="%s.png" style="border: 0px solid ; width: 576px; height: 432px;"></a><br>\n' % (inputFileName,inputFileName)) + htmlFID.write(' <a href="%s_2.pdf"><img alt="" src="%s_2.png" style="border: 0px solid ; width: 576px; height: 432px;"></a><br>\n' % (inputFileName,inputFileName)) + htmlFID.write(' </td>\n')#ends the current data cell. + if (htmlReferenceDir != None): referenceFileName = '%s/spec_%d.00_%d.00_%s' % (htmlReferenceDir,thisStartFreq,thisEndFreq,htmlRefIFOEpoch) htmlFID.write(' <td style="vertical-align: top;">\n') htmlFID.write(' <a href="%s.pdf"><img alt="" src="%s.png" style="border: 0px solid ; width: 576px; height: 432px;"></a><br>\n' % (referenceFileName,referenceFileName)) + htmlFID.write(' <a href="%s_2.pdf"><img alt="" src="%s_2.png" style="border: 0px solid ; width: 576px; height: 432px;"></a><br>\n' % (referenceFileName,referenceFileName)) htmlFID.write(' </td>\n') - htmlFID.write(' </tr>\n') - # Next row with links to text files: - htmlFID.write(' <tr>\n') - htmlFID.write(' <td style="vertical-align: top;">\n') - htmlFID.write(' SFT Timestamps: <a href="%s_timestamps">%s_timestamps</a><br>\n' % (inputFileName,inputFileName)) - htmlFID.write(' Freq. vs Power: <a href="%s.txt">%s.txt</a><br>\n' % (inputFileName,inputFileName)) - htmlFID.write(' Freq. vs Power (Sorted): <a href="%s_sorted.txt">%s_sorted.txt</a><br>\n' % (inputFileName,inputFileName)) - if (htmlReferenceDir != None) and (thresholdSNR > 0): - htmlFID.write(' Coincident Lines: <a href="%s_lines.txt">%s_lines.txt</a><br>\n' % (inputFileName,inputFileName)) + htmlFID.write(' </tr>\n') + # Topten lines code + #htmlFID.write(' <tr>\n') + #htmlFID.write(' <td style="vertical-align: top;">\n') + #htmlFID.write('<object data="%s_topten.txt" type="text/plain" style="width: 620px; height: 450px"></object>' % inputFileName) + #htmlFID.write(' </td\n') + #htmlFID.write(' </tr>\n') + #end of topten lines. + htmlFID.write(' <tr>\n')#open new row in table for lines files. + htmlFID.write(' <td style="vertical-align: top;">\n') + htmlFID.write(' SFT Timestamps: <a href="%s_timestamps">%s_timestamps</a><br>\n' % (inputFileName,inputFileName)) + htmlFID.write(' Freq. vs Power: <a href="%s.txt">%s.txt</a><br>\n' % (inputFileName,inputFileName)) + htmlFID.write(' Freq. vs Power (Sorted): <a href="%s_sorted.txt">%s_sorted.txt</a><br>\n' % (inputFileName,inputFileName)) + if (htmlReferenceDir != None) and (thresholdSNR > 0): + #-------------------------- + #coincident lines + htmlFID.write(' Coincident Lines: <a href="%s_coincident_lines.txt">%s_coincident_lines.txt</a><br>\n' % (inputFileName,inputFileName)) + htmlLinesFID.write('<br>\n') + htmlLinesFID.write('<object data="%s_coincident_lines.txt" type="text/plain" style="width: 620px; height: 450px"></object>' % inputFileName) + htmlLinesFID.write('<br>\n') + #-------------------------- + #new lines + htmlFID.write(' New Lines: <a href="%s_new_lines.txt">%s_new_lines.txt</a><br>\n' % (inputFileName,inputFileName)) + htmlLinesFID.write('<br>\n') + htmlLinesFID.write('<object data="%s_new_lines.txt" type="text/plain" style="width: 620px; height: 450px"></object>' % inputFileName) + htmlLinesFID.write('<br>\n') + #--------------------------- + #old lines + htmlFID.write(' Old Lines: <a href="%s_old_lines.txt">%s_old_lines.txt</a><br>\n' % (inputFileName,inputFileName)) htmlLinesFID.write('<br>\n') - htmlLinesFID.write('<object data="%s_lines.txt" type="text/plain" style="width: 620px; height: 450px"></object>' % inputFileName) + htmlLinesFID.write('<object data="%s_old_lines.txt" type="text/plain" style="width: 620px; height: 450px"></object>' % inputFileName) htmlLinesFID.write('<br>\n') - htmlFID.write(' </td>\n') - if (htmlReferenceDir != None): + #--------------------------- + htmlFID.write(' </td>\n') + if (htmlReferenceDir != None): htmlFID.write(' <td style="vertical-align: top;">\n') htmlFID.write(' SFT Timestamps: <a href="%s_timestamps">%s_timestamps</a><br>\n' % (referenceFileName,referenceFileName)) htmlFID.write(' Freq. vs Power: <a href="%s.txt">%s.txt</a><br>\n' % (referenceFileName,referenceFileName)) htmlFID.write(' Freq. vs Power (Sorted): <a href="%s_sorted.txt">%s_sorted.txt</a><br>\n' % (referenceFileName,referenceFileName)) htmlFID.write(' </td>\n') - htmlFID.write(' </tr>\n') + htmlFID.write(' </tr>\n') thisStartFreq = thisStartFreq + freqSubBand thisEndFreq = thisStartFreq + freqSubBand nodeCount = nodeCount + 1 diff --git a/lalapps/src/pulsar/fscan/plotSpecAvgOutput.m b/lalapps/src/pulsar/fscan/plotSpecAvgOutput.m index 9f12e2b2e3165bf86bc383fcca56d2de9e9fffcf..8274b7c7d7a5c0bd0557d22fdd772556f8895ef7 100644 --- a/lalapps/src/pulsar/fscan/plotSpecAvgOutput.m +++ b/lalapps/src/pulsar/fscan/plotSpecAvgOutput.m @@ -1,4 +1,4 @@ -function plotSpecAvgOutput(filename,outputFileName,chanName,effTBase,deltaFTicks,taveFlag,effTBaseFull,thresholdSNR,coinDF,referenceFile) +function plotSpecAvgOutput(filename,outputFileName,chanName,effTBase,deltaFTicks,taveFlag,effTBaseFull,thresholdSNR,coinDF,pulsar,referenceFile) % % fileName -- the name of the file with data to input; this file is the output from spec_avg. % outputFileName -- base name of the output spectrogram files; will append .pdf and .png to this name. @@ -14,6 +14,7 @@ function plotSpecAvgOutput(filename,outputFileName,chanName,effTBase,deltaFTicks % thresholdSNR -- if > 0 then look for coincident lines with the referenceFile spectra above this threshold. % coinDF -- window in frequency to use when looking for coincident lines. % referenceFile -- base name of the reference file output by spec_avg; will append _timeaverage to this name. +%pulsar --can be 1 or zero, if 1 then assume need to overplot the freq of GW from a source on specgram % Convert relevant strings to numbers. if (ischar(effTBase)) @@ -34,30 +35,49 @@ end if (ischar(coinDF)) coinDF=str2num(coinDF); end +if (ischar(pulsar)) + pulsar=str2num(pulsar); +end -xIn = load(filename);%cg; loads the contents of the file into Xin, this should be a matlab binary file according to matlab help, but hte file is ascii!?!?!?!? Does not seam to matter. This line loads my test1 data for 3 SFTs inot Xin no probs. Typing in on the command line you need to put the filename in 'filename'. Xin is then a 3 by 100 array of doubles. +xIn = load(filename);%cg; loads the contents of the file into Xin, this should be a matlab binary file according to matlab help, but hte file is ascii!?!?!?!? Does not seam to matter. This line loads my test1 data for 3 SFTs into Xin no probs. Typing in on the command line you need to put the filename in 'filename'. Xin is then a 3 by 100 array of doubles. +xlen=length(xIn(:,1)); +ylen=length(xIn(1,:)); y = flipud(transpose((xIn)));%cg; flipud flipes the array/matrix upside down, i.e. reverses the row direction of the array. Transpose obvisouly transposes the array. So the array gets put up on its side and then turned upside down. This is so the values appear in the correct way when displaying the array as an image, which is what imagesc does. + %cg;these lines get the relvant info out of the file name %--------------- undrscr = findstr('_',filename); fStart = str2num(filename((undrscr(1)+1):(undrscr(2)-1))); % start frequency fEnd = str2num(filename((undrscr(2)+1):(undrscr(3)-1))); % end frequency -tStart = str2num(filename((undrscr(4)+1):(undrscr(5)-1))); % start time -tEnd = str2num(filename((undrscr(5)+1):end)); % end time +tStart = str2num(filename((undrscr(4)+1):(undrscr(5)-1))) % start time +tEnd = str2num(filename((undrscr(5)+1):end)) % end time %---------------- -% calculate characteristic values cg; This bit of code gets the data from the input file and orders it appropriately into a matrix for the imagesc matlab function. +% calculate characteristic values cg; calculates a cutoffval for the data so really loud stuff does not dominate. + +y_temp1 = y; -y_temp = [ ]; -for ii=1:length(y(:,1)); %cg; starts the for loop, starting value for ii is 1, end value for ii is length(y(:,1)). The length function returns the length of the vector in question, or if it is an array the length of its longest dimension. - y_temp = [y_temp,y(ii,:)]; +%this little section gets rid of the xols of zeros for teh cutoffval calc, without this if there are more cols of zeros than non-zeros the median value and therefore the cuttoffval will be zero. +ycols=(1:xlen);%create a vector, elements are the column indicies of y +yzeros=find( sum(y(:,ycols)) == 0 );%find all the column indices where the sum of the columns are zero. +y_temp1(:,yzeros)=[];%get rid of all the columns where the sum of the columns are zero. +%ynocols=length(y_temp1(1,:))%use for bug checking. +%y_temp1 is an array with all the gaps taken out, so just data no zeros. + +y_temp2 = [ ];%makes Y-temp2 into a vector, data is put in column by column. +for ii=1:length(y_temp1(:,1)); + y_temp2 = [y_temp2,y_temp1(ii,:)]; end +%get NumBinsAvg from file. +filename_numbins=sprintf('%s_numbins',filename); +NumBinsAvg = load(filename_numbins); +mediany = median(y_temp2); -cutoffval = median(y_temp)+5*(median(y_temp)/sqrt(effTBase));%cg; this cut off value is used in the loop below to get rid of any outliers. Not sure about the formula used for this calc. But be aware, will need to change the value being sqrt'ed.Old value is 180, changed to effTBase +cutoffval = median(y_temp2) + (5*(median(y_temp2)/sqrt(NumBinsAvg)) );%cg; this cut off value is used in the loop below to get rid of any outliers. Not sure about the formula used for this calc. But be aware, will need to change the value being sqrt'ed.Old value is 180, changed to NumBinsAvg, which is the number of bins over which the power values have been averaged in the c code. %maximum = max(max(y)); %minimum = min(min(y)); @@ -65,55 +85,185 @@ cutoffval = median(y_temp)+5*(median(y_temp)/sqrt(effTBase));%cg; this cut off v for ii=1:length(y(:,1)); for jj=1:length(y(1,:)); - if y(ii,jj)>= cutoffval;%cg; + if y(ii,jj)>= cutoffval; y(ii,jj)= cutoffval; end end end +%------------------------- +%get dates etc. + filename_date=sprintf('%s_date',filename); fid_date = fopen(filename_date); -datein=textscan(fid_date, '%d %d %d %d %d %d %d');%once you have used textscan you are at the bottom of the file. +%datein=textscan(fid_date, '%d %d');%once you have used textscan you are at the bottom of the file. +datein=textscan(fid_date, '%d %d %d %d %d %d %d'); fclose(fid_date); -%so datein now contains a number of vectors each containing a number of cells. To access the vetcor datein{1} to datein{7}, and then -%I can used datein{1}(1) to datein{n}(n) +filename_time=sprintf('%s_timestamps',filename); +fid_times = fopen(filename_time); +timesin=textscan(fid_times, '%d %d') +fclose(fid_times); + +utcdate={}; + +for ii=1:xlen; + utcdate(ii)={sprintf('%d-%d-%d',datein{2}(ii),datein{3}(ii), datein{4}(ii) )}; + utctime(ii)={sprintf(' %d:%d:%d',datein{5}(ii),datein{6}(ii), datein{7}(ii) )}; +end + + +%get the start and end UTC time and date for the title +startDateTime = sprintf('%d/%d/%d %d:%d:%d',datein{2}(1),datein{3}(1), datein{4}(1), datein{5}(1),datein{6}(1), datein{7}(1) ); +endDateTime = sprintf('%d/%d/%d %d:%d:%d',datein{2}(xlen),datein{3}(xlen),datein{4}(xlen),datein{5}(xlen),datein{6}(xlen), datein{7}(xlen) ); +StStart = sprintf('%d',tStart); +StEnd = sprintf('%d',tEnd); + +%------------------------- +%cg; plot the spectrogram + +figure(1);%cg; creates a figure graphics object, -%cg; plot the spectrogram and the normalised average power. -%-------------------------------------------------------- -figure(1); %cg; creates a figure graphics object, this figure contains both plots -'thisisfig1' -%if (taveFlag > 0) - %subplot(2,1,1) %cg; subplot creates mulitple plots for adding to the figure. (2,1,1) specifies that the figure will be 2 plots deep by one plot across, and this is the first plot. If the line was subplot(2,1,1);plot(graph), then this would plot graph. This is only used if taveFlag > 0 and we intend to plot the normalised average power. Will need to get rid of the subplot bit for my modified code. -%end +%--------------------------- +%colormapping + +ymax=(max(max(y)));%find max and min values (min must not be zero). +ymin=(min(min(y_temp1))); +yrange=ymax-ymin; + + +log=0;%decide to plot log colour axis or not. + +if (log == 1) + indexdata=log10(y);%indexdata is log of y, note that zeros will become -ve infinity, as long as this is less than 1 it will get assigned to first colour in cmap1, as it should be, i.e. not need to change these values to 1. + imagesc(indexdata); +else + imagesc(y); + cymin=ymin-(yrange/254);%works out the size of a cbar slot assuming 254 slots (not 256) for yrange of data + caxis([cymin ymax]);%ensures that all data bar the zeros are scaled to slots 2 and above, and only one slot is used ymin and below (i.e. zeros) +end + +cmap1=colormap(jet(256));%three by 256 matrix. +cmap1(1,1,1)=0.85;%these three lines reset the first index in the colormap to white. +cmap1(1,2,1)=0.85; +cmap1(1,3,1)=0.85; + +colormap(cmap1); +colorbar('eastoutside'); +%------------------------------------------- +%deal with the Y axis -imagesc((y));%cg; this line creates the specgram. Lines after just label it up. Plots the matrix y. -xlabel('SFT number (see table for corresponding date)','FontSize',13); ylabel('frequency [Hz]','FontSize',13); + +%calc y axis ticks and labels % Show ticks every deltaFTicks Hz: -deltaFTicks = deltaFTicks/10.00; -deltaTicks = deltaFTicks * (effTBaseFull/effTBase);%cg; leave this line in, note its deltaTicks not deltaFTicks - -numTicks = floor((fEnd - fStart)/deltaFTicks);%cg; sorts out the labelling of the frequencies on the y axis -vecTicks = 1 + deltaTicks*(0:numTicks); %cg; creates vecticks,for ftsart = 56, fend= 57. from 0 to numticks (0-10), in 1.0, 1.2, 1.4 ...3.0 -vecTicks(numTicks + 1) = vecTicks(numTicks + 1) - 1; % for purpose of plot, adjust last tick. cg; for 1hz range this gets rid of everything from 2.1 to 3.0. -vecFLabels = fStart + deltaFTicks*(0:numTicks); %cg;this takes array 1.0, 1.2 ...2.0, multiplies by deltaFTicks (0.1) for this case, and adds to sfstart, so we now have 56.0, 56.1 -set(gca, 'YTick', vecTicks);%cg; gca is current axis handle. think this sets the x axis. vecTicks is 1,2,3,4,5, etc. or is it? -%set(gca, 'YTick', vecTicks); +deltaFTicks; +fRange=fEnd-fStart; +numbins=effTBase*fRange; % this is the total number of bins in the matrix passed from spec_avg.c +allf=(fStart:fEnd);%creates a 1D array with every freq between start and end in it, in aascending order. +vecFLabels = allf( (mod(allf,deltaFTicks)==0)|(allf == fEnd)|(allf==fStart) ); %keeps fStart and fEnd, plus any values that are integer multiples of deltaFTicks. + +%work out the bin numbers associated with these freq values. effTBase=bins per hz. +vecTicks=((vecFLabels-fStart)*effTBase)+1; +numTicks=length(vecTicks); +vecTicks(numTicks)=vecTicks(numTicks)-1; +%--------------------------------------------- +%deal with the x axis +xlabel('Time in days since start date','FontSize',13); +%calc x axis ticks and labels. Show a label every tenth of the width, and the first and last sft. +%deltaxticks=fix(xlen/10); %rounds to nearest whole number to zero. +deltaxticks=round(xlen/10); %rounds to nearest whole number to zero. +if (deltaxticks < 1 )%if in the inlikely circumstance there are less than 3 sfts, this will catch the error. + deltaxticks= 1; +end +xticks = (1:deltaxticks:xlen);%creates an array from 1 to xlen with deltaxticks intervals. +xnumticks= length(xticks); +xticks(xnumticks)=xlen; %makes sure the last x tick is at the end of the specgram. + + +for kk=1:xnumticks; + subsc=(xticks(kk)); + %xlabs(kk)= strcat(utcdate(subsc) ,utctime(subsc)); + %days = num2str( (double(timesin{2}(subsc) - tStart) / 86400),'%2.1f\n'); + days = num2str( (double(timesin{2}(subsc) - tStart) / 86400),'%4.2f\n'); + xlabs{kk}= days; +end + +% xlabs = num2str(xlabs,'%2.1f\n') +% cellxlabs=cellstr(xlabs) + +%-------------------------------------------- +%set the ticks and labels for the X Y axis +set(gca, 'YTick', vecTicks);%cg; gca is current axis handle. set(gca, 'YTickLabel', fliplr(vecFLabels)); -titleString = sprintf('Spectrogram for %s; GPS %d - %d s.' ,chanName,tStart,tEnd); + +set(gca, 'XTick', xticks); +set(gca, 'XTickLabel', xlabs); +%------------------------------------------- +%do the titles + +titleString = sprintf('Spectrogram for %s; %s to %s UTC.' ,chanName,startDateTime,endDateTime); title(titleString,'Interpreter','none'); -colorbar('eastoutside'); +%------------------------------------------- +%now plot the crab frequency of this image. + +if (pulsar ~= 0) %only run if crab is not 0 + %need to load in the crab file. + + filename_crab=sprintf('%s_crab',filename); + crab=load(filename_crab);%load in all the data from the crab output file + crabF = crab(:,3);%pick out the GW observed crab frequency + crabF=crabF';%transpose so this is 1 row deep by x no of cols, needed for sub2ind later. + hold on; + sftno=(1:xlen); + + %convert crabF so that it appears at correct place on plot + newcrabF=numbins+1-((crabF-fStart)*effTBase); + % newcrabF(1)%for testing + % size(crabF) + % size(newcrabF) + % size(sftno) + + plot(sftno,newcrabF, 'Color', [0,0,0], 'linestyle', '--'); + + %now find the time average noise power in the same bins as the crab freq + size(y_temp1)%use y_temp1 as its the data without the zeros. + size(y_temp2) + newcrabF(yzeros)=[];%get rid of the elements in newcrabF associated with the zero cols. + newcrabF=fix(newcrabF);%round all the values of newcrabF down so they refer to the specgram bin number. + yt_cols=( 1:length(newcrabF)); + cp_ind=sub2ind(size(y_temp1),newcrabF,yt_cols);%y_temp1 is raw values, y_temp2 is with higher values cut off. + crab_pow=y_temp1(cp_ind);%(newcrabF,yt_cols);%this produces a matrix not a vector as I want. + crab_pow_mean=mean(crab_pow) + + %for testing + % max(crab_pow) + % min(crab_pow) + %y(cp_ind)=ymax+ymax; + % newcrabF=fix(newcrabF)% for testing + % yt_cols=( 1:length(newcrabF)) + % y(newcrabF,yt_cols)=ymax+ymax; + +end %------------------------------------------- %cg, now print the outputs to a file. print('-dpng',[outputFileName '.png']); -set(gcf, 'PaperOrientation', 'landscape');%cg; gcf is current figure handle. -set(gcf, 'PaperPosition', [0 0 11 8.5]); +set(gcf, 'PaperUnits', 'centimeters'); +set (gcf, 'PaperOrientation', 'landscape', 'PaperType', 'A4', 'PaperPosition', [0 0 30 20] ); print('-dpdf','-loose',[outputFileName '.pdf']) +filename_fig=sprintf('%s.fig',filename); +saveas(1,filename_fig); + delete(1);%closes the figures. + +%------------------------------------------- +%------------------------------------------- + +%Now work on the normalised average power plot. + if (taveFlag > 0) %cg; the code below only executes if taveFlag > 0, this bit plots the normalised average power %subplot(2,1,2)cg; if printing the specgram and graph seperately, dont need this line. figure(2); @@ -132,37 +282,32 @@ if (taveFlag > 0) %cg; the code below only executes if taveFlag > 0, this bit pl fprintf(fid,'%f %f\n',fk(k),xout(k)); fprintf(fid2,'%f %f\n',fSorted(k),xoutSorted(k)); end - - stdev_xout = std(xout) - meanval_xout = mean(xout) - + stdev_xout = std(xout); + meanval_xout = mean(xout); % Read in timestamps file to find the number of SFTs used: timestampFileName = sprintf('%s_timestamps',filename); [ntmp, ttmp] = textread(timestampFileName,'%f %f'); % Computed expected 5 sigma cutoff for gaussian noise: cutoffmax = 1.0 + 5.0/sqrt(length(ntmp)); % avoid too small of a maximum cutoff: - if cutoffmax < 2; - cutoffmax = 2; + if cutoffmax < 4; + cutoffmax = 4; end % compute cutoff from data, but do not exceed cutoffmax: cutoff = meanval_xout+(5*stdev_xout); if cutoff > cutoffmax; cutoff = cutoffmax; end - for jj=1:length(xout); if xout(jj)>=cutoff;%cg; xout is one of the properties plotted. xout(jj)=cutoff; end end - - %cg; Plot the normalised average power vs freq %------------------------------------------------- %cg; this uses the blah_blah_blah_timeaverage file output fropm spec_avg.c plot(fk,xout) - titleString = sprintf('Spectrum for %s; averaged over GPS %d - %d s.',chanName,tStart,tEnd); + titleString = sprintf('Spectrum for %s; averaged over %s to %s UTC.' ,chanName,startDateTime,endDateTime);; title(titleString,'Interpreter','none'); ylabel('Normalized Average Power'); xlabel('Frequency (Hz)'); @@ -170,62 +315,128 @@ if (taveFlag > 0) %cg; the code below only executes if taveFlag > 0, this bit pl fclose(fid); fclose(fid2); - %cd; these lines put in to plot the normalised avergae power spectrum into a seperate file to the specgram. - %--------------- - - - - %-------------- - - if (thresholdSNR > 0) - % input the reference file and look for coincidence lines above thresholdSNR - %---------------------------------------------------------------------------- - timeaverageFileNameRef = sprintf('%s_timeaverage',referenceFile); - [fRef, xRef] = textread(timeaverageFileNameRef,'%f %f'); - outputTextFileLines = sprintf('%s_lines.txt',outputFileName); - fid3 = fopen(outputTextFileLines,'w'); - fprintf(fid3,'\n COINCIDENT LINES \n'); - fprintf(fid3,' \n'); - fprintf(fid3,' INPUT REFERENCE \n'); - fprintf(fid3,' Freq. (Hz) Power SNR Freq. (Hz) Power SNR \n'); - fprintf(fid3,' \n'); - xoutMean = mean(xout); - oneOverxoutSTD = 1.0/std(xout); - xRefMean = mean(xRef); - oneOverxRefSTD = 1.0/std(xRef); - SNRout = (xout - xoutMean)*oneOverxoutSTD; - SNRRef = (xRef - xRefMean)*oneOverxRefSTD; - lengthSNRout = length(SNRout); - skip = 0; - iMax = 0; - coincidenceBins = ceil(coinDF*effTBaseFull); - for j = 1:lengthSNRout - if (skip == 0) - jMin = j - coincidenceBins; - if (jMin < 1); jMin = 1; end; - jMax = j + coincidenceBins; - if (jMax > lengthSNRout); jMax = lengthSNRout; end; - [SNRoutmax, iMaxout] = max(SNRout(jMin:jMax)); - iMaxout = jMin + iMaxout - 1; - [SNRRefmax, iMaxRef] = max(SNRRef(jMin:jMax)); - iMaxRef = jMin + iMaxRef - 1; - if ( (SNRoutmax >= thresholdSNR) && (SNRRefmax >= thresholdSNR) ) - skip = 1; - fprintf(fid3,' %11.6f %9.4f %7.2f %11.6f %9.4f %7.2f\n',fk(iMaxout),xout(iMaxout),SNRoutmax,fRef(iMaxRef),xRef(iMaxRef),SNRRefmax); - end - else - if ((j - iMaxRef) > coincidenceBins) && ((j - iMaxout) > coincidenceBins); skip = 0; end; - end - end - fclose(fid3); - end - %--------------------------------------------------------------------------------- + if (thresholdSNR > 0)%only look for lines if threshold SNR has been set. + % input the reference file and look for coincidence lines above thresholdSNR + %---------------------------------------------------------------------------- + timeaverageFileNameRef = sprintf('%s_timeaverage',referenceFile); + [fRef, xRef] = textread(timeaverageFileNameRef,'%f %f'); + %set up file for outputting coindcident lines + %--------------------------------------------- + outputTextFileLines = sprintf('%s_coincident_lines.txt',outputFileName); + fid3 = fopen(outputTextFileLines,'w'); + fprintf(fid3,'\n COINCIDENT LINES \n'); + fprintf(fid3,' \n'); + fprintf(fid3,' INPUT REFERENCE \n'); + fprintf(fid3,' Freq. (Hz) Power SNR Freq. (Hz) Power SNR \n'); + fprintf(fid3,' \n'); + %---------------------------------------------- + %set up file for new lines + %---------------------------------------------- + outputTextFileNewLines = sprintf('%s_new_lines.txt',outputFileName); + fid4 = fopen(outputTextFileNewLines,'w'); + fprintf(fid4,'\n NEW LINES \n'); + fprintf(fid4,' \n'); + fprintf(fid4,' INPUT \n'); + fprintf(fid4,' Freq. (Hz) Power SNR \n'); + fprintf(fid4,' \n'); + %---------------------------------------------- + %set up file for old lines + %---------------------------------------------- + outputTextFileOldLines = sprintf('%s_old_lines.txt',outputFileName); + fid5 = fopen(outputTextFileOldLines,'w'); + fprintf(fid5,'\n OLD LINES \n'); + fprintf(fid5,' \n'); + fprintf(fid5,' INPUT \n'); + fprintf(fid5,' Freq. (Hz) Power SNR \n'); + fprintf(fid5,' \n'); + %---------------------------------------------- + %get variables ready for line finding. + %------------------------------------- + xoutMean = mean(xout); + oneOverxoutSTD = 1.0/std(xout); + xRefMean = mean(xRef); + oneOverxRefSTD = 1.0/std(xRef); + SNRout = (xout - xoutMean)*oneOverxoutSTD;%SNR of current data + SNRRef = (xRef - xRefMean)*oneOverxRefSTD;%SNR of reference data + lengthSNRout = length(SNRout); + skip = 0; + iMax = 0; + coincidenceBins = ceil(coinDF*effTBaseFull); %coinDF -- window in frequency to use when looking for coincident lines. This maybe works out the number of bins over which to compare lines. + + %now find the lines... + for j = 1:lengthSNRout %this loop checks every element in the timeaverage files, i.e. every line. + if (skip == 0)%if true look for coincident lines. + jMin = j - coincidenceBins;%finds the earliest bin for which to compare + if (jMin < 1); jMin = 1; end;%makes sure that jmin cant be less than 1. + jMax = j + coincidenceBins;%finds the latest bin for which to compare + if (jMax > lengthSNRout); jMax = lengthSNRout; end;%makes sure that jmax cant be off the end of the file. + [SNRoutmax, iMaxout] = max(SNRout(jMin:jMax));%finds the peak in the current window, and finds the bin number relative to j of this peak. Current data + iMaxout = jMin + iMaxout - 1;%finds position of peak in terms of j. + [SNRRefmax, iMaxRef] = max(SNRRef(jMin:jMax));%finds the peak in ref data in current window and bin number + iMaxRef = jMin + iMaxRef - 1;%finds position of peak in terms of j. + if ( (SNRoutmax >= thresholdSNR) && (SNRRefmax >= thresholdSNR) )%if both peaks are above the threshoild SNR it is a coincident line. + skip = 1;%dont check for lines again until outside of window + fprintf(fid3,' %11.6f %9.4f %7.2f %11.6f %9.4f %7.2f\n',fk(iMaxout),xout(iMaxout),SNRoutmax,fRef(iMaxRef),xRef(iMaxRef),SNRRefmax); + %add this entry to the lines array +% out=1; +% ii=1; +% while (ii < 11) && (out > 0) +% if fk(iMaxout) > snrlines(ii) +% snrlines(ii) = fk(iMaxout); +% snrfreqs = xout(iMaxout); +% out = 0; +% end +% ii=ii+1; +% end + %snrlines(j)=fk(iMaxout); + %snrfreqs(j)=xout(iMaxout); + elseif ( (SNRoutmax >= thresholdSNR) && (SNRRefmax < thresholdSNR) )%if current line is above thresh SNR but reference is not, it is a new line + skip = 1;%dont check for lines again until outside of window + fprintf(fid4,' %11.6f %9.4f %7.2f\n',fk(iMaxout),xout(iMaxout),SNRoutmax); +% out=1; +% ii=1; +% while (ii < 11) && (out > 0) +% if fk(iMaxout) > snrlines(ii) +% snrlines(ii) = fk(iMaxout); +% snrfreqs = xout(iMaxout); +% out = 0; +% end +% ii=ii+1; +% end + %snrlines(j)=fk(iMaxout); + %snrfreqs(j)=xout(iMaxout); + elseif ( (SNRoutmax < thresholdSNR) && (SNRRefmax >= thresholdSNR) )%if current line is above thresh SNR but reference is not, it is a new line + skip = 1;%dont check for lines again until outside of window + fprintf(fid5,' %11.6f %9.4f %7.2f\n',fk(iMaxout),xout(iMaxout),SNRoutmax); + end + else%if skip !=0, a coincident line has been found, so dont check the next bin until we are outisde of the window. + if ((j - iMaxRef) > coincidenceBins) && ((j - iMaxout) > coincidenceBins); skip = 0; end;%if this is true, it will look for coincident lines in the next bin, if not it will skip the next bin. Is true when j is outisde of window where coincident line ahs been found. + end + end + fclose(fid3); + fclose(fid4); + fclose(fid5); + end + %--------- + %now find and print to file the top ten lines in the lines array. + +% outputtopten = sprintf('%s_topten.txt',outputFileName); +% [snrlinesSorted,iSorted] = sort(snrlines,'descend'); +% snrfreqsSorted = snrfreqs(iSorted); +% fid = fopen(outputtopten,'w'); +% for k = 1:10 +% if (snrlinesSorted(k) > 0) +% fprintf(fid,'%f %f\n',snrlinesSorted(k),snrfreqsSorted(k)); +% end +% end + + %--------------------------------------------------------------------------------- outputFileName2 = sprintf('%s_2',outputFileName); print('-dpng',[outputFileName2 '.png']) - set(gcf, 'PaperOrientation', 'landscape'); - set(gcf, 'PaperPosition', [0 0 11 8.5]); + set(gcf, 'PaperUnits', 'centimeters'); + set (gcf, 'PaperOrientation', 'landscape', 'PaperType', 'A4', 'PaperPosition', [0 0 30 20] ); print('-dpdf','-loose',[outputFileName2 '.pdf']) delete(2); end diff --git a/lalapps/src/pulsar/fscan/spec_avg.c b/lalapps/src/pulsar/fscan/spec_avg.c index d14c1718a9e6961b4b51ff685b61d86287b51027..4881a10bbb5e3a427ca80b595b40a7521172dcf5 100644 --- a/lalapps/src/pulsar/fscan/spec_avg.c +++ b/lalapps/src/pulsar/fscan/spec_avg.c @@ -17,146 +17,575 @@ * MA 02111-1307 USA */ + +/*temporary rubbish bin for headers*/ +/*These are included in HeterodyneCrabPulsar files +#include <lal/LALStdlib.h> +#include <lal/AVFactories.h> +#include <lal/LALConstants.h> +#include <lal/BinaryPulsarTiming.h>*/ + + +/*end of temporary rubbish bin*/ + + + #include <lalapps.h> #include <lal/LALDatatypes.h> -#include <lal/LALStdlib.h> #include <lal/LALStdio.h> -#include <lal/AVFactories.h> #include <lal/UserInput.h> #include <lal/SFTfileIO.h> #include <lal/NormalizeSFTRngMed.h> + +/*LAL malloc header file*/ +#include <lal/LALMalloc.h> + +/* Not sure if I need these +#include <lal/LALBarycenter.h> +#include <lal/LALInitBarycenter.h> +#include <lal/SkyCoordinates.h> +#include <lal/DetectorSite.h> +#include <lal/SFTutils.h> +#include <lal/LALString.h> +#include <lal/Units.h> +#include <lal/TimeSeries.h> +#include <lal/XLALError.h> +#include <lal/LALRCSID.h> +#include <lal/LALAtomicDatatypes.h> +#include <lal/FrameCache.h> +#include <lal/FrameStream.h>*/ + +/*normal c header files*/ +/*test if these two headers are problem*/ #include <stdio.h> -#include <stdlib.h> #include <math.h> +#include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> +#include <lal/Date.h>/*cg; needed to use lal routine GPStoUTC, which is used to convert GPS seconds into UTC date*/ + +#define NUM 1000 /* used for defining structures such as crabOutput*/ + RCSID("$Id"); int main(int argc, char **argv) { - FILE *fp = NULL; - FILE *fp2 = NULL; - FILE *fp3 = NULL; - LALStatus status = blank_status; - - SFTCatalog *catalog = NULL; - SFTVector *sft_vect = NULL; - INT4 i,j,k; - UINT4 numBins, nSFT; - SFTConstraints constraints=empty_SFTConstraints; - LIGOTimeGPS startTime, endTime; - double avg; - REAL4 *timeavg; - REAL8 f; - CHAR outbase[128],outfile[128],outfile2[128],outfile3[128]; - - BOOLEAN help = 0; - CHAR *SFTpatt = NULL; - CHAR *IFO = NULL; - INT4 startGPS = 0; - INT4 endGPS = 0; - REAL8 f_min = 0.0; - REAL8 f_max = 0.0; - INT4 blocksRngMed = 101; - CHAR *outputBname = NULL; - - lalDebugLevel = 0; - LAL_CALL (LALGetDebugLevel(&status, argc, argv, 'v'), &status); - - LAL_CALL(LALRegisterBOOLUserVar (&status, "help", 'h', UVAR_HELP, "Print this help message", &help ), &status); - LAL_CALL(LALRegisterSTRINGUserVar(&status, "SFTs", 'I', UVAR_REQUIRED, "SFT location/pattern", &SFTpatt ), &status); - LAL_CALL(LALRegisterSTRINGUserVar(&status, "IFO", 'I', UVAR_REQUIRED, "Detector", &IFO ), &status); - LAL_CALL(LALRegisterINTUserVar (&status, "startGPS", 's', UVAR_REQUIRED, "Starting GPS time", &startGPS ), &status); - LAL_CALL(LALRegisterINTUserVar (&status, "endGPS", 'e', UVAR_REQUIRED, "Ending GPS time", &endGPS ), &status); - LAL_CALL(LALRegisterREALUserVar (&status, "fMin", 'f', UVAR_REQUIRED, "Minimum frequency", &f_min ), &status); - LAL_CALL(LALRegisterREALUserVar (&status, "fMax", 'F', UVAR_REQUIRED, "Maximum frequency", &f_max ), &status); - LAL_CALL(LALRegisterINTUserVar (&status, "blocksRngMed", 'w', UVAR_OPTIONAL, "Running Median window size", &blocksRngMed), &status); - LAL_CALL(LALRegisterSTRINGUserVar(&status, "outputBname", 'o', UVAR_OPTIONAL, "Base name of output files", &outputBname ), &status); - - LAL_CALL(LALUserVarReadAllInput(&status, argc, argv), &status); - if (help) - return(0); + FILE *fp = NULL; + FILE *fp2 = NULL; + FILE *fp3 = NULL; + FILE *fp4 = NULL; + FILE *fp5 = NULL; + FILE *fp6 = NULL; + LALStatus status = blank_status; + + SFTCatalog *catalog = NULL; + SFTVector *sft_vect = NULL; + INT4 i,j,k,l; + INT4 numBins, nSFT; + SFTConstraints constraints=empty_SFTConstraints; + LIGOTimeGPS startTime, endTime; + REAL8 avg =0; + REAL4 *timeavg =NULL; + REAL8 f =0; + CHAR outbase[256],outfile[256],outfile2[256],outfile3[256], outfile4[256], outfile5[256], outfile6[256]; + REAL8 NumBinsAvg =0; + REAL8 timebaseline =0; + /*CHAR *missing_sft;*/ + + BOOLEAN help = 0; + CHAR *SFTpatt = NULL; + CHAR *IFO = NULL; + INT4 startGPS = 0; + INT4 endGPS = 0; + REAL8 f_min = 0.0; + REAL8 f_max = 0.0; + REAL8 freqres =0.0; + INT4 blocksRngMed = 101; + CHAR *outputBname = NULL; + INT4 cur_epoch = 0, next_epoch = 0; + + /* these varibales are for converting GPS seconds into UTC time and date*/ + LALUnixDate date; + CHARVector *timestamp = NULL; + CHARVector *year_date = NULL; /*cg; creates a char vector*/ + REAL8Vector *timestamps=NULL; + + CHAR *psrInput = NULL; + CHAR *psrEphemeris = NULL; + /*========================================================================================================================*/ + + - startTime.gpsSeconds = startGPS; - startTime.gpsNanoSeconds = 0; - constraints.startTime = &startTime; +lalDebugLevel = 0; +LAL_CALL (LALGetDebugLevel(&status, argc, argv, 'v'), &status); + +LAL_CALL(LALRegisterBOOLUserVar (&status, "help", 'h', UVAR_HELP, "Print this help message", &help ), &status); +LAL_CALL(LALRegisterSTRINGUserVar(&status, "SFTs", 'p', UVAR_REQUIRED, "SFT location/pattern", &SFTpatt ), &status); +LAL_CALL(LALRegisterSTRINGUserVar(&status, "IFO", 'I', UVAR_REQUIRED, "Detector", &IFO ), &status); +LAL_CALL(LALRegisterINTUserVar (&status, "startGPS", 's', UVAR_REQUIRED, "Starting GPS time", &startGPS ), &status); +LAL_CALL(LALRegisterINTUserVar (&status, "endGPS", 'e', UVAR_REQUIRED, "Ending GPS time", &endGPS ), &status); +LAL_CALL(LALRegisterREALUserVar (&status, "fMin", 'f', UVAR_REQUIRED, "Minimum frequency", &f_min ), &status); +LAL_CALL(LALRegisterREALUserVar (&status, "fMax", 'F', UVAR_REQUIRED, "Maximum frequency", &f_max ), &status); +LAL_CALL(LALRegisterINTUserVar (&status, "blocksRngMed", 'w', UVAR_OPTIONAL, "Running Median window size", &blocksRngMed), &status); +LAL_CALL(LALRegisterSTRINGUserVar(&status, "outputBname", 'o', UVAR_OPTIONAL, "Base name of output files", &outputBname ), &status); +LAL_CALL(LALRegisterREALUserVar (&status, "freqRes", 'r', UVAR_REQUIRED, "Spectrogram freq resolution", &freqres ), &status); +LAL_CALL(LALRegisterREALUserVar (&status, "timeBaseline", 't', UVAR_REQUIRED, "The time baseline of sfts", &timebaseline), &status); +LAL_CALL(LALRegisterSTRINGUserVar(&status, "psrInput", 'P', UVAR_OPTIONAL, "name of tempo pulsar file", &psrInput ), &status); +LAL_CALL(LALRegisterSTRINGUserVar(&status, "psrEphemeris", 'S', UVAR_OPTIONAL, "pulsar ephemeris file", &psrEphemeris ), &status); + +LAL_CALL(LALUserVarReadAllInput(&status, argc, argv), &status); +if (help) +return(0); + +startTime.gpsSeconds = startGPS;/*cg; startTime is a structure, and gpsSeconds is a member of that structure*/ +startTime.gpsNanoSeconds = 0;/*cg; gps NanoSeconds is also a member of the startTime structure */ +constraints.startTime = &startTime; /*cg; apersand operator gets the address of a variable, &a is a pointer to a. This line puts the startTime structure into the structure constraints*/ + +endTime.gpsSeconds = endGPS; +endTime.gpsNanoSeconds = 0; +constraints.endTime = &endTime;/*cg; This line puts the end time into the structure constraints*/ +constraints.detector = IFO;/*cg; this adds the interferometer into the contraints structure*/ +LALSFTdataFind ( &status, &catalog,SFTpatt, &constraints );/*cg; creates SFT catalog, uses the constraints structure*/ +LALLoadSFTs ( &status, &sft_vect, catalog, f_min,f_max);/*cg;reads the SFT data into the structure sft_vect*/ +LALDestroySFTCatalog( &status, &catalog);/*cg; obvisouly desctroys the SFT catalogue*/ + +numBins = sft_vect->data->data->length;/*the number of bins in the freq_range*/ +nSFT = sft_vect->length;/* the number of sfts.*/ + +fprintf(stderr, "nSFT = %d\tnumBins = %d\tf0 = %f\n", nSFT, numBins,sft_vect->data->f0);/*cg; prints out these items into the file called spectrumAverage_testcg_0.err which is written to the logs folder.*/ +if (LALUserVarWasSet(&outputBname)) +strcpy(outbase, outputBname); +else +sprintf(outbase, "spec_%.2f_%.2f_%s_%d_%d", f_min,f_max,constraints.detector,startTime.gpsSeconds,endTime.gpsSeconds);/*cg; this is the default name for producing the output files, the different suffixes are just added to this*/ +sprintf(outfile, "%s", outbase);/*cg; name of first file to be output*/ +sprintf(outfile2, "%s_timestamps", outbase);/*cg: name of second file to be output*/ +sprintf(outfile3, "%s_timeaverage", outbase);/*cg; name of third file to be output*/ + +fp = fopen(outfile, "w");/*cg; open all three files for writing, if they don't exist create them, if they do exist overwrite them*/ +fp2 = fopen(outfile2, "w"); +fp3 = fopen(outfile3, "w"); + + +/*----------------------------------------------------------------------------------------------------------------*/ +/*cg; Create the first file, called blah_blah_blah*/ +/*cg; This file outputs very small numbers, one set of 100 numbers for each 1800 second SFT. The numbers are the strain values used in the spectrogram plots. The number of numbers here depends on the frequency range, freq range for this example is from 50Hz to 60Hz, so each Hz is split into 5, giving a freq resolution of 0.2Hz.*/ + + +/*cg; Create the second file, called blah_b;ah_blah_timestamps*/ +/*cg; This will simply contain the time in GPS seconds of each SFT. The time is the name of the SFT, which I am unsure if this refers to the start time, end time, or middle, but I think it is the start time. So this file will conatin a list of the items, starting with the last SFT first labeled 0. SFTno up to 2. SFTno for three SFTs, or more for more obvisouly.*/ + + NumBinsAvg = freqres*numBins/(f_max-f_min);/*this calcs the number of bins over which to average the sft data, this is worked out so it produces the same frequency resoltuion as specified in the arguments passed to the python script. numBins is the total number of bins in the raw sft data*/ + + /*startgps+(timebaseline*nSFT) will work out the time of that nSFT would start at IF there were no gaps in the data, where this is the case, replace the sft data with zeros.*/ + + l=0; + /*create output files and check for missing sfts*/ + for (j=0;j<nSFT;j++)/*cg;nSFT is the numnber of SFT files used for the time specified. So process is repeated for each SFT*/ + { + /*now I need to check if timebaseline+(n-1)sft_epoch = this sft_epoch, if not I need to create a element in the matrix of sft data that starts at timebaseline+(n-1)sft_epoch*/ + cur_epoch = sft_vect->data[j].epoch.gpsSeconds;/*finds the gps time of the current sft in the sequence with indicie j*/ + fprintf(fp2, "%d.\t%d\n", l, cur_epoch);/*cg; this bit writes the second file, i.e. the timestamps*/ - endTime.gpsSeconds = endGPS; - endTime.gpsNanoSeconds = 0; - constraints.endTime = &endTime; - constraints.detector = IFO; - LALSFTdataFind ( &status, &catalog,SFTpatt, &constraints ); - LALLoadSFTs ( &status, &sft_vect, catalog, f_min,f_max); - LALDestroySFTCatalog( &status, &catalog); - - numBins = sft_vect->data->data->length; - nSFT = sft_vect->length; - - fprintf(stderr, "nSFT = %d\tnumBins = %d\tf0 = %f\n", nSFT, numBins,sft_vect->data->f0); - if (LALUserVarWasSet(&outputBname)) - strcpy(outbase, outputBname); - else - sprintf(outbase, "spec_%.2f_%.2f_%s_%d_%d", f_min,f_max,constraints.detector,startTime.gpsSeconds,endTime.gpsSeconds); - sprintf(outfile, "%s", outbase); - sprintf(outfile2, "%s_timestamps", outbase); - sprintf(outfile3, "%s_timeaverage", outbase); - - fp = fopen(outfile, "w"); - fp2 = fopen(outfile2, "w"); - fp3 = fopen(outfile3, "w"); + for ( i=0; i < (numBins-2); i+=NumBinsAvg)/*cg; this loop works out the powers and writes the first file. += makes i increment by NumBinsAvg.*/ + {/*cg; each SFT is split up into a number of bins, the number of bins is read in from the SFT file*/ + avg = 0.0;/*cg; the vairable avg is reset each time.*/ + if (i+NumBinsAvg>numBins) {printf("Error\n");return(2);}/*cg; error is detected, to prevent referencing data past the end of sft_vect.*/ + for (k=0;k<NumBinsAvg;k++)/*cg; for each bin, k goes trhough each entry from 0 to 180.*/ + avg += sqrt(sft_vect->data[j].data->data[i+k].re*sft_vect->data[j].data->data[i+k].re + + sft_vect->data[j].data->data[i+k].im*sft_vect->data[j].data->data[i+k].im);/*cg; re amd im are real and imaginary parts of SFT, duh!*/ + fprintf(fp,"%e\t",avg/NumBinsAvg); + } + fprintf(fp,"\n"); + /*------------------------------*/ + /*Bit to check if there is a gap in the sfts*/ + if ( j < (nSFT-1) )/*in all cases except when we are examining the last sft, check that there is no gap to the next sft*/ + { + next_epoch = sft_vect->data[j+1].epoch.gpsSeconds; + + if (cur_epoch+timebaseline != next_epoch )/*if this returns true then the finishing time of current sft does not match starttime of the next sft.*/ + { + l=l+1; + cur_epoch = cur_epoch+timebaseline; + fprintf(fp2, "%d.\t%d\n", l, cur_epoch ); + + /*fill in blanks into the specgram matrix passed to matlab for the gap between the non con-current sfts*/ + for ( i=0; i < (numBins-2); i+=NumBinsAvg) + { + avg = 0.0; + if (i+NumBinsAvg>numBins) {printf("Error\n");return(2);} + fprintf(fp,"%e\t",avg); + } + fprintf(fp,"\n"); + /*test to see if SFT gap is longer than 3/2*timebaseline, if so create another entry in the matrix*/ + + while ( (cur_epoch + (0.5*timebaseline)) < next_epoch ) + { + for ( i=0; i < (numBins-2); i+=NumBinsAvg) + { + avg = 0.0; + if (i+NumBinsAvg>numBins) {printf("Error\n");return(2);} + fprintf(fp,"%e\t",avg); + } + fprintf(fp,"\n"); + l=l+1; + cur_epoch=cur_epoch+timebaseline; + fprintf(fp2, "%d.\t%d\n", l, cur_epoch ); + } + } + + } + /*----------------------------*/ + l=l+1; + } +fprintf(stderr,"finished checking for missing sfts, l=%d\n", l); +/*----------------------------------------------------------------------------------------------------------------*/ + /* Find time average of normalized SFTs */ +LALNormalizeSFTVect(&status, sft_vect, blocksRngMed); +LALNormalizeSFTVect(&status, sft_vect, blocksRngMed); +timeavg = XLALMalloc(numBins*sizeof(REAL4)); +if (timeavg == NULL) fprintf(stderr,"Timeavg memory not allocated\n"); for (j=0;j<nSFT;j++) { - /* fprintf(stderr, "sft %d out of %d\n", j, nSFT); */ - fprintf(fp2, "%d.\t%d\n", j, sft_vect->data[j].epoch.gpsSeconds); + for ( i=0; i < numBins; i++) + { + if (j == 0) + { + timeavg[i] = sft_vect->data[j].data->data[i].re*sft_vect->data[j].data->data[i].re + + sft_vect->data[j].data->data[i].im*sft_vect->data[j].data->data[i].im; + } + else + { + timeavg[i] += sft_vect->data[j].data->data[i].re*sft_vect->data[j].data->data[i].re + + sft_vect->data[j].data->data[i].im*sft_vect->data[j].data->data[i].im; + } + } + } +/*----------------------------------------------------------------------------------------------------------------*/ +/*cg; Create the third and final file, called blah_blah_blah_timeaverage. This file will contain the data used in the matlab plot script to plot the normalised average power vs the frequency.*/ + +/* Question to the group, the timeaverages are so far output for every freq bin in the raw data, independant of freq res chosen for the spectrogram, do we want this???*/ +/*timeavg records the power of each bin*/ + + +for ( i=0; i < numBins; i++) + { + f = sft_vect->data->f0 + ((REAL4)i)*sft_vect->data->deltaF; + fprintf(fp3,"%16.8f %g\n",f,timeavg[i]/((REAL4)nSFT)); + } + +/*------------------------------------------------------------------------------------------------------------------------*/ +/* CG; create a file containing the UTC times for each SFT GPS time.*/ +sprintf(outfile4, "%s_date", outbase);/*cg; sprintf prints into the char array outfile4, it prints a string followed by _date, the string is outbase.*/ +fp4 = fopen(outfile4, "w"); + +sprintf(outfile6, "%s_numbins", outbase); +fp6 = fopen(outfile6, "w"); +fprintf(fp6,"%f\n",NumBinsAvg); +fclose(fp6); + +LALCHARCreateVector(&status, ×tamp, (UINT4)256); /*128 is the number of elements in the vector, no need for it to be this big.*/ +LALCHARCreateVector(&status, &year_date, (UINT4)128); +timestamps = XLALCreateREAL8Vector(l+1); +/*times = XLALCreateREAL8Vector( MAXLENGTH );*/ - for ( i=0; i < (numBins-2); i+=180) +l=0; + +/*output the UTC time and date for use by matlab plotting script.*/ +for (j=0;j<nSFT;j++) +{ + /*fprintf(stderr,"here 2a, j=%d\n",j);*/ + cur_epoch = sft_vect->data[j].epoch.gpsSeconds; + /*gps.gpsSeconds = cur_epoch;*//*cg;stores GPS time in seconds into the structure gps, in the field gpsSeconds, for use in LALGPStoUTC function*/ + /*gps.gpsNanoSeconds=0;*//*cg; this sets the gps nanoseconds to 0*/ + + /*timestamps->data[l]= gps.gpsSeconds;*/ + timestamps->data[l]= cur_epoch; + + XLALGPSToUTC(&date, cur_epoch);/*cg; gets the UTC date in struct tm format from the GPS seconds.*/ + fprintf(fp4, "%d\t %i\t %i\t %i\t %i\t %i\t %i\n", l, (date.tm_year+1900), (date.tm_mon + 1), date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec); + /*------------------------------*/ + /*Bit to check if there is a gap in the sfts*/ + if ( j< (nSFT-1) )/*in all cases except when we are examining the last sft, check that there is no gap to the next sft*/ { - avg = 0.0; - if (i+180>numBins) {printf("Error\n");return(2);} - for (k=0;k<180;k++) - avg += sqrt(sft_vect->data[j].data->data[i+k].re*sft_vect->data[j].data->data[i+k].re + - sft_vect->data[j].data->data[i+k].im*sft_vect->data[j].data->data[i+k].im); - fprintf(fp,"%e\t",avg/180.0); + next_epoch = sft_vect->data[j+1].epoch.gpsSeconds;/*p->x, if p is a pointer then this expression gets the member of that structure. The datat subscript starts at zero and runs to nSFT-1, there is no data[nSFT]!!! */ + /*cur_epoch = sft_vect->data[j].epoch.gpsSeconds;*/ + if (cur_epoch+timebaseline != next_epoch )/*if this returns true then the finishing time of current sft does not match starttime of the next sft.*/ + { + l=l+1; + cur_epoch = cur_epoch+timebaseline;/*calcs the timestamp to be used for the gap, this is the end of the last sft before the gap*/ + + timestamps->data[l]= cur_epoch; + + XLALGPSToUTC(&date, cur_epoch); + fprintf(fp4, "%d\t %d\t %d\t %d\t %d\t %d\t %d\n", l, (date.tm_year+1900), (date.tm_mon + 1), date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec); + + while ( (cur_epoch + (0.5*timebaseline)) < next_epoch ) + { + l=l+1; + + XLALGPSToUTC(&date, cur_epoch); + fprintf(fp4, "%d\t %d\t %d\t %d\t %d\t %d\t %d\n", l, (date.tm_year+1900), (date.tm_mon + 1), date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec); + + timestamps->data[l]= cur_epoch; + cur_epoch=cur_epoch+timebaseline;/*increment cur_epoch to test if there is still a long gap that needs spliiting*/ + } + } } - fprintf(fp,"\n"); + /*----------------------------*/ + l=l+1; + /*fprintf(stderr,"here 2c, j=%d\n",j);*/ } - - /* Find time average of normalized SFTs */ - LALNormalizeSFTVect(&status, sft_vect, blocksRngMed); - timeavg = (REAL4 *)LALMalloc(numBins*sizeof(REAL4)); - for (j=0;j<nSFT;j++) - { - for ( i=0; i < numBins; i++) + fprintf(stderr,"number of timestamps: %d\n",l); + /*fprintf(fp4, "%u\n", year_date->length);*/ /*just used this as a test line*/ + /*fprintf(fp4, "%u\n", year_date->length);*/ /*just used this as a test line*/ + + /*================================================================================================================*/ + /*================================================================================================================*/ + + + /*This next block of code is for the crab specific changes to fscan*/ + + #define CRAB 0 + /*change this to CRAB 0 to prevent this section of code from compiling, change to 1 to compile it.*/ + + #if CRAB + /*--------------------------------------------------------------------------------------------------------------*/ + /*some header files for the crab*/ + /*#include "../TDS_isolated/HeterodyneCrabPulsar.h"*/ + /*#include "../TDS_isolated/heterodyne_pulsar.h"*/ + #include<HeterodyneCrabPulsar.h> + + fprintf(stderr,"start of crab stuff\n"); + LIGOTimeGPS dataEpoch; + /*below 4 structures are from HeterodyneCrabPulsar.h*/ + GetCrabEphemerisInput input; /*this is needed to get the crab ephemeris*/ + CrabSpindownParamsInput crabEphemerisData; + CrabSpindownParamsOutput crabOutput; + ParamsForHeterodyne hetParams; + + /*CG; these lines allocate memory for the crab ephemeris and crab output variables...*/ + crabEphemerisData.f1 = NULL; + LALDCreateVector( &status, &crabEphemerisData.f1, NUM); + + crabEphemerisData.f0 = NULL; + LALDCreateVector( &status, &crabEphemerisData.f0, NUM); + + crabEphemerisData.tArr = NULL; + LALDCreateVector( &status, &crabEphemerisData.tArr, NUM); + + crabOutput.tArr = NULL; + LALDCreateVector( &status, &crabOutput.tArr, NUM); + + crabOutput.f0 = NULL; + LALDCreateVector( &status, &crabOutput.f0, NUM); + + crabOutput.f1 = NULL; + LALDCreateVector( &status, &crabOutput.f1, NUM); + + crabOutput.f2 = NULL; + LALDCreateVector( &status, &crabOutput.f2, NUM); + + crabOutput.f3 = NULL; + LALDCreateVector( &status, &crabOutput.f3, NUM); + + crabOutput.f4 = NULL; + LALDCreateVector( &status, &crabOutput.f4, NUM); + + + /*This next set of variables are to do with the doppler shifts that are then applied to to the crab feq.*/ + REAL8 t2=0., tdt=0.; + EphemerisData *edat=NULL; + BarycenterInput baryinput, baryinput2; + EarthState earth, earth2; + EmissionTime emit, emit2; + REAL8 df=0., freq, finalFreq; + REAL8 dtpos=0.; /* time between position epoch and data timestamp */ + BinaryPulsarParams pulsarParams; /*general pulsar params strcut, despite binary name*/ + /*CHAR *psrInput = NULL;*/ /* pulsar input file containing params f0, f1 etc. */ + LALDetector det; + CHAR detName[256]; + + /*----------------------------------------------------------------------------------------------------------------*/ + /*for debuging */ + sprintf(outfile5, "%s_crab", outbase); + fp5 = fopen(outfile5, "w"); + + /*cg; calculating the crab freq, done in three steps*/ + /*this needs to be done for each sft, so need some sort of iteration*/ + + /*----------------------------------------------------------------------------------------------------------------*/ + /* ---1--- */ + /*Find rough guess of crabs freq from ephemeris*/ + /*----------------------------------------------------------------------------------------------------------------*/ + + /*Get detector position, this is needed for barycentre calcs*/ + det = *XLALGetSiteInfo( IFO ); + + /* read in tempo par file for pulsar, This is one of the optional command line arguments*/ + /*fprintf(stderr,"%s\n",psrInput);*/ + + /*psrInput="../B0531+21";*//*../B0531+21" psrInput is now read in from the command line arguments and passed to this code*/ + /*fprintf(stderr,"%s\n",psrInput);*/ + XLALReadTEMPOParFile(&pulsarParams, psrInput); + + /*Make sure that posepoch and pepoch are set*/ + if(pulsarParams.pepoch == 0. && pulsarParams.posepoch != 0.) + pulsarParams.pepoch = pulsarParams.posepoch; + else if(pulsarParams.posepoch == 0. && pulsarParams.pepoch != 0.) + pulsarParams.posepoch = pulsarParams.pepoch; + /*fprintf(stderr,"Check on read tempo file, pepoch: %f\n", pulsarParams.pepoch);*/ + + /*input.filename=psrEphemeris;*/ /*/archive/home/colingill/lalsuite/lalapps/src/pulsar/fscan/ /archive/home/colingill/public_html/crab_ephemeris.txt*/ + input.filename = XLALMalloc(sizeof(CHAR)*256); + if(input.filename == NULL) fprintf(stderr,"input.filename pointer memory not allocated\t"); + + strcpy(input.filename,psrEphemeris); + /*fprintf(stderr,"psrEphemeris:%s\n", input.filename);*/ + + /*The first stage is to read in f and fdot from the ephemeris, the ephemeris file is part of lalapps and is maintained by matt*/ + LALGetCrabEphemeris( &status, &crabEphemerisData, &input ); + /*check on the oputputs, crabEphemerisData is a struct of type CrabSpindownParamsInput, and has members tArr, f0, f1*/ + /*fprintf(stderr,"input crab ephemeris present, number of entries: %i\n", crabEphemerisData.numOfData); + fprintf(stderr,"crabEphemerisData:\t%f\t%f\t%f\n", crabEphemerisData.tArr->data[0], crabEphemerisData.f0->data[0], crabEphemerisData.f1->data[0]);*/ + + /*Now I have f and fdot, use function below to compute the higher order derrivatives of the crabs frequency*/ + LALComputeFreqDerivatives( &status, &crabOutput, &crabEphemerisData ); + /*check on this function, crabOutput is datatype CrabSpindownParamsOutput*/ + /*fprintf(stderr,"crabOutput:\t%f\t%f\t%f\n", crabOutput.f0->data[0], crabOutput.f1->data[0], crabOutput.f2->data[0]);*/ + + /*Allocate memory for edat, no need to do in the loop*/ + edat = XLALMalloc(sizeof(*edat)); + (*edat).ephiles.earthEphemeris = "/archive/home/colingill/lalsuite/lalapps/src/pulsar/fscan/earth05-09.dat"; + (*edat).ephiles.sunEphemeris = "/archive/home/colingill/lalsuite/lalapps/src/pulsar/fscan/sun05-09.dat"; + + + for (i=0;i<l;i++) { - if (j == 0) { - timeavg[i] = sft_vect->data[j].data->data[i].re*sft_vect->data[j].data->data[i].re + - sft_vect->data[j].data->data[i].im*sft_vect->data[j].data->data[i].im; - } else { - timeavg[i] += sft_vect->data[j].data->data[i].re*sft_vect->data[j].data->data[i].re + - sft_vect->data[j].data->data[i].im*sft_vect->data[j].data->data[i].im; + /*fprintf(stderr,"iteration number: %d\t", i);*/ + if (i == (l-1))/*catches the last iteration where there is no i+1 entry in timestamps*/ + { + cur_epoch = timestamps->data[i]+(timebaseline/2); + /*fprintf(stderr,"EXCEPTION CAUGHT 1\t");*/ + } + else + { + cur_epoch = timestamps->data[i]+((timestamps->data[i+1] - timestamps->data[i])/2); } + + /*fprintf(stderr,"cur_epoch: %d\t", cur_epoch);*/ + /*The time has to be set so that the nearest entry to that time in the ephemeris can be used*/ + dataEpoch.gpsSeconds = cur_epoch; /*INT8)floor(time->data[j]);*/ + dataEpoch.gpsNanoSeconds = 0; + + /*prepare hetParams, which is then used to get the freq derrivatives out and also in the next sub-section for Bary functions*/ + LALSetSpindownParams( &status, &hetParams, &crabOutput, dataEpoch ); + /*fprintf(fp5,"hetparams:\t%f\t%f\t%f\n", hetParams.epoch, hetParams.f0, hetParams.f1);*/ + + /*----------------------------------------------------------------------------------------------------------------*/ + /* ---2--- */ + /*Add corrections for timing noise to get a better guess at the freq*/ + /*----------------------------------------------------------------------------------------------------------------*/ + + /*now I want to use these params to calc the freq at any point in time. Using the higher order derrivatives is how we adjust for timing noise.*/ + + /*Get the time difference between the current epoch and the epoch of the ephemeris entry*/ + tdt= cur_epoch - hetParams.epoch; + /*fprintf(fp5,"current epoch: %i\tephemeris epoch: %f\t delta t: %f\n", cur_epoch, hetParams.epoch, tdt);*/ + + freq = 2.0*( hetParams.f0 + ((hetParams.f1)*tdt) + (((hetParams.f2)*tdt*tdt)/2) + (((hetParams.f3)*tdt*tdt*tdt)/6) + (((hetParams.f4)*tdt*tdt*tdt*tdt)/24) ); + /*fprintf(fp5,"crab fcoarse: %f\n", freq);*/ + + /*freq = 2.0*(params->f0 + params->f1*t1 + (params->f2)*t1*t1+ (params->f3)*t1*t1*t1 + (params->f4)*t1*t1*t1*t1);*/ /*cg;line 486 from hetcrabpulsar, works out freq, this is with one order of t removed for each of the derrivatives of f, and also each term is divided by a factorial, 1!, 2!, 3!, but this starts one term along from the oroginal code as we have integrated the orginal code to get freq not phase*/ + + /*----------------------------------------------------------------------------------------------------------------*/ + /* ---3--- */ + /*Add doppler shifts for earth's motion back onto the freq to get actual observed freq at detectors.*/ + /*----------------------------------------------------------------------------------------------------------------*/ + + /*now I have the freq, I need to add the doppler shift for the earths motion around the sun */ + baryinput.dInv = 0.;/*I can always set this to zero, as Matt said so, I must ask him why*/ + + LAL_CALL( LALInitBarycenter(&status, edat), &status );/* */ + + /*this lines take position of detector which are in xyz coords in meters from earths centre and converts them into seconds (time)*/ + baryinput.site.location[0] = det.location[0]/LAL_C_SI; + baryinput.site.location[1] = det.location[1]/LAL_C_SI; + baryinput.site.location[2] = det.location[2]/LAL_C_SI; + + /*dtpos should be the time between the entry in the ephemeris and the point in time for which doppler shifts are being calc.ed*/ + dtpos = cur_epoch - pulsarParams.posepoch; + + /* set up RA, DEC, and distance variables for LALBarycenter*/ + baryinput.delta = pulsarParams.dec + dtpos*pulsarParams.pmdec; + baryinput.alpha = pulsarParams.ra + dtpos*pulsarParams.pmra/cos(baryinput.delta); + + t2=cur_epoch+1; + + baryinput2 = baryinput; + + baryinput.tgps.gpsSeconds = (INT4)floor(cur_epoch); + baryinput.tgps.gpsNanoSeconds = (INT4)floor((fmod(cur_epoch,1.0)*1.e9)); + + baryinput2.tgps.gpsSeconds = (INT4)floor(t2); + baryinput2.tgps.gpsNanoSeconds = (INT4)floor((fmod(t2,1.0)*1.e9)); + + /*the barycentre functions are needed to calc the inputs for the correction to fcoarse, namely emit, earth and baryinput*/ + LAL_CALL( LALBarycenterEarth(&status, &earth, &baryinput.tgps, edat), &status ); + LAL_CALL( LALBarycenter(&status, &emit, &baryinput, &earth), &status ); + + LAL_CALL( LALBarycenterEarth(&status, &earth2, &baryinput2.tgps, edat), &status ); + LAL_CALL( LALBarycenter(&status, &emit2, &baryinput2, &earth2), &status ); + + /* I need to calc the correction to the freq for the doppler shifts, the correction is df, from line 1074 heterdyne_pulsar. Note this correction is a gradient.*/ + df = freq*(emit2.deltaT - emit.deltaT); + finalFreq=freq+df; + /*df = fcoarse*(emit2.deltaT - emit.deltaT + binOutput2.deltaT - binOutput.deltaT);*//*use when have binary calcs in here also.*/ + fprintf(fp5,"%f\t%f\t%f\n", freq, df, finalFreq); + /*fprintf(stderr,"crab freq calc, i: %d, f: %f\n", i, finalFreq);*/ + + /*----------------------------------------------------------------------------------------------------------------*/ } + fclose(fp5); + fprintf(stderr,"end of crab stuff\n"); + + /*Free up any memory allocated in crab section*/ + XLALFree(edat); + + #endif + + fprintf(stderr,"end of spec_avg 1\n"); + + /*=======================================================================================================================*/ + /*=======================================================================================================================*/ + - } - for ( i=0; i < numBins; i++) - { - f = sft_vect->data->f0 + ((REAL4)i)*sft_vect->data->deltaF; - fprintf(fp3,"%16.8f %g\n",f,timeavg[i]/((REAL4)nSFT)); - } + /*release a;; the allocaeted memory*/ + LALCHARDestroyVector(&status, ×tamp); + LALCHARDestroyVector(&status, &year_date); + LALDestroySFTVector (&status, &sft_vect ); - LALDestroySFTVector (&status, &sft_vect ); - LALFree(timeavg); + fprintf(stderr,"end of spec_avg 2\n"); - fclose(fp); - fclose(fp2); - fclose(fp3); + if (timeavg != NULL) XLALFree(timeavg); - LAL_CALL(LALDestroyUserVars(&status), &status); + fprintf(stderr,"end of spec_avg 3\n"); + + LAL_CALL(LALDestroyUserVars(&status), &status); + + fprintf(stderr,"end of spec_avg 4\n"); + /*close all the files, spec_avg.c is done, all info written to the files.*/ + fclose(fp); + fclose(fp2); + fclose(fp3); + fclose(fp4); + + fprintf(stderr,"end of spec_avg 5\n"); + + return(0); - return(0); } /* END main */ diff --git a/lalapps/src/pulsar/hough/src/DriveHoughMulti.c b/lalapps/src/pulsar/hough/src/DriveHoughMulti.c index 23bab05d7363dd147a9c51e52b3578ee75106522..c0b0499dbf8e5b314e87e13ea475b366b397271d 100644 --- a/lalapps/src/pulsar/hough/src/DriveHoughMulti.c +++ b/lalapps/src/pulsar/hough/src/DriveHoughMulti.c @@ -670,17 +670,12 @@ int main(int argc, char *argv[]){ { MultiNoiseWeights *multweight = NULL; MultiPSDVector *multPSD = NULL; - INT4 tmpLeap; UINT4 j; - /* LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; */ - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_LOOSE}; /* get ephemeris */ edat = (EphemerisData *)LALCalloc(1, sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = uvar_earthEphemeris; (*edat).ephiles.sunEphemeris = uvar_sunEphemeris; - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; LAL_CALL( LALInitBarycenter( &status, edat), &status); diff --git a/lalapps/src/pulsar/hough/src/DriveHough_v3.c b/lalapps/src/pulsar/hough/src/DriveHough_v3.c index 2f23d2c92664f01276a49def42ff2ee6019a800a..f45e326bdf5a362ec5f4a3dfd5cced98f4f211b8 100644 --- a/lalapps/src/pulsar/hough/src/DriveHough_v3.c +++ b/lalapps/src/pulsar/hough/src/DriveHough_v3.c @@ -538,13 +538,7 @@ int main(int argc, char *argv[]){ { VelocityPar velPar; REAL8 vel[3]; - UINT4 j; - - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 tmpLeap; /* need this because Date pkg defines leap seconds as - INT4, while EphemerisData defines it to be INT2. This won't - cause problems before, oh, I don't know, the Earth has been - destroyed in nuclear holocaust. -- dwchin 2004-02-29 */ + UINT4 j; velPar.detector = *detector; velPar.tBase = timeBase; @@ -556,11 +550,6 @@ int main(int argc, char *argv[]){ (*edat).ephiles.earthEphemeris = uvar_earthEphemeris; (*edat).ephiles.sunEphemeris = uvar_sunEphemeris; - /* Leap seconds for the start time of the run */ - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &(timeV->data[0]), &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; - /* (*edat).leap = 13; <<<<<<< Correct this */ - /* read in ephemeris data */ LAL_CALL( LALInitBarycenter( &status, edat), &status); velPar.edat = edat; diff --git a/lalapps/src/pulsar/hough/src/HoughValidate.c b/lalapps/src/pulsar/hough/src/HoughValidate.c index 8a63c381dad89849d23517f696439b36b5fb445a..8144773c6e1d51ab4f4d1c84498cce46ad71bc65 100644 --- a/lalapps/src/pulsar/hough/src/HoughValidate.c +++ b/lalapps/src/pulsar/hough/src/HoughValidate.c @@ -401,22 +401,12 @@ int main(int argc, char *argv[]){ VelocityPar velPar; REAL8 vel[3]; UINT4 j; - - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 tmpLeap; /* need this because Date pkg defines leap seconds as - INT4, while EphemerisData defines it to be INT2. This won't - cause problems before, oh, I don't know, the Earth has been - destroyed in nuclear holocaust. -- dwchin 2004-02-29 */ - + velPar.detector = *detector; velPar.tBase = timeBase; velPar.vTol = ACCURACY; velPar.edat = NULL; - - /* Leap seconds for the start time of the run */ - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &(timeV.data[0]), &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; - + /* read in ephemeris data */ LAL_CALL( LALInitBarycenter( &status, edat), &status); velPar.edat = edat; @@ -468,7 +458,6 @@ int main(int argc, char *argv[]){ amParams->das->pSource->orientation = 0.0; amParams->das->pSource->equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; amParams->polAngle = amParams->das->pSource->orientation ; /* These two have to be the same!!*/ - amParams->leapAcc = LALLEAPSEC_STRICT; /* timeV is start time ---> change to mid time */ LAL_CALL (LALComputeAM(&status, &amc, timeV.data, amParams), &status); diff --git a/lalapps/src/pulsar/hough/src/MCInjectHoughMulti.c b/lalapps/src/pulsar/hough/src/MCInjectHoughMulti.c index e4b51efb5ae4adaad88965ddf0e83e0b541386b3..9588a170a284fa41680aedf2882fe09679421cd6 100644 --- a/lalapps/src/pulsar/hough/src/MCInjectHoughMulti.c +++ b/lalapps/src/pulsar/hough/src/MCInjectHoughMulti.c @@ -509,14 +509,10 @@ int main(int argc, char *argv[]){ edat = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = uvar_earthEphemeris; (*edat).ephiles.sunEphemeris = uvar_sunEphemeris; - + { - INT4 tmpLeap; UINT4 iIFO, iSFT, numsft, j; - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; + LAL_CALL( LALInitBarycenter( &status, edat), &status); /* get information about all detectors including velocity and timestamps */ diff --git a/lalapps/src/pulsar/hough/src/MCInjectHoughMultiChi2Test.c b/lalapps/src/pulsar/hough/src/MCInjectHoughMultiChi2Test.c index 32786f7543f0c0c1fc1f0b1473f6d61a0c6fd909..5e29169d696e7bb08e884054a2838d6abf9f9a68 100644 --- a/lalapps/src/pulsar/hough/src/MCInjectHoughMultiChi2Test.c +++ b/lalapps/src/pulsar/hough/src/MCInjectHoughMultiChi2Test.c @@ -537,12 +537,8 @@ int main(int argc, char *argv[]){ (*edat).ephiles.sunEphemeris = uvar_sunEphemeris; { - INT4 tmpLeap; UINT4 iIFO, iSFT, numsft, j; - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; + LAL_CALL( LALInitBarycenter( &status, edat), &status); /* get information about all detectors including velocity and timestamps */ diff --git a/lalapps/src/pulsar/hough/src/MCInjectHoughS2.c b/lalapps/src/pulsar/hough/src/MCInjectHoughS2.c index 312766566ace54f8b4513efb65e4533cadc34327..01509fe414033f033361b3f35d63962b20944676 100644 --- a/lalapps/src/pulsar/hough/src/MCInjectHoughS2.c +++ b/lalapps/src/pulsar/hough/src/MCInjectHoughS2.c @@ -559,22 +559,12 @@ int main(int argc, char *argv[]){ VelocityPar velPar; REAL8 vel[3]; UINT4 j; - - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 tmpLeap; /* need this because Date pkg defines leap seconds as - INT4, while EphemerisData defines it to be INT2. This won't - cause problems before, oh, I don't know, the Earth has been - destroyed in nuclear holocaust. -- dwchin 2004-02-29 */ - + velPar.detector = detector; velPar.tBase = timeBase; velPar.vTol = ACCURACY; velPar.edat = NULL; - - /* Leap seconds for the start time of the run */ - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &(timeV->data[0]), &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; - + /* read in ephemeris data */ LAL_CALL( LALInitBarycenter( &status, edat), &status); velPar.edat = edat; diff --git a/lalapps/src/pulsar/hough/src/MultiWeights.c b/lalapps/src/pulsar/hough/src/MultiWeights.c index 8e170bd97408a494520eca19a4a57ea952f59bbf..40c1038af1cd4eb3bdd8c8065dfd5e661e72bd77 100644 --- a/lalapps/src/pulsar/hough/src/MultiWeights.c +++ b/lalapps/src/pulsar/hough/src/MultiWeights.c @@ -311,16 +311,12 @@ int main(int argc, char *argv[]){ { MultiNoiseWeights *multweight = NULL; MultiPSDVector *multPSD = NULL; - INT4 tmpLeap; UINT4 iIFO, iSFT, j; - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; /* get ephemeris */ edat = (EphemerisData *)LALCalloc(1, sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = uvar_earthEphemeris; (*edat).ephiles.sunEphemeris = uvar_sunEphemeris; - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; LAL_CALL( LALInitBarycenter( &status, edat), &status); /* set up weights */ diff --git a/lalapps/src/pulsar/hough/src/ValidateHoughMulti.c b/lalapps/src/pulsar/hough/src/ValidateHoughMulti.c index b20a0ec6279e193760a4d6f7febe84f71055b9da..d604a737e5401f761120d8ee76e71b040aae0ad8 100644 --- a/lalapps/src/pulsar/hough/src/ValidateHoughMulti.c +++ b/lalapps/src/pulsar/hough/src/ValidateHoughMulti.c @@ -354,16 +354,12 @@ int main(int argc, char *argv[]){ { MultiNoiseWeights *multweight = NULL; MultiPSDVector *multPSD = NULL; - INT4 tmpLeap; UINT4 iIFO, iSFT, j; - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; /* get ephemeris */ edat = (EphemerisData *)LALCalloc(1, sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = uvar_earthEphemeris; (*edat).ephiles.sunEphemeris = uvar_sunEphemeris; - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; LAL_CALL( LALInitBarycenter( &status, edat), &status); diff --git a/lalapps/src/pulsar/hough/src/ValidateHoughMultiChi2Test.c b/lalapps/src/pulsar/hough/src/ValidateHoughMultiChi2Test.c index 095521ac5f94d5a8684fb5b3a493e3ab6496dfc2..1552773933700afccd2f75944c235ff92f7a13f0 100644 --- a/lalapps/src/pulsar/hough/src/ValidateHoughMultiChi2Test.c +++ b/lalapps/src/pulsar/hough/src/ValidateHoughMultiChi2Test.c @@ -405,16 +405,12 @@ int main(int argc, char *argv[]){ { MultiNoiseWeights *multweight = NULL; MultiPSDVector *multPSD = NULL; - INT4 tmpLeap; UINT4 iIFO, iSFT, j; - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; /* get ephemeris */ edat = (EphemerisData *)LALCalloc(1, sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = uvar_earthEphemeris; (*edat).ephiles.sunEphemeris = uvar_sunEphemeris; - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &firstTimeStamp, &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; LAL_CALL( LALInitBarycenter( &status, edat), &status); diff --git a/lalapps/src/pulsar/hough/src/Validation2a.c b/lalapps/src/pulsar/hough/src/Validation2a.c index 27b75b96da3213c7ee264e76ec1fc514a18d2bfd..027aac310361e2f6f0fbfc26e043222014495968 100644 --- a/lalapps/src/pulsar/hough/src/Validation2a.c +++ b/lalapps/src/pulsar/hough/src/Validation2a.c @@ -335,8 +335,6 @@ int main(int argc, char *argv[]){ edat = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = earthEphemeris; (*edat).ephiles.sunEphemeris = sunEphemeris; - /* is this the right number of leap seconds? */ - (*edat).leap = 13; /* read in ephemeris data */ SUB( LALInitBarycenter( &status, edat), &status); diff --git a/lalapps/src/pulsar/hough/src/Validation2b.c b/lalapps/src/pulsar/hough/src/Validation2b.c index c71f58c0180e1aec79fc606f325c66c7abcb22d6..726a17addd7fc918450c0c89b06f615020336ddd 100644 --- a/lalapps/src/pulsar/hough/src/Validation2b.c +++ b/lalapps/src/pulsar/hough/src/Validation2b.c @@ -335,8 +335,6 @@ int main(int argc, char *argv[]){ edat = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); (*edat).ephiles.earthEphemeris = earthEphemeris; (*edat).ephiles.sunEphemeris = sunEphemeris; - /* is this the right number of leap seconds? */ - (*edat).leap = 13; /* read in ephemeris data */ SUB( LALInitBarycenter( &status, edat), &status); diff --git a/lalapps/src/pulsar/hough/src2/HierarchicalSearch.c b/lalapps/src/pulsar/hough/src2/HierarchicalSearch.c index 8fb1403785f71886272207cc770f1fecada4b413..e97eb0629ba480af74690d634a9dfec0d08222fd 100644 --- a/lalapps/src/pulsar/hough/src2/HierarchicalSearch.c +++ b/lalapps/src/pulsar/hough/src2/HierarchicalSearch.c @@ -205,7 +205,7 @@ void GetStackVelPos( LALStatus *status, REAL8VectorSequence **velStack, REAL8Vec void SetUpSFTs( LALStatus *status, MultiSFTVectorSequence *stackMultiSFT, MultiNoiseWeightsSequence *stackMultiNoiseWeights, MultiDetectorStateSeriesSequence *stackMultiDetStates, UsefulStageVariables *in); -void PrintFstatVec (LALStatus *status, REAL8FrequencySeries *in, FILE *fp, PulsarDopplerParams *thisPoint, +void PrintFstatVec (LALStatus *status, REAL4FrequencySeries *in, FILE *fp, PulsarDopplerParams *thisPoint, LIGOTimeGPS refTime, INT4 stackIndex); void PrintSemiCohCandidates(LALStatus *status, SemiCohCandidateList *in, FILE *fp, LIGOTimeGPS refTime); @@ -317,7 +317,7 @@ int MAIN( int argc, char *argv[]) { UINT4 nf1dot, nf1dotRes; /* coarse and fine grid number of spindown values */ /* LALdemod related stuff */ - static REAL8FrequencySeriesVector fstatVector; /* Fstatistic vectors for each stack */ + static REAL4FrequencySeriesVector fstatVector; /* Fstatistic vectors for each stack */ UINT4 binsFstat1, binsFstatSearch; static ComputeFParams CFparams; @@ -857,7 +857,7 @@ int MAIN( int argc, char *argv[]) { /* allocate some fstat memory */ fstatVector.length = nStacks; fstatVector.data = NULL; - fstatVector.data = (REAL8FrequencySeries *)LALCalloc( 1, nStacks * sizeof(REAL8FrequencySeries)); + fstatVector.data = (REAL4FrequencySeries *)LALCalloc( 1, nStacks * sizeof(REAL4FrequencySeries)); if ( fstatVector.data == NULL) { fprintf(stderr, "error allocating memory [HierarchicalSearch.c %d]\n" , __LINE__); return(HIERARCHICALSEARCH_EMEM); @@ -1013,14 +1013,14 @@ int MAIN( int argc, char *argv[]) { fstatVector.data[k].deltaF = dFreqStack; fstatVector.data[k].f0 = usefulParams.spinRange_midTime.fkdot[0] - semiCohPar.extraBinsFstat * dFreqStack; if (fstatVector.data[k].data == NULL) { - fstatVector.data[k].data = (REAL8Sequence *)LALCalloc( 1, sizeof(REAL8Sequence)); + fstatVector.data[k].data = (REAL4Sequence *)LALCalloc( 1, sizeof(REAL4Sequence)); if ( fstatVector.data[k].data == NULL) { fprintf(stderr, "error allocating memory [HierarchicalSearch.c %d]\n" , __LINE__); return(HIERARCHICALSEARCH_EMEM); } fstatVector.data[k].data->length = binsFstat1; - fstatVector.data[k].data->data = (REAL8 *)LALCalloc( 1, binsFstat1 * sizeof(REAL8)); + fstatVector.data[k].data->data = (REAL4 *)LALCalloc( 1, binsFstat1 * sizeof(REAL4)); if ( fstatVector.data[k].data->data == NULL) { fprintf(stderr, "error allocating memory [HierarchicalSearch.c %d]\n" , __LINE__); return(HIERARCHICALSEARCH_EMEM); @@ -1028,14 +1028,14 @@ int MAIN( int argc, char *argv[]) { } else { - fstatVector.data[k].data = (REAL8Sequence *)LALRealloc( fstatVector.data[k].data, sizeof(REAL8Sequence)); + fstatVector.data[k].data = (REAL4Sequence *)LALRealloc( fstatVector.data[k].data, sizeof(REAL4Sequence)); if ( fstatVector.data[k].data == NULL) { fprintf(stderr, "error allocating memory [HierarchicalSearch.c %d]\n" , __LINE__); return(HIERARCHICALSEARCH_EMEM); } fstatVector.data[k].data->length = binsFstat1; - fstatVector.data[k].data->data = (REAL8 *)LALRealloc( fstatVector.data[k].data->data, binsFstat1 * sizeof(REAL8)); + fstatVector.data[k].data->data = (REAL4 *)LALRealloc( fstatVector.data[k].data->data, binsFstat1 * sizeof(REAL4)); if ( fstatVector.data[k].data->data == NULL) { fprintf(stderr, "error allocating memory [HierarchicalSearch.c %d]\n" , __LINE__); return(HIERARCHICALSEARCH_EMEM); @@ -1112,7 +1112,7 @@ int MAIN( int argc, char *argv[]) { meanN, sigmaN, semiCohPar.threshold); /* convert fstat vector to peakgrams using the Fstat threshold */ - LAL_CALL( FstatVectToPeakGram( &status, &pgV, &fstatVector, uvar_peakThrF), &status); + LAL_CALL( FstatVectToPeakGram( &status, &pgV, &fstatVector, (REAL4)uvar_peakThrF), &status); /* get candidates */ /* this is the second most costly function. We here allow for using architecture-specific @@ -1338,7 +1338,7 @@ void SetUpSFTs( LALStatus *status, /* set some sft parameters */ deltaFsft = catalog->data[0].header.deltaF; timebase = 1.0/deltaFsft; - + /* calculate start and end times and tobs from catalog*/ tStartGPS = catalog->data[0].header.epoch; in->tStartGPS = tStartGPS; @@ -1347,22 +1347,6 @@ void SetUpSFTs( LALStatus *status, tObs = XLALGPSDiff(&tEndGPS, &tStartGPS); in->tObs = tObs; - /* Leap seconds for the first timestamp */ - /* Repr 26/07/08: deactivated use of old function LALLeapSecs() which has an obsolete leap-second range: - TRY( LALLeapSecs( status->statusPtr, &tmpLeap, &tStartGPS, &lsfas), status); - Use new XLALLeapSeconds() instead: */ -#ifdef WRONGLY_USE_XLALLEAPSECONDS_FOR_EINSTEINATHOME_S5R4_COMPATIBILITY - in->edat->leap = XLALLeapSeconds( tStartGPS.gpsSeconds ); -#else - in->edat->leap = XLALGPSLeapSeconds( tStartGPS.gpsSeconds ); -#endif - { - INT4 err = xlalErrno; - if ( err != XLAL_SUCCESS ) { - ABORT ( status, err, "XLALLeapSeconds() failed!\n"); - } - } - /* get sft catalogs for each stack */ TRY( SetUpStacks( status->statusPtr, &catalogSeq, in->tStack, catalog, in->nStacks), status); @@ -2087,8 +2071,8 @@ void ComputeFstatHoughMap(LALStatus *status, */ void FstatVectToPeakGram (LALStatus *status, HOUGHPeakGramVector *pgV, - REAL8FrequencySeriesVector *FstatVect, - REAL8 thr) + REAL4FrequencySeriesVector *FstatVect, + REAL4 thr) { INT4 j, k; INT4 nStacks, nSearchBins, nPeaks; @@ -2127,14 +2111,14 @@ void FstatVectToPeakGram (LALStatus *status, /* loop over each stack and set peakgram */ for (k=0; k<nStacks; k++) { INT4 *pInt; /* temporary pointer */ - REAL8 *pV; /* temporary pointer */ + REAL4 *pV; /* temporary pointer */ REAL8 f0, deltaF; pV = FstatVect->data[k].data->data; /* loop over Fstat vector, count peaks, and set upg values */ nPeaks = 0; for(j=0; j<nSearchBins; j++) { - if ( (REAL4)(pV[j]) > (REAL4)thr ) { + if (pV[j] > thr ) { nPeaks++; upg[j] = 1; } @@ -2708,7 +2692,7 @@ void PrintSemiCohCandidates(LALStatus *status, /** Print Fstat vectors */ void PrintFstatVec (LALStatus *status, - REAL8FrequencySeries *in, + REAL4FrequencySeries *in, FILE *fp, PulsarDopplerParams *thisPoint, LIGOTimeGPS refTime, diff --git a/lalapps/src/pulsar/hough/src2/HierarchicalSearch.h b/lalapps/src/pulsar/hough/src2/HierarchicalSearch.h index 746b3e3fa0849347e3d408a3a2fccf526b5fca32..8470058dad9362fc174786077619d58b63d3be37 100644 --- a/lalapps/src/pulsar/hough/src2/HierarchicalSearch.h +++ b/lalapps/src/pulsar/hough/src2/HierarchicalSearch.h @@ -205,8 +205,8 @@ NRCSID( HIERARCHICALSEARCHH, "$Id$" ); void FstatVectToPeakGram (LALStatus *status, HOUGHPeakGramVector *pgV, - REAL8FrequencySeriesVector *FstatVect, - REAL8 thr); + REAL4FrequencySeriesVector *FstatVect, + REAL4 thr); void SetUpStacks(LALStatus *status, SFTCatalogSequence *out, diff --git a/lalapps/src/pulsar/hough/src2/HierarchicalSearchGC.c b/lalapps/src/pulsar/hough/src2/HierarchicalSearchGC.c index 8ca78a2fcee658436848c5b8b07ba5f565a78535..58bd6c685e5942578e9e743d73f08f17d0b995b3 100644 --- a/lalapps/src/pulsar/hough/src2/HierarchicalSearchGC.c +++ b/lalapps/src/pulsar/hough/src2/HierarchicalSearchGC.c @@ -1343,22 +1343,6 @@ void SetUpSFTs( LALStatus *status, tObs = XLALGPSDiff(&tEndGPS, &tStartGPS); in->tObs = tObs; - /* Leap seconds for the first timestamp */ - /* Repr 26/07/08: deactivated use of old function LALLeapSecs() which has an obsolete leap-second range: - TRY( LALLeapSecs( status->statusPtr, &tmpLeap, &tStartGPS, &lsfas), status); - Use new XLALLeapSeconds() instead: */ -#ifdef WRONGLY_USE_XLALLEAPSECONDS_FOR_EINSTEINATHOME_S5R4_COMPATIBILITY - in->edat->leap = XLALLeapSeconds( tStartGPS.gpsSeconds ); -#else - in->edat->leap = XLALGPSLeapSeconds( tStartGPS.gpsSeconds ); -#endif - { - INT4 err = xlalErrno; - if ( err != XLAL_SUCCESS ) { - ABORT ( status, err, "XLALLeapSeconds() failed!\n"); - } - } - /* get sft catalogs for each stack */ TRY( SetUpStacks( status->statusPtr, &catalogSeq, in->tStack, catalog, in->nStacks), status); diff --git a/lalapps/src/pulsar/hough/src2/HoughMismatch.c b/lalapps/src/pulsar/hough/src2/HoughMismatch.c index ec250030882b5c0d134a8a6d974b392faeddc56b..044ef97557d8c23c5c363cf6d939172b375143e4 100644 --- a/lalapps/src/pulsar/hough/src2/HoughMismatch.c +++ b/lalapps/src/pulsar/hough/src2/HoughMismatch.c @@ -327,22 +327,12 @@ int main( int argc, char *argv[]){ VelocityPar velPar; REAL8 vel[3]; UINT4 j; - - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 tmpLeap; /* need this because Date pkg defines leap seconds as - INT4, while EphemerisData defines it to be INT2. This won't - cause problems before, oh, I don't know, the Earth has been - destroyed in nuclear holocaust. -- dwchin 2004-02-29 */ - + velPar.detector = detector; velPar.tBase = timeBase; velPar.vTol = 0.0; /* irrelevant */ velPar.edat = NULL; - - /* Leap seconds for the start time of the run */ - SUB( LALLeapSecs(&status, &tmpLeap, &(timeV.data[0]), &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; - + /* read in ephemeris data */ SUB( LALInitBarycenter( &status, edat), &status); velPar.edat = edat; diff --git a/lalapps/src/pulsar/hough/src2/HoughValidateAM.c b/lalapps/src/pulsar/hough/src2/HoughValidateAM.c index 63201648e99d7082c9fbe201dd8ab5398f869ebe..6a64f532017291e01c8d1a05216084cd7e7820c7 100644 --- a/lalapps/src/pulsar/hough/src2/HoughValidateAM.c +++ b/lalapps/src/pulsar/hough/src2/HoughValidateAM.c @@ -366,22 +366,12 @@ int main( int argc, char *argv[]){ VelocityPar velPar; REAL8 vel[3]; UINT4 j; - - LALLeapSecFormatAndAcc lsfas = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 tmpLeap; /* need this because Date pkg defines leap seconds as - INT4, while EphemerisData defines it to be INT2. This won't - cause problems before, oh, I don't know, the Earth has been - destroyed in nuclear holocaust. -- dwchin 2004-02-29 */ - + velPar.detector = detector; velPar.tBase = timeBase; velPar.vTol = 0.0; /* irrelevant */ velPar.edat = NULL; - - /* Leap seconds for the start time of the run */ - LAL_CALL( LALLeapSecs(&status, &tmpLeap, &(timeV.data[0]), &lsfas), &status); - (*edat).leap = (INT2)tmpLeap; - + /* read in ephemeris data */ LAL_CALL( LALInitBarycenter( &status, edat), &status); velPar.edat = edat; diff --git a/lalapps/src/pulsar/hough/src2/Makefile.am b/lalapps/src/pulsar/hough/src2/Makefile.am index e918c350bcb70abc84895f89aabffd5a934cabe7..9a977d8f961fda09b420da97c5ac6aff05375e12 100644 --- a/lalapps/src/pulsar/hough/src2/Makefile.am +++ b/lalapps/src/pulsar/hough/src2/Makefile.am @@ -5,7 +5,9 @@ INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/lalapps -I$(top_srcdir)/src/pulsar/FDS_isolated LDADD = $(top_builddir)/src/lalapps/liblalapps.la -bin_PROGRAMS = lalapps_HoughValidateAM lalapps_HoughMismatch lalapps_HierarchicalSearch lalapps_HierarchicalSearch_v2 lalapps_HierarchicalSearchGC +bin_PROGRAMS = lalapps_HoughValidateAM lalapps_HoughMismatch lalapps_HierarchicalSearch + +EXTRA_PROGRAMS = lalapps_HierarchicalSearchGC lalapps_HoughValidateAM_SOURCES = HoughValidateAM.c ../src/MCInjectHoughS2.h \ ../src/SFTbin.h ../src/SFTbin.c \ @@ -23,11 +25,6 @@ lalapps_HierarchicalSearch_SOURCES = HierarchicalSearch.c HierarchicalSearch.h \ ../../FDS_isolated/HeapToplist.c ../../FDS_isolated/HeapToplist.h \ ../../FDS_isolated/ComputeFStatistic.h -lalapps_HierarchicalSearch_v2_SOURCES = HierarchicalSearch_v2.c HierarchicalSearch.h StackSlideFstat.c StackSlideFstat.h \ - ../../FDS_isolated/FstatToplist.c ../../FDS_isolated/FstatToplist.h \ - ../../FDS_isolated/HeapToplist.c ../../FDS_isolated/HeapToplist.h \ - ../../FDS_isolated/ComputeFStatistic.h - lalapps_HierarchicalSearchGC_SOURCES = HierarchicalSearchGC.c HierarchicalSearchGC.h \ StackSlideFstat.c StackSlideFstat.h \ HoughFStatToplist.c HoughFStatToplist.h \ diff --git a/lalapps/src/pulsar/hough/src2/StackSlideFstat.c b/lalapps/src/pulsar/hough/src2/StackSlideFstat.c index 75d3f9316d6ba577a31a3353779ed8dd37384cfd..58d5d5487af70869764eafbb918bc3818126dee0 100644 --- a/lalapps/src/pulsar/hough/src2/StackSlideFstat.c +++ b/lalapps/src/pulsar/hough/src2/StackSlideFstat.c @@ -68,13 +68,13 @@ static int smallerStackSlide(const void *a,const void *b) { */ void StackSlideVecF(LALStatus *status, SemiCohCandidateList *out, /* output candidates */ - REAL8FrequencySeriesVector *vecF, /* vector with Fstat values or any REAL8FrequencySeriesVector */ + REAL4FrequencySeriesVector *vecF, /* vector with Fstat values or any REAL8FrequencySeriesVector */ SemiCoherentParams *params) /* input parameters */ { REAL8FrequencySeries stackslideSum; /* The output of StackSliding the vecF values */ REAL8 *pstackslideData; /* temporary pointer */ - REAL8 *pFVecData; /* temporary pointer */ + REAL4 *pFVecData; /* temporary pointer */ REAL8 pixelFactor; REAL8 alphaStart, alphaEnd, dAlpha, thisAlpha; @@ -361,13 +361,13 @@ void StackSlideVecF(LALStatus *status, This is similar to StackSlideVecF but adapted to calculate the hough number count and to be as similar to Hough as possible but without using the hough look-up-tables. \param out SemiCohCandidateList is a list of candidates - \param vecF is a vector of Fstat frequency series or any REAL8FrequencySeriesVector. + \param vecF is a vector of Fstat frequency series or any REAL4FrequencySeriesVector. \param params is a pointer to SemiCoherentParams \out SemiCohCandidateList is a list of candidates */ void StackSlideVecF_HoughMode(LALStatus *status, SemiCohCandidateList *out, /**< output candidates */ - REAL8FrequencySeriesVector *vecF, /**< vector with Fstat values or any REAL8FrequencySeriesVector */ + REAL4FrequencySeriesVector *vecF, /**< vector with Fstat values or any REAL8FrequencySeriesVector */ SemiCoherentParams *params) /**< input parameters */ { diff --git a/lalapps/src/pulsar/hough/src2/StackSlideFstat.h b/lalapps/src/pulsar/hough/src2/StackSlideFstat.h index d93ad06508239556a0010e10fbc1996322306e44..8dbcee9479d144cbb90e0eef0d2f281cb5a4b073 100644 --- a/lalapps/src/pulsar/hough/src2/StackSlideFstat.h +++ b/lalapps/src/pulsar/hough/src2/StackSlideFstat.h @@ -111,13 +111,13 @@ NRCSID( STACKSLIDEFSTATH, "$Id$" ); /* Function that stackslides a vector of Fstat frequency series or any REAL8FrequencySeriesVector. */ void StackSlideVecF(LALStatus *status, SemiCohCandidateList *out, - REAL8FrequencySeriesVector *vecF, + REAL4FrequencySeriesVector *vecF, SemiCoherentParams *params); void StackSlideVecF_HoughMode(LALStatus *status, SemiCohCandidateList *out, - REAL8FrequencySeriesVector *vecF, + REAL4FrequencySeriesVector *vecF, SemiCoherentParams *params); /* Calculate f(t) using the master equation given by Eq. 6.18 in gr-qc/0407001 */ diff --git a/lalapps/src/pulsar/templateBanks/FstatMetric.c b/lalapps/src/pulsar/templateBanks/FstatMetric.c index 4a92dd5834807e54f2ae74193e53f1dbdfba9087..2a493002fc3860398592bf71e690989de96d0afc 100644 --- a/lalapps/src/pulsar/templateBanks/FstatMetric.c +++ b/lalapps/src/pulsar/templateBanks/FstatMetric.c @@ -264,7 +264,7 @@ main(int argc, char *argv[]) REAL8 m1, m2, m3; REAL8 mF, mFav, disc, mMin, mMax; gsl_matrix *g_ij, *gFlat_ij, *gamma_ij; - REAL8 mm, mm_projected; + REAL8 mm; UserVariables_t uvar = empty_UserVariables; FILE *fpMetric = 0; @@ -345,6 +345,14 @@ main(int argc, char *argv[]) return -1; } + if ( uvar.projection > 0 ) + { + project_metric ( gamma_ij, gF_ij, (uvar.projection - 1) ); + gsl_matrix_memcpy ( gF_ij, gamma_ij ); + project_metric ( gamma_ij, gFav_ij, (uvar.projection - 1) ); + gsl_matrix_memcpy ( gFav_ij, gamma_ij ); + } + mF = quad_form ( gF_ij, config.dopplerOffset ); mFav = quad_form ( gFav_ij, config.dopplerOffset ); @@ -369,7 +377,7 @@ main(int argc, char *argv[]) if ( fpMetric ) { - fprintf ( fpMetric, "\nA = %.16g; B = %.16g; C = %.16g; D = %.16g;\n", + fprintf ( fpMetric, "\nA = %.16g;\nB = %.16g;\nC = %.16g;\nD = %.16g;\n", config.Ad, config.Bd, config.Cd, config.Dd ); fprintf ( fpMetric, "\ngF_ij = \\\n" ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, gF_ij ); @@ -395,27 +403,28 @@ main(int argc, char *argv[]) printf ("\nSomething failed in computePhaseMetric() \n\n"); return -1; } + + if ( uvar.projection > 0 ) + { + project_metric ( gamma_ij, g_ij, (uvar.projection - 1) ); + gsl_matrix_memcpy ( g_ij, gamma_ij ); + } + mm = quad_form ( g_ij, config.dopplerOffset ); if ( fpMetric ) { const CHAR *gprefix, *mprefix; if ( metricType == METRIC_PHASE ) { - if ( uvar.projection > 0 ) { - project_metric(gamma_ij, g_ij, (uvar.projection - 1) ); - mm_projected = quad_form ( gamma_ij, config.dopplerOffset ); - gprefix = "gPh_projected_ij = \\\n"; mprefix = "mPh_projected = "; - fprintf ( fpMetric, gprefix ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, gamma_ij ); - fprintf ( fpMetric, "\n%s %.16g;\n\n", mprefix, mm_projected ); - } gprefix = "gPh_ij = \\\n"; mprefix = "mPh = "; } else if ( metricType == METRIC_ORBITAL ) { gprefix = "gOrb_ij = \\\n"; mprefix = "mOrb = "; } else if ( metricType == METRIC_PTOLE ) { gprefix = "gPtole_ij = \\\n"; mprefix = "mPtole = "; } - fprintf ( fpMetric, gprefix ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, g_ij ); - fprintf ( fpMetric, "\n%s %.16g;\n\n", mprefix, mm ); + + fprintf ( fpMetric, gprefix ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, g_ij ); + fprintf ( fpMetric, "\n%s %.16g;\n\n", mprefix, mm ); } /* if fpMetric */ @@ -432,14 +441,7 @@ main(int argc, char *argv[]) REAL8 Rorb = LAL_AU_SI; /* ----- translate Doppler-offsets into 'canonical coords ----- */ - if ( config.edat->leap < 0 ) /* signals that we're dealing with LISA */ - { - sineps = 0; coseps = 1; /* already working in ecliptic coords */ - } - else - { - sineps = sin ( LAL_IEARTH ); coseps = cos ( LAL_IEARTH ); - } + sineps = sin ( LAL_IEARTH ); coseps = cos ( LAL_IEARTH ); sind1 = sin(uvar.Delta); cosd1 = cos(uvar.Delta); sina1 = sin(uvar.Alpha); cosa1 = cos(uvar.Alpha); @@ -1019,7 +1021,6 @@ InitCode (LALStatus *status, ConfigVariables *cfg, const UserVariables_t *uvar) cfg->offsetUnits.skypos.system = COORDINATESYSTEM_EQUATORIAL; if ( uvar->unitsType == UNITS_NATURAL ) { - REAL8 nNat = uvar->Freq * uvar->duration * ORB_V0; cfg->offsetUnits.fkdot->data[0] = 1.0 / ( LAL_TWOPI * uvar->duration ); cfg->offsetUnits.fkdot->data[1] = 2.0 / ( LAL_TWOPI * SQ( uvar->duration ) ); cfg->offsetUnits.skypos.longitude = 1.0; @@ -1239,7 +1240,6 @@ getMultiPhaseDerivs (LALStatus *status, PulsarTimesParamStruc times = empty_PulsarTimesParamStruc; MultiPhaseDerivs *mdPhi = NULL; REAL8 TspanInv; - REAL8 eps, zEcl[3], tmp[3], proj; INITSTATUS (status, "getMultiPhaseDerivs", rcsid); ATTATCHSTATUSPTR (status); @@ -1328,32 +1328,11 @@ getMultiPhaseDerivs (LALStatus *status, case PHASE_PTOLE: /* use Ptolemaic orbital approximation */ getPtolePosVel( &posvel, ti, times.tAutumn ); COPY_VECT ( rX, posvel.pos ); - /* add on the detector-motion */ - - /* ecliptic z-axis in equatorial coords */ - eps = 0.409092804; /* Earth inclination to ecliptic in radians (23.439 degrees) */ - zEcl[0] = 0; - zEcl[1] = -sin(eps); - zEcl[2] = cos(eps); + /* add on the detector-motion due to the Earth's spin */ - /* projected out z-motion wrt to ecliptic plane */ - tmp[0] = rDet[0]; - tmp[1] = cos(eps) * rDet[1]; - tmp[2] = sin(eps) * rDet[1]; - - /* projected pure ecliptic-z motion */ - proj = SCALAR ( zEcl, rDet ); - tmp[0] = proj * zEcl[0]; - tmp[1] = proj * zEcl[1]; - tmp[2] = proj * zEcl[2]; - - /* - printf ("%f \t %f %f %f \t %f %f %f\n", ti, rX[0], rX[1], rX[2], tmp[0], tmp[1], tmp[2] ); - */ - - rX[0] += tmp[0]; - rX[1] += tmp[1]; - rX[2] += tmp[2]; + rX[0] += rDet[0]; + rX[1] += rDet[1]; + rX[2] += rDet[2]; break; default: @@ -1622,8 +1601,6 @@ InitEphemeris (LALStatus * status, #define FNAME_LENGTH 1024 CHAR EphemEarth[FNAME_LENGTH]; /* filename of earth-ephemeris data */ CHAR EphemSun[FNAME_LENGTH]; /* filename of sun-ephemeris data */ - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_LOOSE}; - INT4 leap; INITSTATUS( status, "InitEphemeris", rcsid ); ATTATCHSTATUSPTR (status); @@ -1660,16 +1637,6 @@ InitEphemeris (LALStatus * status, TRY (LALInitBarycenter(status->statusPtr, edat), status); - if ( isLISA ) - { - edat->leap = -1; /* dirty hack: signal that ephemeris are in *ECLIPTIC* coords, not EQUATORIAL */ - } - else - { - TRY (LALLeapSecs (status->statusPtr, &leap, &epoch, &formatAndAcc), status); - edat->leap = (INT2) leap; - } - DETATCHSTATUSPTR ( status ); RETURN ( status ); diff --git a/lalapps/src/pulsar/templateBanks/FstatMetric_v2.c b/lalapps/src/pulsar/templateBanks/FstatMetric_v2.c index e9935302fee512b6ac0d8c98bffef6847bb4169d..c653dc9697ac45f92454baa4d76e2ec73f8d578c 100644 --- a/lalapps/src/pulsar/templateBanks/FstatMetric_v2.c +++ b/lalapps/src/pulsar/templateBanks/FstatMetric_v2.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2008 Reinhard Prix + * Copyright (C) 2006, 2008, 2009 Reinhard Prix * * 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 @@ -22,15 +22,21 @@ * * \author{Reinhard Prix} * - * New code to calculated various F-statistic metrics and mismatches + * This module deals with calculating various F-statistic metric approximations, + * Fisher matrices and mismatches. Contrary to previous implementations + * this consistently uses gsl-integration, and allows for very generic + * handling of different coordinate systems in the Doppler parameter space. + * + * In particular, it allows for easy extensions to new coordinates and Doppler parameters. + * * - * Revision: $Id$ * */ /* ---------- includes ---------- */ #include <math.h> - +#include <errno.h> +#include <string.h> #include <gsl/gsl_vector.h> #include <gsl/gsl_matrix.h> @@ -79,7 +85,7 @@ RCSID("$Id"); /* uncomment the following to turn off range-checking in GSL vector-functions */ /* #define GSL_RANGE_CHECK_OFF 1*/ -#define METRIC_FORMAT "%.16g" /* fprintf-format used for printing metric components */ +#define METRIC_FORMAT "% .16e" /* fprintf-format used for printing metric components */ /*---------- local defines ---------- */ #define TRUE (1==1) @@ -101,6 +107,21 @@ RCSID("$Id"); #define SQ(x) ((x) * (x)) /* ---------- local types ---------- */ + +/** Rudimentary first sketch of a history type, to encode all + * the history-trail leading to a certain result from primal inputs. + * + * This will be extended in the future and moved into LAL. + */ +typedef struct +{ + CHAR *app_name; /**< name (and path) of this application */ + CHAR *cmdline; /**< commandline used to produce this result */ + CHAR *LAL_VCS_Version; /**< lal source-version from VCS */ + CHAR *LALApps_VCS_Version; /**< lalapps source-version from VCS */ +} ResultHistory_t; + + typedef struct { EphemerisData *edat; /**< ephemeris data (from LALInitBarycenter()) */ @@ -108,6 +129,7 @@ typedef struct PulsarParams signalParams; /**< GW signal parameters: Amplitudes + doppler */ MultiDetectorInfo detInfo; /**< (multi-)detector info */ DopplerCoordinateSystem coordSys; /**< array of enums describing Doppler-coordinates to compute metric in */ + ResultHistory_t *history; /**< history trail leading up to and including this application */ } ConfigVariables; @@ -127,6 +149,7 @@ typedef struct CHAR *ephemYear; /**< date-range string on ephemeris-files to use */ REAL8 startTime; /**< GPS start time of observation */ + REAL8 refTime; /**< GPS reference time of Doppler parameters */ REAL8 duration; /**< length of observation in seconds */ REAL8 h0; /**< GW amplitude h_0 */ @@ -138,7 +161,9 @@ typedef struct INT4 detMotionType; /**< enum-value DetectorMotionType specifying type of detector-motion to use */ - INT4 projection; /**< project metric onto surface */ + INT4 metricType; /**< type of metric to compute: 0=phase-metric, 1=F-metric(s), 2=both */ + + INT4 projection; /**< project metric onto subspace orthogonal to this coordinate-axis (0=none, 1=1st-coordinate axis, ...) */ LALStringVector* coords; /**< list of Doppler-coordinates to compute metric in, see --coordsHelp for possible values */ BOOLEAN coordsHelp; /**< output help-string explaining all the possible Doppler-coordinate names for --cords */ @@ -157,17 +182,14 @@ extern int vrbflg; /* ---------- local prototypes ---------- */ void initUserVars (LALStatus *status, UserVariables_t *uvar); -void InitCode (LALStatus *status, ConfigVariables *cfg, const UserVariables_t *uvar); +int XLALInitCode ( ConfigVariables *cfg, const UserVariables_t *uvar, const char *app_name); EphemerisData *InitEphemeris (const CHAR *ephemDir, const CHAR *ephemYear, const LIGOTimeGPS *epoch ); -int project_metric( gsl_matrix *ret_ij, gsl_matrix *g_ij, const UINT4 coordinate ); -int outer_product ( gsl_matrix *ret_ij, const gsl_vector *u_i, const gsl_vector *v_j ); -int symmetrize ( gsl_matrix *mat ); -REAL8 quad_form ( const gsl_matrix *mat, const gsl_vector *vec ); +int XLALOutputDopplerMetric ( FILE *fp, const DopplerMetric *metric, const ResultHistory_t *history ); - -void FreeMem ( LALStatus *status, ConfigVariables *cfg ); +int XLALDestroyConfig ( ConfigVariables *cfg ); +void XLALDestroyResultHistory ( ResultHistory_t * history ); /*============================================================ * FUNCTION definitions @@ -176,10 +198,11 @@ void FreeMem ( LALStatus *status, ConfigVariables *cfg ); int main(int argc, char *argv[]) { + const CHAR *fn = argv[0]; + LALStatus status = blank_status; ConfigVariables config = empty_ConfigVariables; UserVariables_t uvar = empty_UserVariables; - FILE *fpMetric = 0; DopplerMetric *metric; DopplerMetricParams metricParams = empty_DopplerMetricParams; @@ -223,110 +246,41 @@ main(int argc, char *argv[]) } /* if coordsHelp */ /* basic setup and initializations */ - LAL_CALL ( InitCode(&status, &config, &uvar), &status); + if ( XLALInitCode( &config, &uvar, argv[0] ) != XLAL_SUCCESS ) { + LogPrintf (LOG_CRITICAL, "%s: XInitCode() failed with xlalErrno = %d.\n\n", fn, xlalErrno ); + return FSTATMETRIC_EXLAL; + } metricParams.coordSys = config.coordSys; metricParams.detMotionType = uvar.detMotionType; + metricParams.metricType = uvar.metricType; metricParams.startTime = config.startTime; metricParams.Tspan = uvar.duration; metricParams.detInfo = config.detInfo; metricParams.signalParams = config.signalParams; + metricParams.projectCoord = uvar.projection - 1; /* user-input counts from 1, but interally we count 0=1st coord. (-1==no projection) */ /* ----- compute metric full metric + Fisher matrix ---------- */ if ( (metric = XLALDopplerFstatMetric ( &metricParams, config.edat )) == NULL ) { - LogPrintf (LOG_CRITICAL, "Something failed in XLALDopplerFstatMetric(). errno = %d\n\n", xlalErrno); + LogPrintf (LOG_CRITICAL, "Something failed in XLALDopplerFstatMetric(). xlalErrno = %d\n\n", xlalErrno); return -1; } /* ---------- output results ---------- */ if ( uvar.outputMetric ) { - UINT4 i; - CHAR *id1, *id2; - CHAR *cmdline = NULL; - REAL8 A, B, C, D; - const DopplerMetricParams *meta = &metricParams; - const PulsarDopplerParams *doppler = &(meta->signalParams.Doppler); - const PulsarAmplitudeParams *Amp = &(meta->signalParams.Amp); - - if ( (fpMetric = fopen ( uvar.outputMetric, "wb" )) == NULL ) + FILE *fpMetric; + if ( (fpMetric = fopen ( uvar.outputMetric, "wb" )) == NULL ) { + LogPrintf (LOG_CRITICAL, "%s: failed to open '%s' for writing. error = '%s'\n", + fn, uvar.outputMetric, strerror(errno)); return FSTATMETRIC_EFILE; + } - /* get full commandline describing search*/ - LAL_CALL ( LALUserVarGetLog (&status, &cmdline, UVAR_LOGFMT_CMDLINE ), &status ); - fprintf ( fpMetric, "%%%% cmdline: %s\n", cmdline ); - LALFree ( cmdline ); - - id1 = XLALClearLinebreaks ( lalGitID ); - id2 = XLALClearLinebreaks ( lalappsGitID ); - fprintf ( fpMetric, "%%%% %s\n%%%%%s\n", id1, id2 ); - fprintf ( fpMetric, "%%%% DopplerCoordinates = [ " ); - LALFree ( id1 ); LALFree ( id2 ); - for ( i=0; i < meta->coordSys.dim; i ++ ) - { - if ( i > 0 ) fprintf ( fpMetric, ", " ); - fprintf ( fpMetric, "%s", XLALDopplerCoordinateName(meta->coordSys.coordIDs[i])); - } - fprintf ( fpMetric, "];\n"); - fprintf ( fpMetric, "%%%% DetectorMotionType = '%s'\n", XLALDetectorMotionName(meta->detMotionType) ); - fprintf ( fpMetric, "%%%% h0 = %g; cosi = %g; psi = %g; phi0 = %g;\n", Amp->h0, Amp->cosi, Amp->psi, Amp->phi0 ); - fprintf ( fpMetric, "%%%% DopplerPoint = {\n"); - fprintf ( fpMetric, "%%%% refTime = {%d, %d}\n", - doppler->refTime.gpsSeconds, doppler->refTime.gpsNanoSeconds ); - fprintf ( fpMetric, "%%%% Alpha = %f rad; Delta = %f rad\n", doppler->Alpha, doppler->Delta ); - fprintf ( fpMetric, "%%%% fkdot = [%f, %g, %g, %g ]\n", - doppler->fkdot[0], doppler->fkdot[1], doppler->fkdot[2], doppler->fkdot[3] ); - if ( doppler->orbit ) - { - const BinaryOrbitParams *orbit = doppler->orbit; - fprintf ( fpMetric, "%%%% orbit = { \n"); - fprintf ( fpMetric, "%%%% tp = {%d, %d}\n", orbit->tp.gpsSeconds, orbit->tp.gpsNanoSeconds ); - fprintf ( fpMetric, "%%%% argp = %g\n", orbit->argp ); - fprintf ( fpMetric, "%%%% asini = %g\n", orbit->asini ); - fprintf ( fpMetric, "%%%% ecc = %g\n", orbit->ecc ); - fprintf ( fpMetric, "%%%% period = %g\n", orbit->period ); - fprintf ( fpMetric, "%%%% }\n"); - } /* if doppler->orbit */ - fprintf ( fpMetric, "%%%% }\n"); - - fprintf ( fpMetric, "%%%% startTime = {%d, %d}\n", meta->startTime.gpsSeconds, meta->startTime.gpsNanoSeconds ); - fprintf ( fpMetric, "%%%% duration = %f\n", meta->Tspan ); - fprintf ( fpMetric, "%%%% detectors = ["); - for ( i=0; i < meta->detInfo.length; i ++ ) - { - if ( i > 0 ) fprintf ( fpMetric, ", "); - fprintf ( fpMetric, "%s", meta->detInfo.sites[i].frDetector.name ); - } - fprintf ( fpMetric, "];\n"); - fprintf ( fpMetric, "%%%% detectorWeights = ["); - for ( i=0; i < meta->detInfo.length; i ++ ) - { - if ( i > 0 ) fprintf ( fpMetric, ", "); - fprintf ( fpMetric, "%f", meta->detInfo.detWeights[i] ); - } - fprintf ( fpMetric, "];\n"); - - /* ----- output phase metric ---------- */ - fprintf ( fpMetric, "\ng_ij = \\\n" ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, metric->g_ij ); - - /* ----- output F-metric (and related matrices ---------- */ - fprintf ( fpMetric, "\ngF_ij = \\\n" ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, metric->gF_ij ); - fprintf ( fpMetric, "\ngFav_ij = \\\n" ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, metric->gFav_ij ); - fprintf ( fpMetric, "\nm1_ij = \\\n" ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, metric->m1_ij ); - fprintf ( fpMetric, "\nm2_ij = \\\n" ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, metric->m2_ij ); - fprintf ( fpMetric, "\nm3_ij = \\\n" ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, metric->m3_ij ); - - /* ----- output Fisher matrix ---------- */ - A = gsl_matrix_get ( metric->Fisher_ab, 0, 0 ); - B = gsl_matrix_get ( metric->Fisher_ab, 1, 1 ); - C = gsl_matrix_get ( metric->Fisher_ab, 0, 1 ); - - D = A * B - C * C; - - fprintf ( fpMetric, "\nA = %.16g; B = %.16g; C = %.16g; D = %.16g;\n", A, B, C, D ); - fprintf ( fpMetric, "\nrho2 = %.16g;\n", metric->rho2 ); - - fprintf (fpMetric, "\nFisher_ab = \\\n" ); XLALfprintfGSLmatrix ( fpMetric, METRIC_FORMAT, metric->Fisher_ab ); + if ( XLALOutputDopplerMetric ( fpMetric, metric, config.history ) != XLAL_SUCCESS ) { + LogPrintf (LOG_CRITICAL, "%s: failed to write Doppler metric into output-file '%s'. xlalErrno = %d\n\n", + fn, uvar.outputMetric, xlalErrno ); + return FSTATMETRIC_EFILE; + } fclose ( fpMetric ); @@ -334,7 +288,10 @@ main(int argc, char *argv[]) /* ----- done: free all memory */ XLALDestroyDopplerMetric ( metric ); - LAL_CALL (FreeMem(&status, &config), &status); + if ( XLALDestroyConfig( &config ) != XLAL_SUCCESS ) { + LogPrintf (LOG_CRITICAL, "%s: XLADestroyConfig() failed, xlalErrno = %d.\n\n", fn, xlalErrno ); + return FSTATMETRIC_EXLAL; + } LALCheckMemoryLeaks(); @@ -363,6 +320,7 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) uvar->startTime = 714180733; uvar->duration = 10 * 3600; + uvar->refTime = 0; uvar->projection = 0; if ( (uvar->IFOs = XLALCreateStringVector ( "H1", NULL )) == NULL ) { @@ -373,6 +331,7 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) uvar->IFOweights = NULL; uvar->detMotionType = DETMOTION_SPIN_ORBIT; + uvar->metricType = 2; /* by default: compute both phase + Fstat metric */ if ( (uvar->coords = XLALCreateStringVector ( "Freq_Nat", "Alpha", "Delta", "f1dot_Nat", NULL )) == NULL ) { LogPrintf (LOG_CRITICAL, "Call to XLALCreateStringVector() failed with xlalErrno = %d\n", xlalErrno ); @@ -389,6 +348,7 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) LALregREALUserStruct(status, Freq, 'f', UVAR_OPTIONAL, "target frequency"); LALregREALUserStruct(status, f1dot, 's', UVAR_OPTIONAL, "first spindown-value df/dt"); LALregREALUserStruct(status, startTime, 't', UVAR_OPTIONAL, "GPS start time of observation"); + LALregREALUserStruct(status, refTime, 0, UVAR_OPTIONAL, "GPS reference time of Doppler parameters. Special values: 0=startTime, -1=mid-time"); LALregREALUserStruct(status, duration, 'T', UVAR_OPTIONAL, "Alternative: Duration of observation in seconds"); LALregSTRINGUserStruct(status,ephemDir, 'E', UVAR_OPTIONAL, "Directory where Ephemeris files are located"); LALregSTRINGUserStruct(status,ephemYear, 'y', UVAR_OPTIONAL, "Year (or range of years) of ephemeris files to be used"); @@ -398,13 +358,14 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) LALregREALUserStruct(status, psi, 0, UVAR_OPTIONAL, "Wave polarization-angle psi [0, pi]" ); LALregREALUserStruct(status, phi0, 0, UVAR_OPTIONAL, "GW initial phase phi_0 [0, 2pi]" ); + LALregINTUserStruct(status, metricType, 0, UVAR_OPTIONAL, "type of metric to compute: 0=phase-metric, 1=F-metric(s), 2=both" ); LALregSTRINGUserStruct(status, outputMetric, 'o', UVAR_OPTIONAL, "Output the metric components (in octave format) into this file."); - LALregINTUserStruct(status, projection, 0, UVAR_OPTIONAL, "Coordinate of metric projection: 0=none, 1=f, 2=Alpha, 3=Delta, 4=f1dot"); + LALregINTUserStruct(status, projection, 0, UVAR_OPTIONAL, "Project onto subspace orthogonal to this axis: 0=none, 1=1st-coord, 2=2nd-coord etc"); LALregLISTUserStruct(status, coords, 'c', UVAR_OPTIONAL, "Doppler-coordinates to compute metric in (see --coordsHelp)"); LALregBOOLUserStruct(status, coordsHelp, 0, UVAR_OPTIONAL, "output help-string explaining all the possible Doppler-coordinate names for --coords"); - LALregINTUserStruct(status, detMotionType, 0, UVAR_DEVELOPER, "Detector-motion: 0=spin+orbit, 1=orbit, 2=spin, 3=spin+ptoleorbit, 4=ptoleorbit"); + LALregINTUserStruct(status, detMotionType, 0, UVAR_DEVELOPER, "Detector-motion: 0=spin+orbit, 1=orbit, 2=spin, 3=spin+ptoleorbit, 4=ptoleorbit, 5=orbit+spin_z, 6=orbit+spin_xy"); LALregBOOLUserStruct(status, version, 'V', UVAR_SPECIAL, "Output code version"); @@ -416,22 +377,39 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) /** basic initializations: set-up 'ConfigVariables' */ -void -InitCode (LALStatus *status, ConfigVariables *cfg, const UserVariables_t *uvar) +int +XLALInitCode ( ConfigVariables *cfg, const UserVariables_t *uvar, const char *app_name) { - const CHAR *fn = "InitCode()"; + const CHAR *fn = "XLALInitCode()"; - INITSTATUS (status, fn, rcsid); - ATTATCHSTATUSPTR (status); + LALStatus status = blank_status; + + if ( !cfg || !uvar || !app_name ) { + LogPrintf (LOG_CRITICAL, "%s: illegal NULL pointer input.\n\n", fn ); + XLAL_ERROR (fn, XLAL_EINVAL ); + } /* ----- determine start-time from user-input */ XLALGPSSetREAL8( &(cfg->startTime), uvar->startTime ); if ( (cfg->edat = InitEphemeris ( uvar->ephemDir, uvar->ephemYear, &(cfg->startTime) )) == NULL ) { - LogPrintf (LOG_CRITICAL, "Failed to initialize ephemeris data!\n"); - ABORT ( status, FSTATMETRIC_EINPUT, FSTATMETRIC_MSGEINPUT); + LogPrintf (LOG_CRITICAL, "%s: InitEphemeris() Failed to initialize ephemeris data!\n\n", fn); + XLAL_ERROR ( fn, XLAL_EFUNC ); } + /* ----- figure out reference time */ + REAL8 refTime; + LIGOTimeGPS refTimeGPS; + /* treat special values first */ + if ( uvar->refTime == 0 ) /* 0 = use startTime */ + refTime = uvar->startTime; + else if ( uvar->refTime == -1 ) /* -1 = use mid-time of observation */ + refTime = uvar->startTime + 0.5 * uvar->duration; + else + refTime = uvar->refTime; + + XLALGPSSetREAL8( &refTimeGPS, refTime ); + /* ----- get parameter-space point from user-input) */ cfg->signalParams.Amp.h0 = uvar->h0; cfg->signalParams.Amp.cosi = uvar->cosi; @@ -441,7 +419,7 @@ InitCode (LALStatus *status, ConfigVariables *cfg, const UserVariables_t *uvar) { PulsarDopplerParams *dop = &(cfg->signalParams.Doppler); (*dop) = empty_PulsarDopplerParams; - dop->refTime = cfg->startTime; + dop->refTime = refTimeGPS; dop->Alpha = uvar->Alpha; dop->Delta = uvar->Delta; dop->fkdot[0] = uvar->Freq; @@ -454,20 +432,20 @@ InitCode (LALStatus *status, ConfigVariables *cfg, const UserVariables_t *uvar) UINT4 numDet = uvar->IFOs->length; if ( numDet > DOPPLERMETRIC_MAX_DETECTORS ) { - LogPrintf (LOG_CRITICAL, "More detectors (%d) specified than can be handled maximally (%d)\n", numDet, DOPPLERMETRIC_MAX_DETECTORS ); - ABORT (status, FSTATMETRIC_EINPUT, FSTATMETRIC_MSGEINPUT); + LogPrintf (LOG_CRITICAL, "%s: More detectors (%d) specified than allowed (%d)\n", fn, numDet, DOPPLERMETRIC_MAX_DETECTORS ); + XLAL_ERROR ( fn, XLAL_EINVAL ); } if ( uvar->IFOweights && (uvar->IFOweights->length != numDet ) ) { - LogPrintf (LOG_CRITICAL, "If specified, the number of IFOweights (%d) must agree with the number of IFOs!\n", - uvar->IFOweights->length, numDet ); - ABORT (status, FSTATMETRIC_EINPUT, FSTATMETRIC_MSGEINPUT); + LogPrintf (LOG_CRITICAL, "%s: number of IFOweights (%d) must agree with the number of IFOs (%d)!\n\n", + fn, uvar->IFOweights->length, numDet ); + XLAL_ERROR ( fn, XLAL_EINVAL ); } cfg->detInfo = empty_MultiDetectorInfo; if ( XLALParseMultiDetectorInfo ( &cfg->detInfo, uvar->IFOs, uvar->IFOweights ) != XLAL_SUCCESS ) { LogPrintf (LOG_CRITICAL, "%s: XLALParseMultiDetectorInfo() failed to parse detector names and/or weights. errno = %d.\n\n", fn, xlalErrno); - ABORT (status, FSTATMETRIC_EINPUT, FSTATMETRIC_MSGEINPUT); + XLAL_ERROR ( fn, XLAL_EFUNC ); } } /* handle detector input */ @@ -475,147 +453,76 @@ InitCode (LALStatus *status, ConfigVariables *cfg, const UserVariables_t *uvar) /* ---------- translate coordinate system into internal representation ---------- */ if ( XLALDopplerCoordinateNames2System ( &cfg->coordSys, uvar->coords ) ) { - XLALPrintError ("%s: Call to XLALDopplerCoordinateNames2System() failed. errno = %d\n\n", fn, xlalErrno ); - ABORT ( status, FSTATMETRIC_EINPUT, FSTATMETRIC_MSGEINPUT); + LogPrintf (LOG_CRITICAL, "%s: Call to XLALDopplerCoordinateNames2System() failed. errno = %d\n\n", fn, xlalErrno ); + XLAL_ERROR ( fn, XLAL_EFUNC ); } + /* ---------- record full 'history' up to and including this application ---------- */ + { + CHAR *cmdline = NULL; + CHAR *tmp; + size_t len = strlen ( app_name ) + 1; - DETATCHSTATUSPTR (status); - RETURN (status); - -} /* InitCode() */ - - -/** Free all memory */ -void -FreeMem ( LALStatus *status, ConfigVariables *cfg ) -{ - - INITSTATUS (status, "FreeMem", rcsid); - ATTATCHSTATUSPTR (status); - - ASSERT ( cfg, status, FSTATMETRIC_ENULL, FSTATMETRIC_MSGENULL ); - - TRY ( LALDestroyUserVars ( status->statusPtr ), status ); - - LALFree ( cfg->edat->ephemE ); - LALFree ( cfg->edat->ephemS ); - LALFree ( cfg->edat ); - - DETATCHSTATUSPTR (status); - RETURN(status); - -} /* FreeMem() */ - - -/** Calculate the projected metric onto the subspace of 'c' given by - * ret_ij = g_ij - ( g_ic * g_jc / g_cc ) , where c is the value of the projected coordinate - * The output-matrix ret must be allocated - * - * return 0 = OK, -1 on error. - */ -int -project_metric( gsl_matrix *ret_ij, gsl_matrix * g_ij, const UINT4 c ) -{ - UINT4 i,j; - - if ( !ret_ij ) - return -1; - if ( !g_ij ) - return -1; - if ( (ret_ij->size1 != ret_ij->size2) ) - return -1; - if ( (g_ij->size1 != g_ij->size2) ) - return -1; - - for ( i=0; i < ret_ij->size1; i ++) { - for ( j=0; j < ret_ij->size2; j ++ ) { - if ( i==c || j==c ) { - gsl_matrix_set ( ret_ij, i, j, 0.0 ); - } - else { - gsl_matrix_set ( ret_ij, i, j, ( gsl_matrix_get(g_ij, i, j) - (gsl_matrix_get(g_ij, i, c) * gsl_matrix_get(g_ij, j, c) / gsl_matrix_get(g_ij, c, c)) )); - } + if ( (cfg->history = XLALCalloc ( 1, sizeof(*cfg->history))) == NULL ) { + LogPrintf (LOG_CRITICAL, "%s: XLALCalloc(1,%d) failed.\n\n", fn, sizeof(*cfg->history)); + XLAL_ERROR ( fn, XLAL_ENOMEM ); } - } - return 0; -} - - -/** Calculate the outer product ret_ij of vectors u_i and v_j, given by - * ret_ij = u_i v_j - * The output-matrix ret must be allocated and have dimensions len(u) x len(v) - * - * return 0 = OK, -1 on error. - */ -int -outer_product (gsl_matrix *ret_ij, const gsl_vector *u_i, const gsl_vector *v_j ) -{ - UINT4 i, j; - if ( !ret_ij || !u_i || !v_j ) - return -1; + if ( (tmp = XLALMalloc ( len )) == NULL ) { + LogPrintf (LOG_CRITICAL, "%s: XLALMalloc (%s) failed.\n\n", fn, len ); + XLAL_ERROR ( fn, XLAL_ENOMEM ); + } + strcpy ( tmp, app_name ); + cfg->history->app_name = tmp; + + /* get commandline describing search*/ + LALUserVarGetLog (&status, &cmdline, UVAR_LOGFMT_CMDLINE ); + if ( status.statusCode ) { + LogPrintf (LOG_CRITICAL, "%s: LALUserVarGetLog() failed with statusCode = %d.\n\n", fn, status.statusCode ); + XLAL_ERROR ( fn, XLAL_EFUNC ); + } + cfg->history->cmdline = cmdline; - if ( (ret_ij->size1 != u_i->size) || ( ret_ij->size2 != v_j->size) ) - return -1; + cfg->history->LAL_VCS_Version = XLALClearLinebreaks ( lalGitID ); + cfg->history->LALApps_VCS_Version = XLALClearLinebreaks ( lalappsGitID ); + } /* record history */ - for ( i=0; i < ret_ij->size1; i ++) - for ( j=0; j < ret_ij->size2; j ++ ) - gsl_matrix_set ( ret_ij, i, j, gsl_vector_get(u_i, i) * gsl_vector_get(v_j, j) ); - return 0; + return XLAL_SUCCESS; -} /* outer_product() */ +} /* XLALInitCode() */ -/* symmetrize the input-matrix 'mat' (which must be quadratic) - */ +/** Destructor for internal configuration struct */ int -symmetrize ( gsl_matrix *mat ) +XLALDestroyConfig ( ConfigVariables *cfg ) { - gsl_matrix *tmp; + const CHAR *fn = "XLALDestroyConfig()"; - if ( !mat ) - return -1; - if ( mat->size1 != mat->size2 ) - return -1; - - tmp = gsl_matrix_calloc ( mat->size1, mat->size2 ); - - gsl_matrix_transpose_memcpy ( tmp, mat ); - - gsl_matrix_add (mat, tmp ); - - gsl_matrix_scale ( mat, 0.5 ); - - gsl_matrix_free ( tmp ); + LALStatus status = blank_status; - return 0; + if ( !cfg ) { + LogPrintf (LOG_CRITICAL, "%s: invalid NULL input!\n\n", fn ); + XLAL_ERROR (fn, XLAL_EINVAL ); + } -} /* symmetrize() */ + LALDestroyUserVars ( &status ); + if ( status.statusCode ) { + LogPrintf (LOG_CRITICAL, "%s: call to LALDestroyUserVars() failed, status = %d\n\n", fn, status.statusCode ); + XLAL_ERROR ( fn, XLAL_EFUNC ); + } + XLALDestroyResultHistory ( cfg->history ); -/* compute the quadratic form = vec.mat.vec - */ -REAL8 -quad_form ( const gsl_matrix *mat, const gsl_vector *vec ) -{ - UINT4 i, j; - REAL8 ret = 0; - - if ( !mat || !vec ) - return 0; - if ( (mat->size1 != mat->size2) || ( mat->size1 != vec->size ) ) - return 0; + LALFree ( cfg->edat->ephemE ); + LALFree ( cfg->edat->ephemS ); + LALFree ( cfg->edat ); - for (i=0; i < mat->size1; i ++ ) - for (j=0; j < mat->size2; j ++ ) - ret += gsl_vector_get(vec, i) * gsl_matrix_get (mat, i, j) * gsl_vector_get(vec,j); + return XLAL_SUCCESS; - return ret; +} /* XLALDestroyConfig() */ -} /* quad_form() */ /** Load Ephemeris from ephemeris data-files */ @@ -663,15 +570,164 @@ InitEphemeris (const CHAR *ephemDir, /**< directory containing ephems */ edat->ephiles.earthEphemeris = EphemEarth; edat->ephiles.sunEphemeris = EphemSun; - edat->leap = XLALGPSLeapSeconds ( epoch->gpsSeconds ); - LALInitBarycenter(&status, edat); if ( status.statusCode != 0 ) { - XLALPrintError ( "%s: LALInitBarycenter() failed! code = %d, msg = '%s'", status.statusCode, status.statusDescription ); + XLALPrintError ( "%s: LALInitBarycenter() failed! code = %d, msg = '%s'", fn, status.statusCode, status.statusDescription ); return NULL; } return edat; } /* InitEphemeris() */ + +int +XLALOutputDopplerMetric ( FILE *fp, const DopplerMetric *metric, const ResultHistory_t *history ) +{ + const CHAR *fn = "XLALOutputDopplerMetric()"; + + UINT4 i; + REAL8 A, B, C, D; + const DopplerMetricParams *meta; + const PulsarDopplerParams *doppler; + const PulsarAmplitudeParams *Amp; + + if ( !fp || !metric ) { + LogPrintf (LOG_CRITICAL, "%s: illegal NULL input.\n\n", fn ); + XLAL_ERROR ( fn, XLAL_EINVAL ); + } + + /* useful shortcuts */ + meta = &(metric->meta); + doppler = &(meta->signalParams.Doppler); + 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->LAL_VCS_Version ) fprintf (fp, "%%%% LAL Version: %s\n", history->LAL_VCS_Version ); + if ( history->LALApps_VCS_Version ) fprintf (fp, "%%%% LALApps Version: %s\n", history->LALApps_VCS_Version ); + } + + 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; cosi = %g; psi = %g; phi0 = %g;\n", Amp->h0, Amp->cosi, Amp->psi, Amp->phi0 ); + fprintf ( fp, "%%%% DopplerPoint = {\n"); + fprintf ( fp, "%%%% refTime = {%d, %d}\n", + doppler->refTime.gpsSeconds, doppler->refTime.gpsNanoSeconds ); + fprintf ( fp, "%%%% Alpha = %f rad; Delta = %f rad\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->orbit ) + { + const BinaryOrbitParams *orbit = doppler->orbit; + fprintf ( fp, "%%%% orbit = { \n"); + fprintf ( fp, "%%%% tp = {%d, %d}\n", orbit->tp.gpsSeconds, orbit->tp.gpsNanoSeconds ); + fprintf ( fp, "%%%% argp = %g\n", orbit->argp ); + fprintf ( fp, "%%%% asini = %g\n", orbit->asini ); + fprintf ( fp, "%%%% ecc = %g\n", orbit->ecc ); + fprintf ( fp, "%%%% period = %g\n", orbit->period ); + fprintf ( fp, "%%%% }\n"); + } /* if doppler->orbit */ + fprintf ( fp, "%%%% }\n"); + + fprintf ( fp, "%%%% startTime = {%d, %d}\n", meta->startTime.gpsSeconds, meta->startTime.gpsNanoSeconds ); + fprintf ( fp, "%%%% duration = %f\n", meta->Tspan ); + fprintf ( fp, "%%%% detectors = ["); + for ( i=0; i < meta->detInfo.length; i ++ ) + { + if ( i > 0 ) fprintf ( fp, ", "); + fprintf ( fp, "%s", meta->detInfo.sites[i].frDetector.name ); + } + fprintf ( fp, "];\n"); + fprintf ( fp, "%%%% detectorWeights = ["); + for ( i=0; i < meta->detInfo.length; i ++ ) + { + if ( i > 0 ) fprintf ( fp, ", "); + fprintf ( fp, "%f", meta->detInfo.detWeights[i] ); + } + fprintf ( fp, "];\n"); + + /* ----- output phase metric ---------- */ + if ( metric->g_ij ) + { + fprintf ( fp, "\ng_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, metric->g_ij ); + fprintf ( fp, "maxrelerr_gPh = %.2e;\n", metric->maxrelerr_gPh ); + } + + /* ----- output F-metric (and related matrices ---------- */ + if ( metric->gF_ij ) + { + fprintf ( fp, "\ngF_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, metric->gF_ij ); + fprintf ( fp, "\ngFav_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, metric->gFav_ij ); + fprintf ( fp, "\nm1_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, metric->m1_ij ); + fprintf ( fp, "\nm2_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, metric->m2_ij ); + fprintf ( fp, "\nm3_ij = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, metric->m3_ij ); + fprintf ( fp, "maxrelerr_gF = %.2e;\n", metric->maxrelerr_gF ); + } + + /* ----- output Fisher matrix ---------- */ + if ( metric->Fisher_ab ) + { + A = gsl_matrix_get ( metric->Fisher_ab, 0, 0 ); + B = gsl_matrix_get ( metric->Fisher_ab, 1, 1 ); + C = gsl_matrix_get ( metric->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", metric->rho2 ); + + fprintf (fp, "\nFisher_ab = \\\n" ); XLALfprintfGSLmatrix ( fp, METRIC_FORMAT, metric->Fisher_ab ); + } + + return XLAL_SUCCESS; + +} /* XLALOutputDopplerMetric() */ + + +/** Destructor for ResultHistory type + */ +void +XLALDestroyResultHistory ( ResultHistory_t * history ) +{ + + if ( !history ) + return; + + if ( history->app_name ) + XLALFree ( history->app_name ); + + if ( history->cmdline ) + XLALFree ( history->cmdline ); + + if ( history->LAL_VCS_Version ) + XLALFree ( history->LAL_VCS_Version ); + + if ( history->LALApps_VCS_Version ) + XLALFree ( history->LALApps_VCS_Version ); + + XLALFree ( history ); + + return; + +} /* XLALDestroyResultHistory() */ diff --git a/lalapps/src/pulsar/templateBanks/Makefile.am b/lalapps/src/pulsar/templateBanks/Makefile.am index 36eab1675c5fdccd82331678dfcb73cdad733373..6b3c1e57393b3d5f58630a49b818b76b476d322b 100644 --- a/lalapps/src/pulsar/templateBanks/Makefile.am +++ b/lalapps/src/pulsar/templateBanks/Makefile.am @@ -32,3 +32,14 @@ lalapps_matchGrids_SOURCES = matchGrids.c lalapps_FstatMetric_SOURCES = FstatMetric.c lalapps_FstatMetric_v2_SOURCES = FstatMetric_v2.c + + +EXTRA_DIST = testMetricCodes.py + +TESTS = testMetricCodes.py +TESTS_ENVIRONMENT = \ +LAL_TOP_SRCDIR=$(LAL_TOP_SRCDIR) \ +LAL_PREFIX=$(LAL_PREFIX) \ +LAL_DATA_PATH=.:$${LAL_TOP_SRCDIR:+"$${LAL_TOP_SRCDIR}/packages/pulsar/test"}:$${LAL_PREFIX:+"$${LAL_PREFIX}/share/lal"} + +CLEANFILES = Fmetric.dat Fmetric_v2.dat diff --git a/lalapps/src/pulsar/templateBanks/getMesh.c b/lalapps/src/pulsar/templateBanks/getMesh.c index 6e8056fa6c03428267ad4034a4a5bd8f8d197d49..cf4f86f96c628363739798e66b0da0ecdb762993 100644 --- a/lalapps/src/pulsar/templateBanks/getMesh.c +++ b/lalapps/src/pulsar/templateBanks/getMesh.c @@ -22,15 +22,15 @@ * * \author{Reinhard Prix} * - * Standalone code to produce a 'mesh' in the parameter-space + * Standalone code to produce a 'mesh' in the parameter-space * Currently this is just some code to use InitDopplerScan() * directly outside of ComputeFStatistic, and can't do much more - * than generating sky-grids. + * than generating sky-grids. * * UserInput-parameters a compatible with ComputeFStatistic. * * Revision: $Id$ - * + * *-----------------------------------------------------------------------*/ /* ---------- includes ---------- */ @@ -92,7 +92,7 @@ typedef struct REAL8 endTime; /**< GPS end time of observation */ REAL8 duration; /**< OR alternatively: length of observation in seconds */ BOOLEAN projectMetric; /**< project out frequency-component of metric */ - + REAL8 dAlpha; /**< Alpha-resolution if GRID_FLAT or GRID_ISOTROPIC */ REAL8 dDelta; /**< Delta-resolution if ... */ REAL8 AlphaBand; /**< Sky-region interval in Alpha */ @@ -105,20 +105,20 @@ typedef struct INT4 metricType; /**< if GRID_METRIC: what type of metric to use? */ REAL8 metricMismatch; /**< what's the maximal mismatch of the grid? */ CHAR *skyRegion; /**< alternative input: polygon describing skyregion */ - + CHAR *skyGridFile; /**< read in sky-grid if GRID_FILE */ CHAR *outputSkyGrid; /**< write sky-grid into this file */ - + INT4 searchNeighbors; /**< number of desired gridpoints/dimension around central point*/ INT4 randomSeed; /**< random-seed for searchNeighbors grid randomization */ - + CHAR *mergedSFTFile; /**< dummy for CFS-compatibility */ INT4 numSkyPartitions; /**< number of (roughly)equal partitions to split sky-grid into */ INT4 partitionIndex; /**< 0<= index < numSkyPartitions: index of sky-partition to generate */ } UserVariables_t; -typedef struct +typedef struct { CHAR EphemEarth[512]; /**< filename of earth-ephemeris data */ CHAR EphemSun[512]; /**< filename of sun-ephemeris data */ @@ -147,10 +147,10 @@ void setTrueRandomSeed(void); extern int vrbflg; /*---------------------------------------------------------------------- - * main function + * main function *----------------------------------------------------------------------*/ int -main(int argc, char *argv[]) +main(int argc, char *argv[]) { LALStatus status = blank_status; ConfigVariables config = empty_ConfigVariables; @@ -159,7 +159,7 @@ main(int argc, char *argv[]) DopplerSkyScanState thisScan = empty_DopplerSkyScanState; /* current state of the Doppler-scan */ UINT4 nFreq, nf1dot; - lalDebugLevel = 0; + lalDebugLevel = 0; vrbflg = 1; /* verbose error-messages */ /* set LAL error-handler */ @@ -167,10 +167,10 @@ main(int argc, char *argv[]) /* register user-variables */ LAL_CALL (LALGetDebugLevel (&status, argc, argv, 'v'), &status); - LAL_CALL (initUserVars (&status, &uvar), &status); + LAL_CALL (initUserVars (&status, &uvar), &status); - /* read cmdline & cfgfile */ - LAL_CALL (LALUserVarReadAllInput (&status, argc,argv), &status); + /* read cmdline & cfgfile */ + LAL_CALL (LALUserVarReadAllInput (&status, argc,argv), &status); if (uvar.help) /* help requested: we're done */ exit (0); @@ -198,7 +198,7 @@ main(int argc, char *argv[]) scanInit.numSkyPartitions = uvar.numSkyPartitions; scanInit.partitionIndex = uvar.partitionIndex; - + /* figure out searchRegion from UserInput and possibly --searchNeighbors */ config.searchRegion = empty_DopplerRegion; /* set to empty first */ LAL_CALL ( getSearchRegion(&status, &(config.searchRegion), &scanInit, &uvar ), &status); @@ -207,41 +207,41 @@ main(int argc, char *argv[]) /* the following call generates a skygrid plus determines dFreq, df1dot,.. * Currently the complete template-grid is more like a 'foliation' of - * the parameter-space by skygrids, stacked along f and f1dot, + * the parameter-space by skygrids, stacked along f and f1dot, * not a full 4D metric template-grid */ - LAL_CALL ( InitDopplerSkyScan( &status, &thisScan, &scanInit), &status); + LAL_CALL ( InitDopplerSkyScan( &status, &thisScan, &scanInit), &status); /* ---------- overload Frequency- and spindown-resolution if input by user ----------*/ if ( LALUserVarWasSet( &uvar.dFreq ) ) thisScan.dfkdot[0] = uvar.dFreq; - if( LALUserVarWasSet( &uvar.df1dot) ) + if( LALUserVarWasSet( &uvar.df1dot) ) thisScan.dfkdot[1] = uvar.df1dot; /* we write the sky-grid to disk? */ - if ( uvar.outputSkyGrid ) + if ( uvar.outputSkyGrid ) { printf ("\nNow writing sky-grid into file '%s' ...", uvar.outputSkyGrid); LAL_CALL(writeSkyGridFile(&status, thisScan.skyGrid, uvar.outputSkyGrid ), &status); printf (" done.\n\n"); } - + /* ----- output grid-info ----- */ - nFreq = (UINT4)(config.searchRegion.fkdotBand[0] / thisScan.dfkdot[0] + 1e-6) + 1; - nf1dot =(UINT4)(config.searchRegion.fkdotBand[1]/ thisScan.dfkdot[1] + 1e-6) + 1; + nFreq = (UINT4)(config.searchRegion.fkdotBand[0] / thisScan.dfkdot[0] + 1e-6) + 1; + nf1dot =(UINT4)(config.searchRegion.fkdotBand[1]/ thisScan.dfkdot[1] + 1e-6) + 1; /* debug output */ if ( lalDebugLevel ) { printf ("DEBUG: Search-region:\n"); printf (" skyRegion = \"%s\"\n", scanInit.skyRegionString); - printf (" Freq in = [%.16g, %.16g]\n", - config.searchRegion.fkdot[0], + printf (" Freq in = [%.16g, %.16g]\n", + config.searchRegion.fkdot[0], config.searchRegion.fkdot[0] + config.searchRegion.fkdotBand[0]); printf (" f1dot in = [%.16g, %.16g]\n", - config.searchRegion.fkdot[1], + config.searchRegion.fkdot[1], config.searchRegion.fkdot[1] + config.searchRegion.fkdotBand[1]); printf ("\nDEBUG: actual grid-spacings: dFreq = %g, df1dot = %g\n\n", @@ -259,10 +259,10 @@ main(int argc, char *argv[]) { printf ("\n%g\n\n", (REAL8)thisScan.numSkyGridPoints * nFreq * nf1dot ); } - /* output octave-compatible 'search-range' as a matrix: + /* output octave-compatible 'search-range' as a matrix: * [ Alpha, AlphaBand; Delta, DeltaBand; Freq, FreqBand; f1dot, f1dotBand ] */ - else + else { SkyRegion skyregion; DopplerRegion *searchRegion = &(config.searchRegion); @@ -271,26 +271,26 @@ main(int argc, char *argv[]) /* we need to parse the skyRegion string into a SkyRegion, which is easier to handle */ LAL_CALL (ParseSkyRegionString(&status, &skyregion, searchRegion->skyRegionString), &status); - if ( skyregion.vertices) + if ( skyregion.vertices) LALFree ( skyregion.vertices ); - Alpha = skyregion.lowerLeft.longitude; + Alpha = skyregion.lowerLeft.longitude; AlphaBand = skyregion.upperRight.longitude - Alpha; Delta = skyregion.lowerLeft.latitude; DeltaBand = skyregion.upperRight.latitude - Delta; - + Freq = searchRegion->fkdot[0]; FreqBand = searchRegion->fkdotBand[0]; f1dot = searchRegion->fkdot[1]; f1dotBand = searchRegion->fkdotBand[1]; - + /* now write octave-compatible matrix containing the search-region */ - printf ("[%.12g, %.12g; %.12g, %.12g; %.12g, %.12g; %.12g, %.12g ]\n", + printf ("[%.12g, %.12g; %.12g, %.12g; %.12g, %.12g; %.12g, %.12g ]\n", Alpha, AlphaBand, Delta, DeltaBand, Freq, FreqBand, f1dot, f1dotBand ); - + } /* if uvar.searchNeighbors */ /* ----- clean up and exit ----- */ @@ -306,7 +306,7 @@ main(int argc, char *argv[]) LALFree ( config.Detector ); - LALCheckMemoryLeaks(); + LALCheckMemoryLeaks(); return 0; } /* main */ @@ -371,8 +371,6 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) LALregINTUserStruct(status, numSkyPartitions, 0, UVAR_OPTIONAL, "Number of (equi-)partitions to split skygrid into"); LALregINTUserStruct(status, partitionIndex, 0, UVAR_OPTIONAL, "Index [0,numSkyPartitions-1] of sky-partition to generate"); - LALregINTUserStruct(status, metricType, 'M', UVAR_OPTIONAL, "Metric: 0=none,1=Ptole-analytic,2=Ptole-numeric, 3=exact"); - LALregREALUserStruct(status, Freq, 'f', UVAR_REQUIRED, "target frequency"); LALregREALUserStruct(status, f1dot, 's', UVAR_OPTIONAL, "first spindown-value df/dt"); LALregREALUserStruct(status, FreqBand, 'b', UVAR_OPTIONAL, "Search frequency band in Hz"); @@ -381,10 +379,8 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) LALregREALUserStruct(status, dFreq, 'r', UVAR_OPTIONAL, "Frequency resolution in Hz (default: 1/(2*Tsft*Nsft)"); LALregREALUserStruct(status, df1dot, 'e', UVAR_OPTIONAL, "Resolution for f1dot (default: use metric or 1/(2*T^2))"); - LALregINTUserStruct(status, metricType, 'M', UVAR_OPTIONAL, "Metric: 0=none,1=Ptole-analytic,2=Ptole-numeric, 3=exact"); - LALregBOOLUserStruct(status, projectMetric, 0, UVAR_OPTIONAL, "Project metric onto frequency-surface"); - LALregREALUserStruct(status, startTime, 't', UVAR_OPTIONAL, "GPS start time of observation"); - LALregREALUserStruct(status, endTime, 't', UVAR_OPTIONAL, "GPS end time of observation"); + LALregREALUserStruct(status, startTime, 0, UVAR_OPTIONAL, "GPS start time of observation"); + LALregREALUserStruct(status, endTime, 0, UVAR_OPTIONAL, "GPS end time of observation"); LALregREALUserStruct(status, duration, 'T', UVAR_OPTIONAL, "Alternative: Duration of observation in seconds"); LALregSTRINGUserStruct(status,ephemDir, 'E', UVAR_OPTIONAL, "Directory where Ephemeris files are located"); @@ -393,6 +389,7 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) /* ---------- */ LALregINTUserStruct(status, gridType, 0 , UVAR_OPTIONAL, "0=flat, 1=isotropic, 2=metric, 3=file, 4=SkyGridFILE+metric"); LALregINTUserStruct(status, metricType, 'M', UVAR_OPTIONAL, "Metric: 0=none,1=Ptole-analytic,2=Ptole-numeric, 3=exact"); + LALregBOOLUserStruct(status, projectMetric, 0, UVAR_OPTIONAL, "Project metric onto frequency-surface"); LALregREALUserStruct(status, metricMismatch, 'X', UVAR_OPTIONAL, "Maximal mismatch for SKY-grid (adjust value for more dimensions)"); LALregREALUserStruct(status, dAlpha, 'l', UVAR_OPTIONAL, "Resolution in alpha (equatorial coordinates) in radians"); LALregREALUserStruct(status, dDelta, 'g', UVAR_OPTIONAL, "Resolution in delta (equatorial coordinates) in radians"); @@ -409,7 +406,7 @@ initUserVars (LALStatus *status, UserVariables_t *uvar) } /* initUserVars() */ /*----------------------------------------------------------------------*/ -/** do some general initializations, +/** do some general initializations, * e.g. load ephemeris-files (if required), setup detector etc */ void @@ -426,14 +423,11 @@ initGeneral (LALStatus *status, ConfigVariables *cfg, const UserVariables_t *uva cfg->duration = uvar->endTime - uvar->startTime; else cfg->duration = uvar->duration; - + /* ---------- init ephemeris if needed ---------- */ if ( uvar->metricType == LAL_PMETRIC_COH_EPHEM ) { - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; - if (LALUserVarWasSet (&uvar->ephemDir) ) { sprintf(cfg->EphemEarth, "%s/earth%s.dat", uvar->ephemDir, uvar->ephemYear); @@ -449,9 +443,6 @@ initGeneral (LALStatus *status, ConfigVariables *cfg, const UserVariables_t *uva cfg->ephemeris->ephiles.earthEphemeris = cfg->EphemEarth; cfg->ephemeris->ephiles.sunEphemeris = cfg->EphemSun; - TRY (LALLeapSecs(status->statusPtr, &leap, &(cfg->startTimeGPS), &formatAndAcc), status); - cfg->ephemeris->leap = leap; - TRY (LALInitBarycenter (status->statusPtr, cfg->ephemeris), status); } /* end: init ephemeris data */ @@ -475,13 +466,13 @@ void checkUserInputConsistency (LALStatus *status, const UserVariables_t *uvar) { - INITSTATUS (status, "checkUserInputConsistency", rcsid); + INITSTATUS (status, "checkUserInputConsistency", rcsid); if (uvar->ephemYear == NULL) { LALPrintError ("\nNo ephemeris year specified (option 'ephemYear')\n\n"); ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); - } + } /* don't allow negative bands (for safty in griding-routines) */ if ( (uvar->AlphaBand < 0) || (uvar->DeltaBand < 0) ) { @@ -516,7 +507,7 @@ checkUserInputConsistency (LALStatus *status, const UserVariables_t *uvar) if ( (haveAlphaBand && !haveDeltaBand) || (haveDeltaBand && !haveAlphaBand) ) { - LALPrintError ("\nERROR: Need either BOTH (AlphaBand, DeltaBand) or NONE.\n\n"); + LALPrintError ("\nERROR: Need either BOTH (AlphaBand, DeltaBand) or NONE.\n\n"); ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); } @@ -534,7 +525,7 @@ checkUserInputConsistency (LALStatus *status, const UserVariables_t *uvar) if ( useSkyGridFile && !haveSkyGridFile ) { LALPrintError ("\nERROR: gridType=FILE, but no skyGridFile specified!\n\n"); - ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); + ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); } if ( !useSkyGridFile && haveSkyGridFile ) { @@ -546,15 +537,15 @@ checkUserInputConsistency (LALStatus *status, const UserVariables_t *uvar) LALWarning (status, "\nWARNING: We are using skyGridFile, but sky-region was" " also specified ... will be ignored!\n"); } - if ( !useMetric && haveMetric) + if ( !useMetric && haveMetric) { LALWarning (status, "\nWARNING: Metric was specified for non-metric grid..." " will be ignored!\n"); } - if ( useMetric && !haveMetric) + if ( useMetric && !haveMetric) { LALPrintError ("\nERROR: metric grid-type selected, but no metricType selected\n\n"); - ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); + ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); } } /* grid-related checks */ @@ -567,20 +558,20 @@ checkUserInputConsistency (LALStatus *status, const UserVariables_t *uvar) if ( !haveEndTime && !haveDuration ) { LALPrintError ("\nERROR: need either --endTime or --duration!\n\n"); - ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); + ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); } if ( haveEndTime && haveDuration ) { LALPrintError ("\nERROR: can specify only one of --endTime or --duration!\n\n"); - ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); + ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); } if ( haveEndTime && (uvar->endTime < uvar->startTime) ) { LALPrintError ("\nERROR: endTime must be later than startTime!\n\n"); - ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); + ABORT (status, GETMESH_EINPUT, GETMESH_MSGEINPUT); } - + } /* check Tspan */ RETURN (status); @@ -588,21 +579,21 @@ checkUserInputConsistency (LALStatus *status, const UserVariables_t *uvar) /** Determine the DopplerRegion in parameter-space to search over. - * - * Normally this is just given directly by the user and therefore trivial. * - * However, for Monte-Carlo-runs testing the metric-grid we want to search - * a (randomized) 'small' region around a given parameter-space point, - * specifying only the (approx.) number of grid-points desired per dimension. + * Normally this is just given directly by the user and therefore trivial. + * + * However, for Monte-Carlo-runs testing the metric-grid we want to search + * a (randomized) 'small' region around a given parameter-space point, + * specifying only the (approx.) number of grid-points desired per dimension. * This is done by getMCDopplerCube(), which determines the appropriate - * Bands in each direction using the metric. + * Bands in each direction using the metric. * This behavior is triggered by the user-input --searchNeighbors. * * This function allows the user additionally to manually override these Bands. * */ void -getSearchRegion (LALStatus *status, +getSearchRegion (LALStatus *status, DopplerRegion *searchRegion, /**< OUT: the DopplerRegion to search over */ const DopplerSkyScanInit *params, /**< IN: DopplerSkyScan params might be needed */ const UserVariables_t *uvar @@ -611,11 +602,11 @@ getSearchRegion (LALStatus *status, DopplerRegion ret = empty_DopplerRegion; - INITSTATUS (status, "getSearchRegion", rcsid); + INITSTATUS (status, "getSearchRegion", rcsid); ATTATCHSTATUSPTR (status); ASSERT ( searchRegion, status, GETMESH_ENULL, GETMESH_MSGENULL); - ASSERT ( searchRegion->skyRegionString == NULL, status, + ASSERT ( searchRegion->skyRegionString == NULL, status, GETMESH_EINPUT, GETMESH_MSGEINPUT); /* set defaults */ @@ -639,15 +630,15 @@ getSearchRegion (LALStatus *status, - /* if user specified the option -searchNeighbors=N, we generate an + /* if user specified the option -searchNeighbors=N, we generate an * automatic search-region of N grid-steps in each dimension * around the given search-point */ - if ( LALUserVarWasSet(&uvar->searchNeighbors) ) + if ( LALUserVarWasSet(&uvar->searchNeighbors) ) { DopplerRegion cube = empty_DopplerRegion; PulsarDopplerParams signal = empty_PulsarDopplerParams; - + signal.Alpha = uvar->Alpha; signal.Delta = uvar->Delta; signal.fkdot[0] = uvar->Freq; @@ -660,7 +651,7 @@ getSearchRegion (LALStatus *status, setTrueRandomSeed(); /* construct MC doppler-cube around signal-location */ - TRY ( getMCDopplerCube(status->statusPtr, + TRY ( getMCDopplerCube(status->statusPtr, &cube, signal, uvar->searchNeighbors, params), status); /* free previous skyRegionString */ @@ -669,15 +660,15 @@ getSearchRegion (LALStatus *status, /* overload defaults with automatic search-region */ ret = cube; - + } /* if searchNeighbors */ /* ---------- finally, the user can override the 'neighborhood' search-Region * if he explicitly specified search-bands in some (or all) directions. - * + * * The motivation is to allow more selective control over the search-region, * e.g. by setting certain bands to zero. - */ + */ { BOOLEAN haveSkyBands = LALUserVarWasSet(&uvar->AlphaBand) && LALUserVarWasSet(&uvar->DeltaBand); @@ -685,16 +676,16 @@ getSearchRegion (LALStatus *status, { CHAR *str = NULL; TRY ( SkySquare2String( status->statusPtr, &str, - uvar->Alpha, uvar->Delta, + uvar->Alpha, uvar->Delta, uvar->AlphaBand, uvar->DeltaBand), status); - if ( ret.skyRegionString) + if ( ret.skyRegionString) LALFree ( ret.skyRegionString ); ret.skyRegionString = str; } else if ( uvar->skyRegion ) { - if ( ret.skyRegionString) + if ( ret.skyRegionString) LALFree ( ret.skyRegionString ); ret.skyRegionString = LALCalloc(1, strlen(uvar->skyRegion) + 1); strcpy ( ret.skyRegionString, uvar->skyRegion); @@ -734,7 +725,7 @@ getSearchRegion (LALStatus *status, } /* getSearchRegion() */ /** set random-seed from /dev/urandom if possible, otherwise - * from uninitialized local-var ;) + * from uninitialized local-var ;) */ void setTrueRandomSeed(void) @@ -743,7 +734,7 @@ setTrueRandomSeed(void) INT4 seed; /* NOTE: possibly used un-initialized! that's ok!! */ fpRandom = fopen("/dev/urandom", "r"); /* read Linux random-pool for seed */ - if ( fpRandom == NULL ) + if ( fpRandom == NULL ) { LALPrintError ("\nCould not read from /dev/urandom ... using default seed.\n\n"); } diff --git a/lalapps/src/pulsar/templateBanks/getMetric.c b/lalapps/src/pulsar/templateBanks/getMetric.c index bfae6b42ab9cc50cbefbb994f34229dfb37f657e..3494b3c2754da4d046e68afcae9371b5b09c822c 100644 --- a/lalapps/src/pulsar/templateBanks/getMetric.c +++ b/lalapps/src/pulsar/templateBanks/getMetric.c @@ -240,9 +240,6 @@ initGeneral (LALStatus *status, ConfigVariables *cfg, const UserInput *uvar) /* ---------- init ephemeris if needed ---------- */ if ( uvar->metricType == LAL_PMETRIC_COH_EPHEM ) { - LALLeapSecFormatAndAcc formatAndAcc = {LALLEAPSEC_GPSUTC, LALLEAPSEC_STRICT}; - INT4 leap; - if (LALUserVarWasSet (&uvar->ephemDir) ) { sprintf(cfg->EphemEarth, "%s/earth%s.dat", uvar->ephemDir, uvar->ephemYear); @@ -258,9 +255,6 @@ initGeneral (LALStatus *status, ConfigVariables *cfg, const UserInput *uvar) cfg->ephemeris->ephiles.earthEphemeris = cfg->EphemEarth; cfg->ephemeris->ephiles.sunEphemeris = cfg->EphemSun; - TRY (LALLeapSecs(status->statusPtr, &leap, &(cfg->startTimeGPS), &formatAndAcc), status); - cfg->ephemeris->leap = leap; - TRY (LALInitBarycenter (status->statusPtr, cfg->ephemeris), status); } /* end: init ephemeris data */ @@ -340,8 +334,6 @@ void printFlatPulsarMetric (LALStatus *status, const UserInput *uvar, const ConfigVariables *config) { REAL8Vector *metric = NULL; - REAL8Vector *physmetric = NULL; - UINT4 dim, a, b; INITSTATUS (status, "printFlatPulsarMetric", rcsid); ATTATCHSTATUSPTR (status); @@ -386,6 +378,8 @@ printMetric (LALStatus *status, const REAL8Vector *metric ) for ( col = 0; col < dim; col ++ ) { printf (" %.16g", metric->data[ PMETRIC_INDEX(row,col) ] ); + if ( col < dim - 1 ) + printf (", "); } if ( row < dim - 1 ) printf (";\n"); diff --git a/lalapps/src/pulsar/templateBanks/skynet.c b/lalapps/src/pulsar/templateBanks/skynet.c index 82539af377a238bee86e6d19ee10d4de7bce9647..0b77a885081183a79430717f9a66104fd41c63c8 100644 --- a/lalapps/src/pulsar/templateBanks/skynet.c +++ b/lalapps/src/pulsar/templateBanks/skynet.c @@ -121,7 +121,6 @@ int main( int argc, char *argv[] ) EphemerisData *eph = (EphemerisData *)LALMalloc(sizeof(EphemerisData)); eph->ephiles.earthEphemeris = earth; eph->ephiles.sunEphemeris = sun; - eph->leap = 13; /* not valid for 2005 - must change */ /* Set up. */ lal_errhandler = LAL_ERR_EXIT; diff --git a/lalapps/src/pulsar/templateBanks/testFlatLatticeTilingPulsar.c b/lalapps/src/pulsar/templateBanks/testFlatLatticeTilingPulsar.c index 1ad4fadd4d090d2faecca82d52ce01d33d86a064..ee23999ee4d1366d1a4c259f48be04e34a284c78 100644 --- a/lalapps/src/pulsar/templateBanks/testFlatLatticeTilingPulsar.c +++ b/lalapps/src/pulsar/templateBanks/testFlatLatticeTilingPulsar.c @@ -324,7 +324,6 @@ int main(int argc, char *argv[]) { if (inject_count > 0) { UINT4 inject_unmatched = 0; - INT4 inject_hit_count_bins = 0; /* Allocate memory */ ALLOC_GSL_VECTOR_INT(inject_min_mismatch_hist, inject_min_mismatch_bins, LALAPPS_ERROR); diff --git a/lalapps/src/ring/coincringread.c b/lalapps/src/ring/coincringread.c index fb9c158fc016e0678acefad3ab80c1995880fdd9..8a9dd217cc7a824c7e409c7d2513888b4b20e736 100644 --- a/lalapps/src/ring/coincringread.c +++ b/lalapps/src/ring/coincringread.c @@ -135,7 +135,6 @@ int distanceCut = 0; int main( int argc, char *argv[] ) { /* lal initialization variables */ - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; LALStatus status = blank_status ; /* program option variables */ @@ -223,8 +222,7 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->start_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION, "$Revi" "sion$")) { XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, @@ -1230,8 +1228,7 @@ why?????????????? /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL(LALGPSTimeNow(&status, &(proctable.processTable->end_time), - &accuracy), &status); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, @@ -1472,4 +1469,5 @@ why?????????????? if ( vrbflg ) fprintf( stdout, "checking memory leaks and exiting\n" ); LALCheckMemoryLeaks(); exit( 0 ); + } diff --git a/lalapps/src/ring/collatesim.c b/lalapps/src/ring/collatesim.c index c5c4da253fc607bcbb1920b3a12f4da87a9f4d93..1a4c26817a1b6a463c303b40075a665ffaeeb5a1 100644 --- a/lalapps/src/ring/collatesim.c +++ b/lalapps/src/ring/collatesim.c @@ -98,7 +98,6 @@ int main( int argc, char *argv[] ) { /* lal initialization variables */ LALStatus stat = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* program option variables */ extern int vrbflg; @@ -146,8 +145,7 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &stat, - &(proctable.processTable->start_time), &accuracy ), &stat ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION, "$Revi" "sion$")) { XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, @@ -387,8 +385,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL( LALGPSTimeNow ( &stat, &(proctable.processTable->start_time), - &accuracy ), &stat ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &stat, &xmlStream, process_table ), &stat ); LAL_CALL( LALWriteLIGOLwXMLTable( &stat, &xmlStream, proctable, diff --git a/lalapps/src/ring/injsgnl.c b/lalapps/src/ring/injsgnl.c index e539ab48f64e5e8041a116ec7382b25df65830a9..a225af32468aff44a43e7abe6b322f6312045f6e 100644 --- a/lalapps/src/ring/injsgnl.c +++ b/lalapps/src/ring/injsgnl.c @@ -94,7 +94,7 @@ int inject_signal( for ( thisInject = ringList; thisInject; thisInject = thisInject->next ) ++numInject; break; - case imr_inject: case imr_ring_inject: case EOBNR_inject: + case imr_inject: case imr_ring_inject: case EOBNR_inject: case Phenom_inject: numInject = SimInspiralTableFromLIGOLw( &injectList, injFile, startSec, stopSec ); break; @@ -140,7 +140,7 @@ int inject_signal( LAL_CALL( LALFindChirpInjectIMR( &status, series, injectList, ringList, response, injectSignalType ), &status ); break; - case EOBNR_inject: + case EOBNR_inject: case Phenom_inject: LAL_CALL( LALFindChirpInjectSignals( &status, series, injectList, response ), &status ); break; default: diff --git a/lalapps/src/ring/plottrigs.m b/lalapps/src/ring/plottrigs.m index 26a932f2d6472e59edae409cc1c510f4d6e4553b..1a0241812c1d2f7604c7b78d7ed9c12b4bdebd10 100644 --- a/lalapps/src/ring/plottrigs.m +++ b/lalapps/src/ring/plottrigs.m @@ -55,7 +55,7 @@ if length(veto_list)>0 && exist('H1vetolist.mat','file')==0 H2vetoend=H2veto(:,3); j=1; for i=1:length(H2vetostart) - H2vetolist=[H1vetolist, H1vetostart(i):H1vetoend(i)-1]; + H2vetolist=[H2vetolist, H2vetostart(i):H2vetoend(i)-1]; end save H2vetolist.mat H2vetolist fprintf('H2 veto list saved\n') @@ -66,7 +66,7 @@ if length(veto_list)>0 && exist('H1vetolist.mat','file')==0 L1vetoend=L1veto(:,3); j=1; for i=1:length(L1vetostart) - L1vetolist=[H1vetolist, H1vetostart(i):H1vetoend(i)-1]; + L1vetolist=[L1vetolist, L1vetostart(i):L1vetoend(i)-1]; end save L1vetolist.mat L1vetolist fprintf('L1 veto list saved\n') diff --git a/lalapps/src/ring/rinca.c b/lalapps/src/ring/rinca.c index c33e53efe1d0b5e227a7ff33dcbf914bb5f34ec5..b069b104e5f260fe4496f1f27bebb15ba55559d6 100644 --- a/lalapps/src/ring/rinca.c +++ b/lalapps/src/ring/rinca.c @@ -138,7 +138,6 @@ static void print_usage(char *program) " [--h2-ds_sq-accuracy] ds_sq specify the ds squared accuracy\n"\ " [--l1-ds_sq-accuracy] ds_sq specify the ds squared accuracy\n"\ "\n"\ - " [--sample-rate] srate specify the sample rate used in the filtering code\n"\ " --data-type data_type specify the data type, must be one of\n"\ " (playground_only|exclude_play|all_data)\n"\ "\n"\ @@ -155,7 +154,6 @@ static void print_usage(char *program) int main( int argc, char *argv[] ) { static LALStatus status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; extern int vrbflg; @@ -268,7 +266,6 @@ int main( int argc, char *argv[] ) {"h1-ds_sq-accuracy", required_argument, 0, 'E'}, {"h2-ds_sq-accuracy", required_argument, 0, 'F'}, {"l1-ds_sq-accuracy", required_argument, 0, 'G'}, - {"sample-rate", required_argument, 0, 'K'}, {"parameter-test", required_argument, 0, 'a'}, {"gps-start-time", required_argument, 0, 's'}, {"gps-end-time", required_argument, 0, 't'}, @@ -302,8 +299,7 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION, "$Revi" "sion$")) { XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, @@ -469,12 +465,6 @@ int main( int argc, char *argv[] ) ADD_PROCESS_PARAM( "float", "%s", optarg ); break; - case 'K': - /* quality factor accuracy L1 */ - accuracyParams.minimizerStep = atof(optarg); - ADD_PROCESS_PARAM( "float", "%le", optarg ); - break; - case 'c': /* slide time for H1 */ slideStep[LAL_IFO_H1] = atof( optarg ); @@ -769,14 +759,6 @@ int main( int argc, char *argv[] ) fprintf( stderr, "Error: --parameter-test must be specified\n" ); exit( 1 ); } - - /* time step for ds_sq_fQt minimizer */ - if ( accuracyParams.test == ds_sq_fQt && ! accuracyParams.minimizerStep ) - { - fprintf( stderr, "Error: --sample-rate must be specified for ds_sq_fQt parameter test\n"); - exit(1); - } - /* Data Type */ if ( dataType == unspecified_data_type ) @@ -828,13 +810,7 @@ if ( vrbflg) "%d specified\n", numIFO ); exit ( 1 ); } - - if ( numIFO == 2 && multiIfoCoinc ) - { - fprintf( stderr, "Must specify three IFOs to do multi-ifo coincidence\n"); - exit ( 1 ); - } - + if ( numIFO > 2 && vrbflg ) { if ( !multiIfoCoinc ) @@ -1261,6 +1237,9 @@ if ( vrbflg) for ( ifoNumber = 0; ifoNumber< LAL_NUM_IFO; ifoNumber++) { + if ( vetoSegs[ifoNumber].initMagic != SEGMENTSH_INITMAGICVAL ) + /* no veto segs */ + continue; if ( XLALTimeSlideSegList( &vetoSegs[ifoNumber], &startCoinc, &endCoinc, &slideTimes[ifoNumber] ) < 0 ) exit(1); @@ -1502,8 +1481,7 @@ cleanexit: snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, ifos ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlStream, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlStream, proctable, diff --git a/lalapps/src/ring/ring_option.c b/lalapps/src/ring/ring_option.c index 2cb701578db87148c8e08bc29be16f8f79b4a51d..d945e8b4c95b9616c891f51588e3769c3425627c 100644 --- a/lalapps/src/ring/ring_option.c +++ b/lalapps/src/ring/ring_option.c @@ -188,11 +188,15 @@ int ring_parse_options( struct ring_params *params, int argc, char **argv ) { localparams.injectType = 3; } + else if( ! strcmp( "Phenom", optarg ) ) + { + localparams.injectType = 4; + } else { localparams.injectType = -1; fprintf( stderr, "invalid --injection_type:\n" - "(must be ringdown, imr, imr_ringdown or EOBNR\n" ); + "(must be ringdown, imr, imr_ringdown, EOBNR or Phenom)\n" ); exit( 1 ); } break; diff --git a/lalapps/src/ring/ring_output.c b/lalapps/src/ring/ring_output.c index 3f69cdfe674bf32c6f18b04465f558386852c142..64d1567740c89adae41c6c92f5666601f180245d 100644 --- a/lalapps/src/ring/ring_output.c +++ b/lalapps/src/ring/ring_output.c @@ -101,11 +101,9 @@ ProcessParamsTable * create_process_params( int argc, char **argv, strncpy( thisParam->program, program, LIGOMETA_PROGRAM_MAX - 1 ); strncpy( thisParam->param, opt, LIGOMETA_PARAM_MAX - 1 ); + strncpy( thisParam->type, "string", LIGOMETA_TYPE_MAX - 1 ); if ( val ) - { - strncpy( thisParam->type, "string", LIGOMETA_TYPE_MAX - 1 ); strncpy( thisParam->value, val, LIGOMETA_VALUE_MAX - 1 ); - } } LALFree( opt ); @@ -184,7 +182,6 @@ int ring_output_events_xml( ProcessTable *ring_create_process_table( struct ring_params *params ) { LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; ProcessTable *processTable = NULL; processTable = LALCalloc( 1, sizeof( *processTable ) ); @@ -203,7 +200,7 @@ ProcessTable *ring_create_process_table( struct ring_params *params ) strncpy( processTable->comment, " ", LIGOMETA_COMMENT_MAX ); strncpy( processTable->ifos, params->ifoName, LIGOMETA_IFOS_MAX ); - LAL_CALL( LALGPSTimeNow( &status, &processTable->end_time, &accuracy ), &status ); + XLALGPSTimeNow(&processTable->end_time); return processTable; } @@ -245,6 +242,7 @@ static SearchSummaryTable *ring_create_search_summary( struct ring_params *param searchSummary->out_end_time = outEndTime; XLALGPSAdd( &searchSummary->out_end_time, 1.0 * params->padData); searchSummary->nevents = params->numEvents; + strncpy( searchSummary->ifos, params->ifoName, LIGOMETA_IFOS_MAX ); return searchSummary; } diff --git a/lalapps/src/ring/ring_test.ini b/lalapps/src/ring/ring_test.ini index 84bc0e1aee93243339256835837baa05ca58e7df..7748455fcdffb54aad2771e6e40bf54572caef01 100644 --- a/lalapps/src/ring/ring_test.ini +++ b/lalapps/src/ring/ring_test.ini @@ -1,59 +1,57 @@ ; s5 ringdown pipeline configuration script. -; -; $Id$ ; -; this is the configuration file for the inspiral DAG generation program +; $Id: ring_test.ini,v 1.3 2008/08/18 18:35:01 lgoggin Exp $ +; +; this is the configuration file for the inspiral DAG generation program ; lalapps_inspiral_hipe that creates a condor DAG to run the ringdown ; analysis pipeline. [condor] ; setup of condor universe and location of executables universe = standard -;universe = vanilla -datafind = /scratch4/lgoggin/s5tag/opt/lscsoft/glue/bin/LSCdataFind +datafind = /scratch4/lgoggin/imrdev/opt/lscsoft/lalsuite/glue/bin/LSCdataFind tmpltbank = /bin/false -ring = /scratch4/lgoggin/s5tag/opt/lscsoft/lalapps/bin/lalapps_ring -inspiral = /scratch4/lgoggin/s5tag/opt/lscsoft/lalapps/bin/lalapps_ring +inspiral = /scratch4/lgoggin/imrdev/opt/lscsoft/lalsuite/lalapps/bin/lalapps_ring inca = /bin/false -rinca = /scratch4/lgoggin/s5tag/opt/lscsoft/lalapps/bin/lalapps_rinca -thinca = /scratch4/lgoggin/s5tag/opt/lscsoft/lalapps/bin/lalapps_rinca -inspinj = /scratch4/lgoggin/s5tag/opt/lscsoft/lalapps/bin/lalapps_rinj +thinca = /scratch4/lgoggin/imrdev/opt/lscsoft/lalsuite/lalapps/bin/lalapps_rinca +; chose the inspinj job to point to lalapps_inspinj or lalapps_rinj as appropriate +;inspinj = /scratch4/lgoggin/imrdev/opt/lscsoft/lalsuite/lalapps/bin/lalapps_rinj +inspinj = /scratch4/lgoggin/imrdev/opt/lscsoft/lalsuite/lalapps/bin/lalapps_inspinj trigtotmplt = /bin/false trigbank = /bin/false sire = /bin/false cohbank = /bin/false chia = /bin/false -frjoin = /scratch4/lgoggin/s5tag/opt/lscsoft/lalapps/bin/lalapps_frjoin -coire = /home/false - +frjoin = /bin/false +coire = /scratch4/lgoggin/imrdev/opt/lscsoft/lalsuite/lalapps/bin/lalapps_coincringread [pipeline] ; tagging information for the configure script -version = $Id$ -cvs-tag = $Name$ +version = $Id: ring_test.ini,v 1.3 2008/08/18 18:35:01 lgoggin Exp $ +cvs-tag = $Name: $ ; user-tag here can be overidden on the command line of lalapps_inspiral_pipe -user-tag = +user-tag = ; data choice (playground_only|exclude_playground|all_data) playground-data-mask = all_data [input] -; the segments file should be the output from segwizard with DQ flags applied -; if no segment file if specified, assumed no data from that IFO. -h1-segments = H1-SELECTED_SEGS-823255302-8100089.txt -h2-segments = H2-SELECTED_SEGS-823255302-8100089.txt -l1-segments = L1-SELECTED_SEGS-823255302-8100089.txt -g1-segments = +; the segment lists (in four column format) +h1-segments = H1-SELECTED_SEGS-871147814-86400.txt +h2-segments = H2-SELECTED_SEGS-871147814-86400.txt +l1-segments = L1-SELECTED_SEGS-871147814-86400.txt +g1-segments = ligo-channel = LSC-STRAIN -geo-channel = -geo-bank = -virgo-channel = +geo-channel = +geo-bank = +virgo-channel = ligo-type = RDS_C03_L2 -geo-type = -num-slides = -;injection seed (if blank then no injections) -injection-seed = 1234 -gps-start-time = 823255302 -gps-end-time = 831355391 +geo-type = +; if running timeslides put the number in here (usually 50), otherwise leave blank +num-slides = +; if running injections put the seed number in here, otherwise leave blank +injection-seed = 2003 +gps-start-time = 871147814 +gps-end-time = 871234214 [condor-max-jobs] ;maximum number of jobs that condor should run of a given category @@ -62,10 +60,11 @@ thinca = 20 trigbank = 20 coire = 20 sire = 20 - + [calibration] ; location of the calibration cache and the cache files -path = /home/lgoggin/projects/ringdown/s5/calibration +; although we are using calibrated data, this field still needs to be read in. *FIXME* +path = /home/lgoggin/projects/ringdown/s5/calibration L1 = L1_CAL_REF_DARM_ERR_S5_V1_U.cache H1 = H1_CAL_REF_DARM_ERR_S5_V1_U.cache H2 = H2_CAL_REF_DARM_ERR_S5_V1_U.cache @@ -79,9 +78,6 @@ match = localhost [data] ; data conditioning parameters common to all ifos pad-data = 8 -;segment-length = 1048576 -;number-of-segments = 16 -;sample-rate = 4096 sample-rate = 8192 block-duration = 2176 segment-duration = 256 @@ -90,9 +86,9 @@ segment-duration = 256 ; data conditioning parameters for ligo data strain-data = highpass-frequency = 35 -cutoff-frequency = 39 +cutoff-frequency = 39 dynamic-range-factor = 1.0e+20 -geo-data = +geo-data = geo-highpass-frequency = 30 geo-data-scale = 1.0e+20 @@ -110,7 +106,8 @@ geo-data-scale = 1.0e+20 [inspiral] ; analysis parameters -- added to all ring jobs -injection-type = ringdown +; comment out the following line if not runnng injections +injection-type = EOBNR bank-max-mismatch = 0.03 bank-min-frequency = 50 bank-max-frequency = 2000 @@ -119,8 +116,6 @@ bank-max-quality = 20.0 bank-template-phase = 0 maximize-duration = 1 debug-level = 33 -;approximant = ringdown -;segment-overlap = 64 [no-veto-inspiral] ; not used in ringdown pipeline @@ -143,18 +138,28 @@ threshold = 5.5 [g1-inspiral] [inspinj] -;injection options (rinj) -;distribution options log_10(frequency) = 0, frequency = 1, mass = 2 -waveform = Ringdown -inj-distr = 0 -time-step = 2630 -minimum-frequency = 50 -maximum-frequency = 2000 -minimum-quality = 2 -maximum-quality = 20 -minimum-distance = 10 -maximum-distance = 1000000 -epsilon = 0.01 +; EOBNR injection parameters +time-step = 2.630000e+03 +time-interval = 5.000000e+01 +d-distr = log10 +l-distr = random +m-distr = logTotalMassUniformMassRatio +i-distr = uniform +f-lower = 10.000000 +min-mass1 = 1.000000e+00 +min-mass2 = 1.000000e+00 +max-mass1 = 3.700000e+02 +max-mass2 = 3.700000e+02 +min-mtotal = 10 +max-mtotal = 3.600000e+02 +min-mratio = 1.000000e+00 +max-mratio = 10 +min-distance = 1000 +max-distance = 300000 +waveform = EOBNRpseudoFourPN +disable-spin = +taper-injection = start +write-sim-ring= [inca] ; not used in ringdown pipeline @@ -167,17 +172,14 @@ maximization-interval = 1 parameter-test = ds_sq_fQt h1-time-accuracy = 2 h2-time-accuracy = 2 -l1-time-accuracy = 2 -;h1-freq-accuracy = 20 -;h2-freq-accuracy = 20 -;l1-freq-accuracy = 20 -;h1-quality-accuracy = 3 -;h2-quality-accuracy = 3 -;l1-quality-accuracy = 3 -h1-ds_sq-accuracy = 0.2 -h2-ds_sq-accuracy = 0.2 -l1-ds_sq-accuracy = 0.2 -sample-rate = 8192 +l1-time-accuracy = 2 +h1-ds_sq-accuracy = 0.4 +h2-ds_sq-accuracy = 0.4 +l1-ds_sq-accuracy = 0.4 +do-veto = +h1-veto-file = H1-CATEGORY_2_VETO_SEGS-871147814-86400.txt +h2-veto-file = H2-CATEGORY_2_VETO_SEGS-871147814-86400.txt +l1-veto-file = L1-CATEGORY_2_VETO_SEGS-871147814-86400.txt [thinca-1] ; not used in ringdown pipeline @@ -188,7 +190,7 @@ sample-rate = 8192 [thinca-slide] ; time slide parameters h1-slide = 0 -h2-slide = 10 +h2-slide = 0 l1-slide = 5 [trigtotmplt] @@ -205,10 +207,10 @@ l1-slide = 5 [cohbank] ; not used in ringdown pipeline - + [trigbank-coherent] ; not used in ringdown pipeline - + [chia] ; not used in ringdown pipeline @@ -219,11 +221,22 @@ l1-slide = 5 ; not used in ringdown pipeline [coire] -; not used in ringdown pipeline +cluster-time = 10000 +coinc-stat = bitten_l +h1-bittenl-a = 2 +h1-bittenl-b = 2.2 +h2-bittenl-a = 2 +h2-bittenl-b = 2.2 +sort-triggers = +h1-h2-distance-cut = +h1-kappa = 2 +h2-kappa = 2 + +[coire-inj] +injection-window = 100 [inspiral-coherent] ; not used in ringdown pipeline [coh-trig] ; not used in ringdown pipeline - diff --git a/lalapps/src/ring/ringread.c b/lalapps/src/ring/ringread.c index d31d53af0b06b26f3b7161fffd96dcbd6928d2b2..16b47e91d2e9d91bec4ff899147ada54b5e3be0d 100644 --- a/lalapps/src/ring/ringread.c +++ b/lalapps/src/ring/ringread.c @@ -126,7 +126,6 @@ int main( int argc, char *argv[] ) { /* lal initialization variables */ LALStatus stat = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; /* program option variables */ extern int vrbflg; @@ -209,8 +208,7 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &stat, &(proctable.processTable->start_time), - &accuracy ), &stat ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION, "$Revi" "sion$")) { XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, @@ -1407,8 +1405,7 @@ int main( int argc, char *argv[] ) /* write out the process and process params tables */ if ( vrbflg ) fprintf( stdout, "process... " ); - LAL_CALL( LALGPSTimeNow ( &stat, &(proctable.processTable->start_time), - &accuracy ), &stat ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &stat, &xmlStream, process_table ), &stat ); LAL_CALL( LALWriteLIGOLwXMLTable( &stat, &xmlStream, proctable, diff --git a/lalapps/src/ring/rinj.c b/lalapps/src/ring/rinj.c index 1b2bff0e6460968cfab133b19cc12b612d18019f..3a0ad0ca516e35472649f67445e3a0fe24685495 100644 --- a/lalapps/src/ring/rinj.c +++ b/lalapps/src/ring/rinj.c @@ -127,7 +127,6 @@ ProcessParamsTable *next_process_param( const char *name, const char *type, int main( int argc, char *argv[] ) { LALStatus status = blank_status; - LALLeapSecAccuracy accuracy = LALLEAPSEC_LOOSE; const INT4 S4StartTime = 793130413; /* Tues Feb 22, 2005 at 12:00 CST (10:00 PST) */ const INT4 S4StopTime = 795679213; /* Wed March 23, 2005 at 24:00 CST (22:00 PST) */ @@ -156,7 +155,6 @@ int main( int argc, char *argv[] ) RandomParams *randParams = NULL; REAL4 u, exponent, expt; REAL4 deltaM; - LALMSTUnitsAndAcc gmstUnits = { MST_HRS, LALLEAPSEC_STRICT }; LALGPSandAcc gpsAndAcc; SkyPosition skyPos; LALSource source; @@ -236,8 +234,7 @@ int main( int argc, char *argv[] ) /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->start_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION, "$Revi" "sion$")) { XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, @@ -798,9 +795,14 @@ int main( int argc, char *argv[] ) gpsAndAcc.gps = this_inj->geocent_start_time; /* set gmst */ - LAL_CALL( LALGPStoGMST1( &status, &(this_inj->start_time_gmst), - &(this_inj->geocent_start_time), &gmstUnits ), &status); - + this_inj->start_time_gmst = fmod(XLALGreenwichMeanSiderealTime( + &this_inj->geocent_start_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ + if( XLAL_IS_REAL8_FAIL_NAN(this_inj->start_time_gmst) ) + { + fprintf(stderr, "XLALGreenwichMeanSiderealTime() failed\n"); + exit(1); + } + memset( &skyPos, 0, sizeof(SkyPosition) ); memset( &source, 0, sizeof(LALSource) ); memset( &placeAndGPS, 0, sizeof(LALPlaceAndGPS) ); @@ -915,8 +917,7 @@ int main( int argc, char *argv[] ) /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" ); - LAL_CALL( LALGPSTimeNow ( &status, &(proctable.processTable->end_time), - &accuracy ), &status ); + XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable, diff --git a/lalapps/src/stochastic/Makefile.am b/lalapps/src/stochastic/Makefile.am index 699cc33e002e9577c8fcc5f32a969907e8c518bb..339d2cdd5f480e6dd1f7fe0994e36bbc821105a7 100644 --- a/lalapps/src/stochastic/Makefile.am +++ b/lalapps/src/stochastic/Makefile.am @@ -25,9 +25,10 @@ gitID: cd $(top_builddir)/misc && $(MAKE) gitID BUILT_SOURCES = gitID -## frame library dependant programs +## frame and stochastic library dependant programs if FRAME if LALFRAME +if LALSTOCHASTIC FRAMEPROGRAMS = lalapps_stochastic lalapps_stochastic_fake lalapps_stochastic_virgo lalapps_stochastic_preprocess lalapps_stochastic_SOURCES = $(STOCH_SRCS) lalapps_stochastic_fake_SOURCES = $(STOCH_FAKE_SRCS) @@ -35,28 +36,38 @@ lalapps_stochastic_virgo_SOURCES = $(STOCH_VIRGO_SRCS) lalapps_stochastic_preprocess_SOURCES = $(STOCH_PREPROCESS_SRCS) endif endif +endif -## metaio library dependant programs +## metaio and stochastic library dependant programs if LALMETAIO +if LALSTOCHASTIC METAIOPROGRAMS = lalapps_stopp lalapps_stopp_bayes lalapps_stopp_SOURCES = $(STOPP_SRCS) lalapps_stopp_bayes_SOURCES = $(STOPP_BAYES_SRCS) endif +endif -## other programs +## stochastic library programs +if LALSTOCHASTIC +STOCHASTICPROGRAMS = lalapps_olapredfcn lalapps_olapredfcn_SOURCES = $(OLAPREDFCN_SRCS) +endif -bin_PROGRAMS = lalapps_olapredfcn ${FRAMEPROGRAMS} ${METAIOPROGRAMS} +bin_PROGRAMS = ${STOCHASTICPROGRAMS} ${FRAMEPROGRAMS} ${METAIOPROGRAMS} +if LALSTOCHASTIC if HAVE_PYTHON bin_SCRIPTS = lalapps_stochastic_pipe lalapps_stochastic_bayes pkgpython_DATA = stochastic.py endif +endif INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/lalapps -I$(top_srcdir)/misc LDADD = $(top_builddir)/src/lalapps/liblalapps.la +if LALSTOCHASTIC EXTRA_DIST = stochastic.py stochastic_pipe.in stochastic_bayes.in +endif MOSTLYCLEANFILES = *STOCHASTIC*.xml *CCSPECTRA*.gwf CLEANFILES = python_config.sed lalapps_stochastic_pipe \ lalapps_stochastic_bayes diff --git a/lalapps/src/string/Makefile.pipeline b/lalapps/src/string/Makefile.pipeline index eb8b886d920180254687c1a7a84af7d442a0c432..25bec3d9ab1d397e42a4d638259589117f19303c 100644 --- a/lalapps/src/string/Makefile.pipeline +++ b/lalapps/src/string/Makefile.pipeline @@ -29,8 +29,8 @@ ligolw_add : ligolw_burca : # run ligolw_burca - pushd injections/triggers && ligolw_burca --verbose --coincidence-algorithm stringcusp --program StringSearch --thresholds H1,H2=0.002 --thresholds H1,L1=0.012 --thresholds H2,L1=0.012 --stringcusp-params 3.0,0.5 cafe*.xml.gz ; popd - pushd noninjections/triggers && ligolw_burca --verbose --coincidence-algorithm stringcusp --program StringSearch --thresholds H1,H2=0.002 --thresholds H1,L1=0.012 --thresholds H2,L1=0.012 --stringcusp-params 3.0,0.5 cafe*.xml.gz ; popd + pushd injections/triggers && ligolw_burca --verbose --coincidence-algorithm stringcusp --thresholds H1,H2=0.002 --thresholds H1,L1=0.012 --thresholds H2,L1=0.012 --stringcusp-params 3.0,0.5 cafe*.xml.gz ; popd + pushd noninjections/triggers && ligolw_burca --verbose --coincidence-algorithm stringcusp --thresholds H1,H2=0.002 --thresholds H1,L1=0.012 --thresholds H2,L1=0.012 --stringcusp-params 3.0,0.5 cafe*.xml.gz ; popd ligolw_binjfind : diff --git a/lalapps/src/string/S4_StringDag.ini b/lalapps/src/string/S4_StringDag.ini index 2d16e623a6d70e6659ec8fe8abe1d98f147489c7..a12095c6873af249b6802c7d520b4aa7d961cc48 100644 --- a/lalapps/src/string/S4_StringDag.ini +++ b/lalapps/src/string/S4_StringDag.ini @@ -7,9 +7,9 @@ [condor] universe = standard -datafind = $ENV(HOME)/s4_string/local/bin/LSCdataFind -string = $ENV(HOME)/s4_string/local/bin/lalapps_StringSearch -injection = $ENV(HOME)/s4_string/local/bin/lalapps_binj +datafind = $ENV(HOME)/s4string/local/bin/LSCdataFind +string = $ENV(HOME)/s4string/local/bin/lalapps_StringSearch +injection = $ENV(HOME)/s4string/local/bin/lalapps_binj [pipeline] version = $Id$ @@ -22,10 +22,12 @@ segment-length = 344 trig-overlap = 0 [input] -segments_H1 = S4H1segments.txt -segments_H2 = S4H2segments.txt -segments_L1 = S4L1segments.txt -channel = LSC-STRAIN +segments_H1 = ../S4H1segments.txt +segments_H2 = ../S4H2segments.txt +segments_L1 = ../S4L1segments.txt +channel_H1 = H1:LSC-STRAIN +channel_H2 = H2:LSC-STRAIN +channel_L1 = L1:LSC-STRAIN type_H1 = H1_RDS_C04_LX type_H2 = H2_RDS_C04_LX type_L1 = L1_RDS_C04_LX diff --git a/lalapps/src/string/StringSearch.c b/lalapps/src/string/StringSearch.c index b67cb6a2269b277fd02a5aee3fd4797a79e37673..b1cf19e0baad6a23c795e145743fab4e3d588979 100644 --- a/lalapps/src/string/StringSearch.c +++ b/lalapps/src/string/StringSearch.c @@ -110,14 +110,15 @@ struct CommandLineArgsTag { REAL8 samplerate; /* desired sample rate */ REAL4 fbankstart; /* lowest frequency of templates */ REAL4 fbankhighfcutofflow; /* lowest high frequency cut-off */ + REAL4 fmismatchmax; /* maximal mismatch allowed from 1 template to the next */ char *FrCacheFile; /* Frame cache file */ char *InjectionFile; /* LIGO xml injection file */ char *ChannelName; /* Name of channel to be read in from frames */ - char *outputFileName; /* Name of xml output filename */ + char *outputFileName; /* Name of xml output filename */ INT4 GPSStart; /* GPS start time of segment to be analysed */ INT4 GPSEnd; /* GPS end time of segment to be analysed */ INT4 ShortSegDuration; /* Number of fixed length sub-segments between GPSStart and GPSEnd */ - REAL4 TruncSecs; /* Half the number of seconds truncated at beginning and end of a chunk */ + REAL4 TruncSecs; /* Half the number of seconds truncated at beginning and end of a chunk */ REAL4 power; /* Kink (-5/3) or cusp (-4/3) frequency power law */ REAL4 threshold; /* event SNR threshold */ INT4 fakenoiseflag; /* =0 if real noise =1 if fake gaussian noise */ @@ -135,48 +136,46 @@ struct CommandLineArgsTag { typedef struct GlobalVariablesTag { - INT4 duration; /* duration of entire segment to be analysed */ - LIGOTimeGPS gpsepoch; /* GPS epoch of start of entire segment to be analysed */ - REAL8TimeSeries ht; /* raw input data */ - REAL4TimeSeries *ht_proc; /* processed (band-pass filtered and down-sampled) input data */ - REAL4FrequencySeries Spec; /* average spectrum */ - RealFFTPlan *fplan; /* fft plans */ - RealFFTPlan *rplan; /* fft plans */ + INT4 duration; /* duration of entire segment to be analysed */ + LIGOTimeGPS gpsepoch; /* GPS epoch of start of entire segment to be analysed */ + REAL8TimeSeries *ht; /* raw input data (LIGO data) */ + REAL4TimeSeries *ht_V; /* raw input data (Virgo data) */ + REAL4TimeSeries *ht_proc; /* processed (band-pass filtered and down-sampled) input data */ + REAL4FrequencySeries Spec; /* average spectrum */ + RealFFTPlan *fplan; /* fft plans */ + RealFFTPlan *rplan; /* fft plans */ INT4 seg_length; } GlobalVariables; typedef struct StringTemplateTag { - REAL4 f; /* Template frequency */ - REAL4 norm; /* Template normalisation */ - REAL4 mismatch; /* Template mismatch relative to last one*/ + INT4 findex; /* Template frequency index */ + REAL4 f; /* Template frequency */ + REAL4 norm; /* Template normalisation */ + REAL4 mismatch; /* Template mismatch relative to last one*/ REAL4FrequencySeries StringFilter; /* Frequency domain filter corresponding to this template */ } StringTemplate; /***************************************************************************/ /* GLOBAL VARIABLES */ - -static LALStatus status; INT4 lalDebugLevel=3; -FrCache *framecache; /* frame reading variables */ +FrCache *framecache; /* frame reading variables */ FrStream *framestream=NULL; -GlobalVariables GV; /* A bunch of stuff is stored in here; mainly to protect it from accidents */ +GlobalVariables GV; /* A bunch of stuff is stored in here; mainly to protect it from accidents */ StringTemplate strtemplate[MAXTEMPLATES]; int NTemplates; -LALLeapSecAccuracy accuracy = LALLEAPSEC_STRICT; - SnglBurst *events=NULL; MetadataTable procTable; MetadataTable procparams; MetadataTable searchsumm; CHAR outfilename[256]; -CHAR ifo[3]; +CHAR ifo[4]; REAL4 SAMPLERATE; @@ -184,7 +183,7 @@ int Nevents=0; PassBandParamStruc highpassParams; -REAL8Vector *window; + /***************************************************************************/ @@ -234,74 +233,94 @@ int FreeMem(void); int main(int argc,char *argv[]) { - - if (ReadCommandLine(argc,argv,&CommandLineArgs)) return 1; - - highpassParams.nMax = 4; - highpassParams.f1 = -1; - highpassParams.a1 = -1; - highpassParams.f2 = CommandLineArgs.flow; - highpassParams.a2 = 0.9; /* this means 90% of amplitude at f2 */ - - if (ReadData(CommandLineArgs)) return 2; - - if (CommandLineArgs.InjectionFile != NULL) - { - if (AddInjections(CommandLineArgs)) return 3; - if ( CommandLineArgs.printinjectionflag ) LALSPrintTimeSeries( GV.ht_proc, "injection.txt" ); - } - - if (WindowData()) return 4; - - if (ProcessData()) return 5; - - if ( CommandLineArgs.printdataflag ) - { - int p; - for (p=0; p<(int)GV.ht_proc->data->length; p++) - fprintf(stdout,"%1.15le\n",GV.ht_proc->data->data[p]); - return 0; - } - - - if (DownSample(CommandLineArgs)) return 6; - - - /* re-size the time series to remove the pad */ - if(!XLALResizeREAL4TimeSeries(GV.ht_proc, (int)(CommandLineArgs.pad/GV.ht_proc->deltaT+0.5), - GV.ht_proc->data->length-2*(UINT4)(CommandLineArgs.pad/GV.ht_proc->deltaT+0.5))) - return 6; - - - - /* reduce duration of segment appropriately */ - GV.duration -= 2*CommandLineArgs.pad; - - if (AvgSpectrum(CommandLineArgs)) return 7; - - if (CommandLineArgs.printspectrumflag) LALSPrintFrequencySeries( &(GV.Spec), "Spectrum.txt" ); - - if (CreateTemplateBank(CommandLineArgs)) return 8; - - if (CreateStringFilters(CommandLineArgs)) return 9; - - if (FindStringBurst(CommandLineArgs)) return 10; - - if (CommandLineArgs.cluster != 0.0 && events) - { - - XLALClusterSnglBurstTable(&events, XLALCompareStringBurstByTime, XLALCompareStringBurstByTime, XLALStringBurstCluster); - - XLALSortSnglBurst(&events, XLALCompareSnglBurstByPeakTimeAndSNR); - } - - XLALSnglBurstAssignIDs(events, procTable.processTable->process_id, 0); - - if (OutputEvents(CommandLineArgs)) return 12; - - if (FreeMem()) return 13; - - return 0; + /****** ReadCommandLine ******/ + printf("ReadCommandLine()\n"); + if (ReadCommandLine(argc,argv,&CommandLineArgs)) return 1; + + highpassParams.nMax = 4; + highpassParams.f1 = -1; + highpassParams.a1 = -1; + highpassParams.f2 = CommandLineArgs.flow; + highpassParams.a2 = 0.9; /* this means 90% of amplitude at f2 */ + + /****** ReadData ******/ + printf("ReadData()\n"); + if (ReadData(CommandLineArgs)) return 2; + + /****** AddInjections ******/ + if (CommandLineArgs.InjectionFile != NULL) { + printf("AddInjections()\n"); + if (AddInjections(CommandLineArgs)) return 3; + /* at this stage, ht_proc contains only the injection */ + if ( CommandLineArgs.printinjectionflag ) LALSPrintTimeSeries( GV.ht_proc, "injection.txt" ); + } + + /****** WindowData ******/ + printf("WindowData()\n"); + if (WindowData()) return 4; + + /****** ProcessData ******/ + printf("ProcessData()\n"); + if (ProcessData()) return 5; + + if ( CommandLineArgs.printdataflag ){ + int p; + for (p=0; p<(int)GV.ht_proc->data->length; p++) + fprintf(stdout,"%1.15e\n",GV.ht_proc->data->data[p]); + return 0; + } + + /****** DownSample ******/ + printf("DownSample()\n"); + if (DownSample(CommandLineArgs)) return 6; + + /****** XLALResizeREAL4TimeSeries ******/ + printf("XLALResizeREAL4TimeSeries()\n"); + /* re-size the time series to remove the pad */ + GV.ht_proc = XLALResizeREAL4TimeSeries(GV.ht_proc, + (int)(CommandLineArgs.pad/GV.ht_proc->deltaT+0.5), + GV.ht_proc->data->length-2*(UINT4)(CommandLineArgs.pad/GV.ht_proc->deltaT+0.5)); + + /* reduce duration of segment appropriately */ + GV.duration -= 2*CommandLineArgs.pad; + + /****** AvgSpectrum ******/ + printf("AvgSpectrum()\n"); + if (AvgSpectrum(CommandLineArgs)) return 7; + if (CommandLineArgs.printspectrumflag) LALSPrintFrequencySeries( &(GV.Spec), "Spectrum.txt" ); + + /****** CreateTemplateBank ******/ + printf("CreateTemplateBank()\n"); + if (CreateTemplateBank(CommandLineArgs)) return 8; + + /****** CreateStringFilters ******/ + printf("CreateStringFilters()\n"); + if (CreateStringFilters(CommandLineArgs)) return 9; + + /****** FindStringBurst ******/ + printf("FindStringBurst()\n"); + if (FindStringBurst(CommandLineArgs)) return 10; + + /****** XLALClusterSnglBurstTable ******/ + printf("XLALClusterSnglBurstTable()\n"); + if (CommandLineArgs.cluster != 0.0 && events){ + XLALClusterSnglBurstTable(&events, XLALCompareStringBurstByTime, XLALCompareStringBurstByTime, XLALStringBurstCluster); + XLALSortSnglBurst(&events, XLALCompareSnglBurstByPeakTimeAndSNR); + } + + /****** XLALSnglBurstAssignIDs ******/ + printf("XLALSnglBurstAssignIDs()\n"); + XLALSnglBurstAssignIDs(events, procTable.processTable->process_id, 0); + + /****** OutputEvents ******/ + printf("OutputEvents()\n"); + if (OutputEvents(CommandLineArgs)) return 12; + + /****** FreeMem ******/ + printf("FreeMem()\n"); + if (FreeMem()) return 13; + + return 0; } @@ -310,76 +329,52 @@ int main(int argc,char *argv[]) /*******************************************************************************/ - -int WindowData(void) -{ +int WindowData(void){ + REAL8Window *window; REAL8 r = 0.001; int k; - int N=GV.ht.data->length; - int kl=r/2*(N-1)+1; - int kh=N-r/2*(N-1)+1; - - /* FIXME: Here I need to add a check to make sure the Tukey window - does not eat past the pad. Need to add CLA to function args */ - /* FIXME: if this is a Tukey window, use LAL's window code to generate - * it */ - - LALDCreateVector(&status,&window,GV.ht.data->length); - TESTSTATUS( &status ); - - for(k = 1; k < kl; k++) - { - window->data[k-1]=0.5*( 1 + cos( LAL_TWOPI/r*(k-1)/(N-1) - LAL_PI)); - } - - for(k = kl; k < kh; k++) - { - window->data[k-1]=1.0; - } - - for(k = kh; k <= N; k++) - { - window->data[k-1]=0.5*( 1 + cos( LAL_TWOPI/r - LAL_TWOPI/r*(k-1)/(N-1) - LAL_PI)); - } - + int N=GV.ht->data->length; + + window = XLALCreateTukeyREAL8Window(N, r); + for (k = 0; k < N; k++) - { - GV.ht.data->data[k] *= window->data[k]; - } + GV.ht->data->data[k] *= window->data->data[k]; + + XLALDestroyREAL8Window(window); - LALDDestroyVector(&status,&window); - TESTSTATUS( &status ); - return 0; } /*******************************************************************************/ -int AddInjections(struct CommandLineArgsTag CLA) -{ +int AddInjections(struct CommandLineArgsTag CLA){ REAL8TimeSeries *injections; - LIGOTimeGPS startTime = GV.ht.epoch; - LIGOTimeGPS stopTime = GV.ht.epoch; + LIGOTimeGPS startTime = GV.ht->epoch; + LIGOTimeGPS stopTime = GV.ht->epoch; SimBurst *sim_burst; unsigned p; - + XLALGPSAdd(&startTime, CLA.ShortSegDuration / 4 + CLA.pad); - XLALGPSAdd(&stopTime, GV.ht_proc->data->length * GV.ht_proc->deltaT - CLA.ShortSegDuration / 4 - CLA.pad); + XLALGPSAdd(&stopTime, GV.ht->data->length * GV.ht->deltaT - CLA.ShortSegDuration / 4 - CLA.pad); /* Get info from injection file */ sim_burst = XLALSimBurstTableFromLIGOLw(CLA.InjectionFile, &startTime, &stopTime); - + /* new injection code is double precision, so we need to create a * buffer to put the injections in and then quantize to single precision * for the string code */ injections = XLALCreateREAL8TimeSeries(GV.ht_proc->name, &GV.ht_proc->epoch, GV.ht_proc->f0, GV.ht_proc->deltaT, &GV.ht_proc->sampleUnits, GV.ht_proc->data->length); memset(injections->data->data, 0, injections->data->length * sizeof(*injections->data->data)); - /* Inject the signals into ht_proc; ht_proc has been set to zero - so I can print out injecitons */ - XLALBurstInjectSignals(injections, sim_burst, NULL); - for(p = 0; p < GV.ht_proc->data->length; p++) - GV.ht_proc->data->data[p] += injections->data->data[p]; + /* Inject the signals into ht_proc -> for printing + Inject the signals into ht */ + if(XLALBurstInjectSignals(injections, sim_burst, NULL)) return 1; + for(p = 0; p < GV.ht_proc->data->length; p++){ + GV.ht_proc->data->data[p] += (REAL4)injections->data->data[p]; + GV.ht->data->data[p] += injections->data->data[p]; + } + + /* injection time series is no more needed */ XLALDestroyREAL8TimeSeries(injections); /* free the injection table */ @@ -389,10 +384,6 @@ int AddInjections(struct CommandLineArgsTag CLA) sim_burst = next; } - /* add injections into the data */ - for(p = 0; p < GV.ht.data->length; p++) - GV.ht.data->data[p] += GV.ht_proc->data->data[p]; - return 0; } @@ -400,8 +391,7 @@ int AddInjections(struct CommandLineArgsTag CLA) static ProcessParamsTable **add_process_param(ProcessParamsTable **proc_param, const ProcessTable *process, - const char *type, const char *param, const char *value) -{ + const char *type, const char *param, const char *value){ *proc_param = XLALCreateProcessParamsTableRow(process); snprintf((*proc_param)->program, LIGOMETA_PROGRAM_MAX, PROGRAM_NAME); snprintf((*proc_param)->type, LIGOMETA_TYPE_MAX, type); @@ -413,53 +403,42 @@ static ProcessParamsTable **add_process_param(ProcessParamsTable **proc_param, /*******************************************************************************/ -int OutputEvents(struct CommandLineArgsTag CLA) -{ - LIGOLwXMLStream xml; - LALLeapSecAccuracy accuracy = LALLEAPSEC_STRICT; - MetadataTable myTable; - - if (!CLA.outputFileName) - { - snprintf(outfilename, sizeof(outfilename)-1, "%s-STRINGSEARCH-%d-%d.xml", ifo, - searchsumm.searchSummaryTable->in_start_time.gpsSeconds, - searchsumm.searchSummaryTable->in_end_time.gpsSeconds - - searchsumm.searchSummaryTable->in_start_time.gpsSeconds); - outfilename[sizeof(outfilename)-1] = '\0'; - }else{ - snprintf(outfilename, sizeof(outfilename)-1, "%s", CLA.outputFileName); - outfilename[sizeof(outfilename)-1] = '\0'; - } +int OutputEvents(struct CommandLineArgsTag CLA){ + LIGOLwXMLStream *xml; + + if (!CLA.outputFileName){ + snprintf(outfilename, sizeof(outfilename)-1, "%s-STRINGSEARCH-%d-%d.xml", ifo, + searchsumm.searchSummaryTable->in_start_time.gpsSeconds, + searchsumm.searchSummaryTable->in_end_time.gpsSeconds - + searchsumm.searchSummaryTable->in_start_time.gpsSeconds); + outfilename[sizeof(outfilename)-1] = '\0'; + } + else{ + snprintf(outfilename, sizeof(outfilename)-1, "%s", CLA.outputFileName); + outfilename[sizeof(outfilename)-1] = '\0'; + } - memset(&xml, 0, sizeof(LIGOLwXMLStream)); - LALOpenLIGOLwXMLFile(&status, &xml, outfilename); + xml = XLALOpenLIGOLwXMLFile(outfilename); /* process table */ snprintf(procTable.processTable->ifos, LIGOMETA_IFOS_MAX, "%s", ifo); - LALGPSTimeNow(&status, &(procTable.processTable->start_time), &accuracy); - if(XLALWriteLIGOLwXMLProcessTable(&xml, procTable.processTable)) { - return -1; - } - + XLALGPSTimeNow(&(procTable.processTable->start_time)); + + if(XLALWriteLIGOLwXMLProcessTable(xml, procTable.processTable)) return -1; + /* process params table */ - if(XLALWriteLIGOLwXMLProcessParamsTable(&xml, procparams.processParamsTable)) { - return -1; - } - + if(XLALWriteLIGOLwXMLProcessParamsTable(xml, procparams.processParamsTable)) return -1; + /* search summary table */ snprintf(searchsumm.searchSummaryTable->ifos, LIGOMETA_IFOS_MAX, "%s", ifo); searchsumm.searchSummaryTable->nevents = Nevents; - - if(XLALWriteLIGOLwXMLSearchSummaryTable(&xml, searchsumm.searchSummaryTable)) { - return -1; - } + + if(XLALWriteLIGOLwXMLSearchSummaryTable(xml, searchsumm.searchSummaryTable)) return -1; /* burst table */ - if(XLALWriteLIGOLwXMLSnglBurstTable(&xml, events)) { - return -1; - } - - LALCloseLIGOLwXMLFile(&status, &xml); + if(XLALWriteLIGOLwXMLSnglBurstTable(xml, events)) return -1; + + XLALCloseLIGOLwXMLFile(xml); /* free event list, process table, search summary and process params */ @@ -473,162 +452,140 @@ int OutputEvents(struct CommandLineArgsTag CLA) /*******************************************************************************/ -int FindEvents(struct CommandLineArgsTag CLA, REAL4Vector *vector, INT4 i, INT4 m, SnglBurst **thisEvent) -{ +int FindEvents(struct CommandLineArgsTag CLA, REAL4Vector *vector, INT4 i, INT4 m, SnglBurst **thisEvent){ int p; + REAL4 maximum; + REAL8 duration; + INT4 pmax, pend, pstart; + INT8 peaktime, starttime; + INT8 timeNS; /* print the snr to stdout */ if (CLA.printsnrflag) - { - for ( p = (int)vector->length/4 ; p < (int)(3*vector->length/4); p++ ) - { - fprintf(stdout,"%d %e\n",m, vector->data[p]); - } - } - + for ( p = (int)vector->length/4 ; p < (int)(3*vector->length/4); p++ ) + fprintf(stdout,"%d %e\n",m, vector->data[p]); + /* Now find thisEvent in the inner half */ - for ( p = (int)vector->length/4 ; p < (int)(3*vector->length/4); p++ ) - { - REAL4 maximum = 0.0; - INT4 pmax=p; - INT8 timeNS = (INT8)( 1000000000 ) * (INT8)(GV.ht_proc->epoch.gpsSeconds+GV.seg_length*i/2*GV.ht_proc->deltaT); - timeNS += (INT8)( 1e9 * GV.ht_proc->deltaT * p ); - - /* Do we have the start of a cluster? */ - if ( (fabs(vector->data[p]) > CLA.threshold) && ( (double)(1e-9*timeNS) > (double)CLA.trigstarttime)) - { - INT4 pend=p,pstart=p; - INT8 peaktime, starttime; - REAL8 duration; - - timeNS = (INT8)( 1000000000 ) * (INT8)(GV.ht_proc->epoch.gpsSeconds+GV.seg_length*i/2*GV.ht_proc->deltaT); - - if ( *thisEvent ) /* create a new event */ - { - (*thisEvent)->next = XLALCreateSnglBurst(); - *thisEvent = (*thisEvent)->next; - } - else /* create the list */ - { - *thisEvent = events = XLALCreateSnglBurst(); - } - - if ( ! *thisEvent ) /* allocation error */ - { - fprintf(stderr,"Could not allocate memory for event. Memory allocation error. Exiting. \n"); - return 1; - } - - /* Clustering in time: While we are above threshold, or within clustering time of the last point above threshold... */ - while( ((fabs(vector->data[p]) > CLA.threshold) || ((p-pend)* GV.ht_proc->deltaT < (float)(CLA.cluster)) ) - && p<(int)(3*vector->length/4)) - { - /* This keeps track of the largest SNR point of the cluster */ - if(fabs(vector->data[p]) > maximum) - { - maximum=fabs(vector->data[p]); - pmax=p; - } - /* pend is the last point above threshold */ - if ( (fabs(vector->data[p]) > CLA.threshold)) - { - pend = p; - } - p++; - } - - peaktime = timeNS + (INT8)( 1e9 * GV.ht_proc->deltaT * pmax ); - duration = GV.ht_proc->deltaT * ( pend - pstart ); - - starttime = timeNS + (INT8)( 1e9 * GV.ht_proc->deltaT * pstart ); - - /* Now copy stuff into event */ - strncpy( (*thisEvent)->ifo, CLA.ChannelName, sizeof(ifo)-1 ); - strncpy( (*thisEvent)->search, "StringCusp", sizeof( (*thisEvent)->search ) ); - strncpy( (*thisEvent)->channel, CLA.ChannelName, sizeof( (*thisEvent)->channel ) ); - - /* give trigger a 1 sample fuzz on either side */ - starttime -= GV.ht_proc->deltaT *1e9; - duration += 2*GV.ht_proc->deltaT; - - (*thisEvent)->start_time.gpsSeconds = starttime / 1000000000; - (*thisEvent)->start_time.gpsNanoSeconds = starttime % 1000000000; - (*thisEvent)->peak_time.gpsSeconds = peaktime / 1000000000; - (*thisEvent)->peak_time.gpsNanoSeconds = peaktime % 1000000000; - (*thisEvent)->duration = duration; - (*thisEvent)->central_freq = (strtemplate[m].f+CLA.fbankstart)/2.0; - (*thisEvent)->bandwidth = strtemplate[m].f-CLA.fbankstart; - (*thisEvent)->snr = maximum; - (*thisEvent)->amplitude = vector->data[pmax]/strtemplate[m].norm; - (*thisEvent)->confidence = -fabs((*thisEvent)->amplitude); /* FIXME */ - (*thisEvent)->string_cluster_t = CLA.cluster; + for ( p = (int)vector->length/4 ; p < (int)(3*vector->length/4); p++ ){ + maximum = 0.0; + pmax=p; + timeNS = (INT8)( 1000000000 ) * (INT8)(GV.ht_proc->epoch.gpsSeconds+GV.seg_length*i/2*GV.ht_proc->deltaT); + timeNS += (INT8)( 1e9 * GV.ht_proc->deltaT * p ); + + /* Do we have the start of a cluster? */ + if ( (fabs(vector->data[p]) > CLA.threshold) && ( (double)(1e-9*timeNS) > (double)CLA.trigstarttime)){ + pend=p; pstart=p; + + timeNS = (INT8)( 1000000000 ) * (INT8)(GV.ht_proc->epoch.gpsSeconds+GV.seg_length*i/2*GV.ht_proc->deltaT); + + if ( *thisEvent ){ /* create a new event */ + (*thisEvent)->next = XLALCreateSnglBurst(); + *thisEvent = (*thisEvent)->next; + } + else /* create the list */ + *thisEvent = events = XLALCreateSnglBurst(); + + if ( ! *thisEvent ){ /* allocation error */ + fprintf(stderr,"Could not allocate memory for event. Memory allocation error. Exiting. \n"); + return 1; + } + + /* Clustering in time: While we are above threshold, or within clustering time of the last point above threshold... */ + while( ((fabs(vector->data[p]) > CLA.threshold) || ((p-pend)* GV.ht_proc->deltaT < (float)(CLA.cluster)) ) + && p<(int)(3*vector->length/4)){ + + /* This keeps track of the largest SNR point of the cluster */ + if(fabs(vector->data[p]) > maximum){ + maximum=fabs(vector->data[p]); + pmax=p; } - } + /* pend is the last point above threshold */ + if ( (fabs(vector->data[p]) > CLA.threshold)) + pend = p; + + p++; + } + peaktime = timeNS + (INT8)( 1e9 * GV.ht_proc->deltaT * pmax ); + duration = GV.ht_proc->deltaT * ( pend - pstart ); + + starttime = timeNS + (INT8)( 1e9 * GV.ht_proc->deltaT * pstart ); + + /* Now copy stuff into event */ + strncpy( (*thisEvent)->ifo, CLA.ChannelName, sizeof(ifo)-2 ); + strncpy( (*thisEvent)->search, "StringCusp", sizeof( (*thisEvent)->search ) ); + strncpy( (*thisEvent)->channel, CLA.ChannelName, sizeof( (*thisEvent)->channel ) ); + + /* give trigger a 1 sample fuzz on either side */ + starttime -= GV.ht_proc->deltaT *1e9; + duration += 2*GV.ht_proc->deltaT; + + (*thisEvent)->start_time.gpsSeconds = starttime / 1000000000; + (*thisEvent)->start_time.gpsNanoSeconds = starttime % 1000000000; + (*thisEvent)->peak_time.gpsSeconds = peaktime / 1000000000; + (*thisEvent)->peak_time.gpsNanoSeconds = peaktime % 1000000000; + (*thisEvent)->duration = duration; + (*thisEvent)->central_freq = (strtemplate[m].f+CLA.fbankstart)/2.0; + (*thisEvent)->bandwidth = strtemplate[m].f-CLA.fbankstart; + (*thisEvent)->snr = maximum; + (*thisEvent)->amplitude = vector->data[pmax]/strtemplate[m].norm; + (*thisEvent)->confidence = -fabs((*thisEvent)->amplitude); /* FIXME */ + (*thisEvent)->string_cluster_t = CLA.cluster; + } + } + return 0; } /*******************************************************************************/ -int FindStringBurst(struct CommandLineArgsTag CLA) -{ +int FindStringBurst(struct CommandLineArgsTag CLA){ int i,p,m; REAL4Vector *vector = NULL; COMPLEX8Vector *vtilde = NULL; SnglBurst *thisEvent = NULL; /* create vector that will hold the data for each overlapping chunk */ - LALSCreateVector( &status, &vector, GV.seg_length); - TESTSTATUS( &status ); + vector = XLALCreateREAL4Vector( GV.seg_length); + /* create vector that will hold FFT of data*/ - LALCCreateVector( &status, &vtilde, GV.seg_length / 2 + 1 ); - TESTSTATUS( &status ); + vtilde = XLALCreateCOMPLEX8Vector( GV.seg_length / 2 + 1 ); /* loop over templates */ - for (m = 0; m < NTemplates; m++) - { - /* loop over overlapping chunks */ - for(i=0; i < 2*GV.duration/CLA.ShortSegDuration - 1 ;i++) - { - /* populate vector that will hold the data for each overlapping chunk */ - memcpy( vector->data, GV.ht_proc->data->data + i*GV.seg_length/2,vector->length*sizeof( *vector->data ) ); + for (m = 0; m < NTemplates; m++){ + /* loop over overlapping chunks */ + for(i=0; i < 2*GV.duration/CLA.ShortSegDuration - 1 ;i++){ + /* populate vector that will hold the data for each overlapping chunk */ + memcpy( vector->data, GV.ht_proc->data->data + i*GV.seg_length/2,vector->length*sizeof( *vector->data ) ); - /* fft it */ - LALForwardRealFFT( &status, vtilde, vector, GV.fplan ); - TESTSTATUS( &status ); - - /* multiply FT of data and String Filter and deltaT (latter not included in LALForwardRealFFT) */ - for ( p = 0 ; p < (int) vtilde->length; p++ ) - { - vtilde->data[p].re *= strtemplate[m].StringFilter.data->data[p]*GV.ht_proc->deltaT; - vtilde->data[p].im *= strtemplate[m].StringFilter.data->data[p]*GV.ht_proc->deltaT; - } - - LALReverseRealFFT( &status, vector, vtilde, GV.rplan); - TESTSTATUS( &status ); - - /* normalise the result by template normalisation and multiply by - df (not inluded in LALReverseRealFFT) factor of 2 is from - match-filter definition */ - - for ( p = 0 ; p < (int)vector->length; p++ ) - { - vector->data[p] *= 2.0 * GV.Spec.deltaF / strtemplate[m].norm; - } - - if(FindEvents(CLA, vector, i, m, &thisEvent)) return 1; - } + /* fft it */ + if(XLALREAL4ForwardFFT( vtilde, vector, GV.fplan )) return 1; + + /* multiply FT of data and String Filter and deltaT (latter not included in LALForwardRealFFT) */ + for ( p = 0 ; p < (int) vtilde->length; p++ ){ + vtilde->data[p].re *= strtemplate[m].StringFilter.data->data[p]*GV.ht_proc->deltaT; + vtilde->data[p].im *= strtemplate[m].StringFilter.data->data[p]*GV.ht_proc->deltaT; + } + + if(XLALREAL4ReverseFFT( vector, vtilde, GV.rplan )) return 1; + + /* normalise the result by template normalisation and multiply by + df (not inluded in LALReverseRealFFT) factor of 2 is from + match-filter definition */ + + for ( p = 0 ; p < (int)vector->length; p++ ) + vector->data[p] *= 2.0 * GV.Spec.deltaF / strtemplate[m].norm; + + if(FindEvents(CLA, vector, i, m, &thisEvent)) return 1; } + } /* sort events in time; if there are any */ - if (events) - /* first sort list in increasing GPS peak time */ + if (events) /* first sort list in increasing GPS peak time */ XLALSortSnglBurst(&events, XLALCompareSnglBurstByPeakTimeAndSNR); - LALSDestroyVector( &status, &vector ); - TESTSTATUS( &status ); - LALCDestroyVector( &status, &vtilde ); - TESTSTATUS( &status ); + XLALDestroyCOMPLEX8Vector( vtilde ); + XLALDestroyREAL4Vector( vector ); return 0; } @@ -636,124 +593,106 @@ int FindStringBurst(struct CommandLineArgsTag CLA) /*******************************************************************************/ -int CreateStringFilters(struct CommandLineArgsTag CLA) -{ +int CreateStringFilters(struct CommandLineArgsTag CLA){ - int p, m, f_low_cutoff_index; + int p, m, f_low_cutoff_index, f_high_cutoff_index; COMPLEX8Vector *vtilde; /* frequency-domain vector workspace */ REAL4Vector *vector; /* time-domain vector workspace */ - + REAL4 f, re, im; + REAL4TimeSeries series; + CHAR filterfilename[256]; vector = XLALCreateREAL4Vector( GV.seg_length); vtilde = XLALCreateCOMPLEX8Vector( GV.seg_length / 2 + 1 ); f_low_cutoff_index = (int) (CLA.fbankstart/ GV.Spec.deltaF+0.5); - for (m = 0; m < NTemplates; m++) - { - int f_high_cutoff_index = (int) (strtemplate[m].f/ GV.Spec.deltaF+0.5); + for (m = 0; m < NTemplates; m++){ + f_high_cutoff_index = (int) (strtemplate[m].f/ GV.Spec.deltaF+0.5); - /* create the space for the filter */ - strtemplate[m].StringFilter.deltaF=GV.Spec.deltaF; - LALSCreateVector( &status, &strtemplate[m].StringFilter.data, GV.Spec.data->length ); - TESTSTATUS( &status ); - - /* populate vtilde with the template divided by the noise */ - for ( p = f_low_cutoff_index; p < (int) vtilde->length; p++ ) - { - REAL4 f=p*GV.Spec.deltaF; + /* create the space for the filter */ + strtemplate[m].StringFilter.deltaF=GV.Spec.deltaF; + strtemplate[m].StringFilter.data = XLALCreateREAL4Vector(GV.Spec.data->length); + + /* populate vtilde with the template divided by the noise */ + for ( p = f_low_cutoff_index; p < (int) vtilde->length; p++ ){ + f=p*GV.Spec.deltaF; - vtilde->data[p].re = sqrt(pow(f,CLA.power)/(GV.Spec.data->data[p])); - vtilde->data[p].im = 0; - } + if(f<=strtemplate[m].f) vtilde->data[p].re = sqrt(pow(f,CLA.power)/(GV.Spec.data->data[p])); + else vtilde->data[p].re = sqrt(pow(f,CLA.power)*exp(1-f/strtemplate[m].f)/(GV.Spec.data->data[p])); + vtilde->data[p].im = 0; + } - /* set all frequencies below the low freq cutoff to zero */ - memset( vtilde->data, 0, f_low_cutoff_index * sizeof( *vtilde->data ) ); - - /* set to zero all values greater than the high frequency cutoff corresponding to this template */ - memset( vtilde->data+f_high_cutoff_index, 0, (vtilde->length-f_high_cutoff_index) * sizeof( *vtilde->data ) ); - - /* set DC and Nyquist to zero anyway */ - vtilde->data[0].re = vtilde->data[vtilde->length - 1].re = 0; - vtilde->data[0].im = vtilde->data[vtilde->length - 1].im = 0; - - - /* reverse FFT vtilde into vector */ - LALReverseRealFFT( &status, vector, vtilde, GV.rplan); - TESTSTATUS( &status ); - - /* multiply times df to make sure units are correct */ - for ( p = 0 ; p < (int)vector->length; p++ ) - vector->data[p] *= GV.Spec.deltaF; - - /* perform the truncation; the truncation is CLA.TruncSecs/2 because - we are dealing with the sqrt of the filter at the moment*/ - if(CLA.TruncSecs != 0.0) - { - memset( vector->data + (INT4)(CLA.TruncSecs/2/GV.ht_proc->deltaT +0.5), 0, - ( vector->length - 2 * (INT4)(CLA.TruncSecs/2/GV.ht_proc->deltaT +0.5)) - * sizeof( *vector->data ) ); - } - - /* forward fft the truncated vector into vtilde */ - LALForwardRealFFT( &status, vtilde, vector, GV.fplan); - TESTSTATUS( &status ); - - for ( p = 0 ; p < (int)vtilde->length-1; p++ ) - { - REAL4 re = vtilde->data[p].re * GV.ht_proc->deltaT; - REAL4 im = vtilde->data[p].im * GV.ht_proc->deltaT; - - strtemplate[m].StringFilter.data->data[p] = (re * re + im * im); - } - - /* set DC and Nyquist to 0*/ - strtemplate[m].StringFilter.data->data[0] = - strtemplate[m].StringFilter.data->data[vtilde->length-1] = 0; - - - /* print out the frequency domain filter */ - if (CLA.printfilterflag) - { - CHAR filterfilename[256]; - snprintf(filterfilename, sizeof(filterfilename)-1, "Filter-%d.txt", m); - filterfilename[sizeof(outfilename)-1] = '\0'; - LALSPrintFrequencySeries( &(strtemplate[m].StringFilter), filterfilename ); - } + /* set all frequencies below the low freq cutoff to zero */ + memset( vtilde->data, 0, f_low_cutoff_index * sizeof( *vtilde->data ) ); + + /* set DC and Nyquist to zero anyway */ + vtilde->data[0].re = vtilde->data[vtilde->length - 1].re = 0; + vtilde->data[0].im = vtilde->data[vtilde->length - 1].im = 0; + + /* reverse FFT vtilde into vector */ + if(XLALREAL4ReverseFFT( vector, vtilde, GV.rplan )) return 1; + + /* multiply times df to make sure units are correct */ + for ( p = 0 ; p < (int)vector->length; p++ ) + vector->data[p] *= GV.Spec.deltaF; + + /* perform the truncation; the truncation is CLA.TruncSecs/2 because + we are dealing with the sqrt of the filter at the moment*/ + if(CLA.TruncSecs != 0.0) + memset( vector->data + (INT4)(CLA.TruncSecs/2/GV.ht_proc->deltaT +0.5), 0, + ( vector->length - 2 * (INT4)(CLA.TruncSecs/2/GV.ht_proc->deltaT +0.5)) + * sizeof( *vector->data ) ); + + + /* forward fft the truncated vector into vtilde */ + if(XLALREAL4ForwardFFT( vtilde, vector, GV.fplan )) return 1; + + for ( p = 0 ; p < (int)vtilde->length-1; p++ ){ + re = vtilde->data[p].re * GV.ht_proc->deltaT; + im = vtilde->data[p].im * GV.ht_proc->deltaT; + strtemplate[m].StringFilter.data->data[p] = (re * re + im * im); + } - /* print out the time domain FIR filter */ - if (CLA.printfirflag) - { - REAL4TimeSeries series; - CHAR filterfilename[256]; - - series.deltaT=GV.ht_proc->deltaT; - series.f0 = 0.0; - strncpy(series.name, "fir filter", LALNameLength); - series.epoch=GV.ht_proc->epoch; - series.sampleUnits=GV.ht_proc->sampleUnits; - - for ( p = 0 ; p < (int)vtilde->length-1; p++ ) - { - REAL4 re = vtilde->data[p].re * GV.ht_proc->deltaT; - REAL4 im = vtilde->data[p].im * GV.ht_proc->deltaT; - - vtilde->data[p].re = (re * re + im * im); - vtilde->data[p].im = 0.0; - } - vtilde->data[0].re = vtilde->data[0].im = 0.0; - vtilde->data[vtilde->length-1].re = vtilde->data[vtilde->length-1].im =0; - - LALReverseRealFFT( &status, vector, vtilde, GV.rplan); - - series.data = vector; - - snprintf(filterfilename, sizeof(filterfilename)-1, "FIRFilter-%d.txt", m); - filterfilename[sizeof(outfilename)-1] = '\0'; - LALSPrintTimeSeries( &series, filterfilename ); - } + /* set DC and Nyquist to 0*/ + strtemplate[m].StringFilter.data->data[0] = + strtemplate[m].StringFilter.data->data[vtilde->length-1] = 0; + + /* print out the frequency domain filter */ + if (CLA.printfilterflag){ + snprintf(filterfilename, sizeof(filterfilename)-1, "Filter-%d.txt", m); + filterfilename[sizeof(outfilename)-1] = '\0'; + LALSPrintFrequencySeries( &(strtemplate[m].StringFilter), filterfilename ); } + /* print out the time domain FIR filter */ + if (CLA.printfirflag){ + series.deltaT=GV.ht_proc->deltaT; + series.f0 = 0.0; + strncpy(series.name, "fir filter", LALNameLength); + series.epoch=GV.ht_proc->epoch; + series.sampleUnits=GV.ht_proc->sampleUnits; + + for ( p = 0 ; p < (int)vtilde->length-1; p++ ){ + re = vtilde->data[p].re * GV.ht_proc->deltaT; + im = vtilde->data[p].im * GV.ht_proc->deltaT; + + vtilde->data[p].re = (re * re + im * im); + vtilde->data[p].im = 0.0; + } + vtilde->data[0].re = vtilde->data[0].im = 0.0; + vtilde->data[vtilde->length-1].re = vtilde->data[vtilde->length-1].im =0; + + if(XLALREAL4ReverseFFT( vector, vtilde, GV.rplan )) return 1; + + series.data = vector; + + snprintf(filterfilename, sizeof(filterfilename)-1, "FIRFilter-%d.txt", m); + filterfilename[sizeof(outfilename)-1] = '\0'; + LALSPrintTimeSeries( &series, filterfilename ); + } + } + XLALDestroyCOMPLEX8Vector( vtilde ); XLALDestroyREAL4Vector( vector ); @@ -762,100 +701,127 @@ int CreateStringFilters(struct CommandLineArgsTag CLA) /*******************************************************************************/ -int CreateTemplateBank(struct CommandLineArgsTag CLA) -{ - REAL8 fmax,f,t1t1,t2t2, epsilon; - int p,f_low_index,f_high_index,k; +int CreateTemplateBank(struct CommandLineArgsTag CLA){ + REAL8 fmax, f_cut, f, t1t1, t2t2, t1t2, epsilon, previous_epsilon; + int p, pcut, f_min_index, f_max_index, f_cut_index, k; + REAL4Vector *integral; fmax = (1.0/GV.ht_proc->deltaT) / 2.0; + f_min_index = CLA.fbankstart / GV.Spec.deltaF; + f_max_index = fmax / GV.Spec.deltaF; + integral = XLALCreateREAL4Vector(f_max_index-f_min_index); + epsilon=0; - f_low_index = CLA.fbankstart / GV.Spec.deltaF; - f_high_index = fmax / GV.Spec.deltaF; - - t1t1=0.0; - for ( p = f_low_index ; p < f_high_index; p++ ) - { - f= p*GV.Spec.deltaF; - t1t1 += 4*pow(pow(f,CLA.power),2)/GV.Spec.data->data[p]*GV.Spec.deltaF; - } + /* first template : f_cutoff = fbankhighfcutofflow */ + f_cut = (int)(CLA.fbankhighfcutofflow/GV.Spec.deltaF)*GV.Spec.deltaF; + f_cut_index = CLA.fbankhighfcutofflow / GV.Spec.deltaF; - /* This is the first template, all others will be slightly smaller */ - strtemplate[0].f=fmax; - strtemplate[0].norm=sqrt(t1t1); + /* compute (t1|t1) */ + t1t1=0.0; + integral->data[0]=4*pow( pow(CLA.fbankstart,CLA.power),2)/GV.Spec.data->data[f_min_index]*GV.Spec.deltaF; + for( p = f_min_index ; p < f_max_index; p++ ){ + f = p*GV.Spec.deltaF; + + if(f<=f_cut) t1t1 += 4*pow(pow(f,CLA.power),2)/GV.Spec.data->data[p]*GV.Spec.deltaF; + else t1t1 += 4*pow( pow(f,CLA.power)*exp(1-f/f_cut) ,2)/GV.Spec.data->data[p]*GV.Spec.deltaF; + + if(p>0) /* keep the integral in memory (to run faster) */ + integral->data[p-f_min_index] = integral->data[p-f_min_index-1]+4*pow(pow(f,CLA.power),2)/GV.Spec.data->data[p]*GV.Spec.deltaF; + } + + strtemplate[0].findex=f_cut_index; + strtemplate[0].f=f_cut; strtemplate[0].mismatch=0.0; - - t2t2=t1t1; + strtemplate[0].norm=sqrt(t1t1); k=1; - - fprintf(stdout,"%% Templ. frequency sigma mismatch\n"); - fprintf(stdout,"%% %d %e %e %e\n",k-1,strtemplate[0].f,strtemplate[0].norm, strtemplate[0].norm); - - f_low_index = CLA.fbankhighfcutofflow / GV.Spec.deltaF; - /* now we loop through and take away from the integral one point at a time */ - for ( p = f_high_index-2 ; p >= f_low_index; p-- ) - { - f= p*GV.Spec.deltaF; - t2t2 -= 4*pow(pow(f,CLA.power),2)/GV.Spec.data->data[p]*GV.Spec.deltaF; - - epsilon=1-sqrt(t2t2/t1t1); + fprintf(stdout,"%% Templ. frequency sigma mismatch\n"); + fprintf(stdout,"%% %d %1.3e %1.3e %1.3e\n",k-1,strtemplate[0].f,strtemplate[0].norm, strtemplate[0].mismatch); + + /* find the next cutoffs given the maximal mismatch */ + for(pcut=f_cut_index+1; pcut<f_max_index; pcut++){ + f_cut = pcut*GV.Spec.deltaF; + + t2t2=integral->data[strtemplate[k-1].findex-f_min_index]; + t1t2=integral->data[strtemplate[k-1].findex-f_min_index]; + + /* compute (t2|t2) and (t1|t2) */ + for( p = strtemplate[k-1].findex+1 ; p < f_max_index; p++ ){ + f = p*GV.Spec.deltaF; - /* FIXME: epsilon should be a command line argument */ - if(epsilon >= 0.05) - { - t1t1=t2t2; - strtemplate[k].f=f; - strtemplate[k].norm=sqrt(t1t1); - strtemplate[k].mismatch=epsilon; - k++; - fprintf(stdout,"%% %d %e %e %e\n",k-1,strtemplate[k-1].f,strtemplate[k-1].norm, strtemplate[k-1].mismatch); - } - if(k == MAXTEMPLATES) - { - fprintf(stderr,"Too many templates for code... Exiting\n"); - return 1; - } + /* (t2|t2) */ + if(f<=f_cut) + t2t2 += 4*pow(pow(f,CLA.power),2)/GV.Spec.data->data[p]*GV.Spec.deltaF; + else + t2t2 += 4*pow( pow(f,CLA.power)*exp(1-f/f_cut) ,2)/GV.Spec.data->data[p]*GV.Spec.deltaF; + + /* (t1|t2) */ + if(f<=f_cut) + t1t2 += 4*pow(pow(f,CLA.power),2)*exp(1-f/strtemplate[k-1].f) /GV.Spec.data->data[p]*GV.Spec.deltaF; + else + t1t2 += 4*pow( pow(f,CLA.power),2)*exp(1-f/strtemplate[k-1].f)*exp(1-f/f_cut) /GV.Spec.data->data[p]*GV.Spec.deltaF; + } + + previous_epsilon = epsilon; + epsilon=1-t1t2/sqrt(t1t1*t2t2); + + /*if(pcut%50==0) printf("%d %f %f\n",pcut, f_cut, epsilon);*/ + + if(epsilon >= CLA.fmismatchmax || pcut==f_max_index-1){ + strtemplate[k].findex=pcut; + strtemplate[k].f=f_cut; + strtemplate[k].norm=sqrt(t2t2); + strtemplate[k].mismatch=epsilon; + k++; + fprintf(stdout,"%% %d %1.3e %1.3e %1.3e\n",k-1,strtemplate[k-1].f,strtemplate[k-1].norm, strtemplate[k-1].mismatch); + t1t1=t2t2; + if(k == MAXTEMPLATES){ + fprintf(stderr,"Too many templates for code... Exiting\n"); + return 1; + } } + + /* to get faster (not so smart though) */ + if(pcut<f_max_index-16 && (epsilon-previous_epsilon)<0.005) + pcut+=15; + } + NTemplates=k; + XLALDestroyREAL4Vector( integral ); return 0; } /*******************************************************************************/ -int AvgSpectrum(struct CommandLineArgsTag CLA) -{ - - GV.seg_length = (int)(CLA.ShortSegDuration/GV.ht_proc->deltaT + 0.5); - - LALSCreateVector( &status, &GV.Spec.data, GV.seg_length / 2 + 1 ); - TESTSTATUS( &status ); - - LALCreateForwardRealFFTPlan( &status, &GV.fplan, GV.seg_length, 0 ); - TESTSTATUS( &status ); +int AvgSpectrum(struct CommandLineArgsTag CLA){ - LALCreateReverseRealFFTPlan( &status, &GV.rplan, GV.seg_length, 0 ); - TESTSTATUS( &status ); + int p; + int segmentLength; + int segmentStride; + REAL4Window *window4; - if (CLA.fakenoiseflag && CLA.whitespectrumflag) - { - int p; - for ( p = 0 ; p < (int)GV.Spec.data->length; p++ ) - { - GV.Spec.data->data[p]=2/SAMPLERATE; - } - GV.Spec.deltaF=1/(GV.seg_length*GV.ht_proc->deltaT); - } - else - { - int segmentLength = GV.seg_length; - int segmentStride = GV.seg_length/2; - REAL4Window *window = NULL; - - window = XLALCreateHannREAL4Window( segmentLength ); - XLALREAL4AverageSpectrumMedianMean( &GV.Spec, GV.ht_proc, segmentLength, - segmentStride, window, GV.fplan ); - XLALDestroyREAL4Window( window ); + GV.seg_length = (int)(CLA.ShortSegDuration/GV.ht_proc->deltaT + 0.5); + GV.Spec.data = XLALCreateREAL4Vector(GV.seg_length / 2 + 1); + GV.fplan = XLALCreateForwardREAL4FFTPlan( GV.seg_length, 0 ); + GV.rplan = XLALCreateReverseREAL4FFTPlan( GV.seg_length, 0 ); + + if (CLA.fakenoiseflag && CLA.whitespectrumflag){ + for ( p = 0 ; p < (int)GV.Spec.data->length; p++ ) + GV.Spec.data->data[p]=2/SAMPLERATE; + GV.Spec.deltaF=1/(GV.seg_length*GV.ht_proc->deltaT); + } + else{ + segmentLength = GV.seg_length; + segmentStride = GV.seg_length/2; + window4 = NULL; + + window4 = XLALCreateHannREAL4Window( segmentLength ); + if(XLALREAL4AverageSpectrumMedianMean( &GV.Spec, GV.ht_proc, segmentLength, + segmentStride, window4, GV.fplan )) + return 1; + + XLALDestroyREAL4Window( window4 ); } return 0; @@ -863,143 +829,138 @@ int AvgSpectrum(struct CommandLineArgsTag CLA) /*******************************************************************************/ -int DownSample(struct CommandLineArgsTag CLA) -{ - ResampleTSParams resamplepar; - - memset( &resamplepar, 0, sizeof( resamplepar ) ); - resamplepar.deltaT = 1.0/CLA.samplerate; - resamplepar.filterType = defaultButterworth; - - LALResampleREAL4TimeSeries( &status, GV.ht_proc, &resamplepar ); - TESTSTATUS( &status ); - +int DownSample(struct CommandLineArgsTag CLA){ + if(XLALResampleREAL4TimeSeries(GV.ht_proc, 1.0/CLA.samplerate)) return 1; return 0; } /*******************************************************************************/ -int ProcessData(void) -{ +int ProcessData(void){ int p; - LALButterworthREAL8TimeSeries( &status, &GV.ht, &highpassParams ); - TESTSTATUS( &status ); - - for (p=0; p<(int)GV.ht.data->length; p++) - { - GV.ht_proc->data->data[p]=GV.ht.data->data[p]; - } - - /* destroy double precision vector */ - LALDDestroyVector(&status,&GV.ht.data); - TESTSTATUS( &status ); + if(XLALButterworthREAL8TimeSeries(GV.ht, &highpassParams)) return 1; + for (p=0; p<(int)GV.ht->data->length; p++) + GV.ht_proc->data->data[p]=(REAL4)GV.ht->data->data[p]; + + /* ht is no more needed -> free memory */ + XLALDestroyREAL8TimeSeries(GV.ht); return 0; } /*******************************************************************************/ -int ReadData(struct CommandLineArgsTag CLA) -{ - static FrChanIn chanin_ht; +int ReadData(struct CommandLineArgsTag CLA){ int p; - - /* create Frame cache, open frame stream and delete frame cache */ - LALFrCacheImport(&status,&framecache,CLA.FrCacheFile); - TESTSTATUS( &status ); - LALFrCacheOpen(&status,&framestream,framecache); - TESTSTATUS( &status ); - LALDestroyFrCache(&status,&framecache); - TESTSTATUS( &status ); - /* Define channel */ - chanin_ht.type = ProcDataChannel; - chanin_ht.name = CLA.ChannelName; + /* create Frame cache, open frame stream and delete frame cache */ + framecache = XLALFrImportCache(CLA.FrCacheFile); + framestream = XLALFrCacheOpen(framecache); + XLALFrDestroyCache(framecache); - GV.duration=CLA.GPSEnd-CLA.GPSStart; - GV.gpsepoch.gpsSeconds=CLA.GPSStart; /* Set global variable epoch */ - GV.gpsepoch.gpsNanoSeconds=0; - - /* Read frame files to extract time series metadata */ - /* FIXME: there are XLAL functions to do this */ - LALFrSeek(&status,&GV.gpsepoch,framestream); - TESTSTATUS( &status ); - LALFrGetREAL8TimeSeries(&status,&GV.ht,&chanin_ht,framestream); - GV.ht.sampleUnits=lalStrainUnit; - TESTSTATUS( &status ); - - /* Allocate space for data vectors */ - LALDCreateVector(&status,&GV.ht.data,(UINT4)(GV.duration/GV.ht.deltaT +0.5)); - TESTSTATUS( &status ); - GV.ht_proc = XLALCreateREAL4TimeSeries(GV.ht.name, &GV.ht.epoch, GV.ht.f0, GV.ht.deltaT, &GV.ht.sampleUnits, (UINT4)(GV.duration/GV.ht.deltaT +0.5)); - - SAMPLERATE=1.0/GV.ht.deltaT; - - /* zero out data */ - for (p=0; p<(int)GV.ht.data->length; p++) - { - GV.ht.data->data[p] = GV.ht_proc->data->data[p] = 0.0; - } + GV.duration = CLA.GPSEnd-CLA.GPSStart; + GV.gpsepoch.gpsSeconds = CLA.GPSStart; + GV.gpsepoch.gpsNanoSeconds = 0; + /* Double vs. simple precision data for LIGO vs. Virgo */ + if(CLA.ChannelName[0]=='V'){ + + /* create and initialize _simple_ precision time series */ + GV.ht_V = XLALCreateREAL4TimeSeries(CLA.ChannelName, &GV.gpsepoch, 0, 0, &lalStrainUnit, 1); + + /* get the meta data */ + XLALFrGetREAL4TimeSeriesMetadata(GV.ht_V,framestream); + + /* resize ht to the correct number of samples */ + XLALResizeREAL4TimeSeries(GV.ht_V, 0, (UINT4)(GV.duration/GV.ht_V->deltaT +0.5)); + + } + else{ + + /* create and initialize _double_ precision time series */ + GV.ht = XLALCreateREAL8TimeSeries(CLA.ChannelName, &GV.gpsepoch, 0, 0, &lalStrainUnit, 1); + + /* get the meta data */ + XLALFrGetREAL8TimeSeriesMetadata(GV.ht,framestream); + + /* resize ht to the correct number of samples */ + XLALResizeREAL8TimeSeries(GV.ht, 0, (UINT4)(GV.duration/GV.ht->deltaT +0.5)); + + } + + /* If we are reading real noise then read it*/ - if (!CLA.fakenoiseflag) - { - /* Read data */ - LALFrSeek(&status,&GV.gpsepoch,framestream); - TESTSTATUS( &status ); - LALFrGetREAL8TimeSeries(&status,&GV.ht,&chanin_ht,framestream); - TESTSTATUS( &status ); - - /* Scale data to avoid single float precision problems */ - for (p=0; p<(int)GV.ht.data->length; p++) - { - GV.ht.data->data[p] *= SCALE; - } + if(!CLA.fakenoiseflag){ + /* seek to and read data */ + XLALFrSeek( framestream, &GV.gpsepoch ); + + if(CLA.ChannelName[0]=='V'){ + XLALFrGetREAL4TimeSeries(GV.ht_V,framestream); + + /* Allocate space for REAL8 data */ + GV.ht = XLALCreateREAL8TimeSeries(GV.ht_V->name, + &GV.ht_V->epoch, + GV.ht_V->f0, + GV.ht_V->deltaT, + &lalStrainUnit, + (UINT4)(GV.duration/GV.ht_V->deltaT +0.5)); + + /* Fill REAL8 data vector */ + for (p=0; p<(int)GV.ht_V->data->length; p++) + GV.ht->data->data[p] = (REAL8)GV.ht_V->data->data[p]; } - /* otherwise create random data set */ - else - { - FILE *devrandom; - RandomParams *randpar=NULL; - REAL4Vector *v1=NULL; - int seed, errorcode; - - if (!(devrandom=fopen("/dev/urandom","r"))) - { - fprintf(stderr,"Unable to open device /dev/urandom\n"); - return 1; - } - errorcode=fread((void*)&seed,sizeof(INT4),1,devrandom); - if (errorcode!=1) - { - fprintf( stderr,"Error reading /dev/urandom file!\n"); - return 1; - } - fclose(devrandom); - - LALSCreateVector (&status, &v1, GV.ht.data->length); - TESTSTATUS( &status ); - - LALCreateRandomParams (&status, &randpar, seed); - TESTSTATUS( &status ); - LALNormalDeviates(&status, v1, randpar); - TESTSTATUS( &status ); - LALDestroyRandomParams (&status, &randpar); - TESTSTATUS( &status ); - - for (p=0; p<(int)GV.ht.data->length; p++) - { - GV.ht.data->data[p] = v1->data[p]; - } + else XLALFrGetREAL8TimeSeries(GV.ht,framestream); - LALSDestroyVector (&status, &v1); - TESTSTATUS( &status ); + /* Scale data to avoid single float precision problems */ + for (p=0; p<(int)GV.ht->data->length; p++) + GV.ht->data->data[p] *= SCALE; + } + /* otherwise create random data set */ + else{ + FILE *devrandom; + RandomParams *randpar=NULL; + REAL4Vector *v1=NULL; + int seed, errorcode; + + if(!(devrandom=fopen("/dev/urandom","r"))){ + fprintf(stderr,"Unable to open device /dev/urandom\n"); + return 1; } - - LALFrClose(&status,&framestream); - TESTSTATUS( &status ); - + errorcode=fread((void*)&seed,sizeof(INT4),1,devrandom); + if (errorcode!=1){ + fprintf( stderr,"Error reading /dev/urandom file!\n"); + return 1; + } + fclose(devrandom); + + v1 = XLALCreateREAL4Vector(GV.ht->data->length); + + randpar = XLALCreateRandomParams (seed); + if(XLALNormalDeviates(v1, randpar)) return 1;; + XLALDestroyRandomParams (randpar); + + for (p=0; p<(int)GV.ht->data->length; p++) + GV.ht->data->data[p] = v1->data[p]; + + XLALDestroyREAL4Vector(v1); + } + + SAMPLERATE=1.0/GV.ht->deltaT; + + /* Allocate space for processed data */ + GV.ht_proc = XLALCreateREAL4TimeSeries(GV.ht->name, + &GV.ht->epoch, + GV.ht->f0, + GV.ht->deltaT, + &lalStrainUnit, + (UINT4)(GV.duration/GV.ht->deltaT +0.5)); + /* zero out processed data */ + for (p=0; p<(int)GV.ht_proc->data->length; p++) GV.ht_proc->data->data[p] = 0.0; + + XLALFrClose(framestream); + if(CLA.ChannelName[0]=='V') XLALDestroyREAL4TimeSeries(GV.ht_V); + return 0; } @@ -1008,14 +969,14 @@ int ReadData(struct CommandLineArgsTag CLA) /*******************************************************************************/ -int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) -{ +int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA){ INT4 errflg = 0; ProcessParamsTable **paramaddpoint = &procparams.processParamsTable; struct option long_options[] = { {"bw-flow", required_argument, NULL, 'f'}, {"bank-freq-start", required_argument, NULL, 'L'}, {"bank-lowest-hifreq-cutoff", required_argument, NULL, 'H'}, + {"max-mismatch", required_argument, NULL, 'M'}, {"threshold", required_argument, NULL, 't'}, {"frame-cache", required_argument, NULL, 'F'}, {"channel-name", required_argument, NULL, 'C'}, @@ -1042,23 +1003,23 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) {"help", no_argument, NULL, 'h' }, {0, 0, 0, 0} }; - char args[] = "hnckwabrxyzl:f:L:H:t:F:C:E:S:i:d:T:s:g:o:p:"; + char args[] = "hnckwabrxyzl:f:L:M:H:t:F:C:E:S:i:d:T:s:g:o:p:"; optarg = NULL; /* set up xml output stuff */ /* create the process and process params tables */ procTable.processTable = XLALCreateProcessTableRow(); - LALGPSTimeNow(&status, &(procTable.processTable->start_time), &accuracy); - if (strcmp(CVS_REVISION, "$Revi" "sion$")) - { - if(XLALPopulateProcessTable(procTable.processTable, PROGRAM_NAME, CVS_REVISION, CVS_SOURCE, CVS_DATE, 0)) - exit(1); - } - else - { - if(XLALPopulateProcessTable(procTable.processTable, PROGRAM_NAME, lalappsGitCommitID, lalappsGitGitStatus, lalappsGitCommitDate, 0)) - exit(1); - } + XLALGPSTimeNow(&(procTable.processTable->start_time)); + if (strcmp(CVS_REVISION, "$Revi" "sion$")) + { + if(XLALPopulateProcessTable(procTable.processTable, PROGRAM_NAME, CVS_REVISION, CVS_SOURCE, CVS_DATE, 0)) + exit(1); + } + else + { + if(XLALPopulateProcessTable(procTable.processTable, PROGRAM_NAME, lalappsGitCommitID, lalappsGitGitStatus, lalappsGitCommitDate, 0)) + exit(1); + } procparams.processParamsTable = NULL; /* create the search summary table */ searchsumm.searchSummaryTable = XLALCreateSearchSummaryTableRow(procTable.processTable); @@ -1069,6 +1030,7 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) CLA->flow=0.0; CLA->fbankstart=0.0; CLA->fbankhighfcutofflow=0.0; + CLA->fmismatchmax=0.05; CLA->FrCacheFile=NULL; CLA->InjectionFile=NULL; CLA->ChannelName=NULL; @@ -1123,6 +1085,11 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) CLA->fbankhighfcutofflow=atof(optarg); ADD_PROCESS_PARAM(procTable.processTable, "float"); break; + case 'M': + /* Maximal mismatch */ + CLA->fmismatchmax=atof(optarg); + ADD_PROCESS_PARAM(procTable.processTable, "float"); + break; case 'L': /* low frequency cutoff */ CLA->fbankstart=atof(optarg); @@ -1141,7 +1108,7 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) case 'C': /* name channel */ CLA->ChannelName=optarg; - memcpy(ifo, optarg, sizeof(ifo) - 1); + memcpy(ifo, optarg, sizeof(ifo) - 2); ADD_PROCESS_PARAM(procTable.processTable, "string"); break; case 'i': @@ -1245,6 +1212,7 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) fprintf(stdout,"\t--bw-flow (-f)\t\tFLOAT\t Low frequency cut-off.\n"); fprintf(stdout,"\t--sample-rate (-s)\t\tFLOAT\t Desired sample rate (Hz).\n"); fprintf(stdout,"\t--bank-lowest-hifreq-cutoff (-H)\tFLOAT\t Template bank lowest high frequency cut-off.\n"); + fprintf(stdout,"\t--max-mismatch (-M)\tFLOAT\t Maximal mismatch allowed from 1 template to the next.\n"); fprintf(stdout,"\t--bank-freq-start (-L)\tFLOAT\t Template bank low frequency cut-off.\n"); fprintf(stdout,"\t--threshold (-t)\t\tFLOAT\t SNR threshold.\n"); fprintf(stdout,"\t--frame-cache (-F)\t\tSTRING\t Name of frame cache file.\n"); @@ -1279,7 +1247,7 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) exit(1); break; } - } + } if(CLA->flow == 0.0) { @@ -1299,6 +1267,11 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) fprintf(stderr,"Try %s -h \n",argv[0]); return 1; } + if(CLA->fmismatchmax == 0.0){ + fprintf(stderr,"No maximal mismatch specified.\n"); + fprintf(stderr,"Try %s -h \n",argv[0]); + return 1; + } if(CLA->threshold == 0.0) { fprintf(stderr,"No SNR threshold specified.\n"); @@ -1349,35 +1322,36 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) REAL4 x=((float)big_seg_length/(float)small_seg_length)-0.5; - if ((int)x != x) - { - fprintf(stderr,"The total duration of the segment T and the short segment duration\n"); - fprintf(stderr,"Should obey the following rule: T/t - 0.5 shold be an odd integer.\n"); - return 1; - } - if (((int)x)%2 != 1) - { - fprintf(stderr,"The total duration of the segment T and the short segment duration\n"); - fprintf(stderr,"Should obey the following rule: T/t - 0.5 shold be an odd integer.\n"); - return 1; - } + if((int)x != x){ + fprintf(stderr,"The total duration of the segment T and the short segment duration\n"); + fprintf(stderr,"Should obey the following rule: T/t - 0.5 shold be an odd integer.\n"); + return 1; + } + if(((int)x)%2 != 1){ + fprintf(stderr,"The total duration of the segment T and the short segment duration\n"); + fprintf(stderr,"Should obey the following rule: T/t - 0.5 shold be an odd integer.\n"); + return 1; + } - if( CLA->ShortSegDuration/4.0 < CLA->TruncSecs) - { - fprintf(stderr,"Short segment length t=%d is too small to accomodate truncation time requested.\n", - small_seg_length); + if( CLA->ShortSegDuration/4.0 < CLA->TruncSecs){ + fprintf(stderr,"Short segment length t=%d is too small to accomodate truncation time requested.\n", small_seg_length); fprintf(stderr,"Need short segment t(=%d) to be >= 4 x Truncation length (%f).\n",CLA->ShortSegDuration,CLA->TruncSecs); return 1; - } + } } + /* check mismatch */ + { + if(CLA->fmismatchmax < 0.0 || CLA->fmismatchmax > 1.0){ + fprintf(stderr,"ERROR : the maximal mismatch is not authorized.\n"); + return 1; + } + } /* check frequencies */ { REAL4 f99=CLA->flow*pow((1/0.9-1)/(1/0.99-1),0.25); if(CLA->fbankstart < f99) - { - fprintf(stderr,"WARNING: Template starting frequency and BW high pass frequency are close. f99=%e, fbw=%e\n",f99, CLA->flow); - } + fprintf(stderr,"WARNING: Template starting frequency and BW high pass frequency are close. f99=%e, fbw=%e\n",f99, CLA->flow); } /* store the input start and end times */ @@ -1391,11 +1365,10 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) searchsumm.searchSummaryTable->in_end_time.gpsNanoSeconds =0; if (CLA->trigstarttime > 0) - { - searchsumm.searchSummaryTable->out_start_time.gpsSeconds = CLA->trigstarttime; - }else{ - searchsumm.searchSummaryTable->out_start_time.gpsSeconds = CLA->GPSStart+small_seg_length/4+CLA->pad; - } + searchsumm.searchSummaryTable->out_start_time.gpsSeconds = CLA->trigstarttime; + else + searchsumm.searchSummaryTable->out_start_time.gpsSeconds = CLA->GPSStart+small_seg_length/4+CLA->pad; + searchsumm.searchSummaryTable->out_start_time.gpsNanoSeconds =0; searchsumm.searchSummaryTable->out_end_time.gpsSeconds = CLA->GPSEnd-small_seg_length/4-CLA->pad; searchsumm.searchSummaryTable->out_end_time.gpsNanoSeconds =0; @@ -1406,30 +1379,20 @@ int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA) /*******************************************************************************/ -int FreeMem(void) -{ +int FreeMem(void){ int m; - + XLALDestroyREAL4TimeSeries(GV.ht_proc); - - LALSDestroyVector(&status,&GV.Spec.data); - TESTSTATUS( &status ); - - + XLALDestroyREAL4Vector(GV.Spec.data); + for (m=0; m < NTemplates; m++) - { - LALSDestroyVector(&status,&strtemplate[m].StringFilter.data); - TESTSTATUS( &status ); - } - - LALDestroyRealFFTPlan( &status, &GV.fplan ); - TESTSTATUS( &status ); - - LALDestroyRealFFTPlan( &status, &GV.rplan ); - TESTSTATUS( &status ); - + XLALDestroyREAL4Vector(strtemplate[m].StringFilter.data); + + XLALDestroyREAL4FFTPlan( GV.fplan ); + XLALDestroyREAL4FFTPlan( GV.rplan ); + LALCheckMemoryLeaks(); - + return 0; } diff --git a/lalapps/src/string/cosmicstring.py b/lalapps/src/string/cosmicstring.py index 90910dca23691edddd12e52bf8416798cda6ea83..3a8954a91c818e8b01db667e76229a808148b943 100644 --- a/lalapps/src/string/cosmicstring.py +++ b/lalapps/src/string/cosmicstring.py @@ -37,8 +37,8 @@ class StringJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): self.add_condor_cmd('environment',"KMP_LIBRARY=serial;MKL_SERIAL=yes") - self.set_stdout_file('logs/string-$(macrochannelname)-$(macrogpsstarttime)-$(macrogpsendtime)-$(cluster)-$(process).out') - self.set_stderr_file('logs/string-$(macrochannelname)-$(macrogpsstarttime)-$(macrogpsendtime)-$(cluster)-$(process).err') + self.set_stdout_file('logs/string-$(macrochannel)-$(macrogpsstarttime)-$(macrogpsendtime)-$(cluster)-$(process).out') + self.set_stderr_file('logs/string-$(macrochannel)-$(macrogpsstarttime)-$(macrogpsendtime)-$(cluster)-$(process).err') self.set_sub_file('string.sub') @@ -86,8 +86,8 @@ class InjJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): for sec in ['injection']: self.add_ini_opts(cp,sec) - self.set_stdout_file('logs/inj-$(macrochannelname)-$(macrogpsstarttime)-$(macrogpsendtime)-$(cluster)-$(process).out') - self.set_stderr_file('logs/inj-$(macrochannelname)-$(macrogpsstarttime)-$(macrogpsendtime)-$(cluster)-$(process).err') + self.set_stdout_file('logs/inj-$(macrochannel)-$(macrogpsstarttime)-$(macrogpsendtime)-$(cluster)-$(process).out') + self.set_stderr_file('logs/inj-$(macrochannel)-$(macrogpsstarttime)-$(macrogpsendtime)-$(cluster)-$(process).err') self.set_sub_file('injection.sub') diff --git a/lalapps/src/string/lalapps_cosmicstring_pipe b/lalapps/src/string/lalapps_cosmicstring_pipe index d1c603e58053b44d2e918bd6adfe6d8e00d6218f..8883e22a9a264dacd20f85132e0aa36daa7be77e 100755 --- a/lalapps/src/string/lalapps_cosmicstring_pipe +++ b/lalapps/src/string/lalapps_cosmicstring_pipe @@ -193,6 +193,7 @@ for ifo in ifos: # create all the LSCdataFind jobs to run in sequence datatype = cp.get('input','type_%s' % ifo) + channeltype = cp.get('input','channel_%s' % ifo) # loop over segments for segment_number, seg in enumerate(data): @@ -214,6 +215,7 @@ for ifo in ifos: string.set_end(chunk.end()) string.set_ifo(ifo) string.set_cache(df.get_output()) + string.add_var_opt('channel',channeltype) string.add_var_opt('threshold',snr[ifo]) string.add_var_opt('trig-start-time',chunk.trig_start()) string.add_var_opt('outfile',string.get_output()) @@ -257,4 +259,3 @@ LSCdataFind server. """ sys.exit(0) - diff --git a/lalapps/src/tracksearch/tracksearch.py b/lalapps/src/tracksearch/tracksearch.py index 2d5d8130fd3fa6d7fd52d341a0c2e541e4432311..74bd76b0de74488d80e7d0a98c761e193f5228d2 100644 --- a/lalapps/src/tracksearch/tracksearch.py +++ b/lalapps/src/tracksearch/tracksearch.py @@ -553,6 +553,7 @@ class tracksearchHousekeeperJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): self.__universe = cp.get('condor','housekeeper_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) + self.add_condor_cmd('getenv','True') for sec in ['housekeeper']: #Check the ini file and warn that we are enabling the rescue of RESULTS directory! ignorePathString=cp.get(sec,'ignore-path') @@ -599,6 +600,7 @@ class tracksearchTimeJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): self.jobType='normal' pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) + self.add_condor_cmd('getenv','True') blockID=block_id layerID=layer_id layerPath=determineLayerPath(cp,blockID,layerID,channel) @@ -668,6 +670,7 @@ class tracksearchMapJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): self.__universe = cp.get('condor','tracksearch_universe'); pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) + self.add_condor_cmd('getenv','True') blockID=block_id layerID=layer_id ### WE NEED A CONDOR DAG VARIABLE TO THE INITIAL DIR ARGUMENT @@ -708,6 +711,7 @@ class tracksearchAveragerJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): self.__universe = cp.get('condor','averager_universe'); pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) + self.add_condor_cmd('getenv','True') blockID=block_id layerID=layer_id layerPath=determineLayerPath(cp,blockID,layerID,channel) @@ -746,6 +750,7 @@ class tracksearchMapCacheBuildJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): self.__universe = cp.get('condor','cachebuilder_universe'); pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) + self.add_condor_cmd('getenv','True') blockID=block_id layerID=layer_id #WE NEED A DAG VARIABLE THE LAYERid FOR PROPER INITIAL DIR @@ -847,6 +852,7 @@ class tracksearchClusterJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): self.__universe = cp.get('condor','clustertool_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) + self.add_condor_cmd('getenv','True') self.block_id=blockID=block_id layerID='RESULTS_'+channel+'_'+str(blockID) #Do not use channel information for initial dir. @@ -892,6 +898,7 @@ class tracksearchThresholdJob(pipeline.CondorDAGJob, pipeline.AnalysisJob): self.__universe= cp .get('condor','clustertool_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) + self.add_condor_cmd('getenv','True') self.block_id=blockID=block_id #layerID='RESULTS_'+str(blockID) layerID='RESULTS_'+channel+'_'+str(blockID) diff --git a/lalapps/src/tracksearch/tracksearchToolbox.c b/lalapps/src/tracksearch/tracksearchToolbox.c index 2d6b6572fd8c9cbc1b62faa826b7d9f723f8693e..45ba5900b35173612ecf03a18c04cf6ef2967662 100644 --- a/lalapps/src/tracksearch/tracksearchToolbox.c +++ b/lalapps/src/tracksearch/tracksearchToolbox.c @@ -17,7 +17,7 @@ * MA 02111-1307 USA */ /* - * Author: Torres C. (Univ of TX at Brownsville) + * Author: Torres Cristina (LLO) */ #include "tracksearch.h" #include "tracksearchToolbox.h" @@ -1088,4 +1088,3 @@ LALappsTSassert(UINT4 err, } return; } - diff --git a/lalapps/src/tracksearch/tsCutPipe.pyin b/lalapps/src/tracksearch/tsCutPipe.pyin index 5fade61658371eae18a64f54d791fa120bf6bd8c..667d272bb0adcddd5401c5436db4df5430203dd1 100755 --- a/lalapps/src/tracksearch/tsCutPipe.pyin +++ b/lalapps/src/tracksearch/tsCutPipe.pyin @@ -29,10 +29,10 @@ from optparse import OptionParser import ConfigParser import time from glue import pipeline -import tracksearch -from tracksearch import buildDir -from tracksearchutils import progressSpinner -from tracksearchutils import generateFileList +from lalapps import tracksearch +from lalapps.tracksearch import buildDir +from lalapps.tracksearchutils import progressSpinner +from lalapps.tracksearchutils import generateFileList #Parse in command line inputs diff --git a/lalapps/src/tracksearch/tsHandler.pyin b/lalapps/src/tracksearch/tsHandler.pyin index dd76fcde1fdd910a988751856ea394b2a6fb999b..fc973e9817ac062503647fe85fdac6d6e7af7a3a 100755 --- a/lalapps/src/tracksearch/tsHandler.pyin +++ b/lalapps/src/tracksearch/tsHandler.pyin @@ -31,7 +31,7 @@ import os import string import time import copy -from tracksearchutils import * +from lalapps.tracksearchutils import * disableGraphics=False try: from pylab import * diff --git a/lalapps/src/tracksearch/tsPipe.pyin b/lalapps/src/tracksearch/tsPipe.pyin index 7ada8211fba834e8eab01db361c9e4486214a0bb..c08e41946ce3aebdce80422167dc319f91cf8d05 100755 --- a/lalapps/src/tracksearch/tsPipe.pyin +++ b/lalapps/src/tracksearch/tsPipe.pyin @@ -29,10 +29,10 @@ from optparse import OptionParser import ConfigParser import time from glue import pipeline -import tracksearch -from tracksearchutils import progressSpinner -from tracksearchutils import autoCreateSegmentList -from tracksearchutils import determineDataPadding +from lalapps import tracksearch +from lalapps.tracksearchutils import progressSpinner +from lalapps.tracksearchutils import autoCreateSegmentList +from lalapps.tracksearchutils import determineDataPadding #Parse the command line options and create help features parser = OptionParser() diff --git a/lalapps/src/tracksearch/tsTunePipe.pyin b/lalapps/src/tracksearch/tsTunePipe.pyin index 462c8e2345fd37cb5b83d401309c3e17294ac14c..fc91f07d023d65c3f8e8e79a1f1e2b1c39bd1f4e 100755 --- a/lalapps/src/tracksearch/tsTunePipe.pyin +++ b/lalapps/src/tracksearch/tsTunePipe.pyin @@ -38,9 +38,9 @@ import os import string import time import pickle -import tracksearch -from tracksearchutils import * -from tracksearch import buildDir +from lalapps import tracksearch +from lalapps.tracksearchutils import * +from lalapps.tracksearch import buildDir #