From 3d995604bbbf5b26229c57806cc908c665ce5c36 Mon Sep 17 00:00:00 2001 From: bpwrs Date: Tue, 13 Jan 2026 09:36:25 -0600 Subject: [PATCH 1/2] Update plot.py plot_vecs_model_darn_grid now accepts mlt coordinates --- FBI/plotting/plot.py | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/FBI/plotting/plot.py b/FBI/plotting/plot.py index 3e48e2c..1be37ea 100644 --- a/FBI/plotting/plot.py +++ b/FBI/plotting/plot.py @@ -62,11 +62,12 @@ def plot_vecs_model_darn_grid(lompe, ax, coord='mag'): v_emag = np.delete(v_emag, hilats) v_nmag = np.delete(v_nmag, hilats) - # Rotate and scale vectors (https://github.com/SciTools/cartopy/issues/1179) - u_src_crs = v_emag / np.cos(mlats / 180 * np.pi) - v_src_crs = v_nmag - magnitude = np.sqrt(v_emag ** 2 + v_nmag ** 2) - magn_src_crs = np.sqrt(u_src_crs ** 2 + v_src_crs ** 2) + if coord == 'mag':# Rotate and scale vectors (https://github.com/SciTools/cartopy/issues/1179) + u_src_crs = v_emag / np.cos(mlats / 180 * np.pi) + v_src_crs = v_nmag + elif coord == 'mlt': + u_src_crs = v_emag + v_src_crs = v_nmag colours_norm = Normalize(vmin=0, vmax=1000) if coord == 'mag': @@ -102,6 +103,31 @@ def plot_vecs_model_darn_grid(lompe, ax, coord='mag'): # magn_src_crs_thick, v_src_crs_thick * magnitude_thick / magn_src_crs_thick, # magnitude_thick, norm=colours_norm, scale=2000, scale_units='inches', width=0.002, # headwidth=3, transform=ccrs.PlateCarree(), angles='xy', cmap='viridis', zorder=3) + elif coord == 'mlt': + mlts = apex.mlon2mlt(mlons, time) + quiv_thin = ax.quiver(mlats, mlts, v_src_crs, u_src_crs, magnitude, + norm=colours_norm, scale=2000, scale_units='inches', width=0.001, + headwidth=7, headlength=4, headaxislength=1.5, angles='xy', cmap='viridis', zorder=3) + + mlats_idx = mlats_grid[idx_in_grid].compressed() + mlons_idx = mlons_grid[idx_in_grid].compressed() + locs = [] + for this_mlat, this_mlon in zip(mlats_idx, mlons_idx): + loc = np.where((this_mlat == mlats) & ((np.floor(this_mlon) == mlons) | (np.ceil(this_mlon) == mlons))) + if loc[0]: + locs.append(loc[0]) + + u_src_crs_thick = u_src_crs[locs] + v_src_crs_thick = v_src_crs[locs] + magnitude_thick = magnitude[locs] + magn_src_crs_thick = magn_src_crs[locs] + thick_mlons = mlons[locs] + thick_mlats = mlats[locs] + + thick_mlts = apex.mlon2mlt(thick_mlons, time) + quiv_thick = ax.quiver(thick_mlats, thick_mlts, v_src_crs_thick, u_src_crs_thick, magnitude_thick, + norm=colours_norm, scale=2000, scale_units='inches', width=0.0015, + headwidth=7, headlength=4, headaxislength=1.5,angles='xy', cmap='viridis', zorder=3) else: quiv_thick = None quiv_thin = None From 3222faf6a46d0eaebcad6a56b43a7063005b0a4b Mon Sep 17 00:00:00 2001 From: bpwrs Date: Tue, 13 Jan 2026 09:40:56 -0600 Subject: [PATCH 2/2] Update plot_main.py Added function lompe_scan_plot_vecs_polar that plots the flow vectors in an mlt-mlat coordinate system, polar view --- FBI/plotting/plot_main.py | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/FBI/plotting/plot_main.py b/FBI/plotting/plot_main.py index c9c1f4e..d8918d1 100644 --- a/FBI/plotting/plot_main.py +++ b/FBI/plotting/plot_main.py @@ -52,6 +52,50 @@ def lompe_scan_plot_vectors(lompe, path=None, save=True): else: print('Allready processed: ' + save_path) +def lompe_scan_plot_vecs_polar(lompe, path, boundary=True save=True): + """ + + :param path: + :param lompe: + :param save: + :return: + """ + + scan_time = dt.datetime(lompe['scan_year'][0], lompe['scan_month'][0], lompe['scan_day'][0], lompe['scan_hour'][0], + lompe['scan_minute'][0], lompe['scan_second'][0], lompe['scan_millisec'][0]) + + if path is not None: + save_path = path + scan_time.strftime("polar_pot_%Y-%m-%d %H%M%S") + '.png' + if pathy.isfile(save_path) is False: # Check plot doesn't already exist + go = True + else: + go = False + else: + go = True + + if go is True: + # Apex coordinate stuff + apex = apexpy.Apex(scan_time, refh=300) + + # Global polar axis + ax, coord, fig = get_polar_axis(scan_time, apex) + plt.title(scan_time.strftime("%Y-%m-%d %H:%M:%S")) + + # Locations of SuperDARN data + plot_vecs_model_darn_grid(lompe, ax, apex=apex, time=scan_time, coord=coord) + + # Boundary box + if boundary=True: + plot_boundary_box(lompe, ax, apex, scan_time) + + if save is True: + plt.savefig(save_path, dpi=300, bbox_inches='tight') + plt.close('all') + return None, None, None, None + else: + return fig, ax, None, plt + else: + print('Allready processed: ' + save_path) def lompe_scan_plot_potential(lompe, path, save=True): """