Skip to content

Commit

Permalink
Merge pull request #287 from justin-richling/bad-polygon-fix
Browse files Browse the repository at this point in the history
Fix bad polygon error in plotting
  • Loading branch information
justin-richling authored Feb 26, 2024
2 parents 50c6e65 + 4f936c9 commit 4625c8a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/plotting_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,20 +723,20 @@ def make_polar_plot(wks, case_nickname, base_nickname,
levs_diff = np.unique(np.array(levelsdiff))

if len(levs) < 2:
img1 = ax1.contourf(lons, lats, d1_cyclic, transform=ccrs.PlateCarree(), colors="w", norm=norm1)
img1 = ax1.contourf(lons, lats, d1_cyclic, transform=ccrs.PlateCarree(), transform_first=True, colors="w", norm=norm1)
ax1.text(0.4, 0.4, empty_message, transform=ax1.transAxes, bbox=props)

img2 = ax2.contourf(lons, lats, d2_cyclic, transform=ccrs.PlateCarree(), colors="w", norm=norm1)
img2 = ax2.contourf(lons, lats, d2_cyclic, transform=ccrs.PlateCarree(), transform_first=True, colors="w", norm=norm1)
ax2.text(0.4, 0.4, empty_message, transform=ax2.transAxes, bbox=props)
else:
img1 = ax1.contourf(lons, lats, d1_cyclic, transform=ccrs.PlateCarree(), cmap=cmap1, norm=norm1, levels=levels1)
img2 = ax2.contourf(lons, lats, d2_cyclic, transform=ccrs.PlateCarree(), cmap=cmap1, norm=norm1, levels=levels1)
img1 = ax1.contourf(lons, lats, d1_cyclic, transform=ccrs.PlateCarree(), transform_first=True, cmap=cmap1, norm=norm1, levels=levels1)
img2 = ax2.contourf(lons, lats, d2_cyclic, transform=ccrs.PlateCarree(), transform_first=True, cmap=cmap1, norm=norm1, levels=levels1)

if len(levs_diff) < 2:
img3 = ax3.contourf(lons, lats, dif_cyclic, transform=ccrs.PlateCarree(), colors="w", norm=dnorm)
img3 = ax3.contourf(lons, lats, dif_cyclic, transform=ccrs.PlateCarree(), transform_first=True, colors="w", norm=dnorm)
ax3.text(0.4, 0.4, empty_message, transform=ax3.transAxes, bbox=props)
else:
img3 = ax3.contourf(lons, lats, dif_cyclic, transform=ccrs.PlateCarree(), cmap=cmapdiff, norm=dnorm, levels=levelsdiff)
img3 = ax3.contourf(lons, lats, dif_cyclic, transform=ccrs.PlateCarree(), transform_first=True, cmap=cmapdiff, norm=dnorm, levels=levelsdiff)

#Set Main title for subplots:
st = fig.suptitle(wks.stem[:-5].replace("_"," - "), fontsize=18)
Expand Down Expand Up @@ -952,10 +952,10 @@ def plot_map_vect_and_save(wks, case_nickname, base_nickname,
# Generate vector plot:
# - contourf to show magnitude w/ colorbar
# - vectors (colored or not) to show flow --> subjective (?) choice for how to thin out vectors to be legible
img1 = ax1.contourf(lons, lats, mdl_mag, cmap='Greys', transform=ccrs.PlateCarree())
img1 = ax1.contourf(lons, lats, mdl_mag, cmap='Greys', transform=ccrs.PlateCarree(), transform_first=True,)
ax1.quiver(lons[skip], lats[skip], umdlfld[skip], vmdlfld[skip], mdl_mag.values[skip], transform=ccrs.PlateCarree(), cmap='Reds')

img2 = ax2.contourf(lons, lats, obs_mag, cmap='Greys', transform=ccrs.PlateCarree())
img2 = ax2.contourf(lons, lats, obs_mag, cmap='Greys', transform=ccrs.PlateCarree(), transform_first=True)
ax2.quiver(lons[skip], lats[skip], uobsfld[skip], vobsfld[skip], obs_mag.values[skip], transform=ccrs.PlateCarree(), cmap='Reds')

# We should think about how to do plot customization and defaults.
Expand Down Expand Up @@ -1028,7 +1028,7 @@ def plot_map_vect_and_save(wks, case_nickname, base_nickname,
fig.colorbar(img2, cax=cb_c2_ax)

# Plot vector differences:
img3 = ax3.contourf(lons, lats, diff_mag, transform=ccrs.PlateCarree(), norm=normdiff, cmap='PuOr', alpha=0.5)
img3 = ax3.contourf(lons, lats, diff_mag, transform=ccrs.PlateCarree(), transform_first=True, norm=normdiff, cmap='PuOr', alpha=0.5)
ax3.quiver(lons[skip], lats[skip], udiffld[skip], vdiffld[skip], transform=ccrs.PlateCarree())

# Add color bar to difference plot:
Expand Down Expand Up @@ -1182,10 +1182,10 @@ def plot_map_and_save(wks, case_nickname, base_nickname,

levs = np.unique(np.array(levels))
if len(levs) < 2:
img.append(ax[i].contourf(lons,lats,a,colors="w",transform=ccrs.PlateCarree()))
img.append(ax[i].contourf(lons,lats,a,colors="w",transform=ccrs.PlateCarree(),transform_first=True))
ax[i].text(0.4, 0.4, empty_message, transform=ax[i].transAxes, bbox=props)
else:
img.append(ax[i].contourf(lons, lats, a, levels=levels, cmap=cmap, norm=norm, transform=ccrs.PlateCarree(), **cp_info['contourf_opt']))
img.append(ax[i].contourf(lons, lats, a, levels=levels, cmap=cmap, norm=norm, transform=ccrs.PlateCarree(), transform_first=True, **cp_info['contourf_opt']))
#End if
ax[i].set_title("AVG: {0:.3f}".format(area_avg[i]), loc='right', fontsize=11)

Expand Down

0 comments on commit 4625c8a

Please sign in to comment.