Ejemplo n.º 1
0
def makeScatteredPlot(chan,opts,distribution,list11=None,list12=None,list21=None,list22=None,list31=None,list32=None):

  p1 = None
  p2 = None
  p3 = None
  parameter = distribution.split('-')[0]
  pylab.figure()

  ax = pylab.subplot(111)
  ax.set_xscale('log')
  ax.set_yscale('log')

  if list11 and list12:
    p1 = pylab.plot(list11,list12,linestyle='None', marker='o',\
               markerfacecolor='k', markeredgecolor='k',\
               markersize=4, markeredgewidth=0)

  if list21 and list22:
    p2 = pylab.plot(list21,list22,linestyle='None', marker='v',\
               markerfacecolor='r', markeredgecolor='r',\
               markersize=4, markeredgewidth=0)

  if list31 and list32:
    p3 = pylab.plot(list31,list32,linestyle='None', marker='s',\
               markerfacecolor='r', markeredgecolor='r',\
               markersize=8, markeredgewidth=0)

  pylab.grid()
  pylab.xlabel('Z in ' + chan,size='x-large')
  pylab.ylabel('Z in ' + opts.ref_channel,size='x-large')
  pylab.title('Scattered plot of significance for channel: ' + chan)

  if p1 and p2 and p3:
    pylab.legend((p1,p2,p3),('background','foreground','candidate'),loc = 'upper right')
    lim = max(max(list11),max(list12),max(list21),max(list22),max(list31),max(list32))
  if p1 and p2 and not p3:
    pylab.legend((p1,p2),('background','foreground'),loc = 'upper right')
    lim = max(max(list11),max(list12),max(list21),max(list22))
  if p1 and not p2 and p3:
    pylab.legend((p1,p3),('background','candidate'),loc = 'upper right')
    lim = max(max(list11),max(list12),max(list31),max(list32))    
  if p1 and not p2 and not p3:
#   pylab.legend((p1),('background'),loc='upper right')
    lim = max(max(list11),max(list12))

  ax.set_xlim(1e0, lim*2)
  ax.set_ylim(1e0, lim*2)

  figText = chan.split(':')[0] + '_' + chan.split(':')[1] + '_' + parameter + '_scat'
   
  figName = InspiralUtils.set_figure_name(opts,figText)
  InspiralUtils.savefig_pylal(figName)
  pylab.close()

  return figName  
Ejemplo n.º 2
0
def makeScatteredPlot(chan,opts,distribution,list11=None,list12=None,list21=None,list22=None,list31=None,list32=None):

  p1 = None
  p2 = None
  p3 = None
  parameter = distribution.split('-')[0]
  pylab.figure()

  ax = pylab.subplot(111)
  ax.set_xscale('log')
  ax.set_yscale('log')

  if list11 and list12:
    p1 = pylab.plot(list11,list12,linestyle='None', marker='o',\
               markerfacecolor='k', markeredgecolor='k',\
               markersize=4, markeredgewidth=0)

  if list21 and list22:
    p2 = pylab.plot(list21,list22,linestyle='None', marker='v',\
               markerfacecolor='r', markeredgecolor='r',\
               markersize=4, markeredgewidth=0)

  if list31 and list32:
    p3 = pylab.plot(list31,list32,linestyle='None', marker='s',\
               markerfacecolor='r', markeredgecolor='r',\
               markersize=8, markeredgewidth=0)

  pylab.grid()
  pylab.xlabel('Z in ' + chan,size='x-large')
  pylab.ylabel('Z in ' + opts.ref_channel,size='x-large')
  pylab.title('Scattered plot of significance for channel: ' + chan)

  if p1 and p2 and p3:
    pylab.legend((p1,p2,p3),('background','foreground','candidate'),loc = 'upper right')
    lim = max(max(list11),max(list12),max(list21),max(list22),max(list31),max(list32))
  if p1 and p2 and not p3:
    pylab.legend((p1,p2),('background','foreground'),loc = 'upper right')
    lim = max(max(list11),max(list12),max(list21),max(list22))
  if p1 and not p2 and p3:
    pylab.legend((p1,p3),('background','candidate'),loc = 'upper right')
    lim = max(max(list11),max(list12),max(list31),max(list32))    
  if p1 and not p2 and not p3:
#   pylab.legend((p1),('background'),loc='upper right')
    lim = max(max(list11),max(list12))

  ax.set_xlim(1e0, lim*2)
  ax.set_ylim(1e0, lim*2)

  figText = chan.split(':')[0] + '_' + chan.split(':')[1] + '_' + parameter + '_scat'
   
  figName = InspiralUtils.set_figure_name(opts,figText)
  InspiralUtils.savefig_pylal(figName)
  pylab.close()

  return figName  
Ejemplo n.º 3
0
def plotHistogram(chan,opts,distribution,histoList,binList,percentiles=None,candidate=None,candidateRank=None):

  parameter = distribution.split('-')[0]
      
  step = binList[1] - binList[0]
  counter = sum(histoList)

  xlimInf = min(binList)
  if candidate and not parameter == 'dt':
    xlimSup = max(max(binList),candidate + 2.0)
  else:
    xlimSup = max(binList)

  pylab.figure()
  # semilogy(bins + step/2., z_dist+0.0001, 'r^',markerfacecolor="b",markersize=12)
  # plot(bins + step/2., z_dist)
  pylab.bar(binList[0:len(binList)-1], histoList, width=step, bottom=0)

  if percentiles:
    line1 = pylab.axvline(x=percentiles[0], ymin=0, ymax=max(histoList), color='g', label='50th percentile', linewidth=2, linestyle='--')
    line2 = pylab.axvline(x=percentiles[1], ymin=0, ymax=max(histoList), color='m', label='95th percentile', linewidth=2, linestyle='--')
    line3 = pylab.axvline(x=percentiles[2], ymin=0, ymax=max(histoList), color='r', label='99th percentile', linewidth=2, linestyle='--')
    if parameter == 'dt':
      pylab.axvline(x=-percentiles[0], ymin=0, ymax=max(histoList), color='g', label='50th percentile', linewidth=2, linestyle='--')
      pylab.axvline(x=-percentiles[1], ymin=0, ymax=max(histoList), color='m', label='95th percentile', linewidth=2, linestyle='--')
      pylab.axvline(x=-percentiles[2], ymin=0, ymax=max(histoList), color='r', label='99th percentile', linewidth=2, linestyle='--')

  if candidate:
    line0 = pylab.axvline(x=candidate, ymin=0, ymax=max(histoList), color='k', label='candidate value (%s percentile)' % (candidateRank), linewidth=2, linestyle='-')

  if percentiles and candidate:
    pylab.legend((line0,line1,line2,line3),('candidate','50%','95%','99%'),loc = 'upper right')

  if percentiles and not candidate:
    pylab.legend((line1,line2,line3),('50%','95%','99%'),loc = 'upper right')

  pylab.xlim(xlimInf,xlimSup)

  pylab.xlabel(parameter + ' value',size='large')
  # ylabel(r'#',size='x-large')
  pylab.grid()  
  pylab.title("Histogram of the " + parameter + " value for " + chan + ', Statistics = ' + str(counter))


  figText = chan.split(':')[0] + '_' + chan.split(':')[1] + '_' + parameter + '_dist'
  figFileName = InspiralUtils.set_figure_name(opts,figText)
  InspiralUtils.savefig_pylal(figFileName) 
  pylab.close()

  return figFileName
Ejemplo n.º 4
0
def plotHistogram(chan,opts,distribution,histoList,binList,percentiles=None,candidate=None,candidateRank=None):

  parameter = distribution.split('-')[0]
      
  step = binList[1] - binList[0]
  counter = sum(histoList)

  xlimInf = min(binList)
  if candidate and not parameter == 'dt':
    xlimSup = max(max(binList),candidate + 2.0)
  else:
    xlimSup = max(binList)

  pylab.figure()
  # semilogy(bins + step/2., z_dist+0.0001, 'r^',markerfacecolor="b",markersize=12)
  # plot(bins + step/2., z_dist)
  pylab.bar(binList[0:len(binList)-1], histoList, width=step, bottom=0)

  if percentiles:
    line1 = pylab.axvline(x=percentiles[0], ymin=0, ymax=max(histoList), color='g', label='50th percentile', linewidth=2, linestyle='--')
    line2 = pylab.axvline(x=percentiles[1], ymin=0, ymax=max(histoList), color='m', label='95th percentile', linewidth=2, linestyle='--')
    line3 = pylab.axvline(x=percentiles[2], ymin=0, ymax=max(histoList), color='r', label='99th percentile', linewidth=2, linestyle='--')
    if parameter == 'dt':
      pylab.axvline(x=-percentiles[0], ymin=0, ymax=max(histoList), color='g', label='50th percentile', linewidth=2, linestyle='--')
      pylab.axvline(x=-percentiles[1], ymin=0, ymax=max(histoList), color='m', label='95th percentile', linewidth=2, linestyle='--')
      pylab.axvline(x=-percentiles[2], ymin=0, ymax=max(histoList), color='r', label='99th percentile', linewidth=2, linestyle='--')

  if candidate:
    line0 = pylab.axvline(x=candidate, ymin=0, ymax=max(histoList), color='k', label='candidate value (%s percentile)' % (candidateRank), linewidth=2, linestyle='-')

  if percentiles and candidate:
    pylab.legend((line0,line1,line2,line3),('candidate','50%','95%','99%'),loc = 'upper right')

  if percentiles and not candidate:
    pylab.legend((line1,line2,line3),('50%','95%','99%'),loc = 'upper right')

  pylab.xlim(xlimInf,xlimSup)

  pylab.xlabel(parameter + ' value',size='large')
  # ylabel(r'#',size='x-large')
  pylab.grid()  
  pylab.title("Histogram of the " + parameter + " value for " + chan + ', Statistics = ' + str(counter))


  figText = chan.split(':')[0] + '_' + chan.split(':')[1] + '_' + parameter + '_dist'
  figFileName = InspiralUtils.set_figure_name(opts,figText)
  InspiralUtils.savefig_pylal(figFileName) 
  pylab.close()

  return figFileName
parser.add_option("","--bit-word", default=False, type="string", help="Provide the path for the bit-word pickle file")
parser.add_option("","--hist-ranks", default=False, type="string", help="Provide the path for the hist-ranks pickle file")
parser.add_option("","--cum-hist-signif", default=False, type="string", help="Provide the path for the cum-hist-signif pickle file")

# use glob.glob('filename') to extract files from opts.pickle_files

(opts,args)=parser.parse_args()

try: os.mkdir(opts.output_path)
except: pass


################   PLOTS   #############################################################

# Initializing the html output
InspiralUtils.message(opts, "Initialisation...")
opts = InspiralUtils.initialise(opts, __prog__, __version__)
fnameList = []
tagList = []
fig_num = 0
comments = ""

###########################################################################################
if opts.verbose:
  print 'Generating Plots...'

colorDIC = {'ann':'b', 'mvsc':'g', 'svm':'r', 'ovl':'c', 'combined':'m'}
labelDIC = {'ann':'ANN', 'mvsc':'MVSC', 'svm':'SVM', 'ovl':'OVL', 'combined':'MVC$_{\mathrm{max}}$'}

matplotlib.rc('text', usetex=True)
Ejemplo n.º 6
0
parser.add_option("-c", "--create-param-list",action="store_true",\
    default=False,help="create .txt files containing the list of parameters for each channel (for debugging only)")


command_line = sys.argv[1:]
(opts,args) = parser.parse_args()

####################### SANITY CHECKS #####################################


################# NOW START THE REAL WORK ##################################

# initialize some variables
figNumber = 0
currentDir = os.path.abspath('.')
opts = InspiralUtils.initialise(opts, __prog__, git_version.verbose_msg)
fnameList = []

# Get the list of qscan channels to be analyzed (should become optional later...). The script needs to be improved to follow this behavior: if the text file is not specified in the configuration file, then all the channels found in the summary files should be analyzed...

if opts.process_background_only:
  channelList = listFromFile(opts.channel_list)
  if len(channelList) == 0:
    print >> sys.stderr, "channel list not found"
    sys.exit(1)

# Check the summary length
if opts.check_length:
  checkSummaryLength(opts,opts.background_input_path)

Ejemplo n.º 7
0
parser.add_option("-c", "--create-param-list",action="store_true",\
    default=False,help="create .txt files containing the list of parameters for each channel (for debugging only)")


command_line = sys.argv[1:]
(opts,args) = parser.parse_args()

####################### SANITY CHECKS #####################################


################# NOW START THE REAL WORK ##################################

# initialize some variables
figNumber = 0
currentDir = os.path.abspath('.')
opts = InspiralUtils.initialise(opts, __prog__, git_version.verbose_msg)
fnameList = []

# Get the list of qscan channels to be analyzed (should become optional later...). The script needs to be improved to follow this behavior: if the text file is not specified in the configuration file, then all the channels found in the summary files should be analyzed...

if opts.process_background_only:
  channelList = listFromFile(opts.channel_list)
  if len(channelList) == 0:
    print >> sys.stderr, "channel list not found"
    sys.exit(1)

# Check the summary length
if opts.check_length:
  checkSummaryLength(opts,opts.background_input_path)

Ejemplo n.º 8
0
def makeScatteredPlot(
    chan, opts, distribution, list11=None, list12=None, list21=None, list22=None, list31=None, list32=None
):

    p1 = None
    p2 = None
    p3 = None
    parameter = distribution.split("-")[0]
    pylab.figure()

    ax = pylab.subplot(111)
    ax.set_xscale("log")
    ax.set_yscale("log")

    if list11 and list12:
        p1 = pylab.plot(
            list11,
            list12,
            linestyle="None",
            marker="o",
            markerfacecolor="k",
            markeredgecolor="k",
            markersize=4,
            markeredgewidth=0,
        )

    if list21 and list22:
        p2 = pylab.plot(
            list21,
            list22,
            linestyle="None",
            marker="v",
            markerfacecolor="r",
            markeredgecolor="r",
            markersize=4,
            markeredgewidth=0,
        )

    if list31 and list32:
        p3 = pylab.plot(
            list31,
            list32,
            linestyle="None",
            marker="s",
            markerfacecolor="r",
            markeredgecolor="r",
            markersize=8,
            markeredgewidth=0,
        )

    pylab.grid()
    pylab.xlabel("Z in " + chan, size="x-large")
    pylab.ylabel("Z in " + opts.ref_channel, size="x-large")
    pylab.title("Scattered plot of significance for channel: " + chan)

    if p1 and p2 and p3:
        pylab.legend((p1, p2, p3), ("background", "foreground", "candidate"), loc="upper right")
        lim = max(max(list11), max(list12), max(list21), max(list22), max(list31), max(list32))
    if p1 and p2 and not p3:
        pylab.legend((p1, p2), ("background", "foreground"), loc="upper right")
        lim = max(max(list11), max(list12), max(list21), max(list22))
    if p1 and not p2 and p3:
        pylab.legend((p1, p3), ("background", "candidate"), loc="upper right")
        lim = max(max(list11), max(list12), max(list31), max(list32))
    if p1 and not p2 and not p3:
        #   pylab.legend((p1),('background'),loc='upper right')
        lim = max(max(list11), max(list12))

    ax.set_xlim(1e0, lim * 2)
    ax.set_ylim(1e0, lim * 2)

    figText = chan.split(":")[0] + "_" + chan.split(":")[1] + "_" + parameter + "_scat"

    figName = InspiralUtils.set_figure_name(opts, figText)
    InspiralUtils.savefig_pylal(figName)
    pylab.close()

    return figName
Ejemplo n.º 9
0
def plotHistogram(chan, opts, distribution, histoList, binList, percentiles=None, candidate=None, candidateRank=None):

    parameter = distribution.split("-")[0]

    step = binList[1] - binList[0]
    counter = sum(histoList)

    xlimInf = min(binList)
    if candidate and not parameter == "dt":
        xlimSup = max(max(binList), candidate + 2.0)
    else:
        xlimSup = max(binList)

    pylab.figure()
    # semilogy(bins + step/2., z_dist+0.0001, 'r^',markerfacecolor="b",markersize=12)
    # plot(bins + step/2., z_dist)
    pylab.bar(binList[0 : len(binList) - 1], histoList, width=step, bottom=0)

    if percentiles:
        line1 = pylab.axvline(
            x=percentiles[0],
            ymin=0,
            ymax=max(histoList),
            color="g",
            label="50th percentile",
            linewidth=2,
            linestyle="--",
        )
        line2 = pylab.axvline(
            x=percentiles[1],
            ymin=0,
            ymax=max(histoList),
            color="m",
            label="95th percentile",
            linewidth=2,
            linestyle="--",
        )
        line3 = pylab.axvline(
            x=percentiles[2],
            ymin=0,
            ymax=max(histoList),
            color="r",
            label="99th percentile",
            linewidth=2,
            linestyle="--",
        )
        if parameter == "dt":
            pylab.axvline(
                x=-percentiles[0],
                ymin=0,
                ymax=max(histoList),
                color="g",
                label="50th percentile",
                linewidth=2,
                linestyle="--",
            )
            pylab.axvline(
                x=-percentiles[1],
                ymin=0,
                ymax=max(histoList),
                color="m",
                label="95th percentile",
                linewidth=2,
                linestyle="--",
            )
            pylab.axvline(
                x=-percentiles[2],
                ymin=0,
                ymax=max(histoList),
                color="r",
                label="99th percentile",
                linewidth=2,
                linestyle="--",
            )

    if candidate:
        line0 = pylab.axvline(
            x=candidate,
            ymin=0,
            ymax=max(histoList),
            color="k",
            label="candidate value (%s percentile)" % (candidateRank),
            linewidth=2,
            linestyle="-",
        )

    if percentiles and candidate:
        pylab.legend((line0, line1, line2, line3), ("candidate", "50%", "95%", "99%"), loc="upper right")

    if percentiles and not candidate:
        pylab.legend((line1, line2, line3), ("50%", "95%", "99%"), loc="upper right")

    pylab.xlim(xlimInf, xlimSup)

    pylab.xlabel(parameter + " value", size="large")
    # ylabel(r'#',size='x-large')
    pylab.grid()
    pylab.title("Histogram of the " + parameter + " value for " + chan + ", Statistics = " + str(counter))

    figText = chan.split(":")[0] + "_" + chan.split(":")[1] + "_" + parameter + "_dist"
    figFileName = InspiralUtils.set_figure_name(opts, figText)
    InspiralUtils.savefig_pylal(figFileName)
    pylab.close()

    return figFileName
parser.add_option(
    "-P",
    "--output-path",
    action="store",
    type="string",
    default="",
    metavar="PATH",
    help="path where the plots and will be stored",
)
# parser.add_option("","--output_path",action="store",\
#      type="string",default="",  metavar="PATH",\
#      help="path where the results will be stored. Generally prefer to set the same as the previous option, for the plots and html file")
(opts, args) = parser.parse_args()

# Initializing the html output
InspiralUtils.message(opts, "Initialisation...")
opts = InspiralUtils.initialise(opts, __prog__, __version__)
fnameList = []
tagList = []
fig_num = 0
comments = ""


dic = {}
dkeys = []
dval_FOM = []
dval_splits = []
dsort = []
dev_sig = []
dev_dt = []
dev_dur = []
    "only if an ifo is processed remotely (for instance V1 qscans). The " \
    "format should be an ifo string followed by a coma and a string " \
    "that contains the url of the remote qscan result page. For instance: " \
    "--remote-seismic-qscan-web V1,http://virgo.in2p3.fr/followups/romain/" \
    "tests/lv/local_followup_043009/871147814-873567014/CAT3/seismic-qscan/V1/")

command_line = sys.argv[1:]
(opts, args) = parser.parse_args()

##############################################################################
# main program

# List of ifos (used to check for Nelson KW vetoes)
#ifoList = ['H1','H2','L1']

opts = InspiralUtils.initialise(opts, __prog__, git_version.verbose_msg)

page = markup.page(mode="strict_html")
page._escape = False
doctype = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">"""
doctype += """\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">"""

title = "Detection Checklist for candidate " + str(
    opts.trigger_gps.split(",")[0].strip())
page.init(title=title, doctype=doctype)
#page.init(title=title)
page.h1()
page.add("Detection Checklist for Candidate " +
         str(opts.trigger_gps.split(",")[0].strip()) + " " +
         opts.ifolist_in_coinc + " in " + opts.ifo_times)
page.h1.close()
Ejemplo n.º 12
0
                  type="string",
                  help="Provide the path for the cum-hist-signif pickle file")

# use glob.glob('filename') to extract files from opts.pickle_files

(opts, args) = parser.parse_args()

try:
    os.mkdir(opts.output_path)
except:
    pass

################   PLOTS   #############################################################

# Initializing the html output
InspiralUtils.message(opts, "Initialisation...")
opts = InspiralUtils.initialise(opts, __prog__, __version__)
fnameList = []
tagList = []
fig_num = 0
comments = ""

###########################################################################################
if opts.verbose:
    print 'Generating Plots...'

colorDIC = {'ann': 'b', 'mvsc': 'g', 'svm': 'r', 'ovl': 'c', 'combined': 'm'}
labelDIC = {
    'ann': 'ANN',
    'mvsc': 'MVSC',
    'svm': 'SVM',
Ejemplo n.º 13
0
    "only if an ifo is processed remotely (for instance V1 qscans). The " \
    "format should be an ifo string followed by a coma and a string " \
    "that contains the url of the remote qscan result page. For instance: " \
    "--remote-seismic-qscan-web V1,http://virgo.in2p3.fr/followups/romain/" \
    "tests/lv/local_followup_043009/871147814-873567014/CAT3/seismic-qscan/V1/")

command_line = sys.argv[1:]
(opts,args) = parser.parse_args()

##############################################################################
# main program

# List of ifos (used to check for Nelson KW vetoes)
#ifoList = ['H1','H2','L1']

opts = InspiralUtils.initialise(opts, __prog__, git_version.verbose_msg)

page = markup.page(mode="strict_html")
page._escape = False
doctype="""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">"""
doctype+="""\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">"""

title = "Detection Checklist for candidate " + str(opts.trigger_gps.split(",")[0].strip())
page.init(title=title, doctype=doctype)
#page.init(title=title)
page.h1()
page.add("Detection Checklist for Candidate " + str(opts.trigger_gps.split(",")[0].strip()) + " " + opts.ifolist_in_coinc + " in " + opts.ifo_times)
page.h1.close()

page.h2()
page.add("Inspiral triggers found by CBC search:")
      "output in a format that can be directly published on the cbc webpage "\
      "or in CVS. This only works IF --enable-output is also specified. The "\
      "argument should be the cvs directory where the html file will be placed "\
      "Example: --html-for-cbcweb protected/projects/s5/yourprojectdir")
parser.add_option("","--verbose", action="store_true",\
      default=False, help="print information" )
parser.add_option("-P","--output-path",action="store",\
      type="string",default="",  metavar="PATH",\
      help="path where the plots and will be stored")
#parser.add_option("","--output_path",action="store",\
#      type="string",default="",  metavar="PATH",\
#      help="path where the results will be stored. Generally prefer to set the same as the previous option, for the plots and html file")
(opts, args) = parser.parse_args()

# Initializing the html output
InspiralUtils.message(opts, "Initialisation...")
opts = InspiralUtils.initialise(opts, __prog__, __version__)
fnameList = []
tagList = []
fig_num = 0
comments = ""

dic = {}
dkeys = []
dval_FOM = []
dval_splits = []
dsort = []
dev_sig = []
dev_dt = []
dev_dur = []
dev_freq = []