def run_traprb(molconsts, fn_input=None, fn_output=None, maxv=None, ni=None, ns=None, igraph=None, ienerg=None, istate=None, rmin=None, rmax=None, delr=None): """ Runs TRAPRB and returns a the TRAPRB object :param molconsts: MolConsts object :param fn_input: input filename (will be created with this name). If not passed, will make up a filename as 'temp-in-*' :param fn_output: output filename (will be created with this name). If not passed, will make up a filename as 'temp-out-*' :return: TRAPRB object For meanings of parameters and their default values, see filetraprb.py::TRAPRBInputState class **This routine creates files 'temp-traprb*' and leaves then** **Not multiprocessing-safe**, unless fn_input and fn_output are controlled externally. """ if fn_input is None: fn_input = a99.new_filename("temp-in-") if fn_output is None: fn_output = a99.new_filename("temp-out-") fin = pyfant.FileTRAPRBInput() fin.from_molconsts( molconsts, maxv, ni, ns, igraph, ienerg, istate, rmin, rmax, delr, ) fin.save_as(fn_input) r = pyfant.TRAPRB() r.fn_input = fn_input r.fn_output = fn_output r.run() return r
def main(fns_input, fn_output): ffmol = [] for fn in fns_input: fmol = pyfant.FileMolecules() try: fmol.load(fn) print("File '{}': {} molecule{}".format( fn, len(fmol), "" if len(fmol) == 1 else "s")) ffmol.append(fmol) except: a99.get_python_logger().exception("Skipping file '{}'".format(fn)) n = len(ffmol) fout = pyfant.FileMolecules() fout.titm = "Merge of {} file{}: {}".format( n, "s" if n != 1 else "", ", ".join([os.path.split(fmol.filename)[1] for fmol in ffmol])) for fmol in ffmol: fout.molecules.extend(fmol.molecules) print("Number of molecules in output: {}".format(len(fout))) if fn_output is None: fn_output = a99.new_filename(_PREFIX, ".dat") fout.save_as(fn_output) print("Saved file '{}'".format(fn_output))
def wants_auto(self): idx = self.w_source.index filename = None if idx == 0: lines = self.w_hitran.data if lines: filename = "{}.dat".format(lines["header"]["table_name"]) if filename is None: # Default filename = a99.new_filename("mol", "dat") self.w_out.value = filename
def _wants_autofilename(self): name = _NAMES[self.w_source.index] filename = None if name == "HITRAN": lines = self.w_hitran.data if lines: filename = "{}.dat".format(lines["header"]["table_name"]) if filename is None: # Default filename = a99.new_filename("mol", "dat") self.w_out.value = filename self._update_fobj() self.changed.emit()
def main(flag_cleanup=True): tmpdir = a99.new_filename("hydrogen-profiles") # Saves current directory pwd = os.getcwd() mylog("Creating directory '{}'...".format(tmpdir)) os.mkdir(tmpdir) try: pyfant.link_to_data() _main() finally: # Restores current directory os.chdir(pwd) # Removes temporary directory if flag_cleanup: mylog("Removing directory '{}'...".format(tmpdir)) shutil.rmtree(tmpdir) else: mylog("Not cleaning up.")