-
Notifications
You must be signed in to change notification settings - Fork 3
Added vector polar plotting #1
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -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) | ||
|
Owner
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. The |
||
| 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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): | ||||||
|
Owner
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.
Suggested change
|
||||||
| """ | ||||||
|
|
||||||
| :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: | ||||||
|
Owner
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.
Suggested change
|
||||||
| plot_boundary_box(lompe, ax, apex, scan_time) | ||||||
|
|
||||||
| if save is True: | ||||||
|
Owner
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.
Suggested change
|
||||||
| 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): | ||||||
| """ | ||||||
|
|
||||||
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.
These got accidentally removed