From 4f0f8248b47f67a1ca992848ba97b582fe23b2c8 Mon Sep 17 00:00:00 2001 From: Nick Nelson Date: Mon, 12 Sep 2022 14:10:42 -0600 Subject: [PATCH 1/4] Use Mollweide Projection for Shell Slices Changed plot_Shell_Slices.py to make Mollweide plots --- post_processing/plot_Shell_Slices.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/post_processing/plot_Shell_Slices.py b/post_processing/plot_Shell_Slices.py index 96e02206..24b78217 100644 --- a/post_processing/plot_Shell_Slices.py +++ b/post_processing/plot_Shell_Slices.py @@ -65,7 +65,7 @@ ##################################### # Shell Slice from rayleigh_diagnostics import Shell_Slices -import numpy +import numpy as np import matplotlib.pyplot as plt from matplotlib import ticker, font_manager # Read the data @@ -76,22 +76,30 @@ ntheta = ss.ntheta nphi = ss.nphi costheta = ss.costheta -theta = numpy.arccos(costheta) +theta = np.arccos(costheta) - np.pi/2.0 +phi = np.arange(nphi)*2.0*np.pi/nphi - np.pi tindex =1 # All example quantities were output with same cadence. Grab second time-index from all. rindex = 0 # only output one radius -sizetuple=(8,8) +sizetuple=(12,5) vr = ss.vals[:,:,rindex,ss.lut[1],tindex] -fig, ax = plt.subplots(figsize=sizetuple) +fig = plt.figure(figsize=sizetuple) +ax = fig.add_subplot(111, projection='mollweide') -img = plt.imshow(numpy.transpose(vr), extent=[0,360,-90,90]) -ax.set_xlabel( 'Longitude') -ax.set_ylabel( 'Latitude') +plot1 = ax.pcolormesh(phi, theta, vr.transpose(), shading='auto', cmap='hot') + +ax.set_xticklabels([]) +ax.set_yticklabels([]) + +#ax.set_xlabel( 'Longitude') +#ax.set_ylabel( 'Latitude') ax.set_title( 'Radial Velocity') +plt.colorbar(plot1, label='cm/s') + plt.tight_layout() savefile = 'Shell_Slices_LatLon.pdf' print('Saving figure to: ', savefile) From 95d6490c9f8c5465c11983d0d5817e0b75a2eb57 Mon Sep 17 00:00:00 2001 From: Nick Nelson Date: Mon, 12 Sep 2022 15:13:55 -0600 Subject: [PATCH 2/4] Added shading option to pcolormesh Newer versions of matplotllib throw a warning when we use pcolormesh without adding a shading keyword. This adds shading=auto to all instances of pcolormesh --- post_processing/plot_Equatorial_Slices.py | 2 +- post_processing/rayleigh_diagnostics.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/post_processing/plot_Equatorial_Slices.py b/post_processing/plot_Equatorial_Slices.py index a968bc3e..3d60ec36 100644 --- a/post_processing/plot_Equatorial_Slices.py +++ b/post_processing/plot_Equatorial_Slices.py @@ -97,7 +97,7 @@ fig, ax = plt.subplots(figsize=(8,8)) tsize = 20 # title font size cbfsize = 10 # colorbar font size -img = ax.pcolormesh(X,Y,field,cmap='jet') +img = ax.pcolormesh(X,Y,field,cmap='jet',shading='auto') ax.axis('equal') # Ensure that x & y axis ranges have a 1:1 aspect ratio ax.axis('off') # Do not plot x & y axes diff --git a/post_processing/rayleigh_diagnostics.py b/post_processing/rayleigh_diagnostics.py index 796d1144..0c24f511 100644 --- a/post_processing/rayleigh_diagnostics.py +++ b/post_processing/rayleigh_diagnostics.py @@ -2457,9 +2457,9 @@ def plot_azav(fig,ax,field,radius,costheta,sintheta,r_bcz=0.71,mini=-1,maxi=-1,m #plt.hold(True) if (len(underlay) == 1): - img = ax.pcolormesh(yr,xr,field,cmap=mycmap) + img = ax.pcolormesh(yr,xr,field,cmap=mycmap,shading='auto') else: - img = ax.pcolormesh(yr,xr,underlay,cmap=mycmap) + img = ax.pcolormesh(yr,xr,underlay,cmap=mycmap,shading='auto') #ax.plot(r_bcz*sintheta,r_bcz*costheta,'k--',[0,1],[0,0],'k--') ax.axis('equal') ax.axis('off') From 4c37660c714447258bdf58e5c657b3039ef77b80 Mon Sep 17 00:00:00 2001 From: nicholasjnelson <48227468+nicholasjnelson@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:34:08 -0600 Subject: [PATCH 3/4] Added rasterized to control file sizes --- post_processing/plot_Equatorial_Slices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/post_processing/plot_Equatorial_Slices.py b/post_processing/plot_Equatorial_Slices.py index 3d60ec36..667f229d 100644 --- a/post_processing/plot_Equatorial_Slices.py +++ b/post_processing/plot_Equatorial_Slices.py @@ -97,7 +97,7 @@ fig, ax = plt.subplots(figsize=(8,8)) tsize = 20 # title font size cbfsize = 10 # colorbar font size -img = ax.pcolormesh(X,Y,field,cmap='jet',shading='auto') +img = ax.pcolormesh(X,Y,field,cmap='jet',shading='auto', rasterized=True) ax.axis('equal') # Ensure that x & y axis ranges have a 1:1 aspect ratio ax.axis('off') # Do not plot x & y axes From 25527463fadbbfff05ef07ab4754dc822b5c1453 Mon Sep 17 00:00:00 2001 From: nicholasjnelson <48227468+nicholasjnelson@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:35:00 -0600 Subject: [PATCH 4/4] Added rasterize to control filesize --- post_processing/plot_Shell_Slices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/post_processing/plot_Shell_Slices.py b/post_processing/plot_Shell_Slices.py index 24b78217..e2d2bd2c 100644 --- a/post_processing/plot_Shell_Slices.py +++ b/post_processing/plot_Shell_Slices.py @@ -89,7 +89,7 @@ fig = plt.figure(figsize=sizetuple) ax = fig.add_subplot(111, projection='mollweide') -plot1 = ax.pcolormesh(phi, theta, vr.transpose(), shading='auto', cmap='hot') +plot1 = ax.pcolormesh(phi, theta, vr.transpose(), shading='auto', cmap='hot', rasterized=True) ax.set_xticklabels([]) ax.set_yticklabels([])