Example #1
0
def test_create_from_socet_lis():
    socetlis = get_path('socet_isd.lis')
    socetell = get_path('ellipsoid.ell')
    js = json.loads(socetset_keywords_to_json(socetlis))
    assert isinstance(js, dict)  # This is essentially a JSON linter
    # Manually validated
    assert 'RECTIFICATION_TERMS' in js.keys()
    assert 'SEMI_MAJOR_AXIS' in js.keys()  # From ellipsoid file
    assert 'NUMBER_OF_EPHEM' in js.keys()
    assert len(js['EPHEM_PTS']) / 3 == js['NUMBER_OF_EPHEM']
Example #2
0
def gxp_expected_gpf():
    dtype_dict = {
        'point_id': 'str',
        'use': 'int32',
        'point_type': 'int32',
        'lat_Y_North': 'float64',
        'long_X_East': 'float64',
        'ht': 'float64',
        'sig0': 'float64',
        'sig1': 'float64',
        'sig2': 'float64',
        'res0': 'float64',
        'res1': 'float64',
        'res2': 'float64',
        'eigenval0': 'float64',
        'eigenvec0_i': 'float64',
        'eigenvec0_j': 'float64',
        'eigenvec0_k': 'float64',
        'eigenval1': 'float64',
        'eigenvec1_i': 'float64',
        'eigenvec1_j': 'float64',
        'eigenvec1_k': 'float64',
        'eigenval2': 'float64',
        'eigenvec2_i': 'float64',
        'eigenvec2_j': 'float64',
        'eigenvec2_k': 'float64'
    }
    return pd.read_csv(get_path('GXP_example_gpf.csv'), dtype=dtype_dict)
Example #3
0
    def test_file_to_list(self):
        truth = [
            'AS15-M-0295_SML.png', 'AS15-M-0296_SML.png',
            'AS15-M-0297_SML.png', 'AS15-M-0298_SML.png',
            'AS15-M-0299_SML.png', 'AS15-M-0300_SML.png'
        ]

        self.assertEqual(utils.file_to_list(get_path('pngs.lis')), truth)
Example #4
0
def mock_requests_post(*args, **kwargs):
    class MockResponse:
        def __init__(self, json_data, status_code):
            self.json_data = json_data
            self.status_code = status_code

        def json(self):
            return self.json_data

    if 'mars_reconnaissance_orbiter' in args[0]:
        with open(get_path('ctx.response'), 'r') as f:
            resp = json.load(f)
        return MockResponse(resp, 200)

    return MockResponse(None, 404)
Example #5
0
def insight_expected_gpf():
    dtype_dict = {
        'point_id': 'str',
        'stat': 'int32',
        'known': 'int32',
        'lat_Y_North': 'float64',
        'long_X_East': 'float64',
        'ht': 'float64',
        'sig0': 'float64',
        'sig1': 'float64',
        'sig2': 'float64',
        'res0': 'float64',
        'res1': 'float64',
        'res2': 'float64'
    }
    return pd.read_csv(get_path('InSightE08_XW.csv'), dtype=dtype_dict)
Example #6
0
import pandas as pd
import pvl

from plio.io import io_controlnetwork
from plio.io import ControlNetFileV0002_pb2 as cnf
from plio.utils.utils import find_in_dict

from plio.examples import get_path

import pytest

sys.path.insert(0, os.path.abspath('..'))


@pytest.mark.parametrize(
    'cnet_file', (get_path('apollo_out.net'), get_path('apollo_out_v5.net')))
def test_cnet_read(cnet_file):
    df = io_controlnetwork.from_isis(cnet_file)
    assert len(df) == find_in_dict(df.header, 'NumberOfMeasures')
    assert isinstance(df, io_controlnetwork.IsisControlNetwork)
    assert len(df.groupby('id')) == find_in_dict(df.header, 'NumberOfPoints')
    for proto_field, mangled_field in io_controlnetwork.IsisStore.point_field_map.items(
    ):
        assert proto_field not in df.columns
        assert mangled_field in df.columns
    for proto_field, mangled_field in io_controlnetwork.IsisStore.measure_field_map.items(
    ):
        assert proto_field not in df.columns
        assert mangled_field in df.columns

Example #7
0
 def test_read(self):
     d = io_json.read_json(get_path('logging.json'))
     self.assertIn('handlers', d.keys())
Example #8
0
 def test_read(self):
     d = io_json.read_json(get_path('logging.json'))
     self.assertIn('handlers', d.keys())
 def setUp(self):
     self.examplefile = get_path('SP_2C_03_04184_N187_E0053.spc')
     self.examplelabel = get_path('SP_2C_03_04184_N187_E0053.lbl')
Example #10
0
    def test_file_to_list(self):
        truth = ['AS15-M-0295_SML.png', 'AS15-M-0296_SML.png',
                 'AS15-M-0297_SML.png', 'AS15-M-0298_SML.png',
                 'AS15-M-0299_SML.png', 'AS15-M-0300_SML.png']

        self.assertEqual(utils.file_to_list(get_path('pngs.lis')), truth)
 def test_generate_serial_number(self):
     label = get_path('Test_PVL.lbl')
     serial = isis_serial_number.generate_serial_number(label)
     self.assertEqual('APOLLO15/METRIC/1971-07-31T14:02:27.179', serial)
 def setUp(self):
     self.examplefile = get_path('SP_2C_02_02358_S138_E3586.spc')
Example #13
0
 def test_setup_yaml(self):
     log.setup_logging(path=get_path('logging.yaml'))
     logger = logging.getLogger(__name__)
     self.assertEqual(logger.root.level, logging.DEBUG)
Example #14
0
def insight_expected_ipf():
    return pd.read_csv(get_path('P20_008845_1894_XN_09N203W.csv'))
Example #15
0
def insight_ipf():
    return get_path('P20_008845_1894_XN_09N203W.ipf')
Example #16
0
def insight_expected_gpf():
    return pd.read_csv(get_path('InSightE08_XW.csv'))
Example #17
0
 def test_setup_yaml(self):
     log.setup_logging(path=get_path('logging.yaml'))
     logger = logging.getLogger(__name__)
     self.assertEqual(logger.root.level, logging.DEBUG)
Example #18
0
 def setUp(self):
     self.examplefile = get_path('CL5_398645626CCS_F0030004CCAM02013P3.csv')
Example #19
0
def label(request):
    return get_path(request.param)
def label(request):
    return get_path(request.param)
Example #21
0
        fl = f.readlines()

    with open(file) as f:
        fs = f.readlines()
    
    # Quick check to make sure that length of GPF files matches
    #  otherwise, the test that follows will be invalid
    assert len(fl) == len(fs)

    # Test that every 5th line (the lines containing the point ID and integer flags) matches
    for i in range(3,len(fs),5):
        assert fs[i] == fl[i]
'''


@pytest.mark.parametrize('gpf', [get_path('InSightE08_string_id.gpf')])
def test_gpf_dtypes(gpf):
    """
    This test makes sure that a GPF whose point IDs only contain numbers
    are always treated as strings after they're read in.
    """
    # Read the GPF file under test into a pandas dataframe
    df = read_gpf(gpf)

    # Truth list of column data types
    truth_dtypes = [
        'O', 'int32', 'int32', 'float64', 'float64', 'float64', 'float64',
        'float64', 'float64', 'float64', 'float64', 'float64'
    ]

    # Test list of column data types
 def setUp(self):
     self.examplefile = get_path('SP_2C_03_04184_N187_E0053.spc')
     self.examplelabel = get_path('SP_2C_03_04184_N187_E0053.lbl')
Example #23
0
def insight_gpf():
    return get_path('InSightE08_XW.gpf')
def apollo_cnet():
    return get_path('apollo_out.net')
Example #25
0
def gxp_gpf():
    return get_path('GXP_example_gpf.gpf')
 def setUp(self):
     self.examplefile = get_path('SP_2C_02_02358_S138_E3586.spc')
Example #27
0
def example_str_id_gpf():
    return get_path('InSightE08_string_id.gpf')
Example #28
0
 def test_read(self):
     d = io_yaml.read_yaml(get_path('logging.yaml'))
     self.assertIn('handlers', d.keys())
Example #29
0
 def setUp(self):
     self.dataset = io_gdal.GeoDataset(get_path('Mars_MGS_MOLA_ClrShade_MAP2_0.0N0.0_MERC.tif'))
Example #30
0
 def test_read(self):
     d = io_yaml.read_yaml(get_path('logging.yaml'))
     self.assertIn('handlers', d.keys())
Example #31
0
def header():
    return pvl.load(get_path('ctx.pvl'))
Example #32
0
 def setUp(self):
     self.examplefile = get_path('pos10001.tab')
Example #33
0
 def setUp(self):
     self.dataset = io_gdal.GeoDataset(
         get_path('Mars_MGS_MOLA_ClrShade_MAP2_90.0N0.0_POLA.tif'))
Example #34
0
 def setUp(self):
     self.dataset = io_gdal.GeoDataset(get_path('Lunar_LRO_LOLA_Shade_MAP2_90.0N20.0_LAMB.tif'))
 def test_generate_serial_number(self):
     label = get_path('Test_PVL.lbl')
     serial = isis_serial_number.generate_serial_number(label)
     self.assertEqual('APOLLO15/METRIC/1971-07-31T14:02:27.179', serial)
Example #36
0
 def setUp(self):
     self.examplefile = get_path('pos10001.tab')
Example #37
0
 def setUp(self):
     self.dataset = io_gdal.GeoDataset(
         get_path('Lunar_LRO_LOLA_Shade_MAP2_90.0N20.0_LAMB.tif'))