code
stringlengths
1
18.2k
def add_node(self,node): """ Add a CondorDAGNode to this DAG. The CondorJob that the node uses is also added to the list of Condor jobs in the DAG so that a list of the submit files needed by the DAG can be maintained. Each unique CondorJob will be added once to prevent duplicate submit files being written. @param node...
def write_maxjobs(self,fh,category): """ Write the DAG entry for this category's maxjobs to the DAG file descriptor. @param fh: descriptor of open DAG file. @param category: tuple containing type of jobs to set a maxjobs limit for and the maximum number of jobs of that type to run at once. """ fh.write( 'MAXJOBS ' + st...
def write_sub_files(self): """ Write all the submit files used by the dag to disk. Each submit file is written to the file name set in the CondorJob. """ if not self.__nodes_finalized: for node in self.__nodes: node.finalize() if not self.is_dax(): for job in self.__jobs: job.write_sub_file()
def write_concrete_dag(self): """ Write all the nodes in the DAG to the DAG file. """ if not self.__dag_file_path: raise CondorDAGError, "No path for DAG file" try: dagfile = open( self.__dag_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path for node in self.__nodes: node.write_j...
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ # keep track of if we are using stampede at TACC using_stampede = False if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return import Pegasus.DAX3 # create the workflow object dax_name = o...
workflow_pfn_dict[pfn_tuple[0]] = pfn_tuple if self.get_pegasus_worker(): # write the executable into the dax worker_package = Pegasus.DAX3.Executable( namespace="pegasus", name="worker", os="linux", arch="x86_64", installed=False) worker_package.addPFN(Pegasus.DAX3.PFN(self.get_pegasus_worker(),"local")) workflow_exec...
node as a sub-dax subdax_name = os.path.split(node.job().get_dax())[-1] dax_subdir = node.job().get_dag_directory() if dax_subdir: subdax_path = os.path.join( os.getcwd(),node.job().get_dag_directory(),subdax_name) else: subdax_path = os.path.join(os.getcwd(),subdax_name) dax_subdir = '.' subdax = Pegasus.DAX3.DAX(subd...
if node.get_reduce_dax() is False: pegasus_args += " --force " if node.get_static_pfn_cache(): pegasus_args += " --cache " + node.get_static_pfn_cache() + " " pegasus_args += "--output-site local -vvvvvv" subdax.addArguments(pegasus_args) subdax_file = Pegasus.DAX3.File(subdax_name) subdax_file.addPFN(Pegasus.DAX3.PFN(...
for f in node.get_output_files(): output_node_file_dict[f] = 1 checkpoint_node_file_dict = {} for f in node.get_checkpoint_files(): checkpoint_node_file_dict[f] = 1 for f in output_node_file_dict.keys(): workflow_job.uses(Pegasus.DAX3.File(os.path.basename(f)),link=Pegasus.DAX3.Link.OUTPUT,register=False,transfer=True)...
if node.job().get_dax_mpi_cluster(): workflow_job.addProfile(Pegasus.DAX3.Profile("pegasus","job.aggregator","mpiexec")) workflow_job.addProfile(Pegasus.DAX3.Profile("pegasus","clusters.size",str(node.job().get_dax_mpi_cluster()))) # write the grid start parameter for this node # if the grid start is not None if node.g...
must run in the vanilla universe workflow_job.addProfile(Pegasus.DAX3.Profile("condor","universe","vanilla")) else: workflow_job.addProfile(Pegasus.DAX3.Profile("condor","universe",node.job().get_universe())) # add any other user specified condor commands or classads for p in node.get_pegasus_profile(): workflow_job.ad...
os="linux", arch="x86_64", installed="true") dev_mpiexec.addPFN(Pegasus.DAX3.PFN("file:///home1/02796/dabrown/bin/mpi-cluster-wrapper-impi.sh","stampede-dev")) workflow.addExecutable(dev_mpiexec) # FIXME put all the pfns in the workflow for pfn_key in workflow_pfn_dict.keys(): f = Pegasus.DAX3.File(workflow_pfn_dict[pf...
def write_dag(self): """ Write either a dag or a dax. """ if not self.__nodes_finalized: for node in self.__nodes: node.finalize() self.write_concrete_dag() self.write_abstract_dag()
def write_script(self): """ Write the workflow to a script (.sh instead of .dag). Assuming that parents were added to the DAG before their children, dependencies should be handled correctly. """ if not self.__dag_file_path: raise CondorDAGError, "No path for DAG file" try: dfp = self.__dag_file_path outfilename = ".".j...
def prepare_dax(self,grid_site=None,tmp_exec_dir='.',peg_frame_cache=None): """ Sets up a pegasus script for the given dag """ dag=self log_path=self.__log_file_path # this function creates the following three files needed by pegasus peg_fh = open("pegasus_submit_dax", "w") pegprop_fh = open("pegasus.properties", "w") ...
jobs on an execution site without relying # on a shared filesystem between the head node and the worker nodes. If this # is set, specify staging site ( using --staging-site option to pegasus-plan) # to indicate the site to use as a central storage location for a workflow. pegasus.data.configuration=nonsharedfs """ else...
print >> basedir_fh, PEGASUS_BASEDIR_SCRIPT % ( tmp_exec_dir, dag.get_dax_file().replace('.dax','') + '-0.dag' ) basedir_fh.close() os.chmod("pegasus_basedir",0755) # write the site catalog file which is needed by pegasus pwd = os.getcwd() try: hostname = socket.gethostbyaddr(socket.gethostname())[0] except: hostname =...
print >> sitefile, """ <profile namespace="env" key="PEGASUS_HOME">%s</profile>""" % os.environ['PEGASUS_HOME'] except: pass try: print >> sitefile, """ <profile namespace="env" key="LIGO_DATAFIND_SERVER">%s</profile>""" % os.environ['LIGO_DATAFIND_SERVER'] except: pass try: print >> sitefile, """ <profile namespace="e...
</site> <!-- Nikhef Stage in Site --> <site handle="nikhef-srm" arch="x86_64" os="LINUX"> <directory type="shared-scratch" path="/%s/"> <file-server operation="all" url="srm://tbn18.nikhef.nl:8446/srm/managerv2?SFN=/dpm/nikhef.nl/home/virgo/%s/" /> </directory> </site> """ % (os.path.basename(tmp_exec_dir),os.path.base...
jobtype="compute"/> <directory type="shared-scratch" path="%s"> <file-server operation="all" url="gsiftp://gridftp.stampede.tacc.xsede.org%s"/> </directory> <profile namespace="env" key="PEGASUS_HOME">/usr</profile> <profile namespace="globus" key="queue">development</profile> <profile namespace="globus" key="maxwallti...
pegasus-analyzer -t -i `./pegasus_basedir` to debug any failed jobs. """
def get_config(self,sec,opt): """ Get the configration variable in a particular section of this jobs ini file. @param sec: ini file section. @param opt: option from section sec. """ return string.strip(self.__cp.get(sec,opt))
def set_start(self,time,pass_to_command_line=True): """ Set the GPS start time of the analysis node by setting a --gps-start-time option to the node when it is executed. @param time: GPS start time of job. @bool pass_to_command_line: add gps-start-time as variable option. """ if pass_to_command_line: self.add_var_opt('...
def set_end(self,time,pass_to_command_line=True): """ Set the GPS end time of the analysis node by setting a --gps-end-time option to the node when it is executed. @param time: GPS end time of job. @bool pass_to_command_line: add gps-end-time as variable option. """ if pass_to_command_line: self.add_var_opt('gps-end-ti...
def set_trig_start(self,time,pass_to_command_line=True): """ Set the trig start time of the analysis node by setting a --trig-start-time option to the node when it is executed. @param time: trig start time of job. @bool pass_to_command_line: add trig-start-time as a variable option. """ if pass_to_command_line: self.ad...
def set_trig_end(self,time,pass_to_command_line=True): """ Set the trig end time of the analysis node by setting a --trig-end-time option to the node when it is executed. @param time: trig end time of job. @bool pass_to_command_line: add trig-end-time as a variable option. """ if pass_to_command_line: self.add_var_opt(...
def set_input(self,filename,pass_to_command_line=True): """ Add an input to the node by adding a --input option. @param filename: option argument to pass as input. @bool pass_to_command_line: add input as a variable option. """ self.__input = filename if pass_to_command_line: self.add_var_opt('input', filename) self.ad...
def set_output(self,filename,pass_to_command_line=True): """ Add an output to the node by adding a --output option. @param filename: option argument to pass as output. @bool pass_to_command_line: add output as a variable option. """ self.__output = filename if pass_to_command_line: self.add_var_opt('output', filename) ...
def set_ifo(self,ifo): """ Set the ifo name to analyze. If the channel name for the job is defined, then the name of the ifo is prepended to the channel name obtained from the job configuration file and passed with a --channel-name option. @param ifo: two letter ifo code (e.g. L1, H1 or H2). """ self.__ifo = ifo if sel...
def set_ifo_tag(self,ifo_tag,pass_to_command_line=True): """ Set the ifo tag that is passed to the analysis code. @param ifo_tag: a string to identify one or more IFOs @bool pass_to_command_line: add ifo-tag as a variable option. """ self.__ifo_tag = ifo_tag if pass_to_command_line: self.add_var_opt('ifo-tag', ifo_tag)
def set_user_tag(self,usertag,pass_to_command_line=True): """ Set the user tag that is passed to the analysis code. @param user_tag: the user tag to identify the job @bool pass_to_command_line: add user-tag as a variable option. """ self.__user_tag = usertag if pass_to_command_line: self.add_var_opt('user-tag', usertag...
def set_cache(self,filename): """ Set the LAL frame cache to to use. The frame cache is passed to the job with the --frame-cache argument. @param filename: calibration file to use. """ if isinstance( filename, str ): # the name of a lal cache file created by a datafind node self.add_var_opt('frame-cache', filename) sel...
t_end >= (self.get_data_start()-self.get_pad_data()-int(d)-1)): self.add_input_file(lfn) # set the frame type based on the LFNs returned by datafind self.add_var_opt('frame-type',b) else: raise CondorDAGNodeError, "Unknown LFN cache format"
def calibration_cache_path(self): """ Determine the path to the correct calibration cache file to use. """ if self.__ifo and self.__start > 0: cal_path = self.job().get_config('calibration','path') # check if this is S2: split calibration epochs if ( self.__LHO2k.match(self.__ifo) and (self.__start >= 729273613) and (s...
def calibration(self): """ Set the path to the calibration cache file for the given IFO. During S2 the Hanford 2km IFO had two calibration epochs, so if the start time is during S2, we use the correct cache file. """ # figure out the name of the calibration cache files # as specified in the ini-file self.calibration_ca...
def make_chunks(self,length=0,overlap=0,play=0,sl=0,excl_play=0,pad_data=0): """ Divides the science segment into chunks of length seconds overlapped by overlap seconds. If the play option is set, only chunks that contain S2 playground data are generated. If the user has a more complicated way of generating chunks, thi...
start/end of the playground @param sl: slide by sl seconds before determining playground data. @param excl_play: exclude the first excl_play second from the start and end of the chunk when computing if the chunk overlaps with playground. @param pad_data: exclude the first and last pad_data seconds of the segment when g...
(play_end - 6370) > start ): print "Two playground segments in this chunk:", print " Code to handle this case has not been implemented" sys.exit(1) else: if play_start > start: trig_start = int(play_start) if play_end < end: trig_end = int(play_end) self.__chunks.append(AnalysisChunk(start,end,trig_start,trig_end)) els...
def add_chunk(self,start,end,trig_start=0,trig_end=0): """ Add an AnalysisChunk to the list associated with this ScienceSegment. @param start: GPS start time of chunk. @param end: GPS end time of chunk. @param trig_start: GPS start time for triggers from chunk """ self.__chunks.append(AnalysisChunk(start,end,trig_start...
def set_start(self,t): """ Override the GPS start time (and set the duration) of this ScienceSegment. @param t: new GPS start time. """ self.__dur += self.__start - t self.__start = t
def set_end(self,t): """ Override the GPS end time (and set the duration) of this ScienceSegment. @param t: new GPS end time. """ self.__dur -= self.__end - t self.__end = t
def read(self,filename,min_length,slide_sec=0,buffer=0): """ Parse the science segments from the segwizard output contained in file. @param filename: input text file containing a list of science segments generated by segwizard. @param min_length: only append science segments that are longer than min_length. @param slid...
2*abs(buffer) x = ScienceSegment(tuple([id,st,en,du])) self.__sci_segs.append(x)
def tama_read(self,filename): """ Parse the science segments from a tama list of locked segments contained in file. @param filename: input text file containing a list of tama segments. """ self.__filename = filename for line in open(filename): columns = line.split() id = int(columns[0]) start = int(math.ceil(float(colu...
def make_chunks(self,length,overlap=0,play=0,sl=0,excl_play=0,pad_data=0): """ Divide each ScienceSegment contained in this object into AnalysisChunks. @param length: length of chunk in seconds. @param overlap: overlap between segments. @param play: if true, only generate chunks that overlap with S2 playground data. @p...
def make_chunks_from_unused(self,length,trig_overlap,play=0,min_length=0, sl=0,excl_play=0,pad_data=0): """ Create an extra chunk that uses up the unused data in the science segment. @param length: length of chunk in seconds. @param trig_overlap: length of time start generating triggers before the start of the unused d...
pad_data seconds of the segment when generating chunks """ for seg in self.__sci_segs: # if there is unused data longer than the minimum chunk length if seg.unused() > min_length: end = seg.end() - pad_data start = end - length if (not play) or (play and (((end-sl-excl_play-729273613)%6370) < (600+length-2*excl_play)))...
= int(play_end) if (trig_end == 0) or (trig_end > trig_start): seg.add_chunk(start, end, trig_start, trig_end) else: seg.add_chunk(start, end, trig_start) seg.set_unused(0)
def make_short_chunks_from_unused( self,min_length,overlap=0,play=0,sl=0,excl_play=0): """ Create a chunk that uses up the unused data in the science segment @param min_length: the unused data must be greater than min_length to make a chunk. @param overlap: overlap between chunks in seconds. @param play: if true, only ...
def make_optimised_chunks(self, min_length, max_length, pad_data=0): """ Splits ScienceSegments up into chunks, of a given maximum length. The length of the last two chunks are chosen so that the data utilisation is optimised. @param min_length: minimum chunk length. @param max_length: maximum chunk length. @param pad_...
((N-1) * max_length) middle = (start + seg_end)/2 seg.add_chunk(start, middle) seg.add_chunk(middle, seg_end) seg.set_unused(0) elif seg.unused() > min_length: # utilise as single chunk seg.add_chunk(seg_start, seg_end) else: # no chunk of usable length seg.set_unused(0)
def intersection(self, other): """ Replaces the ScienceSegments contained in this instance of ScienceData with the intersection of those in the instance other. Returns the number of segments in the intersection. @param other: ScienceData to use to generate the intersection """ # we only deal with the case of two lists ...
= start1 if stop1 > stop2: ostop = stop2 else: ostop = stop1 x = ScienceSegment(tuple([id, ostart, ostop, ostop-ostart])) outlist.append(x) if stop2 > stop1: break # step forward iseg2 += 1 if iseg2 < len(other): seg2 = other[iseg2] start2 = seg2.start() stop2 = seg2.end() else: # pseudo-segment in the far future start...
def union(self, other): """ Replaces the ScienceSegments contained in this instance of ScienceData with the union of those in the instance other. Returns the number of ScienceSegments in the union. @param other: ScienceData to use to generate the intersection """ # we only deal with the case of two lists here length1 =...
2 if start2 == -1: i2 += 1 if i2 < length2: start2 = other[i2].start() stop2 = other[i2].end() elif i1 == length1: break # pick the earlier segment from the two lists if start1 > -1 and ( start2 == -1 or start1 <= start2): ustart = start1 ustop = stop1 # mark this segment has having been consumed start1 = -1 elif start...
output segment ostop = ustop else: # This lies entirely within the current output segment pass else: # flush the current output segment, and replace it with the # new segment x = ScienceSegment(tuple([id,ostart,ostop,ostop-ostart])) seglist.append(x) ostart = ustart ostop = ustop # flush out the final output segment (i...
def coalesce(self): """ Coalesces any adjacent ScienceSegments. Returns the number of ScienceSegments in the coalesced list. """ # check for an empty list if len(self) == 0: return 0 # sort the list of science segments self.__sci_segs.sort() # coalesce the list, checking each segment for validity as we go outlist = [] ...
len(self)
def invert(self): """ Inverts the ScienceSegments in the class (i.e. set NOT). Returns the number of ScienceSegments after inversion. """ # check for an empty list if len(self) == 0: # return a segment representing all time self.__sci_segs = ScienceSegment(tuple([0,0,1999999999,1999999999])) # go through the list check...
def play(self): """ Keep only times in ScienceSegments which are in the playground """ length = len(self) # initialize list of output segments ostart = -1 outlist = [] begin_s2 = 729273613 play_space = 6370 play_len = 600 for seg in self: start = seg.start() stop = seg.end() id = seg.id() # select first playground segm...
self.__sci_segs = outlist return len(self)
def intersect_3(self, second, third): """ Intersection routine for three inputs. Built out of the intersect, coalesce and play routines """ self.intersection(second) self.intersection(third) self.coalesce() return len(self)
def intersect_4(self, second, third, fourth): """ Intersection routine for four inputs. """ self.intersection(second) self.intersection(third) self.intersection(fourth) self.coalesce() return len(self)
def split(self, dt): """ Split the segments in the list is subsegments at least as long as dt """ outlist=[] for seg in self: start = seg.start() stop = seg.end() id = seg.id() while start < stop: tmpstop = start + dt if tmpstop > stop: tmpstop = stop elif tmpstop + dt > stop: tmpstop = int( (start + stop)/2 ) x = Scie...
def group(self, lst, n): """ Group an iterable into an n-tuples iterable. Incomplete tuples are discarded """ return itertools.izip(*[itertools.islice(lst, i, None, n) for i in range(n)])
def parse(self,type_regex=None): """ Each line of the frame cache file is like the following: /frames/E13/LHO/frames/hoftMon_H1/H-H1_DMT_C00_L2-9246,H,H1_DMT_C00_L2,1,16 1240664820 6231 {924600000 924646720 924646784 924647472 924647712 924700000} The description is as follows: 1.1) Directory path of files 1.2) Site 1....
lists. """ path = self.__path cache = self.cache if type_regex: type_filter = re.compile(type_regex) else: type_filter = None f = open(path, 'r') # holds this iteration of the cache gwfDict = {} # parse each line in the cache file for line in f: # ignore lines that don't match the regex if type_filter and type_filter.s...
in times[1:-1].split(' ') ] # group the integers by two and turn those tuples into segments segments = [ pycbc_glue.segments.segment(a) for a in self.group(times, 2) ] # initialize if necessary for this site if not gwfDict.has_key(site): gwfDict[site] = {} # initialize if necessary for this frame type if not gwfDict[si...
def __set_output(self): """ Private method to set the file to write the cache to. Automaticaly set once the ifo, start and end times have been set. """ if self.__start and self.__end and self.__observatory and self.__type: self.__output = os.path.join(self.__job.get_cache_dir(), self.__observatory + '-' + self.__type +...
def set_start(self,time,pad = None): """ Set the start time of the datafind query. @param time: GPS start time of query. """ if pad: self.add_var_opt('gps-start-time', int(time)-int(pad)) else: self.add_var_opt('gps-start-time', int(time)) self.__start = time self.__set_output()
def set_end(self,time): """ Set the end time of the datafind query. @param time: GPS end time of query. """ self.add_var_opt('gps-end-time', time) self.__end = time self.__set_output()
def set_observatory(self,obs): """ Set the IFO to retrieve data for. Since the data from both Hanford interferometers is stored in the same frame file, this takes the first letter of the IFO (e.g. L or H) and passes it to the --observatory option of LSCdataFind. @param obs: IFO to obtain data for. """ self.add_var_opt(...
def set_type(self,type): """ sets the frame type that we are querying """ self.add_var_opt('type',str(type)) self.__type = str(type) self.__set_output()
def get_output(self): """ Return the output file, i.e. the file containing the frame cache data. or the files itself as tuple (for DAX) """ if self.__dax: # we are a dax running in grid mode so we need to resolve the # frame file metadata into LFNs so pegasus can query the RLS if self.__lfn_list is None: if self.job()....
= None try: proxy = os.environ['X509_USER_PROXY'] cert = proxy key = proxy except: try: cert = os.environ['X509_USER_CERT'] key = os.environ['X509_USER_KEY'] except: uid = os.getuid() proxy_path = "/tmp/x509up_u%d" % uid if os.access(path, os.R_OK): cert = proxy_path key = proxy_path h = httplib.HTTPSConnection(server,...
= os.path.split(path)[1] lfnDict[lfn] = 1 self.__lfn_list = lfnDict.keys() self.__lfn_list.sort() return self.__lfn_list else: return self.__output
def set_xml_output(self, xml_file): """ Tell ligolw_sqlite to dump the contents of the database to a file. """ if self.get_database() is None: raise ValueError, "no database specified" self.add_file_opt('extract', xml_file) self.__xml_output = xml_file
def get_output(self): """ Override standard get_output to return xml-file if xml-file is specified. Otherwise, will return database. """ if self.__xml_output: return self.__xml_output elif self.get_database(): return self.get_database() else: raise ValueError, "no output xml file or database specified"
def get_version(): """Reads version number. This workaround is required since __init__ is an entry point exposing stuff from other modules, which may use dependencies unavailable in current environment, which in turn will prevent this application from install. """ contents = read(os.path.join(PATH_BASE, 'srptools', '__...
def get_coinc_def_id(xmldoc, search, coinc_type, create_new = True, description = u""): """ Wrapper for the get_coinc_def_id() method of the CoincDefiner table class in pycbc_glue.ligolw.lsctables. This wrapper will optionally create a new coinc_definer table in the document if one does not already exist. """ try: coin...
def fromfilenames(filenames, coltype = int): """ Return a segmentlist describing the intervals spanned by the files whose names are given in the list filenames. The segmentlist is constructed by parsing the file names, and the boundaries of each segment are coerced to type coltype. The file names are parsed using a gen...
name in filenames: [(s, d)] = pattern.findall(name.strip().rstrip(".gz")) s = coltype(s) d = coltype(d) l.append(segments.segment(s, s + d)) return l
def fromlalcache(cachefile, coltype = int): """ Construct a segmentlist representing the times spanned by the files identified in the LAL cache contained in the file object file. The segmentlist will be created with segments whose boundaries are of type coltype, which should raise ValueError if it cannot convert its st...
def fromsegwizard(file, coltype = int, strict = True): """ Read a segmentlist from the file object file containing a segwizard compatible segment list. Parsing stops on the first line that cannot be parsed (which is consumed). The segmentlist will be created with segment whose boundaries are of type coltype, which shou...
input file are not coalesced or out of order, then thusly shall be the output of this function. It is recommended that this function's output be coalesced before use. """ commentpat = re.compile(r"\s*([#;].*)?\Z", re.DOTALL) twocolsegpat = re.compile(r"\A\s*([\d.+-eE]+)\s+([\d.+-eE]+)\s*\Z") threecolsegpat = re.compile...
is None: format = this_line_format elif format != this_line_format: raise ValueError("segment '%s' format mismatch" % line) l.append(seg) return l
def tosegwizard(file, seglist, header = True, coltype = int): """ Write the segmentlist seglist to the file object file in a segwizard compatible format. If header is True, then the output will begin with a comment line containing column names. The segment boundaries will be coerced to type coltype and then passed to s...
def fromtama(file, coltype = lal.LIGOTimeGPS): """ Read a segmentlist from the file object file containing TAMA locked-segments data. Parsing stops on the first line that cannot be parsed (which is consumed). The segmentlist will be created with segments whose boundaries are of type coltype, which should raise ValueErr...
in file: try: [tokens] = segmentpat.findall(line) l.append(segments.segment(map(coltype, tokens[0:2]))) except ValueError: break return l
def from_range_strings(ranges, boundtype = int): """ Parse a list of ranges expressed as strings in the form "value" or "first:last" into an equivalent pycbc_glue.segments.segmentlist. In the latter case, an empty string for "first" and(or) "last" indicates a (semi)infinite range. A typical use for this function is in ...
i, range in enumerate(ranges): parts = range.split(":") if len(parts) == 1: parts = boundtype(parts[0]) segs[i] = segments.segment(parts, parts) continue if len(parts) != 2: raise ValueError(range) if parts[0] == "": parts[0] = segments.NegInfinity else: parts[0] = boundtype(parts[0]) if parts[1] == "": parts[1] = segm...
def to_range_strings(seglist): """ Turn a segment list into a list of range strings as could be parsed by from_range_strings(). A typical use for this function is in machine-generating configuration files or command lines for other programs. Example: >>> from pycbc_glue.segments import * >>> segs = segmentlist([segment...
segments.PosInfinity): ranges[i] = "%s:%s" % (str(seg[0]), str(seg[1])) else: raise ValueError(seg) # success return ranges
def segmentlistdict_to_short_string(seglists): """ Return a string representation of a segmentlistdict object. Each segmentlist in the dictionary is encoded using to_range_strings() with "," used to delimit segments. The keys are converted to strings and paired with the string representations of their segmentlists usin...
pycbc_glue.ligolw library should be used. """ return "/".join(["%s=%s" % (str(key), ",".join(to_range_strings(value))) for key, value in seglists.items()])
def segmentlistdict_from_short_string(s, boundtype = int): """ Parse a string representation of a set of named segmentlists into a segmentlistdict object. The string encoding is that generated by segmentlistdict_to_short_string(). The optional boundtype argument will be passed to from_range_strings() when parsing the s...
= boundtype) return d
def from_bitstream(bitstream, start, dt, minlen = 1): """ Convert consecutive True values in a bit stream (boolean-castable iterable) to a stream of segments. Require minlen consecutive True samples to comprise a segment. Example: >>> list(from_bitstream((True, True, False, True, False), 0, 1)) [segment(0, 2), segment(...
def S2playground(extent): """ Return a segmentlist identifying the S2 playground times within the interval defined by the segment extent. Example: >>> from pycbc_glue import segments >>> S2playground(segments.segment(874000000, 874010000)) [segment(874000013, 874000613), segment(874006383, 874006983)] """ lo = int(exte...
def segmentlist_range(start, stop, period): """ Analogous to Python's range() builtin, this generator yields a sequence of continuous adjacent segments each of length "period" with the first starting at "start" and the last ending not after "stop". Note that the segments generated do not form a coalesced list (they are...