def test_find_apparent_cloud_position_terrain():
    cloud = utils.RotatedECRPosition(*CORRECTED_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    app = utils.find_apparent_cloud_position(sat_pos, cloud,
                                             CORRECTED_LATLONH[-1])
    # no shift when terrain is as high as cloud
    np.testing.assert_allclose(app, cloud, rtol=1e-6)
def test_find_position_roundtrip():
    app_cloud = utils.RotatedECRPosition(*APPARENT_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    actual = utils.find_actual_cloud_position(sat_pos, app_cloud,
                                              CORRECTED_LATLONH[-1])
    app = utils.find_apparent_cloud_position(sat_pos, actual)
    np.testing.assert_allclose(app, app_cloud, rtol=1e-6)
def test_find_actual_cloud_position():
    app_cloud = utils.RotatedECRPosition(*APPARENT_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    actual = utils.find_actual_cloud_position(sat_pos, app_cloud,
                                              CORRECTED_LATLONH[-1])
    exp = utils.RotatedECRPosition(*CORRECTED_POS)
    np.testing.assert_allclose(actual, exp)
def test_get_solar_ecr_position():
    time = pd.Timestamp("20190726T125619-06:00")
    cloud = utils.RotatedECRPosition(*CORRECTED_POS)
    sol = utils.get_solar_ecr_position(time.value / 1e9, CORRECTED_LATLONH[0],
                                       CORRECTED_LATLONH[1])
    pos = utils.find_apparent_cloud_position(sol, cloud)
    # sun should be at same latitude at this time
    np.testing.assert_allclose(pos.to_geodetic()[1], cloud.to_geodetic()[1])
    assert pos.to_geodetic()[0] > cloud.to_geodetic()[0]
def test_find_apparent_cloud_position_on_surface():
    cloud = utils.RotatedECRPosition(*APPARENT_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    app = utils.find_apparent_cloud_position(sat_pos, cloud)
    np.testing.assert_allclose(app, cloud, rtol=1e-6)
def test_find_apparent_cloud_position():
    cloud = utils.RotatedECRPosition(*CORRECTED_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    app = utils.find_apparent_cloud_position(sat_pos, cloud)
    exp = utils.RotatedECRPosition(*APPARENT_POS)
    np.testing.assert_allclose(app, exp, rtol=1e-6)
def test_find_actual_cloud_position_no_height():
    app_cloud = utils.RotatedECRPosition(*APPARENT_POS)
    sat_pos = utils.RotatedECRPosition(*GOES17_POS)
    actual = utils.find_actual_cloud_position(sat_pos, app_cloud, 0)
    np.testing.assert_allclose(actual, app_cloud, rtol=1e-6)
def test_rotatedecrposition_from_geodetic(known_positions):
    pos = utils.RotatedECRPosition.from_geodetic(*known_positions[1])
    expected = utils.RotatedECRPosition(*known_positions[0])
    np.testing.assert_allclose(pos, expected, rtol=1e-5)