def test_great_arc_points_differentiates(aia171_test_map): coordinate_frame = aia171_test_map.coordinate_frame a = SkyCoord(600 * u.arcsec, -600 * u.arcsec, frame=coordinate_frame) b = SkyCoord(-100 * u.arcsec, 800 * u.arcsec, frame=coordinate_frame) gc = GreatArc(a, b) coordinates = gc.coordinates(10) inner_angles = gc.inner_angles(11) distances = gc.distances(12) assert len(coordinates) == 10 and len(gc.coordinates()) == 100 assert len(inner_angles) == 11 and len(gc.inner_angles()) == 100 assert len(distances) == 12 and len(gc.distances()) == 100
def test_great_arc_points_differentiates(): m = sunpy.map.Map(sunpy.map.Map(sunpy.data.test.get_test_filepath('aia_171_level1.fits'))) coordinate_frame = m.coordinate_frame a = SkyCoord(600*u.arcsec, -600*u.arcsec, frame=coordinate_frame) b = SkyCoord(-100*u.arcsec, 800*u.arcsec, frame=coordinate_frame) gc = GreatArc(a, b) coordinates = gc.coordinates(10) inner_angles = gc.inner_angles(11) distances = gc.distances(12) assert len(coordinates) == 10 and len(gc.coordinates()) == 100 assert len(inner_angles) == 11 and len(gc.inner_angles()) == 100 assert len(distances) == 12 and len(gc.distances()) == 100
def test_great_arc_coordinates(points_requested, points_expected, first_point, last_point, last_inner_angle, last_distance, aia171_test_map): coordinate_frame = aia171_test_map.coordinate_frame a = SkyCoord(600 * u.arcsec, -600 * u.arcsec, frame=coordinate_frame) b = SkyCoord(-100 * u.arcsec, 800 * u.arcsec, frame=coordinate_frame) gc = GreatArc(a, b, points=points_requested) coordinates = gc.coordinates() inner_angles = gc.inner_angles() distances = gc.distances() # Ensure a GreatArc object is returned assert isinstance(gc, GreatArc) # Test the properties of the GreatArc object a_trans = a.transform_to(frames.Heliocentric) assert gc.start.x == a_trans.x assert gc.start.y == a_trans.y assert gc.start.z == a_trans.z b_trans = b.transform_to(frames.Heliocentric(observer=a.observer)) assert gc.end.x == b_trans.x assert gc.end.y == b_trans.y assert gc.end.z == b_trans.z assert gc.distance_unit == u.m assert gc.observer == a.observer assert gc.center.x == 0 * u.m assert gc.center.y == 0 * u.m assert gc.center.z == 0 * u.m assert u.allclose( gc.start_cartesian * u.m, np.asarray([428721.0913539, -428722.9051924, 341776.0910214]) * u.km) assert u.allclose( gc.end_cartesian * u.m, np.asarray([-71429.5229381, 571439.071248, 390859.5797815]) * u.km) assert u.allclose(gc.center_cartesian * u.m, np.asarray([0, 0, 0]) * u.km) assert u.allclose( gc.v1 * u.m, np.asarray([428721.0913539, -428722.9051924, 341776.0910214]) * u.km) assert u.allclose(gc._r, 696000000.0015007) assert u.allclose( gc.v2 * u.m, np.asarray([-71429.5229381, 571439.071248, 390859.5797815]) * u.km) assert u.allclose( gc.v3 * u.m, np.asarray([56761.6265851, 466230.7005856, 513637.0815867]) * u.km) # Inner angle assert gc.inner_angle.unit == u.rad np.testing.assert_almost_equal(gc.inner_angle.value, 1.8683580432741789) # Distance assert gc.distance.unit == u.m np.testing.assert_approx_equal(gc.distance.value, 1300377198.1299164) # Radius of the sphere assert gc.radius.unit == u.m assert u.isclose(gc.radius.value * u.m, 696000.000001501 * u.km) # Test the calculation of the SkyCoords # Coordinates method # Number of points assert len(coordinates) == points_expected # Start and end coordinates np.testing.assert_almost_equal(coordinates[0].Tx.value, first_point[0]) np.testing.assert_almost_equal(coordinates[0].Ty.value, first_point[1]) np.testing.assert_almost_equal(coordinates[-1].Tx.value, last_point[0]) np.testing.assert_almost_equal(coordinates[-1].Ty.value, last_point[1]) # Inner angles method # Inner angles assert len(inner_angles) == points_expected np.testing.assert_almost_equal(inner_angles[-1].value, last_inner_angle) # Distances method assert len(distances) == points_expected assert u.isclose(distances[-1].value * u.m, last_distance * u.km)
def test_great_arc_coordinates(points_requested, points_expected, first_point, last_point, last_inner_angle, last_distance): m = sunpy.map.Map( sunpy.map.Map( sunpy.data.test.get_test_filepath('aia_171_level1.fits'))) coordinate_frame = m.coordinate_frame a = SkyCoord(600 * u.arcsec, -600 * u.arcsec, frame=coordinate_frame) b = SkyCoord(-100 * u.arcsec, 800 * u.arcsec, frame=coordinate_frame) gc = GreatArc(a, b, points=points_requested) coordinates = gc.coordinates() inner_angles = gc.inner_angles() distances = gc.distances() # Ensure a GreatArc object is returned assert isinstance(gc, GreatArc) # Test the properties of the GreatArc object assert gc.start == a assert gc.end == b assert gc.distance_unit == u.km assert gc.observer == a.observer assert gc.center.x == 0 * u.km assert gc.center.y == 0 * u.km assert gc.center.z == 0 * u.km np.testing.assert_almost_equal( gc.start_cartesian, np.asarray([428721.0913539, -428722.9051924, 341776.0910214])) np.testing.assert_almost_equal( gc.end_cartesian, np.asarray([-71429.5229381, 571439.071248, 390859.5797815])) np.testing.assert_almost_equal(gc.center_cartesian, np.asarray([0, 0, 0])) np.testing.assert_almost_equal( gc.v1, np.asarray([428721.0913539, -428722.9051924, 341776.0910214])) np.testing.assert_almost_equal(gc._r, 696000.000001501) np.testing.assert_almost_equal( gc.v2, np.asarray([-71429.5229381, 571439.071248, 390859.5797815])) np.testing.assert_almost_equal( gc.v3, np.asarray([56761.6265851, 466230.7005856, 513637.0815867])) # Inner angle assert gc.inner_angle.unit == u.rad np.testing.assert_almost_equal(gc.inner_angle.value, 1.8683580432741789) # Distance assert gc.distance.unit == u.km np.testing.assert_almost_equal(gc.distance.value, 1300377.1981298963) # Radius of the sphere assert gc.radius.unit == u.km np.testing.assert_almost_equal(gc.radius.value, 696000.000001501) # Test the calculation of the SkyCoords # Coordinates method # Number of points assert len(coordinates) == points_expected # Start and end coordinates np.testing.assert_almost_equal(coordinates[0].Tx.value, first_point[0]) np.testing.assert_almost_equal(coordinates[0].Ty.value, first_point[1]) np.testing.assert_almost_equal(coordinates[-1].Tx.value, last_point[0]) np.testing.assert_almost_equal(coordinates[-1].Ty.value, last_point[1]) # Inner angles method # Inner angles assert len(inner_angles) == points_expected np.testing.assert_almost_equal(inner_angles[-1].value, last_inner_angle) # Distances method assert len(distances) == points_expected np.testing.assert_almost_equal(distances[-1].value, last_distance)
def test_great_arc_coordinates(points_requested, points_expected, first_point, last_point, last_inner_angle, last_distance): m = sunpy.map.Map(sunpy.map.Map(sunpy.data.test.get_test_filepath('aia_171_level1.fits'))) coordinate_frame = m.coordinate_frame a = SkyCoord(600*u.arcsec, -600*u.arcsec, frame=coordinate_frame) b = SkyCoord(-100*u.arcsec, 800*u.arcsec, frame=coordinate_frame) gc = GreatArc(a, b, points=points_requested) coordinates = gc.coordinates() inner_angles = gc.inner_angles() distances = gc.distances() # Ensure a GreatArc object is returned assert isinstance(gc, GreatArc) # Test the properties of the GreatArc object assert gc.start == a assert gc.end == b assert gc.distance_unit == u.km assert gc.observer == a.observer assert gc.center.x == 0 * u.km assert gc.center.y == 0 * u.km assert gc.center.z == 0 * u.km np.testing.assert_almost_equal(gc.start_cartesian, np.asarray([428721.09135385, -428722.90519236, 341776.09102756])) np.testing.assert_almost_equal(gc.end_cartesian, np.asarray([-71429.52293813, 571439.07124801, 390859.57978693])) np.testing.assert_almost_equal(gc.center_cartesian, np.asarray([0, 0, 0])) np.testing.assert_almost_equal(gc.v1, np.asarray([428721.09135385, -428722.90519236, 341776.09102756])) np.testing.assert_almost_equal(gc._r, 696000.00000451738) np.testing.assert_almost_equal(gc.v2, np.asarray([-71429.52293813, 571439.07124801, 390859.57978693])) np.testing.assert_almost_equal(gc.v3, np.asarray([56761.62657985, 466230.70058902, 513637.08158833])) # Inner angle assert gc.inner_angle.unit == u.rad np.testing.assert_almost_equal(gc.inner_angle.value, 1.8683580432741789) # Distance assert gc.distance.unit == u.km np.testing.assert_almost_equal(gc.distance.value, 1300377.1981272686) # Radius of the sphere assert gc.radius.unit == u.km np.testing.assert_almost_equal(gc.radius.value, 696000.0000045174) # Test the calculation of the SkyCoords # Coordinates method # Number of points assert len(coordinates) == points_expected # Start and end coordinates np.testing.assert_almost_equal(coordinates[0].Tx.value, first_point[0]) np.testing.assert_almost_equal(coordinates[0].Ty.value, first_point[1]) np.testing.assert_almost_equal(coordinates[-1].Tx.value, last_point[0]) np.testing.assert_almost_equal(coordinates[-1].Ty.value, last_point[1]) # Inner angles method # Inner angles assert len(inner_angles) == points_expected np.testing.assert_almost_equal(inner_angles[-1].value, last_inner_angle) # Distances method assert len(distances) == points_expected np.testing.assert_almost_equal(distances[-1].value, last_distance)