<jupyter_start><jupyter_text>Fetching some data from WHOI's S-MODE thredds<jupyter_code># The 10/14 VIIRS SST image looks particularly good
base_url = 'http://smode.whoi.edu:8080/thredds/dodsC/satellite/'
filename = 'VIIRS_NRT/VIIRS_NRT_20211014T102000Z.nc'

# Put the data into a Dataset and select data within MAPEXTENT
sst = xr.open_dataset(base_url+filename).isel(time=0)
sst = sst.where((sst.lon>=MAPEXTENT[0])&
                (sst.lon<=MAPEXTENT[1])&
                (sst.lat>=MAPEXTENT[2])&
                (sst.lat<=MAPEXTENT[3]),
                 drop=True)
sst
# AVISO's SLA may also be useful
base_url = 'http://smode.whoi.edu:8080/thredds/dodsC/satellite/'
aviso = xr.open_dataset(base_url+'AVISO/aviso.nc').sel(time='2021-10-14T00:00:00.000000000')

# AVISO data is on a regular grid, with longitude and latitude as coordinates, 
# so we can slice the dataset easily
d = 0.25
aviso = aviso.sel(longitude=slice(MAPEXTENT[0]-d,MAPEXTENT[1]+d),
                  latitude=slice(MAPEXTENT[2]-d,MAPEXTENT[3]+d)
)
aviso<jupyter_output><empty_output><jupyter_text>A quick-and-dirty plot<jupyter_code>fig = plt.figure(figsize=(8,5))
ax = fig.add_subplot(111)

# Plot shoreline and operations area
shore.plot(x = 'longitude',
           y = 'latitude', 
           color = 'k',
           legend=False,
           ax = ax
)

opsarea.plot(x = 'longitude',
             y = 'latitude', 
             color = 'k',
             legend=False,
             ax = ax
)

# plot SST image
kwargs_t = {
    'vmin': 11.5,
    'vmax': 15.5,
    'cmap': 'Spectral_r',
    'add_colorbar': False
}

im = (sst.sea_surface_temperature-273.15).\
                plot.pcolormesh(x='lon',
                                y='lat',
                                **kwargs_t
                )

# contour absolute dynamic topography
kwargs_a = {
    'levels': np.arange(-0.2,0.201,.01),
    'colors': '0.25',
    'linewidths': 0.75
}

(aviso.adt-aviso.adt.mean()).plot.contour(**kwargs_a,ax=ax)

ax.set_xlim(*MAPEXTENT[:2])
ax.set_ylim(*MAPEXTENT[2:])

plt.colorbar(im,label=r'SST [$^\circ$C]',
             shrink=0.75,extend='both')<jupyter_output><empty_output><jupyter_text>A map with projection using cartopy<jupyter_code>projection = ccrs.PlateCarree(
                central_longitude=(MAPEXTENT[0]+MAPEXTENT[1])/2
)

map_axes = (GeoAxes,{'map_projection':projection})
trans = ccrs.PlateCarree()
fig = plt.figure(figsize=(8,7))

ax = fig.add_subplot(111, projection=projection)     

ax.set_extent(MAPEXTENT)


# Plot shoreline and operations area
opsarea.plot(x = 'longitude',
             y = 'latitude', 
             color = 'k',
             legend=False,
             ax = ax,
             transform=ccrs.PlateCarree()
)

# plot sst image
im = (sst.sea_surface_temperature-273.15).\
                plot.pcolormesh(x='lon',
                                y='lat',
                                transform=trans,
                                **kwargs_t)

# contour absolute dynamic topography
(aviso.adt-aviso.adt.mean()).plot.contour(ax=ax, 
                                          transform=trans,
                                           **kwargs_a)


# map properties (continent, labels, grid)
plot_map_properties(ax,
                    transform=ccrs.PlateCarree(),
                    continent_facecolor='0.35')

fig.colorbar(im,shrink=0.5,extend='both',
             label=r'SST [C$^\circ$]')

# Save figure in the desired extensions
[fig.savefig(os.path.join(figdir,figname+'_cartopy.'+ext),
             **figproperties) 
             for ext in extension]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13892747985551543, 'fraction_numerical': 0.03167546540705751, 'mean_word_length': 2.380281690140845, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '124423', 'license': 'MIT', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1250, 'n_words': 208, 'path': 'SSTSnapshot.ipynb', 'repo_name': 'NASA-SMODE/Maps', 'size': '3599'}