示例#1
0
def test_get_telescope_center_xyz():
    ref_xyz = (-2562123.42683, 5094215.40141, -2848728.58869)
    ref_latlonalt = (-26.7 * np.pi / 180.0, 116.7 * np.pi / 180.0, 377.8)
    test_telescope_dict = {
        "test": {
            "center_xyz": ref_xyz,
            "latitude": None,
            "longitude": None,
            "altitude": None,
            "citation": "",
        },
        "test2": {
            "center_xyz": ref_xyz,
            "latitude": ref_latlonalt[0],
            "longitude": ref_latlonalt[1],
            "altitude": ref_latlonalt[2],
            "citation": "",
        },
    }
    telescope_obj = pyuvdata.get_telescope(
        "test", telescope_dict_in=test_telescope_dict)
    telescope_obj_ext = pyuvdata.Telescope()
    telescope_obj_ext.citation = ""
    telescope_obj_ext.telescope_name = "test"
    telescope_obj_ext.telescope_location = ref_xyz

    assert telescope_obj == telescope_obj_ext

    telescope_obj_ext.telescope_name = "test2"
    telescope_obj2 = pyuvdata.get_telescope(
        "test2", telescope_dict_in=test_telescope_dict)
    assert telescope_obj2 == telescope_obj_ext
示例#2
0
def test_get_telescope_center_xyz():
    ref_xyz = (-2562123.42683, 5094215.40141, -2848728.58869)
    ref_latlonalt = (-26.7 * np.pi / 180.0, 116.7 * np.pi / 180.0, 377.8)
    test_telescope_dict = {
        'test': {
            'center_xyz': ref_xyz,
            'latitude': None,
            'longitude': None,
            'altitude': None,
            'citation': ''
        },
        'test2': {
            'center_xyz': ref_xyz,
            'latitude': ref_latlonalt[0],
            'longitude': ref_latlonalt[1],
            'altitude': ref_latlonalt[2],
            'citation': ''
        }
    }
    telescope_obj = pyuvdata.get_telescope(
        'test', telescope_dict_in=test_telescope_dict)
    telescope_obj_ext = pyuvdata.Telescope()
    telescope_obj_ext.citation = ''
    telescope_obj_ext.telescope_name = 'test'
    telescope_obj_ext.telescope_location = ref_xyz

    assert telescope_obj == telescope_obj_ext

    telescope_obj_ext.telescope_name = 'test2'
    telescope_obj2 = pyuvdata.get_telescope(
        'test2', telescope_dict_in=test_telescope_dict)
    assert telescope_obj2 == telescope_obj_ext
示例#3
0
def test_extra_parameter_iter():
    "Test expected optional parameters."
    telescope_obj = pyuvdata.Telescope()
    extra = []
    for prop in telescope_obj.extra():
        extra.append(prop)
    for a in extra_parameters:
        a in extra, "expected attribute " + a + " not returned in extra iterator"
示例#4
0
def test_unexpected_attributes():
    "Test for extra attributes."
    telescope_obj = pyuvdata.Telescope()
    expected_attributes = required_properties + other_attributes
    attributes = [i for i in telescope_obj.__dict__.keys() if i[0] != '_']
    for a in attributes:
        nt.assert_true(a in expected_attributes,
                       msg='unexpected attribute ' + a + ' found in Telescope')
示例#5
0
def test_unexpected_parameters():
    "Test for extra parameters."
    telescope_obj = pyuvdata.Telescope()
    expected_parameters = required_parameters + extra_parameters
    attributes = [i for i in telescope_obj.__dict__.keys() if i[0] == '_']
    for a in attributes:
        nt.assert_true(a in expected_parameters,
                       msg='unexpected parameter ' + a + ' found in Telescope')
示例#6
0
def test_required_parameter_iter():
    "Test expected required parameters."
    telescope_obj = pyuvdata.Telescope()
    required = []
    for prop in telescope_obj.required():
        required.append(prop)
    for a in required_parameters:
        assert a in required, 'expected attribute ' + a + ' not returned in required iterator'
示例#7
0
def test_parameter_iter():
    "Test expected parameters."
    telescope_obj = pyuvdata.Telescope()
    all = []
    for prop in telescope_obj:
        all.append(prop)
    for a in required_parameters:
        assert a in all, 'expected attribute ' + a + ' not returned in object iterator'
示例#8
0
def test_unexpected_attributes():
    "Test for extra attributes."
    telescope_obj = pyuvdata.Telescope()
    expected_attributes = required_properties + other_attributes
    attributes = [i for i in list(telescope_obj.__dict__.keys()) if i[0] != "_"]
    for a in attributes:
        assert a in expected_attributes, (
            "unexpected attribute " + a + " found in Telescope"
        )
示例#9
0
def test_unexpected_parameters():
    "Test for extra parameters."
    telescope_obj = pyuvdata.Telescope()
    expected_parameters = required_parameters + extra_parameters
    attributes = [i for i in list(telescope_obj.__dict__.keys()) if i[0] == "_"]
    for a in attributes:
        assert a in expected_parameters, (
            "unexpected parameter " + a + " found in Telescope"
        )
示例#10
0
def test_extra_parameter_iter():
    "Test expected optional parameters."
    telescope_obj = pyuvdata.Telescope()
    extra = []
    for prop in telescope_obj.extra():
        extra.append(prop)
    for a in extra_parameters:
        nt.assert_true(a in extra,
                       msg='expected attribute ' + a +
                       ' not returned in extra iterator')
示例#11
0
def test_properties():
    "Test that properties can be get and set properly."
    telescope_obj = pyuvdata.Telescope()
    prop_dict = dict(list(zip(required_properties, required_parameters)))
    for k, v in prop_dict.items():
        rand_num = np.random.rand()
        setattr(telescope_obj, k, rand_num)
        this_param = getattr(telescope_obj, v)
        try:
            assert rand_num == this_param.value
        except (AssertionError):
            print("setting {prop_name} to a random number failed".format(prop_name=k))
            raise