Skip to content

Commit

Permalink
adjust figure labels
Browse files Browse the repository at this point in the history
adjust figure labels
  • Loading branch information
jgieseler authored Oct 17, 2022
2 parents 6698b75 + 9342ffe commit f608632
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
28 changes: 15 additions & 13 deletions seppy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ def onset_analysis(self, df_flux, windowstart, windowlen, windowrange, channels_
ax.axvspan(avg_start, avg_end, color=color_dict['bg'],
label="Background")

ax.set_xlabel("Time (HH:MM \nYYYY-mm-dd)", fontsize=16)
# ax.set_xlabel("Time [HH:MM \nYYYY-mm-dd]", fontsize=16)
ax.set_ylabel(r"Intensity [1/(cm$^{2}$ sr s MeV)]", fontsize=16)
ax.yaxis.set_major_locator(plt.MaxNLocator(4))

Expand All @@ -931,8 +931,9 @@ def onset_analysis(self, df_flux, windowstart, windowlen, windowrange, channels_

# date tick locator and formatter
ax.xaxis_date()
ax.xaxis.set_major_locator(ticker.MaxNLocator(9))
utc_dt_format1 = DateFormatter('%H:%M \n%Y-%m-%d')
# ax.xaxis.set_major_locator(ticker.MaxNLocator(9))
# utc_dt_format1 = DateFormatter('%H:%M \n%Y-%m-%d')
utc_dt_format1 = DateFormatter('%H:%M\n%b %d\n%Y')
ax.xaxis.set_major_formatter(utc_dt_format1)

if self.species == 'e':
Expand Down Expand Up @@ -1421,12 +1422,12 @@ def dynamic_spectrum(self, view, cmap: str = 'magma', xlim: tuple = None, resamp
from seppy.tools.swaves import plot_swaves
ax[0], colormesh = plot_swaves(downloaded_files=self.radio_files, spacecraft=self.radio_spacecraft[0], start_time=t_start, end_time=t_end, ax=ax[0], cmap=cmap)

fig.tight_layout(pad=9.5, w_pad=-0.5, h_pad=-0.5)
fig.tight_layout(pad=9.5, w_pad=-0.5, h_pad=1.0)
# plt.subplots_adjust(wspace=-1, hspace=-1.8)

# Colorbar
cb = fig.colorbar(colormesh, orientation='vertical', ax=ax[0])
clabel = "Intensity"
clabel = "Intensity" + "\n" + "[dB]"
cb.set_label(clabel)

# Colormesh
Expand All @@ -1451,24 +1452,25 @@ def dynamic_spectrum(self, view, cmap: str = 'magma', xlim: tuple = None, resamp
ax[DYN_SPEC_INDX].set_ylabel(f"Energy [{y_unit}]")

# x-axis settings
ax[DYN_SPEC_INDX].set_xlabel("Time [HH:MM \nm-d]")
# ax[DYN_SPEC_INDX].set_xlabel("Time [HH:MM \nm-d]")
ax[DYN_SPEC_INDX].xaxis_date()
ax[DYN_SPEC_INDX].set_xlim(t_start, t_end)
# ax[DYN_SPEC_INDX].xaxis.set_major_locator(mdates.HourLocator(interval = 1))
utc_dt_format1 = DateFormatter('%H:%M \n%m-%d')
# utc_dt_format1 = DateFormatter('%H:%M \n%m-%d')
utc_dt_format1 = DateFormatter('%H:%M\n%b %d\n%Y')
ax[DYN_SPEC_INDX].xaxis.set_major_formatter(utc_dt_format1)
# ax.xaxis.set_minor_locator(mdates.MinuteLocator(interval = 5))

# Title
if view is not None:
title = f"{spacecraft.upper()} {instrument.upper()} ({view}) {s_identifier}, {date_of_event}"
title = f"{spacecraft.upper()}/{instrument.upper()} ({view}) {s_identifier}, {date_of_event}"
else:
title = f"{spacecraft.upper()} {instrument.upper()} {s_identifier}, {date_of_event}"
title = f"{spacecraft.upper()}/{instrument.upper()} {s_identifier}, {date_of_event}"

if self.radio_spacecraft is None:
ax[0].set_title(title)
else:
ax[0].set_title(f"Radio + Dynamic Spectrum, {title}")
ax[0].set_title(f"Radio & Dynamic Spectrum, {title}")

# saving of the figure
if save:
Expand Down Expand Up @@ -1610,11 +1612,11 @@ def tsa_plot(self, view, selection=None, xlim=None, resample=None):

# settings for y and x axes
ax.set_yscale("log")
ax.set_ylabel(r"Intensity" + "\n" + r"[1/(cm$^{2}$ sr s MeV)$^{-1}$]")
ax.set_ylabel(r"Intensity [1/(cm$^{2}$ sr s MeV)]")

ax.set_xlabel(r"$t_{0} = t - L/v$")
ax.xaxis_date()
ax.xaxis.set_major_formatter(DateFormatter('%H:%M\n%m-%d'))
ax.xaxis.set_major_formatter(DateFormatter('%H:%M\n%b %d'))

if xlim is None:
ax.set_xlim(dataframe.index[0], dataframe.index[-1])
Expand Down Expand Up @@ -1726,7 +1728,7 @@ def normalize_axes(button):

# Reset the y-axis label
if plotted_natural[0].get_visible():
ax.set_ylabel(r"Intensity" + "\n" + r"[1/(cm$^{2}$ sr s MeV)$^{-1}$]")
ax.set_ylabel(r"Intensity [1/(cm$^{2}$ sr s MeV)]")
else:
ax.set_ylabel("Intensity normalized")

Expand Down
5 changes: 3 additions & 2 deletions seppy/tools/swaves.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ def plot_swaves(downloaded_files, spacecraft, start_time, end_time, ax, cmap='in

colormesh = ax.pcolormesh(time_arr, freq[::-1], data_arr[::-1], vmin=0, vmax=0.5*np.max(data_arr), cmap=cmap)

ax.set_ylabel('Frequency (MHz)')
ax.set_xlabel('Date and time (UT)')
ax.set_ylabel('Frequency [MHz]')
# Disable xlabel here because we only use it stacked ontop particle spectrogram:
# ax.set_xlabel('Date and time (UT)')
ax.set_yscale('log')
ax.set_ylim(freq[-1], freq[0])
ax.set_yticks([0.01, 0.1, 1, 10])
Expand Down
2 changes: 1 addition & 1 deletion seppy/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from setuptools_scm import get_version
__version__ = get_version(root='..', relative_to=__file__)
except Exception:
__version__ = '0.1.2'
__version__ = '0.1.3'

0 comments on commit f608632

Please sign in to comment.