Skip to main content
Ctrl+K
SunPy
  • About
    • Our Mission
    • SunPy Project
    • Presentations
    • Community Roles
    • Meetings
    • Code of Conduct
  • Documentation
    • sunpy
    • ndcube
    • aiapy
    • drms
    • pfsspy
    • radiospectra
    • sunkit-instruments
    • sunkit-image
    • sunraster
    • sunpy-soar
    • roentgen
  • Affiliated Packages
  • Get Help
  • Contribute
  • Blog
  • About
    • Our Mission
    • SunPy Project
    • Presentations
    • Community Roles
    • Meetings
    • Code of Conduct
  • Documentation
    • sunpy
    • ndcube
    • aiapy
    • drms
    • pfsspy
    • radiospectra
    • sunkit-instruments
    • sunkit-image
    • sunraster
    • sunpy-soar
    • roentgen
  • Affiliated Packages
  • Get Help
  • Contribute
  • Blog
Logo image

sunpy 5.0.1 documentation

  • The sunpy tutorial
    • Installation
    • Units
    • Times
    • Coordinates
    • Acquiring Data
      • Finding and Downloading Data from JSOC
      • Searching the Heliophysics Event Knowledgebase
    • Maps
    • Timeseries
  • Installation
  • Example Gallery
    • Acquiring Data
      • Getting data from CDAWeb
      • Querying Metadata clients
      • Querying and loading SHARP data
      • Querying the GOES flare event list
      • Requesting cutouts of AIA images from the JSOC
    • Map
      • Comparing Map Rotation Functions
      • Creating a Composite map
      • Creating a mask for LASCO C2 data
      • Cropping a Map
      • Finding bright regions with ndimage
      • Finding contours of a map
      • Finding the brightest pixel
      • Generating a map from data array
      • Histograming map data
      • Map metadata modification
      • Masking HMI based on the intensity of AIA
      • Overplotting HMI Contours on an AIA Image
      • Plotting a Map without any Axes
      • Plotting a difference image
      • Resampling Maps
      • Rotating a Map
      • Segmenting a Map based on transformation of coordinates
    • Combining, Co-aligning, and Reprojecting Images
      • Aligning AIA and HMI Data with Reproject
      • Auto-Aligning AIA and HMI Data During Plotting
      • Creating Carrington Maps
      • Creating a Full Sun Map with AIA and EUVI
      • Reprojecting Images to Different Observers
      • Reprojecting Using a Spherical Screen
      • Reprojecting to a Map Projection with a Custom Origin
      • Rotating HMI maps so they’re not ‘upside-down’
    • Time Series
      • Creating a TimeSeries from GOES-XRS near real time data
      • Find Peaks in sunpy TimeSeries
      • Flare times on a GOES XRS plot
      • Making a power spectrum from a TimeSeries
      • Retrieving and analyzing GOES X-Ray Sensor (XRS) data
      • Smoothing of timeSeries data using convolution filters
      • The TimeSeriesMetaData class
      • Using TimeSeries
    • Coordinates, times, and units
      • AIA to STEREO coordinate conversion
      • Converting between Helioprojective and AltAz Coordinate
      • Create a Helioprojective Map from observations in the RA-DEC coordinate system
      • Drawing the AIA limb on a STEREO EUVI image
      • Extracting intensity of a map along a line
      • Getting the location of the planets
      • Getting the observer location from a Map
      • Identifying stars in a STEREO/SECCHI COR2 coronagraph image
      • Obtaining a spacecraft trajectory from JPL Horizons
      • Offsetting the north pole of a coordinate frame
      • Overplotting the position of the Venus transit
      • Setting the correct position for SOHO in a LASCO C3 Map
    • Plotting
      • Blending maps using mplcairo
      • Combining off-limb and disk maps
      • Creating a Composite Plot with Three Maps
      • Creating a visualization with ArrayAnimatorWCS
      • Drawing a latitude-longitude quadrangle
      • Drawing a rectangle on a map
      • Drawing and using a Great Arc
      • Drawing heliographic longitude and latitude lines
      • Editing the colormap and normalization of a Map
      • Fading between two maps
      • Finding Local Peaks in Solar Data
      • Fine grained Plotting Features of Map
      • How to use the LineAnimator
      • Imshow and maps coordinates
      • Loading an HMI synoptic map
      • Overlay an AIA image on a LASCO C2 coronagraph
      • Overlaying Two Maps
      • Overplotting HEK feature/event polygons on a map
      • Overplotting SRS active region locations on a magnetograms
      • Plot positions on a blank map
      • Plotting a coordinate grid
      • Plotting a map
      • Plotting a solar cycle index
      • Plotting points on a Map with WCSAxes
      • Plotting the solar equator and prime meridian
      • Plotting the solar limb
      • Set Axis Range When Plotting a Map
      • Simple Differential Rotation
      • Using the sunpy Colormaps with matplotlib
    • Differential Rotation of the Sun
      • Comparing differential-rotation models
      • Differentially rotating a coordinate
      • Differentially rotating a map
      • Overlaying differentially rotated gridlines
    • Saving and Loading Data
      • Saving and loading coordinates with asdf
      • Saving and loading sunpy Maps with FITS
      • Saving and loading sunpy Maps with asdf
    • Computer Vision Techniques
      • Edge Enhancing Coronal Loops
      • Enhancing off-disk emission
      • Finding and masking bright pixels
      • Masking out the solar disk
    • Showcase
      • HMI Showcase: Cutout
      • Reproducing the “Where is STEREO Today?” plot
      • Visualizing 3D stereoscopic images
  • How-To Guides
    • Access coordinate components
    • How to create a sunpy Map
    • Create Coordinate Objects
    • Create Custom Maps by Hand
    • Create Custom TimeSeries
    • Parse times with parse_time
    • Use the Remote Data Manager
    • Search for multiple wavelengths with Fido
    • Search the Virtual Solar Observatory (VSO)
    • Transform between coordinate frames
  • Topic Guides
    • Coordinates
      • Calculating Carrington longitude
      • Differential rotation using coordinate frames
      • Coordinates with velocity information
      • Coordinates and WCS
      • The role of rsun in coordinate transformations
    • Add a new rotation method to Map
    • Adding new data sources to Fido
    • Switching from HelioviewerClient to hvpy
    • How “HISTORY” and “COMMENT” FITS Keys are Handled in sunpy
    • Installation
    • Logging system
    • Writing a new instrument Map class
    • A Detailed Look at the TimeSeries Metadata
    • The role of “rsun” in sunpy
  • Reference
    • sunpy (sunpy)
      • self_test
      • system_info
      • print_config
    • Coordinates (sunpy.coordinates)
      • get_body_heliographic_stonyhurst
      • get_earth
      • get_horizons_coord
      • propagate_with_solar_surface
      • solar_frame_to_wcs_mapping
      • solar_wcs_frame_mapping
      • transform_with_sun_center
      • BaseHeliographic
      • GeocentricEarthEquatorial
      • GeocentricSolarEcliptic
      • Heliocentric
      • HeliocentricEarthEcliptic
      • HeliocentricInertial
      • HeliographicCarrington
      • HeliographicStonyhurst
      • Helioprojective
      • NorthOffsetFrame
      • RotatedSunFrame
      • SunPyBaseCoordinateFrame
      • get_body_heliographic_stonyhurst
      • get_earth
      • get_horizons_coord
      • angular_radius
      • sky_position
      • carrington_rotation_number
      • carrington_rotation_time
      • true_longitude
      • apparent_longitude
      • true_latitude
      • apparent_latitude
      • mean_obliquity_of_ecliptic
      • true_rightascension
      • true_declination
      • true_obliquity_of_ecliptic
      • apparent_rightascension
      • apparent_declination
      • print_params
      • B0
      • L0
      • P
      • earth_distance
      • orientation
      • get_rectangle_coordinates
      • solar_angle_equivalency
      • get_limb_coordinates
      • GreatArc
      • SunPyBaseCoordinateFrame
      • BaseHeliographic
      • HeliographicStonyhurst
      • HeliographicCarrington
      • Heliocentric
      • Helioprojective
      • HeliocentricEarthEcliptic
      • GeocentricSolarEcliptic
      • HeliocentricInertial
      • GeocentricEarthEquatorial
      • NorthOffsetFrame
      • RotatedSunFrame
      • transform_with_sun_center
      • propagate_with_solar_surface
      • hgs_to_hgc
      • hgc_to_hgs
      • hcc_to_hpc
      • hpc_to_hcc
      • hcc_to_hgs
      • hgs_to_hcc
      • hpc_to_hpc
      • hcrs_to_hgs
      • hgs_to_hcrs
      • hgs_to_hgs
      • hgc_to_hgc
      • hcc_to_hcc
      • hme_to_hee
      • hee_to_hme
      • hee_to_hee
      • hee_to_gse
      • gse_to_hee
      • gse_to_gse
      • hgs_to_hci
      • hci_to_hgs
      • hci_to_hci
      • hme_to_gei
      • gei_to_hme
      • gei_to_gei
      • solar_wcs_frame_mapping
      • solar_frame_to_wcs_mapping
    • Data (sunpy.data)
      • download_sample_data
      • manager
      • cache
      • download_all
      • get_test_filepath
      • get_test_data_filenames
      • get_dummy_map_from_header
      • write_header_file_from_image_file
      • Cache
      • DataManager
      • ParfiveDownloader
      • SqliteStorage
      • DownloaderBase
      • DownloaderError
      • ParfiveDownloader
      • StorageProviderBase
      • SqliteStorage
      • InMemStorage
    • Database (sunpy.database)
      • disable_undo
      • split_database
      • Database
      • EntryAlreadyAddedError
      • NoSuchEntryError
      • NoSuchTagError
      • NonRemovableTagError
      • EntryAlreadyStarredError
      • EntryAlreadyUnstarredError
      • EntryNotFoundError
      • TagAlreadyAssignedError
      • PartialFetchError
      • entries_from_query_result
      • entries_from_file
      • entries_from_dir
      • display_entries
      • WaveunitNotFoundError
      • WaveunitNotConvertibleError
      • JSONDump
      • FitsHeaderEntry
      • FitsKeyComment
      • Tag
      • DatabaseEntry
      • BaseCache
      • LRUCache
      • LFUCache
      • EmptyCommandStackError
      • NoSuchEntryError
      • NonRemovableTagError
      • DatabaseOperation
      • AddEntry
      • RemoveEntry
      • EditEntry
      • CommandManager
      • Starred
      • Tag
      • Path
      • DownloadTime
      • FitsHeaderEntry
    • Image processing (sunpy.image)
      • resample
      • reshape_image_to_4d_superpixel
      • add_rotation_function
      • affine_transform
    • Input/output (sunpy.io)
      • detect_filetype
      • read_file
      • read_file_header
      • write_file
      • read
      • get_header
      • write
      • read_genx
      • read_srs
      • header_to_fits
      • read
      • get_header
      • write
      • extract_waveunit
      • format_comments_and_history
      • FileHeader
      • read
      • get_header
      • write
      • read_file
      • read_file_header
      • write_file
      • detect_filetype
      • read_cdf
    • Maps (sunpy.map)
      • all_coordinates_from_map
      • all_corner_coords_from_map
      • all_pixel_indices_from_map
      • contains_coordinate
      • contains_full_disk
      • contains_limb
      • contains_solar_center
      • coordinate_is_on_solar_disk
      • extract_along_coord
      • is_all_off_disk
      • is_all_on_disk
      • map_edges
      • on_disk_bounding_coordinates
      • pixelate_coord_path
      • sample_at_coords
      • solar_angular_radius
      • CompositeMap
      • GenericMap
      • MapMetaValidationError
      • MapSequence
      • PixelPair
      • Map
      • maxwell
      • meta_keywords
      • make_fitswcs_header
      • get_observer_meta
      • make_heliographic_header
      • from_helioviewer_project
      • source_stretch
      • AIAMap
      • CORMap
      • EITMap
      • EUIMap
      • EUVIMap
      • HIMap
      • HMIMap
      • HMISynopticMap
      • KCorMap
      • LASCOMap
      • MDIMap
      • MDISynopticMap
      • RHESSIMap
      • SJIMap
      • SOTMap
      • SUVIMap
      • SWAPMap
      • SXTMap
      • TRACEMap
      • WISPRMap
      • XRTMap
    • Remote data (sunpy.net)
      • Scraper
      • Fido
      • Time
      • Instrument
      • Wavelength
      • Level
      • ExtentType
      • Sample
      • Detector
      • Resolution
      • Physobs
      • Source
      • Provider
      • AttrAnd
      • AttrOr
      • UnifiedResponse
      • UnifiedDownloaderFactory
      • VSOClient
      • VSOQueryResponseTable
      • Extent
      • Field
      • Pixels
      • Filter
      • Quicklook
      • PScale
      • EVEClient
      • GBMClient
      • GONGClient
      • GenericClient
      • LYRAClient
      • NOAAIndicesClient
      • NOAAPredictClient
      • NoRHClient
      • QueryResponse
      • RHESSIClient
      • SRSClient
      • SUVIClient
      • XRSClient
      • SatelliteNumber
      • Cutout
      • JSOCClient
      • JSOCResponse
      • Keyword
      • Notify
      • PrimeKey
      • Protocol
      • Segment
      • Series
      • Series
      • Protocol
      • Notify
      • Segment
      • PrimeKey
      • Cutout
      • Keyword
      • HEKClient
      • HEKRow
      • HEKTable
      • Contains
      • EventType
      • HEKAttr
      • HEKComparisonParamAttrWrapper
      • SpatialRegion
      • translate_results_to_query
      • vso_attribute_parse
      • H2VClient
      • get_datasets
      • get_observatory_groups
      • CDAWEBClient
      • Dataset
      • HECClient
      • HECResponse
      • Chaincode
      • MaxRecords
      • TableName
      • HelioviewerClient
      • convert_row_to_table
      • QueryResponseColumn
      • BaseQueryResponse
      • QueryResponseRow
      • QueryResponseTable
      • BaseClient
      • QueryResponse
      • GenericClient
      • and
      • or
      • Attr
      • DataAttr
      • DummyAttr
      • SimpleAttr
      • Range
      • AttrAnd
      • AttrOr
      • ValueAttr
      • AttrWalker
      • AttrComparison
      • ComparisonParamAttrWrapper
      • Scraper
    • Physics (sunpy.physics)
      • diff_rot
      • solar_rotate_coordinate
      • differential_rotate
    • Solar properties (sunpy.sun)
      • get
      • find
      • print_all
      • spectral_classification
      • au
      • mass
      • equatorial_radius
      • volume
      • surface_area
      • average_density
      • equatorial_surface_gravity
      • effective_temperature
      • luminosity
      • mass_conversion_rate
      • escape_velocity
      • sfu
      • average_angular_size
      • sidereal_rotation_rate
      • first_carrington_rotation
      • mean_synodic_period
      • interior
      • evolution
    • Time (sunpy.time)
      • find_time
      • is_time
      • is_time_equal
      • is_time_in_given_format
      • julian_centuries
      • parse_time
      • TimeRange
      • TimeTaiSeconds
      • TimeUTime
    • Timeseries (sunpy.timeseries)
      • TimeSeriesMetaData
      • GenericTimeSeries
      • TimeSeries
      • ESPTimeSeries
      • EVESpWxTimeSeries
      • GBMSummaryTimeSeries
      • XRSTimeSeries
      • LYRATimeSeries
      • NOAAIndicesTimeSeries
      • NOAAPredictIndicesTimeSeries
      • NoRHTimeSeries
      • RHESSISummaryTimeSeries
    • Utilities (sunpy.util)
      • deprecated
      • dict_keys_same
      • expand_list
      • expand_list_generator
      • find_dependencies
      • get_keywords
      • get_set_methods
      • get_width
      • hash_file
      • missing_dependencies_by_extra
      • replacement_filename
      • system_info
      • unique
      • warn_deprecated
      • warn_metadata
      • warn_user
      • MetaDict
      • NoMapsInFileError
      • SunpyDeprecationWarning
      • SunpyMetadataWarning
      • SunpyPendingDeprecationWarning
      • SunpyUserWarning
      • SunpyWarning
      • load_config
      • copy_default_config
      • print_config
      • BasicRegistrationFactory
      • NoMatchError
      • MultipleMatchError
      • ValidationFunctionError
      • parse_header
      • slugify
      • get_content_disposition
      • get_filename
      • get_system_filename
      • download_file
      • download_fileobj
      • xml_to_dict
      • node_to_dict
      • get_node_text
      • NotTextNodeError
      • Generate
      • seconddispatch
      • DatabaseEntryType
    • Visualization (sunpy.visualization)
      • axis_labels_from_ctype
      • draw_limb
      • peek_show
      • show_colormaps
      • aia_color_table
      • sswidl_lasco_color_table
      • eit_color_table
      • sxt_color_table
      • xrt_color_table
      • trace_color_table
      • sot_color_table
      • hmi_mag_color_table
      • suvi_color_table
      • rhessi_color_table
      • std_gamma_2
      • euvi_color_table
      • solohri_lya1216_color_table
      • MapSequenceAnimator
      • is_wcsaxes
      • gca_wcs
      • get_world_transform
      • default_wcs_grid
      • wcsaxes_heliographic_overlay
      • limb
      • equator
      • prime_meridian
    • Customizing sunpy
    • Troubleshooting and Bugs
    • SSWIDL/sunpy Cheat Sheet
  • Release History
    • Full Changelog
    • What’s New in sunpy 5.0?
    • What’s New in sunpy 4.1?
    • What’s New in SunPy 4.0?
    • What’s New in SunPy 3.1?
    • What’s New in SunPy 3.0?
    • What’s New in SunPy 2.1?
    • What’s New in SunPy 2.0?
    • What’s New in SunPy 1.1?
    • What’s New in SunPy 1.0?
    • What’s New in SunPy 0.9?
    • What’s New in SunPy 0.8?
  • Acknowledging or Citing SunPy
  • Known Issues
  • Current status of sub-packages
  • Developer’s Guide
  • Example Gallery
  • Coordinates, times, and units
  • Identifying stars in a STEREO/SECCHI COR2 coronagraph image

Note

Go to the end to download the full example code

Identifying stars in a STEREO/SECCHI COR2 coronagraph image#

Since the field of view in SECCHI COR2 images can span 2 to 15 solar radii, we often observe stars in these image data. In this example, we will use the Astroquery package to query the VizieR star catalog for stars observed by the Gaia satellite within the SECCHI COR2 field of view. Then we will use the coordinates framework in SunPy and AstroPy to transform the coordinates returned by VizieR into SECCHI COR2 image coordinates. As a bonus, we’ll also identify Mars.”

This requires the installation of the astroquery package, which can be installed on top of the existing sunpy conda environment: conda install -c astropy astroquery and an active internet connection.

import hvpy
import matplotlib.pyplot as plt
from astroquery.vizier import Vizier

import astropy.units as u
from astropy.coordinates import Distance, SkyCoord
from astropy.time import Time

import sunpy.map
from sunpy.coordinates import get_body_heliographic_stonyhurst
from sunpy.time import parse_time
from sunpy.util.config import get_and_create_download_dir

Let’s download a STEREO-A SECCHI COR2 image from Helioviewer.org which provide pre-processed images and load it into a Map. We download to the default sunpy download directory.

cor2_file = hvpy.save_file(hvpy.getJP2Image(parse_time('2014/05/15 07:54').datetime,
                                            hvpy.DataSource.COR2_A.value),
                           get_and_create_download_dir() + "/COR2.jp2")
cor2_map = sunpy.map.Map(cor2_file)

To efficiently search the star field, we need to know what stars are near the Sun as observed by STEREO. We need the vector that points from STEREO to the Sun. The location of STEREO in HCRS provides the Sun-to-STEREO vector.

sun_to_stereo = cor2_map.observer_coordinate.transform_to('hcrs')
INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]

We next reflect the vector to get our search vector which points from STEREO to the Sun.

stereo_to_sun = SkyCoord(-sun_to_stereo.spherical, obstime=sun_to_stereo.obstime, frame='hcrs')

Let’s look up bright stars using the Vizier search capability provided by astroquery. We will search the GAIA2 star catalog for stars with magnitude brighter than 7.

vv = Vizier(columns=['**'], row_limit=-1, column_filters={'Gmag': '<7'}, timeout=1200)
vv.ROW_LIMIT = -1
result = vv.query_region(stereo_to_sun, radius=4 * u.deg, catalog='I/345/gaia2')

Let’s see how many stars we’ve found.

print(len(result[0]))
23

Now we load all stars into an array coordinate. The reference epoch for the star positions is J2015.5,so we update these positions to the date of the COR2 observation using astropy.coordinates.SkyCoord.apply_space_motion().

tbl_crds = SkyCoord(ra=result[0]['RA_ICRS'],
                    dec=result[0]['DE_ICRS'],
                    distance=Distance(parallax=u.Quantity(result[0]['Plx'])),
                    pm_ra_cosdec=result[0]['pmRA'],
                    pm_dec=result[0]['pmDE'],
                    radial_velocity=result[0]['RV'],
                    frame='icrs',
                    obstime=Time(result[0]['Epoch'], format='jyear'))
tbl_crds = tbl_crds.apply_space_motion(new_obstime=cor2_map.date)

One of the bright features is actually Mars, so let’s also get that coordinate.

mars = get_body_heliographic_stonyhurst('mars', cor2_map.date, observer=cor2_map.observer_coordinate)
INFO: Apparent body location accounts for 1269.95 seconds of light travel time [sunpy.coordinates.ephemeris]

Let’s plot the results. The coordinates will be transformed automatically when plotted using plot_coord().

fig = plt.figure()
ax = fig.add_subplot(projection=cor2_map)

# Let's tweak the axis to show in degrees instead of arcsec
lon, lat = ax.coords
lon.set_major_formatter('d.dd')
lat.set_major_formatter('d.dd')

cor2_map.plot(axes=ax, vmin=0, vmax=600)
cor2_map.draw_limb(axes=ax)

# Plot the position of Mars
ax.plot_coord(mars, 's', color='white', fillstyle='none', markersize=12, label='Mars')
# Plot all of the stars
ax.plot_coord(tbl_crds, 'o', color='white', fillstyle='none')
ax.legend()

plt.show()
COR2-A white-light 2014-05-15 07:54:00
INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]
INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]

Total running time of the script: (0 minutes 11.401 seconds)

Download Python source code: STEREO_SECCHI_starfield.py

Download Jupyter notebook: STEREO_SECCHI_starfield.ipynb

Gallery generated by Sphinx-Gallery

previous

Getting the observer location from a Map

next

Obtaining a spacecraft trajectory from JPL Horizons

© Copyright 2023, The SunPy Community.

Code • Forum • Chat

Built with Sphinx 7.2.5.