Commit 319c42f0 authored by Carl Schreck's avatar Carl Schreck
Browse files

initial commit

parents
""" Script to test out issues with subsetting maps."""
__author__ = "Carl Schreck"
__email__ = "cjschrec@ncsu.edu"
__copyright__ = "Copyright 2020, North Carolina State University"
__license__ = "BSD-3.0"
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from matplotlib.ticker import AutoLocator
min_lon = 180
max_lon = 360
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_extent([min_lon, max_lon, -90, 90], crs=ccrs.PlateCarree())
plt.savefig(f'figures/set_extent.{min_lon}.{max_lon}.png')
plt.show()
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_xlim(min_lon, max_lon)
ax.set_ylim(-90, 90)
plt.savefig(f'figures/set_xlim.{min_lon}.{max_lon}.png')
plt.show()
min_lon = 190
max_lon = 360
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_extent([min_lon, max_lon, -90, 90], crs=ccrs.PlateCarree())
plt.savefig(f'figures/set_extent.{min_lon}.{max_lon}.png')
plt.show()
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_xlim(min_lon, max_lon)
ax.set_ylim(-90, 90)
plt.savefig(f'figures/set_xlim.{min_lon}.{max_lon}.png')
plt.show()
min_lon = 170
max_lon = 360
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_extent([min_lon, max_lon, -90, 90], crs=ccrs.PlateCarree())
plt.savefig(f'figures/set_extent.{min_lon}.{max_lon}.png')
plt.show()
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_xlim(min_lon, max_lon)
ax.set_ylim(-90, 90)
plt.savefig(f'figures/set_xlim.{min_lon}.{max_lon}.png')
plt.show()
min_lon = -160
max_lon = 160
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_extent([min_lon, max_lon, -90, 90], crs=ccrs.PlateCarree())
plt.savefig(f'figures/set_extent.{min_lon}.{max_lon}.png')
plt.show()
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_xlim(min_lon, max_lon)
ax.set_ylim(-90, 90)
plt.savefig(f'figures/set_xlim.{min_lon}.{max_lon}.png')
plt.show()
min_lon = -190
max_lon = 0
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_extent([min_lon, max_lon, -90, 90], crs=ccrs.PlateCarree())
plt.savefig(f'figures/set_extent.{min_lon}.{max_lon}.png')
plt.show()
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))
ax.coastlines()
ax.gridlines()
ax.gridlines().xlabels_bottom = True
ax.gridlines().ylabels_left = True
ax.set_xlim(min_lon, max_lon)
ax.set_ylim(-90, 90)
plt.savefig(f'figures/set_xlim.{min_lon}.{max_lon}.png')
plt.show()
import cartopy.feature
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=240))
ax.set_extent([170, 360, 15, 80], crs=ccrs.PlateCarree())
# add some features to make the map a little more polished
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.OCEAN)
ax.coastlines('50m')
plt.show()
\ No newline at end of file
""" Draw a quick map of data in a file."""
__author__ = "Carl Schreck"
__email__ = "cjschrec@ncsu.edu"
__copyright__ = "Copyright 2020, North Carolina State University"
__license__ = "BSD-3.0"
import xarray as xr
import os
from matplotlib import pyplot as plt
import cartopy.crs as ccrs
import cjs # '~carl/lib/python'
cjs.tstamp('Here we go!')
# These are some parameters that could be useful to have up top
path = f'{os.environ["DATA_DIR"]}/prism/netcdf/tmin-198101.nc'
var_name = 'tmin'
ds = xr.open_dataset(path)
ax = plt.axes(projection=ccrs.AlbersEqualArea(central_longitude=360-95,
standard_parallels=(40,60)))
plt.gca().outline_patch.set_visible(False)
ax.set_extent([-118, -75, 23.5, 50.5])
shp_name = 'ne_10m_admin_1_states_provinces_lakes'
cjs.add_map(ax, shp_name, edgecolor='none', facecolor='silver', zorder=1,
usa_only=True)
cjs.add_map(ax, shp_name, edgecolor=(0.2, 0.2, 0.2), facecolor='none', zorder=3,
usa_only=True)
ds[var_name].isel(time=0).plot(ax=ax, zorder=2, transform=ccrs.PlateCarree())
plt.show()
cjs.tstamp('Thank you, come again.')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment