-
-
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 feature "plot current sheet" #143
base: main
Are you sure you want to change the base?
Changes from all commits
22a9e4f
6d2ebf9
73be5da
3f83599
f91f1f9
0f3a875
93517b9
27e9951
881fbe9
6f3e509
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added a method to plot a current sheet via :meth:`~sunkit_pyvista.plotter.SunpyPlotter.plot_current_sheet`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
from astropy.visualization import AsymmetricPercentileInterval | ||
from astropy.visualization.wcsaxes import Quadrangle | ||
from matplotlib import colors | ||
from sunkit_magex.pfss.coords import strum2cart | ||
from sunpy.coordinates import HeliocentricInertial, Helioprojective | ||
from sunpy.coordinates.utils import get_rectangle_coordinates | ||
from sunpy.map.maputils import all_corner_coords_from_map | ||
|
@@ -509,6 +510,31 @@ def color_func(field_line): | |
|
||
self._add_mesh_to_dict(block_name="field_lines", mesh=spline) | ||
|
||
def plot_current_sheet(self, pfss_out, **kwargs): | ||
""" | ||
Plot current sheet "(Br=0)". | ||
|
||
Parameters | ||
---------- | ||
pfss_out : `sunkit_magex.pfss.output.Output` | ||
Magnetic field calculated by `sunkit_magex`. | ||
**kwargs : | ||
Keyword arguments are passed to `pyvista.Plotter.add_mesh`. | ||
""" | ||
sc_vect = pfss_out.grid.sc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the way we are loading the output here the same as in #72? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure but it should be looked at. I would hope we can that code instead. If we can expand the code in 72 to work for all frames and return all the surfaces, we can then change this to plot a surface based on user input. |
||
pc_vect = np.insert(pfss_out.grid.pc, 0, pfss_out.grid.pc[-1]) | ||
rg_vect = pfss_out.grid.rg | ||
coord = SkyCoord((pfss_out.input_map.meta["crval1"] * u.deg).to(u.rad), 0.0 * u.rad, frame=HeliocentricInertial) | ||
coord = coord.transform_to(self.coordinate_frame) | ||
bc_r = np.insert(pfss_out.bc[0], 0, pfss_out.bc[0][-1], axis=0) | ||
[s_arr, p_arr, r_arr] = np.meshgrid(sc_vect, pc_vect, rg_vect) | ||
x_arr, y_arr, z_arr = strum2cart(r_arr, s_arr, p_arr + coord.lon.to(u.rad).value) | ||
pfss_out_pv = pv.StructuredGrid(x_arr, y_arr, z_arr) | ||
pfss_out_pv["Br"] = bc_r.ravel("F") | ||
isos_br = pfss_out_pv.contour(isosurfaces=1, rng=[0, 0]) | ||
self.plotter.add_mesh(isos_br, **kwargs) | ||
self._add_mesh_to_dict(block_name="current_sheet", mesh=isos_br) | ||
|
||
def save(self, filepath, *, overwrite=False): | ||
""" | ||
Save all the meshes. | ||
|
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.
Is this the definition of a current sheet in a PFSS model?