Exemplo n.º 1
0
    def genSchedule(self, directory='.', lvem=True):
        '''
        generate a schedule for Bayestar
        '''
        sched = schedule.Schedule()
        if random.random() < self.startProb:
            start_dt = max(
                0, random.normalvariate(self.startTimeout, self.startJitter))
            message = 'BayesWaveBurst launched'
            sched.insert(
                schedule.WriteLog(start_dt,
                                  self.graceDBevent,
                                  message,
                                  gdb_url=self.gdb_url))

            if random.random() < self.finishProb:
                finish_dt = max(
                    start_dt,
                    random.normalvariate(self.finishTimeout,
                                         self.finishJitter))

                for message in [
                        'BWB Follow-up results', 'BWB parameter estimation',
                        'BWB Bayes Factors'
                ]:
                    sched.insert(
                        schedule.WriteLog(finish_dt,
                                          self.graceDBevent,
                                          message,
                                          tagname=['pe'],
                                          gdb_url=self.gdb_url))

                if random.random() < self.skymapProb:
                    skymap_dt = max(
                        finish_dt,
                        random.normalvariate(self.skymapTimeout,
                                             self.skymapJitter))
                    message = 'BWB'
                    fitsname = self.writeFITS(directory=directory)
                    tagname = ['sky_loc']
                    if lvem:
                        tagname.append('lvem')
                    sched.insert(
                        schedule.WriteLog(skymap_dt,
                                          self.graceDBevent,
                                          message,
                                          filename=fitsname,
                                          tagname=tagname,
                                          gdb_url=self.gdb_url))

                    ### add in plotting and skyviewer
                    agenda = PlotSkymaps(self.graceDBevent, timeout=self.plotSkymapTimeout, jitter=self.plotSkymapJitter, probOfSuccess=self.plotSkymapProb, gdb_url=self.gdb_url).genSchedule(fitsname, tagname=tagname) \
                             + Skyviewer(self.graceDBevent, timeout=self.skyviewerTimeout, jitter=self.skyviewerJitter, probOfSuccess=self.skyviewerProb, gdb_url=self.gdb_url).genSchedule(fitsname, tagname=tagname)
                    agenda.bump(skymap_dt)
                    sched += agenda

        return sched
Exemplo n.º 2
0
    def genSchedule(self, directory='.', lvem=True):
        '''
        generate a schedule for Bayestar
        '''
        sched = schedule.Schedule()
        if random.random() < self.startProb:
            start_dt = max(
                0, random.normalvariate(self.startTimeout, self.startJitter))
            for message in [
                    'INFO:BAYESTAR:by your command...',
                    'INFO:BAYESTAR:starting sky localization'
            ]:
                sched.insert(
                    schedule.WriteLog(start_dt,
                                      self.graceDBevent,
                                      message,
                                      gdb_url=self.gdb_url))

            if random.random() < self.finishProb:
                finish_dt = max(
                    start_dt,
                    random.normalvariate(self.finishTimeout,
                                         self.finishJitter))

                message = 'INFO:BAYESTAR:sky localization complete'
                sched.insert(
                    schedule.WriteLog(finish_dt,
                                      self.graceDBevent,
                                      message,
                                      gdb_url=self.gdb_url))

                if random.random() < self.skymapProb:
                    skymap_dt = max(
                        finish_dt,
                        random.normalvariate(self.skymapTimeout,
                                             self.skymapJitter))
                    message = 'INFO:BAYESTAR:uploaded sky map'
                    fitsname = self.writeFITS(directory=directory)
                    tagname = ['sky_loc']
                    if lvem:
                        tagname.append('lvem')
                    sched.insert(
                        schedule.WriteLog(skymap_dt,
                                          self.graceDBevent,
                                          message,
                                          filename=fitsname,
                                          tagname=tagname,
                                          gdb_url=self.gdb_url))

                    ### add in plotting and skyviewer
                    agenda = PlotSkymaps(self.graceDBevent, timeout=self.plotSkymapTimeout, jitter=self.plotSkymapJitter, probOfSuccess=self.plotSkymapProb, gdb_url=self.gdb_url).genSchedule(fitsname, tagname=tagname) \
                             + Skyviewer(self.graceDBevent, timeout=self.skyviewerTimeout, jitter=self.skyviewerJitter, probOfSuccess=self.skyviewerProb, gdb_url=self.gdb_url).genSchedule(fitsname, tagname=tagname)
                    agenda.bump(skymap_dt)
                    sched += agenda

        return sched
Exemplo n.º 3
0
    def genSchedule(self, directory='.', lvem=True):
        '''
        generate a schedule for Bayestar
        '''
        sched = schedule.Schedule()
        if random.random() < self.startProb:
            start_dt = max(
                0, random.normalvariate(self.startTimeout, self.startJitter))
            message = 'LALInference online estimation started'
            sched.insert(
                schedule.WriteLog(start_dt,
                                  self.graceDBevent,
                                  message,
                                  gdb_url=self.gdb_url))

            if random.random() < self.finishProb:
                finish_dt = max(
                    start_dt,
                    random.normalvariate(self.finishTimeout,
                                         self.finishJitter))

                message = 'LALInference online estimation finished'
                filename = self.writeDat(directory=directory)
                sched.insert(
                    schedule.WriteLog(finish_dt,
                                      self.graceDBevent,
                                      message,
                                      gdb_url=self.gdb_url))

                if random.random() < self.skymapProb:
                    skymap_dt = max(
                        finish_dt,
                        random.normalvariate(self.skymapTimeout,
                                             self.skymapJitter))
                    message = 'LALInference'
                    fitsname = self.writeFITS(directory=directory)
                    tagname = ['sky_loc']
                    if lvem:
                        tagname.append('lvem')
                    sched.insert(
                        schedule.WriteLog(skymap_dt,
                                          self.graceDBevent,
                                          message,
                                          filename=fitsname,
                                          tagname=tagname,
                                          gdb_url=self.gdb_url))

                    ### add in plotting and skyviewer
                    agenda = PlotSkymaps(self.graceDBevent, timeout=self.plotSkymapTimeout, jitter=self.plotSkymapJitter, probOfSuccess=self.plotSkymapProb, gdb_url=self.gdb_url).genSchedule(fitsname, tagname=tagname) \
                             + Skyviewer(self.graceDBevent, timeout=self.skyviewerTimeout, jitter=self.skyviewerJitter, probOfSuccess=self.skyviewerProb, gdb_url=self.gdb_url).genSchedule(fitsname, tagname=tagname)
                    agenda.bump(skymap_dt)
                    sched += agenda

        return sched
Exemplo n.º 4
0
 def genSchedule(self):
     sched = schedule.Schedule()
     if random.random() < self.probOfReport:
         sched.insert(
             schedule.WriteLog(
                 max(0, random.normalvariate(self.timeout, self.jitter)),
                 self.graceDBevent,
                 self.genMessage(),
                 gdb_url=self.gdb_url,
             ))
     return sched
Exemplo n.º 5
0
 def genSchedule(self, fits, tagname=['sky_loc']):
     sched = schedule.Schedule()
     if random.random() < self.prob:
         sched.insert(
             schedule.WriteLog(max(
                 0, random.normalvariate(self.timeout, self.jitter)),
                               self.graceDBevent,
                               self.genMessage(),
                               filename=self.genJSON(fits),
                               tagname=tagname,
                               gdb_url=self.gdb_url))
     return sched
Exemplo n.º 6
0
    def genSchedule(self, directory='.'):
        '''
        generate a schedule for SegDB2GraceDB uploads
        '''
        sched = schedule.Schedule()
        if random.random() < self.startProb:
            start_dt = max(
                0, random.normalvariate(self.startDelay, self.startJitter))
            message = 'began searching for segments in : fakeSegDB'
            sched.insert(
                schedule.WriteLog(start_dt,
                                  self.graceDBevent,
                                  message,
                                  gdb_url=self.gdb_url))

            for flag, (delay, jitter, prob), (start, dur) in self.flags:
                if random.random() < prob:
                    filename = self.genFilename(flag,
                                                start,
                                                dur,
                                                directory=directory)
                    start_dt += max(0, random.normalvariate(delay, jitter))
                    sched.insert(
                        schedule.WriteLog(start_dt,
                                          self.graceDBevent,
                                          flag,
                                          filename=filename,
                                          gdb_url=self.gdb_url))
                else:
                    break  ### process failed, so we stop

            sched.insert(
                schedule.WriteLog(
                    start_dt,
                    self.graceDBevent,
                    'finished searching for segments in : fakeSegDB',
                    gdb_url=self.gdb_url))

        return sched
Exemplo n.º 7
0
    def genSchedule(self, directory='.'):
        '''
        generate and return the schedule for Virgo DQ information
        '''
        # Create Schedule object
        sched = schedule.Schedule()
        if 'V1' not in self.instruments:
            # don't schedule anything, no action taken
            pass
        else:
            if random.random() <= self.startProb:
                dt = max(
                    0, random.normalvariate(self.startDelay, self.startJitter))
                message = "Starting V1 detchar analysis: [%d;%d]" % (
                    self.start, self.stop)
                sched.insert(
                    schedule.WriteLog(dt,
                                      self.graceDBevent,
                                      message,
                                      gdb_url=self.gdb_url))

                if random.random() <= self.ifostatsProb:
                    dt += max(
                        0,
                        random.normalvariate(self.ifostatsDelay,
                                             self.ifostatsJitter))
                    message = "Testing V1 interferometer status:"
                    filename = self.genIFOStatusFilename(directory=directory)
                    sched.insert(
                        schedule.WriteLog(dt,
                                          self.graceDBevent,
                                          message,
                                          filename=filename,
                                          gdb_url=self.gdb_url))

                if random.random() <= self.vetoesProb:
                    #FIXME: Currently implementing "IS/IS NOT vetoed" only, needs more logic
                    dt += max(
                        0,
                        random.normalvariate(self.vetoesDelay,
                                             self.vetoesJitter))
                    message = "Testing %s V1 veto channel: this event IS NOT vetoed" % (
                        self.pipeline, )
                    sched.insert(
                        schedule.WriteLog(dt,
                                          self.graceDBevent,
                                          message,
                                          gdb_url=self.gdb_url))
                else:
                    dt += max(
                        0,
                        random.normalvariate(self.vetoesDelay,
                                             self.vetoesJitter))
                    message = "Testing %s V1 veto channel: this event IS vetoed" % (
                        self.pipeline, )
                    sched.insert(
                        schedule.WriteLog(dt,
                                          self.graceDBevent,
                                          message,
                                          gdb_url=self.gdb_url))

                if random.random() <= self.rmsChanProb:
                    dt += max(
                        0,
                        random.normalvariate(self.rmsChanDelay,
                                             self.rmsChanJitter))
                    message = "Testing V1 band RMS channels:"
                    filename = self.genRMSChanFilename(directory=directory)
                    sched.insert(
                        schedule.WriteLog(dt,
                                          self.graceDBevent,
                                          message,
                                          filename=filename,
                                          gdb_url=self.gdb_url))

                if random.random() < self.injProb:
                    #FIXME: Currently implementing "FOUND/ DID NOT FIND injections"
                    #Need to implement what happens when injections are found
                    dt += max(
                        0, random.normalvariate(self.injDelay, self.injJitter))
                    message = "Testing V1 hardware injection: DID FIND injections"
                    sched.insert(
                        schedule.WriteLog(dt,
                                          self.graceDBevent,
                                          message,
                                          gdb_url=self.gdb_url))
                else:
                    dt += max(
                        0, random.normalvariate(self.injDelay, self.injJitter))
                    message = "Testing V1 hardware injection: DID NOT FIND injections"
                    sched.insert(
                        schedule.WriteLog(dt,
                                          self.graceDBevent,
                                          message,
                                          gdb_url=self.gdb_url))
                # write finishing test
                message = "V1 detchar analysis finished"
                sched.insert(
                    schedule.WriteLog(dt,
                                      self.graceDBevent,
                                      message,
                                      gdb_url=self.gdb_url))
        return sched
Exemplo n.º 8
0
    def genSchedule(self, directory='.'):
        '''
        generate a schedule for iDQ uploads
        '''
        sched = schedule.Schedule()

        for instrument in self.instruments:
            if random.random() < self.startProb:
                dt = max(
                    0, random.normalvariate(self.startDelay, self.startJitter))
                message = 'Started Searching for iDQ information within [%d, %d] at %s' % (
                    self.start, self.stop, instrument)
                sched.insert(
                    schedule.WriteLog(dt,
                                      self.graceDBevent,
                                      message,
                                      gdb_url=self.gdb_url))

                for classifier in self.classifiers:
                    if random.random() < self.tablesProb:
                        dt += max(
                            0,
                            random.normalvariate(self.tablesDelay,
                                                 self.tablesJitter))
                        message = 'iDQ glitch tables %s:' % instrument
                        filename = self.genTablesFilename(instrument,
                                                          classifier,
                                                          directory=directory)
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              message,
                                              filename=filename,
                                              gdb_url=self.gdb_url))
                    else:
                        break

                    if random.random() < self.fapProb:
                        dt += max(
                            0,
                            random.normalvariate(self.fapDelay,
                                                 self.fapJitter))
                        fap = self.drawFAP()
                        message = 'minimum glitch-FAP for %s at %s within [%d, %d] is %.6f' % (
                            classifier, instrument, self.start, self.stop, fap)
                        filename = self.genFAPFilename(instrument,
                                                       classifier,
                                                       directory=directory)
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              message,
                                              filename=filename,
                                              gdb_url=self.gdb_url))
                    else:
                        break

                    if random.random() < self.gwfProb:
                        dt += max(
                            0,
                            random.normalvariate(self.gwfDelay,
                                                 self.gwfJitter))
                        fapMessage = 'iDQ fap timesereis for %s at %s within [%d, %d] :' % (
                            classifier, instrument, self.start, self.stop)
                        rnkMessage = 'iDQ glitch-rank frame for %s at %s within [%d, %d] :' % (
                            classifier, instrument, self.start, self.stop)
                        fapGWF, rnkGWF = self.genGWFFilenames(
                            instrument, classifier, directory=directory)
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              fapMessage,
                                              filename=fapGWF,
                                              gdb_url=self.gdb_url))
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              rnkMessage,
                                              filename=rnkGWF,
                                              gdb_url=self.gdb_url))
                    else:
                        break

                    if random.random() < self.timeseriesProb:
                        dt += max(
                            0,
                            random.normalvariate(self.timeseriesDelay,
                                                 self.timeseriesJitter))
                        message = 'iDQ fap and glitch-rank timeseries plot for %s at %s:' % (
                            classifier, instrument)
                        pngFilename = self.genTimeseriesFilename(
                            instrument, classifier, directory=directory)
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              message,
                                              filename=pngFilename,
                                              gdb_url=self.gdb_url))
                    else:
                        break

                    if 'ovl' not in classifier:  ### warning! this is dangerous hard coding!
                        pass
                    elif random.random() < self.activeChanProb:
                        dt += max(
                            0,
                            random.normalvariate(self.activeChanDelay,
                                                 self.activeChanJitter))
                        jsonMessage = 'iDQ (possible) active channels for %s at %s' % (
                            classifier, instrument)
                        pngMessage = 'iDQ channel strip chart for %s at %s' % (
                            classifier, instrument)
                        jsonFilename, pngFilename = self.genActiveChanFilename(
                            instrument, classifier, directory=directory)
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              jsonMessage,
                                              filename=jsonFilename,
                                              gdb_url=self.gdb_url))
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              pngMessage,
                                              filename=pngFilename,
                                              gdb_url=self.gdb_url))
                    else:
                        break

                    if random.random() < self.calibProb:
                        dt += max(
                            0,
                            random.normalvariate(self.calibDelay,
                                                 self.calibJitter))
                        jsonMessage = 'iDQ calibration sanity check for %s at %s' % (
                            classifier, instrument)
                        pngMessage = 'iDQ calibration sanity check figure for %s at %s' % (
                            classifier, instrument)
                        jsonFilename, pngFilename = self.genCalibFilename(
                            instrument, classifier, directory=directory)
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              jsonMessage,
                                              filename=jsonFilename,
                                              gdb_url=self.gdb_url))
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              pngMessage,
                                              filename=pngFilename,
                                              gdb_url=self.gdb_url))
                    else:
                        break

                    if random.random() < self.rocProb:
                        dt += max(
                            0,
                            random.normalvariate(self.rocDelay,
                                                 self.rocJitter))
                        jsonMessage = 'iDQ local ROC curves for %s at %s' % (
                            classifier, instrument)
                        pngMessage = 'iDQ local ROC figure for %s at %s'
                        jsonFilename, pngFilename = self.genROCFilename(
                            instrument, classifier, directory=directory)
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              jsonMessage,
                                              filename=jsonFilename,
                                              gdb_url=self.gdb_url))
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              pngMessage,
                                              filename=pngFilename,
                                              gdb_url=self.gdb_url))
                    else:
                        break

                    if random.random() < self.statsProb:
                        dt += max(
                            0,
                            random.normalvariate(self.statsDelay,
                                                 self.statsJitter))
                        calibMessage = 'iDQ local calibration vital statistics for %s at %s' % (
                            classifier, instrument)
                        trainMessage = 'iDQ local training vital statistics for %s at %s' % (
                            classifier, instrument)
                        calibFilename, trainFilename = self.genStatsFilenames(
                            instrument, classifier, directory=directory)
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              calibMessage,
                                              filename=calibFilename,
                                              gdb_url=self.gdb_url))
                        sched.insert(
                            schedule.WriteLog(dt,
                                              self.graceDBevent,
                                              trainMessage,
                                              filename=trainFilename,
                                              gdb_url=self.gdb_url))
                    else:
                        break

                else:  ### we made it all the way through! add finish statement
                    message = 'Finished searching for iDQ information within [%d, %d] at %s' % (
                        self.start, self.stop, instrument)
                    sched.insert(
                        schedule.WriteLog(dt,
                                          self.graceDBevent,
                                          message,
                                          gdb_url=self.gdb_url))

        return sched
Exemplo n.º 9
0
    agenda = pipeObj.genSchedule(directory=opts.output_dir)

    ### put some stuff into the event

    ### writeLabel
    for label in set( [random.choice(labels) for _ in xrange(5)] ):
        agenda.insert( schedule.WriteLabel( 100, gDBevent, label, gdb_url=opts.fakeDB_dir ) )
    
    ### removeLabel
#    agenda.insert( schedule.RemoveLabel( 150, gDBevent, label, gdb_url=opts.fakeDB_dir ) )
    #                                                    ^this should be defined in the previous loop!

    ### writeLog
    for num in xrange(5):
        message = 'message number : %d'%(num+1)
        agenda.insert( schedule.WriteLog( 200, gDBevent, message, gdb_url=opts.fakeDB_dir ) )

    for num in xrange(5):
        message  = "message with file number : %d"%(num+1)
        filename = os.path.join( opts.output_dir, "%s-%d.txt"%(randStr, num+1) )
        open(filename, 'w').close()
        agenda.insert( schedule.WriteLog( 300, gDBevent, message, filename=filename, gdb_url=opts.fakeDB_dir ) )

    ### writeFile
    for num in xrange(num, num+5):
        filename = os.path.join( opts.output_dir, "%s_%d.txt"%(randStr, num+1) )
        open(filename, 'w').close()
        agenda.insert( schedule.WriteFile( 400, gDBevent, filename, gdb_url=opts.fakeDB_dir ) )

    ### iterate and do things
    for action in agenda: