Exemplo n.º 1
0
def test_copy_star(tmpdir):
    os.chdir(str(tmpdir))

    dir_ = os.path.join(pyfant.get_pfant_data_path(), 'arcturus')
    pyfant.copy_star(dir_)

    assert glob.glob("*") == ['abonds.dat', 'main.dat']
Exemplo 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)
Exemplo n.º 3
0
def copy_star(src_dir=None, starname=None):
    """
    Copies files such as main.dat and abonds.dat from PFANT/data/some_directory into local directory

    Args:
        src_dir: absolute path to directory containing PFANT star data files FileMain and FileAbonds
                 (and optionally FileDissoc files, which will be also copied if present)
        starname: if passed, will ignore src_dir and make it from starname instead, considering
                  starname as a subdirectory of PFANT/data/
    """
    star_classes = [pyfant.FileMain, pyfant.FileDissoc, pyfant.FileAbonds]

    if starname is not None:
        src_dir = os.path.join(pyfant.get_pfant_data_path(), starname)

    if src_dir is None and starname is None:
        raise ValueError("Supply either src_dir or starname")

    if not os.path.isdir(src_dir):
        raise ValueError("'{}' is not a valid directory".format(src_dir))

    a99.get_python_logger().debug("Will look inside directory %s" % src_dir)

    # makes list of files to analyse
    types = ('*.dat', '*.mod')
    ff = []
    for type_ in types:
        ff.extend(glob.glob(os.path.join(src_dir, type_)))

    copy_or_skip_files(ff)
Exemplo n.º 4
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'
    ]
Exemplo n.º 5
0
import logging
import sys
import pyfant
import a99

a99.logging_level = logging.INFO
a99.flag_log_file = True

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description=__doc__,
                                     formatter_class=a99.SmartFormatter)
    parser.add_argument('-l',
                        '--list',
                        action='store_true',
                        help='lists subdirectories of ' +
                        pyfant.get_pfant_data_path())
    parser.add_argument('-p',
                        '--path',
                        action='store_true',
                        help='system path mode')
    parser.add_argument(
        '-y',
        '--yes',
        action="store_true",
        help="Automatically answers 'yes' to eventual question")
    parser.add_argument(
        'directory',
        type=str,
        nargs="?",
        default="common",
        help=
Exemplo 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()
Exemplo n.º 7
0
import a99


a99.logging_level = logging.INFO
a99.flag_log_file = True


if __name__ == "__main__":
    flag_menu = len(sys.argv) == 1  # will display menu if no command-line arguments

    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=a99.SmartFormatter
    )
    parser.add_argument('-l', '--list', action='store_true',
      help='lists subdirectories of '+pyfant.get_pfant_data_path())
    parser.add_argument('-p', '--path', action='store_true',
      help='system path mode')
    parser.add_argument('directory', type=str, nargs="?",
     help='name of directory (either a subdirectory of PFANT/data or the path '
          'to a valid system directory (see modes of operation)')

    args = parser.parse_args()


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