def write_lagrange(m, x, i, output): # When we determine which Lagrange point we have we save it. periods = [] x["Type number"] = 3 #HB print "L" + str(i) + ":" d = parseD.parseD('fort.9') routh = 0.5 * (1 - math.sqrt(69) / 9) for evalue in d(x["Label"])["Eigenvalues"]: # If the real part in sufficiently small # we get the imaginary part if evalue[1] > 0 and (i <= 3 or evalue[0] == 0 or m < routh): # and compute the period. If is is not in our # list of periods (i.e. it is not a complex conjugate # to one we have already computed) we add it. periods.append(2 * math.pi / evalue[1]) periods.sort() for j in range(len(periods)): period = periods[j] label = (i - 1) * 2 + j + 1 # above Routh's ratio we have one period for L4/L5, otherwise 3. if i == 5: label = label - 2 + len(periods) print "Label: %d; imaginary part: %7s; period: %10s" % ( label, 2 * math.pi / period, period) x["Label"] = label x["Branch number"] = i * 10 + j + 1 x["p"][10] = period x.write(output)
def make_s(sfile, label, step, floquet=None): solution = sl(sfile) if floquet is None: #first figure out the Floquet multiplier diag = parseD.parseD('d.' + str(sfile)) for d in diag: if d["Label"] != 0: break addend = d["Label"] - solution[0]["Label"] floquet = 1.0 + 1e-3 for mplier in diag(label + addend)["Multipliers"]: if abs(mplier[0]) > abs(floquet): if abs(floquet) > 1.0 + 1e-3 + 1e-10: print "Warning: more than one multiplier > 1" floquet = mplier[0] print "Floquet multiplier: ", floquet solution = solution(label) for point in solution['data']: for i in range(len(point['u'])): point['u'].append(0) point['u dot'].append(0) solution['Label'] = 1 solution['Free Parameters'] = [2, 3, 4] solution["Parameter NULL vector"] = [0, 1, 0] solution['Parameters'][3] = floquet solution['Parameters'][4] = 0 solution['Parameters'][5] = step solution.writeFilename('s.ext') print "Written to s.ext"
def readFilename(self, fort7_filename, fort8_filename=None, fort9_filename=None): parseB.parseBR.readFilename(self, fort7_filename) for i, d in enumerate(self): self[i] = bifDiagBranch(d) if fort8_filename is not None and isinstance(fort8_filename, str): solution = parseS.parseS(fort8_filename) i = 0 for d in self: for k, x in map(d._gettypelabel, d.labels.getIndices()): if x.get("LAB", 0) != 0: x["solution"] = solution[i] i = i + 1 if not fort9_filename is None: # for now just attach diagnostics information to the first branch self[0].diagnostics = parseD.parseD(fort9_filename)
def read(self, fort7_input, fort8_input=None, fort9_input=None): parseB.parseBR.read(self, fort7_input) for i, d in enumerate(self): self[i] = bifDiagBranch(d) if fort8_input is not None and (isinstance(fort8_input, (file, gzip.GzipFile))): solution = parseS.parseS() solution.read(fort8_input) i = 0 for d in self: for k, x in map(d._gettypelabel, d.labels.getIndices()): if x.get("LAB", 0) != 0: x["solution"] = solution[i] i = i + 1 if fort9_input is not None: diagnostics = parseD.parseD() diagnostics.read(fort9_input) # for now just attach diagnostics information to the first branch self[0].diagnostics = diagnostics
def __init__(self, fort7_filename=None, fort8_filename=None, fort9_filename=None): self.diagnostics = None if isinstance(fort7_filename, list): self.diagram = None self.solution = parseS.parseS(fort7_filename) elif fort8_filename is None and fort7_filename is not None: raise AUTOExceptions.AUTORuntimeError( "Must set both both filenames") elif isinstance(fort7_filename, str) or fort7_filename is None: self.diagram = parseB.parseB(fort7_filename) self.solution = parseS.parseS(fort8_filename) if not fort9_filename is None: self.diagnostics = parseD.parseD(fort9_filename) else: self.diagram = fort7_filename self.solution = fort8_filename self.diagnostics = fort9_filename if self.diagnostics is None: self.diagnostics = [] self.dg = self.diagram self.sl = self.solution
def __realinit(self, fort7_filename, fort8_filename, fort9_filename, constants): ioerrors = [] try: parseB.parseBR.__init__(self, fort7_filename) for i, d in enumerate(self): self[i] = bifDiagBranch(d) except IOError: ioerrors.append(str(sys.exc_info()[1])) parseB.parseBR.__init__(self) fort7_filename = None if isinstance(fort8_filename, parseS.AUTOSolution): fort8_filename = [fort8_filename] try: solution = parseS.parseS(fort8_filename) except IOError: ioerrors.append(str(sys.exc_info()[1])) solution = None if fort7_filename is None: raise AUTOExceptions.AUTORuntimeError('\n'.join(ioerrors)) if fort7_filename is None and fort8_filename is not None: # simulate a bifurcation diagram labels = {} for s in solution: br = s["Branch number"] if labels == {} or br != branch.BR: if labels != {}: branch.labels = Points.PointInfo(labels) branch = bifDiagBranch() self.append(branch) branch.BR = br branch.coordarray = [] branch.coordnames = [] branch.headernames = [] branch.headerlist = [] branch.c = constants labels = {} base = 0 i = 0 pt = s["PT"] lab = s["LAB"] ty = s["TY number"] if i >= base + pt - 1: # point numbers wrapped around base += 9999 i = base + pt - 1 labels[i] = {s["TY"]: {"LAB": lab, "TY number": ty, "PT": pt}} if labels != {}: branch.labels = Points.PointInfo(labels) if fort9_filename is not None and self.data != []: try: # for now just attach diagnostics information to first branch self[0].diagnostics = parseD.parseD(fort9_filename) except IOError: pass i = 0 if solution is not None: for d in self: if constants is None and d.c is not None: constants = d.c constants = parseC.parseC(constants) for k in constants: if k in self.nonekeys: constants[k] = None for ind in d.labels.getIndices(): if i >= len(solution): break x = d._gettypelabel(ind)[1] s = solution[i] if x.get("LAB", 0) != 0 or s["LAB"] == 0: i = i + 1 s = x["solution"] = parseS.AUTOSolution( s, constants=constants) if d.coordnames != []: s.b = d[ind]
# 找出多少个商品 numbers = int(html2.xpath('//div[@class="filter-activity"]/span/text()')[0]) page_number = math.ceil(numbers/60) # 翻页 for num in range(1, page_number+1): ul = re.sub('#qk=shaixuan', f'&page={num}', d_urk) # print(ul) response3 = requests.get(ul).text html3 = etree.HTML(response3) # 提取所有商品 urls = html3.xpath('//ul[@id="js_hover"]/li/div[@class="title"]/a/@href') for ull in urls: ull = f'http:{ull}' print(ull) try: parseD(ull) except: pass # response4 = requests.get(ull).text # html4 = etree.HTML(response4) # # 提取信息 # title = html4.xpath('//div[@class="scroll-wrap"]/h2/text()') # # 尺码信息 # chima = html4.xpath('//div[@class="total-size"]//li/a/text()') # # 商品信息 # shangpin = html4.xpath('//div[@class="pro-desc-content"]/text()') # # 图片网址 # pictures = html4.xpath('//div[@class="pic-list-wrap"]//img/@src') # # picture_data = {