rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.vars = self.vars_stack[-1]
self.vars.update(self.vars_stack[-1])
def pop_vars (self): """ Restore the last set of variables saved using "push_vars". """ self.vars = self.vars_stack[-1] del self.vars_stack[-1]
if not self.expand_needed(): return 0
def run (self): if not self.expand_needed(): return 0 self.msg(0, _("writing %s...") % (self.out)) self.out_stream = open(self.out, "w") try: self.expand_path(self.env.source()) except rubber.EndDocument: self.out_stream.write("\\end{document}\n") self.out_stream.close() self.env.something_done = 1
try: self.expand_path(self.env.source()) except rubber.EndDocument: self.out_stream.write("\\end{document}\n") self.out_stream.close() self.env.something_done = 1 def expand_needed (self): """ Check if running epxanding the source is needed. """ final = self.env.src_base + "-final.tex" if not exists(final): self.msg(3...
def run (self): if not self.expand_needed(): return 0 self.msg(0, _("writing %s...") % (self.out)) self.out_stream = open(self.out, "w") try: self.expand_path(self.env.source()) except rubber.EndDocument: self.out_stream.write("\\end{document}\n") self.out_stream.close() self.env.something_done = 1
self.env.do_process(file, path, dump=self.out_stream)
try: self.expand_path(self.env.source()) except rubber.EndDocument: self.out_stream.write("\\end{document}\n")
def expand_path (self, path): # self.out_stream.write("%%--- beginning of file %s\n" % path) file = open(path)
return 0
continue
def main (self, cmdline): """ Run Rubber for the specified command line. This processes each specified source in order (for making or cleaning). If an error happens while making one of the documents, the whole process stops. The method returns the program's exit code. """ self.prologue = [] self.epilogue = [] self.clea...
self.conf = Config()
def __init__ (self, message): """ Initialize the environment. This prepares the processing steps for the given file (all steps are initialized empty) and sets the regular expressions and the hook dictionary. """ self.msg = message self.msg(2, _("initializing Rubber..."))
self.msg(1, _("initializing..."))
self.msg(1, _("reinitializing..."))
def restart (self): """ Reinitialize the environment, in order to process a new document. This resets the process and the hook dictionary and unloads modules. """ self.msg(1, _("initializing...")) self.modules.clear() self.initialize()
self.modules.register("bibtex", dict) for db in dict["arg"].split(","): self.modules["bibtex"].add_db(db)
if dict["arg"]: self.modules.register("bibtex", dict) for db in dict["arg"].split(","): self.modules["bibtex"].add_db(db)
def h_bibliography (self, dict): """ Called when the macro \\bibliography is found. This method actually registers the module bibtex (if not already done) and registers the databases. """ self.modules.register("bibtex", dict) for db in dict["arg"].split(","): self.modules["bibtex"].add_db(db)
self.modules.register("bibtex", dict) self.modules["bibtex"].set_style(dict["arg"])
if dict["arg"]: self.modules.register("bibtex", dict) self.modules["bibtex"].set_style(dict["arg"])
def h_bibliographystyle (self, dict): """ Called when \\bibliographystyle is found. This registers the module bibtex (if not already done) and calls the method set_style() of the module. """ self.modules.register("bibtex", dict) self.modules["bibtex"].set_style(dict["arg"])
if self.src_path != "":
if self.src_path == "": self.src_path = "." else:
def set_source (self, path): """ Specify the main source for the document. The exact path and file name are determined, and the source building process is updated if needed, according the the source file's extension. """ name = self.conf.find_input(path) if not name: self.msg(0, _("cannot find %s") % path) return 1 sel...
saved = {}
saved = self.vars.copy()
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = {} for (key, val) in dict.items(): saved[key] = self.vars[key] self.vars[key] = val self.vars_stack.append(saved)
saved[key] = self.vars[key]
def push_vars (self, **dict): """ For each named argument "key=val", save the value of variable "key" and assign it the value "val". """ saved = {} for (key, val) in dict.items(): saved[key] = self.vars[key] self.vars[key] = val self.vars_stack.append(saved)
self.vars.update(self.vars_stack[-1])
self.vars = self.vars_stack[-1]
def pop_vars (self): """ Restore the last set of variables saved using "push_vars". """ self.vars.update(self.vars_stack[-1]) del self.vars_stack[-1]
self.cwd = join(curdir, "")
self.cwd = "./"
def __init__ (self, level=1, write=None): """ Initialize the object with the specified verbosity level and an optional writing function. If no such function is specified, no message will be output until the 'write' field is changed. """ self.level = level self.write = write self.short = 0 self.path = "" self.cwd = join...
rule = dict(cp.items(name))
rule = {} for key in cp.options(name): rule[key] = cp.get(name, key)
def read_ini (self, filename): """ Read a set of rules from a file. See the texinfo documentation for the expected format of this file. """ from ConfigParser import ConfigParser cp = ConfigParser() cp.read(filename) for name in cp.sections(): rule = dict(cp.items(name)) rule["cost"] = cost = cp.getint(name, "cost") exp...
that no compilatin was done (by the script) yet.
that no compilation was done (by the script) yet.
def compile_needed (self): """ Returns true if a first compilation is needed. This method supposes that no compilatin was done (by the script) yet. """ if self.must_compile: return 1 self.msg(3, _("checking if compiling is necessary...")) if not exists(self.src_base + self.out_ext): self.msg(3, _("the output file doesn...
return string.find(line, "warning:") != -1
if string.find(line, "warning:") == -1: return 1
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": # We check for the substring "warning:" because pdfTeX # sometimes issues warnings (like undefined references) in the # form of errors...
values += self.canonicalize(arg)
values += canonicalize(arg)
def canonicalize(args): """ BootAuth canonicalization method. Parameter values are collected, sorted, converted to strings, then hashed with the node key. """
values += self.canonicalize(arg.values())
values += canonicalize(arg.values())
def canonicalize(args): """ BootAuth canonicalization method. Parameter values are collected, sorted, converted to strings, then hashed with the node key. """
if old_rec != None and rec['timestamp'] > old_rec['timestamp']:
if old_rec == None: self[name] = rec elif rec['timestamp'] > old_rec['timestamp']:
def deliver_record(self, rec): """A record is simply a dictionary with 'name' and 'timestamp' keys. We keep some persistent private data in the records under keys that start with '_'; thus record updates should not displace such keys.""" name = rec['name'] old_rec = self.get(name) if old_rec != None and rec['timestamp...
elif rec['timestamp'] >= self._min_timestamp: self[name] = rec
def deliver_record(self, rec): """A record is simply a dictionary with 'name' and 'timestamp' keys. We keep some persistent private data in the records under keys that start with '_'; thus record updates should not displace such keys.""" name = rec['name'] old_rec = self.get(name) if old_rec != None and rec['timestamp...
if self.system(cf_rec['postinstall_cmd']): system(err_cmd)
if self.system(cf_rec['postinstall_cmd']): self.system(err_cmd)
def update_conf_file(self, cf_rec): if not cf_rec['enabled']: return dest = cf_rec['dest'] logger.log('conf_files: considering file %s' % dest) err_cmd = cf_rec['error_cmd'] mode = string.atoi(cf_rec['file_permissions'], base=8) uid = pwd.getpwnam(cf_rec['file_owner'])[2] gid = grp.getgrnam(cf_rec['file_group'])[2] url...
function = function.replace('.', '/')
function = function.split('.')
def processInputs(self): 'See IPublisherRequest'
self.setPathSuffix((function,))
self.setPathSuffix(function)
def processInputs(self): 'See IPublisherRequest'
except Exception, e: self.handleException(e)
except: self.handleException(sys.exc_info())
def setBody(self, body): """Sets the body of the response
import traceback traceback.print_tb(exc_info[2]) print t print value
def handleException(self, exc_info): """Handle Errors during publsihing and wrap it in XML-RPC XML""" t, value = exc_info[:2]
if self._charset is not None and isinstance(text, unicode): return text.encode(self._charset)
if isinstance(text, unicode): return text.encode(self._charset or 'UTF-8')
def _encode(self, text): if self._charset is not None and isinstance(text, unicode): return text.encode(self._charset) return text
self._args, function = xmlrpclib.loads(self._body_instream.read())
lines = ''.join(self._body_instream.readlines()) self._args, function = xmlrpclib.loads(lines)
def processInputs(self): 'See IPublisherRequest'
publication = Attribute("""the request's publication object
publication = Attribute("""The request's publication object
def retry(): """Return a retry request
body = Attribute("""the body of the request as a string""") bodyFile = Attribute("""the body of the request as a file""")
body = Attribute("""The body of the request as a string""") bodyFile = Attribute("""The body of the request as a file""")
def processInputs(): """Do any input processing that needs to bve done before traversing
The only request data are envirnment variables.
The only request data are environment variables.
def __getitem__(key): """Return request data
data = self.stream.readline(size)
data = self.stream.readline()
def readline(self, size=None): data = self.stream.readline(size) self.cacheStream.write(data) return data
self.test_IApplicationRequest_bodyStream
self.test_IApplicationRequest_body
def testHaveCustomTestsForIApplicationRequest(self): # Make sure that tests are defined for things we can't test here self.test_IApplicationRequest_bodyStream
auth=self._auth if auth: if auth.lower().startswith('basic '): if base64 is None: import base64
if self._auth: if self._auth.lower().startswith('basic '): if base64 is None: import base64
def _authUserPW(self): 'See IHTTPCredentials' global base64 auth=self._auth if auth: if auth.lower().startswith('basic '): if base64 is None: import base64 name, password = base64.decodestring( auth.split()[-1]).split(':') return name, password
auth.split()[-1]).split(':')
self._auth.split()[-1]).split(':')
def _authUserPW(self): 'See IHTTPCredentials' global base64 auth=self._auth if auth: if auth.lower().startswith('basic '): if base64 is None: import base64 name, password = base64.decodestring( auth.split()[-1]).split(':') return name, password
def _updateContentLength(self): blen = str(len(self._body))
def _updateContentLength(self, data=None): if data is None: blen = str(len(self._body)) else: blen = str(len(data))
def _updateContentLength(self): blen = str(len(self._body)) if blen.endswith('L'): blen = blen[:-1] self.setHeader('content-length', blen)
cookies on the response object.
cookies on the response object and encode the string into appropriate encoding.
def write(self, string): """See IApplicationResponse
if self.getHeader('content-type', '').startswith('text'): data = self._encode(data) self._updateContentLength(data)
def output(self, data): """Output the data to the world. There are a couple of steps we have to do:
if self.getHeader('content-type', '').startswith('text'): data = self._encode(data)
def output(self, data): """Output the data to the world. There are a couple of steps we have to do:
self.pres = Presentation()
self.pres = Presentation(ContentStub(), TestRequest())
def setUp(self): self.pres = Presentation()
self.filename = aFieldStorage.filename
self.filename = unicode(aFieldStorage.filename, 'UTF-8')
def __init__(self, aFieldStorage):
"XMLRPC View"
def getDefaultTraversal(request, ob): """Get the default published object for the request
(item.filename is not None
(item.filename is not None and item.filename != ''
def processInputs(self): 'See IPublisherRequest'
eq(locale.getLocaleLanguageId(), lang) eq(locale.getLocaleCountryId(), country) eq(locale.getLocaleVariantId(), variant)
eq(locale.id.language, lang) eq(locale.id.country, country) eq(locale.id.variant, variant)
def testRequestLocale(self): eq = self.assertEqual unless = self.failUnless for httplang in ('it', 'it-ch', 'it-CH', 'IT', 'IT-CH', 'IT-ch'): req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': httplang}) locale = req.getLocale() unless(ILocale.isImplementedBy(locale)) parts = httplang.split('-') lang = parts.pop(0).low...
eq(locale.getLocaleLanguageId(), None) eq(locale.getLocaleCountryId(), None) eq(locale.getLocaleVariantId(), None)
eq(locale.id.language, None) eq(locale.id.country, None) eq(locale.id.variant, None)
def testRequestLocale(self): eq = self.assertEqual unless = self.failUnless for httplang in ('it', 'it-ch', 'it-CH', 'IT', 'IT-CH', 'IT-ch'): req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': httplang}) locale = req.getLocale() unless(ILocale.isImplementedBy(locale)) parts = httplang.split('-') lang = parts.pop(0).low...
path = self.get("PATH_INFO", "/") path = unquote(path) path = path.decode('UTF-8') self._environ["PATH_INFO"] = path
def __setupPath(self): # The recommendation states that: # # Unless there is some compelling reason for a # particular scheme to do otherwise, translating character sequences # into UTF-8 (RFC 2279) [3] and then subsequently using the %HH # encoding for unsafe octets is recommended. # # See: http://www.ietf.org/rfc/rfc...
def IPublisher(Interface):
class IPublisher(Interface):
def IPublisher(Interface): def publish(request): """Publish a request The request must be an IPublisherRequest. """
response.setCharset()
response.setCharset(charset)
def _getResultFromResponse(self, body, charset=None, headers=None): response, stream = self._createResponse() if charset is not None: response.setCharset() if headers is not None: for hdr, val in headers.iteritems(): response.setHeader(hdr, val) response.setBody(body) response.outputBody() return self._parseResult(stre...
"""Do any input processing that needs to bve done before traversing
"""Do any input processing that needs to be done before traversing
def processInputs(): """Do any input processing that needs to bve done before traversing
raise Unauthorized("Name %s begins with an underscore" % `name`)
raise Unauthorized, name
def traverseName(self, request, ob, name, check_auth=1): if name.startswith('_'): raise Unauthorized("Name %s begins with an underscore" % `name`) if hasattr(ob, name): subob = getattr(ob, name) else: try: subob = ob[name] except (KeyError, IndexError, TypeError, AttributeError): raise NotFound(ob, name, request) if se...
'''Effect persistent side-effects.
"""Effect persistent side-effects.
def __call__(obj, request, exc_info): '''Effect persistent side-effects.
'''
"""
def __call__(obj, request, exc_info): '''Effect persistent side-effects.
inittime = int(time())
fullinittime = time() inittime = int(fullinittime)
def getobsc(snum,stime,observables,zerotime=0.0): inittime = int(time()) lasttime = 0 print "Processing...", sys.stdout.flush() try: if len(Numeric.shape(observables)) == 0: array = Numeric.zeros(snum,typecode='d') for i in Numeric.arange(0,snum): array[i] = observables(zerotime+i*stime) if i % 1024 == 0: lasttime = ...
currenttime = int(time()) - inittime
currenttime = time() - fullinittime
def getobsc(snum,stime,observables,zerotime=0.0): inittime = int(time()) lasttime = 0 print "Processing...", sys.stdout.flush() try: if len(Numeric.shape(observables)) == 0: array = Numeric.zeros(snum,typecode='d') for i in Numeric.arange(0,snum): array[i] = observables(zerotime+i*stime) if i % 1024 == 0: lasttime = ...
vel = ((1.0*snum)/currenttime) print "\r...completed in %d s [%d (multi)samples/s]. " % (currenttime,vel)
vel = snum/currenttime print "\r...completed in %d s [%d (multi)samples/s]. " % (int(currenttime),int(vel))
def getobsc(snum,stime,observables,zerotime=0.0): inittime = int(time()) lasttime = 0 print "Processing...", sys.stdout.flush() try: if len(Numeric.shape(observables)) == 0: array = Numeric.zeros(snum,typecode='d') for i in Numeric.arange(0,snum): array[i] = observables(zerotime+i*stime) if i % 1024 == 0: lasttime = ...
if currenttime - lasttime > 2:
if currenttime - lasttime > 2 and i > 0:
def dotime(i,snum,inittime,lasttime): currenttime = int(time()) - inittime if currenttime - lasttime > 2: percdone = int((100.0*i)/snum) timeleft = int(((1.0 * currenttime) / i) * (snum-i)) vel = ((1.0*i)/currenttime) minleft = timeleft / 60 secleft = timeleft - minleft*60 print "\r...%d/%d (%d%%) done [%d (multi)s...
def spect(series,sampling,patches=1,detrend=0):
def spect(series,sampling,patches=1,detrend=0,overlap=1):
def spect(series,sampling,patches=1,detrend=0): nyquistf = 0.5 / sampling if patches==0: period = pdg(series) elif patches==1: period = wpdg(series,detrend) else: period = opwpdg(series,patches,detrend) pdlen = shape(period)[0]-1 freqs = arange(0,pdlen+1,typecode='d') * (nyquistf / pdlen) deltaf = nyquistf / pdlen ...
period = opwpdg(series,patches,detrend)
if overlap==0: period = nopwpdg(series,patches,detrend) else: period = opwpdg(series,patches,detrend)
def spect(series,sampling,patches=1,detrend=0): nyquistf = 0.5 / sampling if patches==0: period = pdg(series) elif patches==1: period = wpdg(series,detrend) else: period = opwpdg(series,patches,detrend) pdlen = shape(period)[0]-1 freqs = arange(0,pdlen+1,typecode='d') * (nyquistf / pdlen) deltaf = nyquistf / pdlen ...
pdlen = samples/2
pdlen = (samples-1)/2.0
def wpdg(series,detrend=0): samples = shape(series)[0] pdlen = samples/2 window = 1.0 - abs(arange(0,samples,typecode='d') - pdlen) / (pdlen) weight = samples * sum(window ** 2) # detrending if detrend==0: mean = 0.0 else: mean = sum(series) / (1.0*samples) wseries = window * (series - mean) wpdgram = pdg(wseries) ...
def nopwpdg(series,patches,detrend=0): samples = shape(series)[0] serlen = samples - (samples % (4*patches)) patlen = serlen/patches pdlen = patlen/2 opwpdgram = zeros(pdlen+1,typecode='d') for cnt in range(0,patches): opwpdgram[:] += wpdg(series[cnt*patlen:(cnt+1)*patlen],detrend) opwpdgram[:] /= 1.0*patches retu...
def opwpdg(series,patches,detrend=0): samples = shape(series)[0] serlen = samples - (samples % (4*patches)) patlen = serlen/patches pdlen = patlen/2 opwpdgram = zeros(pdlen+1,typecode='d') for cnt in range(0,2*patches-1): opwpdgram[:] += wpdg(series[cnt*pdlen:(cnt+2)*pdlen],detrend) opwpdgram[:] /= (2.0*patches - 1...
def getobs(snum,stime,observables):
def getobs(snum,stime,observables,zerotime=0.0):
def getobs(snum,stime,observables): if len(shape(observables)) == 0: array = zeros(snum,typecode='d') for i in arange(0,snum): array[i] = observables(i*stime) else: obslen = shape(observables)[0] array = zeros((snum,obslen),typecode='d') for i in arange(0,snum): for j in range(0,obslen): array[i,j] = observables[j](i*s...
array[i] = observables(i*stime)
array[i] = observables(zerotime+i*stime)
def getobs(snum,stime,observables): if len(shape(observables)) == 0: array = zeros(snum,typecode='d') for i in arange(0,snum): array[i] = observables(i*stime) else: obslen = shape(observables)[0] array = zeros((snum,obslen),typecode='d') for i in arange(0,snum): for j in range(0,obslen): array[i,j] = observables[j](i*s...
array[i,j] = observables[j](i*stime)
array[i,j] = observables[j](zerotime+i*stime)
def getobs(snum,stime,observables): if len(shape(observables)) == 0: array = zeros(snum,typecode='d') for i in arange(0,snum): array[i] = observables(i*stime) else: obslen = shape(observables)[0] array = zeros((snum,obslen),typecode='d') for i in arange(0,snum): for j in range(0,obslen): array[i,j] = observables[j](i*s...
def getobsc(snum,stime,observables):
def getobsc(snum,stime,observables,zerotime=0.0):
def getobsc(snum,stime,observables): inittime = int(time()) lasttime = 0 print "Processing...", sys.stdout.flush() if len(shape(observables)) == 0: array = zeros(snum,typecode='d') for i in arange(0,snum): array[i] = observables(i*stime) if i % 1024 == 0: lasttime = dotime(i,snum,inittime,lasttime) else: obslen = sha...
array[i] = observables(i*stime)
array[i] = observables(zerotime+i*stime)
def getobsc(snum,stime,observables): inittime = int(time()) lasttime = 0 print "Processing...", sys.stdout.flush() if len(shape(observables)) == 0: array = zeros(snum,typecode='d') for i in arange(0,snum): array[i] = observables(i*stime) if i % 1024 == 0: lasttime = dotime(i,snum,inittime,lasttime) else: obslen = sha...
array[i,j] = observables[j](i*stime)
array[i,j] = observables[j](zerotime+i*stime)
def getobsc(snum,stime,observables): inittime = int(time()) lasttime = 0 print "Processing...", sys.stdout.flush() if len(shape(observables)) == 0: array = zeros(snum,typecode='d') for i in arange(0,snum): array[i] = observables(i*stime) if i % 1024 == 0: lasttime = dotime(i,snum,inittime,lasttime) else: obslen = sha...
for i in arange(0,snum):
for i in Numeric.arange(0,snum):
def getobs(snum,stime,observables,zerotime=0.0): if len(Numeric.shape(observables)) == 0: array = Numeric.zeros(snum,typecode='d') for i in arange(0,snum): array[i] = observables(zerotime+i*stime) else: obslen = Numeric.shape(observables)[0] array = Numeric.zeros((snum,obslen),typecode='d') for i in Numeric.arange(0,sn...
Ted's Julian date 2457023.5"""
Ted's Julian date 2457023.5."""
def stdLISApositions(): """Returns four Numeric arrays corresponding to times [in seconds] along
[t,p1,p2,p3] = stdlisapositions()
[t,p1,p2,p3] = stdLISApositions()
def stdSampledLISA(interp=1):
assert os.system('python setup.py install --prefix=' + escapespace(thisdir)) == 0
assert os.system('python setup.py install --prefix=' + escapespace(installdir)) == 0
def findpackage(packagename,dirname): packagetargz = glob.glob(packagename + '-*.tar.gz') packagetgz = glob.glob(packagename + '-*.tgz') packagetar = glob.glob(packagename + '-*.tar') packagezip = glob.glob(packagename + '-*.zip') if packagetargz: print "Unpacking " + packagetargz[-1] os.system('tar zxvf ' + pac...
assert os.system('./configure --prefix=' + escapespace(thisdir)) == 0
assert os.system('./configure --prefix=' + escapespace(installdir)) == 0
def findpackage(packagename,dirname): packagetargz = glob.glob(packagename + '-*.tar.gz') packagetgz = glob.glob(packagename + '-*.tgz') packagetar = glob.glob(packagename + '-*.tar') packagezip = glob.glob(packagename + '-*.zip') if packagetargz: print "Unpacking " + packagetargz[-1] os.system('tar zxvf ' + pac...
assert os.system('python setup.py install --prefix=. --root=' + escapespace(thisdir)) == 0
assert os.system('python setup.py install --prefix=. --root=' + escapespace(installdir)) == 0
def findpackage(packagename,dirname): packagetargz = glob.glob(packagename + '-*.tar.gz') packagetgz = glob.glob(packagename + '-*.tgz') packagetar = glob.glob(packagename + '-*.tar') packagezip = glob.glob(packagename + '-*.zip') if packagetargz: print "Unpacking " + packagetargz[-1] os.system('tar zxvf ' + pac...
assert os.system('python setup.py install --prefix=' + escapespace(thisdir) + ' --with-numeric=' + escapespace(thisdir)) == 0
assert os.system('python setup.py install --prefix=' + escapespace(installdir) + ' --with-numeric=' + escapespace(installdir)) == 0
def findpackage(packagename,dirname): packagetargz = glob.glob(packagename + '-*.tar.gz') packagetgz = glob.glob(packagename + '-*.tgz') packagetar = glob.glob(packagename + '-*.tar') packagezip = glob.glob(packagename + '-*.zip') if packagetargz: print "Unpacking " + packagetargz[-1] os.system('tar zxvf ' + pac...
' --with-numpy=' + escapespace(thisdir) + ' --with-swig=' + escapespace(thisdir) + '/bin/swig --prefix=' + escapespace(thisdir))) == 0
' --with-numpy=' + escapespace(installdir) + ' --with-swig=' + escapespace(installdir) + '/bin/swig --prefix=' + escapespace(installdir))) == 0
def findpackage(packagename,dirname): packagetargz = glob.glob(packagename + '-*.tar.gz') packagetgz = glob.glob(packagename + '-*.tgz') packagetar = glob.glob(packagename + '-*.tar') packagezip = glob.glob(packagename + '-*.zip') if packagetargz: print "Unpacking " + packagetargz[-1] os.system('tar zxvf ' + pac...
lambda x: ( str(2.0*math.pi - float(x)), 'Radian' ) )
lambda x: ( float(x) != 0 and str(2.0*math.pi - float(x)) or '0', 'Radian' ) )
def convertUnit(param,unitin,unitout,paramname=''): if unitout == unitin: return (param,unitin) if unitout == "Radian": if unitin == "Degree": return ((math.pi/180.0) * float(param),'Radian') elif unitin == "DMS": # space separated dms = map(float, param.split()) return ((math.pi/180.0) * (dms[0] + dms[1]/60.0 + dms[...
lambda x: ( str(2.0*math.pi - float(x)), 'Radian' ) )
lambda x: ( float(x) != 0 and str(2.0*math.pi - float(x)) or '0', 'Radian' ) ) conversionRules['Inclination'] = ( [('SLInclination','Radian')], lambda x: ( str(float(x) < math.pi and math.pi - float(x) or 3.0*math.pi - float(x)), 'Radian' ) ) conversionRules['SLInclination'] = ( [('Inclination','Radian')], lambda...
def convertUnit(param,unitin,unitout,paramname=''): if unitout == unitin: return (param,unitin) if unitout == "Radian": if unitin == "Degree": return ((math.pi/180.0) * float(param),'Radian') elif unitin == "DMS": # space separated dms = map(float, param.split()) return ((math.pi/180.0) * (dms[0] + dms[1]/60.0 + dms[...
conversionRules['InitialPosition'] = ( [('InitialEta','Radian'),('InitialXi','Radian'),('Armswitch','1')],
conversionRules['InitialPosition'] = ( [('InitialEta','Radian'),('InitialXi','Radian'),('ArmSwitch','1')],
def ex2ipr(e,x,s): eta = float(e) xi = float(x) sw = float(s) if sw > 0: raise NotImplementedError, "convertParameters(): LISA eta/xi configuration with sw > 0 not compatible with PseudoLISA" initpos = eta initrot = xi + initpos - 1.5*math.pi return ( (str(initpos),'Radian'), (str(initrot),'Radian') )
conversionRules['InitialRotation'] = ( [('InitialEta','Radian'),('InitialXi','Radian'),('Armswitch','1')],
conversionRules['InitialRotation'] = ( [('InitialEta','Radian'),('InitialXi','Radian'),('ArmSwitch','1')],
def ex2ipr(e,x,s): eta = float(e) xi = float(x) sw = float(s) if sw > 0: raise NotImplementedError, "convertParameters(): LISA eta/xi configuration with sw > 0 not compatible with PseudoLISA" initpos = eta initrot = xi + initpos - 1.5*math.pi return ( (str(initpos),'Radian'), (str(initrot),'Radian') )
XMLToObject['EMRI'] = ('EMRI',lisawp_emri.EMRI)
XMLToObject['ExtremeMassRatioInspiral'] = ('EMRI',lisawp_emri.EMRI)
def makeoptional(parlist): return map(lambda p: lambda s: p[0] in s or p,parlist)
self.coupletag('Param',{'Name': 'TimeOffset','Type': 's'},
self.coupletag('Param',{'Name': 'TimeOffset','Type': 'Second'},
def writeTimeSeries(self,TimeSeries): # write out the TimeSeries defined in TimeSeries self.opentag('XSIL',{'Type': 'TimeSeries', 'Name': TimeSeries.description})
self.coupletag('Param',{'Name': 'Cadence','Unit': 's'},
self.coupletag('Param',{'Name': 'Cadence','Unit': 'Second'},
def writeTimeSeries(self,TimeSeries): # write out the TimeSeries defined in TimeSeries self.opentag('XSIL',{'Type': 'TimeSeries', 'Name': TimeSeries.description})
self.coupletag('Param',{'Name': 'Duration','Unit': 's'},
self.coupletag('Param',{'Name': 'Duration','Unit': 'Second'},
def writeTimeSeries(self,TimeSeries): # write out the TimeSeries defined in TimeSeries self.opentag('XSIL',{'Type': 'TimeSeries', 'Name': TimeSeries.description})
tree = p(f.read())
lines = f.read()
def __init__(self,filename): p = pyRXP.Parser()
import numpy.dft as FFT
import numpy.fft as FFT
def sn(signal,noise,stime,npatches): """Compute the optimal S/N for signal, sampled at intervals of stime, and for the total duration represented in the array, against noise represented by the time series noise; npatches overlapping periods are used to estimate the PSD of the noise.""" # compute signal spectrum withou...
""" % (pythonpath, pythonpath)
SYNTHLISABASE="%s"; export SYNTHLISABASE """ % (pythonpath, pythonpath, installpath)
def runswig(source,cppfile,pyfile,deps): if not os.path.isfile(cppfile) or not os.path.isfile(pyfile) \ or newer_group(deps,cppfile) or newer_group(deps,pyfile): try: spawn([swig_bin,'-w402','-c++','-python','-o',cppfile,source]) except: print 'Sorry, I am unable to swig the modified ' + lisasim_isource sys.exit(cmd)
""" % (pythonpath, pythonpath)
setenv SYNTHLISABASE %s """ % (pythonpath, pythonpath, installpath)
def runswig(source,cppfile,pyfile,deps): if not os.path.isfile(cppfile) or not os.path.isfile(pyfile) \ or newer_group(deps,cppfile) or newer_group(deps,pyfile): try: spawn([swig_bin,'-w402','-c++','-python','-o',cppfile,source]) except: print 'Sorry, I am unable to swig the modified ' + lisasim_isource sys.exit(cmd)
version = '1.2.4',
version = '1.2.6',
def runswig(source,cppfile,pyfile,deps): if not os.path.isfile(cppfile) or not os.path.isfile(pyfile) \ or newer_group(deps,cppfile) or newer_group(deps,pyfile): try: spawn([swig_bin,'-w402','-c++','-python','-o',cppfile,source]) except: print 'Sorry, I am unable to swig the modified ' + lisasim_isource sys.exit(cmd)
db = CountryByIP(db_file)
try: db = CountryByIP(db_file) except IOError, exc: import errno if exc.errno==errno.ENOENT: sys.exit('Database not found. Run update.py to create it.') else: sys.exit('Cannot open database: %s' % exc)
def __getitem__(self, ip): offset = 0 fp = self.fp for part in ip.split('.'): start = offset+int(part)*4 fp.seek(start) value = fp.read(4) assert len(value)==4 if value[:2]=='\xFF\xFF': if value[2:]=='\x00\x00': raise KeyError(ip) else: return value[2:] offset = struct.unpack('!I', value)[0] raise RuntimeError('ip2cc d...
try: ln = pobj.stdout.readline() except IOError:
ln = pobj.stdout.readline() if alarm_triggered:
def run_tlsmd(webtlsmdd, jdict): job_id = jdict["job_id"] tlsmd = jdict["tlsmd"] ## write the tlsmd execution command out to a file open("tlsmdcmd.txt", "w").write(" ".join(tlsmd) + '\n') pobj = subprocess.Popen(tlsmd, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, close_fds = True, b...
if self.struct.title:
if self.struct.header:
def html_globals(self): """Output a HTML table displaying global TLSMD settings. """ if conf.globalconf.tls_model in ["ISOT", "NLISOT"]: tls_model = "Isotropic" elif conf.globalconf.tls_model in ["ANISO", "NLANISO"]: tls_model = "Anisotropic"
if numpy.allclose(L1, 0.0) or type(L1)==complex:
if numpy.allclose(L1, 0.0) or type(L1)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, ...
if numpy.allclose(L2, 0.0) or type(L2)==complex:
if numpy.allclose(L2, 0.0) or type(L2)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, ...
if numpy.allclose(L3, 0.0) or type(L3)==complex:
if numpy.allclose(L3, 0.0) or type(L3)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, ...
if numpy.allclose(Tr1, 0.0) or type(Tr1)==complex:
if numpy.allclose(Tr1, 0.0) or type(Tr1)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, ...
if numpy.allclose(Tr2, 0.0) or type(Tr2)==complex:
if numpy.allclose(Tr2, 0.0) or type(Tr2)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, ...
if numpy.allclose(Tr3, 0.0) or type(Tr3)==complex:
if numpy.allclose(Tr3, 0.0) or type(Tr3)==numpy.complex_:
def calc_itls_center_of_reaction(iT, iL, iS, origin): """iT is a single float; iL[3,3]; iS[3] """ ## construct TLS tensors from isotropic TLS description T0 = numpy.array([[iT, 0.0, 0.0], [0.0, iT, 0.0], [0.0, 0.0, iT]], float) L0 = iL.copy() S0 = numpy.array([ [ 0.0, 0.0, iS[1]], [iS[0], 0.0, 0.0], [ 0.0, ...
if numpy.allclose(L1, 0.0) or type(L1)==complex:
if numpy.allclose(L1, 0.0) or type(L1)==numpy.complex_:
def calc_TLS_center_of_reaction(T0, L0, S0, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction...
if numpy.allclose(L2, 0.0) or type(L2)==complex:
if numpy.allclose(L2, 0.0) or type(L2)==numpy.complex_:
def calc_TLS_center_of_reaction(T0, L0, S0, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction...
if numpy.allclose(L3, 0.0) or type(L3)==complex:
if numpy.allclose(L3, 0.0) or type(L3)==numpy.complex_:
def calc_TLS_center_of_reaction(T0, L0, S0, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction...
if numpy.allclose(Tr1, 0.0) or type(Tr1)==complex:
if numpy.allclose(Tr1, 0.0) or type(Tr1)==numpy.complex_:
def calc_TLS_center_of_reaction(T0, L0, S0, origin): """Calculate new tensors based on the center for reaction. This method returns a dictionary of the calculations: T^: T tensor in the coordinate system of L L^: L tensor in the coordinate system of L S^: S tensor in the coordinate system of L COR: Center of Reaction...