How to use the orbitize.read_input.read_file function in orbitize

To help you get started, we’ve selected a few orbitize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sblunt / orbitize / tests / test_api.py View on Github external
def test_systeminit():
    """
    Test that initializing a ``System`` class produces a list of ``Prior``
    objects of the correct length when:
        - parallax and total mass are fixed
        - parallax and total mass errors are given
        - parallax is fixed, total mass error is given
        - parallax error is given, total mass error is fixed

    Test that the different types of data are parsed correctly
    when initializing a ``System`` object.
    """
    testdir = orbitize.DATADIR
    input_file = os.path.join(testdir, 'test_val.csv')
    data_table = read_input.read_file(input_file)

    # Manually set 'object' column of data table
    data_table['object'] = 1
    data_table['object'][1] = 2

    plx_mass_errs2lens = {
        (0., 0.): 14,
        (1., 1.): 14,
        (0., 1.): 14,
        (1., 0.): 14
    }

    for plx_e, mass_e in plx_mass_errs2lens.keys():

        testSystem_priors = system.System(
            2, data_table, 10., 10., plx_err=plx_e, mass_err=mass_e
github sblunt / orbitize / tests / test_read_input.py View on Github external
def test_read_file():
    """
    Test the read_file function using the test_val.csv file and test_val_radec.csv
    """
    # Check that main test input is read in with correct values
    input_file = os.path.join(orbitize.DATADIR, 'test_val.csv')
    _compare_table(read_file(input_file))
    # Check that an input value with all valid entries and only ra/dec columns can be read
    input_file_radec = os.path.join(orbitize.DATADIR, 'test_val_radec.csv')
    read_file(input_file_radec)
github sblunt / orbitize / tests / test_read_input.py View on Github external
def test_read_file():
    """
    Test the read_file function using the test_val.csv file and test_val_radec.csv
    """
    # Check that main test input is read in with correct values
    input_file = os.path.join(orbitize.DATADIR, 'test_val.csv')
    _compare_table(read_file(input_file))
    # Check that an input value with all valid entries and only ra/dec columns can be read
    input_file_radec = os.path.join(orbitize.DATADIR, 'test_val_radec.csv')
    read_file(input_file_radec)
github sblunt / orbitize / tests / test_read_input.py View on Github external
def test_write_orbitize_input():
    """
    Test the write_orbitize_input and the read_file functions
    """
    input_file = os.path.join(orbitize.DATADIR, 'test_val.csv')
    test_table = read_file(input_file)
    output_file = os.path.join(orbitize.DATADIR, 'temp_test_orbitize_input.csv')
    # If temp output file already exists, delete it
    if os.path.isfile(output_file):
        os.remove(output_file)
    try:  # Catch these tests so that we remove temporary file
        # Test that we were able to write the table
        write_orbitize_input(test_table,output_file)
        assert os.path.isfile(output_file)
        # Test that we can read the table and check if it's correct
        test_table_2 = read_file(output_file)
        _compare_table(test_table_2)
    finally:
        # Remove temporary file
        os.remove(output_file)