def test_conv_kurucz(tmpdir): pass os.chdir(str(tmpdir)) db = pyfant.FileMolDB() db.init_default() # conn = db.get_conn() molconsts = pyfant.MolConsts() molconsts.populate_all_using_str(db, "OH [A 2 Sigma - X 2 Pi]") molconsts.None_to_zero() h = _fake_file() fileobj = pyfant.FileKuruczMolecule() fileobj._do_load_h(h, "_fake_file") conv = pyfant.ConvKurucz(molconsts=molconsts, flag_hlf=True, flag_normhlf=True, flag_fcf=False, flag_quiet=False, fcfs=None, iso=None) f, log = conv.make_file_molecules(fileobj) assert f.num_lines == 5 assert f[0].s == 0.5
def test_populate_all_using_str(tmpdir): os.chdir(str(tmpdir)) db = pyfant.FileMolDB() db.init_default() consts = pyfant.MolConsts() consts.populate_all_using_str(db, "OH [A 2 SIGMA - X 2 PI]")
def test_molconsts_to_molecule(tmpdir): os.chdir(str(tmpdir)) db = pyfant.FileMolDB() db.init_default() mc = pyfant.some_molconsts(db) mm = pyfant.molconsts_to_molecule(mc)
def test_parse_pfantmol_descriptions(tmpdir): os.chdir(str(tmpdir)) db = pyfant.FileMolDB() db.init_default() cursor = db.get_conn().execute("select * from pfantmol") for row in cursor: mc = pyfant.MolConsts() mc.populate_parse_str(row["description"])
def test_populate_all_using_ids(tmpdir): os.chdir(str(tmpdir)) db = pyfant.FileMolDB() db.init_default() consts = pyfant.MolConsts() consts.populate_all_using_ids(db, id_molecule=7, id_system=6, id_pfantmol=12, id_statel=96, id_state2l=97)
def _do_load_moldb(self): """Loads FileMolDB and updates part of GUI accordingly. This is an intermediate GUI updating stage.""" moldb, flag_valid = pyfant.FileMolDB(), False fn_moldb = self.w_fn_moldb.value try: moldb.load(fn_moldb) flag_valid = True except Exception as e: self.add_log_error("Error loading file '{}'".format(fn_moldb), True, e) self.w_fn_moldb.flag_valid = flag_valid self.w_molconsts.set_moldb(moldb if flag_valid else None)
def test_populate_all_using_ids_raises(tmpdir): """Uses invalid ids to see method raising ValueError""" os.chdir(str(tmpdir)) db = pyfant.FileMolDB() db.init_default() consts = pyfant.MolConsts() with pytest.raises(ValueError): consts.populate_all_using_ids(db, id_molecule=111, id_system=11116, id_pfantmol=11112, id_statel=111196, id_state2l=111197)
def test_some_molconsts(tmpdir): """Reproduces all the steps in some_molconsts()""" os.chdir(str(tmpdir)) db = pyfant.FileMolDB() db.init_default() s = "OH [A 2 SIGMA - X 2 PI]" ret = pyfant.MolConsts() ret.populate_all_using_str(db, s) ret.populate_parse_str(s) db.get_conn().close() os.unlink(db.filename) ret.None_to_zero() return ret
def test_adds_to_one0(tmpdir): os.chdir(str(tmpdir)) db = pyfant.FileMolDB() db.init_default() consts = pyfant.MolConsts() consts.populate_all_using_str(db, "OH [A 2 sigma - X 2 pi]") consts.None_to_zero() mtools = pyfant.kovacs_toolbox(consts) for J2l in range(30): try: k = 2. / ((2 * consts.get_S2l() + 1) * (2 * J2l + 1) * (2 - consts["cro"])) mtools.populate(0, 0, J2l) sum_ = sum([x * k for x in mtools._dict_sj.values() if x > 0]) print("J2l={:2}: sum={}".format(J2l, sum_)) except ZeroDivisionError: print("ZeroDivisionError for J2l={}".format(J2l))
if __name__ == "__main__": deffn = pyfant.FileMolDB.default_filename parser = argparse.ArgumentParser( description=__doc__, formatter_class=a99.SmartFormatter ) parser.add_argument('fn', type=str, help='Molecules database file name', default=deffn, nargs='?') args = parser.parse_args() if args.fn == deffn and not os.path.isfile(deffn): args.fn = None m = None if args.fn is not None: m = pyfant.FileMolDB() m.load(args.fn) app = a99.get_QApplication([]) form = pyfant.XFileMolDB(None, [m,]) form.showMaximized() sys.exit(app.exec_())
def test_FileMolDB(tmpdir): os.chdir(str(tmpdir)) obj = pyfant.FileMolDB() obj.init_default() obj.save_as("another")
"""Converts Plez's Turbospectrum file to PFANT format. Requires Turbospectrum linelist file 'N14H-AX-2011.bsyn.list' (system 'NH A-X PGopher'). """ import pyfant fmoldb = pyfant.FileMolDB() fmoldb.init_default() molconsts = fmoldb.get_molconsts("NH [A 3 Pi - X 3 Sigma]") molconsts.None_to_zero() fplez = pyfant.FilePlezLinelist() fplez.load("N14H-AX-2011.bsyn.list") converter = pyfant.ConvPlez(name="NH A-X PGopher", molconsts=molconsts) fmol, log = converter.make_file_molecules(fplez) fmol.save_as("nh-converted.dat")