def test_coordinate_is_on_solar_disk(aia171_test_map, all_off_disk_map, all_on_disk_map, straddles_limb_map): off_disk = aia171_test_map.bottom_left_coord on_disk = aia171_test_map.center # Check for individual coordinates assert coordinate_is_on_solar_disk(on_disk) assert ~coordinate_is_on_solar_disk(off_disk) # Raise the error with pytest.raises(ValueError): coordinate_is_on_solar_disk( on_disk.transform_to(HeliographicStonyhurst)) # Check for sets of coordinates assert np.any( coordinate_is_on_solar_disk(all_coordinates_from_map(aia171_test_map))) assert np.any(~coordinate_is_on_solar_disk( all_coordinates_from_map(aia171_test_map))) assert np.all(~coordinate_is_on_solar_disk( all_coordinates_from_map(all_off_disk_map))) assert np.all( coordinate_is_on_solar_disk(all_coordinates_from_map(all_on_disk_map))) assert np.any( coordinate_is_on_solar_disk( all_coordinates_from_map(straddles_limb_map))) assert np.any(~coordinate_is_on_solar_disk( all_coordinates_from_map(straddles_limb_map)))
def test_coordinate_is_on_solar_disk(aia171_test_map, all_off_disk_map, all_on_disk_map, straddles_limb_map): off_disk = aia171_test_map.bottom_left_coord on_disk = aia171_test_map.center # Check for individual coordinates assert coordinate_is_on_solar_disk(on_disk) assert ~coordinate_is_on_solar_disk(off_disk) # Raise the error with pytest.raises(ValueError): coordinate_is_on_solar_disk(on_disk.transform_to(HeliographicStonyhurst)) # Check for sets of coordinates assert np.any(coordinate_is_on_solar_disk(all_coordinates_from_map(aia171_test_map))) assert np.any(~coordinate_is_on_solar_disk(all_coordinates_from_map(aia171_test_map))) assert np.all(~coordinate_is_on_solar_disk(all_coordinates_from_map(all_off_disk_map))) assert np.all(coordinate_is_on_solar_disk(all_coordinates_from_map(all_on_disk_map))) assert np.any(coordinate_is_on_solar_disk(all_coordinates_from_map(straddles_limb_map))) assert np.any(~coordinate_is_on_solar_disk(all_coordinates_from_map(straddles_limb_map)))
aia = sunpy.map.Map(AIA_171_IMAGE) ############################################################################### # A utility function gives us access to the helioprojective coordinate of each # pixels. We can use that to create a new array of all the coordinates # that are on the solar disk. hpc_coords = all_coordinates_from_map(aia) ############################################################################### # Now, we can create a mask from the coordinates by using another utility # function that gives us a mask that has `True` for those coordinates that are # on the solar disk. We also make a slight change to the colormap so that # masked values are shown as black instead of the default white. mask = coordinate_is_on_solar_disk(hpc_coords) palette = aia.cmap.copy() palette.set_bad('black') ############################################################################### # Finally we create a new map with our new mask. scaled_map = sunpy.map.Map(aia.data, aia.meta, mask=mask) ############################################################################### # Let's plot the results using our modified colormap. plt.figure() scaled_map.plot(cmap=palette) scaled_map.draw_limb() plt.show()
def test_functions_raise_non_frame_coords(non_helioprojective_skycoord): with pytest.raises(ValueError, match=r"ICRS, .* Helioprojective"): solar_angular_radius(non_helioprojective_skycoord) with pytest.raises(ValueError, match=r"ICRS, .* Helioprojective"): coordinate_is_on_solar_disk(non_helioprojective_skycoord)