Esempio n. 1
0
def test_link_to_data(tmpdir):
    os.chdir(str(tmpdir))
    pyfant.link_to_data(pyfant.get_pfant_data_path("common"))
    d = glob.glob("*")
    d.sort()
    assert d == [
        'absoru2.dat', 'atoms.dat', 'grid.mod', 'grid.moo', 'hmap.dat',
        'molecules.dat', 'partit.dat'
    ]
Esempio n. 2
0
def test_run_parallel(tmpdir):
    os.chdir(str(tmpdir))

    pyfant.copy_star(pyfant.get_pfant_data_path('arcturus'))
    pyfant.link_to_data(pyfant.get_pfant_data_path("common"))

    cc = []

    c = pyfant.Combo()
    c.conf.flag_output_to_dir = True
    cc.append(c)
    c = pyfant.Combo()
    c.conf.flag_output_to_dir = True
    cc.append(c)

    pyfant.run_parallel(cc, flag_console=False)
Esempio n. 3
0
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.")
Esempio n. 4
0
        print("Directory name is required, except if '-l' option specified.")
        parser.print_usage()
        sys.exit()

    # "-l" mode
    if args.list:
        print("\n".join(
            a99.format_h1("Subdirectories of '%s'" %
                          pyfant.get_pfant_data_path())))
        for dirname in pyfant.get_pfant_data_subdirs():
            print(dirname)
        sys.exit()

    if args.path:
        dir_ = args.directory
    else:
        dir_ = pyfant.get_pfant_path('data', args.directory)

    flag_ask = not args.path and not args.yes

    if flag_ask:
        while True:
            ans = input("Create links to PFANT data files in '%s' (Y/n)? " %
                        dir_).upper()
            if ans in ("N", "NO"):
                sys.exit()
            if ans in ("Y", "YES", ""):
                break

    pyfant.link_to_data(dir_)
Esempio n. 5
0
"""Runs synthesis over large wavelength range, then plots continuum"""

import pyfant
import f311
import matplotlib.pyplot as plt
import a99

if __name__ == "__main__":
    # Copies files main.dat and abonds.dat to local directory (for given star)
    pyfant.copy_star(starname="sun-grevesse-1996")
    # Creates symbolic links to all non-star-specific files, such as atomic & molecular lines,
    # partition functions, etc.
    pyfant.link_to_data()

    # Creates object that will run the four Fortran executables (innewmarcs, hydro2, pfant, nulbad)
    obj = pyfant.Combo()
    oo = obj.conf.opt
    # synthesis interval start (angstrom)
    oo.llzero = 2500
    # synthesis interval end (angstrom)
    oo.llfin = 30000
    # savelength step (angstrom)
    oo.pas = 1.
    # Turns off hydrogen lines
    oo.no_h = True
    # Turns off atomic lines
    oo.no_atoms = True
    # Turns off molecular lines
    oo.no_molecules = True

    obj.run()
Esempio n. 6
0
def test_run_combo(tmpdir):
    os.chdir(str(tmpdir))
    pyfant.copy_star(pyfant.get_pfant_data_path('arcturus'))
    pyfant.link_to_data(pyfant.get_pfant_data_path("common"))
    c = pyfant.Combo()
    c.run()