from svrimg.utils.get_tables import get_index_table, get_svrgis_table, get_geog
from svrimg.utils.get_images import get_example
df_indexer = get_index_table("all", data_dir="../data/csvs/")
df_svrgis = get_svrgis_table(data_dir="../data/csvs/")
geog = get_geog(data_dir="../data/geog/")
gridrad = get_example()
df_indexer.head()
df_svrgis.head()
geog
gridrad
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
plt.rcParams['figure.figsize'] = 10, 10
from svrimg.utils.map_helper import radar_colormap
from matplotlib.colors import BoundaryNorm
import cartopy.crs as ccrs
import cartopy.feature as cfeature
ax = plt.axes(projection=ccrs.LambertConformal(central_longitude=-95))
ax.set_extent([-110, -70, 24, 48])
ax.coastlines()
ax.add_feature(cfeature.STATES)
cmap = radar_colormap()
classes = np.array(list(range(0, 85, 5)))
norm = BoundaryNorm(classes, ncolors=cmap.N)
ax.pcolormesh(geog.CLONG.squeeze(), geog.CLAT.squeeze(), gridrad.REFC_MAX.squeeze(),
norm=norm, cmap=cmap, transform=ccrs.PlateCarree())
df_subset = df_indexer[df_indexer.radar_time=='4/27/2011 19:00']
df_subset
from svrimg.utils.get_images import request_images
info = request_images(df_subset.index.values, "../data/tor")
info
from svrimg.utils.get_images import read_image
uid = "201104271836z000303011"
fname = info[uid]
im = read_image(fname)
plt.imshow(np.flipud(im), cmap=cmap, norm=norm)
row = df_indexer.loc[uid]
blank = np.zeros(shape=(899, 1399))
blank[row.ymin:row.ymax+1, row.xmin:row.xmax+1] = im
plt.imshow(np.flipud(blank), cmap=cmap, norm=norm)
plt.rcParams['figure.figsize'] = 10, 10
ax = plt.axes(projection=ccrs.LambertConformal(central_longitude=-95))
ax.set_extent([-110, -70, 24, 48])
ax.coastlines()
ax.add_feature(cfeature.STATES)
cmap = radar_colormap()
classes = np.array(list(range(0, 85, 5)))
norm = BoundaryNorm(classes, ncolors=cmap.N)
ax.pcolormesh(geog.CLONG.squeeze(), geog.CLAT.squeeze(), gridrad.REFC_MAX.squeeze() - blank,
norm=norm, cmap=cmap, transform=ccrs.PlateCarree())
plt.rcParams['figure.figsize'] = 10, 10
ax = plt.axes(projection=ccrs.LambertConformal(central_longitude=-95))
ax.set_extent([-110, -70, 24, 48])
ax.coastlines()
ax.add_feature(cfeature.STATES)
uid = "201104271915z000300950"
fname = info[uid]
im = read_image(fname)
row = df_indexer.loc[uid]
blank = np.zeros(shape=(899, 1399))
blank[row.ymin:row.ymax+1, row.xmin:row.xmax+1] = im
ax.pcolormesh(geog.CLONG.squeeze(), geog.CLAT.squeeze(), gridrad.REFC_MAX.squeeze() - blank,
norm=norm, cmap=cmap, transform=ccrs.PlateCarree())
from svrimg.utils.get_images import geo_read_image
plt.rcParams['figure.figsize'] = 10, 10
ax = plt.axes(projection=ccrs.LambertConformal(central_longitude=-95))
ax.set_extent([-88, -83, 33, 38])
ax.coastlines()
ax.add_feature(cfeature.STATES)
vals = geo_read_image(df_indexer, info, "201104271915z000300950")
ax.pcolormesh(geog.CLONG.squeeze(), geog.CLAT.squeeze(), vals,
norm=norm, cmap=cmap, transform=ccrs.PlateCarree())