def _do_save_as(self, filename): with open(filename, "w") as h: a99.write_lf( h, "# filename / niv inf / niv sup / central lambda / kiex / c1") for r in self.rows: a99.write_lf( h, "%s %s %s %s %s %s" % (r.fn, r.na, r.nb, r.clam, r.kiex, r.c1))
def _do_save_as(self, filename): with open(filename, "w") as h: n = len(self.atoms) for i, e in enumerate(self.atoms): p = len(e) for j, a in enumerate(e.lines): finrai = 1 if i == n - 1 and j == p - 1 else 0 a99.write_lf(h, "%2s%1d %10.3f" % (e.elem, e.ioni, a.lambda_)) # Writing floating-point numbers with %.7g format creates a more compact # file. In Fortran it is read with '*' format, so it understands as # long as there is a space between numbers. a99.write_lf(h, "%.7g %.7g %.7g %.7g %.7g %.7g %.7g %1d" % \ (a.kiex, a.algf, a.ch, a.gr, a.ge, a.zinf, a.abondr, finrai))
def _do_save_as(self, filename): with open(filename, "w") as h: # h.writelines([' %-2s%6.2f\n' % (self.ele[i], self.abol[i]) # for i in xrange(len(self))]) # h.writelines(['1\n', '1\n']) a99.write_lf( h, "%5d%5d%10.5f%10.5f %s" % (self.nmetal, self.nimax, self.eps, self.switer, self.title)) # atoms part fr = ff.FortranRecordReader('(a2, 2x, i6, f10.3, 2i5, f10.5)') for elems, nelemx, ip, ig0, ig1, cclog in \ zip(self.elems, self.nelemx, self.ip, self.ig0, self.ig1, self.cclog): elems = elems.upper().strip( ) # to follow convention: right-aligned upper case a99.write_lf( h, '%2s %6d%10.3f%5d%5d%10.5f' % (elems, nelemx, ip, ig0, ig1, cclog)) for mol, c, mmax, nelem, natom in \ zip(self.mol, self.c, self.mmax, self.nelem, self.natom): mol = mol.upper().strip( ) # to follow convention: right-aligned upper case l = [ "%3s %11.5e%12.5e%12.5e%12.5e%12.5e%1d" % tuple([mol] + c + [mmax]) ] for nelemm, natomm in zip(nelem, natom): l.append("%2d%1d" % (nelemm, natomm)) s = "".join(l) a99.write_lf(h, s) a99.write_lf(h, "") a99.write_lf(h, "") # two blank lines to signal end-of-file
def _do_save_as(self, filename): with open(filename, "w") as h: a99.write_lf(h, str(len(self.molecules))) a99.write_lf(h, self.titm) a99.write_lf(h, " ".join([str(x.nv) for x in self.molecules])) for i_m, m in enumerate(self.molecules): a99.get_python_logger().info( "Saving '{}': molecule {}/{}".format( filename, i_m + 1, len(self.molecules))) # # Assembles "titulo" # ## Transitions ltrans = [] for sol in m: if sol.vl is None or sol.v2l is None: break ltrans.append([sol.vl, sol.v2l]) new_titulo = "{} # {} # {}".\ format(m.description, " ".join([s.strip() for s in m.symbols]), "|".join(["{:.0f},{:.0f}".format(*t) for t in ltrans])) # - mled change, incorporate shit a99.write_lf(h, new_titulo) a99.write_lf( h, (" ".join(["%.10g"] * 9)) % (m.fe, m.do, m.mm, m.am, m.bm, m.ua, m.ub, m.te, m.cro)) a99.write_lf(h, "") a99.write_lf(h, str(m.s)) a99.write_lf(h, " ".join(["{:g}".format(x.qqv) for x in m.sol])) a99.write_lf(h, " ".join(["{:.2f}".format(x.ggv) for x in m.sol])) a99.write_lf(h, " ".join(["{:.5f}".format(x.bbv) for x in m.sol])) a99.write_lf(h, " ".join(["{:.2f}".format(x.ddv) for x in m.sol])) a99.write_lf(h, " ".join(["{:g}".format(x.fact) for x in m.sol])) num_sol = len(m.sol) for i, s in enumerate(m.sol): num_lines = len( s) # number of lines for current set-of-lines for j in range(num_lines): numlin = 0 if j < num_lines - 1 else 9 if i == num_sol - 1 else 1 a99.write_lf( h, "%.10g %.10g %.10g %s %d" % (s.lmbdam[j], s.sj[j], s.jj[j], s.branch[j], numlin))
def _do_save_as(self, filename): """Saves to file.""" assert isinstance(self.vvt, list), "vvt must be list!" list2str = lambda l: " ".join([str(x) for x in l]) with open(filename, "w") as h: a99.write_lf(h, "%s" % self.titrav) a99.write_lf( h, "%s %s %s %s %s" % (a99.bool2str( self.ecrit), self.pas, self.echx, self.echy, self.fwhm)) a99.write_lf(h, "%s" % self.vvt[0]) if self.vvt[0] > NINE_HUNDRED: a99.write_lf(h, "%s" % len(self.vvt)) # self.ivtot) a99.write_lf(h, list2str(self.tolv)) a99.write_lf(h, list2str(self.vvt)) a99.write_lf( h, list2str( [self.teff, self.glog, self.asalog, self.nhe, self.inum])) a99.write_lf(h, list2str([a99.bool2str(self.ptdisk), self.mu])) a99.write_lf(h, str(self.afstar)) a99.write_lf(h, list2str(self.xxcor)) a99.write_lf(h, self.flprefix) a99.write_lf(h, list2str([self.llzero, self.llfin, self.aint])) for filetoh in self.filetohy: a99.write_lf(h, filetoh)