def create_node(self, bank): """ Set up a CondorDagmanNode class to run lalapps_splitbank code Parameters ---------- bank : pycbc.workflow.core.File The OutFile containing the template bank to be split Returns -------- node : pycbc.workflow.core.Node The node to run the job """ node = Node(self) # FIXME: This is a hack because SplitBank fails if given an input file # whose path contains the character '-' or if the input file is not in # the same directory as the output. Therefore we just set the path to # be the local path fullPath = bank.cache_entry.path bank.cache_entry.path = os.path.basename(fullPath) node.add_input_opt('--bank-file', bank) # FIXME: Set the path back to what it was. This is part of the hack # above and should be removed if possible. bank.cache_entry.path = fullPath # Get the output (taken from inspiral.py) url_list = [] x = bank.filename.split('-') if len(x) != 4: errMsg = "Input file name is not compatible with splitbank. Name " errMsg += "must follow the lal cache standard, for example " errMsg += "H1-TMPLTBANK-900000000-1000.xml. " errMsg += "Got %s." % (bank.filename, ) raise ValueError(errMsg) for i in range(0, self.num_banks): out_file = "%s-%s_%2.2d-%s-%s" % (x[0], x[1], i, x[2], x[3]) out_url = urlparse.urlunparse([ 'file', 'localhost', os.path.join(self.out_dir, out_file), None, None, None ]) url_list.append(out_url) job_tag = bank.description + "_" + self.name.upper() out_file = File( bank.ifo, job_tag, bank.segment, file_url=out_url, tags=bank.tags, store_file=self.retain_files) node._add_output(out_file) return node
def create_node(self, bank): """ Set up a CondorDagmanNode class to run lalapps_splitbank code Parameters ---------- bank : pycbc.workflow.core.File The OutFile containing the template bank to be split Returns -------- node : pycbc.workflow.core.Node The node to run the job """ node = Node(self) # FIXME: This is a hack because SplitBank fails if given an input file # whose path contains the character '-' or if the input file is not in # the same directory as the output. Therefore we just set the path to # be the local path fullPath = bank.cache_entry.path bank.cache_entry.path = os.path.basename(fullPath) node.add_input_opt('--bank-file', bank) # FIXME: Set the path back to what it was. This is part of the hack # above and should be removed if possible. bank.cache_entry.path = fullPath # Get the output (taken from inspiral.py) url_list = [] x = bank.filename.split('-') if len(x) != 4: errMsg = "Input file name is not compatible with splitbank. Name " errMsg += "must follow the lal cache standard, for example " errMsg += "H1-TMPLTBANK-900000000-1000.xml. " errMsg += "Got %s." % (bank.filename, ) raise ValueError(errMsg) for i in range(0, self.num_banks): out_file = "%s-%s_%2.2d-%s-%s" % (x[0], x[1], i, x[2], x[3]) out_url = urlparse.urlunparse([ 'file', 'localhost', os.path.join(self.out_dir, out_file), None, None, None ]) url_list.append(out_url) job_tag = bank.description + "_" + self.name.upper() out_file = File(bank.ifo, job_tag, bank.segment, file_url=out_url, tags=bank.tags, store_file=self.retain_files) node._add_output(out_file) return node
def get_veto_segs(workflow, ifo, category, start_time, end_time, out_dir, vetoGenJob, tag=None, execute_now=False): """ Obtain veto segments for the selected ifo and veto category and add the job to generate this to the workflow. Parameters ----------- workflow: pycbc.workflow.core.Workflow An instance of the Workflow class that manages the workflow. ifo : string The string describing the ifo to generate vetoes for. category : int The veto category to generate vetoes for. start_time : gps time (either int/LIGOTimeGPS) The time at which to begin searching for segments. end_time : gps time (either int/LIGOTimeGPS) The time at which to stop searching for segments. out_dir : path The directory in which output will be stored. vetoGenJob : Job The veto generation Job class that will be used to create the Node. tag : string, optional (default=None) Use this to specify a tag. This can be used if this module is being called more than once to give call specific configuration (by setting options in [workflow-datafind-${TAG}] rather than [workflow-datafind]). This is also used to tag the Files returned by the class to uniqueify the Files and uniqueify the actual filename. FIXME: Filenames may not be unique with current codes! execute_now : boolean, optional If true, jobs are executed immediately. If false, they are added to the workflow to be run later. Returns -------- veto_def_file : pycbc.workflow.core.OutSegFile The workflow File object corresponding to this DQ veto file. """ segValidSeg = segments.segment([start_time,end_time]) node = Node(vetoGenJob) node.add_opt('--veto-categories', str(category)) node.add_opt('--ifo-list', ifo) node.add_opt('--gps-start-time', str(start_time)) node.add_opt('--gps-end-time', str(end_time)) vetoXmlFileName = "%s-VETOTIME_CAT%d-%d-%d.xml" \ %(ifo, category, start_time, end_time-start_time) vetoXmlFilePath = os.path.abspath(os.path.join(out_dir, vetoXmlFileName)) currUrl = urlparse.urlunparse(['file', 'localhost', vetoXmlFilePath, None, None, None]) if tag: currTags = [tag, 'VETO_CAT%d' %(category)] else: currTags = ['VETO_CAT%d' %(category)] vetoXmlFile = OutSegFile(ifo, 'SEGMENTS', segValidSeg, currUrl, tags=currTags) node._add_output(vetoXmlFile) if execute_now: if file_needs_generating(vetoXmlFile.cache_entry.path): workflow.execute_node(node) else: node.executed = True for fil in node._outputs: fil.node = None fil.PFN(fil.storage_path, site='local') else: workflow.add_node(node) return vetoXmlFile