-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Adds ability to plot Pfsspy field lines #12
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
60f6cb5
pfsspy experimentation
jeffreypaul15 8f8e623
pfsspy experimentation
jeffreypaul15 e40977c
Functionality to play field lines
jeffreypaul15 1e648ab
Functionality to play field lines
jeffreypaul15 67dba43
edited example docstring
jeffreypaul15 5b76d0b
updated setup.cfg
jeffreypaul15 2f0202c
codestyle
jeffreypaul15 b1b563d
kwargs to plot_field_lines
jeffreypaul15 a98b05f
Apply suggestions from code review
jeffreypaul15 667f417
updated method to accept only one argument
jeffreypaul15 2c47e9d
updated method to accept only one argument
jeffreypaul15 418dd09
Merge branch 'pfsspy' of https://github.com/jeffreypaul15/sunkit-pyvi…
jeffreypaul15 5e6968a
merge changes from origin
jeffreypaul15 2b65f5b
rebase
jeffreypaul15 13e821d
added colours for field lines
jeffreypaul15 3fd9de8
Apply comment suggestions from code review
jeffreypaul15 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 @@ | ||
Added :meth:`~sunkit_pyvista.plotter.SunpyPlotter.plot_field_lines` method which allows for plotting of magnetic field lines from `pfsspy` through pyvista. |
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,62 @@ | ||
""" | ||
================================ | ||
Plotting Field Lines from pfsspy | ||
================================ | ||
|
||
sunkit-pyvista can be used to plot field lines from `pfsspy`. | ||
""" | ||
|
||
import numpy as np | ||
import pfsspy | ||
from pfsspy import tracing | ||
from pfsspy.sample_data import get_gong_map | ||
|
||
import astropy.units as u | ||
from astropy.constants import R_sun | ||
from astropy.coordinates import SkyCoord | ||
from sunpy.data.sample import AIA_193_IMAGE | ||
from sunpy.map import Map | ||
|
||
from sunkit_pyvista import SunpyPlotter | ||
|
||
############################################################################### | ||
# We will firstly use an AIA 193 image from the sunpy sample data as the base image. | ||
m = Map(AIA_193_IMAGE) | ||
|
||
# Start by creating a plotter | ||
plotter = SunpyPlotter() | ||
|
||
# Plot a map | ||
plotter.plot_map(m) | ||
# Add an arrow to show the solar rotation axis | ||
plotter.plot_solar_axis() | ||
|
||
# We load a gong_map from pfsspy | ||
gong_fname = get_gong_map() | ||
gong_map = Map(gong_fname) | ||
|
||
# Define the number of grid points in rho and solar surface rarius | ||
nrho = 35 | ||
rss = 2.5 | ||
|
||
# Create 5 points spaced between lat={-90, 90} degrees | ||
lat = np.linspace(-np.pi / 2, np.pi / 2, 8, endpoint=False) | ||
# Create 5 points spaced between long={0, 180} degrees | ||
lon = np.linspace(0, 2 * np.pi, 8, endpoint=False) | ||
# Make a 2D grid from these 1D points | ||
lat, lon = np.meshgrid(lat, lon, indexing='ij') | ||
# Create lon, lat and radial coordinate values by using a pfsspy | ||
# and trace them using tracer | ||
lat, lon = lat.ravel() * u.rad, lon.ravel() * u.rad | ||
radius = 1.2 | ||
tracer = tracing.PythonTracer() | ||
input_ = pfsspy.Input(gong_map, nrho, rss) | ||
output_ = pfsspy.pfss(input_) | ||
seeds = SkyCoord(lon, lat, radius*R_sun, | ||
frame=gong_map.coordinate_frame) | ||
field_lines = tracer.trace(seeds, output_) | ||
|
||
# We plot the field lines | ||
plotter.plot_field_lines(field_lines) | ||
|
||
plotter.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
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.
This will be an issue if the AIA map and the GONG map were not taken at the same time. I will see if I can add a GONG map to the pfsspy sample data that is taken at the same observation date as the AIA map. Lets not block this PR on this point, but we should fix it before releasing the package!
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.
Oh okay, yes