Last active
February 8, 2022 18:07
-
-
Save raphaeldussin/6835e929386371aeb6cda7091893ed72 to your computer and use it in GitHub Desktop.
interpolate and plot temperature in ROMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cmocean | |
import cartopy.crs as ccrs | |
import matplotlib.pyplot as plt | |
# extract temperature and depth for a given time | |
snapshot = CCS2.isel(time=50) | |
temp_snapshot = snapshot['temp'] | |
depth_snapshot = snapshot['z_rho'] | |
# compute temperature at 100 meters depth using xgcm.transform | |
temp_100m = grid_ccs2.transform(temp_snapshot, 'Z', np.array([-100]), | |
target_data=depth_snapshot, | |
method='linear') | |
# plot results | |
plt.figure(figsize=[10,10]) | |
ax = plt.axes(projection=ccrs.PlateCarree()) | |
p = temp_100m.plot(ax=ax, x='lon_rho', y='lat_rho', | |
vmin=5, vmax=15, | |
cmap=cmocean.cm.thermal, | |
add_labels=False, | |
transform=ccrs.PlateCarree()) | |
# background | |
url = 'http://map1c.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi' | |
p.axes.add_wmts(url, 'BlueMarble_NextGeneration') | |
p.axes.set_extent([225,255,20,50]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment