Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1783,15 +1783,18 @@
"plot_sun_body_line = False # plot straight line between Sun and body\n",
"transparent = False # make output figure background transparent\n",
"markers = 'numbers' # use 'numbers' or 'letters' for the body markers (use False for colored squares)\n",
"coord_sys='Stonyhurst' # 'Carrington' (default) or 'Stonyhurst'\n",
"fix_earth=True # if True, Earth is always at a fixed longitude position. If False, the plot is oriented with 0° fixed. \n",
"\n",
"for i in range(2,19,1): \n",
" j = str(i).rjust(2, '0')\n",
" date = f'2022-6-{j} 12:00:00'\n",
" filename = f'animate_{date[:-9]}.png' # define filename of output figure\n",
"\n",
" sm7 = SolarMACH(date=date, body_list=body_list, vsw_list=vsw_list, coord_sys='Stonyhurst')\n",
" sm7 = SolarMACH(date=date, body_list=body_list, vsw_list=vsw_list, coord_sys=coord_sys)\n",
" sm7.plot(plot_spirals=plot_spirals,\n",
" plot_sun_body_line=plot_sun_body_line,\n",
" fix_earth=fix_earth,\n",
" transparent=transparent,\n",
" markers=markers,\n",
" outfile=filename\n",
Expand Down Expand Up @@ -1824,7 +1827,7 @@
"source": [
"Build an animated GIF out of these files using `imageio`. \n",
"\n",
"Note: Using `coord_sys'=Carrington'` above may lead to unexpected behavior while generating the GIF. It's advised to use `coord_sys='Stonyhurst'` for this purpose."
"Note: The `fix_earth` option above should be changed according to the used coordinate system. For `coord_sys'=Carrington'`, you should use `fix_earth=False`; for `coord_sys='Stonyhurst'` `fix_earth=True`. Otherwise the coordinate systems will be mixed up in the animation."
]
},
{
Expand Down
10 changes: 8 additions & 2 deletions solarmach/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ def plot(self, plot_spirals=True,
transparent=False,
markers=False,
return_plot_object=False,
fix_earth=True,
long_offset=270,
outfile='',
figsize=(12, 8),
Expand Down Expand Up @@ -621,8 +622,10 @@ def plot(self, plot_spirals=True,
if defined, body markers contain 'numbers' or 'letters' for better identification. If False (default), only geometric markers are used.
return_plot_object : bool, optional
if True, figure and axis object of matplotib are returned, allowing further adjustments to the figure
fix_earth : bool, optional
if True (default), Earth is always at the defined long_offset position (by default "6 o'clock", i.e., 270°). If False, the plot is oriented with 0° at the position defined with long_offset.
long_offset : int or float, optional
longitudinal offset for polar plot; defines where Earth's longitude is (by default 270, i.e., at "6 o'clock")
longitudinal offset for polar plot; defines for fix_earth=True (default) where Earth's longitude is (by default 270, i.e., at "6 o'clock"). For fix_earth=False it defines where 0° is located.
outfile : string, optional
if provided, the plot is saved with outfile as filename. supports png and pdf format.
long_sector : list of 2 numbers, optional
Expand Down Expand Up @@ -681,7 +684,10 @@ def plot(self, plot_spirals=True,

rlabel_pos = E_long + 120
ax.set_rlabel_position(rlabel_pos)
ax.set_theta_offset(np.deg2rad(long_offset - E_long))
if fix_earth:
ax.set_theta_offset(np.deg2rad(long_offset - E_long))
elif not fix_earth:
ax.set_theta_offset(np.deg2rad(long_offset))
ax.yaxis.get_major_locator().base.set_params(nbins=4)
circle = plt.Circle((0., 0.),
self.max_dist + 0.29,
Expand Down
Binary file removed solarmach/tests/baseline/test_solarmach_plot.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions solarmach/tests/figure_hashes_mpl_391.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"solarmach.tests.test.test_solarmach_plot": "53086961f48868f8d686c28258dbd53d58a99e4bbd9d250c288f585dc0df8f9b",
"solarmach.tests.test.test_solarmach_pfss": "ee9c8886e831b834c79da3a3078d1a9bb0845217b4c6217d48c7d4cbdb34d723"
"solarmach.tests.test.test_solarmach_plot[Carrington-numbers-True-270]": "340c9cd49b5b4b167bca92b832e693d1087c5b87ceedf1d52d00e0119c68b121",
"solarmach.tests.test.test_solarmach_plot[Stonyhurst-letters-False-0]": "802af17af20c79b80c7e35b8262b194de6053eb6188f2b3f494d991dafe09e01",
"solarmach.tests.test.test_solarmach_pfss": "3e1397b7e555862d47419969d2f762201e7d71d5cf79fff7cc8ac9a35f51b828"
}
9 changes: 5 additions & 4 deletions solarmach/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ def test_solarmach_wrong_datetime_format():
"""


@pytest.mark.mpl_image_compare(hash_library=Path(__file__).parent / 'figure_hashes_mpl_391.json', deterministic=True)
@pytest.mark.parametrize("coord_sys, markers, fix_earth, long_offset", [('Carrington', 'numbers', True, 270), ('Stonyhurst', 'letters', False, 0)])
# @pytest.mark.mpl_image_compare(hash_library=Path(__file__).parent / 'figure_hashes_mpl_391.json', deterministic=True)
@pytest.mark.filterwarnings("ignore:FigureCanvasAgg is non-interactive, and thus cannot be shown:UserWarning:solarmach")
def test_solarmach_plot():
def test_solarmach_plot(coord_sys, markers, fix_earth, long_offset):
body_list = ['STEREO-A']
vsw_list = [400]
date = '2021-10-28 15:15:00'
Expand All @@ -131,10 +132,10 @@ def test_solarmach_plot():
long_sector_color='red'
background_spirals=[6, 600]

sm = SolarMACH(date=date, body_list=body_list, vsw_list=vsw_list, reference_long=reference_long, reference_lat=reference_lat)
sm = SolarMACH(date=date, body_list=body_list, vsw_list=vsw_list, reference_long=reference_long, reference_lat=reference_lat, coord_sys=coord_sys)
fig, ax = sm.plot(plot_spirals=True, plot_sun_body_line=True,
reference_vsw=reference_vsw, transparent=False,
show_earth_centered_coord=False, markers='numbers',
markers=markers, fix_earth=fix_earth,
long_sector=long_sector, long_sector_vsw=long_sector_vsw, long_sector_color=long_sector_color,
background_spirals=background_spirals, outfile=filename, return_plot_object=True)
assert os.path.exists(os.getcwd()+os.sep+filename)
Expand Down