def test_differential_rotate(aia171_test_map, all_off_disk_map, all_on_disk_map, straddles_limb_map): # Test a map that is entirely off the disk of the Sun # Should report an error with pytest.raises(ValueError): dmap = differential_rotate(all_off_disk_map) # Test a full disk map new_observer = get_earth(aia171_test_map.date + 6 * u.hr) dmap = differential_rotate(aia171_test_map, observer=new_observer) assert dmap.data.shape == aia171_test_map.data.shape # Test a map that is entirely on disk - triggers sub full disk branches # Rotated map should have a smaller extent in the x - direction new_observer = get_earth(all_on_disk_map.date - 48 * u.hr) dmap = differential_rotate(all_on_disk_map, observer=new_observer) assert dmap.data.shape[1] < all_on_disk_map.data.shape[1] # This rotated map should have a larger extent in the x direction new_observer = get_earth(all_on_disk_map.date + 48 * u.hr) dmap = differential_rotate(all_on_disk_map, observer=new_observer) assert dmap.data.shape[1] > all_on_disk_map.data.shape[1] # Test a map that straddles the limb - triggers sub full disk branches # Rotated map should have a smaller extent in the x - direction new_observer = get_earth(straddles_limb_map.date + 48 * u.hr) dmap = differential_rotate(straddles_limb_map, observer=new_observer) assert dmap.data.shape[1] < straddles_limb_map.data.shape[1] # The output map should have the positional properties of the observer assert dmap.date == new_observer.obstime assert dmap.heliographic_latitude == new_observer.lat assert dmap.heliographic_longitude == new_observer.lon
def test_differential_rotate(aia171_test_map, all_off_disk_map, all_on_disk_map, straddles_limb_map): # Test a map that is entirely off the disk of the Sun # Should report an error with pytest.raises(ValueError): dmap = differential_rotate(all_off_disk_map) # Test a full disk map new_observer = get_earth(aia171_test_map.date + 6*u.hr) dmap = differential_rotate(aia171_test_map, observer=new_observer) assert dmap.data.shape == aia171_test_map.data.shape # Test a map that is entirely on disk - triggers sub full disk branches # Rotated map should have a smaller extent in the x - direction new_observer = get_earth(all_on_disk_map.date - 48*u.hr) dmap = differential_rotate(all_on_disk_map, observer=new_observer) assert dmap.data.shape[1] < all_on_disk_map.data.shape[1] # This rotated map should have a larger extent in the x direction new_observer = get_earth(all_on_disk_map.date + 48*u.hr) dmap = differential_rotate(all_on_disk_map, observer=new_observer) assert dmap.data.shape[1] > all_on_disk_map.data.shape[1] # Test a map that straddles the limb - triggers sub full disk branches # Rotated map should have a smaller extent in the x - direction new_observer = get_earth(straddles_limb_map.date + 48*u.hr) dmap = differential_rotate(straddles_limb_map, observer=new_observer) assert dmap.data.shape[1] < straddles_limb_map.data.shape[1] # The output map should have the positional properties of the observer assert dmap.date == new_observer.obstime assert dmap.heliographic_latitude == new_observer.lat assert dmap.heliographic_longitude == new_observer.lon
def test_differential_rotate_observer_all_on_disk(all_on_disk_map): # Test a map that is entirely on disk - triggers sub full disk branches # Rotated map should have a smaller extent in the x - direction new_observer = get_earth(all_on_disk_map.date - 48 * u.hr) dmap = differential_rotate(all_on_disk_map, observer=new_observer) assert dmap.data.shape[1] < all_on_disk_map.data.shape[1] # This rotated map should have a larger extent in the x direction new_observer = get_earth(all_on_disk_map.date + 48 * u.hr) dmap = differential_rotate(all_on_disk_map, observer=new_observer) assert dmap.data.shape[1] > all_on_disk_map.data.shape[1] assert dmap.date.isot == new_observer.obstime.isot assert dmap.heliographic_latitude == new_observer.lat assert dmap.heliographic_longitude == new_observer.lon
def test_differential_rotate_time_all_on_disk(all_on_disk_map): # Test a map that is entirely on disk - triggers sub full disk branches # Rotated map should have a smaller extent in the x - direction new_time = all_on_disk_map.date - 48*u.hr with pytest.warns(UserWarning, match="Using 'time' assumes an Earth-based observer"): dmap = differential_rotate(all_on_disk_map, time=new_time) assert dmap.data.shape[1] < all_on_disk_map.data.shape[1] # This rotated map should have a larger extent in the x direction new_time = all_on_disk_map.date + 48*u.hr with pytest.warns(UserWarning, match="Using 'time' assumes an Earth-based observer"): dmap = differential_rotate(all_on_disk_map, time=new_time) assert dmap.data.shape[1] > all_on_disk_map.data.shape[1] # The output map should have the same time as the new time now. assert dmap.date.isot == new_time.isot
def test_differential_rotate_observer_full_disk(aia171_test_map): # Test a full disk map new_observer = get_earth(aia171_test_map.date + 6 * u.hr) dmap = differential_rotate(aia171_test_map, observer=new_observer) assert dmap.data.shape == aia171_test_map.data.shape assert dmap.date.isot == new_observer.obstime.isot assert dmap.heliographic_latitude == new_observer.lat assert dmap.heliographic_longitude == new_observer.lon
def test_differential_rotate_time_full_disk(aia171_test_map): # Test a full disk map new_time = aia171_test_map.date + 6*u.hr with pytest.warns(UserWarning, match="Using 'time' assumes an Earth-based observer"): dmap = differential_rotate(aia171_test_map, time=new_time) assert dmap.data.shape == aia171_test_map.data.shape # The output map should have the same time as the new time now. assert dmap.date.isot == new_time.isot
def test_differential_rotate_time_straddles_limb(straddles_limb_map): # Test a map that straddles the limb - triggers sub full disk branches # Rotated map should have a smaller extent in the x - direction new_time = straddles_limb_map.date + 48*u.hr # Ignore some invalid NaN comparisions within astropy # (fixed in astropy 4.0.1 https://github.com/astropy/astropy/pull/9843) with np.errstate(invalid='ignore'): with pytest.warns(UserWarning, match="Using 'time' assumes an Earth-based observer"): dmap = differential_rotate(straddles_limb_map, time=new_time) assert dmap.data.shape[1] < straddles_limb_map.data.shape[1] # The output map should have the same time as the new time now. assert dmap.date.isot == new_time.isot
def test_differential_rotate_observer_straddles_limb(straddles_limb_map): # Test a map that straddles the limb - triggers sub full disk branches # Rotated map should have a smaller extent in the x - direction new_observer = get_earth(straddles_limb_map.date + 48 * u.hr) # Ignore some invalid NaN comparisons within astropy # (fixed in astropy 4.0.1 https://github.com/astropy/astropy/pull/9843) with np.errstate(invalid='ignore'): dmap = differential_rotate(straddles_limb_map, observer=new_observer) assert dmap.data.shape[1] < straddles_limb_map.data.shape[1] # The output map should have the positional properties of the observer assert dmap.date.isot == new_observer.obstime.isot assert dmap.heliographic_latitude == new_observer.lat assert dmap.heliographic_longitude == new_observer.lon
def test_differential_rotation(aia171_test_map): with pytest.warns(UserWarning, match="Using 'time' assumes an Earth-based observer"): rot_map = differential_rotate(aia171_test_map, time=2 * u.day) return rot_map.data
def test_differential_rotate_time_off_disk(all_off_disk_map): # Test a map that is entirely off the disk of the Sun # Should report an error new_time = all_off_disk_map.date + 48 * u.hr with pytest.raises(ValueError): differential_rotate(all_off_disk_map, time=new_time)
def test_differential_rotate_observer_all_off_disk(all_off_disk_map): # Test a map that is entirely off the disk of the Sun # Should report an error with pytest.raises(ValueError): differential_rotate(all_off_disk_map)
from astropy.coordinates import SkyCoord import matplotlib.pyplot as plt import os import sunpy_paper # get the data of interest and save fits files map1 = map.Map( os.path.join(sunpy_paper.data_dir, 'aia_lev1_1600a_2014_10_20t00_00_16_13z_image_lev1.fits')) map2 = map.Map( os.path.join(sunpy_paper.data_dir, 'aia_lev1_1600a_2014_10_22t00_00_16_12z_image_lev1.fits')) # rotate map at 2014-10-20 to day of 2014-10-22 rotated_map = differential_rotation.differential_rotate( map1, observer=map2.observer_coordinate) # plotting the data vmin = 50 vmax = 7000 fig = plt.figure(figsize=(8, 11)) ax1 = fig.add_subplot(3, 1, 1, projection=map1) ax2 = fig.add_subplot(3, 1, 2, projection=map2, sharex=ax1, sharey=ax1) ax3 = fig.add_subplot(3, 1, 3, projection=rotated_map, sharex=ax1, sharey=ax1) # plot maps map1.plot(vmin=vmin, vmax=vmax, axes=ax1, title='AIA 1600 $\mathrm{\AA}$') map2.plot(vmin=vmin, vmax=vmax, axes=ax2, title=False) rotated_map.plot(vmin=vmin, vmax=vmax, axes=ax3, title=False)
def test_differential_rotation(aia171_test_map): rot_map = differential_rotate(aia171_test_map, time=2 * u.day) return rot_map.data