-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fov table joins added #143
Draft
NucleonGodX
wants to merge
7
commits into
sunpy:main
Choose a base branch
from
NucleonGodX:soar-fov
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a901667
fov table joins added
NucleonGodX 18476b2
added table fetching ability for fov coordinates
NucleonGodX a3ee671
Merge branch 'sunpy:main' into soar-fov
NucleonGodX 0ee1122
fov example added
NucleonGodX c6e75f0
Apply suggestions from code review
NucleonGodX ddffa89
suggested changes applied
NucleonGodX 31150c1
incorrect fov raises warning
NucleonGodX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
""" | ||
======================================== | ||
Retrieve and Plot Field of View on a map | ||
======================================== | ||
|
||
This example demonstrates how to fetch Solar Orbiter's Field of View (FOV) for each instrument values | ||
and Solar Orbiter data using `sunpy.net.Fido` and plot them on a `sunpy.map.Map`. | ||
""" | ||
|
||
import astropy.units as u | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import sunpy.map | ||
import sunpy.net.attrs as a | ||
from astropy.coordinates import SkyCoord | ||
from sunpy.coordinates import frames | ||
from sunpy.net import Fido | ||
|
||
##################################################### | ||
# Importing sunpy_soar registers the client with sunpy | ||
import sunpy_soar # NOQA: F401 | ||
|
||
##################################################### | ||
# We'll begin by constructing a search query for the Field of View (FOV). | ||
# In this example, we'll use the instrument EUI and set the perspective to that of Earth's field of view. | ||
|
||
instrument = a.Instrument("EUI") | ||
time = a.Time("2022-10-13 12:06:00", "2022-10-13 12:06:10") | ||
level = a.Level(2) | ||
detector = a.Detector("HRI_EUV") | ||
product = a.soar.Product("eui-hrieuv174-image") | ||
fov = a.soar.FOV("earth") | ||
|
||
##################################################### | ||
# Now we will do the search. | ||
|
||
result = Fido.search(instrument & time & level & detector & product & fov) | ||
|
||
##################################################### | ||
# To plot the FOV, we need a map to overlay them on to. | ||
# For this we will create a blank map as the base. | ||
|
||
data = np.full((10, 10), np.nan) | ||
skycoord = SkyCoord( | ||
0 * u.arcsec, 0 * u.arcsec, obstime="2022-10-13 12:06:00", observer="earth", frame=frames.Helioprojective | ||
) | ||
header = sunpy.map.make_fitswcs_header(data, skycoord, scale=[220, 220] * u.arcsec / u.pixel) | ||
blank_map = sunpy.map.Map(data, header) | ||
|
||
##################################################### | ||
# Now we need to extract the FOV coordinates from search results. | ||
|
||
fov_earth_bot_left_tx = result[0]["fov_earth_left_arcsec_tx"][0] * u.arcsec | ||
fov_earth_bot_left_ty = result[0]["fov_earth_left_arcsec_ty"][0] * u.arcsec | ||
fov_earth_top_right_tx = result[0]["fov_earth_right_arcsec_tx"][0] * u.arcsec | ||
fov_earth_top_right_ty = result[0]["fov_earth_right_arcsec_ty"][0] * u.arcsec | ||
|
||
# Ensure correct ordering of coordinates | ||
bottom_left_tx = min(fov_earth_bot_left_tx, fov_earth_top_right_tx) | ||
bottom_left_ty = min(fov_earth_bot_left_ty, fov_earth_top_right_ty) | ||
top_right_tx = max(fov_earth_bot_left_tx, fov_earth_top_right_tx) | ||
top_right_ty = max(fov_earth_bot_left_ty, fov_earth_top_right_ty) | ||
|
||
##################################################### | ||
# To plot the corners of the corners of the FOVs, we need turn them into a `~astropy.coordinates.SkyCoord`. | ||
|
||
earth_fov_bottom_left = SkyCoord(bottom_left_tx, bottom_left_ty, frame=blank_map.coordinate_frame) | ||
earth_fov_top_right = SkyCoord(top_right_tx, top_right_ty, frame=blank_map.coordinate_frame) | ||
|
||
# Plot the blank map and the FOV. | ||
fig = plt.figure() | ||
ax = fig.add_subplot(projection=blank_map) | ||
blank_map.plot(axes=ax) | ||
blank_map.draw_limb(axes=ax, color="k") | ||
blank_map.draw_grid(axes=ax, color="k") | ||
|
||
# Draw the FOV as a quadrangle | ||
blank_map.draw_quadrangle(earth_fov_bottom_left, top_right=earth_fov_top_right, axes=ax, edgecolor="blue") | ||
|
||
# Set title and show legend | ||
ax.set_title("Fields of View on Blank Map") | ||
ax.legend() | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quadrangle was distorting, due to the coordinate values.
This code fixed that.
or maybe I am doing something wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the values returned from all of
fov_earth
variables.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like the wrong values to for each pair.
Can you check we got the values from the SOAR correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are the values I get from the SOAR, maybe I am missing something in the plotting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The numbers for fov_earth_bot_left_tx and fov_earth_top_right_tx are reversed.
I assume that's on our side?
What is strange is that those top right values look like the values of the left edge.
Can you double check the example from the issue to make sure we are getting the correct values?
Something is up but I dont know what exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we have just discussed, this is probably because on 2022-10-13T12 (date of the example code) the Earth-Sun-SO angle was 109°, so the SO FOV was on the far side of the Sun seen from Earth. It appears that SOAR converts the bottom left and top right (θx, θy) helioprojective coordinates of the corners of the field of view seen from SO (assuming 0° roll) to Earth view, dropping the 3rd coordinate and not taking into account what is visible from Earth or not.