rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
Protract the segmentlists.
Run protract(x) on all segmentlists.
def protract(self, x): """ Protract the segmentlists. """ for key in self.iterkeys(): self[key].protract(x) return self
raise ValueError, "could not convert \"%s\" to CacheEntry" % string
raise ValueError, "could not convert \"%s\" to CacheEntry" % args[0]
def __init__(self, *args): if len(args) == 0: self.observatory = None self.description = None self.segment = segments.segment(None, None) self.url = None elif len(args) == 1: match = self._regex.search(args[0]) if not match: raise ValueError, "could not convert \"%s\" to CacheEntry" % string self.observatory = match.gr...
return segmentlist([seg.protract(x) for seg in self]).coalesce()
for i in xrange(len(self)): self[i] = self[i].protract(x) return self.coalesce()
def protract(self, x): """ For each segment in the list, move both the start and the end a distance x away from the other. Coalesce the result. """ return segmentlist([seg.protract(x) for seg in self]).coalesce()
return segmentlist([seg.contract(x) for seg in self]).coalesce()
for i in xrange(len(self)): self[i] = self[i].contract(x) return self.coalesce()
def contract(self, x): """ For each segment in the list, move both the start and the end a distance x towards the other. Coalesce the result. """ return segmentlist([seg.contract(x) for seg in self]).coalesce()
def peak(self):
def get_peak(self):
def peak(self): return lal.LIGOTimeGPS(self.peak_time, self.peak_time_ns)
pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp,dax)
CondorDAGJob.__init__(self,self.__universe,self.__executable) AnalysisJob.__init__(self,cp,dax)
def __init__(self,log_dir,cp,dax=False): """ cp = ConfigParser object from which options are read. """ self.__executable = cp.get('condor','ligolw_add') self.__universe = 'vanilla' pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp,dax)
pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp,dax)
CondorDAGJob.__init__(self,self.__universe,self.__executable) AnalysisJob.__init__(self,cp,dax)
def __init__(self,log_dir,cp,dax=False): """ cp = ConfigParser object from which options are read. """ self.__executable = cp.get('condor','ldbdc') self.__universe = 'scheduler' pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp,dax)
def index(self, val): """ Return the smallest index of the row(s) with this column equal to value.
def index(self, value): """ Return the smallest index of the row(s) with this column equal to value.
def index(self, val): """ Return the smallest index of the row(s) with this column equal to value. """ for i in xrange(len(self.parentNode)): if getattr(self.parentNode[i], self.asattribute) == value: return i raise ValueError, "%s not found" % repr(val)
def start_tag(self, indent): """ See the source code for an explanation. """ return indent + "<%s Name=\"%s\" Type=\"%s\"/>" % (self.tagName, self.getAttribute("Name"), self.getAttribute("Type"))
def asarray(self): """ Construct a numarray array from this column. """ if self.getAttribute("Type") in StringTypes: raise TypeError, "Column does not have numeric type" # hack to work around bug in numarray: numarray tests that # an object can be turned into an array, that is it is # "list like", by trying to retriev...
def start_tag(self, indent): """ See the source code for an explanation. """ return indent + "<%s Name=\"%s\" Type=\"%s\" Delimiter=\"%s\">" % (self.tagName, self.getAttribute("Name"), self.getAttribute("Type"), self.getAttribute("Delimiter"))
def write(self, file = sys.stdout, indent = ""): columninfo = [(c.getAttribute("Type") in StringTypes, StripColumnName(c.getAttribute("Name"))) for c in self.parentNode.getElementsByTagName(ligolw.Column.tagName)]
xml = template % (id_tag, executable, node_name, cmd_line)
xml = template % (id_tag, executable, node_name)
def write_dax(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dag_file_path: raise CondorDAGError, "No path for DAX file" try: dagfile = open( self.__dag_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
sql = "SELECT state_vec_major, state_vec_minor, segment_def_id "
sql = "SELECT ifos, state_vec_major, state_vec_minor, segment_def_id "
def __init__(self, dbname, dbuser = '', dbpasswd = '', debug = False): """ Open a connection to the state segment database.
self.state_vec[tuple([r[0],r[1]])] = r[2]
self.state_vec[r[0].strip()][tuple([r[1],r[2]])] = r[3]
def __init__(self, dbname, dbuser = '', dbpasswd = '', debug = False): """ Open a connection to the state segment database.
self.state_vec[(ver,val)] = self.cursor.fetchone()[0]
self.state_vec[ifo][(ver,val)] = self.cursor.fetchone()[0]
def publish_state(self, ifo, start_time, start_time_ns, end_time, end_time_ns, ver, val ): """ Publish a state segment for a state vector in the database """
def set_state_name(self,ver,val,name): try: sql = "INSERT INTO state_vec (version,value,state) VALUES (%s,%s,%s)" self.cursor.execute(sql,(ver,val,name)) except _mysql_exceptions.IntegrityError, e: sql = "UPDATE state_vec SET state = '%s'" % name sql += "WHERE version = %s AND value = %s" % (ver,val) self.cursor.execut...
def publish_state(self, ifo, start_time, start_time_ns, end_time, end_time_ns, ver, val ): """ Publish a state segment for a state vector in the database """
logger.debug("removing process table for key %s" % str(uniq_proc))
logger.debug("removing process row for key %s" % str(uniq_proc))
def insertdmt(self, arg): """ Insert LIGO_LW xml data from the DMT in the metadata database. For DMT inserts, we need to check for existing process_id and segment_definer_id rows and change the contents of the table to be inserted accordingly. We must also update the end_time of any existing entries in the process tabl...
for sec in ['datafind']: self.add_ini_opts(config_file,sec)
for o in self.__config_file.options('datafind'): opt = string.strip(o) if opt is not "type": arg = string.strip(self.__config_file.get('datafind',opt)) self.add_opt(opt,arg)
def __init__(self,cache_dir,log_dir,config_file,dax=0): """ @param cache_dir: the directory to write the output lal cache files to. @param log_dir: the directory to write the stderr file to. @param config_file: ConfigParser object containing the path to the LSCdataFind executable in the [condor] section and a [datafind...
self.__type = self.job().get_config_file().get('datafind','type')
self.set_type(self.job().get_config_file().get('datafind','type'))
def __init__(self,job): """ @param job: A CondorDAGJob that can run an instance of LALdataFind. """ CondorDAGNode.__init__(self,job) AnalysisNode.__init__(self) self.__start = 0 self.__end = 0 self.__observatory = None self.__output = None self.__job = job self.__dax = job.is_dax() self.__lfn_list = None # try and get...
input = f.read(512) if input == "": break
input = f.read(size = 512, waitForBytes = 512)
def __response__(self): """ Read the response sent back by the LDRdataFindServer. Parse out the return code with 0 for success and non-zero for error, and then the list of strings representing the returned result(s).
def showTypes(self, argDict):
def explainTypes(self, argDict):
def showTypes(self, argDict): """ Query LSCsegFindServer for the comment values for the 'state_vec.state' attribute in the metadata table.
start = long(framereg.search(x).group(3)) end = long(framereg.search(x).group(3)) + \ long(framereg.search(x).group(4))
start = long(self.framereg.search(lfn).group(3)) end = long(self.framereg.search(lfn).group(3)) + \ long(self.framereg.search(lfn).group(4))
def register_lfn(self,lfn,start=None,end=None): """ Start publishing state information for a new logical file name
self.__universe = 'local'
self.__universe = 'scheduler'
def __init__(self,cache_dir,log_dir,config_file,dax=0): """ @param cache_dir: the directory to write the output lal cache files to. @param log_dir: the directory to write the stderr file to. @param config_file: ConfigParser object containing the path to the LSCdataFind executable in the [condor] section and a [datafind...
def __init__(self, host, port=30000):
def __init__(self, host, port=30010):
def __init__(self, host, port=30000): """ Open a connection to a LDRdataFindServer and return an instance of class LDRdataFindClient. One of the public methods can then be called to send a request to the server.
if opt is not "type":
if opt[:4] != "type":
def __init__(self,cache_dir,log_dir,config_file,dax=0): """ @param cache_dir: the directory to write the output lal cache files to. @param log_dir: the directory to write the stderr file to. @param config_file: ConfigParser object containing the path to the LSCdataFind executable in the [condor] section and a [datafind...
"chisq_dof": "real_4", "sigmasq": "real_4",
"chisq_dof": "int_4s", "sigmasq": "real_8",
def set_band(self, band): self.central_freq = (band[0] + band[1])/2.0 self.bandwidth = band.duration()
def __getitem__(self, key): """ Return a sorted list of rows matching the process ID key. """ params = LSCTableMulti.__getitem__(self, key) params.sort(lambda a, b: cmp((a.process_id, a.param), (b.process_id, b.param))) return params
def set_program(self, key, value): """ Set the program for all entries with process ID key to value. """ for row in self: if row.process_id == key: row.program = value
logger.debug("Method insert called")
msg = "Method dmtinsert called. Known processes %s, " % str(dmt_proc_dict) msg += "known segment_definers %s" % str(dmt_seg_def_dict) logger.debug(msg)
def insertdmt(self, arg): """ Insert LIGO_LW xml data from the DMT in the metadata database. For DMT inserts, we need to check for existing process_id and segment_definer_id rows and change the contents of the table to be inserted accordingly. We must also update the end_time of any existing entries in the process tabl...
msg = "Error querying LDRdataFindServer for LFNs with metadata query %s : %s" % (sql, str(output[0]))
msg = "Error querying LDRdataFindServer for LFNs: %s" % (str(output[0],))
def lfnQueryWithMetadata(self, queryList): """ Query LDRdataFindServer to find the LFN(s) with the appropriate metadata values.
msg = "Error querying LDRdataFindServer for PFNs with metadata query %s : %s" % (sql, str(output[0]))
msg = "Error querying LDRdataFindServer for PFNs: %s" % (str(output[0],))
def pfnQueryWithMetadata(self, queryList): """ Query LDRdataFindServer to find the PFNs(s) for LFN(s) with the appropriate metadata values.
logger.error("Server not initialized for RLS connections") msg "This server is not initialized for RLS connections"
msg = "server is not initialized for RLS connections" logger.error(msg)
def insertmap(self, arg): """ Insert some LIGO_LW xml data in the metadata database with an LFN to PFN mapping inserted into the RLS database
self[key] = copy.copy(value)
self[key] = copy(value)
def __ior__(self, other): for key, value in other.iteritems(): if key in self: self[key] |= value else: self[key] = copy.copy(value) return self
for value in self.iteritems():
for value in self.itervalues():
def intersects_segment(self, seg): """ Returns True if any segmentlist in self intersects the segment, otherwise returns False. """ for value in self.iteritems(): if value.intersects(seg): return True return False
self.__bad_macro_chars = re.compile(r'-_]')
self.__bad_macro_chars = re.compile(r'[-_]')
def __init__(self, universe, executable): """ universe = the condor universe to run the job in. executable = the executable to run in the DAG. """ CondorJob.__init__(self, universe, executable, 1) self.__notifcation = 'never' self.__var_args = [] self.__bad_macro_chars = re.compile(r'-_]')
self.__bad_macro_chars = re.compile(r'-_]')
self.__bad_macro_chars = re.compile(r'[-_]')
def __init__(self, job): """ job = the CondorJob that this node corresponds to. """ if not isinstance(job, CondorDAGJob): raise CondorDAGNodeError, "A DAG node must correspond to a Condor DAG job" self.__name = None self.__job = job self.__vars = {} self.__retry = 0 self.__parents = [] self.__bad_macro_chars = re.compi...
distinctValueList = LDRdataFindClient.distinctAttrValues(self, "instrument")
distinctValueList = LDRdataFindClient.distinctAttrValues(self, "site")
def showObservatories(self, argDict): """ Query LDRdataFindServer for the distinct values for the 'instrument' attribute in the metadata table.
format = argDict['format']
def findStateSegments(self, argDict): """ Query the LDRdataFindServer for state segments from a particular interferometer, with a particular state type, for a particular range of GPS times.
def make_chunks(self,length=0,overlap=0,play=0):
def make_chunks(self,length=0,overlap=0,play=0,sl=0):
def make_chunks(self,length=0,overlap=0,play=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, this method should be overriden...
and ( s2play(start) or s2play(middle) or s2play(end) ) ):
and ( s2play(start-sl) or s2play(middle-sl) or s2play(end-sl) ) ):
def make_chunks(self,length=0,overlap=0,play=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, this method should be overriden...
def set_start(self,gps): """ Re-set the GPS start time of this ScienceSegment to gps. gps = new GPS start time of segment. """ self.__segment[1] = gps
def set_start(self,gps): """ Re-set the GPS start time of this ScienceSegment to gps. gps = new GPS start time of segment. """ self.__segment[1] = gps
def set_end(self,gps): """ Re-set the GPS end time of this ScienceSegment to gps. gps = new GPS end time of segment. """ self.__segment[2] = gps
def end(self): """ Returns the GPS end time of this ScienceSegment. """ return self.__segment[2]
def read(self,file,min_length):
def read(self,file,min_length,slide_sec = 0):
def read(self,file,min_length): """ Parse the science segments from the segwizard output contained in file. file = input text file containing a list of science segments generated by segwizard. min_length = only append science segments that are longer than min_length. """ self.__file = file octothorpe = re.compile(r'\A#...
x = ScienceSegment(tuple(map(int,line.split())))
(id,st,en,du) = map(int,line.split()) if slide_sec > 0: st += slide_sec elif slide_sec < 0: en += slide_sec du -= abs(slide_sec) x = ScienceSegment(tuple([id,st,en,du]))
def read(self,file,min_length): """ Parse the science segments from the segwizard output contained in file. file = input text file containing a list of science segments generated by segwizard. min_length = only append science segments that are longer than min_length. """ self.__file = file octothorpe = re.compile(r'\A#...
def slide(self,delta): """ Slide each ScienceSegment by: delta > 0: [s,e] -> [s+delta,e]. delta < 0: [s,e] -> [s,e-delta]. delta = seconds to slide each science segment by. """ for seg in self.__sci_segs: if delta > 0: seg.set_start(seg.start() + delta) elif delta < 0: seg.set_end(seg.end() - delta) def make_chunks(se...
def make_chunks(self,length,overlap,play,sl=0):
def slide(self,delta): """ Slide each ScienceSegment by: delta > 0: [s,e] -> [s+delta,e]. delta < 0: [s,e] -> [s,e-delta]. delta = seconds to slide each science segment by. """ for seg in self.__sci_segs: if delta > 0: seg.set_start(seg.start() + delta) elif delta < 0: seg.set_end(seg.end() - delta)
seg.make_chunks(length,overlap,play) def make_chunks_from_unused(self,length,trig_overlap,play,min_length):
seg.make_chunks(length,overlap,play,sl) def make_chunks_from_unused(self,length,trig_overlap,play,min_length,sl=0):
def make_chunks(self,length,overlap,play): """ Divide each ScienceSegment contained in this object into AnalysisChunks. length = length of chunk in seconds. overlap = overlap between segments. play = if true, only generate chunks that overlap with S2 playground data. """ for seg in self.__sci_segs: seg.make_chunks(leng...
logger.debug("removing known process row for key %s" % str(uniq_proc))
def insertdmt(self, arg): """ Insert LIGO_LW xml data from the DMT in the metadata database. For DMT inserts, we need to check for existing process_id and segment_definer_id rows and change the contents of the table to be inserted accordingly. We must also update the end_time of any existing entries in the process tabl...
logger.debug("removing process row for key %s" % str(uniq_proc))
def insertdmt(self, arg): """ Insert LIGO_LW xml data from the DMT in the metadata database. For DMT inserts, we need to check for existing process_id and segment_definer_id rows and change the contents of the table to be inserted accordingly. We must also update the end_time of any existing entries in the process tabl...
logger.debug("removing known segment_definer row for key %s"
ligomd.table['segment_definer']['stream'].pop(row_idx) logger.debug("removed known segment_definer row for key %s"
uniq_def = (row[run_col],row[ifos_col],row[name_col],row[vers_col])
ligomd.table['segment_definer']['stream'].pop(row_idx)
uniq_def = (row[run_col],row[ifos_col],row[name_col],row[vers_col])
logger.debug("removing segment_definer row for key %s"
ligomd.table['segment_definer']['stream'].pop(row_idx) logger.debug("removed segment_definer row for key %s"
uniq_def = (row[run_col],row[ifos_col],row[name_col],row[vers_col])
self.__bad_macro_chars = re.compile(r'[-_]')
self.__bad_macro_chars = re.compile(r'[-]')
def __init__(self, universe, executable): """ universe = the condor universe to run the job in. executable = the executable to run in the DAG. """ CondorJob.__init__(self, universe, executable, 1) CondorJob.set_notification(self, 'never') self.__var_args = [] self.__bad_macro_chars = re.compile(r'[-_]')
self.add_arg(arg,'$(' + macro + ')')
self.add_arg(arg,'$(macro_' + macro + ')')
def add_var_arg(self, arg): """ Add a variable (or macro) option to the condor job. The option is added to the submit file and a different argument to the option can be set fot each node in the DAG. arg = name of option to add. """ if arg not in self.__var_args: self.__var_args.append(arg) macro = self.__bad_macro_char...
self.__bad_macro_chars = re.compile(r'[-_]')
self.__bad_macro_chars = re.compile(r'[-]')
def __init__(self, job): """ job = the CondorJob that this node corresponds to. """ if not isinstance(job, CondorDAGJob): raise CondorDAGNodeError, "A DAG node must correspond to a Condor DAG job" self.__name = None self.__job = job self.__vars = {} self.__retry = 0 self.__parents = [] self.__bad_macro_chars = re.compi...
self.__vars[macro] = value
self.__vars['macro_' + macro] = value
def add_var(self,var,value): """ Add the a variable (macro) arguments for this node. If the option specified does not exist in the CondorJob, it is added so the submit file will be correct when written. var = option name. value = value of the option for this node in the DAG. """ macro = self.__bad_macro_chars.sub( r'',...
return self.slide_id def _set_key(self, key): self.slide_id = key def _has_key(self, key): return self.slide_id == key
return self.time_slide_id def _set_key(self, key): self.time_slide_id = key def _has_key(self, key): return self.time_slide_id == key
def _get_key(self): return self.slide_id
overlap seconds using the INCORRECT playground algorithm that may miss chunks. 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, this method should be overriden in a sub-class. Any data at the end of the ScienceSegment tha...
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, this method should be overriden in a sub-class. Any data at the end of the ScienceSegment that is too short to contain a chunk is ignored. The length of thi...
def make_chunks_bad_play(self,length=0,overlap=0,play=0,sl=0): """ Divides the science segment into chunks of length seconds overlapped by overlap seconds using the INCORRECT playground algorithm that may miss chunks. If the play option is set, only chunks that contain S2 playground data are generated. If the user has ...
if (not play) or (play and ((end-sl-729273613) % 6370 < length + 600)):
if (not play) or (play and (((end-sl-729273613) % 6370) < (600+length))):
def make_chunks(self,length=0,overlap=0,play=0,sl=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, this method should be over...
Divide each ScienceSegment contained in this object into AnalysisChunks using the INCORRECT playground algorithm which may miss some chunks. length = length of chunk in seconds. overlap = overlap between segments. play = if true, only generate chunks that overlap with S2 playground data. sl = slide by sl seconds before...
def make_chunks_bad_play(self,length,overlap,play,sl=0): """ Divide each ScienceSegment contained in this object into AnalysisChunks using the INCORRECT playground algorithm which may miss some chunks. length = length of chunk in seconds. overlap = overlap between segments. play = if true, only generate chunks that ove...
for seg in self.__sci_segs: if seg.unused() > min_length: start = seg.end() - length end = seg.end() middle = start + length / 2 pstart = end - seg.unused() - trig_overlap pmiddle = pstart + (end - pstart) / 2 if (not play) or ( play and ( s2play(pstart-sl) or s2play(pmiddle-sl) or s2play(end-sl) ) ): seg.add_chunk(st...
def make_chunks_from_unused_bad_play( self,length,trig_overlap,play,min_length,sl=0): """ Create an extra chunk that uses up the unused data in the science segment using the INCORRECT playground algorithm which may miss some chunks. length = length of chunk in seconds. trig_overlap = length of time start generating tri...
return lal.LIGOTimeGPS(self.start_time, self.start_time_ns)
try: return lal.LIGOTimeGPS(self.start_time, self.start_time_ns) except AttributeError: return lal.LIGOTimeGPS(self.stop_time, self.stop_time_ns) - self.duration
def get_start(self): return lal.LIGOTimeGPS(self.start_time, self.start_time_ns)
return lal.LIGOTimeGPS(self.stop_time, self.stop_time_ns)
try: return lal.LIGOTimeGPS(self.stop_time, self.stop_time_ns) except AttributeError: return lal.LIGOTimeGPS(self.start_time, self.start_time_ns) + self.duration
def get_stop(self): return lal.LIGOTimeGPS(self.stop_time, self.stop_time_ns)
input = f.read(512) if input == "": break
input = f.read(size = 512, waitForBytes = 512)
def __response__(self): """ Read the response sent back by the LSCsegFindServer. Parse out the return code with 0 for success and non-zero for error, and then the list of strings representing the returned result(s).
if len(input) < 512: break
def __response__(self): """ Read the response sent back by the LSCsegFindServer. Parse out the return code with 0 for success and non-zero for error, and then the list of strings representing the returned result(s).
attrs = sax.xmlreader.AttributesImpl({u"Name": Type.tableName}) table = Type(attrs) for name, type in table.validcolumns.items(): table.appendChild(metaio.Column(sax.xmlreader.AttributesImpl({u"Name": ":".join(Type.tableName.split(":")[:-1]) + ":" + name, u"Type": type}))) table.appendChild(metaio.Stream(attrs))
table = Type(sax.xmlreader.AttributesImpl({u"Name": Type.tableName})) for key, value in table.validcolumns.items(): table.appendChild(metaio.Column(sax.xmlreader.AttributesImpl({u"Name": ":".join(Type.tableName.split(":")[:-1]) + ":" + key, u"Type": value}))) table.appendChild(metaio.Stream(sax.xmlreader.AttributesImpl...
def New(Type): """ Convenience function for constructing pre-defined LSC tables. Example: import lsctables table = lsctables.New(lsctables.ProcessTable) """ attrs = sax.xmlreader.AttributesImpl({u"Name": Type.tableName}) table = Type(attrs) for name, type in table.validcolumns.items(): table.appendChild(metaio.Column...
def start(self):
def s(self):
def start(self): return self.start
def end(end):
def e(end):
def end(end): return self.end
cal_path = string.strip(self.__cp.get('calibration','path'))
cal_path = self.job().get_config('calibration','path')
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. """ cal_path = string.strip(self.__cp.get('calibration','path'))
cal_file = string.strip(self.__cp.get('calibration','H2-1'))
cal_file = self.job().get_config('calibration','H2-1')
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. """ cal_path = string.strip(self.__cp.get('calibration','path'))
cal_file = string.strip(self.__cp.get('calibration','H2-2'))
cal_file = self.job().get_config('calibration','H2-2')
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. """ cal_path = string.strip(self.__cp.get('calibration','path'))
cal_file = string.strip(self.__cp.get('calibration',self.__ifo))
cal_file = self.job().get_config('calibration',self.__ifo)
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. """ cal_path = string.strip(self.__cp.get('calibration','path'))
def initserver(configuration,log):
def initialize(configuration,log):
def initserver(configuration,log): # define the global variables used by the server global logger, max_bytes, xmlparser, dbobj, xmlparser, lwtparser, rls # initialize the logger logger = log log.info("Initializing server module %s" % __name__ ) # initialize the database hash table dbobj = ldbd.LIGOMetadataDatabase(co...
log.info("Initializing server module %s" % __name__ )
logger.info("Initializing server module %s" % __name__ )
def initserver(configuration,log): # define the global variables used by the server global logger, max_bytes, xmlparser, dbobj, xmlparser, lwtparser, rls # initialize the logger logger = log log.info("Initializing server module %s" % __name__ ) # initialize the database hash table dbobj = ldbd.LIGOMetadataDatabase(co...
def shutdownserver():
def shutdown():
def shutdownserver(): global logger, max_bytes, xmlparser, dbobj, xmlparser, lwtparser, rls log.info("Shutting down server module %s" % __name__ ) del rls del lwtparser del xmlparser del dbobj
log.info("Shutting down server module %s" % __name__ )
logger.info("Shutting down server module %s" % __name__ )
def shutdownserver(): global logger, max_bytes, xmlparser, dbobj, xmlparser, lwtparser, rls log.info("Shutting down server module %s" % __name__ ) del rls del lwtparser del xmlparser del dbobj
arg = command line option to add.
opt = command line option to add.
def add_opt(self, opt, value): """ Add a command line option to the executable. The order that the arguments will be appended to the command line is not guaranteed, but they will always be added before any command line arguments. The name of the option is prefixed with double hyphen and the program is expected to parse...
if self.__options.keys() or self.arguments:
if self.__options.keys() or self.__short_options.keys() or self.arguments:
def write_sub_file(self): """ Write a submit file for this Condor job. """ if not self.__log_file: raise CondorSubmitError, "Log file not specified." if not self.__err_file: raise CondorSubmitError, "Error file not specified." if not self.__out_file: raise CondorSubmitError, "Output file not specified." if not self.__...
def add_macro(self,name,value): """ Add a variable (macro) for this node. This can be different for each node in the DAG, even if they use the same CondorJob. Within the CondorJob, the value of the macro can be referenced as '$(name)' -- for instance, to define a unique output or error file for each node. name = macr...
def set_name(self): """ Generate a unique name for this node in the DAG. """ t = str( long( time.time() * 1000 ) ) r = str( long( random.random() * 100000000000000000L ) ) a = str( self.__class__ ) self.__name = md5.md5(t + r + a).hexdigest()
Add the a variable (macro) options for this node. If the option
Add a variable (macro) option for this node. If the option
def add_var_opt(self,opt,value): """ Add the a variable (macro) options for this node. If the option specified does not exist in the CondorJob, it is added so the submit file will be correct when written. opt = option name. value = value of the option for this node in the DAG. """ macro = self.__bad_macro_chars.sub( r'...
if self.__opts.keys() or self.__vars:
if self.__macros.keys() or self.__opts.keys() or self.__args:
def write_vars(self,fh): """ Write the variable (macro) options and arguments to the DAG file descriptor. fh = descriptor of open DAG file. """ if self.__opts.keys() or self.__vars: fh.write( 'VARS ' + self.__name ) for k in self.__opts.keys(): fh.write( ' ' + str(k) + '="' + str(self.__opts[k]) + '"' ) if self.__args:...
if not self.__log_file_path:
if not self.__dag_file_path:
def write_dag(self): """ Write all the nodes in the DAG to the DAG file. """ if not self.__log_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_job(dagfil...
An AnalysisCunk is the unit of data that a node works with, usually some
An AnalysisChunk is the unit of data that a node works with, usually some
def set_cache(self,file): """ Set the LAL frame cache to to use. The frame cache is passed to the job with the --frame-cache argument. file = calibration file to use. """ self.add_var_opt('frame-cache', file)
def __init__(self, start, end, trig_start):
def __init__(self, start, end, trig_start = 0, trig_end = 0):
def __init__(self, start, end, trig_start): """ start = GPS start time of the chunk. end = GPS end time of the chunk. trig_start = GPS time at which to start generating triggers """ self.__start = start self.__end = end self.__length = end - start self.__trig_start = trig_start
return '<AnalysisChunk: start %d, end %d, trig_start %d>' % ( self.__start, self.__end, self.__trig_start)
if self.__trig_start and self.__trig_end: return '<AnalysisChunk: start %d, end %d, trig_start %d, trig_end %d>' % ( self.__start, self.__end, self.__trig_start, self.__trig_end) elif self.__trig_start and not self.__trig_end: return '<AnalysisChunk: start %d, end %d, trig_start %d>' % ( self.__start, self.__end, self....
def __repr__(self): return '<AnalysisChunk: start %d, end %d, trig_start %d>' % ( self.__start, self.__end, self.__trig_start)
if self.trig_start > 0: print "self.__end - self.__trig_start = ", self.__end - self.__trig_start
if self.__trig_start and self.__trig_end: return self.__trig_end - self.__trig_start elif self.__trig_start and not self.__trig_end:
def __len__(self): """ Returns the length of data for which this AnalysisChunk will produce triggers (in seconds). """ if self.trig_start > 0: print "self.__end - self.__trig_start = ", self.__end - self.__trig_start return self.__end - self.__trig_start else: print "self.__length = ", self.__length return self.__lengt...
print "self.__length = ", self.__length return self.__length
return self.__end - self.__start
def __len__(self): """ Returns the length of data for which this AnalysisChunk will produce triggers (in seconds). """ if self.trig_start > 0: print "self.__end - self.__trig_start = ", self.__end - self.__trig_start return self.__end - self.__trig_start else: print "self.__length = ", self.__length return self.__lengt...
self.__chunks.append(AnalysisChunk(start,end,0))
self.__chunks.append(AnalysisChunk(start,end))
def make_chunks(self,length=0,overlap=0,play=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, this method should be overriden...
macro = self.__bad_macro_chars( r'', arg )
macro = self.__bad_macro_chars( r'', var )
def add_var(self,var,value): """ Add the a variable (macro) arguments for this node. If the option specified does not exist in the CondorJob, it is added so the submit file will be correct when written. var = option name. value = value of the option for this node in the DAG. """ macro = self.__bad_macro_chars( r'', arg...
def set_notifcation(self, value):
def set_notification(self, value):
def set_notifcation(self, value): """ Set the email address to send notification to. value = email address or never for no notification. """ self.__notification = value
self.set_notification('never')
CondorJob.set_notification(self, 'never')
def __init__(self, universe, executable): """ universe = the condor universe to run the job in. executable = the executable to run in the DAG. """ CondorJob.__init__(self, universe, executable, 1) self.set_notification('never') self.__var_args = [] self.__bad_macro_chars = re.compile(r'[-_]')
ifoTrigs = metaio.new_from_template(self)
ifoTrigs = table.new_from_template(self)
def ifocut(self,ifo): ifoTrigs = metaio.new_from_template(self) for row in self.rows: if row.ifo == ifo: ifoTrigs.append(row) return ifoTrigs
vetoed = metaio.new_from_template(self) keep = metaio.new_from_template(self)
vetoed = table.new_from_template(self) keep = table.new_from_template(self)
def veto(self,seglist): vetoed = metaio.new_from_template(self) keep = metaio.new_from_template(self) for row in self.rows: time = row.get_end() if time in seglist: vetoed.append(event) else: keep.append(event)
slideTrigs = metaio.new_from_template(self)
slideTrigs = table.new_from_template(self)
def getslide(self,slide_num): """ Return the triggers with a specific slide number. @param slide_num: the slide number to recover (contained in the event_id) """ slideTrigs = metaio.new_from_template(self) for row in self.rows: if ( (row.event_id % 1000000000) / 100000 ) == slide_num: slideTrigs.append(row) return sli...
def veto(self,seglist,site): vetoed = metaio.new_from_template(self) keep = metaio.new_from_template(self) for row in self.rows: time = row.get_end(site) if time in seglist: vetoed.append(event) else: keep.append(event) return keep class SimInspiral(LSCTableRow): __slots__ = SimInspiralTable.validcolumns.keys() def ...
def get_end(self,site = None): if not site: return lal.LIGOTimeGPS(self.geocent_end_time, self.geocent_end_time_ns) else: return lal.LIGOTimeGPS(getattr(self,site + 'end_time'), getattr(self,site + 'end_time_ns'))
if row.param in [r.param for r in self]:
if (row.process_id, row.param) in [(r.process_id, r.param) for r in self]:
def appendRow(self, row): if row.param in [r.param for r in self]: raise ligolw.ElementError, "duplicate parameter %s for process ID %s" % (row.param, row.process_id) if row.type not in metaio.Types: raise ligolw.ElementError, "unrecognized Type attribute %s" % row.type metaio.Table.appendRow(self, row)
saveFiles=False, cfgFile=None, localSegFile=None, coalesce=False, showTypes=False):
saveFiles=False, cfgFile=None, localSegFile=None, coalesce=False, showTypes=False, curlPath="/usr/bin/curl"):
def __init__(self, server=None, startTime=None, endTime=None, segType=None,\
self.curlPath = self.__get_STR('curlPath',curlPath)
def __init__(self, server=None, startTime=None, endTime=None, segType=None,\
self.port = self.__get_PLONG('minLength',portString)
self.port = self.__get_PLONG('portString',portString)
def __init__(self, server=None, startTime=None, endTime=None, segType=None,\
curlExit = os.system('/usr/bin/curl --fail --connect-timeout 100 %s 1> %s 2>/dev/null' % (urlString, localFileName))
curlExit = os.system('%s --fail --connect-timeout 100 %s 1> %s 2>/dev/null' % (self.curlPath, urlString, localFileName))
def __getWebPage(self,urlString,localFileName): """ returns a url to a local file. """ try: for i in range (0,2): curlExit = os.system('/usr/bin/curl --fail --connect-timeout 100 %s 1> %s 2>/dev/null' % (urlString, localFileName)) if long(curlExit) == 0L: curlFailed = False break if curlFailed: msg = "Error retrieving ...
msg = "Could not retrieve web page '%s', make sure /usr/bin/curl and web page exist." % urlString
msg = "Could not retrieve the web page: '%s'. The path to the curl utility used was '%s'. Make sure the web page exist and the path to curl is correct." % (urlString, self.curlPath)
def __getWebPage(self,urlString,localFileName): """ returns a url to a local file. """ try: for i in range (0,2): curlExit = os.system('/usr/bin/curl --fail --connect-timeout 100 %s 1> %s 2>/dev/null' % (urlString, localFileName)) if long(curlExit) == 0L: curlFailed = False break if curlFailed: msg = "Error retrieving ...
return sqrt(sx**2 + sy**2 + sz**2)
return (sx**2 + sy**2 + sz**2)**(0.5)
def get_spin_mag(self,objectnumber): sx = self.get_column('spin' + str(objectnumber) + 'x') sy = self.get_column('spin' + str(objectnumber) + 'y') sz = self.get_column('spin' + str(objectnumber) + 'z') return sqrt(sx**2 + sy**2 + sz**2)
if type(x) is types.stringType:
if isinstance(x, types.StringTypes):
def distinctAttribute(self, arg): """ Find distinct values for an attribute. Corresponds to the DISTINCT method in the LSCsegFindServer RPC protocol.